]> git.dujemihanovic.xyz Git - u-boot.git/commitdiff
bootm: Create a function to run through the bootm states
authorSimon Glass <sjg@chromium.org>
Sat, 16 Dec 2023 03:14:21 +0000 (20:14 -0700)
committerTom Rini <trini@konsulko.com>
Thu, 21 Dec 2023 21:07:52 +0000 (16:07 -0500)
In quite a few places, the bootm command is used to handle a boot. We
want these to be done without needing CONFIG_CMDLINE, so add a new
bootm_run() function to handle this.

Signed-off-by: Simon Glass <sjg@chromium.org>
Reviewed-by: Tom Rini <trini@konsulko.com>
boot/bootm.c
cmd/bootm.c
include/bootm.h

index 66b7e350aa86b870824745b8b1dee52a7e1d6184..cce8485f2d47d49a3361f595af79f6de787e3b93 100644 (file)
@@ -1123,6 +1123,23 @@ err:
        return ret;
 }
 
+int bootm_run(struct bootm_info *bmi)
+{
+       int states;
+
+       bmi->cmd_name = "bootm";
+       states = BOOTM_STATE_START | BOOTM_STATE_FINDOS | BOOTM_STATE_PRE_LOAD |
+               BOOTM_STATE_FINDOTHER | BOOTM_STATE_LOADOS |
+               BOOTM_STATE_OS_PREP | BOOTM_STATE_OS_FAKE_GO |
+               BOOTM_STATE_OS_GO | BOOTM_STATE_MEASURE;
+       if (IS_ENABLED(CONFIG_SYS_BOOT_RAMDISK_HIGH))
+               states |= BOOTM_STATE_RAMDISK;
+       if (IS_ENABLED(CONFIG_PPC) || IS_ENABLED(CONFIG_MIPS))
+               states |= BOOTM_STATE_OS_CMDLINE;
+
+       return bootm_run_states(bmi, states);
+}
+
 int bootm_boot_start(ulong addr, const char *cmdline)
 {
        char addr_str[30];
index 26d20b9118d25c7a186eaf4061acf40dff46dfb2..9737a2d28c034881dca61192bd1eeb0d30efc41f 100644 (file)
@@ -136,7 +136,6 @@ static int do_bootm_subcommand(struct cmd_tbl *cmdtp, int flag, int argc,
 int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
        struct bootm_info bmi;
-       int states;
        int ret;
 
        /* determine if we have a sub command */
@@ -157,17 +156,6 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
                        return do_bootm_subcommand(cmdtp, flag, argc, argv);
        }
 
-       states = BOOTM_STATE_START | BOOTM_STATE_FINDOS | BOOTM_STATE_PRE_LOAD |
-               BOOTM_STATE_FINDOTHER | BOOTM_STATE_LOADOS |
-               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;
-       if (IS_ENABLED(CONFIG_MEASURED_BOOT))
-               states |= BOOTM_STATE_MEASURE;
-       if (IS_ENABLED(CONFIG_PPC) || IS_ENABLED(CONFIG_MIPS))
-               states |= BOOTM_STATE_OS_CMDLINE;
-
        bootm_init(&bmi);
        if (argc)
                bmi.addr_img = argv[0];
@@ -180,7 +168,7 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
        bmi.argc = argc;
        bmi.argv = argv;
 
-       ret = bootm_run_states(&bmi, states);
+       ret = bootm_run(&bmi);
 
        return ret ? CMD_RET_FAILURE : 0;
 }
index 628d3d3e83ffb539ad0de3e5db2f3c8f1369317a..6e6b2ad8f7ef200a04b60354311b1220103e1d73 100644 (file)
@@ -150,6 +150,19 @@ int bootm_measure(struct bootm_headers *images);
  */
 int bootm_run_states(struct bootm_info *bmi, int states);
 
+/**
+ * bootm_run() - Run the entire bootm process
+ *
+ * This runs through the bootm process from start to finish, using the default
+ * set of states.
+ *
+ * This uses bootm_run_states().
+ *
+ * @bmi: bootm information
+ * Return: 0 if ok, something else on error
+ */
+int bootm_run(struct bootm_info *bmi);
+
 void arch_preboot_os(void);
 
 /*