From patchwork Thu Nov 20 02:55:50 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 744 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=1763607433; bh=2RucJaTVPL+rlo+QUVp/nnDSkWcMVkXPjFQD+5YV+NM=; 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=avIr0oMT69agfqzKMoZ30dj+h9qPkee97bkz8A24FxTrxbkZJgToPe3QyEcmRks+X fudBY9i5y0XR7saI4S9XfeRNaHb1JBI5K2S4W2j9L3D5fleml46VZfjsTCrjHmQeQJ +MWmvvXwwTyIAptgQG+SbCLanM3v2DpJlkiqdkX+rPHKipw8WnqO0XCYK551pWqfpS zeIbGh6Z7801NKh/PYrWIE0jbF0E77lh6pjuhk2fW6hoX3vKWhCKdS+/txNmvrxB9u 0GMBOAcHkUBb81ECinC0IegoM89GPdi81WQwsVQ/SktGYYmlKLVTI+WlBv3FVH6v/m B8MPAZT8sDuZA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 5C1AD686DF for ; Wed, 19 Nov 2025 19:57:13 -0700 (MST) 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 P2PuejtrBd0u for ; Wed, 19 Nov 2025 19:57:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607433; bh=2RucJaTVPL+rlo+QUVp/nnDSkWcMVkXPjFQD+5YV+NM=; 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=avIr0oMT69agfqzKMoZ30dj+h9qPkee97bkz8A24FxTrxbkZJgToPe3QyEcmRks+X fudBY9i5y0XR7saI4S9XfeRNaHb1JBI5K2S4W2j9L3D5fleml46VZfjsTCrjHmQeQJ +MWmvvXwwTyIAptgQG+SbCLanM3v2DpJlkiqdkX+rPHKipw8WnqO0XCYK551pWqfpS zeIbGh6Z7801NKh/PYrWIE0jbF0E77lh6pjuhk2fW6hoX3vKWhCKdS+/txNmvrxB9u 0GMBOAcHkUBb81ECinC0IegoM89GPdi81WQwsVQ/SktGYYmlKLVTI+WlBv3FVH6v/m B8MPAZT8sDuZA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4443F68657 for ; Wed, 19 Nov 2025 19:57:13 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607429; bh=Q8CTifE/x8EPaC32lHk17Mxh4dbL+mZTQGYno9B7Iyg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=M1fxhp0l9H1N9MTd6NknEZh0fJhewMVaQG9+7aPXEbfc9B1GdWvGgfFI029gvyE+Q 9DmplDVhZ4GoPZsuLDeSxJb6p/ygemi6M1RP9kNLSNhs4CpYciEZjS7EQNj2L94qsI GH6lRGE52Jv/uPDWksKf8wVXc0I3pcTYGIJlMHzyM4jTMUKhvvQVVnXMNplfbwoNP5 CIuyM2T6prFjN/JfZPWbFJvw/fVkeTIMuhFBInp7EQXVNx4l+MtznRvIujsTIRQzfp EeA0ZhiwoBBBUCqlgae4Qu0noMj1UI7QdFfPuG0g89/asFbMI9eO9Y8u1s3TW4Vbrx 62hLQ/ml7EHYw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 669F7686C9; Wed, 19 Nov 2025 19:57:09 -0700 (MST) 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 U1CwdoSQ0n-L; Wed, 19 Nov 2025 19:57:09 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607422; bh=OzEV0O7CLWp+bBVgxetbJU1eIct5QGqEvLDMou5/FkQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JqirsP+/FlVifLr68+1+ynhSXjGiF578DzPchVILkicZ5E2WJI6LqZhCFADvBeAu4 bFu9Cc6/VUy5U2FPCs5KvPPPNPvTrJQSLdWeXFmD3Ob+M2jAFm6ieE3YGyD9/xNW9e E4qpTgZgp+gTfP3N74fmhEdC6rIAdKQ3pJhYWrP1S0mVjMUBMLkantt/OelOgHtJiO Vq1nZs8UvcIpjo0z0v96TeDn7Ad4RIKMHfmLLWuFWJ1A6RkLZ8n/Blmey0bcDYQ3L3 F/AUkdabVDBFxiDuX4sj/8ObUPLarh3zfIn/wdyFq8P99kmpA3AjQJMm24Kk0Vsq7W 7RXg8TpsoPhJw== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 83A245E7DA; Wed, 19 Nov 2025 19:57:02 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:50 -0700 Message-ID: <20251120025614.2215587-16-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: KABQOQSWWPTCFPSKXAFXXXHNIRERTX6B X-Message-ID-Hash: KABQOQSWWPTCFPSKXAFXXXHNIRERTX6B 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 , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 15/30] fit: Put the indent string into print context 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 Move the indent string into struct fit_print_ctx so it is available to the printing functions. This avoids having to pass it as a separate parameter. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 54 +++++++++++++++++++++++++++++------------------ boot/image-fit.c | 4 ++-- include/image.h | 18 ++++++++++------ tools/fit_image.c | 4 ++-- 4 files changed, 49 insertions(+), 31 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index bb6dc140e34..07454dcf5cf 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -28,19 +28,21 @@ * fit_print_init() - initialize FIT print context * @ctx: pointer to FIT print context to initialize * @fit: pointer to the FIT format image header + * @indent: indentation string for printing * * This initializes a fit_print_ctx structure with the given FIT image. */ -void fit_print_init(struct fit_print_ctx *ctx, const void *fit) +void fit_print_init(struct fit_print_ctx *ctx, const void *fit, + const char *indent) { ctx->fit = fit; + ctx->indent = indent; } /** * fit_image_print_data() - prints out the hash node details * @ctx: pointer to FIT print context * @noffset: offset of the hash node - * @p: pointer to prefix string * @type: Type of information to print ("hash" or "sign") * * fit_image_print_data() lists properties for the processed hash node @@ -52,9 +54,10 @@ void fit_print_init(struct fit_print_ctx *ctx, const void *fit) * no returned results */ static void fit_image_print_data(struct fit_print_ctx *ctx, int noffset, - const char *p, const char *type) + const char *type) { const char *keyname, *padding, *algo; + const char *p = ctx->indent; const void *fit = ctx->fit; int value_len, ret, i; uint8_t *value; @@ -103,7 +106,6 @@ static void fit_image_print_data(struct fit_print_ctx *ctx, int noffset, * fit_image_print_verification_data() - prints out the hash/signature details * @ctx: pointer to FIT print context * @noffset: offset of the hash or signature node - * @p: pointer to prefix string * * This lists properties for the processed hash node * @@ -111,7 +113,7 @@ static void fit_image_print_data(struct fit_print_ctx *ctx, int noffset, * no returned results */ static void fit_image_print_verification_data(struct fit_print_ctx *ctx, - int noffset, const char *p) + int noffset) { const void *fit = ctx->fit; const char *name; @@ -123,14 +125,30 @@ static void fit_image_print_verification_data(struct fit_print_ctx *ctx, */ name = fit_get_name(fit, noffset); if (!strncmp(name, FIT_HASH_NODENAME, strlen(FIT_HASH_NODENAME))) - fit_image_print_data(ctx, noffset, p, "Hash"); + fit_image_print_data(ctx, noffset, "Hash"); else if (!strncmp(name, FIT_SIG_NODENAME, strlen(FIT_SIG_NODENAME))) - fit_image_print_data(ctx, noffset, p, "Sign"); + fit_image_print_data(ctx, noffset, "Sign"); } -void fit_image_print(struct fit_print_ctx *ctx, int image_noffset, const char *p) +/** + * fit_image_print - prints out the FIT component image details + * @ctx: pointer to FIT print context + * @image_noffset: offset of the component image node + * @p: pointer to prefix string + * + * fit_image_print() lists all mandatory properties for the processed component + * image. If present, hash nodes are printed out as well. Load + * address for images of type firmware is also printed out. Since the load + * address is not mandatory for firmware images, it will be output as + * "unavailable" when not present. + * + * returns: + * no returned results + */ +void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) { const void *fit = ctx->fit; + const char *p = ctx->indent; uint8_t type, arch, os, comp = IH_COMP_NONE; const char *desc; size_t size; @@ -230,7 +248,7 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset, const char *p noffset = fdt_next_node(fit, noffset, &ndepth)) { if (ndepth == 1) { /* Direct child node of the component image node */ - fit_image_print_verification_data(ctx, noffset, p); + fit_image_print_verification_data(ctx, noffset); } } } @@ -239,7 +257,6 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset, const char *p * fit_conf_print - prints out the FIT configuration details * @ctx: pointer to FIT print context * @noffset: offset of the configuration node - * @p: pointer to prefix string * * fit_conf_print() lists all mandatory properties for the processed * configuration node. @@ -247,10 +264,10 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset, const char *p * returns: * no returned results */ -static void fit_conf_print(struct fit_print_ctx *ctx, int noffset, - const char *p) +static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) { const void *fit = ctx->fit; + const char *p = ctx->indent; const char *uname, *desc; int ret, ndepth, i; @@ -321,7 +338,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset, noffset = fdt_next_node(fit, noffset, &ndepth)) { if (ndepth == 1) { /* Direct child node of the component config node */ - fit_image_print_verification_data(ctx, noffset, p); + fit_image_print_verification_data(ctx, noffset); } } } @@ -329,6 +346,7 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset, void fit_print(struct fit_print_ctx *ctx) { const void *fit = ctx->fit; + const char *p = ctx->indent; const char *desc; char *uname; int images_noffset; @@ -337,12 +355,8 @@ void fit_print(struct fit_print_ctx *ctx) int ndepth; int count = 0; int ret; - const char *p; time_t timestamp; - /* Indent string is defined in header image.h */ - p = IMAGE_INDENT_STRING; - /* Root node properties */ ret = fit_get_desc(fit, 0, &desc); printf("%sFIT description: ", p); @@ -381,7 +395,7 @@ void fit_print(struct fit_print_ctx *ctx) printf("%s Image %u (%s)\n", p, count++, fit_get_name(fit, noffset)); - fit_image_print(ctx, noffset, p); + fit_image_print(ctx, noffset); } } @@ -411,7 +425,7 @@ void fit_print(struct fit_print_ctx *ctx) printf("%s Configuration %u (%s)\n", p, count++, fit_get_name(fit, noffset)); - fit_conf_print(ctx, noffset, p); + fit_conf_print(ctx, noffset); } } } @@ -420,6 +434,6 @@ void fit_print_contents(const void *fit) { struct fit_print_ctx ctx; - fit_print_init(&ctx, fit); + fit_print_init(&ctx, fit, IMAGE_INDENT_STRING); fit_print(&ctx); } diff --git a/boot/image-fit.c b/boot/image-fit.c index ed77a5e09c5..bb8a96fe39e 100644 --- a/boot/image-fit.c +++ b/boot/image-fit.c @@ -1557,8 +1557,8 @@ static int print_and_verify(const void *fit, int rd_noffset, int verify) { struct fit_print_ctx ctx; - fit_print_init(&ctx, fit); - fit_image_print(&ctx, rd_noffset, " "); + fit_print_init(&ctx, fit, " "); + fit_image_print(&ctx, rd_noffset); if (verify) { puts(" Verifying Hash Integrity ... "); diff --git a/include/image.h b/include/image.h index 9b5a1815df9..7a5ad29a3ec 100644 --- a/include/image.h +++ b/include/image.h @@ -1202,9 +1202,11 @@ int fit_get_subimage_count(const void *fit, int images_noffset); /** * struct fit_print_ctx - context for FIT printing * @fit: pointer to the FIT format image header + * @indent: indentation string for printing */ struct fit_print_ctx { const void *fit; + const char *indent; }; #if CONFIG_IS_ENABLED(FIT_PRINT) @@ -1213,10 +1215,12 @@ struct fit_print_ctx { * fit_print_init() - initialize FIT print context * @ctx: pointer to FIT print context to initialize * @fit: pointer to the FIT format image header + * @indent: indentation string for printing * * This inits a fit_print_ctx structure with the given FIT image. */ -void fit_print_init(struct fit_print_ctx *ctx, const void *fit); +void fit_print_init(struct fit_print_ctx *ctx, const void *fit, + const char *indent); /** * fit_print() - prints out the contents of the FIT format image @@ -1231,10 +1235,9 @@ void fit_print_init(struct fit_print_ctx *ctx, const void *fit); void fit_print(struct fit_print_ctx *ctx); /** - * fit_image_print - prints out the FIT component image details + * fit_image_print() - prints out the FIT component image details * @ctx: pointer to FIT print context * @noffset: offset of the component image node - * @p: pointer to prefix string * * fit_image_print() lists all mandatory properties for the processed component * image. If present, hash nodes are printed out as well. Load @@ -1245,7 +1248,7 @@ void fit_print(struct fit_print_ctx *ctx); * returns: * no returned results */ -void fit_image_print(struct fit_print_ctx *ctx, int noffset, const char *p); +void fit_image_print(struct fit_print_ctx *ctx, int noffset); /** * fit_print_contents() - prints out the contents of the FIT format image @@ -1263,11 +1266,12 @@ void fit_print_contents(const void *fit); #else /* !FIT_PRINT */ -static inline void fit_print_init(struct fit_print_ctx *ctx, const void *fit) {} -static inline void fit_print(const void *fit) {} -static inline void fit_image_print(const void *fit, int noffset, const char *p) +static inline void fit_print_init(struct fit_print_ctx *ctx, const void *fit, + const char *indent) { } +static inline void fit_print(const void *fit) {} +static inline void fit_image_print(const void *fit, int noffset) {} static inline void fit_print_contents(const void *fit) {} #endif diff --git a/tools/fit_image.c b/tools/fit_image.c index 017a2d212e9..10815e8f4d3 100644 --- a/tools/fit_image.c +++ b/tools/fit_image.c @@ -976,8 +976,8 @@ static int fit_extract_contents(void *ptr, struct imgtool *itl) printf("Extracted:\n%s Image %u (%s)\n", p, count, fit_get_name(fit, noffset)); - fit_print_init(&ctx, fit); - fit_image_print(&ctx, noffset, p); + fit_print_init(&ctx, fit, p); + fit_image_print(&ctx, noffset); return fit_image_extract(fit, noffset, itl->outfile);