]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/PlatformPei/Platform.c
Fix GCC warnings
[mirror_edk2.git] / OvmfPkg / PlatformPei / Platform.c
index f5552e9ba5fe715d1fc9664a9cc2e7c062e8acf4..889ba51240a56e423b4b43b677a71f2d220bfb69 100644 (file)
@@ -1,7 +1,7 @@
 /**@file\r
   Platform PEI driver\r
 \r
-  Copyright (c) 2006 - 2009, Intel Corporation\r
+  Copyright (c) 2006 - 2010, Intel Corporation\r
   All rights reserved. This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -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,32 @@ 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 (\r
+        2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)\r
+        );\r
+  DEBUG ((EFI_D_INFO,\r
+          "Reserved variable store memory: 0x%lX; size: %dkb\n",\r
+          VariableStore,\r
+          (2 * PcdGet32 (PcdFlashNvStorageFtwSpareSize)) / 1024\r
+        ));\r
+  PcdSet64 (PcdEmuVariableNvStoreReserved, VariableStore);\r
+}\r
+\r
+\r
 /**\r
   Perform Platform PEI initialization.\r
 \r
@@ -176,6 +204,8 @@ InitializePlatform (
 \r
   MemDetect ();\r
 \r
+  ReserveEmuVariableNvStore ();\r
+\r
   PeiFvInitialization ();\r
 \r
   MemMapInitialization ();\r