From patchwork Tue Sep 30 23:25:40 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 454 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=1759274799; bh=LMKDM6msKudUVoYl2XYL1b9zQP/78bn9j96jJiW2xxI=; 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=QD0DvJrgfMSW0MqBaoJOSXCVYAK2rxD/kA2l8WmaarDfh+Dq84PGxs3LNTUrwKP/T BtGzEt71/2weuNf0WBSsX9RPW2XHFf2eiGcwSW0dBE41UbUiS4h8w74+No0o8UlbIO 9YPRvZ08pG2P/tE/iR+4o4H++eNkBHyzfZD/CGxjWxH9TNCUN9BDW1vi5soy+ASE7f axZm15n41nBpRzf8fHQkbDfMrDIz8KLaVJA7CiQsI8ZlcNSvt8OwOnwI0tnTOtXDHj y5p8sTm0XOCr0ry+4lPMqk9JtuB4XnRkJABGSXel7CnE8SgRGSTljn2o1Onb5oo+YO re1BIVOX4Ccog== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 006D067E7F for ; Tue, 30 Sep 2025 17:26:39 -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 4zqy9_GwGGB2 for ; Tue, 30 Sep 2025 17:26:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274798; bh=LMKDM6msKudUVoYl2XYL1b9zQP/78bn9j96jJiW2xxI=; 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=UBm9IbHwQFOA56uNQOtK1raS4eoC4/xRJVo8EOKkRtxRKh/is5wD0CCT6Tgj+SZn5 /Vfvv3NIYZwKb/W8+2ekO8qUZKhzGMgoJ3lwNl8M3O9C8AeSUu8g+Xn7RFfScQxz2w QoLIXfvttySOyFh/beQVheBxOa/rZsJYCBm6+p4zxU/Odwnhk4Dgj8fSzvSVu5zl6v sp/EDk8aij0rgtCp4Enl72ETYYReDYA+tdHXYNkjbK6d6lejUzQwqDJmHf86gptuAe yghP/cIiEQNKUSwQL72p3oxxkbkki5QM3ux7uwlLMd6G9OoNgbVWiDe7eES+EM+yHF ZY5tc9399Ma/Q== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id E428367B7A for ; Tue, 30 Sep 2025 17:26:38 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274796; bh=WsDwlTgzoK92oXPRhlItLsGSydrUjzsAt3rEzzHiQjk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nczARrSQE0wYn6Klad8lfe0LInF5br+6S7cizVmAXoakrxKekF9bXmF9+1npFQ7rn T56vayocrskITXm3b3d3edTgWAykE2p7i4SfLdcYY48OJFgBRCpfy4kDYpAbs91mFe idKvpYIufI/tCQ4Wb7W9262GhO+xVf3n6pLdfxn0vZNoZssleEZD1IZoE1FEFV+45e 5f9KQDiD3muqrMwFsgnrTWMPGNMwf0Uo7s9QYgkSTFF8Y3zTuK2fQ7d+bIeuCOyVM+ COBsseKpYXH+ezgZezwTXt0hmt9RNOtTZveLRW8KdbqX8FDJrcTA4QUMQ2U/fMN/0j gsRCQzWp6KwHg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id EEB4167B5E; Tue, 30 Sep 2025 17:26:36 -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 U30olA0Bdqbi; Tue, 30 Sep 2025 17:26:36 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1759274792; bh=+U4vy9bN6PmEviqfQG6N9SSL02RAncYWfiakC3JZHuE=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=qQyrzXSRjAW3FUWBw4Kf3gfqnM9xOd5heXH/2It2t9yTby8XfJNByLY9zQRTXqbKB NDuIayYYqPOlZLGKrYlrFlXJ7sx5YPwyhVwVwk/P9hnsTN6wXxBu/cJCeuEN12nCLO JmD+ThgqTcPhk/qbOMiFBL5MpHEMO1ESKk8gnPurle+uWwG/hrempSRxXoe+Lco17+ QMBGizJisUrjdf16ZO8m8CEeCX9xcBBVn3j/ivdmFStsQ7aCIA08u3CTmnG9eSaepP Xdj5jrduGtWv+IBV6h+9f2UnlAimyboyxG5k6M/qm8fgz2LA72jW03BbK9WK8U/vHe 6CzZJbXI/wdXw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 77A5967E2E; Tue, 30 Sep 2025 17:26:32 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Tue, 30 Sep 2025 17:25:40 -0600 Message-ID: <20250930232611.1564850-4-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20250930232611.1564850-1-sjg@u-boot.org> References: <20250930232611.1564850-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 65UOXXFXPQEBGYSXDC6FAR3DZUKBZFGW X-Message-ID-Hash: 65UOXXFXPQEBGYSXDC6FAR3DZUKBZFGW 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 v2 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 --- 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 79be94960e7..de86f196503 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -56,6 +56,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 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