From patchwork Mon Feb 12 07:47:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sughosh Ganu X-Patchwork-Id: 772035 Delivered-To: patch@linaro.org Received: by 2002:adf:9dca:0:b0:33b:4db1:f5b3 with SMTP id q10csp2000732wre; Sun, 11 Feb 2024 23:49:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IEOUWcP93MLG+D3KGAxaHybtDN2AUadlzbdT8HsgeD2DQlmZ126mf+J12oNdl4jciyg0P16 X-Received: by 2002:a17:906:fb91:b0:a3c:8e78:8b59 with SMTP id lr17-20020a170906fb9100b00a3c8e788b59mr2185865ejb.15.1707724190475; Sun, 11 Feb 2024 23:49:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1707724190; cv=none; d=google.com; s=arc-20160816; b=yopa4cm0SOVyqZ+YQPh5qxlYAksK18hafa5SawjJAC/s11G7UAHF+xQ2b87x00WmTd LZke6e90RLFJTKd1ojpXSA97JpfPznnyKd9bjPRSJDoLzLLh1G77CO8xlHZ26moT5vh2 1rGa8EODgOE1lRroU1uApH80RqV38uO/dyCqjT9tSPjVcJAgJb0Ji3u81j1hZHy6M6GA 496VvLa5KWqkw8/Y5eVRidf4iulrQ7/1DKZzG2wATeGM7Wf/1kU/61S6az3WJNqOabXa 8wZgM41vmb8Hk0F+BnTcjXisdnKe5TuukTCyiTwmSeCqG0D4zpwIZA57ON/0wFLxOSB/ TO4g== 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=XQ+Je8cNHWJ3PTly8nrDE2q4TQfl8iwdG+2xdTCcAcU=; fh=D3bFdOmJcMUdGZFNSA+qVq0LaWny8rzHVSf56m18rSw=; b=T/Ay8vL7Y8rKMue7FGX4rnipq1C9EXA641GPbEdJGY4mpktO9Pb8Uuf2Zedpem3SHB VdQqzoT/oNuaZanbFvXzWwGbnAfDk0yW4krz5tvyejfVhXG5JjQCWvTHp1g1ExQDuBwK Kyot1U1zn+c+NGLFRMKEUfd17C87WjvI6ucVQKWOHuuWuRpB6fmFYsV11wr2Q1Lbk2Fi GrHTfzSSMiv5cYtgPNJhiznc+OmJkDXVTIf0VowrTWxqQWN0CRuS6eodndOFPJOLoE5K 0hG5fD1wXL3WYd2p+4yd+XLYbf3W8Pm79ipxc9ji/khtFMUCrBBwwJ8KipBX1xgmR0RK yiiQ==; darn=linaro.org 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 X-Forwarded-Encrypted: i=1; AJvYcCXG+X79gZReMqmY70TGI4qw1fnjwVef1GOt62AyrYKvXEZV5BmC51bgVlTzlA5ZtIXSxNTEkXuAe05CxkdZ09OcLxiddG/Ha44bG4Vwmm0UQtBT2N1ctwN3CsijXvn+s/vpsmkRLqqyj8CmyVqFLBsvf+ZZn27FDsirZRojy9QIgWNWXG/HetUsQ3cilNNlO3puNuzR7S0i37kxIf7DAes8aYzRqiVI2KPSrU5pnlghjX7J5TMo5kppY0v/Mfy+wKUJkC6tc9ou6t7N6joYAe3x0VRSOU2Ti2PWw7tFC08lGtTjwxPiKJmHRjhzuYGwGnRAdqxYb6FR01N8rNUdMIDcM8zGFhrRmeSDM6uuGexQ6jrIRltlj/p8FmJOvAUOHRv12Gk/t8gzL+Sbhwz0CAUOa22Hfywc0cAaquRsoAqxCDKGUgkQBgik2gJrV0mAWaKGWuynVQuhnhYPXv+6BT9q7Rmml5YWKALJE9boaqOj73uPFYuiyANdiLOvogw9rSsacfW7oJS36T0PZlxByGKdIhIx1Ej2u4AQoXPqWN2EnY8wWpxhixUdyXqq02SFfzRWu6E1BJitjdXa/em4bmswtlmtYgpRbadwJO164K5YD7mLj600dvE0Cadof4amlHIFWY6wldi6fCag95CJljcdOCxXxTTO5s6wtLCSB+/teaxtR67MPYI5Eek1yDO+uoPJugrz51OBQrrUR8mv20COUnYk/qNCX+3ht4vPXCEuk3cNAZ9JUxYOE+SDTH0pBph98FkjXiDLCuK+qZjFt046A4QvX8emnow8niv5phdx5eB2fjidooCwv64nBQGSuF9fX1RHQ/rq2HT6/x0mgAPjMpvM2NnEuT+lYiMsxwyDFwU= Return-Path: Received: from phobos.denx.de (phobos.denx.de. [85.214.62.61]) by mx.google.com with ESMTPS id y19-20020a170906559300b00a3723f1f1c3si3700038ejp.33.2024.02.11.23.49.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 11 Feb 2024 23:49:50 -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 8384A87EF6; Mon, 12 Feb 2024 08:48:26 +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 4353C87EFB; Mon, 12 Feb 2024 08:48:25 +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 4A00687EF4 for ; Mon, 12 Feb 2024 08:48:23 +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 5652ADA7; Sun, 11 Feb 2024 23:49:04 -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 894473F762; Sun, 11 Feb 2024 23:48:19 -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 , Michal Simek , Jassi Brar , Sughosh Ganu Subject: [PATCH v2 13/21] efi_firmware: fwu: get the number of FWU banks at runtime Date: Mon, 12 Feb 2024 13:17:04 +0530 Message-Id: <20240212074712.3657076-14-sughosh.ganu@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240212074712.3657076-1-sughosh.ganu@linaro.org> References: <20240212074712.3657076-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 --- Changes since V1: None 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 c742e23268..26d2916ee1 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);