From patchwork Tue Sep 30 00:51:19 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 439 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193526; bh=d29xyp4OXC4RCHpLXV7hXtPWqIzRVBMjzD7Et2+ZXFY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=FufA123zacwTuj9j8GMfLGz6UCC5JOErBcLWOOLTcFkEcBPRWpulk7mFAgLxmOWdC Fg4VwQ0HI4AFH02xmJCsajAxKw4KpQf8auSmTcxFbhYZzhIBJPV0KuMaga8h5SwJgS 9U8yWSj5JeCnkzyZGdfGg1BhADoRhDgoeL5FezEWlmtNq/rO6LtPSUUjUNIUVOlMOZ gqATOWoSY2pQuNuTM+EaFJhVx9lGPZStaI2guWbdbj7PQhUqwWIMB1iWpAn7MHDpPn PQ/MTDDLCjCAyOqNSZ58nFNU8yJXli5N6jVPn4YZJ4AT9ZM62bGmoEZfuhd6vCK4Gv QkmGpHS3c9d9g== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id C477067E59 for ; Mon, 29 Sep 2025 18:52:06 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id BdEq0X4LviTP for ; Mon, 29 Sep 2025 18:52:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193526; bh=d29xyp4OXC4RCHpLXV7hXtPWqIzRVBMjzD7Et2+ZXFY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=FufA123zacwTuj9j8GMfLGz6UCC5JOErBcLWOOLTcFkEcBPRWpulk7mFAgLxmOWdC Fg4VwQ0HI4AFH02xmJCsajAxKw4KpQf8auSmTcxFbhYZzhIBJPV0KuMaga8h5SwJgS 9U8yWSj5JeCnkzyZGdfGg1BhADoRhDgoeL5FezEWlmtNq/rO6LtPSUUjUNIUVOlMOZ gqATOWoSY2pQuNuTM+EaFJhVx9lGPZStaI2guWbdbj7PQhUqwWIMB1iWpAn7MHDpPn PQ/MTDDLCjCAyOqNSZ58nFNU8yJXli5N6jVPn4YZJ4AT9ZM62bGmoEZfuhd6vCK4Gv QkmGpHS3c9d9g== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B3EC967E31 for ; Mon, 29 Sep 2025 18:52:06 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193524; bh=xA9OksOm/NcRzfjWkTZMUEAgSxOcq39Pl7iHlZCvpbQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lhFFOe5iN/aqD4FnecnvdeaqRic4+njbdEs3pq8Ocqqw3BegIiBPdVvzBBNSw4p6B eBeciFU6TKOgamNIpyR2pOS2dtNYcZTzKv2Z1PUiqrr+Fx5ElUVm8TXM7XJQvrVhEl BPAyiNKBszwxjVI11Fr1gg49xsmsZsWOqF9IJjR1FuOjocKlT69dsVIgy1IfiVqbQ5 lkuZ/G5YOcfV1Kvm7VGs0u16zMHaP0Ko1TZFLZQFPGiLzKelx1EA4iUn8yt6JTwA5r ed/j1eGxdgeco2NwlLWU0fDAkekZfcM1QhBfgaEzJGj9U9sER3vBra3RxUoY0GproL AawBTDaLZcOsQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id B4FDA67E31; Mon, 29 Sep 2025 18:52:04 -0600 (MDT) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id q5oxYdythcYf; Mon, 29 Sep 2025 18:52:04 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759193518; bh=6lk/OL7wYytGEai8f222pjYKuErwtiHhlOuTOSOTzrM=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=uoVrISP0Jq8EERm8qws1Kcf7zAV+lw9O/quwUankEnCCLrOrILRiv5bPJOiJS9xQp Hs7BEd1IR8zrttCKrTCngH23V0X7wG7LENaX0tGgJg2BaB3OWc69xC6Pmh2V0gMbmH qt5gOU8xwbJ5tsWOO7mjMJJ8qOSIwVwchCI6nLSxfTRoW1EMYuouILOTww72yWZpgH YQxm5/YdfmtCcN0RJZ/+KknfMMfLFqqb+bKtTL8S2aslpy5hik2453mnI0Z50C/NTl rbTEYPubIpMiLXUjTE4Drtxlc3WGBA/IvdSekpydHgxWyHNK2Z4Cp3He3rqFKAs5Lq XO6c0VwNAoqNg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 245D967E03; Mon, 29 Sep 2025 18:51:58 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Mon, 29 Sep 2025 18:51:19 -0600 Message-ID: <20250930005137.3650600-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930005137.3650600-1-sjg@u-boot.org> References: <20250930005137.3650600-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: TDUZXWCVUUIZE4V5BX6XCCLC35RKR6RU X-Message-ID-Hash: TDUZXWCVUUIZE4V5BX6XCCLC35RKR6RU X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 03/15] boot: Move showing of bootflows out of the command List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass 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 --- 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 #include -/** - * 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