1 // SPDX-License-Identifier: GPL-2.0+
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
14 #include <asm/global_data.h>
15 #include <u-boot/zlib.h>
18 #include <asm/byteorder.h>
19 #ifdef CONFIG_SHOW_BOOT_PROGRESS
20 # include <status_led.h>
23 DECLARE_GLOBAL_DATA_PTR;
27 #define LINUX_MAX_ENVS 256
28 #define LINUX_MAX_ARGS 256
30 static ulong get_sp (void);
31 static void set_clocks_in_mhz (struct bd_info *kbd);
33 void arch_lmb_reserve(struct lmb *lmb)
35 arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 1024);
38 int do_bootm_linux(int flag, int argc, char *const argv[],
39 struct bootm_headers *images)
43 void (*kernel) (struct bd_info *, ulong, ulong, ulong, ulong);
44 struct lmb *lmb = &images->lmb;
47 * allow the PREP bootm subcommand, it is required for bootm to work
49 if (flag & BOOTM_STATE_OS_PREP)
52 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
55 /* allocate space for kernel copy of board info */
56 ret = boot_get_kbd (lmb, &kbd);
58 puts("ERROR with allocation of kernel bd\n");
61 set_clocks_in_mhz(kbd);
63 if (IS_ENABLED(CONFIG_LMB)) {
64 ret = image_setup_linux(images);
69 kernel = (void (*)(struct bd_info *, ulong, ulong, ulong, ulong))images->ep;
71 debug("## Transferring control to Linux (at address %08lx) ...\n",
74 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
77 * Linux Kernel Parameters (passing board info data):
78 * sp+00: Ignore, side effect of using jsr to jump to kernel
79 * sp+04: ptr to board info data
80 * sp+08: initrd_start or 0 if no initrd
81 * sp+12: initrd_end - unused if initrd_start is 0
82 * sp+16: Start of command line string
83 * sp+20: End of command line string
85 (*kernel)(kbd, images->initrd_start, images->initrd_end,
86 images->cmdline_start, images->cmdline_end);
92 static ulong get_sp (void)
96 asm("movel %%a7, %%d0\n"
97 "movel %%d0, %0\n": "=d"(sp): :"%d0");
102 static void set_clocks_in_mhz (struct bd_info *kbd)
106 s = env_get("clocks_in_mhz");
108 /* convert all clock information to MHz */
109 kbd->bi_intfreq /= 1000000L;
110 kbd->bi_busfreq /= 1000000L;