From patchwork Thu Nov 20 02:56:02 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 755 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=1763607465; bh=X4jJlm0O7YYfwerj4S8zblH3zZvYerqqFNvScf6nCtA=; 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=wtYmbTBziiVkr/cfqhp4+jQ4jBa0NbxGJqwLXvsjwJ7D6CveaQNCfIw1DEpDJ90lM UBvOtQ+/rImO8kJHsPAwzPv/HG3zEGgTOjRT7N5ERIfxdL/ve/2dm0rxbdPY4hbub3 4SaF1KI9K6LhI4iETzTmzTlyrNNz+Zo/uuScm5RJ+UGvysIHY0462NolBdmBx9VqDl AWUVsIS2XZUIlVskapuQVI7nTUHHUUcL9QQI3K4v4SVsDal/4B3ogGpte460UUcGxW MmraCfuKHDQr3/BAIDdn6OTU3nY3gkCVvR4FXH27NHwqnYbIRsJKtvxV9pd7SNGaPw KFlUZu/5GhH7Q== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 2FDED686F2 for ; Wed, 19 Nov 2025 19:57:45 -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 9-pcU1mB3tfv for ; Wed, 19 Nov 2025 19:57:45 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607464; bh=X4jJlm0O7YYfwerj4S8zblH3zZvYerqqFNvScf6nCtA=; 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=ZlGB2FMrhpTtRKmA0Mq9Ux48oiZBx+3l/1c3wTthX9xnorX1+JvAN/RL8iONXBFof AEKl0S3JLxrAyRh2S5jU1MJzAtHbvxDzPVqE0Co9ZYU/f6GGQcf6s2uL4iam/TEHCu HlpHV3xEyOXUKVeIoVkjnMo6Cb1lv3iKO7O6ve2elgINQADyPHmN7R4QLgvabRVw5L yfl4wQ5zjq0SGZn8LTtgoEHXIWm8NLLOKMwQNumjm212YyX4IgvQYXr0HP5X5xlIfX 3b21392U6WqWbsTtvIaIW8wiyfaNlpXcw915Fh2bhDoKcksAL1icxwEiRWbWn/2CMo St5UPPYUcbk9A== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 4D6A068614 for ; Wed, 19 Nov 2025 19:57:44 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607461; bh=0e4imx59AEox48R/xQuKidpjZWZTK3ywqNwNUhZ71yI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=VRtnJ3jF6zvcqErC6nxbjhsf5QOa4Ki7EY/FhCpquwtwEZjNQ4OALg5MbFaVVjjcA Xnk1axD98dFvBQHoY7VlQ2cn8sQpZVwd5Cs2r+taF5sy3eTrRWRfCasCRzhNUQhfuK FFU5hOF2fk5XcvpjJ9OBtuiQdB8cwKFY7M7gTR0CBc/rCJoUZ2ENshpUjmZxnloxfJ Va4tyEMA01warV900P4dfsyd0C0VjF6ctz/rTw+rynqhKIvA2cWu9YGpAe2S2lMr3M ihUPCsn63kGvLQKMBwQ/mT8b4oqLHozB2dsFmnlmmAbJb/digumsU5y8uiv2GG7MFd ECGfuNMptAxIQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 9F72B68657; Wed, 19 Nov 2025 19:57:41 -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 UWoEcLmAh1Nk; Wed, 19 Nov 2025 19:57:41 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607460; bh=pb7ADZKP8Wp7GlRVjp7nbVioL5HvUNmBoznwf4L/Mv8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YyIayzIgynqXSUPGCKKDCP0VQ7bHjULRZH+T/HM2JWmzCcvm5ffnedV34yUXll8n7 ZR25Jitd+tOw1sPNo6KvQUZ6771pbO43bzYa0a0tWLtjyOwSHYpYnO7fnpldnsvm+l yDF3qtUH6rnESlKWDNAP/e+1ZDxLoh/SWYcyOmpspuv6h/gAv0Y5nS32Wkt+Q8lC0O SG+xhrXZdzyiMBAOxv/adZ5tPDW6iU0aw69ZPbV1nqy0xH7OHxwe9Q7nAsxK7wgoE9 XkVxjapep08hJGXAim/imFiJTsP1JCmu8pNSoJBauTop8UKXRB42qOT0Isvb/jUF46 SnGa9Vt/fNJsg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6EFE35E7DA; Wed, 19 Nov 2025 19:57:40 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:56:02 -0700 Message-ID: <20251120025614.2215587-28-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: QYYAHQTDR75FY5MDCSEAIXO2X5UHQQHM X-Message-ID-Hash: QYYAHQTDR75FY5MDCSEAIXO2X5UHQQHM 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 27/30] fit: Add a helper for address printing 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 Add emit_addr() to handle printing load an entry addresses. The helper takes a 'valid' boolean parameter to determine whether to print the address value or 'unavailable'. Combine the two separate if() blocks for the load address. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 42 ++++++++++++++++++++++++------------------ 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index 069afbe8567..70199a34c18 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -179,6 +179,26 @@ static void emit_desc(struct fit_print_ctx *ctx, int noffset, emit_label_val(ctx, label, ret ? "unavailable" : desc); } +/** + * emit_addr() - print an address property + * @ctx: pointer to FIT print context + * @label: label string to use when printing + * @addr: address value to print + * @valid: true if the address is valid, false to print "unavailable" + * + * Prints an address with the given label. If valid is false, prints + * "unavailable" instead of the address value. + */ +static void emit_addr(struct fit_print_ctx *ctx, const char *label, ulong addr, + bool valid) +{ + emit_label(ctx, label); + if (valid) + printf("0x%08lx\n", addr); + else + printf("unavailable\n"); +} + /** * fit_image_print_data() - prints out the hash node details * @ctx: pointer to FIT print context @@ -335,30 +355,16 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) if (type == IH_TYPE_KERNEL || type == IH_TYPE_STANDALONE || type == IH_TYPE_FIRMWARE || type == IH_TYPE_RAMDISK || - type == IH_TYPE_FPGA) { + type == IH_TYPE_FPGA || type == IH_TYPE_FLATDT) { ret = fit_image_get_load(fit, image_noffset, &load); - emit_label(ctx, "Load Address"); - if (ret) - printf("unavailable\n"); - else - printf("0x%08lx\n", load); - } - - /* optional load address for FDT */ - if (type == IH_TYPE_FLATDT && - !fit_image_get_load(fit, image_noffset, &load)) { - emit_label(ctx, "Load Address"); - printf("0x%08lx\n", load); + if ((type != IH_TYPE_FLATDT) || !ret) + emit_addr(ctx, "Load Address", load, !ret); } if (type == IH_TYPE_KERNEL || type == IH_TYPE_STANDALONE || type == IH_TYPE_RAMDISK) { ret = fit_image_get_entry(fit, image_noffset, &entry); - emit_label(ctx, "Entry Point"); - if (ret) - printf("unavailable\n"); - else - printf("0x%08lx\n", entry); + emit_addr(ctx, "Entry Point", entry, !ret); } /* Process all hash subnodes of the component image node */