From patchwork Thu May 5 20:16:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1627244 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.a=rsa-sha256 header.s=selector1 header.b=ABi2yU8S; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KvQ3Y6PkVz9sBF for ; Fri, 6 May 2022 06:17:29 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4384383FE3; Thu, 5 May 2022 22:17:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.b="ABi2yU8S"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 686FF8400D; Thu, 5 May 2022 22:17:13 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.2 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0630.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::630]) (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 B8C0483FE3 for ; Thu, 5 May 2022 22:17:08 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dAi0JqeIbzN+cg/PdEsqUja0WJpVwmUXwr2gqHBMDu2daU4VB55MtUGjc6SEVFLWjp7UwkibRL+f3JcbkJ7Rt8a+rLwKwDMAq7pYnYnSfFEHT4ozH0zBFENxn3k7AdkR6iHacWG1XdKC7OOB3rNcfw5oUEskbc6Sz0ixGK4t0bX0Aq91QniZWB5yxiqT0LSt2kDs95NJPqqRZAKuBc0pXLImg8pH8BupMsqzgkM1GvOVtn0efJKtnfscH4feA/dlt/bir1C0pGb9A7mp1gML5z36Ti42HjSexyFcpjfGiKsaLFYcGeJerCw2aVkyMP5xmkZbJwYWBd4AYQP8eFPvUA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=xVv94sslWz7+6NAqWubrNcVcSBzfeBOR1kl+jfd+IH0=; b=Bd8wotDjmWJ/ta4njjskMITqaG9eLj6KQNjEsYvlN1YpN8eF2jRKiSlKhWD4MgbGwASISwEbKTYmN2wkiTbtT1MJ5ZNM2+gkk3633ChcA/LlZ3uj2mZqjsmmbq6kWH2SaXT54nxeMLoLhGlGpKcHLpJJq0L4EJ4wPKCNJIIvPHrt6l2EEsNkCIhb2T4iQdaA2VDFlQOa8hveAHbQ0iUMfhcXl4PqgnjaWLHZWPG1jzZP1FAiFmEa2oT0Q8aQUJQ2zxN7ejv8Dozw0QonagRZ4xYHTZMLKwSty1oBJwZ0nmtRXnPSU7dXw4I5pdTJVBXGf/T9MC2bRCyG5e3hwqnpKQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=xVv94sslWz7+6NAqWubrNcVcSBzfeBOR1kl+jfd+IH0=; b=ABi2yU8SNQrKGhuPFfzzn1MeIwUvlEu7IZ9fwmPgvOXhtsv5Lvhwi16fMvWGz4K4Eyg9RV/srUgzMM70DxzvOQ7Smfmvc2+GWCkuwss1G8JEs/m7RISZkI4qWk+0QS5zLP9QQBJy4gLXlyKvd1e2bbqtz2df5PwPX4WfIvpGr4JNh4kNES1x+Z2pFgWa3NfnanxCkccsTkqJUgj9f4U4yQOi0q57nO5hqj36bd8jnc2CEQsYR2tuBOH2r5vXhD9tzynAnXSFvFa42Lz5aV0kfw+U27YanIFUGKYoL+OZ8F2WOavZK3tLvAy8CmcIHUT4QI4/XFiZVhJNar6kcU8cXQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by DB8PR03MB5676.eurprd03.prod.outlook.com (2603:10a6:10:10b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.25; Thu, 5 May 2022 20:17:07 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c%5]) with mapi id 15.20.5206.027; Thu, 5 May 2022 20:17:07 +0000 From: Sean Anderson To: Tom Rini , u-boot@lists.denx.de Cc: Stefan Roese , Marek Vasut , Simon Glass , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= , Sean Anderson Subject: [PATCH v3 1/9] spl: Add generic spl_load function Date: Thu, 5 May 2022 16:16:47 -0400 Message-Id: <20220505201655.645692-2-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220505201655.645692-1-sean.anderson@seco.com> References: <20220505201655.645692-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR20CA0047.namprd20.prod.outlook.com (2603:10b6:208:235::16) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3fd797d1-efe5-4c38-7ff5-08da2ed43a75 X-MS-TrafficTypeDiagnostic: DB8PR03MB5676:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ejoeop1ThSsl9rAutMPpFAHpUL6AfPen68vRS3ZWMRjO9R/+rgqR2WQskrBwpb4L7xrtIYfrWfhOqB0Pifh+NWd1xswB1pVZuDP3giIc48phY5enyVVswTTMONuE290eLSy4v8YAbesaVAzkuNboZfjoMTfcR+5upXd8TSgs32Wk9DlbIunf8T9MSJyNKy/+Fzk2+5Un5yKxZzDmLfXEUXxtjtSmYgW++DNGvlkJMj2mtFzcbrjg6d8KJgCaCD7PJZyncpVGr0nLzSmR5QoGzw2hAMZJb53mxFzcoZaAaEpui56Fh971LyfpCYwQwOwWq/X+zd/uLigVzlDkYheBmYvo53AYt6mwsS5PYmKgv4fka+3MRUkuYkfA2SiljrpdiYn02r7z+f5xdCqYEvE4+OV8JbE9uIe5sNuH/KhsXzBFOpgbJ1YAQgykBsbbOKyglMHU42vW7WvPsOFZk7QPTK7mki8P9IVB/pgGxssgN7dTe1TzPcnswI0EqVmgFt9jZnkG0fQmr/I4jTwDNqjSKCvrDnMggL9dKUymsokgTNSV33/oqpy5q2JPFjAs9kw39cf/Pm7hO59aDKW+tMPQRuBZcUqhNtKuGRSMVKMJhKDNNf1uiEBL/Dvh9xGBTClwabS+5s3rl1EIDNou99rpJ0P7bmuPSLQwCRcae/vY0gX4jH4XdB7zcYerAFdYPbhDYS9GWaaCXq560EyxjupIBVdV6FPtvdT1tlfk63AQiTo= X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4972.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(86362001)(1076003)(4326008)(6512007)(54906003)(26005)(186003)(2616005)(44832011)(8676002)(83380400001)(66946007)(107886003)(66556008)(66476007)(316002)(5660300002)(38350700002)(36756003)(6486002)(38100700002)(6506007)(8936002)(508600001)(2906002)(52116002)(6666004)(41533002); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: pkZrJaZwTWoGiSGrkf8CR7eWhRxV0hkeSmE6NVSk9DM/oubelrceY2ezdEUr0+r/cBG632gxhJXYDb31EA0CcBAXdfGuTWS6lySGzmTuYVMdhMMXzbgMAiDKnAHw/VfzAul4lFcVVCfRtHTe1a3RLIpo9BrO2w2hmZV5oj30rfi/BKTyOZbxOKYbsDXIeMDRkLqwTRLYQvswsIl1kyysAVLewxWGAXxF/MYmew2iQnaaKrPJAEi5/KEz3wyAAl0faQ+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+Is0gAdTk152SMgbSXcyLONFYFtgcgcRVbdnvyTCQFweS7m4dHTsSWOkPd98pUzeTjPQgq/CstX9f3630RpgbbEGdmjTpnHSLy3+u8ticaO+86JlwFQKT5svmsfLy5vZv1HXIcWnZP2JfGwAFZnSzraV5ljjpJ14XZOqkB2ClTSqUzfXRqkpW2mrEc7UzlxQTWmeEXGajE3O8+zdnpDXmecK1+Rr9wwKopBaQ1KDBC0Y71HXV/eyqckgJhitKr31t3RHcq6YktNRwFc6F+fpM9NsChX6nNDMVnFwXtQR+XTHUdxcliTUdDewJxAoULl9nRU/2Twjg8LdPQeZPd8jTzS+H7ZH1oR8TNJ25zshm6ksBcSgJd3NoOl6mN0JUqLuwDdWweSB/uGydtj8x52iDwL/YDsbrZ475O4jyi17aZjTAP908f7B/0= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3fd797d1-efe5-4c38-7ff5-08da2ed43a75 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2022 20:17:07.6632 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LSD1ew2m48KGLo4/jvcQvAedgvbZqPbAEM8Y1kO2jElXpLW9ycfRqh7VIlG2LrI194fofdX45CFlpC9X0HpSCQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR03MB5676 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean Implementers of SPL_LOAD_IMAGE_METHOD have to correctly determine what type of image is being loaded and then call the appropriate image load function correctly. This is tricky, because some image load functions expect the whole image to already be loaded (CONFIG_SPL_LOAD_FIT_FULL), some will load the image automatically using spl_load_info.read() (CONFIG_SPL_LOAD_FIT/CONFIG_SPL_LOAD_IMX_CONTAINER), and some just parse the header and expect the caller to do the actual loading afterwards (legacy/raw images). Load methods often only support a subset of the above methods, meaning that not all image types can be used with all load methods. Further, the code to invoke these functions is duplicated between different load functions. To address this problem, this commit introduces a "spl_load" function. It aims to handle image detection and correct invocation of each of the parse/load functions. spl_simple_read is a wrapper around spl_load_info.read with get_aligned_image* functions inlined for size purposes. Additionally, we assume that bl_len is a power of 2 so we can do bitshifts instead of divisions (which is smaller and faster). Signed-off-by: Sean Anderson Reviewed-by: Stefan Roese --- Changes in v3: - Fix using ffs instead of fls - Fix using not initializing bl_len when info->filename was NULL Changes in v2: - Use reverse-xmas-tree style for locals in spl_simple_read. This is not complete, since overhead depends on bl_mask. common/spl/spl.c | 68 ++++++++++++++++++++++++++++++++++++++++++++++++ include/spl.h | 30 ++++++++++++++++++++- 2 files changed, 97 insertions(+), 1 deletion(-) diff --git a/common/spl/spl.c b/common/spl/spl.c index c9750ee163..f9a1cfc71e 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -399,6 +399,74 @@ int spl_parse_image_header(struct spl_image_info *spl_image, return 0; } +static int spl_simple_read(struct spl_load_info *info, void *buf, size_t size, + size_t offset) +{ + size_t bl_len = info->filename ? ARCH_DMA_MINALIGN : info->bl_len; + size_t bl_mask = bl_len - 1; + size_t overhead = offset & bl_mask; + size_t bl_shift = fls(bl_mask); + int ret; + + debug("%s: buf=%p size=%lx offset=%lx\n", __func__, buf, (long)size, + (long)offset); + debug("%s: bl_len=%lx bl_mask=%lx bl_shift=%lx\n", __func__, bl_len, + bl_mask, bl_shift); + + buf -= overhead; + size = (size + overhead + bl_mask) >> bl_shift; + offset = offset >> bl_shift; + + debug("info->read(info, %lx, %lx, %p)\n", (ulong)offset, (ulong)size, + buf); + ret = info->read(info, offset, size, buf); + return ret == size ? 0 : -EIO; +} + +int spl_load(struct spl_image_info *spl_image, + const struct spl_boot_device *bootdev, struct spl_load_info *info, + struct image_header *header, size_t size, size_t sector) +{ + int ret; + size_t offset = sector * info->bl_len; + + if (image_get_magic(header) == FDT_MAGIC) { + if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL)) { + void *buf; + + /* + * In order to support verifying images in the FIT, we + * need to load the whole FIT into memory. Try and + * guess how much we need to load by using the total + * size. This will fail for FITs with external data, + * but there's not much we can do about that. + */ + if (!size) + size = roundup(fdt_totalsize(header), 4); + buf = spl_get_load_buffer(0, size); + ret = spl_simple_read(info, buf, size, offset); + if (ret) + return ret; + + return spl_parse_image_header(spl_image, bootdev, buf); + } + + if (IS_ENABLED(CONFIG_SPL_LOAD_FIT)) + return spl_load_simple_fit(spl_image, info, sector, + header); + } + + if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER)) + return spl_load_imx_container(spl_image, info, sector); + + ret = spl_parse_image_header(spl_image, bootdev, header); + if (ret) + return ret; + + return spl_simple_read(info, (void *)spl_image->load_addr, + spl_image->size, offset + spl_image->offset); +} + __weak void __noreturn jump_to_image_no_args(struct spl_image_info *spl_image) { typedef void __noreturn (*image_entry_noargs_t)(void); diff --git a/include/spl.h b/include/spl.h index 6134aba857..025fffb895 100644 --- a/include/spl.h +++ b/include/spl.h @@ -237,7 +237,7 @@ struct spl_image_info { * * @dev: Pointer to the device, e.g. struct mmc * * @priv: Private data for the device - * @bl_len: Block length for reading in bytes + * @bl_len: Block length for reading in bytes; must be a power of 2 * @filename: Name of the fit image file. * @read: Function to call to read from the device */ @@ -609,6 +609,34 @@ int spl_load_image_ext_os(struct spl_image_info *spl_image, struct spl_boot_device *bootdev, struct blk_desc *block_dev, int partition); +/** + * spl_load() - Parse a header and load the image + * @spl_image: Image data which will be filled in by this function + * @bootdev: The device to load from + * @info: Describes how to load additional information from @bootdev. At the + * minimum, read() and bl_len must be populated. + * @header: The image header. This should already have been loaded. It may be + * clobbered by the load process (if e.g. the load address overlaps). + * @size: The size of the image, if it is known in advance. Some boot devices + * (such as filesystems) know how big an image is before parsing the + * header. If this information is unknown, then the size will be + * determined from the header. + * @sectors: The offset from the start if @bootdev, in units of @info->bl_len. + * This should have the offset @header was loaded from. It will be + * added to any offsets passed to @info->read(). + * + * This function determines the image type (FIT, legacy, i.MX, raw, etc), calls + * the appropriate parsing function, determines the load address, and the loads + * the image from storage. It is designed to replace ad-hoc image loading which + * may not support all image types (especially when config options are + * involved). + * + * Return: 0 on success, or a negative error on failure + */ +int spl_load(struct spl_image_info *spl_image, + const struct spl_boot_device *bootdev, struct spl_load_info *info, + struct image_header *header, size_t size, size_t sector); + /** * spl_early_init() - Set up device tree and driver model in SPL if enabled * From patchwork Thu May 5 20:16:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1627245 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.a=rsa-sha256 header.s=selector1 header.b=jMWy11SP; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KvQ3p545Rz9sBF for ; Fri, 6 May 2022 06:17:42 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id AD202840DE; Thu, 5 May 2022 22:17:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.b="jMWy11SP"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id B8539840B4; Thu, 5 May 2022 22:17:19 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0625.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::625]) (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 6E47583FC3 for ; Thu, 5 May 2022 22:17:10 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LaME/6erfWWuUaLEB1MUZZS/RWTcnU5//jzdND5E21vMS8qXjGt4Vh7UtS6KFk+z5KmrDc598o0FigxO4Bn0G2SdQA5m4a1wg3mikOcm+z5DRRRBXr0loVrGvXOv5zalMMF2I2NRFcwIc/HS3MPhkSiyXXxbOoMKBDnugJl0H8RaxWm3wqLxnRG3YxybgEor0LcRTT9rpE2A+el7D/TOubnqCgBXori80UQ4Qc+vK3pFPuQV8XSnlFPAjYSwUw79d66jkoQyzlyDsqyRb696ocLh+H7ONhYbTZEFXXfAiL7piMIgkm4KVXhhTrLh7rZMXR99tqkyP6pNkmv7mVkcvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=h9cF4CkkYaWNj1ecG1rYowqej50djIKW1qlRXi/y0fI=; b=kIRuRxu4UdlgL6vrWw+4vlfQmoTouTeuIE729PfQldbLoxwvBI6DDjsE51pUelkmvYC2e7DUn12OEoDomiZwZQveoJV7VxmWL9Px7vRP7rhoeh6MW2aXWFpdWP1KjAazGFn+lwhsfhyLerG0+WGa8heJ5KMgkBHHAtjx2rAfmwK9LArz7WKp9wQjJg4kHFoY/XLpJk1no8iHkL9ym5avK6W5lj2cErj0Rz2wkQaS0hDTusQ1myFnpd1bmpeZkRyA+3eT+GRHOb5IbG7YNebW+qpCy5fyMWvN+RkjbSyPpml0UTZbiGnoWt8IMPIY1dUWtLuAlkqkLGQaCdmSse1QBg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=h9cF4CkkYaWNj1ecG1rYowqej50djIKW1qlRXi/y0fI=; b=jMWy11SPU6lV0U32/gD/+ksaEl+bz5w2aGPxC6cGoBWxiaClSY33AQXERawXN/kGJ7ByvENd1DLk+WmDP5Kx/FU0rfo/ZBvTHAh4OHgebLGHkVS/CTklGpw3KBvQe8UkOJXczjc4TYnogq09BxDe10FR4QOgJ3PUh88PIargIc4bgSP3I/6UTGSH+u0/jjkF7EOJZga+ZqD/g8JVtnyV0MDeCZhCQGfuk290Sxn5fIqhbs+eHTEimsP7ep9iLY3yPx8kIEzkRFuYpIozcon29CEeW8Avdhz3lRiQ3gFVVFnDoJ0hzP8X4zu3wpbeFPnUEpvMjh9xQLHHsw67cH4HZg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by DB8PR03MB5676.eurprd03.prod.outlook.com (2603:10a6:10:10b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.25; Thu, 5 May 2022 20:17:09 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c%5]) with mapi id 15.20.5206.027; Thu, 5 May 2022 20:17:09 +0000 From: Sean Anderson To: Tom Rini , u-boot@lists.denx.de Cc: Stefan Roese , Marek Vasut , Simon Glass , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= , Sean Anderson Subject: [PATCH v3 2/9] spl: Convert ext to use spl_load Date: Thu, 5 May 2022 16:16:48 -0400 Message-Id: <20220505201655.645692-3-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220505201655.645692-1-sean.anderson@seco.com> References: <20220505201655.645692-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR20CA0047.namprd20.prod.outlook.com (2603:10b6:208:235::16) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0d403e96-170c-428e-e70c-08da2ed43b63 X-MS-TrafficTypeDiagnostic: DB8PR03MB5676:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: NRVSPu/Z7ILdQQcPVQtkxmqwFHdreGac8ImhPKV/zYzlQXCytPawg8pkIRvEF18Tvneb0jee6jkia28gpLqUyCkIXRdHN6dwUdTbzkv4liOU5Cd0DSARL84c5ToTunr0HtVsICINAGo4XdNv3WJZvM7AupyCSD/lo9n/E09PVaxLBN03vPYRaVCpYrbQpKRF/LM9U/XQ4oKkDid/jtcrm55BdGHh1gbZ6cCQffc9amqGrbcoi3thsFq1TFcoMY2zz/potj5jPTQwieRQ5Y1SxRBDmEmywBU/fKXx01RaA4wUBYjV5RMUy7eUhbycn2C4MzX87vyJTmkSAmDo+axekJbYtq7wL33PxPmHamkFTm9T9WHiOd2Y3VlFIWv3AzX55hH0CX+DZYoCpJZWuT0NTfz396KsQEJzK96KSYeAzuwrv38pR5PS4QyWg/y5yUzwzfRtgK2S+PjurREX3oLpr5/xjsHzlnoV2W4YpWlasHPnV51kobIa8hzo7ciEtjOXgW66bnZW6AY0KFqCJ8iuEpkra2ScEnGVMa35CqnI4ak25cGrTXuBnQnhpURhVzeGGipYi4gxAG43OC91vihsxhqlMuwU8/zww6DI0uMdN8vIY5ovSnOQmgGhzyP5FOWj1NCbJ5RcjYcN2/rJapX3ViwOWNvfQ1FPdMdcXGDQH+/Cjv8zlUW52drFybjcY3F/oA/8kmpQ9eYmoyn4RnMIhA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4972.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(86362001)(1076003)(4326008)(6512007)(54906003)(26005)(186003)(2616005)(44832011)(8676002)(83380400001)(66946007)(107886003)(66556008)(66476007)(316002)(5660300002)(38350700002)(36756003)(6486002)(38100700002)(6506007)(8936002)(508600001)(2906002)(52116002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yZ7335bDaZkH4LqBHTekp39m0owNlU5RCME58F3SMvimPa2JRBLCHS394yvedGnk/Tq09oOA/KbHh7TLu3rREexQGDIeIPbkd9wpfgYs6zMOy1mi9GWKZiak0irsUK8auMIsQsSWjxagfBatFWj+8EbDqTaevw01q8SXvjNtWXyQWir52FnWZ7iUWxTeQ7ebDPh8wZe7TUu/aGrb1NcE9IfHxDFaM0JOqUj/St4YOUSuBwuINxC8PQGQjXA+TtBIeVAkwoM2I6R4G5LKV2YAkdB59wlEsk0OmA28D8lNoE8XWXOjzvX8sdFwZjlS6ulmcPdhze021H7Bo5XFrEwO0d6oYNrfc/eONCiMoTnREXWS0c4u3T5/TUvwIfWCcEhCutSnOLSu4Bq8yhUVAn0vuso65y7eO2j23KxaOMp12U1g1oed6dCPW9bAwM3bd51YEn/GokzRvqpC3FnrEhWKPqJiSOXE8ALFar+jaAHjR2yJSJPEPLlE7Y+tt1c5pM5MNKlpVUo6MLIt8UnpYKoP2nVgrs7DrAc2IyCtO+y1ePXSJ+E92D5dtF0AYrSrcM1kgzilmsljNvaevDSO8I6oeRivGY2X0LH+wPmUNoUJp06mXAqpOLcUTe3vZXGV4jx5TAS/3il20VjWQdViwBC4UOWdFpFA+oojhBoMFJyGgKY71T2XT3DyYwp4x7Yng7PAQoZEyeVbOlGlVjlUqqXuXH1a2KZ+Max4wodenJJdQqWsJteYb7wVnEqfPPWRUV+lVgL0SvzOTsJzJOV3qEHfT/71rENhkQSjS3T+PuWs7jXU7FekJhf3zooIaHM7+telYq1ej6Gzld8K3Cu8qYE33drKHJcqNBg5gMFjxmH8aTh3tvrehFSFtFQAH5PrGGumNEIQMOwVRja47WfvOlcpy2vFCyOq+wx1wEpLDsJYzlmE0GqE+mZidoSfdi7Cp2iSzuoowkF2o/aOqqgoLnP641FHUiFdsNTVEh3ZPyUFbt0LjhPoQGHqsNo3VHjYcnodrU0uhbmFhWflkIUcVREfB62Q+43ICBbqJw0CRNIw/cTAuckTKHmf7eShQzMcFeSkDFZ9dENfDc+kN1eWDaE8RzMnVI1DfGT5SML2uotI+ZgwkHHWkQzdmfEUBIfguLXNEf0/ezSIANlgmBTZ6en4ISC8j5YTClk4Lc0x7brMfEcEPSucmss1bTgOir/eRalaKQeiT+w0Di1xCy2xMn/MPW7IJv4OzxjzvFynWgonpM19piml8eDibx7ADETFi23M8yEqD+DECoZnklm7eYhGseqOX8RPsfHqTJpa8A6yD+eyRbmOUc5yHUE/b+/kqKtrvGxz9e+LMv5QekCTsT0ft2QOcYCDZqsXE+RDDMtqnp9Tg6ijzXZZjvJkUmHEf+5NG3OHI1HyOn0cHSpl5HfVEENbl3fFSZRcyia9YbuXSPOVC3oAHUOxxTMZZppbNrKVg8jaTcSbFJfKMhUtLRenUafjFwgGzkRVYk6NcWc/U7v24TyqryU2NVVBvYjQyTQhgmo7K3or7AbhI7M20P2PZKyOQLL3VASUDG59wyS9MMtjbc8g0xUad8+lIsuN5F4a6Y29Iiize/4su1dEiSEIOCE8XerDFVAPpotlWS+kwLVGxusUsjsoyTAW0g1Nsf7hS6t444kBOEFdaTA40GscuDvvDU0KH46tOD1IQX5epCKYQPDHSvdNbNzc/JtwQH4t8qUTeatkFsj1pkjj37K/BdgZF+ljVmOUUWXnFMkxzKE= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0d403e96-170c-428e-e70c-08da2ed43b63 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2022 20:17:09.2100 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 2e96fIJvhQKQo5Vb4bz15md51mJm6Cjmfy09ASit/4ekN9szHLfAboHMDMS8srqaCj7eUK3lmDNbdfuHuiNYTQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR03MB5676 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean This converts the ext load method to use spl_load. As a consequence, it also adds support for FIT and IMX images. Signed-off-by: Sean Anderson Reviewed-by: Stefan Roese --- (no changes since v1) common/spl/spl_ext.c | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/common/spl/spl_ext.c b/common/spl/spl_ext.c index ebd914c492..1384842776 100644 --- a/common/spl/spl_ext.c +++ b/common/spl/spl_ext.c @@ -9,6 +9,18 @@ #include #include +static ulong spl_fit_read(struct spl_load_info *load, ulong file_offset, + ulong size, void *buf) +{ + int ret; + loff_t actlen; + + ret = ext4fs_read(buf, file_offset, size, &actlen); + if (ret) + return ret; + return actlen; +} + int spl_load_image_ext(struct spl_image_info *spl_image, struct spl_boot_device *bootdev, struct blk_desc *block_dev, int partition, @@ -18,6 +30,10 @@ int spl_load_image_ext(struct spl_image_info *spl_image, struct image_header *header; loff_t filelen, actlen; struct disk_partition part_info = {}; + struct spl_load_info load = { + .read = spl_fit_read, + .bl_len = 1, + }; header = spl_get_load_buffer(-sizeof(*header), sizeof(*header)); @@ -47,13 +63,7 @@ int spl_load_image_ext(struct spl_image_info *spl_image, goto end; } - err = spl_parse_image_header(spl_image, bootdev, header); - if (err < 0) { - puts("spl: ext: failed to parse image header\n"); - goto end; - } - - err = ext4fs_read((char *)spl_image->load_addr, 0, filelen, &actlen); + err = spl_load(spl_image, bootdev, &load, header, filelen, 0); end: #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT From patchwork Thu May 5 20:16:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1627246 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.a=rsa-sha256 header.s=selector1 header.b=LbR9xGjZ; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KvQ405R4Kz9sBF for ; Fri, 6 May 2022 06:17:52 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9A8D8840ED; Thu, 5 May 2022 22:17:24 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.b="LbR9xGjZ"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 3960584024; Thu, 5 May 2022 22:17:22 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0625.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::625]) (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 9126484021 for ; Thu, 5 May 2022 22:17:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mGeNiYJE11UzcI+4q3lmwpHYvF6sED4y2j6Vecg2BSrVX6EnDn/uFFE4b4m3Mu+W04uR8QICvSHPPrao/EjKgFSZ1xI/kQRAOWeS412fxFucU2/j7cMin9UVQy+v74+3i8P9KndtcO+nsZ8KtSjz6oRBgf3jMcqFF+eWqmqd+4p3yuh/3gkU/Nh6JmEtpwy2ktNbbQOHtBQhxaKuoPhb86LCSyPM6v+PzGZazDZ5ggjsBy9+NPv4ROkIAm6gj7sssmqzAxGXHQk6+be5qlsBiUn7XEfn206hlmDyYzJaJs2JlpTFksAMswp+IFhvwwhLtIEa2pRZHRTsxU5Yqc3Oew== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=J/vZlic9CmJf6cSpn3RX+bVoVn0nX1dt4SIzQeOS4U8=; b=ADlvyntIPj3YOTswOYY+XqAFA4VxtSVHHOH1Lrl6VHCn2rY211KlM/ba3YFs3BaridLojCZ8y9Bj9+VK3LnW1ZAFlgmuY5R37TglKZPZc9dQjQcUP61xOEwYAUosSom+fuZGKjpe926TSgX40aN9qqOwNl7gdgrtv27ax6+n745tcRv/1PQtH3+8ShYxjuLfSHZF/Fp4Edmi8AShpfMMC80lqUaFVTRQ4KsRmM6r3Y37zacDJWVrgGyp1N4IOnTBXwaRhHTyqut+YKzMWYVsA/L3DcbHZNeFR3p1D4DzCe0a1bBFs9p0D3fKFEGUI6bDY8gCKdLRT6vMg11gTV1KdA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=J/vZlic9CmJf6cSpn3RX+bVoVn0nX1dt4SIzQeOS4U8=; b=LbR9xGjZA3+8D5CU5ctlqTT2sPMuIgposM3v8KbvnX14otU9tRGEbQdKw1cc8rp7GxAvO5ADLZw0OfB3SuBrSoQoFOfD4SOhDn8oqhBGcUSOHmT6yswEiQymRtMBQ9uA50YTcTjPmbDirC6aspMqCKQvZV97Vx2FirfiRD9H5xrbdHvu8BpiJLi09ft2BKZVLUNjb1tLEGeG6SBjzWklJSUWHZlsj2l50ff6CylnjznM6LQWFIQHPg4h6xD5o4iNsn7KbP/GkDHBH+P7zzrfocT/jQXkktZhXRAjGYT6Sq95eO+tpeS4oigW+I1arsPwLrICkynihFWQ1c64n4wg8Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by DB8PR03MB5676.eurprd03.prod.outlook.com (2603:10a6:10:10b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.25; Thu, 5 May 2022 20:17:10 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c%5]) with mapi id 15.20.5206.027; Thu, 5 May 2022 20:17:10 +0000 From: Sean Anderson To: Tom Rini , u-boot@lists.denx.de Cc: Stefan Roese , Marek Vasut , Simon Glass , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= , Sean Anderson Subject: [PATCH v3 3/9] spl: Convert fat to spl_load Date: Thu, 5 May 2022 16:16:49 -0400 Message-Id: <20220505201655.645692-4-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220505201655.645692-1-sean.anderson@seco.com> References: <20220505201655.645692-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR20CA0047.namprd20.prod.outlook.com (2603:10b6:208:235::16) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8ba766a8-90c9-4885-6098-08da2ed43c65 X-MS-TrafficTypeDiagnostic: DB8PR03MB5676:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: /6lJbmNLwJFWxuUzVq1cjW7vp0kHw1utm6Dg34VMHrYh6E2INgqk3r8O+46mY1ledF5wpgDKuzMGhXvEHAcbBeWKyNKl8zh94MZvrYtSf5ORv4yXsbpTeLG2cftQh9H5FMv/gv1MMQfm9DXzjP1k1ma07c0dFVTCRo02Hguyaoz3wvGZXUFITsjpm9TqXEuzavE1hSZe6IxrK7skxpCbew2RF1u+xgOdy1AAZ54jTithIyy47eQzQ3HfcO39Vwkiz6Ug+/opCAeKkb6jAFjWhkorTyjOVClMYVaN9AVDPtQZ6Rrc2Cd7jbF5vn+8bp3L3+yCkcMQr3PFdi2eb5hF2XjpZRLGbFQ3T8dNhQoRBqri347fAygKK/g79bA7mcqtPsb/aAA5Usv+GZFNioQr/RuCB1pXEjpIe1e9Pzbbv1oO2wj/QA/yoMgeZmS8OK0g/Cw6QC7J8hkCasyzA26gt6IPRfAlpNbniuYsyyjNAbAwMfIQr0mvmSdxeD7176xaISAvLr4DReV+ynRaZKw+FQCNiBwr4GvJDU/OORqzBD/mJNQG/KFx5RZZV0Qp5voQsrhfMsR69nNoNXogZuwJmAokg5rho/ozrxAb/4wC7gr6zMbtHHZzJUIEmTvzp/WaoEcKc9rtBLdLGyjHdu3X8ewlNnjfL9eO4JrIJz6+ZTFwgh9WdnQlvT+ubGCN2Jc6L+fJXTI9uDkDWe1hkWkLvw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4972.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(86362001)(1076003)(4326008)(6512007)(54906003)(26005)(186003)(2616005)(44832011)(8676002)(83380400001)(66946007)(107886003)(66556008)(66476007)(316002)(5660300002)(38350700002)(36756003)(6486002)(38100700002)(6506007)(8936002)(508600001)(2906002)(52116002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: YJ24p4NrGlVNChAWuNgIZHohrxXkq250zW6ZvCnVpE4e1ZxQvad++QrmZoJ2xeTQtRJhC2x2UYl+s0m1bMYVAUIzJ4glgR/qkU7uSGzbCDVMJgix37+dLIKtvvvsS/5avHVao021eXnAEMhIsJl++gVYheERAEP8l0+3/P38NeTECIFzpY0hq5pa1yWiahCCTF5znDvq82MvtYL8+z2oW0+62eV3rwIZOwPddKN9ieGlybl1ULLrHqBjc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4uVK9JFFJbIGbO4KA83D6uJRMQOzt5wy5nquTTShchd5gIMNx52xRKtQftfHk3WL6Ax07ZUyTXBi3DHZqj0B+d3DQSEPH9F2NUlshummRu9sDWmQA078Ow1XWeLYoVXTpA8ecqosqoAYw21fWmRDOnNLaCgQrpLMGq5OG7Mux62hxJA6pl62m93uLHggMEMIgF39q0LnfN0hOY0cDzW3CVai+5D6kNdG2L0MnyTglxHK/OIG+CBMe5gNVvOTWtmn02T8sNWURo6GD3H/P8ckf3+7s+tU9X3RrPRDhjDZP4BOKtinj0yd7RfeUv4drFgiW1y+ROFzUYpCiWCmNgHaJkNeXPorsCfdibm7yqe+OUhDGflJqmVKkfBZw5r3c915ATlWmq0NwBqCpdCKEgeoBpjfO9D3RS1hMCZoVBuiWeSDeGq7359RI7cLZHjTLANVy+Y1T1HsBe0kw= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8ba766a8-90c9-4885-6098-08da2ed43c65 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2022 20:17:10.8661 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: euaArvUXfyS5p6HOwv3p0GIk81hlFtzSasEYs0jtZ/vMdLGimoDh59tTEgiMKfpGMEFtq2t/vXquykQeO2vWrQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR03MB5676 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean This converts the fat loader to use spl_load. Signed-off-by: Sean Anderson Reviewed-by: Stefan Roese Tested-by: Tom Rini --- Changes in v3: - Fix failing on success common/spl/spl_fat.c | 40 ++++++++-------------------------------- 1 file changed, 8 insertions(+), 32 deletions(-) diff --git a/common/spl/spl_fat.c b/common/spl/spl_fat.c index 5b270541fc..f25f1a19ac 100644 --- a/common/spl/spl_fat.c +++ b/common/spl/spl_fat.c @@ -61,6 +61,11 @@ int spl_load_image_fat(struct spl_image_info *spl_image, { int err; struct image_header *header; + struct spl_load_info load = { + .read = spl_fit_read, + .bl_len = 1, + .filename = filename, + }; err = spl_register_fat_device(block_dev, partition); if (err) @@ -72,45 +77,16 @@ int spl_load_image_fat(struct spl_image_info *spl_image, if (err <= 0) goto end; - if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) && - image_get_magic(header) == FDT_MAGIC) { - err = file_fat_read(filename, (void *)CONFIG_SYS_LOAD_ADDR, 0); - if (err <= 0) - goto end; - err = spl_parse_image_header(spl_image, bootdev, - (struct image_header *)CONFIG_SYS_LOAD_ADDR); - if (err == -EAGAIN) - return err; - if (err == 0) - err = 1; - } else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) && - image_get_magic(header) == FDT_MAGIC) { - struct spl_load_info load; - - debug("Found FIT\n"); - load.read = spl_fit_read; - load.bl_len = 1; - load.filename = (void *)filename; - load.priv = NULL; - - return spl_load_simple_fit(spl_image, &load, 0, header); - } else { - err = spl_parse_image_header(spl_image, bootdev, header); - if (err) - goto end; - - err = file_fat_read(filename, - (u8 *)(uintptr_t)spl_image->load_addr, 0); - } + err = spl_load(spl_image, bootdev, &load, header, err, 0); end: #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT - if (err <= 0) + if (err < 0) printf("%s: error reading image %s, err - %d\n", __func__, filename, err); #endif - return (err <= 0); + return err; } #if CONFIG_IS_ENABLED(OS_BOOT) From patchwork Thu May 5 20:16:50 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1627247 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.a=rsa-sha256 header.s=selector1 header.b=dbG4kH7G; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KvQ4G1FHmz9sBF for ; Fri, 6 May 2022 06:18:06 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 8658D84096; Thu, 5 May 2022 22:17:27 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.b="dbG4kH7G"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id E090E84088; Thu, 5 May 2022 22:17:22 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0625.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::625]) (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 BB38984073 for ; Thu, 5 May 2022 22:17:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=lcpKrnHNFbbq0RjBVwru0j3i4qkSMq9pR6B4NUrlYYpQdqP8hZZMu64eFKcV6bF5Xaw+tv5jh+ufpnRUoRxa//vxuCoKUIEIp44WGsgC1rs8UWmYkIVKLq3/cDq84LAHFXohULS7xcrB90y9vG1N/rms4wormYk248nTtN6cZ5+gQuESanNE8cqLnP5tNC6LSGfR4QaBnnD0GyOGMoJ7VTm9faQAztqZrF2A6bsHULIf4jfiXAVoUMPSm8D15gZkGymrvdqFq44qTgxhqmQ8eae1PsX8FvEAa+MefukHxEdXkOroWg8od+r3P16jbGoXXNaLCfPUaJGZMYIdSKQxMA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/qdyM8bddgNttceJw78/31ZHTo7r3on9oOsp+6Jft3s=; b=EhU7cUrspvnAcD+HnSLDiN/HVMYYqbfEAbMo1Bge5j0K7oAiTmpjl2d/PW85R12pb2o9DSAGmPg+RlKJ0QTiaEcWc2ZiEBJhZiFbfwbk2946hZN+y7xJSKz9uwk0h5PiGxD3MzSVNBE9QRNNkbABoyc6sDrOi2hUp07ToipAU1gYIH7qr2MKwCsX06jNGq0f5I/clKyjlWM++mLpe0aXBp4+J09NMsSVdLBvGSUC2Ixkcqx1uiomKYGeTB5GspjMPcxPPCVh4zna3Pb6/HSw1R3qe4BXJhkvcWuH7Pw0K9hn/o5HUr4ty9fUXLEheCCuVz5u5bXdaU0l8NWCEa1rnA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/qdyM8bddgNttceJw78/31ZHTo7r3on9oOsp+6Jft3s=; b=dbG4kH7Grxp8g5cRezl/g6fhwzc8w1Y3IiDeleP4NTRyvVzGD4rkg04lRM1Pl+Ska6FZftvz/2SzxO1aRErn8KbD3/QQQIetha+AoAKPbtRf3dDfRk94VBz/AFMuSFf+oT0VUKwVFdAcR+Zwu20d2SnXCPKN9Hr5neqShgsKETcSJRwDwrFUkxwc9UeotqtwbkgUJDidaWqnEbFusOJlTA4Flo/TksNd7OvRcVmJQGl1hL9r/+nSTOndYi9qIhOG/aQFbIvXhMV88Fwhw1GUJOIuho1nB9NmtJ8m1uM2htEraVtBMakPD9H8NLe+is7RD9Nlm5B6NeatW+owR1Y3rQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by DB8PR03MB5676.eurprd03.prod.outlook.com (2603:10a6:10:10b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.25; Thu, 5 May 2022 20:17:12 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c%5]) with mapi id 15.20.5206.027; Thu, 5 May 2022 20:17:12 +0000 From: Sean Anderson To: Tom Rini , u-boot@lists.denx.de Cc: Stefan Roese , Marek Vasut , Simon Glass , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= , Sean Anderson Subject: [PATCH v3 4/9] spl: Convert mmc to spl_load Date: Thu, 5 May 2022 16:16:50 -0400 Message-Id: <20220505201655.645692-5-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220505201655.645692-1-sean.anderson@seco.com> References: <20220505201655.645692-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR20CA0047.namprd20.prod.outlook.com (2603:10b6:208:235::16) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0e840a64-472b-47f3-79d8-08da2ed43d45 X-MS-TrafficTypeDiagnostic: DB8PR03MB5676:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 4bkgqXSG/iuEhnWf8mvGjmOhm6QSwk+AeVS3uhvv2w5ht9oC+atkknrqoIxOmcwT/1mnWVJCKPf6S4RZciGulEo53/FjsiESnPNzM5BPs0cmccjejdJV0M3++iJErsjg3LNAM/7uPGuA9zIBJ9tFtspnRjdsytMv9aPFsocfEC+Z6BVP+J5b2xWbvG/OG4xAJD57NJRuOBSsRo0Kb4MU8gyzn4+HRmKm7v23SvPG1oN7AGoMdKavKnwZPLGZxr7tFPWCFsUBrqhyWlLLfAxuyx/eP4ypI1tkbpYE3w902Wn3sjrSR3vug3+/e7nxiKMdzK7x3Eh6i5CBggBy9rl4QE4Xauq9cCqluinruIp7DKvBdKwz49IMLkZIL3Zmqo9BTP3694xtBd7pGi+DpGaHAhdgzCxWeRNDFsqnuMkUoRIbGO34LDDEp1klzpVVT5XedeVmxgVnn7GoyA/AoZuRDEh4SdAvZ+fLcAhxw8ls6oVlvMrusUi4IWKFpIy/SLQSUWPY3sZIOatAvWa1+x9WqCmQ/SCEu1daWllLAcNZcJxLOI6U62c673qaCFOslkWhGaJXtuYwUHyXEnJuoxaF2RkYDRaTY6gMjMDTAH45V1j+pMj+CnzWxudRh+An1zzac37Zz67NOQUY3SqlyZw/tB/tK5yVWiAIxwQPlCF+Y4sQx8uxo/Nn1BIXZkShFFP+CoTyx2/rGlnfOOzcVGinig== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4972.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(86362001)(1076003)(4326008)(6512007)(54906003)(26005)(186003)(2616005)(44832011)(8676002)(83380400001)(66946007)(107886003)(66556008)(66476007)(316002)(5660300002)(38350700002)(36756003)(6486002)(38100700002)(6506007)(8936002)(508600001)(2906002)(52116002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: CH4VFWQSrjPBUEtRjbClGQCSWcwE9g2S9qpwQvXKCSup/GnxHmrL3pwyFVqIMSbVQ1gHmQjKM2TyjdHLwlgFZ0Fbhmp7ZGy+y4C888vfutd8+yKieafgn6PwFz0hp4KHECfibp/C+VZpkQ+YFNSImiFuA02cQBtYdBD46ewLIg6e87ta8omnZEJ1jDe9viy0frDsuIWR86gMlRzRkzLlQMvXHcSy8/LdCLNTRxICviJgjvOil2uiiv79U7liqzGswHJUDJ8Sm40E3d+7FbeLqWxR+7raA/qZRqDoiWEIyC0Xe+bnUJva8e+Th4NjM0TZNbc6L3Cq8i8CWEdePYDXUuhui79jiG0joMjia+l26kCJhtrUFlpT0aBqyd5qVCOUiFeLRnDdZ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G7kARzjRuXAEbqDyqr8erq/ZaOwErHF5hSCYShwfYP41PBeWGIh/dWuRolB7xPx3dZqNxX/KHz+lgkO9KStTUJNhJt9EZYWZh+BH7irdLV3lnWC/owdZR23ruiIqRvA+IyDkSjOwVGUFsERg7hJJ7cZMLN+SjK4UsSMQV7IfRbkP0Simh4u79eyPGCcyc/azNt5nYsZiE+9Tz+z/+Hx+ur7xH0qugcMATaZImjAkBPInWEdnoscrhBBcU2pIMFrVbmcIi50uFCeA2Lv2UQXZ27yK+E= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0e840a64-472b-47f3-79d8-08da2ed43d45 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2022 20:17:12.3660 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: OI8fLyBVGCQNpDyz35ggHypAOpPVvgvVrm6UUmEyHS9va3E1gDFe+unG4p9JTHfU64xIqeLNGChP9OildWpYsA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR03MB5676 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean This converts the mmc loader to spl_load. Legacy images are handled by spl_load (via spl_parse_image_header), so mmc_load_legacy can be omitted. Signed-off-by: Sean Anderson Reviewed-by: Stefan Roese Tested-by: Tom Rini --- (no changes since v1) common/spl/spl_mmc.c | 73 ++++---------------------------------------- 1 file changed, 6 insertions(+), 67 deletions(-) diff --git a/common/spl/spl_mmc.c b/common/spl/spl_mmc.c index 6116a68371..93a28cdaa9 100644 --- a/common/spl/spl_mmc.c +++ b/common/spl/spl_mmc.c @@ -17,48 +17,6 @@ #include #include -static int mmc_load_legacy(struct spl_image_info *spl_image, - struct spl_boot_device *bootdev, - struct mmc *mmc, - ulong sector, struct image_header *header) -{ - u32 image_offset_sectors; - u32 image_size_sectors; - unsigned long count; - u32 image_offset; - int ret; - - ret = spl_parse_image_header(spl_image, bootdev, header); - if (ret) - return ret; - - /* convert offset to sectors - round down */ - image_offset_sectors = spl_image->offset / mmc->read_bl_len; - /* calculate remaining offset */ - image_offset = spl_image->offset % mmc->read_bl_len; - - /* convert size to sectors - round up */ - image_size_sectors = (spl_image->size + mmc->read_bl_len - 1) / - mmc->read_bl_len; - - /* Read the header too to avoid extra memcpy */ - count = blk_dread(mmc_get_blk_desc(mmc), - sector + image_offset_sectors, - image_size_sectors, - (void *)(ulong)spl_image->load_addr); - debug("read %x sectors to %lx\n", image_size_sectors, - spl_image->load_addr); - if (count != image_size_sectors) - return -EIO; - - if (image_offset) - memmove((void *)(ulong)spl_image->load_addr, - (void *)(ulong)spl_image->load_addr + image_offset, - spl_image->size); - - return 0; -} - static ulong h_spl_load_read(struct spl_load_info *load, ulong sector, ulong count, void *buf) { @@ -86,6 +44,11 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image, struct image_header *header; struct blk_desc *bd = mmc_get_blk_desc(mmc); int ret = 0; + struct spl_load_info load = { + .dev = mmc, + .bl_len = mmc->read_bl_len, + .read = h_spl_load_read, + }; header = spl_get_load_buffer(-sizeof(*header), bd->blksz); @@ -97,31 +60,7 @@ int mmc_load_image_raw_sector(struct spl_image_info *spl_image, goto end; } - if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) && - image_get_magic(header) == FDT_MAGIC) { - struct spl_load_info load; - - debug("Found FIT\n"); - load.dev = mmc; - load.priv = NULL; - load.filename = NULL; - load.bl_len = mmc->read_bl_len; - load.read = h_spl_load_read; - ret = spl_load_simple_fit(spl_image, &load, sector, header); - } else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER)) { - struct spl_load_info load; - - load.dev = mmc; - load.priv = NULL; - load.filename = NULL; - load.bl_len = mmc->read_bl_len; - load.read = h_spl_load_read; - - ret = spl_load_imx_container(spl_image, &load, sector); - } else { - ret = mmc_load_legacy(spl_image, bootdev, mmc, sector, header); - } - + ret = spl_load(spl_image, bootdev, &load, header, 0, sector); end: if (ret) { #ifdef CONFIG_SPL_LIBCOMMON_SUPPORT From patchwork Thu May 5 20:16:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1627248 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.a=rsa-sha256 header.s=selector1 header.b=FP7W6N0v; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KvQ4S5xjDz9sBF for ; Fri, 6 May 2022 06:18:16 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 327F484065; Thu, 5 May 2022 22:17:30 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.b="FP7W6N0v"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id EFDD084011; Thu, 5 May 2022 22:17:24 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0625.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::625]) (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 DBE4B84057 for ; Thu, 5 May 2022 22:17:15 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=gi0ZDvdNp75T53hrc9ymo1DtUkuhT6VOztA4XfNm+ecyQ7rd7cCRJLkMsc4jXc3+VbNfzhBGV+/DKV04PzUgOiI6jKZbsm1QBf15aMfxXo2+5pCg1vGH5HNx+NJ9kDT21yq+hkkF6VWnBp5sMNke50KnUzSTQFNjl0PVyboqSJK+1rPfs/9YEGP3UFsFcexvm5nJydOzMzLWpcMv1U22An9VzDqWrDdCZx8ykdGpViv0zPmwbICn5Xvd0AVHnsC+0bA500rLHemfKjoE8vH10xlrcv2ZlyOTRE1lCt1PgdEg75jXitq8Aj6tYHhg03NodI0T5Rw/rj755ZhswHwPXw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FsMSvck2DKFBlDDze6KMFN67Deb1rfERr+t8wIHoSsw=; b=fIn5kHmm1W+2H70hGRFHc8TOWe/mWH90YdmYcFFrI6660rEEpKerUk8Axe/qu96+gNPLljdB8Nfp5YUPnMb+P+6Mn8/IbSisQDxsoVCnaA9mPX1jm/u15okV2YX5W+OOkZAhH/X/1OV2/zY0Z4+ATbVeDu+EFW5oXYvBfT6uCjFnmt6FAsVZtUAFJrYujflV5IYcTrflpHv0znF+P911PbciEilpG2egI5BHO8jzvYhFbiNKSJ1UUrifJADZGx17PqanpGOmaU5kcl/0opKj0IPpySLKkSp/mZ4H0YF9OWn7W/TJQ2LWi3v/mCAJRfUH/3GYQbmUjOAppoI+cKC6rQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=FsMSvck2DKFBlDDze6KMFN67Deb1rfERr+t8wIHoSsw=; b=FP7W6N0vZKvL6XZCU1UJXq1s1bg/nuFQ/6sLVcrsUz0476hcjn6JEtj3CYC5Aje1W4rq5KyKCcdPz70IpBmKOp/D74sYtifr+NCafjx7/UHT0Ie86l7HYGdQaRau4AyGQuYWFLRLx4UlbRheThIeU+YwDuUgybE8JFOWWkDuRLhtbbZ04H4j/gmcPD8pIvYM/I7hVFKFsopbptCRN7DSzQ9g2wgc8ecadYqbmLtcEDgGVwnVNm1hjIOhyAue9WS9PjGmhn9cV7WIamSt2A15QrnAgbma2Y0tPjZ/WxVEq8He4FYDFnUM6mwnAlT3NhP+/Z6P/1QRi5eXqB6wN4iJqg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by DB8PR03MB5676.eurprd03.prod.outlook.com (2603:10a6:10:10b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.25; Thu, 5 May 2022 20:17:13 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c%5]) with mapi id 15.20.5206.027; Thu, 5 May 2022 20:17:13 +0000 From: Sean Anderson To: Tom Rini , u-boot@lists.denx.de Cc: Stefan Roese , Marek Vasut , Simon Glass , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= , Sean Anderson Subject: [PATCH v3 5/9] spl: Convert net to spl_load Date: Thu, 5 May 2022 16:16:51 -0400 Message-Id: <20220505201655.645692-6-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220505201655.645692-1-sean.anderson@seco.com> References: <20220505201655.645692-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR20CA0047.namprd20.prod.outlook.com (2603:10b6:208:235::16) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: fd72b7af-9e34-4809-9305-08da2ed43e25 X-MS-TrafficTypeDiagnostic: DB8PR03MB5676:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jr0hniORJLEu0Zuv52KnBDF8WAOc95NvHtgJAKLUqFWy95o9x+5gITboOZAKwYIxUqDQpqrJdjQafO+igkjDM7yeyWi2IznFMOxkEwqjqDivjHuXbgYMMPz2od9jcWFkd0LvI3Zr2k/NMnuLDcxyUu4kn528uHrwpq0AXWPZzK63bZ1KsO9wTlAjhZxvN9Mze4IMAZ0R1TJiLJC/mYxM/GLmji9xkFVRhefzKZTb1+gCump0PXq4kJULQfDNVdn7surUl8XA8Z45vzoS7QSfFY3DH8HSWdRfYIgk7Y9/636S+LlYrFDwYstrG1b1c2uaXBzX5k3bh53fyYF96gFMdXhy7CssF3r+3BlBsZ4MirackokILMs26vXf8xLhcV90GUv0i2ROqxnkXd+mJBp2f7SvismpaiALl5pI9g01Z+GvJR2wuwa+oM6PojOcG6l2lgrW3C3Yu/1ZwxffCwmEDK6gla0szAvBH9hg9aZPWfaVwmKgYiVA1ourNEV3UnBzw83mXXzuW/4hmWrCDpM2E44ejFZiy0Q0jo3nFDGvh2Q3yb9k2GgOE5isQ4vPwN7bd//lx0iAYOvJk6UsMHr8qGVUpKjQRfC/9e6NSF2x1E611CFZNQEpqbNnztYlM13V4m60waWscPvJYHA3E2ZzQ1UVPozuWyYbBk8kQl7SpdbRS48ydTzaoEXOeFYFa+sAqzg85lgxKCxbGSKxaxlijA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4972.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(86362001)(1076003)(4326008)(6512007)(54906003)(26005)(186003)(2616005)(44832011)(8676002)(83380400001)(66946007)(107886003)(66556008)(66476007)(316002)(5660300002)(38350700002)(36756003)(6486002)(38100700002)(6506007)(8936002)(508600001)(2906002)(52116002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: uX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KFY4P21OUvPD+vWrXtyXobb7xsVZpMKeKmPRndVnp8h6OKdFwbXmbJEGGo/pHyUyFKCwCF3VTN6XGltq8eau+7Nnp43QoA6QNpTvGdSN8pPkQmsRhZ2ycp+oBjMzYet5Zlae+jG0RRaOk147EhI30YEJzso1x7a3UxlxKuuvtUHogj/d83gOHDJVTjFWPfhwWfCdKjVgiO0Pgl9eoEb68ZBqs9t3sIB2KycfH0QmLe8FuGS3/+cRCCwg2RTZ9UEu5EjyFNuTEpiNns7AwH00nOWPdWaso6ZmHUQpm9EHrgwepVmeKw7gCs2AYGkqbkGPuJLvHKCz3WiZ3hcGMwjQUWbZVxGCpRgm/jaO49qbgJ7bvGbOg8UZgelf0kTOqw0NCwrttN0HJdgmHTRrgcaxtzslI6SPUFc7f87nIN0COPnk1q9+V2igR6F1H8l5t6f71gFbWgnUWj7sl0nJPVqF4PhJ+9j77OLObn00ljic3DUERqKDb9LNzirpX9Xm5fnfZ+vxSB69N/zWxFGnONg/SdlD4WzsdEQju4Gd0G7G/9URLDVr0RMYR6nTeNpFjuTe0dUXe0i8PgPHSfqA3/eALYi7gtQq5ev5kqPcl5mL6xCNmAMJifmKOfG4LPMqvoNGSsOEM49yL3taFbFvD1ynZT8K/w2cGGxf47ts4gmKzDtcfmokG1eoNzo5yzE= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: fd72b7af-9e34-4809-9305-08da2ed43e25 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2022 20:17:13.8815 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 8ETPbMDdVXx2Le7ztf8gdEYDXlMMTkG502uNgoLYljrRjTkhNDugvGRKlWyj/wXeA7yckVu3tbbfMyygJT61cg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR03MB5676 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean This converts the net load method to use spl_load. As a result, it also adds support for LOAD_FIT_FULL and IMX images. Signed-off-by: Sean Anderson Reviewed-by: Stefan Roese --- (no changes since v1) common/spl/spl_net.c | 24 +++++------------------- 1 file changed, 5 insertions(+), 19 deletions(-) diff --git a/common/spl/spl_net.c b/common/spl/spl_net.c index a853e6aead..3b4374add6 100644 --- a/common/spl/spl_net.c +++ b/common/spl/spl_net.c @@ -29,6 +29,10 @@ static int spl_net_load_image(struct spl_image_info *spl_image, struct spl_boot_device *bootdev) { struct image_header *header = (struct image_header *)image_load_addr; + struct spl_load_info load = { + .bl_len = 1, + .read = spl_net_load_read, + }; int rv; env_init(); @@ -47,25 +51,7 @@ static int spl_net_load_image(struct spl_image_info *spl_image, return rv; } - if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) && - image_get_magic(header) == FDT_MAGIC) { - struct spl_load_info load; - - debug("Found FIT\n"); - load.bl_len = 1; - load.read = spl_net_load_read; - rv = spl_load_simple_fit(spl_image, &load, 0, header); - } else { - debug("Legacy image\n"); - - rv = spl_parse_image_header(spl_image, bootdev, header); - if (rv) - return rv; - - memcpy((void *)spl_image->load_addr, header, spl_image->size); - } - - return rv; + return spl_load(spl_image, bootdev, &load, header, 0, 0); } #endif From patchwork Thu May 5 20:16:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1627249 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.a=rsa-sha256 header.s=selector1 header.b=c/3g59s/; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KvQ4g5nCnz9sBF for ; Fri, 6 May 2022 06:18:27 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2F71884088; Thu, 5 May 2022 22:17:33 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.b="c/3g59s/"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8178D8407A; Thu, 5 May 2022 22:17:25 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0625.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::625]) (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 43ECB84092 for ; Thu, 5 May 2022 22:17:16 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=MXTZ7FIWYtW3yJJgWOxVoxk9fGfUSUnCxSkkc+MmHzOj2zupb5/7AGxcO1G1h/W4tppltchv93PUfvixgNhy96Q9ClxNb8zVRY3u5J6tA+HEvkTvQOvJWWSv5p0JARNiTg6JMFfMwqLgQ9gZ/k8qdOsA3VuMKw3Q7+pfEFQa5elVBK7QWRBW09JEcDZHG+9K0ikE/+5W2vVQOhQFADczpEVT80B+0dIT4d7DeGTnbZ5Ep+fr1M60MPEgG8g2Y7qt7T4t1JYy0ooB/Eij16D4Zp+N37zAoUjqNasPwki9cikMuNNslqqWtewroaU850feHlFTUAU9gac+6NJohRKaxQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=fmzv1c3atgK/C3MPGR+CWZffRkD/rRyrcLcfACiUr4s=; b=HCC5F3DNvp1hjwxoD09SqMVxfElvOgZDzRhFycpIoTOVm77rnwTE1YX4PMD58twKfrX7qaVZ4F5tfZ62Tza9ASb9g8KQP3hqaHwFQgG8B0CpLaSE52sFt9rJpORUJE0mTvLmOz/ZUjvi/+jyataR4/dhi8kbopxUCGTPgyVVX8NhvGrT46yuJ+4y0C2z1THz0Fe2uxb6aTd7SWetacIPnAm0HL0kkpFBKpYkMoR8X8nTgI8uljOk+dikTWwPFm55mc4LNjlCvcnW/NiYPP6b4YxFnWP3NSS0Aph0DvRNQggNVL8bst7NgeBK8N/KrXk27FoKAwrR+UiuADb/yQPsQQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=fmzv1c3atgK/C3MPGR+CWZffRkD/rRyrcLcfACiUr4s=; b=c/3g59s/KF4i+L4LjxGR1aphbCCilGw4bLni1MD+Xql/RU4d3+cjH0QKGg0PTw1w2zIxtcuT0WAwm8zi4UsHKSjUek+v0JFVnotpuaoG66SBBgyn56BTXwxMgWHLtr+YYxBvsYcDtCCDIwriyqWQShOnieM1SyRv5NAGhd1JC298JQs9+BnRyXTMeHFs04SsV9Y9dffgriGjavVO0J58ithBO1KKOuDJjqndO3J9xnXcqsM3Fxtd45wTOtK8dvUxgbo80pTfdvOjo5+F9Hlp+IdU0mGs0fyctrae6PwwAoLaVXIjTH/VdoQs71jElXYIPd9ukhVBUhBh/m3troOFfg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by DB8PR03MB5676.eurprd03.prod.outlook.com (2603:10a6:10:10b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.25; Thu, 5 May 2022 20:17:15 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c%5]) with mapi id 15.20.5206.027; Thu, 5 May 2022 20:17:15 +0000 From: Sean Anderson To: Tom Rini , u-boot@lists.denx.de Cc: Stefan Roese , Marek Vasut , Simon Glass , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= , Sean Anderson Subject: [PATCH v3 6/9] spl: Convert nor to spl_load Date: Thu, 5 May 2022 16:16:52 -0400 Message-Id: <20220505201655.645692-7-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220505201655.645692-1-sean.anderson@seco.com> References: <20220505201655.645692-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR20CA0047.namprd20.prod.outlook.com (2603:10b6:208:235::16) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5117aff2-1b6b-45f8-5c7e-08da2ed43f16 X-MS-TrafficTypeDiagnostic: DB8PR03MB5676:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: m8h2YWQSu8jc5hpDyy4WZWXLQ9ZXEUqPggJj5Wa6eqPlIfgFs5DNbvV1g6poNbfven3xM5HsdF6PnHvCPe0q9PTrv56klZb7iYqn/3HzlEtvVuL7xNJ07xiS2cWbselnvz5TtprPoEJLTdNtr9Jgu/kfq4wrHgsIi1OUlDC6fDE1Qz1MYXR0kM6fMTEEJy7DH1Cln5nDr7gpxdUezWsOlQIJrHsCTr08OnQ9GLy8T2kvjw6DNH1lJRTHvA7Ryn9j+JjkklkiDBUnGzYa82dPUnmFoUOh6sdnkN3LuzgurXa0LBRTD5UlXEghyT47G0nFoaBRKtdt+L8fpz0DUbAk9GBelw5CUMwt59zflnfVDvBzmm/I7CwXJqpuuO1hxcOTqHEpKtJ5Lz3NPjBmSTyfURCdNod27fMRFlupguoRZZ3TV24WQMV9F3nqHX5K+zymThEt1mw+VsaDDa3q6jnw+DN3AurtFkY6YWh3AZOio92MmLXBNZhAed5wQVhkMTNPtpJYCJV3A8OE5+sJWtzNVPVxj4D5kMVAaM7J6ZtV+d0QZQPFQGnWAgrLLcEqR5GvHVmWKkSBd3JKa3w5x6AleQM3GYpIeFTJEINjQa4+3Lc0bTG5YDtAbaCpBiLRbtU933aR3MU83LuFQ+yce3D+bAJ8/3RWJ7rTKtryLbNQrp5yLMQ+YuWxqKGNRVVWR2ddvINTnvEB3f7S6AbAeq51lQ== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4972.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(86362001)(1076003)(4326008)(6512007)(54906003)(26005)(186003)(2616005)(44832011)(8676002)(83380400001)(66946007)(107886003)(66556008)(66476007)(316002)(5660300002)(38350700002)(36756003)(6486002)(38100700002)(6506007)(8936002)(508600001)(2906002)(52116002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: aGt7qGWsxZnJjYXp68T+NYW7nTMo81MPQa9XSen1ULdk+OWImMpurEVxYl73fBx0FENvBR+9VzRzPiFpLCYsyGPkWV7KLTT6CzUYy9iJE5O4mljhLuc7tUHFhu4NQ10zwAAlSgKL/+4iZBBaUBp34fDTkNohEJhPPGjhZEfNgQAW4lWzYPf+hsAgByndME4Yzc6pnbVq39++pNE1V29X13lfu/lWAwJTLUniJ8s/a96DM6izzVFMhjjwfT/ibX4sI5ITcTKdP0liBV+10QNrdz1Ocdv9wNlV/Qr+SKqjt3ts2+MTGsJNmJN+EolcMEsOFsIuO196tNFukeBz2gqgkbPUw7q1lVRgWiwTgZpivWC3fcB1QxEBi2Wa0/7QUbWup4Ldimltd53KR5s05KFxwqzyoNI8iDUpMQblnJTsvSGWzp1kn60vxKtrA6z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ok1PM0dAgj/+vDgCgNBMQgXknrdCUIw4z/IC93uHMpya98WvYNPZ4Z5QJhq6NX+S8LVynGoC07ltfgsj0qxQEyTPyPePXH31mM+7jYx3ClBtXLXB+afH8EjSIQEMfvHkxxaSDMqFa0WxIdz3aXEHIb/1ZnKG46XWBXlIKcFDJtJc4DI5Ifxfd3TYc3DYYyWVMefhPi8vF5JGNa8OedblcrIGhuAj+fveMcdwLCzduUmthY5F5vsI4gwwDXM= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5117aff2-1b6b-45f8-5c7e-08da2ed43f16 X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2022 20:17:15.4283 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wxWgeWc474ulA8NoHjdfl8aypYfhfXAN+ok4Hz5q4FPJLVPOQ3vGazsi8Evccsa1V0kaCFNA0IFM+rku1yB20w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR03MB5676 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean This converts the nor load method to use spl_load. As a result it also adds support for LOAD_FIT_FULL. Signed-off-by: Sean Anderson Reviewed-by: Stefan Roese --- (no changes since v1) common/spl/spl_nor.c | 35 ++++++----------------------------- 1 file changed, 6 insertions(+), 29 deletions(-) diff --git a/common/spl/spl_nor.c b/common/spl/spl_nor.c index 0f4fff8493..90ece77af1 100644 --- a/common/spl/spl_nor.c +++ b/common/spl/spl_nor.c @@ -26,8 +26,11 @@ unsigned long __weak spl_nor_get_uboot_base(void) static int spl_nor_load_image(struct spl_image_info *spl_image, struct spl_boot_device *bootdev) { - __maybe_unused const struct image_header *header; - __maybe_unused struct spl_load_info load; + struct image_header *header = (void *)spl_nor_get_uboot_base(); + struct spl_load_info load = { + .bl_len = 1, + .read = spl_nor_load_read, + }; /* * Loading of the payload to SDRAM is done with skipping of @@ -91,32 +94,6 @@ static int spl_nor_load_image(struct spl_image_info *spl_image, * Load real U-Boot from its location in NOR flash to its * defined location in SDRAM */ -#ifdef CONFIG_SPL_LOAD_FIT - header = (const struct image_header *)spl_nor_get_uboot_base(); - if (image_get_magic(header) == FDT_MAGIC) { - debug("Found FIT format U-Boot\n"); - load.bl_len = 1; - load.read = spl_nor_load_read; - return spl_load_simple_fit(spl_image, &load, - spl_nor_get_uboot_base(), - (void *)header); - } -#endif - if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER)) { - load.bl_len = 1; - load.read = spl_nor_load_read; - return spl_load_imx_container(spl_image, &load, - spl_nor_get_uboot_base()); - } - - /* Legacy image handling */ - if (IS_ENABLED(CONFIG_SPL_LEGACY_IMAGE_SUPPORT)) { - load.bl_len = 1; - load.read = spl_nor_load_read; - return spl_load_legacy_img(spl_image, bootdev, &load, - spl_nor_get_uboot_base()); - } - - return 0; + return spl_load(spl_image, bootdev, &load, header, 0, 0); } SPL_LOAD_IMAGE_METHOD("NOR", 0, BOOT_DEVICE_NOR, spl_nor_load_image); From patchwork Thu May 5 20:16:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1627250 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.a=rsa-sha256 header.s=selector1 header.b=MX02yQZM; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KvQ4t3Qj3z9sBF for ; Fri, 6 May 2022 06:18:38 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id C1F758408F; Thu, 5 May 2022 22:17:36 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.b="MX02yQZM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id A0A6F840C4; Thu, 5 May 2022 22:17:28 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0607.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::607]) (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 201D4840AD for ; Thu, 5 May 2022 22:17:18 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=fXaJMG9XECndx78EhKyhj6PsJSgEvnDPKQSEx8cqhUq+Uu/ujokLW0nCw+d4hmuoAyPztsLWnUkvs+aZ2p9H06XvS4xvgpqlO+EO7PZXBBNXchRFpxHoZdIdB+QgG/W6JnRWgfrQZ5UxRevaUeMhfdA4EWUeFKZhJYrHUeyQ0JJKOfuDgZ7q+mVSt97+ppv7Krfbntpl8oleAa4fpYxCpM2ThhUG4CYuPWH2g1Pd7dtECJd2J1p/YFltUMPL25kWpz/EreEe5xCzMkuxcxSMdeuYVekU9nn2HNT+oZScoOPyGwterHrAy4xB4eXjSuYscQSuMGFvfKWlNkQc5SE2pQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=t+Opr1i2snuGhamgsJiJwjh9TJ4FHhm/MZogQ1HxbEg=; b=Je/T0SY8/nZfMeBih302WujGAZzROv0bReEStuEXfQT5qwyZxAdA0BO+nq7Znp1+Ts4WLXb0w1gtJKb+k3DvKXvcDDWQVYQh/C2XSvZyIJWG0j62cKtgq/hMweqwNiA1G9S5mluow0Ii7dBCALoq1XYmobac/LxPP8ThTLAbMgGuc/JFetNaLGFPiKY2GBzRzEDaqWf5DPWCHOSC+HPxxMm++DFXODjDputJE17dEsCenux/gx+cOc9Jbcc2EGgJ7ycK1OKnKsZEUJ5fsOldXOVLVdB5KEb/303z4Ljg+Nx36iIX7kejnJhjBXVUjbyOwZ0ayKkFgpJL9OPSU74myw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=t+Opr1i2snuGhamgsJiJwjh9TJ4FHhm/MZogQ1HxbEg=; b=MX02yQZMYvQXEFZrjZKfN6y1wcl/phT5MnoUeUksUmcvLIzI6L58A78xyCrxTNJU2++6G8RfxpOQT3s6fPbFKdA/OFLp35KG73oV9NZA+p+olqMhm2V0Gz8DnzM8pTrHbSgB6qJXkOIl59xfi3KeHR2EbI2RLZJS0K0znCzPtfbhQyMIJJzMRpcbx7r5AL1JvzyMLo+QAaYgrbV6nRMXol3OWbncdWxQ/FyqEFmqFAGL1VcDO89mbzn47gbxAiDt/tfSext+Vq/JuJg+UVAt8KcxjoSBcFWrRZqnQQ5oL64OES4uZE4Xcm/dnHx+vOEnY8TxBVAs73wW9WQb08SxeQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by DB8PR03MB5676.eurprd03.prod.outlook.com (2603:10a6:10:10b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.25; Thu, 5 May 2022 20:17:17 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c%5]) with mapi id 15.20.5206.027; Thu, 5 May 2022 20:17:17 +0000 From: Sean Anderson To: Tom Rini , u-boot@lists.denx.de Cc: Stefan Roese , Marek Vasut , Simon Glass , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= , Sean Anderson Subject: [PATCH v3 7/9] spl: Convert semihosting to spl_load Date: Thu, 5 May 2022 16:16:53 -0400 Message-Id: <20220505201655.645692-8-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220505201655.645692-1-sean.anderson@seco.com> References: <20220505201655.645692-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR20CA0047.namprd20.prod.outlook.com (2603:10b6:208:235::16) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 92f9e0d7-2afe-4381-3a41-08da2ed43ffb X-MS-TrafficTypeDiagnostic: DB8PR03MB5676:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: abzKDsPwsJyjCWsyWcvnFCLATGmVXdHxz1d8TyWf9cfo0Q1bTsXzAcxf7oaA8R8R5yHvKWWjYZXjEbYzztWttoe5zWoxQtxy6AwcDh0eEo/hDIqrhNVfxMmDlZzA8D6EnVao1TZY5QSu4KGb9NsI6huC4vOP89Hz3jcJzFV+NNo55F4uLostzowzO8vs6UL1vpoaNShhjOmZwhZ5lko07ddUkiVKJp+TMZBHHOhsAKwUBkIMw2M3rL9uLlY7nAMg0ZCmSc5/E3iOXySe6tse9nmNGWL6vmGNQ+U2ZlKn3newHd8c97/FbFNj9ZAsGeRPtRfrTDJzYnasUz8fvMTsOdpFqsN4O9YUxsdJp0bC7reUuiYaTdp3JAY3QnalCk+cowLJ44o3gkKvrVyBs+ykIaVrzpRyUNdpIJoWrQ8ELVX59/j7dSmHk0rU6YbGDJaNwas+E12+mmY6yz/nRU2gUp+tOedLPdnt1oEaTrVIQtPb/9lDtGUpaoQqJEYsoRa6ZEdCDY4IgrqunyVbFxqKbo0h39TAcQpAnHOpIGR2RVaGtF3/Dd/kCGkjxn2Xyyf4ZeCzXulnNzRDY8KIxV6MQ4QZtwsNJ5URiRldo1GPgis1lT976yZvRE0CJGjzCOSi3DlnA/Ncdez5oGJcMPncW/8nT5R1ovmdp+6byzvejzvwf4yqM00hYfzNUebCmCXb9P4uWSeaCEe7nVcd3A3CVA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4972.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(86362001)(1076003)(4326008)(6512007)(54906003)(26005)(186003)(2616005)(44832011)(8676002)(83380400001)(66946007)(107886003)(66556008)(66476007)(316002)(5660300002)(38350700002)(36756003)(6486002)(38100700002)(6506007)(8936002)(508600001)(2906002)(52116002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: esku7odXLqBiVgT1Oyl8ykcuNafOuQo0XvHjTxeFXtj9Nl84eLTE5Td5Mohx/PBsrdKL55f5Q4GuPmeSKtH9Fi/f7LUvyRShSn7b1QyXLb1ugkKHjo2iEVUsRXOj9jJyqbfSuWTvb+aKrFB8TjVrK3LN3P0lqdFkOATyN7h1/z0QceSLXqCd1aaNdyKAv8J7/+81u3kKuxrzAUj10YghSQwRjTZ8PJvYQgyQXV6zoFHRJEzTclOwd25/VIi38DFMsvfDsT85ElSlX9erM68KU6js2M0Z9/rQlFOgzpQ1xmEJRg1WsPTczjdtCp1yM1RI09TmqdSUCtrRXqbwKvd4YFKQULjtLJJLxwf2GnKQiq6k3TmneaB9yMY+YMT49eNhqVqm/QlVQVVi1MIitFZdOiPFcRbqmFdUaxn8espEtU6qhy/99iekNuv6rdTpv5uIRtyj4laxHnd9WmGUXdFrbJxvF8YFAJYqcsT72mvFiqTv5O0Pzos1AIOua0iG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uRkBj5CpHOWo9gufSXhR3pzAq0jwffMEYpKv0rZbNpUl8IYuGFRNZ2J+9+7R6hCkTqXdrbw+md46XevLSab3Xq20RukqXF2icdnPUORFt7wfpHS44NU/7XTBT8mzeN2Wjc5isFKmm16XCTLkc2CBG709XrHs4Lnhfeut+2bwh0tcavKxJTE= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 92f9e0d7-2afe-4381-3a41-08da2ed43ffb X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2022 20:17:16.9438 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nxAkSt5vwYDWloEzigsHQd7B51Ll+ymhS6rHVLjfP8TiqXnPQOy/I+ylmo0oxLdQ9MWFA5SNHhyKoMOP9UsocA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR03MB5676 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean This converts the semihosting load method to use spl_load. As a result, it also adds support for LOAD_FIT_FULL and IMX images. Signed-off-by: Sean Anderson --- (no changes since v2) Changes in v2: - New common/spl/spl_semihosting.c | 39 +++++++++++++++--------------------- 1 file changed, 16 insertions(+), 23 deletions(-) diff --git a/common/spl/spl_semihosting.c b/common/spl/spl_semihosting.c index df6aeb2951..35fbc2ee5e 100644 --- a/common/spl/spl_semihosting.c +++ b/common/spl/spl_semihosting.c @@ -9,16 +9,16 @@ #include #include -static int smh_read_full(long fd, void *memp, size_t len) +static ulong spl_smh_fit_read(struct spl_load_info *load, ulong sector, + ulong count, void *buf) { - long read; + int ret, fd = *(int *)load->priv; - read = smh_read(fd, memp, len); - if (read < 0) - return read; - if (read != len) - return -EIO; - return 0; + if (smh_seek(fd, sector)) + return 0; + + ret = smh_read(fd, buf, count); + return ret < 0 ? 0 : ret; } static int spl_smh_load_image(struct spl_image_info *spl_image, @@ -29,12 +29,17 @@ static int spl_smh_load_image(struct spl_image_info *spl_image, long fd, len; struct image_header *header = spl_get_load_buffer(-sizeof(*header), sizeof(*header)); + struct spl_load_info load = { + .bl_len = 1, + .read = spl_smh_fit_read, + }; fd = smh_open(filename, MODE_READ | MODE_BINARY); if (fd < 0) { log_debug("could not open %s: %ld\n", filename, fd); return fd; } + load.priv = &fd; ret = smh_flen(fd); if (ret < 0) { @@ -43,25 +48,13 @@ static int spl_smh_load_image(struct spl_image_info *spl_image, } len = ret; - ret = smh_read_full(fd, header, sizeof(struct image_header)); - if (ret) { + ret = smh_read(fd, header, sizeof(struct image_header)); + if (ret != sizeof(struct image_header)) { log_debug("could not read image header: %d\n", ret); goto out; } - ret = spl_parse_image_header(spl_image, bootdev, header); - if (ret) { - log_debug("failed to parse image header: %d\n", ret); - goto out; - } - - ret = smh_seek(fd, 0); - if (ret) { - log_debug("could not seek to start of image: %d\n", ret); - goto out; - } - - ret = smh_read_full(fd, (void *)spl_image->load_addr, len); + ret = spl_load(spl_image, bootdev, &load, header, len, 0); if (ret) log_debug("could not read %s: %d\n", filename, ret); out: From patchwork Thu May 5 20:16:54 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1627251 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.a=rsa-sha256 header.s=selector1 header.b=dM2d1BXz; dkim-atps=neutral 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=) 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 (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KvQ546T2wz9sBF for ; Fri, 6 May 2022 06:18:48 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E5115840D8; Thu, 5 May 2022 22:17:39 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.b="dM2d1BXz"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 536EF8407A; Thu, 5 May 2022 22:17:30 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0603.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::603]) (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 52788840A6 for ; Thu, 5 May 2022 22:17:19 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=PrApBVtfFwKjwLYIXRZ5tQ3hCUfj/OJGew6Eb2Kv1YNEcPKne2Y67T0PrsbknvvOmRaD06ubft7t7RybsGHVGPJFe+EWbFYyZF0jpEm4/VRSJipCOTNd0uZloO+iBtA/D4868xjyjvDDdvNaMyuFWu5ov8rl1zkJMVgPPp04d3jm6azCCwxn/ZoTQ/7otGa/eSxI5aI2xGUv8GCQiWQ8Z/BC7nAmIY7aPHhq5j4VO83u2vl7W9RRwy/sj6SGbiZ56NRdM5G5USUutxaZSLdMDUDuco1x08mWsC3h4tOTTSopwSfBKtvi6uqJ9R1TFZ72K5yBUJWao1+5iwjSNiIstA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=JWUm7hyQBN6C6BrfAh3YeATUg1VH8QvuTMDMihRYoEI=; b=PAuAZkisnyRiREFqEEQBEx6CvbXqHeTqKrgOQRsDihBEYQ/6QrSI3V5RJ78IsrM09+5CD08bhKAKp/GYWNbCTny2sGSYuuVENxqkToL7ExkBMAdFbfiZUF1YOWo3ErzmGiYqeKzI/HDCOOh2CTniwehZEidVkIogO/8p5Ho2JmxzdJr49qz7WXK0q0wfe1Img3tMm4s3zrG5C2N9XXnELeq2byHZ045KZuwxjAolJtbYyO5Kk1rlPnY/694yPhBgbGL471jCGnoTPfvmBhi+jL5POuV4xXadH3wIqDSqtVEn4UQQqJP8ufUf98OxqQ4HjnUUhmZCIGyZlgvTrsoW4Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=JWUm7hyQBN6C6BrfAh3YeATUg1VH8QvuTMDMihRYoEI=; b=dM2d1BXzSnAlTFavqF6MwtiLfaAsqVFa4lojz6gjBovhcYMNDQM7EWDPZl/PuaE1Sqfrwu3MqybsqAOhHcDS8Au7Tay7YZb/212f48saYAc3PdCU6OU6acEveKrCyfhuLY5/I4f+j6O3zsc4GoOQktGaS85QR5P+K6hmgWXxGQ7kny8x7VIY4nFafqO0if69vyLMdQotwouepPOoKFChAWwZsBVHfD2NlwPXpUOy4Q25sQM4dQoXgLCyizDAxi1Om2yyc0sDo8oXK1RsJbAj2cW79fiGy2pWi3e2LKSINivEwMcipqGSAja5LbB5xAm3OPzjgax8spjf8QPcIkYi5w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by DB8PR03MB5676.eurprd03.prod.outlook.com (2603:10a6:10:10b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.25; Thu, 5 May 2022 20:17:18 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c%5]) with mapi id 15.20.5206.027; Thu, 5 May 2022 20:17:18 +0000 From: Sean Anderson To: Tom Rini , u-boot@lists.denx.de Cc: Stefan Roese , Marek Vasut , Simon Glass , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= , Sean Anderson Subject: [PATCH v3 8/9] spl: Convert spi to spl_load Date: Thu, 5 May 2022 16:16:54 -0400 Message-Id: <20220505201655.645692-9-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220505201655.645692-1-sean.anderson@seco.com> References: <20220505201655.645692-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR20CA0047.namprd20.prod.outlook.com (2603:10b6:208:235::16) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8d2abc1c-60bb-416d-5378-08da2ed440db X-MS-TrafficTypeDiagnostic: DB8PR03MB5676:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: YNJMH8xpPYhgljUrdccyNQ0haxzG5FnLwos97tbUhmonoP4Ea+tOpFtLuB1F1uoH3jzowUvkkATmNo159z2AYbqHAPSImHogZassvwtXTrAq8wNP8QMN0e1mKxhcohqfQkaQN7VWQ4fm93QST+w2kqYTYfSka58URR+71BZeBgje19pe0sntZCApkEYTadj9nzHaJ4ntnspXHZn+S9DHelDtBC3Hb0SeDlGZsnnN5MZ+UttYBd2JX13+roB4ofaELqBKAYUWcYszGZ8d3Izkm/douTFJf2u0tE99a39PRNi1pYvsn6N386dDmQ/Gr8YVl0JenKgIxqHD+vuEjP39TlmZO8KDfInOeD/a4Fj3k9YZv7eNTkMV6i2Jb496WBsyMCz7vqfX/u1TXV/MIo5uVI+kls2Fw8lRmNjUTwgOmV9T6T9oeTt3LQDsAgY4oCqNeX4FPyGHbiWjaWPXf7zGS8mg6nm/tfEf+/3Xuk81S9YSHAAoKJatbV3RBGYQ2HnjxmJLwXo//ZNyBZGkLl/vaWk/niri9YhT3+j9xZo9LxleUGJGpYgiCYO4VA7SP79Zv8GI9ys6Am80CGkUr5mgiFGUq5DzDRNmWxUZdNJ2vPm5PsYWlfIcPg/PBWE5116idqYzIhVn/IYZ8qPepmkHXsMvGeufHm6pExWzha6FHO/c0Vu/O1bkJ4ltCLB6JjO3gvLM7NBKlEgR005GjNd/nw== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4972.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(86362001)(1076003)(4326008)(6512007)(54906003)(26005)(186003)(2616005)(44832011)(8676002)(83380400001)(66946007)(107886003)(66556008)(66476007)(316002)(5660300002)(38350700002)(36756003)(6486002)(38100700002)(6506007)(8936002)(508600001)(2906002)(52116002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?XwFXa8nEvImNFk6Dc/9Qoj7vpMe/?= =?utf-8?q?FQTOIh0sfU40Ofz99vb1r33tlMsAJXuOQDFuFKY4GTzo7x1fQUGB6WX940lAUsoVn?= =?utf-8?q?+CHSI04kxLh3WQ/y8EdOVpcIdXCnyQTYV9vfG9uBToI8B5uIqnrWPjlQDnbyuvMfD?= =?utf-8?q?Ie20J89jvD2mxMnN8jEWEG8f8OWkqRBAWqt6bEhYesSpTj4qZWd/w+JH5doSDa1Kl?= =?utf-8?q?KRSCGqs2m6xIWYsH0czUpkqwUyhiBd5JZHuDt4fgmQ3gzIPoeFIv4iHvEynGoZeqE?= =?utf-8?q?P65iQOTtPMgQq1iEWnkfRYoiwQaNZsQk1IxVVLEpps+b5Ac/zbjFiX0g1/V4hh6ub?= =?utf-8?q?BXUydkLlQk6txwXfCyGNOO7rr2JjbYgAKJB6LddLRWyyaGM2CAHJBy7OSwS3H5SQo?= =?utf-8?q?4DaLX9MSW5FUHWQBo02Nfqf0Ns/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0dJ3ZVnxDak4vkeMsVNU/ANUEH?= =?utf-8?q?fkBoXFClIAZds9En9BqtPcUiJ1qUzwuopY3m9rau+MI91xzgZ3llf0V9cU6H47YZj?= =?utf-8?q?XAmGo0JozOPMh9IhBMRZ4sra3MqHM7dABg3eh+lClDQfSCXfBp9ki2szZI6CQBeKx?= =?utf-8?q?40zZ2zsMS9yQDVu6EQc7jJzB+ThMqyrlMtIMXUbs8HS0FNjPcL9lVSfeJmbVtucFl?= =?utf-8?q?n2NHyq/49DzwkJcrq3yMGBiWVeXd/OTV6izCB5IkNlWRHLu1hPed39pADJwlpKF6j?= =?utf-8?q?RtH83JK84Y31Cgbs13fvEniQqvr2M5h2uTDMk2Tz8eB/ERFHFt2ZJds5tRU4BuNCr?= =?utf-8?q?5ftqATnaZYJXLNZVbq6W3XCswyYh6EyykxuWGynbI9z0RzcYcJeAI=3D?= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8d2abc1c-60bb-416d-5378-08da2ed440db X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2022 20:17:18.4281 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: yIpfXmW1RrOgzch7v4tW5IDpmvT+n167qezChjJ07NypHy8a0mkNhok7Bu7cgugppPN7puEAIrM4GnQxnVBObA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR03MB5676 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean This converts the spi load method to use spl_load. As a consequence, it also adds support for LOAD_FIT_FULL. Signed-off-by: Sean Anderson Reviewed-by: Stefan Roese --- (no changes since v1) common/spl/spl_spi.c | 48 +++++++------------------------------------- 1 file changed, 7 insertions(+), 41 deletions(-) diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c index cf3f7ef4c0..037db1a19f 100644 --- a/common/spl/spl_spi.c +++ b/common/spl/spl_spi.c @@ -83,6 +83,10 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, unsigned int payload_offs; struct spi_flash *flash; struct image_header *header; + struct spl_load_info load = { + .bl_len = 1, + .read = spl_spi_fit_read, + }; /* * Load U-Boot image from SPI flash into RAM @@ -99,6 +103,7 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, return -ENODEV; } + load.dev = flash; payload_offs = spl_spi_get_uboot_offs(flash); header = spl_get_load_buffer(-sizeof(*header), sizeof(*header)); @@ -121,47 +126,8 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, return err; } - if (IS_ENABLED(CONFIG_SPL_LOAD_FIT_FULL) && - image_get_magic(header) == FDT_MAGIC) { - err = spi_flash_read(flash, payload_offs, - roundup(fdt_totalsize(header), 4), - (void *)CONFIG_SYS_LOAD_ADDR); - if (err) - return err; - err = spl_parse_image_header(spl_image, bootdev, - (struct image_header *)CONFIG_SYS_LOAD_ADDR); - } else if (IS_ENABLED(CONFIG_SPL_LOAD_FIT) && - image_get_magic(header) == FDT_MAGIC) { - struct spl_load_info load; - - debug("Found FIT\n"); - load.dev = flash; - load.priv = NULL; - load.filename = NULL; - load.bl_len = 1; - load.read = spl_spi_fit_read; - err = spl_load_simple_fit(spl_image, &load, - payload_offs, - header); - } else if (IS_ENABLED(CONFIG_SPL_LOAD_IMX_CONTAINER)) { - struct spl_load_info load; - - load.dev = flash; - load.priv = NULL; - load.filename = NULL; - load.bl_len = 1; - load.read = spl_spi_fit_read; - - err = spl_load_imx_container(spl_image, &load, - payload_offs); - } else { - err = spl_parse_image_header(spl_image, bootdev, header); - if (err) - return err; - err = spi_flash_read(flash, payload_offs + spl_image->offset, - spl_image->size, - (void *)spl_image->load_addr); - } + err = spl_load(spl_image, bootdev, &load, header, 0, + payload_offs); } return err; From patchwork Thu May 5 20:16:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 1627252 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: bilbo.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.a=rsa-sha256 header.s=selector1 header.b=wzwVoWKb; dkim-atps=neutral Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by bilbo.ozlabs.org (Postfix) with ESMTPS id 4KvQ5H0s1Zz9sBF for ; Fri, 6 May 2022 06:18:59 +1000 (AEST) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 4EDE984101; Thu, 5 May 2022 22:17:42 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=seco.com header.i=@seco.com header.b="wzwVoWKb"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id D62B2840D8; Thu, 5 May 2022 22:17:31 +0200 (CEST) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.2 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-db3eur04on0627.outbound.protection.outlook.com [IPv6:2a01:111:f400:fe0c::627]) (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 20F4B83FEC for ; Thu, 5 May 2022 22:17:21 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=reject dis=none) header.from=seco.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sean.anderson@seco.com ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=N7jwy//CzKg4qtDxXe2KVmXmynX0dXKVvDM/z69VsWXgqMZCH+so/2Xsn09whXZS+cZx6GNpuJNsbcvRAvaInSia4QeF/XkkksYb0nDvdkcbCffOXU/UX+nwZagUz/FSVC6rDAKfH1s9vQhcngK2/igJsFFy4GC8tzCzrH/7HsmI2DAiKyaNDmt6j9HOy4/XfyW8aHJxoCjHaPi4NmzyLIuJKtrKcQZGSiqRwe5H9DWFnpAisw8UMUkOEXwzkipcjdj6hJew3f1yA/hGudKl2qSILb81AWqud9OY67Y+/4Jz94OZgAoYMRyYW5Z4vj8iCUo0xzcQc+FIn/K19IJqhw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=6/hFUyLZaSKXut6It+mTZ5EIsWAymGmiqIlajNY9IeQ=; b=Tu4uspagipYjlpHTlwbYPDfYprdTNM8FTO58645nIO61tHrnYmNNgf6U/820RbfOWTlBzk3dh89olH5T1nJI8uPZHWYMczE1OVOth5PofsIcvPkg3ySgg5LlQX71G49vWsMcfHXn/SAfCPI+sFVF7lcdZ89aq5dee25B2ZwrxEKdrFCJy5M25NpOLy2pfJUmcVDFREmwoG3vHOSEaxVIGNNQ1phSk4atPAKUjSUTa8/u0AYkdw0bELuLq/Uspc7wUaVul45t5+F5k4/DBt8gd7/ON8TZHhtAlQlAaiONC2rWmjVejG89uEactMH7mProKe+T1mdzT+zFewXY7uA4Mw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=seco.com; dmarc=pass action=none header.from=seco.com; dkim=pass header.d=seco.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=seco.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=6/hFUyLZaSKXut6It+mTZ5EIsWAymGmiqIlajNY9IeQ=; b=wzwVoWKbTIrys9bE7+deQjNMm/E03L9yl9c1QR5aLcleVZ2BZ9fhn5yq82MJwulJ35ABNmrQO7rh9TeapJJclO0xbRIyNwxKjz7lVvl6Sd2Np2PDGbEy6cp14MVYF2qSHNc0CJstUs155d3W2gSNCbhxyZkVdIUZr+bluhAWG0ZIW5I93vRQxk9aykg6xaxLGtJzvGV826Hg0e5nEpA9Fe1X4qJ5b9VF6Xwb9rZkxTAO49iqF5RV+m7XfiaeP+2wYwB2gxV7HqPrth5BBjyddQKSneKGFxwTbjXjwDAZvsAJMXj+wNgxkE5wrqlaXjG6hrCPMZkENn86WCfAY8IfMw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=seco.com; Received: from DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) by DB8PR03MB5676.eurprd03.prod.outlook.com (2603:10a6:10:10b::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5206.25; Thu, 5 May 2022 20:17:20 +0000 Received: from DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c]) by DB7PR03MB4972.eurprd03.prod.outlook.com ([fe80::a9d3:8abd:3f5e:a0c%5]) with mapi id 15.20.5206.027; Thu, 5 May 2022 20:17:20 +0000 From: Sean Anderson To: Tom Rini , u-boot@lists.denx.de Cc: Stefan Roese , Marek Vasut , Simon Glass , =?utf-8?q?Pali_Roh=C3=A1r?= , =?utf-8?q?Marek_Beh=C3=BAn?= , Sean Anderson , Jagan Teki , Nathan Barrett-Morrison Subject: [PATCH v3 9/9] spl: spi: Consolidate spi_load_image_os into spl_spi_load_image Date: Thu, 5 May 2022 16:16:55 -0400 Message-Id: <20220505201655.645692-10-sean.anderson@seco.com> X-Mailer: git-send-email 2.35.1.1320.gc452695387.dirty In-Reply-To: <20220505201655.645692-1-sean.anderson@seco.com> References: <20220505201655.645692-1-sean.anderson@seco.com> X-ClientProxiedBy: MN2PR20CA0047.namprd20.prod.outlook.com (2603:10b6:208:235::16) To DB7PR03MB4972.eurprd03.prod.outlook.com (2603:10a6:10:7d::22) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f3725f6b-ab71-46c4-df88-08da2ed441ef X-MS-TrafficTypeDiagnostic: DB8PR03MB5676:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: rkWJK4SZUQUco7sQt0O+G1wF8Txn9SLMAWORO7iCmoNZq4/gKlcsjZhS3FotwLqhHJSUMdBIJbghvNw3Ld5+KR7ujm5KRYsdLqU54kHyzJIx7ojSR0T3M7rDiFwG9TG+IuGgIexOaIGt8BEZ2P7h0Q7YrwHYaIM6mCEZkQbJI9DZrc2rZSxL/OXWP5lfNPGmlvwRfsu0K2rHs3RjC7ST5FxV7NBeT784EvnMeYQ4HEJv1/ixmHy6fvM3Hb7toiAXtEHzylmdsY3lr8wp7h0p3OtV7tNvZCOMG2zgNR42zQVE2MXyDay5vksLec/qMqyHdW5TMFW+lz+l948KxV4QbhPiYSR7CgXl2A62AugLTK9vkK3i7Yq0NFC6URpP5yrWBj9IFmhxFcz0PiNMYapev8zIzNb8I9TvOYboCcPnj1R2wLgVeu5HGklBdBRX8mq0nAnkCBm1aFc7c9EEK0LkKYofKd0NOKCeu/aEOcZpttsS6ntgyi6VWmj/aPvx9hfGuZvHjhxgLYtucCqOYS5EywKlLw4156nlA182SAoZRSVGknX/ndBvRmi5z6FiC5243484Ts+B4ufnhRJHxwNDeksV0/jGwtp9FiA7BjUUKSejbFIfOWKAqSUdo1C5OfAL8F0mWmFT2Jc80dMdyPsgaRYuZMvgKM8acLG0KNjRq83EtCA/zueqNzcgfLQ4a8DBDcYkIL6QAz3u8U6/UqbkpA== X-Forefront-Antispam-Report: CIP:255.255.255.255; CTRY:; LANG:en; SCL:1; SRV:; IPV:NLI; SFV:NSPM; H:DB7PR03MB4972.eurprd03.prod.outlook.com; PTR:; CAT:NONE; SFS:(13230001)(366004)(86362001)(1076003)(4326008)(6512007)(54906003)(26005)(186003)(2616005)(44832011)(8676002)(83380400001)(66946007)(66556008)(66476007)(316002)(5660300002)(38350700002)(36756003)(6486002)(38100700002)(6506007)(8936002)(508600001)(2906002)(52116002)(6666004); DIR:OUT; SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Y1iwZ3QouZ+2zyOVf6FTnQe936CXJdh0LGB613hmWiprENWyMhCSCDskZ/6pXFwbzwkDrINkj3KMdN00ibXdCby0nxEgNKBS3QeWMH9XtbeQxogGrWxDi8whi8c/kxLkcJLM5pmDeCT5c92FNpiZN/yQK36nY1HRnstYLRRA5mqn3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5rJ7g855W3LVljpOWWIJSwmWqtDAl5nouVT+Vi+il+Ehf6Suxy+LpsIbFxh8CFMHB5xvRehMF7NABtQ/erwQahTvJyXJIR7K1qPt2s2vz1ThvWbTzOm8PnqN0p2ZOsvn4eIamEsCxB/zsSwIyzDTmBJTYLjawGCTJSX8sU5sQIr3rcOtjyCDvxmLIrwax5+bwW98b7fqBxfLhyTyJzZiFbnkngsUyhoiHAwk7HkjFkYPqJ4+bTkRxTugBARDhsKOnFLoMPgA658n2oRwJjolYXjaR373NbF95Sj2kEsvC6gBHX4mSjQe+uBEdGD1BvwMaJM/fdOj/04LrnFzuYjXdJ2PK0yF4J3s6P5AxEZ6U0QxNge/RoDjEw/ikG/63S2eKky6wdqrLCtlSn+J6FI5l0QTeKpWLtuHgzoJRphWZnXL1UbpyApULGxNiSBRGDb6pZtNOK0NzhqaMD3F7Rzb5bA0C+l02nTM6YgB6CctTp429qVmhbyO8= X-OriginatorOrg: seco.com X-MS-Exchange-CrossTenant-Network-Message-Id: f3725f6b-ab71-46c4-df88-08da2ed441ef X-MS-Exchange-CrossTenant-AuthSource: DB7PR03MB4972.eurprd03.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 May 2022 20:17:20.1936 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: bebe97c3-6438-442e-ade3-ff17aa50e733 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: nVDwY5d1i9XZaJOdMm7mLK3Lqtt0Wxw93Ar4I6FNBK/IsHeo0elZfpN+vrg1TjQzhubpGQt/Dx5Vqb9h0adCUg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DB8PR03MB5676 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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.103.5 at phobos.denx.de X-Virus-Status: Clean spi_load_image_os performs almost the same steps as the non-falcon-boot path of spl_spi_load_image. The load address is different, and it also loads a device tree, but that's it. Refactor the boot process so that they can both use the same load function. Signed-off-by: Sean Anderson --- (no changes since v2) Changes in v2: - New common/spl/spl_spi.c | 87 +++++++++++++++++--------------------------- 1 file changed, 33 insertions(+), 54 deletions(-) diff --git a/common/spl/spl_spi.c b/common/spl/spl_spi.c index 037db1a19f..e724a74783 100644 --- a/common/spl/spl_spi.c +++ b/common/spl/spl_spi.c @@ -18,41 +18,6 @@ #include #include -#if CONFIG_IS_ENABLED(OS_BOOT) -/* - * Load the kernel, check for a valid header we can parse, and if found load - * the kernel and then device tree. - */ -static int spi_load_image_os(struct spl_image_info *spl_image, - struct spl_boot_device *bootdev, - struct spi_flash *flash, - struct image_header *header) -{ - int err; - - /* Read for a header, parse or error out. */ - spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS, sizeof(*header), - (void *)header); - - if (image_get_magic(header) != IH_MAGIC) - return -1; - - err = spl_parse_image_header(spl_image, bootdev, header); - if (err) - return err; - - spi_flash_read(flash, CONFIG_SYS_SPI_KERNEL_OFFS, - spl_image->size, (void *)spl_image->load_addr); - - /* Read device tree. */ - spi_flash_read(flash, CONFIG_SYS_SPI_ARGS_OFFS, - CONFIG_SYS_SPI_ARGS_SIZE, - (void *)CONFIG_SYS_SPL_ARGS_ADDR); - - return 0; -} -#endif - static ulong spl_spi_fit_read(struct spl_load_info *load, ulong sector, ulong count, void *buf) { @@ -71,6 +36,29 @@ unsigned int __weak spl_spi_get_uboot_offs(struct spi_flash *flash) return CONFIG_SYS_SPI_U_BOOT_OFFS; } +static int spi_do_load_image(struct spl_image_info *spl_image, + struct spl_boot_device *bootdev, + struct spl_load_info *load, + unsigned int payload_offs) +{ + int ret; + struct spi_flash *flash = load->dev; + struct image_header *header = + spl_get_load_buffer(-sizeof(*header), sizeof(*header)); + + /* mkimage header is 64 bytes. */ + ret = spi_flash_read(flash, payload_offs, sizeof(*header), + (void *)header); + if (ret) { + debug("%s: Failed to read from SPI flash (err=%d)\n", + __func__, ret); + return ret; + } + + return spl_load(spl_image, bootdev, load, header, 0, + payload_offs); +} + /* * The main entry for SPI booting. It's necessary that SDRAM is already * configured and available since this code loads the main U-Boot image @@ -79,10 +67,8 @@ unsigned int __weak spl_spi_get_uboot_offs(struct spi_flash *flash) static int spl_spi_load_image(struct spl_image_info *spl_image, struct spl_boot_device *bootdev) { - int err = 0; unsigned int payload_offs; struct spi_flash *flash; - struct image_header *header; struct spl_load_info load = { .bl_len = 1, .read = spl_spi_fit_read, @@ -106,31 +92,24 @@ static int spl_spi_load_image(struct spl_image_info *spl_image, load.dev = flash; payload_offs = spl_spi_get_uboot_offs(flash); - header = spl_get_load_buffer(-sizeof(*header), sizeof(*header)); - if (CONFIG_IS_ENABLED(OF_REAL)) { payload_offs = ofnode_conf_read_int("u-boot,spl-payload-offset", payload_offs); } #if CONFIG_IS_ENABLED(OS_BOOT) - if (spl_start_uboot() || spi_load_image_os(spl_image, bootdev, flash, header)) -#endif - { - /* Load u-boot, mkimage header is 64 bytes. */ - err = spi_flash_read(flash, payload_offs, sizeof(*header), - (void *)header); - if (err) { - debug("%s: Failed to read from SPI flash (err=%d)\n", - __func__, err); - return err; - } - - err = spl_load(spl_image, bootdev, &load, header, 0, - payload_offs); + if (spl_start_uboot()) { + int err = spi_do_load_image(spl_image, bootdev, &load, + CONFIG_SYS_SPI_KERNEL_OFFS); + if (!err) + /* Read device tree. */ + return spi_flash_read(flash, CONFIG_SYS_SPI_ARGS_OFFS, + CONFIG_SYS_SPI_ARGS_SIZE, + (void *)CONFIG_SYS_SPL_ARGS_ADDR); } +#endif - return err; + return spi_do_load_image(spl_image, bootdev, &load, payload_offs); } /* Use priorty 1 so that boards can override this */ SPL_LOAD_IMAGE_METHOD("SPI", 1, BOOT_DEVICE_SPI, spl_spi_load_image);