1 // SPDX-License-Identifier: GPL-2.0+
3 * (C) Copyright 2000-2009
4 * Wolfgang Denk, DENX Software Engineering, wd@denx.de.
14 #include <linux/kernel.h>
15 #include <linux/sizes.h>
18 * Image booting support
20 static int booti_start(cmd_tbl_t *cmdtp, int flag, int argc,
21 char * const argv[], bootm_headers_t *images)
28 ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START,
31 /* Setup Linux kernel Image entry point */
34 debug("* kernel: default image load address = 0x%08lx\n",
37 ld = simple_strtoul(argv[0], NULL, 16);
38 debug("* kernel: cmdline image address = 0x%08lx\n", ld);
41 ret = booti_setup(ld, &relocated_addr, &image_size, false);
45 /* Handle BOOTM_STATE_LOADOS */
46 if (relocated_addr != ld) {
47 debug("Moving Image from 0x%lx to 0x%lx\n", ld, relocated_addr);
48 memmove((void *)relocated_addr, (void *)ld, image_size);
51 images->ep = relocated_addr;
52 images->os.start = relocated_addr;
53 images->os.end = relocated_addr + image_size;
55 lmb_reserve(&images->lmb, images->ep, le32_to_cpu(image_size));
58 * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
59 * have a header that provide this informaiton.
61 if (bootm_find_images(flag, argc, argv))
67 int do_booti(cmd_tbl_t *cmdtp, int flag, int argc, char * const argv[])
74 if (booti_start(cmdtp, flag, argc, argv, &images))
78 * We are doing the BOOTM_STATE_LOADOS state ourselves, so must
79 * disable interrupts ourselves
81 bootm_disable_interrupts();
83 images.os.os = IH_OS_LINUX;
84 #ifdef CONFIG_RISCV_SMODE
85 images.os.arch = IH_ARCH_RISCV;
87 images.os.arch = IH_ARCH_ARM64;
89 ret = do_bootm_states(cmdtp, flag, argc, argv,
90 #ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
93 BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
100 #ifdef CONFIG_SYS_LONGHELP
101 static char booti_help_text[] =
102 "[addr [initrd[:size]] [fdt]]\n"
103 " - boot Linux 'Image' stored at 'addr'\n"
104 "\tThe argument 'initrd' is optional and specifies the address\n"
105 "\tof an initrd in memory. The optional parameter ':size' allows\n"
106 "\tspecifying the size of a RAW initrd.\n"
107 #if defined(CONFIG_OF_LIBFDT)
108 "\tSince booting a Linux kernel requires a flat device-tree, a\n"
109 "\tthird argument providing the address of the device-tree blob\n"
110 "\tis required. To boot a kernel with a device-tree blob but\n"
111 "\twithout an initrd image, use a '-' for the initrd argument.\n"
117 booti, CONFIG_SYS_MAXARGS, 1, do_booti,
118 "boot Linux kernel 'Image' format from memory", booti_help_text