2 * Copyright (C) 2013-2014 Synopsys, Inc. All rights reserved.
4 * SPDX-License-Identifier: GPL-2.0+
9 DECLARE_GLOBAL_DATA_PTR
;
11 static ulong
get_sp(void)
15 asm("mov %0, sp" : "=r"(ret
) : );
19 void arch_lmb_reserve(struct lmb
*lmb
)
24 * Booting a (Linux) kernel image
26 * Allocate space for command line and board info - the
27 * address should be as high as possible within the reach of
28 * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
29 * memory, which means far enough below the current stack
33 debug("## Current stack ends at 0x%08lx ", sp
);
35 /* adjust sp by 4K to be safe */
37 lmb_reserve(lmb
, sp
, (CONFIG_SYS_SDRAM_BASE
+ gd
->ram_size
- sp
));
40 static int cleanup_before_linux(void)
44 invalidate_icache_all();
49 /* Subcommand: PREP */
50 static void boot_prep_linux(bootm_headers_t
*images
)
52 if (image_setup_linux(images
))
57 static void boot_jump_linux(bootm_headers_t
*images
, int flag
)
59 void (*kernel_entry
)(int zero
, int arch
, uint params
);
61 int fake
= (flag
& BOOTM_STATE_OS_FAKE_GO
);
63 kernel_entry
= (void (*)(int, int, uint
))images
->ep
;
65 debug("## Transferring control to Linux (at address %08lx)...\n",
66 (ulong
) kernel_entry
);
67 bootstage_mark(BOOTSTAGE_ID_RUN_OS
);
69 printf("\nStarting kernel ...%s\n\n", fake
?
70 "(fake run for tracing)" : "");
71 bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF
, "start_kernel");
73 cleanup_before_linux();
75 if (IMAGE_ENABLE_OF_LIBFDT
&& images
->ft_len
) {
77 r2
= (unsigned int)images
->ft_addr
;
80 r2
= (unsigned int)getenv("bootargs");
84 kernel_entry(r0
, 0, r2
);
87 int do_bootm_linux(int flag
, int argc
, char *argv
[], bootm_headers_t
*images
)
89 /* No need for those on ARC */
90 if ((flag
& BOOTM_STATE_OS_BD_T
) || (flag
& BOOTM_STATE_OS_CMDLINE
))
93 if (flag
& BOOTM_STATE_OS_PREP
) {
94 boot_prep_linux(images
);
98 if (flag
& (BOOTM_STATE_OS_GO
| BOOTM_STATE_OS_FAKE_GO
)) {
99 boot_jump_linux(images
, flag
);
103 boot_prep_linux(images
);
104 boot_jump_linux(images
, flag
);