]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OVMF: Add support for more persistent NV variables which can survive a system reboot.
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 7 Sep 2009 20:18:17 +0000 (20:18 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Mon, 7 Sep 2009 20:18:17 +0000 (20:18 +0000)
Make use of EMU Variable driver's PcdEmuVariableNvStoreReserved to allow
NV variables to persist a VM system reset.  The contents of the NV variables
will still be lost when the VM is shut down, but they appear to persist
when the efi shell reset command is run.  (Tested with QEMU 0.10.0.)

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@9241 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/OvmfPkgIa32.dsc
OvmfPkg/OvmfPkgIa32X64.dsc
OvmfPkg/OvmfPkgX64.dsc
OvmfPkg/PlatformPei/Platform.c
OvmfPkg/PlatformPei/PlatformPei.inf

index 3a41cb74d5cd66358bcbf71018475d3b823d7480..80e80383fbd54d8542f446681b3acd34b84f7317 100644 (file)
 #\r
 ################################################################################\r
 \r
-[PcdsDynamicDefault.common.DEFAULT]\r
+[PcdsDynamicDefault.common]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0\r
 \r
 ################################################################################\r
 #\r
     <LibraryClasses>\r
       NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf\r
   }\r
-  OvmfPkg/PlatformPei/PlatformPei.inf\r
+\r
+  OvmfPkg/PlatformPei/PlatformPei.inf {\r
+    <LibraryClasses>\r
+      PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf\r
+  }\r
 \r
   #\r
   # DXE Phase modules\r
index e46185688ccecfefd5c718769c301a4ddb53d6ac..96e84e7a394f9e92163a6af8409abdba341f64ba 100644 (file)
 #\r
 ################################################################################\r
 \r
-[PcdsDynamicDefault.common.DEFAULT]\r
+[PcdsDynamicDefault.common]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0\r
 \r
 ################################################################################\r
 #\r
     <LibraryClasses>\r
       NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf\r
   }\r
-  OvmfPkg/PlatformPei/PlatformPei.inf\r
+\r
+  OvmfPkg/PlatformPei/PlatformPei.inf {\r
+    <LibraryClasses>\r
+      PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf\r
+  }\r
 \r
 [Components.X64]\r
   #\r
index 0e44628bf3c7cdc23cf91c54588501aa9ef6cb12..c4cf30fcc941bb2b216e629fcc0d6253b175fc64 100644 (file)
@@ -57,8 +57,6 @@
   UefiDecompressLib|MdePkg/Library/BaseUefiDecompressLib/BaseUefiDecompressLib.inf\r
   UefiHiiServicesLib|MdeModulePkg/Library/UefiHiiServicesLib/UefiHiiServicesLib.inf\r
   HiiLib|MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf\r
-  S3Lib|MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf\r
-  RecoveryLib|MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf\r
   GenericBdsLib|IntelFrameworkModulePkg/Library/GenericBdsLib/GenericBdsLib.inf\r
   CapsuleLib|MdeModulePkg/Library/DxeCapsuleLibNull/DxeCapsuleLibNull.inf\r
   DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf\r
 #\r
 ################################################################################\r
 \r
-[PcdsDynamicDefault.common.DEFAULT]\r
+[PcdsDynamicDefault.common]\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved|0\r
 \r
 ################################################################################\r
 #\r
     <LibraryClasses>\r
       NULL|IntelFrameworkModulePkg/Library/LzmaCustomDecompressLib/LzmaCustomDecompressLib.inf\r
   }\r
-  OvmfPkg/PlatformPei/PlatformPei.inf\r
+\r
+  OvmfPkg/PlatformPei/PlatformPei.inf {\r
+    <LibraryClasses>\r
+      PcdLib|MdePkg/Library/PeiPcdLib/PeiPcdLib.inf\r
+  }\r
 \r
   #\r
   # DXE Phase modules\r
index f5552e9ba5fe715d1fc9664a9cc2e7c062e8acf4..0a7894438d2aecdb470dff0619c0d2e80c92291a 100644 (file)
@@ -23,6 +23,8 @@
 #include <Library/DebugLib.h>\r
 #include <Library/HobLib.h>\r
 #include <Library/IoLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/PcdLib.h>\r
 #include <Library/PciLib.h>\r
 #include <Library/PeimEntryPoint.h>\r
 #include <Library/ResourcePublicationLib.h>\r
@@ -156,6 +158,30 @@ MiscInitialization (
 }\r
 \r
 \r
+VOID\r
+ReserveEmuVariableNvStore (\r
+  )\r
+{\r
+  EFI_PHYSICAL_ADDRESS VariableStore;\r
+\r
+  //\r
+  // Allocate storage for NV variables early on so it will be\r
+  // at a consistent address.  Since VM memory is preserved\r
+  // across reboots, this allows the NV variable storage to survive\r
+  // a VM reboot.\r
+  //\r
+  VariableStore =\r
+    (EFI_PHYSICAL_ADDRESS)(UINTN)\r
+      AllocateRuntimePool (FixedPcdGet32(PcdVariableStoreSize));\r
+  DEBUG ((EFI_D_INFO,\r
+          "Reserved variable store memory: 0x%lX; size: %dkb\n",\r
+          VariableStore,\r
+          FixedPcdGet32(PcdVariableStoreSize) / 1024\r
+        ));\r
+  PcdSet64 (PcdEmuVariableNvStoreReserved, VariableStore);\r
+}\r
+\r
+\r
 /**\r
   Perform Platform PEI initialization.\r
 \r
@@ -176,6 +202,8 @@ InitializePlatform (
 \r
   MemDetect ();\r
 \r
+  ReserveEmuVariableNvStore ();\r
+\r
   PeiFvInitialization ();\r
 \r
   MemMapInitialization ();\r
index c52538fe4ef9df1921c34e84df22344fd1e9a90d..df6545199b8deb6ee99bc3cb9082ff4d3a9a8ba5 100644 (file)
@@ -63,7 +63,7 @@
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r
 \r
 [Pcd.common]\r
-  gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase\r
+  gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved\r
 \r
 [Depex]\r
   TRUE\r