From patchwork Mon Feb 7 18:19:56 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 540571 Delivered-To: patch@linaro.org Received: by 2002:ac0:f7d2:0:0:0:0:0 with SMTP id i18csp344816imr; Mon, 7 Feb 2022 10:22:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQMtKyVoCj3bP1dp9lcaK6P+bgY/fARuwX7nwKdVXDodKSnjGL2f7jzG/bBuly0uC8TRg7 X-Received: by 2002:a05:6402:1e91:: with SMTP id f17mr715059edf.407.1644258129329; Mon, 07 Feb 2022 10:22:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644258129; cv=none; d=google.com; s=arc-20160816; b=pfz1A6ly2G5QwUlSWbP9NArzSxmxh8semQfMVj+H50Eykv7Z3b06t0U3qsp5G90H0e ogiJRJeHNb1Q5vt4G27lmcD+kChiaMThwKbRMys/r4FCVH3TyJjI1qxdZv+U4Ir9adLZ weIPGboqmiC0GQu4+yp0OZW2S6rLP5qeExYPmIXNp/ffOtDNrhaRWfWP1j11VqqBfCoL nZkJlZMqCUMfAUKOxwVaRPFYgreGyOR6eQ5SPuMJDGr1jR6hxy/niVe8buhNqrb3X1dc oS6Yl0S7xzsnnNfuEfJTAAa2B1TcHd040rh+4a0xqab1lEhoz9TebFtTrrn3YW5zUgJu TsLg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:references:in-reply-to :message-id:date:subject:cc:to:from; bh=LqAUW4epP0Q3KjeKtYf1Eh5fm1PmDm7V40A4qGi3FGw=; b=kI0/52ScQUNfV1zQQM0dETgBhx9CBGIs+KXiK5d1PR7oX8D0Fl7qMsTxFveFv/R5kT ZaDv79ClHEJ1XV1q+eNq6yoMF8bnkeZU5p5F+BpvgFOxe74VQ9J+JudTCFE/ICyKSsWJ yYLEKOLaOFkCmHa8ATyTPsaKV2Ju7hIcgoP5ESGvVFDhx0WGJ+a+mnLlaoNCo69fo7VJ XtQ2M+vAJkgGkvSWZSEWu1MP7QuQ1gagFTWT4JEGRzEZshbvLjUhkiIjUUMqhn8SRptS xQF7xvR0ZvC2EcedK4S8QaMRS0uPRhVW8BHeoC0uo89wkItY8ux8z0oDJPtpY1qOp2SY 3rhA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from phobos.denx.de (phobos.denx.de. [2a01:238:438b:c500:173d:9f52:ddab:ee01]) by mx.google.com with ESMTPS id oz32si8384232ejc.168.2022.02.07.10.22.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Feb 2022 10:22:09 -0800 (PST) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 2a01:238:438b:c500:173d:9f52:ddab:ee01 as permitted sender) smtp.mailfrom=u-boot-bounces@lists.denx.de; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 5BF5783BEC; Mon, 7 Feb 2022 19:21:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id F164983BCD; Mon, 7 Feb 2022 19:21:31 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.2 required=5.0 tests=BAYES_00,SPF_HELO_NONE, SPF_SOFTFAIL,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.2 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by phobos.denx.de (Postfix) with ESMTP id 8E155837E2 for ; Mon, 7 Feb 2022 19:21:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=linaro.org Authentication-Results: phobos.denx.de; spf=fail smtp.mailfrom=sughosh.ganu@linaro.org Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 0054211B3; Mon, 7 Feb 2022 10:21:28 -0800 (PST) Received: from a076522.blr.arm.com (a076522.blr.arm.com [10.162.16.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id F3EB33F718; Mon, 7 Feb 2022 10:21:23 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Masami Hiramatsu , Patrick Delaunay , Patrice Chotard , Alexander Graf , AKASHI Takahiro , Simon Glass , Bin Meng , Ilias Apalodimas , Jose Marinho , Grant Likely , Tom Rini , Etienne Carriere , Sughosh Ganu Subject: [PATCH v4 06/11] stm32mp1: Populate ImageTypeId values in EFI_FIRMWARE_IMAGE_DESCRIPTOR array Date: Mon, 7 Feb 2022 23:49:56 +0530 Message-Id: <20220207182001.31270-7-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20220207182001.31270-1-sughosh.ganu@linaro.org> References: <20220207182001.31270-1-sughosh.ganu@linaro.org> 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 The EFI_FIRMWARE_IMAGE_DESCRIPTOR array is returned by the Firmware Management Protocol's(FMP) GetImageInfo function. The image descriptor array contains the ImageTypeId which is a GUID identifying the firmware images that are supported by the instance of the FMP. These ImageTypeId values are compared against the value in the capsule to identify the FMP instance to be used for the capsule. Add a function for the GPT partitioned device based ST platforms for filling up the image descriptor array with the ImageTypeId values. For the GPT partitioned devices, the array can be populated by reading the GPT header which contains the Partition Entry Array, where each entry contains the PartitionTypeGUID for the corresponding image. Signed-off-by: Sughosh Ganu --- Changes since V3: * Define the function fill_image_type_guid_array for the ST DK2 board for GPT partitioned devices. board/st/stm32mp1/stm32mp1.c | 94 ++++++++++++++++++++++++++++++++++++ 1 file changed, 94 insertions(+) diff --git a/board/st/stm32mp1/stm32mp1.c b/board/st/stm32mp1/stm32mp1.c index 5525b69392..fc14c9808b 100644 --- a/board/st/stm32mp1/stm32mp1.c +++ b/board/st/stm32mp1/stm32mp1.c @@ -1021,4 +1021,98 @@ void fwu_plat_get_bootidx(void *boot_idx) *bootidx = readl(TAMP_BOOTCOUNT); } + +static int fill_gpt_partition_guids(struct blk_desc *desc, + efi_guid_t **part_guid_arr) +{ + int i; + u32 part; + int alt_num; + struct dfu_entity *dfu; + struct disk_partition info; + efi_guid_t part_type_guid; + efi_guid_t null_guid = NULL_GUID; + efi_status_t ret = EFI_SUCCESS; + + dfu_init_env_entities(NULL, NULL); + + alt_num = 0; + list_for_each_entry(dfu, &dfu_list, list) { + ++alt_num; + } + + if (!alt_num) { + log_warning("Probably dfu_alt_info not defined\n"); + ret = EFI_NOT_READY; + goto out; + } + + *part_guid_arr = malloc(sizeof(efi_guid_t) * alt_num); + if (!*part_guid_arr) { + ret = EFI_OUT_OF_RESOURCES; + goto out; + } + + for (i = 0; i < alt_num; i++) + guidcpy((*part_guid_arr + i), &null_guid); + + for (i = 0, part = 1; i < alt_num; i++) { + dfu = dfu_get_entity(i); + + if (!dfu) + continue; + + /* + * Currently, Multi Bank update + * feature is being supported + * only on GPT partitioned + * MMC/SD devices. + */ + if (dfu->dev_type != DFU_DEV_MMC) + continue; + + if (part_get_info(desc, part, &info)) { + part++; + continue; + } + + uuid_str_to_bin(info.type_guid, part_type_guid.b, + UUID_STR_FORMAT_GUID); + guidcpy((*part_guid_arr + i), &part_type_guid); + part++; + } + +out: + dfu_free_entities(); + + return ret; +} + +efi_status_t fill_image_type_guid_array(const efi_guid_t __always_unused + *default_guid, + efi_guid_t **part_guid_arr) +{ + int ret; + struct udevice *dev; + struct blk_desc *desc; + + /* + * Get the storage device on which the + * FWU metadata has been stored + */ + ret = fwu_get_mdata_device(&dev); + if (ret) { + log_err("Unable to get FWU metadata device\n"); + return EFI_DEVICE_ERROR; + } + + desc = dev_get_uclass_plat(dev); + if (!desc) { + log_err("Block device not found\n"); + return EFI_DEVICE_ERROR; + } + + return fill_gpt_partition_guids(desc, part_guid_arr); +} + #endif /* CONFIG_FWU_MULTI_BANK_UPDATE */