]> Git Repo - J-u-boot.git/blobdiff - cmd/booti.c
Merge patch series "Resolve issues with booting distros on x86"
[J-u-boot.git] / cmd / booti.c
index bfc07428e6eb883f644710f45d4f67e93760f6aa..898df0f8896bfb728422b372436eb7361a2c89bf 100644 (file)
@@ -12,6 +12,7 @@
 #include <lmb.h>
 #include <log.h>
 #include <mapmem.h>
+#include <asm/global_data.h>
 #include <linux/kernel.h>
 #include <linux/sizes.h>
 
@@ -19,9 +20,9 @@ DECLARE_GLOBAL_DATA_PTR;
 /*
  * Image booting support
  */
-static int booti_start(struct cmd_tbl *cmdtp, int flag, int argc,
-                      char *const argv[], bootm_headers_t *images)
+static int booti_start(struct bootm_info *bmi)
 {
+       struct bootm_headers *images = bmi->images;
        int ret;
        ulong ld;
        ulong relocated_addr;
@@ -33,16 +34,15 @@ static int booti_start(struct cmd_tbl *cmdtp, int flag, int argc,
        unsigned long decomp_len;
        int ctype;
 
-       ret = do_bootm_states(cmdtp, flag, argc, argv, BOOTM_STATE_START,
-                             images, 1);
+       ret = bootm_run_states(bmi, BOOTM_STATE_START);
 
        /* Setup Linux kernel Image entry point */
-       if (!argc) {
+       if (!bmi->addr_img) {
                ld = image_load_addr;
                debug("*  kernel: default image load address = 0x%08lx\n",
                                image_load_addr);
        } else {
-               ld = simple_strtoul(argv[0], NULL, 16);
+               ld = hextoul(bmi->addr_img, NULL);
                debug("*  kernel: cmdline image address = 0x%08lx\n", ld);
        }
 
@@ -74,12 +74,13 @@ static int booti_start(struct cmd_tbl *cmdtp, int flag, int argc,
        unmap_sysmem((void *)ld);
 
        ret = booti_setup(ld, &relocated_addr, &image_size, false);
-       if (ret != 0)
+       if (ret || IS_ENABLED(CONFIG_SANDBOX))
                return 1;
 
        /* Handle BOOTM_STATE_LOADOS */
        if (relocated_addr != ld) {
-               debug("Moving Image from 0x%lx to 0x%lx\n", ld, relocated_addr);
+               printf("Moving Image from 0x%lx to 0x%lx, end=%lx\n", ld,
+                      relocated_addr, relocated_addr + image_size);
                memmove((void *)relocated_addr, (void *)ld, image_size);
        }
 
@@ -93,7 +94,8 @@ static int booti_start(struct cmd_tbl *cmdtp, int flag, int argc,
         * Handle the BOOTM_STATE_FINDOTHER state ourselves as we do not
         * have a header that provide this informaiton.
         */
-       if (bootm_find_images(flag, argc, argv, relocated_addr, image_size))
+       if (bootm_find_images(image_load_addr, bmi->conf_ramdisk, bmi->conf_fdt,
+                             relocated_addr, image_size))
                return 1;
 
        return 0;
@@ -101,12 +103,25 @@ static int booti_start(struct cmd_tbl *cmdtp, int flag, int argc,
 
 int do_booti(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
+       struct bootm_info bmi;
+       int states;
        int ret;
 
        /* Consume 'booti' */
        argc--; argv++;
 
-       if (booti_start(cmdtp, flag, argc, argv, &images))
+       bootm_init(&bmi);
+       if (argc)
+               bmi.addr_img = argv[0];
+       if (argc > 1)
+               bmi.conf_ramdisk = argv[1];
+       if (argc > 2)
+               bmi.conf_fdt = argv[2];
+       bmi.boot_progress = true;
+       bmi.cmd_name = "booti";
+       /* do not set up argc and argv[] since nothing uses them */
+
+       if (booti_start(&bmi))
                return 1;
 
        /*
@@ -116,24 +131,22 @@ int do_booti(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
        bootm_disable_interrupts();
 
        images.os.os = IH_OS_LINUX;
-#ifdef CONFIG_RISCV_SMODE
-       images.os.arch = IH_ARCH_RISCV;
-#elif CONFIG_ARM64
-       images.os.arch = IH_ARCH_ARM64;
-#endif
-       ret = do_bootm_states(cmdtp, flag, argc, argv,
-#ifdef CONFIG_SYS_BOOT_RAMDISK_HIGH
-                             BOOTM_STATE_RAMDISK |
-#endif
-                             BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
-                             BOOTM_STATE_OS_GO,
-                             &images, 1);
+       if (IS_ENABLED(CONFIG_RISCV_SMODE))
+               images.os.arch = IH_ARCH_RISCV;
+       else if (IS_ENABLED(CONFIG_ARM64))
+               images.os.arch = IH_ARCH_ARM64;
+
+       states = BOOTM_STATE_MEASURE | BOOTM_STATE_OS_PREP |
+               BOOTM_STATE_OS_FAKE_GO | BOOTM_STATE_OS_GO;
+       if (IS_ENABLED(CONFIG_SYS_BOOT_RAMDISK_HIGH))
+               states |= BOOTM_STATE_RAMDISK;
+
+       ret = bootm_run_states(&bmi, states);
 
        return ret;
 }
 
-#ifdef CONFIG_SYS_LONGHELP
-static char booti_help_text[] =
+U_BOOT_LONGHELP(booti,
        "[addr [initrd[:size]] [fdt]]\n"
        "    - boot Linux flat or compressed 'Image' stored at 'addr'\n"
        "\tThe argument 'initrd' is optional and specifies the address\n"
@@ -149,8 +162,7 @@ static char booti_help_text[] =
        "\tis required. To boot a kernel with a device-tree blob but\n"
        "\twithout an initrd image, use a '-' for the initrd argument.\n"
 #endif
-       "";
-#endif
+       );
 
 U_BOOT_CMD(
        booti,  CONFIG_SYS_MAXARGS,     1,      do_booti,
This page took 0.028791 seconds and 4 git commands to generate.