From patchwork Mon Jan 22 11:54:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 764630 Delivered-To: patch@linaro.org Received: by 2002:a05:6000:10c4:b0:337:62d3:c6d5 with SMTP id b4csp1059428wrx; Mon, 22 Jan 2024 03:57:11 -0800 (PST) X-Google-Smtp-Source: AGHT+IG4j9a3++LLzBW0KRpSlu5bH1R3Xa3obuyOK9CHP0V2wdA9D+hK4nQ2BQWq89QPx0HuInHf X-Received: by 2002:a5d:4a0d:0:b0:337:aa5b:c4ee with SMTP id m13-20020a5d4a0d000000b00337aa5bc4eemr1980778wrq.116.1705924631215; Mon, 22 Jan 2024 03:57:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1705924631; cv=none; d=google.com; s=arc-20160816; b=NKJypaI74N0WZTGpnkD3ANCqpnGY/v01EumUg4afJY+67AOypfIUm3Lhoc4oTr+Z19 QlaFrTunhabmkWMLunppdkq4oGIEbuu1dMkX+aP31XnoFeuUV9FAUcwJpafdtRtwkDaa VGcxEijmH+zv5B5v2Q/xy9IqsTURyDD8OP9Xxv62pmyt4OGgFVp3h23O+eRUnOXjl7Rc YtDHvqTf2i3ztwrfoFhfz2n7BI+lSKq9DkY9grT3eJjFVkaEeWeQ7G8iwRSALFq87y+U LOxdcHe58joajvrpfYpUkT6PmERwbc+/mLR5h0CcEOyHbuqIBFZYeBYSnGhRoehS4F3u 5grw== 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=CZTA2LA5AT3Vcke11TicoqLAN7fFe7A9C/LmzCMxMdA=; fh=rhmJ78R78zNUSUA9Nt0a5TbZO4CVsI4vi5GcqSIe+nI=; b=R3FTKYUA8Jtp29/E6ytYuAIMPQ6nWxa8vNlRqG68zuubGLt1uxkWjUM2thgx+rjPf5 C3H0O0nNr/sgOgwfjxCPYFWnubAHd0Y7IfsomfbXMlL89bvU9F5zhFxjsk20SGsMKovK +xPVM7vdkh228R4eABtMpplOl45oMnJKMnOSQYD113ZbEgADx+EvzCYPnqrv5ilsZC25 u46ygH4vjLSCU+Ou9ybK3cdUNS/WeiCMgHHKsZpPdgu5OHJvMbyoC2atfdN/7meU7wVm fb0S04wJH7HnRT+dlbO0He8wei5unIxgmywlDBzzaJKHqiEZvswR56b+DNLxi3Zp982B JHKA== 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 b7-20020a5d45c7000000b00337d58c4bc5si4766416wrs.695.2024.01.22.03.57.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 22 Jan 2024 03:57:11 -0800 (PST) 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 610C087BBC; Mon, 22 Jan 2024 12:55:54 +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 B0DB687C9B; Mon, 22 Jan 2024 12:55:53 +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 5410E87C0B for ; Mon, 22 Jan 2024 12:55:50 +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 D24E81FB; Mon, 22 Jan 2024 03:56:35 -0800 (PST) Received: from a079122.blr.arm.com (a079122.arm.com [10.162.17.48]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 2AB643F73F; Mon, 22 Jan 2024 03:55:46 -0800 (PST) From: Sughosh Ganu To: u-boot@lists.denx.de Cc: Heinrich Schuchardt , Ilias Apalodimas , Masahisa Kojima , Patrice Chotard , Patrick Delaunay , Yann Gautier , Etienne Carriere , Sughosh Ganu Subject: [PATCH 12/18] efi_firmware: fwu: Get the number of FWU banks at runtime Date: Mon, 22 Jan 2024 17:24:33 +0530 Message-Id: <20240122115439.653871-13-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240122115439.653871-1-sughosh.ganu@linaro.org> References: <20240122115439.653871-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.8 at phobos.denx.de X-Virus-Status: Clean With the migration of the FWU metadata to version 2, the number of banks are now obtained at runtime, instead of the config symbols. Make use of the API to get the number of banks in the versioning functions. Signed-off-by: Sughosh Ganu --- lib/efi_loader/efi_firmware.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/efi_loader/efi_firmware.c b/lib/efi_loader/efi_firmware.c index 51797a169f..74f241015d 100644 --- a/lib/efi_loader/efi_firmware.c +++ b/lib/efi_loader/efi_firmware.c @@ -207,7 +207,8 @@ void efi_firmware_fill_version_info(struct efi_firmware_image_descriptor *image_ u16 varname[13]; /* u"FmpStateXXXX" */ efi_status_t ret; efi_uintn_t size, expected_size; - uint num_banks = 1; + u8 num_banks = 1; + u16 __maybe_unused num_images; uint active_index = 0; struct fmp_state *var_state; @@ -229,7 +230,9 @@ void efi_firmware_fill_version_info(struct efi_firmware_image_descriptor *image_ if (ret) return; - num_banks = CONFIG_FWU_NUM_BANKS; + ret = fwu_get_banks_images(&num_banks, &num_images); + if (ret) + return; } size = num_banks * sizeof(*var_state); @@ -379,7 +382,8 @@ efi_status_t efi_firmware_set_fmp_state_var(struct fmp_state *state, u8 image_in { u16 varname[13]; /* u"FmpStateXXXX" */ efi_status_t ret; - uint num_banks = 1; + u8 num_banks = 1; + u16 __maybe_unused num_images; uint update_bank = 0; efi_uintn_t size; efi_guid_t *image_type_id; @@ -398,7 +402,9 @@ efi_status_t efi_firmware_set_fmp_state_var(struct fmp_state *state, u8 image_in if (ret) return EFI_INVALID_PARAMETER; - num_banks = CONFIG_FWU_NUM_BANKS; + ret = fwu_get_banks_images(&num_banks, &num_images); + if (ret) + return EFI_INVALID_PARAMETER; } size = num_banks * sizeof(*var_state);