1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2007 Michal Simek
4 * (C) Copyright 2004 Atmark Techno, Inc.
11 #include <bootstage.h>
15 #include <fdt_support.h>
20 #include <asm/cache.h>
21 #include <asm/global_data.h>
22 #include <u-boot/zlib.h>
23 #include <asm/byteorder.h>
25 DECLARE_GLOBAL_DATA_PTR;
27 static ulong get_sp(void)
31 asm("addik %0, r1, 0" : "=r"(ret) : );
35 void arch_lmb_reserve(struct lmb *lmb)
37 arch_lmb_reserve_generic(lmb, get_sp(), gd->ram_top, 4096);
40 static void boot_jump_linux(bootm_headers_t *images, int flag)
42 void (*thekernel)(char *cmdline, ulong rd, ulong dt);
43 ulong dt = (ulong)images->ft_addr;
44 ulong rd_start = images->initrd_start;
45 ulong cmdline = images->cmdline_start;
46 int fake = (flag & BOOTM_STATE_OS_FAKE_GO);
48 thekernel = (void (*)(char *, ulong, ulong))images->ep;
50 debug("## Transferring control to Linux (at address 0x%08lx) ",
52 debug("cmdline 0x%08lx, ramdisk 0x%08lx, FDT 0x%08lx...\n",
53 cmdline, rd_start, dt);
54 bootstage_mark(BOOTSTAGE_ID_RUN_OS);
56 printf("\nStarting kernel ...%s\n\n", fake ?
57 "(fake run for tracing)" : "");
58 bootstage_mark_name(BOOTSTAGE_ID_BOOTM_HANDOFF, "start_kernel");
60 #ifdef XILINX_USE_DCACHE
61 flush_cache(0, XILINX_DCACHE_BYTE_SIZE);
66 * Linux Kernel Parameters (passing device tree):
67 * r5: pointer to command line
68 * r6: pointer to ramdisk
69 * r7: pointer to the fdt, followed by the board info data
71 thekernel((char *)cmdline, rd_start, dt);
76 static void boot_prep_linux(bootm_headers_t *images)
78 if (IMAGE_ENABLE_OF_LIBFDT && images->ft_len) {
79 debug("using: FDT\n");
80 if (image_setup_linux(images)) {
81 printf("FDT creation failed! hanging...");
87 int do_bootm_linux(int flag, int argc, char *const argv[],
88 bootm_headers_t *images)
90 images->cmdline_start = (ulong)env_get("bootargs");
92 /* cmdline init is the part of 'prep' and nothing to do for 'bdt' */
93 if (flag & BOOTM_STATE_OS_BD_T || flag & BOOTM_STATE_OS_CMDLINE)
96 if (flag & BOOTM_STATE_OS_PREP) {
97 boot_prep_linux(images);
101 if (flag & (BOOTM_STATE_OS_GO | BOOTM_STATE_OS_FAKE_GO)) {
102 boot_jump_linux(images, flag);
106 boot_prep_linux(images);
107 boot_jump_linux(images, flag);