
From: Simon Glass <sjg@chromium.org> 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@chromium.org> --- boot/bootflow.c | 55 +++++++++++++++++++++++++++++++++++++ cmd/bootflow.c | 68 ++-------------------------------------------- include/bootflow.h | 9 ++++++ 3 files changed, 67 insertions(+), 65 deletions(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index 79be94960e7..4e646202f3d 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -56,6 +56,61 @@ 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: + 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 33ed9a1cd73..c9f36a364dd 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"); @@ -240,7 +178,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); } @@ -298,7 +236,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"); @@ -307,7 +245,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 4d1f888a5a8..6f53a7d4991 100644 --- a/include/bootflow.h +++ b/include/bootflow.h @@ -740,4 +740,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