summaryrefslogtreecommitdiff
path: root/OvmfPkg/PlatformPei/Platform.c
diff options
context:
space:
mode:
authorjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>2009-09-07 20:18:17 +0000
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>2009-09-07 20:18:17 +0000
commit77ba993c886a79b6199e941f4ddb7861ed3a211e (patch)
treedb098b9bd45f4c5e806fa0c82c78da81905d84ce /OvmfPkg/PlatformPei/Platform.c
parent02328a57a216efd3ff301187f5c718122185d2a2 (diff)
downloadedk2-platforms-77ba993c886a79b6199e941f4ddb7861ed3a211e.tar.xz
OVMF: Add support for more persistent NV variables which can survive a system reboot.
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
Diffstat (limited to 'OvmfPkg/PlatformPei/Platform.c')
-rw-r--r--OvmfPkg/PlatformPei/Platform.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index f5552e9ba5..0a7894438d 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -23,6 +23,8 @@
#include <Library/DebugLib.h>
#include <Library/HobLib.h>
#include <Library/IoLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PcdLib.h>
#include <Library/PciLib.h>
#include <Library/PeimEntryPoint.h>
#include <Library/ResourcePublicationLib.h>
@@ -156,6 +158,30 @@ MiscInitialization (
}
+VOID
+ReserveEmuVariableNvStore (
+ )
+{
+ EFI_PHYSICAL_ADDRESS VariableStore;
+
+ //
+ // 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 =
+ (EFI_PHYSICAL_ADDRESS)(UINTN)
+ AllocateRuntimePool (FixedPcdGet32(PcdVariableStoreSize));
+ DEBUG ((EFI_D_INFO,
+ "Reserved variable store memory: 0x%lX; size: %dkb\n",
+ VariableStore,
+ FixedPcdGet32(PcdVariableStoreSize) / 1024
+ ));
+ PcdSet64 (PcdEmuVariableNvStoreReserved, VariableStore);
+}
+
+
/**
Perform Platform PEI initialization.
@@ -176,6 +202,8 @@ InitializePlatform (
MemDetect ();
+ ReserveEmuVariableNvStore ();
+
PeiFvInitialization ();
MemMapInitialization ();