From patchwork Wed Jun 1 18:00:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 577795 Delivered-To: patch@linaro.org Received: by 2002:a05:7000:8f0c:0:0:0:0 with SMTP id mq12csp834119mab; Wed, 1 Jun 2022 11:01:58 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzVBeZry70KJdgeQ+Kj7AdQKYm3oW2hOlyRfSBc5c7qZrBs/xlZSXmkmShIpodzfBdrper9 X-Received: by 2002:a05:6e02:18cd:b0:2cf:282c:be02 with SMTP id s13-20020a056e0218cd00b002cf282cbe02mr802198ilu.114.1654106517810; Wed, 01 Jun 2022 11:01:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654106517; cv=none; d=google.com; s=arc-20160816; b=hgtLHstUE05dgjY1KSwdKM2GoVSfCa67zGlsKrYemNsS323/Zjd4rKlDoGi5O5zhOO KAUAWTvFQwhTIjQM25XLR1jpJR6rgAPwc2JeSnS5ij22M7fsqd5jhGmKDViX2ajSJ+4N T7Osvhg6pDBjoHv02zlXlaejccYEd3LIzHcHQhZ8eihKyeY7VzUPqnWfrOXuphwkaARi O9tMROHXEKJxYSQTJWMnCL1emcYUqONcaRNO8zd0H348PU9hkg/e8cfTLlplTNxQt1pl E+iOVUx+oN2H38+zA5v8hxuFWNiiq9+3b7TYRtCGL4amhTDDyNPzOjFxN49fVjMYGhsG kKfA== 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:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from; bh=jUKficrefF1qUBIuBK/64V8fW4fdF/Hm1EFMn5UoLQ8=; b=RgM/GCzQxzDjr4zbT7USA6GpLtKnD0/GDlhS+wlrMcLTXkKOcQD3+fdTJU6lPgKgxS ZYo2vgbzyjA+4yU+9BfFXHNVoqY2XVu1akX7l/5C9zRJ33o3KjT78fBhq0hJC0hX/8ga ENpVUEvitIt4kIMTuLtk1tecW5OVgllm3517H+Co2T0ycX4PSqpJk1HGGvBzdSOhnr8J psKJwstQjd9txVpxwoGTmbgU5kgHWN88LvE3l08twNdfiAY3egy4GOv2kgAom+PEFjOu YA80EEQXBXI69rnyv+zSseMEcNO9LL3KuMnWm/ry28C2LypERz0epnB+FiE+0BuLfxTX DCdw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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. [85.214.62.61]) by mx.google.com with ESMTPS id p8-20020a056e02144800b002cde0eaf204si3481850ilo.15.2022.06.01.11.01.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jun 2022 11:01:57 -0700 (PDT) Received-SPF: pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 as permitted sender) client-ip=85.214.62.61; Authentication-Results: mx.google.com; spf=pass (google.com: domain of u-boot-bounces@lists.denx.de designates 85.214.62.61 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 1DB3D8431C; Wed, 1 Jun 2022 20:01:20 +0200 (CEST) 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 D7A5F842FE; Wed, 1 Jun 2022 20:01: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=-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 CDC61842D4 for ; Wed, 1 Jun 2022 20:01:09 +0200 (CEST) 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 1572DD6E; Wed, 1 Jun 2022 11:01:09 -0700 (PDT) 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 598F53F766; Wed, 1 Jun 2022 11:01:07 -0700 (PDT) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Takahiro Akashi , Sughosh Ganu Subject: [PATCH v2 4/4] EFI: FMP: Use a common GetImageInfo function for FIT and raw images Date: Wed, 1 Jun 2022 23:30:41 +0530 Message-Id: <20220601180041.340240-5-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20220601180041.340240-1-sughosh.ganu@linaro.org> References: <20220601180041.340240-1-sughosh.ganu@linaro.org> MIME-Version: 1.0 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 GetImageInfo function definitions for the FIT images and raw images are the same. Use a common function for the both the Firmware Management Protocol(FMP) instances for raw and FIT images. Signed-off-by: Sughosh Ganu --- Changes since V1: None lib/efi_loader/efi_firmware.c | 80 ++++++----------------------------- 1 file changed, 14 insertions(+), 66 deletions(-) diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c index 9cdefab41f..0ffee3fb1f 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -177,18 +177,8 @@ static efi_status_t efi_fill_image_desc_array( return EFI_SUCCESS; } -#ifdef CONFIG_EFI_CAPSULE_FIRMWARE_FIT -/* - * This FIRMWARE_MANAGEMENT_PROTOCOL driver provides a firmware update - * method with existing FIT image format, and handles - * - multiple regions of firmware via DFU - * but doesn't support - * - versioning of firmware image - * - package information - */ - /** - * efi_firmware_fit_get_image_info - return information about the current + * efi_firmware_get_image_info - return information about the current * firmware image * @this: Protocol instance * @image_info_size: Size of @image_info @@ -206,7 +196,7 @@ static efi_status_t efi_fill_image_desc_array( * Return status code */ static -efi_status_t EFIAPI efi_firmware_fit_get_image_info( +efi_status_t EFIAPI efi_firmware_get_image_info( struct efi_firmware_management_protocol *this, efi_uintn_t *image_info_size, struct efi_firmware_image_descriptor *image_info, @@ -239,6 +229,16 @@ efi_status_t EFIAPI efi_firmware_fit_get_image_info( return EFI_EXIT(ret); } +#ifdef CONFIG_EFI_CAPSULE_FIRMWARE_FIT +/* + * This FIRMWARE_MANAGEMENT_PROTOCOL driver provides a firmware update + * method with existing FIT image format, and handles + * - multiple regions of firmware via DFU + * but doesn't support + * - versioning of firmware image + * - package information + */ + /** * efi_firmware_fit_set_image - update the firmware image * @this: Protocol instance @@ -278,7 +278,7 @@ efi_status_t EFIAPI efi_firmware_fit_set_image( } const struct efi_firmware_management_protocol efi_fmp_fit = { - .get_image_info = efi_firmware_fit_get_image_info, + .get_image_info = efi_firmware_get_image_info, .get_image = efi_firmware_get_image_unsupported, .set_image = efi_firmware_fit_set_image, .check_image = efi_firmware_check_image_unsupported, @@ -293,58 +293,6 @@ const struct efi_firmware_management_protocol efi_fmp_fit = { * method with raw data. */ -/** - * efi_firmware_raw_get_image_info - return information about the current - * firmware image - * @this: Protocol instance - * @image_info_size: Size of @image_info - * @image_info: Image information - * @descriptor_version: Pointer to version number - * @descriptor_count: Pointer to number of descriptors - * @descriptor_size: Pointer to descriptor size - * @package_version: Package version - * @package_version_name: Package version's name - * - * Return information bout the current firmware image in @image_info. - * @image_info will consist of a number of descriptors. - * Each descriptor will be created based on "dfu_alt_info" variable. - * - * Return status code - */ -static -efi_status_t EFIAPI efi_firmware_raw_get_image_info( - struct efi_firmware_management_protocol *this, - efi_uintn_t *image_info_size, - struct efi_firmware_image_descriptor *image_info, - u32 *descriptor_version, - u8 *descriptor_count, - efi_uintn_t *descriptor_size, - u32 *package_version, - u16 **package_version_name) -{ - efi_status_t ret = EFI_SUCCESS; - - EFI_ENTRY("%p %p %p %p %p %p %p %p\n", this, - image_info_size, image_info, - descriptor_version, descriptor_count, descriptor_size, - package_version, package_version_name); - - if (!image_info_size) - return EFI_EXIT(EFI_INVALID_PARAMETER); - - if (*image_info_size && - (!image_info || !descriptor_version || !descriptor_count || - !descriptor_size || !package_version || !package_version_name)) - return EFI_EXIT(EFI_INVALID_PARAMETER); - - ret = efi_fill_image_desc_array(image_info_size, image_info, - descriptor_version, descriptor_count, - descriptor_size, package_version, - package_version_name); - - return EFI_EXIT(ret); -} - /** * efi_firmware_raw_set_image - update the firmware image * @this: Protocol instance @@ -430,7 +378,7 @@ efi_status_t EFIAPI efi_firmware_raw_set_image( } const struct efi_firmware_management_protocol efi_fmp_raw = { - .get_image_info = efi_firmware_raw_get_image_info, + .get_image_info = efi_firmware_get_image_info, .get_image = efi_firmware_get_image_unsupported, .set_image = efi_firmware_raw_set_image, .check_image = efi_firmware_check_image_unsupported,