OvmfPkg: Add section of memory to use for PEI on S3 resume
authorJordan Justen <jordan.l.justen@intel.com>
Tue, 4 Mar 2014 08:02:16 +0000 (08:02 +0000)
committerjljusten <jljusten@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 4 Mar 2014 08:02:16 +0000 (08:02 +0000)
This 32k section of RAM will be declared to the PEI Core on
S3 resume to allow memory allocations during S3 resume PEI.

If the boot mode is BOOT_ON_S3_RESUME, then we publish
the pre-reserved PcdS3AcpiReservedMemory range to PEI.

If the boot mode is not BOOT_ON_S3_RESUME, then we reserve
this range as ACPI NVS so the OS will not use it.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jordan Justen <jordan.l.justen@intel.com>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15294 6f19259b-4bc3-4df7-8a09-765794883524

OvmfPkg/OvmfPkg.dec
OvmfPkg/OvmfPkgIa32.fdf
OvmfPkg/OvmfPkgIa32X64.fdf
OvmfPkg/OvmfPkgX64.fdf
OvmfPkg/PlatformPei/MemDetect.c
OvmfPkg/PlatformPei/PlatformPei.inf

index 034ccd8ef7167327bb1428feb843a9fb3434f956..8a52bb143bd89689e462bef966426e6b01771841 100644 (file)
@@ -84,6 +84,7 @@
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize|0x0|UINT32|0x12\r
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|0x0|UINT32|0x13\r
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize|0x0|UINT32|0x14\r
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesSize|0x0|UINT32|0x12\r
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|0x0|UINT32|0x13\r
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize|0x0|UINT32|0x14\r
+  gUefiOvmfPkgTokenSpaceGuid.PcdS3AcpiReservedMemoryBase|0x0|UINT32|0x17\r
 \r
 [PcdsDynamic, PcdsDynamicEx]\r
   gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2\r
 \r
 [PcdsDynamic, PcdsDynamicEx]\r
   gUefiOvmfPkgTokenSpaceGuid.PcdEmuVariableEvent|0|UINT64|2\r
index 7c4e6cda62e090f5acc22c66b7b9370d9a1746a0..84654e63d4fb930d26ebc29c95fc07693ede5ed2 100644 (file)
@@ -141,6 +141,9 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase|gUefiOvmfPkgTokenSpaceGuid.P
 0x010000|0x008000\r
 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize\r
 \r
 0x010000|0x008000\r
 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize\r
 \r
+0x018000|0x008000\r
+gUefiOvmfPkgTokenSpaceGuid.PcdS3AcpiReservedMemoryBase|gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize\r
+\r
 0x020000|0x0E0000\r
 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize\r
 FV = PEIFV\r
 0x020000|0x0E0000\r
 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize\r
 FV = PEIFV\r
index 3cb49de30aa299321254b1f6e1643fd9065b7695..e3728a4330ffd9114e09721262ae16dbaae9abda 100644 (file)
@@ -141,6 +141,9 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase|gUefiOvmfPkgTokenSpaceGuid.P
 0x010000|0x008000\r
 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize\r
 \r
 0x010000|0x008000\r
 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize\r
 \r
+0x018000|0x008000\r
+gUefiOvmfPkgTokenSpaceGuid.PcdS3AcpiReservedMemoryBase|gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize\r
+\r
 0x020000|0x0E0000\r
 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize\r
 FV = PEIFV\r
 0x020000|0x0E0000\r
 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize\r
 FV = PEIFV\r
index bd1dc1bc5d2813744ec1d3e9b1db1a051bc250ea..b8117ac81f6e742cb5138f91429da05fcecb3a9d 100644 (file)
@@ -141,6 +141,9 @@ gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPageTablesBase|gUefiOvmfPkgTokenSpaceGuid.P
 0x010000|0x008000\r
 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize\r
 \r
 0x010000|0x008000\r
 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfSecPeiTempRamSize\r
 \r
+0x018000|0x008000\r
+gUefiOvmfPkgTokenSpaceGuid.PcdS3AcpiReservedMemoryBase|gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize\r
+\r
 0x020000|0x0E0000\r
 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize\r
 FV = PEIFV\r
 0x020000|0x0E0000\r
 gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvBase|gUefiOvmfPkgTokenSpaceGuid.PcdOvmfPeiMemFvSize\r
 FV = PEIFV\r
index 29df5370b05e68ca00c0ebd98239c22778991876..11c79687c435da5fcccaa962660b5119540aba39 100644 (file)
@@ -99,16 +99,21 @@ PublishPeiMemory (
   UINT64                      MemorySize;\r
   UINT64                      LowerMemorySize;\r
 \r
   UINT64                      MemorySize;\r
   UINT64                      LowerMemorySize;\r
 \r
-  LowerMemorySize = GetSystemMemorySizeBelow4gb ();\r
-\r
-  //\r
-  // Determine the range of memory to use during PEI\r
-  //\r
-  MemoryBase = PcdGet32 (PcdOvmfDxeMemFvBase) + PcdGet32 (PcdOvmfDxeMemFvSize);\r
-  MemorySize = LowerMemorySize - MemoryBase;\r
-  if (MemorySize > SIZE_64MB) {\r
-    MemoryBase = LowerMemorySize - SIZE_64MB;\r
-    MemorySize = SIZE_64MB;\r
+  if (mBootMode == BOOT_ON_S3_RESUME) {\r
+    MemoryBase = PcdGet32 (PcdS3AcpiReservedMemoryBase);\r
+    MemorySize = PcdGet32 (PcdS3AcpiReservedMemorySize);\r
+  } else {\r
+    LowerMemorySize = GetSystemMemorySizeBelow4gb ();\r
+\r
+    //\r
+    // Determine the range of memory to use during PEI\r
+    //\r
+    MemoryBase = PcdGet32 (PcdOvmfDxeMemFvBase) + PcdGet32 (PcdOvmfDxeMemFvSize);\r
+    MemorySize = LowerMemorySize - MemoryBase;\r
+    if (MemorySize > SIZE_64MB) {\r
+      MemoryBase = LowerMemorySize - SIZE_64MB;\r
+      MemorySize = SIZE_64MB;\r
+    }\r
   }\r
 \r
   //\r
   }\r
 \r
   //\r
@@ -173,4 +178,15 @@ InitializeRamRegions (
   } else {\r
     XenPublishRamRegions ();\r
   }\r
   } else {\r
     XenPublishRamRegions ();\r
   }\r
+\r
+  if (mS3Supported && mBootMode != BOOT_ON_S3_RESUME) {\r
+    //\r
+    // This is the memory range that will be used for PEI on S3 resume\r
+    //\r
+    BuildMemoryAllocationHob (\r
+      (EFI_PHYSICAL_ADDRESS)(UINTN) PcdGet32 (PcdS3AcpiReservedMemoryBase),\r
+      (UINT64)(UINTN) PcdGet32 (PcdS3AcpiReservedMemorySize),\r
+      EfiACPIMemoryNVS\r
+      );\r
+  }\r
 }\r
 }\r
index ad620350a2939e6f3f155cca4ad2d363cdd0058f..abd05676d61cceba099f12d534fd44d6bb6f182e 100644 (file)
@@ -2,7 +2,7 @@
 #  Platform PEI driver\r
 #\r
 #  This module provides platform specific function to detect boot mode.\r
 #  Platform PEI driver\r
 #\r
 #  This module provides platform specific function to detect boot mode.\r
-#  Copyright (c) 2006 - 2013, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
 #\r
 #  This program and the accompanying materials\r
 #  are licensed and made available under the terms and conditions of the BSD License\r
@@ -36,6 +36,7 @@
   Xen.c\r
 \r
 [Packages]\r
   Xen.c\r
 \r
 [Packages]\r
+  IntelFrameworkModulePkg/IntelFrameworkModulePkg.dec\r
   MdePkg/MdePkg.dec\r
   MdeModulePkg/MdeModulePkg.dec\r
   UefiCpuPkg/UefiCpuPkg.dec\r
   MdePkg/MdePkg.dec\r
   MdeModulePkg/MdeModulePkg.dec\r
   UefiCpuPkg/UefiCpuPkg.dec\r
@@ -64,6 +65,8 @@
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase\r
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize\r
   gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress\r
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvBase\r
   gUefiOvmfPkgTokenSpaceGuid.PcdOvmfDxeMemFvSize\r
   gUefiOvmfPkgTokenSpaceGuid.PcdAcpiPmBaseAddress\r
+  gUefiOvmfPkgTokenSpaceGuid.PcdS3AcpiReservedMemoryBase\r
+  gEfiIntelFrameworkModulePkgTokenSpaceGuid.PcdS3AcpiReservedMemorySize\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdVariableStoreSize\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageFtwSpareSize\r
   gEfiMdeModulePkgTokenSpaceGuid.PcdFlashNvStorageVariableSize\r