From nobody Sat Nov 2 14:40:03 2024 Delivered-To: importer@patchew.org Received-SPF: none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) client-ip=198.145.21.10; envelope-from=edk2-devel-bounces@lists.01.org; helo=ml01.01.org; Authentication-Results: mx.zoho.com; spf=none (zoho.com: 198.145.21.10 is neither permitted nor denied by domain of lists.01.org) smtp.mailfrom=edk2-devel-bounces@lists.01.org; Return-Path: Received: from ml01.01.org (ml01.01.org [198.145.21.10]) by mx.zohomail.com with SMTPS id 1489534399219524.5472251815715; Tue, 14 Mar 2017 16:33:19 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 8E55780400; Tue, 14 Mar 2017 16:33:08 -0700 (PDT) Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 2CF13803F7 for ; Tue, 14 Mar 2017 16:33:07 -0700 (PDT) Received: from int-mx10.intmail.prod.int.phx2.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BD0D3C04B95E; Tue, 14 Mar 2017 23:33:07 +0000 (UTC) Received: from lacos-laptop-7.usersys.redhat.com (ovpn-116-194.phx2.redhat.com [10.3.116.194]) by int-mx10.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v2ENWpwe006449; Tue, 14 Mar 2017 19:33:06 -0400 X-Original-To: edk2-devel@ml01.01.org From: Laszlo Ersek To: edk2-devel-01 Date: Wed, 15 Mar 2017 00:32:42 +0100 Message-Id: <20170314233246.17864-11-lersek@redhat.com> In-Reply-To: <20170314233246.17864-1-lersek@redhat.com> References: <20170314233246.17864-1-lersek@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 14 Mar 2017 23:33:07 +0000 (UTC) Subject: [edk2] [PATCH 10/14] OvmfPkg: introduce FlashNvStorageAddressLib X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Errors-To: edk2-devel-bounces@lists.01.org Sender: "edk2-devel" X-ZohoMail: RSF_4 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" An OVMF binary built with -D SMM_REQUIRE or with -D MEM_VARSTORE_EMU_ENABLE=3DFALSE requires flash to be present at the expected (build-time determined) location; falling back to the emulated varstore is not possible. In such builds, we can replace the settings of the - varstore, - FTW working block, - and FTW spare area address PCDs in QemuFlashFvbServicesRuntimeDxe with identical settings in a new plug-in (NULL class) library, to be linked into variable-related PEIMs. This will enable such builds to access variables during the PEI phase, without dynamic flash detection and without ordering constraints against other PEIMs. Cc: Jordan Justen Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Laszlo Ersek --- OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddressLib.inf | 48= ++++++++++++++++++ OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddressLib.c | 53= ++++++++++++++++++++ 2 files changed, 101 insertions(+) diff --git a/OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddress= Lib.inf b/OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddressLib= .inf new file mode 100644 index 000000000000..f79194f80de9 --- /dev/null +++ b/OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddressLib.inf @@ -0,0 +1,48 @@ +## @file +# +# A hook-in library for variable-related PEIMs, in order to set +# - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64, +# - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase, +# - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase, +# from their gUefiOvmfPkgTokenSpaceGuid counterparts, just before those PE= IMs +# consume them. +# +# Copyright (C) 2017, Red Hat, Inc. +# +# This program and the accompanying materials are licensed and made availa= ble +# under the terms and conditions of the BSD License which accompanies this +# distribution. The full text of the license may be found at +# http://opensource.org/licenses/bsd-license.php +# +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WI= THOUT +# WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. +# +## + +[Defines] + INF_VERSION =3D 1.25 + BASE_NAME =3D FlashNvStorageAddressLib + FILE_GUID =3D 5FF5A9F9-D01E-49EC-9A17-1682FC85122F + MODULE_TYPE =3D BASE + VERSION_STRING =3D 1.0 + LIBRARY_CLASS =3D FlashNvStorageAddressLib|PEIM + CONSTRUCTOR =3D SetFlashNvStorageAddresses + +[Sources] + FlashNvStorageAddressLib.c + +[Packages] + MdePkg/MdePkg.dec + MdeModulePkg/MdeModulePkg.dec + OvmfPkg/OvmfPkg.dec + +[LibraryClasses] + PcdLib + +[Pcd] + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwSpareBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwWorkingBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageVariableBase diff --git a/OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddress= Lib.c b/OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddressLib.c new file mode 100644 index 000000000000..dc1280cc23f1 --- /dev/null +++ b/OvmfPkg/Library/FlashNvStorageAddressLib/FlashNvStorageAddressLib.c @@ -0,0 +1,53 @@ +/** @file + + A hook-in library for variable-related PEIMs, in order to set + - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64, + - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase, + - gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase, + from their gUefiOvmfPkgTokenSpaceGuid counterparts, just before those PE= IMs + consume them. + + Copyright (C) 2017, Red Hat, Inc. + + This program and the accompanying materials are licensed and made availa= ble + under the terms and conditions of the BSD License which accompanies this + distribution. The full text of the license may be found at + http://opensource.org/licenses/bsd-license.php + + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WI= THOUT + WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + +**/ + +#include + +RETURN_STATUS +EFIAPI +SetFlashNvStorageAddresses ( + VOID + ) +{ + RETURN_STATUS PcdStatus; + + PcdStatus =3D PcdSet64S ( + PcdFlashNvStorageVariableBase64, + PcdGet32 (PcdOvmfFlashNvStorageVariableBase) + ); + if (RETURN_ERROR (PcdStatus)) { + return PcdStatus; + } + + PcdStatus =3D PcdSet32S ( + PcdFlashNvStorageFtwWorkingBase, + PcdGet32 (PcdOvmfFlashNvStorageFtwWorkingBase) + ); + if (RETURN_ERROR (PcdStatus)) { + return PcdStatus; + } + + PcdStatus =3D PcdSet32S ( + PcdFlashNvStorageFtwSpareBase, + PcdGet32 (PcdOvmfFlashNvStorageFtwSpareBase) + ); + return PcdStatus; +} --=20 2.9.3 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel