1 // SPDX-License-Identifier: GPL-2.0+
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
14 #include <u-boot/zlib.h>
17 #include <asm/byteorder.h>
18 #ifdef CONFIG_SHOW_BOOT_PROGRESS
19 # include <status_led.h>
22 DECLARE_GLOBAL_DATA_PTR;
26 #define LINUX_MAX_ENVS 256
27 #define LINUX_MAX_ARGS 256
29 static ulong get_sp (void);
30 static void set_clocks_in_mhz (struct bd_info *kbd);
32 void arch_lmb_reserve(struct lmb *lmb)
37 * Booting a (Linux) kernel image
39 * Allocate space for command line and board info - the
40 * address should be as high as possible within the reach of
41 * the kernel (see CONFIG_SYS_BOOTMAPSZ settings), but in unused
42 * memory, which means far enough below the current stack
46 debug ("## Current stack ends at 0x%08lx ", sp);
48 /* adjust sp by 1K to be safe */
50 lmb_reserve(lmb, sp, (CONFIG_SYS_SDRAM_BASE + gd->ram_size - sp));
53 int do_bootm_linux(int flag, int argc, char *const argv[],
54 bootm_headers_t *images)
58 void (*kernel) (struct bd_info *, ulong, ulong, ulong, ulong);
59 struct lmb *lmb = &images->lmb;
62 * allow the PREP bootm subcommand, it is required for bootm to work
64 if (flag & BOOTM_STATE_OS_PREP)
67 if ((flag != 0) && (flag != BOOTM_STATE_OS_GO))
70 /* allocate space for kernel copy of board info */
71 ret = boot_get_kbd (lmb, &kbd);
73 puts("ERROR with allocation of kernel bd\n");
76 set_clocks_in_mhz(kbd);
78 ret = image_setup_linux(images);
82 kernel = (void (*)(struct bd_info *, ulong, ulong, ulong, ulong))images->ep;
84 debug("## Transferring control to Linux (at address %08lx) ...\n",
87 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
90 * Linux Kernel Parameters (passing board info data):
91 * sp+00: Ignore, side effect of using jsr to jump to kernel
92 * sp+04: ptr to board info data
93 * sp+08: initrd_start or 0 if no initrd
94 * sp+12: initrd_end - unused if initrd_start is 0
95 * sp+16: Start of command line string
96 * sp+20: End of command line string
98 (*kernel)(kbd, images->initrd_start, images->initrd_end,
99 images->cmdline_start, images->cmdline_end);
100 /* does not return */
105 static ulong get_sp (void)
109 asm("movel %%a7, %%d0\n"
110 "movel %%d0, %0\n": "=d"(sp): :"%d0");
115 static void set_clocks_in_mhz (struct bd_info *kbd)
119 s = env_get("clocks_in_mhz");
121 /* convert all clock information to MHz */
122 kbd->bi_intfreq /= 1000000L;
123 kbd->bi_busfreq /= 1000000L;