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
#\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
#\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
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
#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
}\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
\r
MemDetect ();\r
\r
+ ReserveEmuVariableNvStore ();\r
+\r
PeiFvInitialization ();\r
\r
MemMapInitialization ();\r
gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r
\r
[Pcd.common]\r
- gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareBase\r
+ gEfiMdeModulePkgTokenSpaceGuid.PcdEmuVariableNvStoreReserved\r
\r
[Depex]\r
TRUE\r