[PATCH v2 05/17] boot: Move showing of bootflows out of the command
Simon Glass
sjg at chromium.org
Wed Oct 1 23:26:30 CEST 2025
It is helpful in tests to be able to show the bootflow that is being
examined. Move show_bootflow() into boot/ and rename it.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v2:
- Add a log_err() for an invalid state
boot/bootflow.c | 57 ++++++++++++++++++++++++++++++++++++++
cmd/bootflow.c | 68 ++--------------------------------------------
include/bootflow.h | 9 ++++++
3 files changed, 69 insertions(+), 65 deletions(-)
diff --git a/boot/bootflow.c b/boot/bootflow.c
index 4595aa55f0f..9aa9d449b7f 100644
--- a/boot/bootflow.c
+++ b/boot/bootflow.c
@@ -54,6 +54,63 @@ const char *bootflow_state_get_name(enum bootflow_state_t state)
return bootflow_state[state];
}
+/**
+ * report_bootflow_err() - Report where a bootflow failed
+ *
+ * When a bootflow does not make it to the 'loaded' state, something went wrong.
+ * Print a helpful message if there is an error
+ *
+ * @bflow: Bootflow to process
+ * @err: Error code (0 if none)
+ */
+static void report_bootflow_err(struct bootflow *bflow, int err)
+{
+ if (!err)
+ return;
+
+ /* Indent out to 'Method' */
+ printf(" ** ");
+
+ switch (bflow->state) {
+ case BOOTFLOWST_BASE:
+ printf("No media/partition found");
+ break;
+ case BOOTFLOWST_MEDIA:
+ printf("No partition found");
+ break;
+ case BOOTFLOWST_PART:
+ printf("No filesystem found");
+ break;
+ case BOOTFLOWST_FS:
+ printf("File not found");
+ break;
+ case BOOTFLOWST_FILE:
+ printf("File cannot be loaded");
+ break;
+ case BOOTFLOWST_READY:
+ printf("Ready");
+ break;
+ case BOOTFLOWST_COUNT:
+ log_err("Unexpected boot value of bootflow error %d",
+ bflow->state);
+ break;
+ }
+
+ printf(", err=%dE\n", err);
+}
+
+void bootflow_show(int index, struct bootflow *bflow, bool errors)
+{
+ const char *name = bootflow_guess_label(bflow);
+
+ printf("%3x %-11s %-6s %-9.9s %4x %-25.25s %s\n", index,
+ bflow->method ? bflow->method->name : "(none)",
+ bootflow_state_get_name(bflow->state), name, bflow->part,
+ bflow->name, bflow->fname ?: "");
+ if (errors)
+ report_bootflow_err(bflow, bflow->err);
+}
+
int bootflow_first_glob(struct bootflow **bflowp)
{
struct bootstd_priv *std;
diff --git a/cmd/bootflow.c b/cmd/bootflow.c
index 5b803d4ace5..46b2c8260d0 100644
--- a/cmd/bootflow.c
+++ b/cmd/bootflow.c
@@ -18,68 +18,6 @@
#include <log.h>
#include <mapmem.h>
-/**
- * report_bootflow_err() - Report where a bootflow failed
- *
- * When a bootflow does not make it to the 'loaded' state, something went wrong.
- * Print a helpful message if there is an error
- *
- * @bflow: Bootflow to process
- * @err: Error code (0 if none)
- */
-static void report_bootflow_err(struct bootflow *bflow, int err)
-{
- if (!err)
- return;
-
- /* Indent out to 'Method' */
- printf(" ** ");
-
- switch (bflow->state) {
- case BOOTFLOWST_BASE:
- printf("No media/partition found");
- break;
- case BOOTFLOWST_MEDIA:
- printf("No partition found");
- break;
- case BOOTFLOWST_PART:
- printf("No filesystem found");
- break;
- case BOOTFLOWST_FS:
- printf("File not found");
- break;
- case BOOTFLOWST_FILE:
- printf("File cannot be loaded");
- break;
- case BOOTFLOWST_READY:
- printf("Ready");
- break;
- case BOOTFLOWST_COUNT:
- break;
- }
-
- printf(", err=%dE\n", err);
-}
-
-/**
- * show_bootflow() - Show the status of a bootflow
- *
- * @seq: Bootflow index
- * @bflow: Bootflow to show
- * @errors: True to show the error received, if any
- */
-static void show_bootflow(int index, struct bootflow *bflow, bool errors)
-{
- const char *name = bootflow_guess_label(bflow);
-
- printf("%3x %-11s %-6s %-9.9s %4x %-25.25s %s\n", index,
- bflow->method ? bflow->method->name : "(none)",
- bootflow_state_get_name(bflow->state), name, bflow->part,
- bflow->name, bflow->fname ?: "");
- if (errors)
- report_bootflow_err(bflow, bflow->err);
-}
-
static void show_header(void)
{
printf("Seq Method State Uclass Part Name Filename\n");
@@ -233,7 +171,7 @@ static int do_bootflow_scan(struct cmd_tbl *cmdtp, int flag, int argc,
return CMD_RET_FAILURE;
}
if (list)
- show_bootflow(i, &bflow, errors);
+ bootflow_show(i, &bflow, errors);
if (!menu && boot && !bflow.err)
bootflow_run_boot(&iter, &bflow);
}
@@ -291,7 +229,7 @@ static int do_bootflow_list(struct cmd_tbl *cmdtp, int flag, int argc,
!ret;
ret = bootdev_next_bootflow(&bflow), i++) {
num_valid += bflow->state == BOOTFLOWST_READY;
- show_bootflow(i, bflow, errors);
+ bootflow_show(i, bflow, errors);
}
} else {
printf("Showing all bootflows\n");
@@ -300,7 +238,7 @@ static int do_bootflow_list(struct cmd_tbl *cmdtp, int flag, int argc,
!ret;
ret = bootflow_next_glob(&bflow), i++) {
num_valid += bflow->state == BOOTFLOWST_READY;
- show_bootflow(i, bflow, errors);
+ bootflow_show(i, bflow, errors);
}
}
show_footer(i, num_valid);
diff --git a/include/bootflow.h b/include/bootflow.h
index 657e3731f11..b1efeee3259 100644
--- a/include/bootflow.h
+++ b/include/bootflow.h
@@ -700,4 +700,13 @@ int bootflow_menu_poll(struct expo *exp, int *seqp);
*/
const char *bootflow_guess_label(const struct bootflow *bflow);
+/**
+ * bootflow_show() - Show the status of a bootflow
+ *
+ * @seq: Bootflow index
+ * @bflow: Bootflow to show
+ * @errors: True to show the error received, if any
+ */
+void bootflow_show(int index, struct bootflow *bflow, bool errors);
+
#endif
--
2.43.0
More information about the U-Boot
mailing list