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 <s...@chromium.org>
---

 boot/bootm.c    | 19 +++++++++++++++++++
 cmd/bootm.c     | 14 +-------------
 include/bootm.h | 13 +++++++++++++
 3 files changed, 33 insertions(+), 13 deletions(-)

diff --git a/boot/bootm.c b/boot/bootm.c
index 1f46bb88b38e..301ba480677d 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -1123,6 +1123,25 @@ 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;
+       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;
+
+       return bootm_run_states(bmi, states);
+}
+
 int bootm_boot_start(ulong addr, const char *cmdline)
 {
        char addr_str[30];
diff --git a/cmd/bootm.c b/cmd/bootm.c
index 68fb48f77a90..744a84d6c394 100644
--- a/cmd/bootm.c
+++ b/cmd/bootm.c
@@ -132,7 +132,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 */
@@ -153,17 +152,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;
-
        memset(&bmi, '\0', sizeof(struct bootm_info));
        if (argc)
                bmi.addr_fit = argv[0];
@@ -173,7 +161,7 @@ int do_bootm(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
                bmi.conf_fdt = argv[2];
        bmi.boot_progress = true;
        bmi.images = &images;
-       ret = bootm_run_states(&bmi, states);
+       ret = bootm_run(&bmi);
 
        return ret ? CMD_RET_FAILURE : 0;
 }
diff --git a/include/bootm.h b/include/bootm.h
index a3bef1ab88f2..ef46c085b594 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -137,6 +137,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);
 
 /*
-- 
2.43.0.rc2.451.g8631bc7472-goog

Reply via email to