From nobody Sat Nov 2 12:25:34 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 1490602157258794.6391805577924; Mon, 27 Mar 2017 01:09:17 -0700 (PDT) Received: from [127.0.0.1] (localhost [IPv6:::1]) by ml01.01.org (Postfix) with ESMTP id 44A3820084759; Mon, 27 Mar 2017 01:08:59 -0700 (PDT) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (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 AE3CE203BEBF5 for ; Mon, 27 Mar 2017 01:08:56 -0700 (PDT) Received: from fmsmga005.fm.intel.com ([10.253.24.32]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Mar 2017 01:08:56 -0700 Received: from junghyun-mobl.amr.corp.intel.com (HELO jljusten-skl.amr.corp.intel.com) ([10.252.131.12]) by fmsmga005.fm.intel.com with ESMTP; 27 Mar 2017 01:08:56 -0700 X-Original-To: edk2-devel@lists.01.org DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=intel.com; i=@intel.com; q=dns/txt; s=intel; t=1490602136; x=1522138136; h=from:to:cc:subject:date:message-id:in-reply-to: references; bh=zanHpqemdOOekzMge/GpSlUiPsoMETOjdPH9r5f6zKA=; b=nS/J/j619P2W6BgiiCJxvX3doyLPvNkF310c/6Q1a6E4A3p88vT1UtI5 Oz6ghA/KL3ANRx0zrvlO1R2KBWhUdA==; X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.36,229,1486454400"; d="scan'208";a="80948373" From: Jordan Justen To: edk2-devel@lists.01.org Date: Mon, 27 Mar 2017 01:05:41 -0700 Message-Id: <20170327080544.24748-10-jordan.l.justen@intel.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170327080544.24748-1-jordan.l.justen@intel.com> References: <20170327080544.24748-1-jordan.l.justen@intel.com> Subject: [edk2] [PATCH 09/12] OvmfPkg PlatformPei: Set flash variable PCDs X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Justen , Laszlo Ersek 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" This allows the PEI based variable drivers to run. Cc: Laszlo Ersek Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jordan Justen --- OvmfPkg/PlatformPei/Platform.c | 34 +--------- OvmfPkg/PlatformPei/Platform.h | 7 ++- OvmfPkg/PlatformPei/PlatformPei.inf | 10 ++- OvmfPkg/PlatformPei/Vars.c | 122 ++++++++++++++++++++++++++++++++= ++++ 4 files changed, 140 insertions(+), 33 deletions(-) create mode 100644 OvmfPkg/PlatformPei/Vars.c diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c index 77a8a16c15..2e943d6e7b 100644 --- a/OvmfPkg/PlatformPei/Platform.c +++ b/OvmfPkg/PlatformPei/Platform.c @@ -1,7 +1,7 @@ /**@file Platform PEI driver =20 - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
Copyright (c) 2011, Andrei Warkentin =20 This program and the accompanying materials @@ -499,35 +499,6 @@ BootModeInitialization ( =20 =20 VOID -ReserveEmuVariableNvStore ( - ) -{ - EFI_PHYSICAL_ADDRESS VariableStore; - RETURN_STATUS PcdStatus; - - // - // Allocate storage for NV variables early on so it will be - // at a consistent address. Since VM memory is preserved - // across reboots, this allows the NV variable storage to survive - // a VM reboot. - // - VariableStore =3D - (EFI_PHYSICAL_ADDRESS)(UINTN) - AllocateAlignedRuntimePages ( - EFI_SIZE_TO_PAGES (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)), - PcdGet32 (PcdFlashNvStorageFtwSpareSize) - ); - DEBUG ((EFI_D_INFO, - "Reserved variable store memory: 0x%lX; size: %dkb\n", - VariableStore, - (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024 - )); - PcdStatus =3D PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore); - ASSERT_RETURN_ERROR (PcdStatus); -} - - -VOID DebugDumpCmos ( VOID ) @@ -660,8 +631,9 @@ InitializePlatform ( // mHostBridgeDevId =3D PciRead16 (OVMF_HOSTBRIDGE_DID); =20 + SetupVariables (); + if (mBootMode !=3D BOOT_ON_S3_RESUME) { - ReserveEmuVariableNvStore (); PeiFvInitialization (); MemMapInitialization (); NoexecDxeInitialization (); diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h index 18f42c3f0e..dfbdb8b75d 100644 --- a/OvmfPkg/PlatformPei/Platform.h +++ b/OvmfPkg/PlatformPei/Platform.h @@ -1,7 +1,7 @@ /** @file Platform PEI module include file. =20 - Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+ Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BS= D License which accompanies this distribution. The full text of the license may b= e found at @@ -95,6 +95,11 @@ XenPublishRamRegions ( VOID ); =20 +VOID +SetupVariables ( + VOID + ); + extern EFI_BOOT_MODE mBootMode; =20 extern BOOLEAN mS3Supported; diff --git a/OvmfPkg/PlatformPei/PlatformPei.inf b/OvmfPkg/PlatformPei/Plat= formPei.inf index 53c6dd445a..0eaf27e553 100644 --- a/OvmfPkg/PlatformPei/PlatformPei.inf +++ b/OvmfPkg/PlatformPei/PlatformPei.inf @@ -2,7 +2,7 @@ # Platform PEI driver # # This module provides platform specific function to detect boot mode. -# Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.
+# Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
# # This program and the accompanying materials # are licensed and made available under the terms and conditions of the B= SD License @@ -34,6 +34,7 @@ Fv.c MemDetect.c Platform.c + Vars.c Xen.c =20 [Packages] @@ -83,9 +84,16 @@ gUefiOvmfPkgTokenSpaceGuid.PcdPciMmio64Size gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDecompressionScratchEnd gUefiOvmfPkgTokenSpaceGuid.PcdQ35TsegMbytes + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashVariablesEnable + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageVariableBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwWorkingBase + gUefiOvmfPkgTokenSpaceGuid.PcdOvmfFlashNvStorageFtwSpareBase gEfiMdePkgTokenSpaceGuid.PcdGuidedExtractHandlerTableAddress gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwWorkingBase + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize + gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableBase64 gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved gEfiMdeModulePkgTokenSpaceGuid.PcdPciDisableBusEnumeration diff --git a/OvmfPkg/PlatformPei/Vars.c b/OvmfPkg/PlatformPei/Vars.c new file mode 100644 index 0000000000..563f847a55 --- /dev/null +++ b/OvmfPkg/PlatformPei/Vars.c @@ -0,0 +1,122 @@ +/**@file + Platform PEI Variable Store Initialization + + Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.
+ + This program and the accompanying materials are licensed and made + available 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, WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER + EXPRESS OR IMPLIED. + +**/ + +#include +#include +#include +#include +#include + +#include "Platform.h" + +#define OVMF_FVB_BLOCK_SIZE (FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize)) +#define OVMF_FVB_SIZE (2 * FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize)) +#define OVMF_FV_HEADER_LENGTH OFFSET_OF (FVB_FV_HDR_AND_VARS_TEMPLATE, Var= Hdr) + + +VOID +ReserveEmuVariableNvStore ( + ) +{ + EFI_PHYSICAL_ADDRESS VariableStore; + UINT32 Offset; + RETURN_STATUS PcdStatus; + + // + // Allocate storage for NV variables early on so it will be + // at a consistent address. Since VM memory is preserved + // across reboots, this allows the NV variable storage to survive + // a VM reboot. + // + VariableStore =3D + (EFI_PHYSICAL_ADDRESS)(UINTN) + AllocateAlignedRuntimePages ( + EFI_SIZE_TO_PAGES (OVMF_FVB_SIZE), + PcdGet32 (PcdFlashNvStorageFtwSpareSize) + ); + ASSERT (VariableStore !=3D 0); + ASSERT ((VariableStore + OVMF_FVB_SIZE) <=3D MAX_ADDRESS); + DEBUG ((EFI_D_INFO, + "Reserved variable store memory: 0x%lX; size: %dkb\n", + VariableStore, + (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024 + )); + PcdStatus =3D PcdSet64S (PcdEmuVariableNvStoreReserved, VariableStore); + ASSERT_RETURN_ERROR (PcdStatus); + + // + // Initialize the main FV header and variable store header + // + PcdStatus =3D PcdSet64S ( + PcdFlashNvStorageVariableBase64, + VariableStore); + ASSERT_RETURN_ERROR (PcdStatus); + + // + // Initialize the Fault Tolerant Write data area + // + Offset =3D PcdGet32 (PcdVariableStoreSize); + PcdStatus =3D PcdSet32S ( + PcdFlashNvStorageFtwWorkingBase, + VariableStore + Offset); + ASSERT_RETURN_ERROR (PcdStatus); + + // + // Initialize the Fault Tolerant Write spare block + // + Offset =3D FixedPcdGet32 (PcdFlashNvStorageFtwSpareSize); + PcdStatus =3D PcdSet32S ( + PcdFlashNvStorageFtwSpareBase, + VariableStore + Offset); + ASSERT_RETURN_ERROR (PcdStatus); +} + + +VOID +SetupVariables ( + VOID + ) +{ + RETURN_STATUS PcdStatus; + + if (PcdGetBool (PcdOvmfFlashVariablesEnable)) { + // + // If flash is enabled, then set the variable PCD to point + // directly at flash. + // + PcdStatus =3D PcdSet64S ( + PcdFlashNvStorageVariableBase64, + (UINTN) PcdGet32 (PcdOvmfFlashNvStorageVariableBase) + ); + ASSERT_RETURN_ERROR (PcdStatus); + PcdStatus =3D PcdSet32S ( + PcdFlashNvStorageFtwWorkingBase, + PcdGet32 (PcdOvmfFlashNvStorageFtwWorkingBase) + ); + ASSERT_RETURN_ERROR (PcdStatus); + PcdStatus =3D PcdSet32S ( + PcdFlashNvStorageFtwSpareBase, + PcdGet32 (PcdOvmfFlashNvStorageFtwSpareBase) + ); + ASSERT_RETURN_ERROR (PcdStatus); + } else { + // + // If flash is not enabled, then allocate a buffer and initialize + // it if necessary for variable operations. + // + ReserveEmuVariableNvStore (); + } +} --=20 2.11.0 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel