From patchwork Mon Jan 4 19:48:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 1422235 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=collabora.com Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D8mQT0SMlz9sVk for ; Tue, 5 Jan 2021 06:48:33 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DBC0182652; Mon, 4 Jan 2021 20:48:19 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id EC42F82648; Mon, 4 Jan 2021 20:48:15 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [46.235.227.227]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 8D73B82573 for ; Mon, 4 Jan 2021 20:48:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sebastian.reichel@collabora.com Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 0F31A1F45003 Received: by jupiter.universe (Postfix, from userid 1000) id F2F4D4800BB; Mon, 4 Jan 2021 20:48:09 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Simon Glass , Stefano Babic , Fabio Estevam Cc: "NXP i.MX U-Boot Team" , u-boot@lists.denx.de Subject: [PATCHv3 1/2] image: cleanup pre-processor usage Date: Mon, 4 Jan 2021 20:48:03 +0100 Message-Id: <20210104194804.133428-2-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210104194804.133428-1-sebastian.reichel@collabora.com> References: <20210104194804.133428-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Replace most #ifdef checks for USE_HOSTCC and CONFIG_* with normal if instructions. Reviewed-by: Simon Glass Signed-off-by: Sebastian Reichel --- common/image-fit.c | 46 ++++++++++++++++++++-------------------------- include/image.h | 4 ++++ 2 files changed, 24 insertions(+), 26 deletions(-) diff --git a/common/image-fit.c b/common/image-fit.c index c82d4d8015f0..097cd38af05c 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -15,7 +15,6 @@ #include #else #include -#include #include #include #include @@ -28,6 +27,7 @@ DECLARE_GLOBAL_DATA_PTR; #include #include #include +#include #include #include #include @@ -486,16 +486,16 @@ void fit_image_print(const void *fit, int image_noffset, const char *p) ret = fit_image_get_data_and_size(fit, image_noffset, &data, &size); -#ifndef USE_HOSTCC - printf("%s Data Start: ", p); - if (ret) { - printf("unavailable\n"); - } else { - void *vdata = (void *)data; + if (!host_build()) { + printf("%s Data Start: ", p); + if (ret) { + printf("unavailable\n"); + } else { + void *vdata = (void *)data; - printf("0x%08lx\n", (ulong)map_to_sysmem(vdata)); + printf("0x%08lx\n", (ulong)map_to_sysmem(vdata)); + } } -#endif printf("%s Data Size: ", p); if (ret) @@ -1420,7 +1420,6 @@ int fit_all_image_verify(const void *fit) return 1; } -#ifdef CONFIG_FIT_CIPHER static int fit_image_uncipher(const void *fit, int image_noffset, void **data, size_t *size) { @@ -1444,7 +1443,6 @@ static int fit_image_uncipher(const void *fit, int image_noffset, out: return ret; } -#endif /* CONFIG_FIT_CIPHER */ /** * fit_image_check_os - check whether image node is of a given os type @@ -1486,9 +1484,8 @@ int fit_image_check_arch(const void *fit, int noffset, uint8_t arch) uint8_t image_arch; int aarch32_support = 0; -#ifdef CONFIG_ARM64_SUPPORT_AARCH32 - aarch32_support = 1; -#endif + if (IS_ENABLED(CONFIG_ARM64_SUPPORT_AARCH32)) + aarch32_support = 1; if (fit_image_get_arch(fit, noffset, &image_arch)) return 0; @@ -1977,13 +1974,13 @@ int fit_image_load(bootm_headers_t *images, ulong addr, } bootstage_mark(bootstage_id + BOOTSTAGE_SUB_CHECK_ARCH); -#if !defined(USE_HOSTCC) && !defined(CONFIG_SANDBOX) - if (!fit_image_check_target_arch(fit, noffset)) { - puts("Unsupported Architecture\n"); - bootstage_error(bootstage_id + BOOTSTAGE_SUB_CHECK_ARCH); - return -ENOEXEC; + if (!host_build() && IS_ENABLED(CONFIG_SANDBOX)) { + if (!fit_image_check_target_arch(fit, noffset)) { + puts("Unsupported Architecture\n"); + bootstage_error(bootstage_id + BOOTSTAGE_SUB_CHECK_ARCH); + return -ENOEXEC; + } } -#endif #ifndef USE_HOSTCC fit_image_get_arch(fit, noffset, &os_arch); @@ -2029,9 +2026,8 @@ int fit_image_load(bootm_headers_t *images, ulong addr, return -ENOENT; } -#ifdef CONFIG_FIT_CIPHER /* Decrypt data before uncompress/move */ - if (IMAGE_ENABLE_DECRYPT) { + if (IS_ENABLED(CONFIG_FIT_CIPHER) && IMAGE_ENABLE_DECRYPT) { puts(" Decrypting Data ... "); if (fit_image_uncipher(fit, noffset, &buf, &size)) { puts("Error\n"); @@ -2039,12 +2035,10 @@ int fit_image_load(bootm_headers_t *images, ulong addr, } puts("OK\n"); } -#endif -#if !defined(USE_HOSTCC) && defined(CONFIG_FIT_IMAGE_POST_PROCESS) /* perform any post-processing on the image data */ - board_fit_image_post_process(&buf, &size); -#endif + if (!host_build() && IS_ENABLED(CONFIG_FIT_IMAGE_POST_PROCESS)) + board_fit_image_post_process(&buf, &size); len = (ulong)size; diff --git a/include/image.h b/include/image.h index 00bc03bebece..41473dbb9cdf 100644 --- a/include/image.h +++ b/include/image.h @@ -1552,6 +1552,10 @@ int board_fit_config_name_match(const char *name); * @return no return value (failure should be handled internally) */ void board_fit_image_post_process(void **p_image, size_t *p_size); +#else +static inline void board_fit_image_post_process(void **p_image, size_t *p_size) +{ +} #endif /* CONFIG_SPL_FIT_IMAGE_POST_PROCESS */ #define FDT_ERROR ((ulong)(-1)) From patchwork Mon Jan 4 19:48:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sebastian Reichel X-Patchwork-Id: 1422236 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=collabora.com Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4D8mQh2nWhz9sVk for ; Tue, 5 Jan 2021 06:48:44 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 3DA3E8265E; Mon, 4 Jan 2021 20:48:22 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 34E4D82644; Mon, 4 Jan 2021 20:48:18 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,SPF_HELO_PASS, UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.2 Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id A969A82644 for ; Mon, 4 Jan 2021 20:48:12 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sebastian.reichel@collabora.com Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: sre) with ESMTPSA id 136E31F45044 Received: by jupiter.universe (Postfix, from userid 1000) id 05BA44800BD; Mon, 4 Jan 2021 20:48:09 +0100 (CET) From: Sebastian Reichel To: Sebastian Reichel , Simon Glass , Stefano Babic , Fabio Estevam Cc: "NXP i.MX U-Boot Team" , u-boot@lists.denx.de Subject: [PATCHv3 2/2] image: support board_fit_config_name_match Date: Mon, 4 Jan 2021 20:48:04 +0100 Message-Id: <20210104194804.133428-3-sebastian.reichel@collabora.com> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20210104194804.133428-1-sebastian.reichel@collabora.com> References: <20210104194804.133428-1-sebastian.reichel@collabora.com> MIME-Version: 1.0 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.102.3 at phobos.denx.de X-Virus-Status: Clean Support reusing board_fit_config_name_match() to automatically select a sensible default configuration for booting fitImages using 'bootm'. Reviewed-by: Simon Glass Signed-off-by: Sebastian Reichel --- common/image-fit.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/common/image-fit.c b/common/image-fit.c index 097cd38af05c..6a8787ca0aa0 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -1738,12 +1738,19 @@ int fit_conf_get_node(const void *fit, const char *conf_uname) if (conf_uname == NULL) { /* get configuration unit name from the default property */ debug("No configuration specified, trying default...\n"); - conf_uname = (char *)fdt_getprop(fit, confs_noffset, - FIT_DEFAULT_PROP, &len); - if (conf_uname == NULL) { - fit_get_debug(fit, confs_noffset, FIT_DEFAULT_PROP, - len); - return len; + if (!host_build() && IS_ENABLED(CONFIG_MULTI_DTB_FIT)) { + noffset = fit_find_config_node(fit); + if (noffset < 0) + return noffset; + conf_uname = fdt_get_name(fit, noffset, NULL); + } else { + conf_uname = (char *)fdt_getprop(fit, confs_noffset, + FIT_DEFAULT_PROP, &len); + if (conf_uname == NULL) { + fit_get_debug(fit, confs_noffset, FIT_DEFAULT_PROP, + len); + return len; + } } debug("Found default configuration: '%s'\n", conf_uname); }