From patchwork Wed May 16 05:35:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Keguang Zhang X-Patchwork-Id: 914548 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="cdlFSBnE"; dkim-atps=neutral Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 40mB6W10Gwz9s33 for ; Wed, 16 May 2018 20:50:27 +1000 (AEST) Received: by lists.denx.de (Postfix, from userid 105) id C38E8C21D9A; Wed, 16 May 2018 10:49:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=-0.0 required=5.0 tests=FREEMAIL_FROM, RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id D78CBC21DF8; Wed, 16 May 2018 10:47:58 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 26AF8C21C27; Wed, 16 May 2018 05:36:24 +0000 (UTC) Received: from mail-pl0-f67.google.com (mail-pl0-f67.google.com [209.85.160.67]) by lists.denx.de (Postfix) with ESMTPS id A2568C21BE5 for ; Wed, 16 May 2018 05:36:22 +0000 (UTC) Received: by mail-pl0-f67.google.com with SMTP id bi12-v6so1433495plb.12 for ; Tue, 15 May 2018 22:36:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=9ek31oBBOQ3yMdaNrT4r6fAGv/DboMChCr/DQ/sNlkY=; b=cdlFSBnEc2TEDf8ECLUolVA4ofwvmSHOhqqBIWOod198YuM3bkcW37loafgfuq9Giq 1tv0luGJ2kuUUHMPR5hwhsErtsMGSO49P1yOjQMgh0IHaXjAgZM0dU7xV+KxPPd7sDkM V7GS57/yg8uPcIXy9lO/KqACN8XitGs1SG0wB0uMY7A8M9klzkx9XEHp+EZNTjlENtuL 4xvbiPXqG1NuF9mE4ha5IRlE0xw7/prEjDlxHqcB2fLfTrinCTw+RfOiaC9yCX4T75Hb Z1gTX43DWkSr943CvT4tUEax/uvYuwaCfdVXjfddKUpXEkAsFSYQLHlr9gHRKVXS1oNm uL4w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=9ek31oBBOQ3yMdaNrT4r6fAGv/DboMChCr/DQ/sNlkY=; b=ahMN9kHiDzw+CjI+KTrnMW2cLFscbCe1+OcsTCNuARgnfXFaRuM0+06MUwvWm3I1QD VhyOWc/j7bI5bnVUKYQ7wWTtzexnVLglAmd09PaK6nZUr1cU3rse2qF6zYwn/jKQXjCU evMAr3EPdLohZFq3d+505wGb24mm/+VFxHzapp6Ct6OqHEbCPFXf5a6Jf7hyz5RrmBEP Ok3IehN24DPKcCnbs2EETERHpnC2pP/xpJ64opF6a2hRkiGHH7CcxCGlgs6gEUouHkT3 9t8FCth2FOnjCzSIvFcGPhE+VFgaAmCbycVqLbrU3RQSgIGI4N7ISfk1ZJ6PDJv5sptZ itbQ== X-Gm-Message-State: ALKqPwffLQadjf4ylM/IWSGf9O4WCK2m9W5ZX0xBrXpFGnhOkNZd7pc8 IU+kwRItKfViWqjimeAj8GUBIBG8 X-Google-Smtp-Source: AB8JxZogBvNtoO31FOxZWPT5ewZibUHcLlYWgHGNw7BdrGMXrpjA0qbCXVWks9yo9M/ScmzG6kDcKA== X-Received: by 2002:a17:902:822:: with SMTP id 31-v6mr17756693plk.172.1526448980729; Tue, 15 May 2018 22:36:20 -0700 (PDT) Received: from localhost.localdomain ([117.18.48.82]) by smtp.gmail.com with ESMTPSA id p71-v6sm2425558pfl.170.2018.05.15.22.36.17 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 15 May 2018 22:36:20 -0700 (PDT) From: Kelvin Cheung To: u-boot@lists.denx.de Date: Wed, 16 May 2018 13:35:39 +0800 Message-Id: <1526448939-23869-1-git-send-email-keguang.zhang@gmail.com> X-Mailer: git-send-email 1.9.1 X-Mailman-Approved-At: Wed, 16 May 2018 10:47:56 +0000 Cc: Andre Przywara , Pantelis Antoniou , Michal Simek , Kelvin Cheung Subject: [U-Boot] [PATCH] common: image-fit: add FIT data-position & data-offset property support X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" Add FIT data-position & data-offset property support for bootm, which are already supported in SPL. Signed-off-by: Kelvin Cheung --- common/image-fit.c | 82 +++++++++++++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 78 insertions(+), 4 deletions(-) diff --git a/common/image-fit.c b/common/image-fit.c index 5b93dce..f21db4b 100644 --- a/common/image-fit.c +++ b/common/image-fit.c @@ -359,11 +359,14 @@ void fit_image_print(const void *fit, int image_noffset, const char *p) { char *desc; uint8_t type, arch, os, comp; - size_t size; + size_t size = 0; ulong load, entry; const void *data; int noffset; int ndepth; + bool external_data = false; + int offset; + int len; int ret; /* Mandatory properties */ @@ -391,7 +394,27 @@ void fit_image_print(const void *fit, int image_noffset, const char *p) fit_image_get_comp(fit, image_noffset, &comp); printf("%s Compression: %s\n", p, genimg_get_comp_name(comp)); - ret = fit_image_get_data(fit, image_noffset, &data, &size); + if (!fit_image_get_data_position(fit, image_noffset, &offset)) { + external_data = true; + } else if (!fit_image_get_data_offset(fit, image_noffset, &offset)) { + external_data = true; + /* + * For FIT with external data, figure out where + * the external images start. This is the base + * for the data-offset properties in each image. + */ + size = (fdt_totalsize(fit) + 3) & ~3; + offset += size; + } + + if (external_data) { + printf("%s External Data\n", p); + ret = fit_image_get_data_size(fit, image_noffset, &len); + data = fit + offset; + size = len; + } else { + ret = fit_image_get_data(fit, image_noffset, &data, &size); + } #ifndef USE_HOSTCC printf("%s Data Start: ", p); @@ -1151,9 +1174,35 @@ int fit_image_verify(const void *fit, int image_noffset) size_t size; int noffset = 0; char *err_msg = ""; + bool external_data = false; + int offset; + int len; + int ret; /* Get image data and data length */ - if (fit_image_get_data(fit, image_noffset, &data, &size)) { + if (!fit_image_get_data_position(fit, image_noffset, &offset)) { + external_data = true; + } else if (!fit_image_get_data_offset(fit, image_noffset, &offset)) { + external_data = true; + /* + * For FIT with external data, figure out where + * the external images start. This is the base + * for the data-offset properties in each image. + */ + size = (fdt_totalsize(fit) + 3) & ~3; + offset += size; + } + + if (external_data) { + debug("External Data\n"); + ret = fit_image_get_data_size(fit, image_noffset, &len); + data = fit + offset; + size = len; + } else { + ret = fit_image_get_data(fit, image_noffset, &data, &size); + } + + if (ret) { err_msg = "Can't get image data/size"; printf("error!\n%s for '%s' hash node in '%s' image node\n", err_msg, fit_get_name(fit, noffset, NULL), @@ -1750,6 +1799,9 @@ int fit_image_load(bootm_headers_t *images, ulong addr, uint8_t os_arch; #endif const char *prop_name; + bool external_data = false; + int offset; + int data_len; int ret; fit = map_sysmem(addr, 0); @@ -1875,7 +1927,29 @@ int fit_image_load(bootm_headers_t *images, ulong addr, bootstage_mark(bootstage_id + BOOTSTAGE_SUB_CHECK_ALL_OK); /* get image data address and length */ - if (fit_image_get_data(fit, noffset, &buf, &size)) { + if (!fit_image_get_data_position(fit, noffset, &offset)) { + external_data = true; + } else if (!fit_image_get_data_offset(fit, noffset, &offset)) { + external_data = true; + /* + * For FIT with external data, figure out where + * the external images start. This is the base + * for the data-offset properties in each image. + */ + size = (fdt_totalsize(fit) + 3) & ~3; + offset += size; + } + + if (external_data) { + debug("External Data\n"); + ret = fit_image_get_data_size(fit, noffset, &data_len); + buf = fit + offset; + size = data_len; + } else { + ret = fit_image_get_data(fit, noffset, &buf, &size); + } + + if (ret) { printf("Could not find %s subimage data!\n", prop_name); bootstage_error(bootstage_id + BOOTSTAGE_SUB_GET_DATA); return -ENOENT;