In a few places, the bootz command is used to handle a boot. We want
these to be done without needing CONFIG_CMDLINE, so add a new
bootz_run() function to handle this.

Signed-off-by: Simon Glass <s...@chromium.org>
---

 boot/bootm.c    | 13 +++++++++++++
 cmd/bootz.c     |  9 ++-------
 include/bootm.h | 13 +++++++++++++
 3 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/boot/bootm.c b/boot/bootm.c
index 301ba480677d..22c6d1604176 100644
--- a/boot/bootm.c
+++ b/boot/bootm.c
@@ -1142,6 +1142,19 @@ int bootm_run(struct bootm_info *bmi)
        return bootm_run_states(bmi, states);
 }
 
+int bootz_run(struct bootm_info *bmi)
+{
+       int states;
+
+       bmi->cmd_name = "bootz";
+       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;
+
+       return bootm_run_states(bmi, states);
+}
+
 int bootm_boot_start(ulong addr, const char *cmdline)
 {
        char addr_str[30];
diff --git a/cmd/bootz.c b/cmd/bootz.c
index fa6743a71170..f03062f1cf75 100644
--- a/cmd/bootz.c
+++ b/cmd/bootz.c
@@ -75,7 +75,7 @@ static int bootz_start(struct cmd_tbl *cmdtp, int flag, int 
argc,
 int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 {
        struct bootm_info bmi;
-       int states, ret;
+       int ret;
 
        /* Consume 'bootz' */
        argc--; argv++;
@@ -102,12 +102,7 @@ int do_bootz(struct cmd_tbl *cmdtp, int flag, int argc, 
char *const argv[])
        bmi.images = &images;
        bmi.cmd_name = "bootz";
 
-       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);
+       ret = bootz_run(&bmi);
 
        return ret;
 }
diff --git a/include/bootm.h b/include/bootm.h
index ef46c085b594..d7c9486553e4 100644
--- a/include/bootm.h
+++ b/include/bootm.h
@@ -150,6 +150,19 @@ int bootm_run_states(struct bootm_info *bmi, int states);
  */
 int bootm_run(struct bootm_info *bmi);
 
+/**
+ * bootz_run() - Run the entire bootz process
+ *
+ * This runs through the bootz 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 bootz_run(struct bootm_info *bmi);
+
 void arch_preboot_os(void);
 
 /*
-- 
2.43.0.rc2.451.g8631bc7472-goog

Reply via email to