]> git.proxmox.com Git - mirror_edk2.git/blobdiff - OvmfPkg/PlatformPei/MemDetect.c
OvmfPkg/PlatformPei: Refactor InitializeRamRegions
[mirror_edk2.git] / OvmfPkg / PlatformPei / MemDetect.c
index 45f7eba65d040f7353a25999974ad71bce91f843..23a583ed33860143fbec6a491f033346a982c3d1 100644 (file)
@@ -161,7 +161,7 @@ PlatformQemuUc32BaseInitialization (
   // variable MTRR suffices by truncating the size to a whole power of two,\r
   // while keeping the end affixed to 4GB. This will round the base up.\r
   //\r
-  LowerMemorySize           = GetSystemMemorySizeBelow4gb (PlatformInfoHob);\r
+  LowerMemorySize           = PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob);\r
   PlatformInfoHob->Uc32Size = GetPowerOfTwo32 ((UINT32)(SIZE_4GB - LowerMemorySize));\r
   PlatformInfoHob->Uc32Base = (UINT32)(SIZE_4GB - PlatformInfoHob->Uc32Size);\r
   //\r
@@ -372,7 +372,8 @@ GetHighestSystemMemoryAddressFromPvhMemmap (
 }\r
 \r
 UINT32\r
-GetSystemMemorySizeBelow4gb (\r
+EFIAPI\r
+PlatformGetSystemMemorySizeBelow4gb (\r
   IN EFI_HOB_PLATFORM_INFO  *PlatformInfoHob\r
   )\r
 {\r
@@ -761,7 +762,7 @@ PublishPeiMemory (
   UINT32                S3AcpiReservedMemoryBase;\r
   UINT32                S3AcpiReservedMemorySize;\r
 \r
-  LowerMemorySize = GetSystemMemorySizeBelow4gb (&mPlatformInfoHob);\r
+  LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (&mPlatformInfoHob);\r
   if (mPlatformInfoHob.SmmSmramRequire) {\r
     //\r
     // TSEG is chipped from the end of low RAM\r
@@ -871,7 +872,7 @@ QemuInitializeRamBelow1gb (
 **/\r
 STATIC\r
 VOID\r
-QemuInitializeRam (\r
+PlatformQemuInitializeRam (\r
   IN EFI_HOB_PLATFORM_INFO  *PlatformInfoHob\r
   )\r
 {\r
@@ -885,7 +886,7 @@ QemuInitializeRam (
   //\r
   // Determine total memory size available\r
   //\r
-  LowerMemorySize = GetSystemMemorySizeBelow4gb (PlatformInfoHob);\r
+  LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob);\r
 \r
   if (PlatformInfoHob->BootMode == BOOT_ON_S3_RESUME) {\r
     //\r
@@ -995,19 +996,12 @@ QemuInitializeRam (
   }\r
 }\r
 \r
-/**\r
-  Publish system RAM and reserve memory regions\r
-\r
-**/\r
+STATIC\r
 VOID\r
-InitializeRamRegions (\r
+PlatformQemuInitializeRamForS3 (\r
   IN EFI_HOB_PLATFORM_INFO  *PlatformInfoHob\r
   )\r
 {\r
-  QemuInitializeRam (PlatformInfoHob);\r
-\r
-  SevInitializeRam ();\r
-\r
   if (PlatformInfoHob->S3Supported && (PlatformInfoHob->BootMode != BOOT_ON_S3_RESUME)) {\r
     //\r
     // This is the memory range that will be used for PEI on S3 resume\r
@@ -1113,7 +1107,7 @@ InitializeRamRegions (
       //\r
       TsegSize = PlatformInfoHob->Q35TsegMbytes * SIZE_1MB;\r
       BuildMemoryAllocationHob (\r
-        GetSystemMemorySizeBelow4gb (PlatformInfoHob) - TsegSize,\r
+        PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob) - TsegSize,\r
         TsegSize,\r
         EfiReservedMemoryType\r
         );\r
@@ -1152,3 +1146,19 @@ InitializeRamRegions (
  #endif\r
   }\r
 }\r
+\r
+/**\r
+  Publish system RAM and reserve memory regions\r
+\r
+**/\r
+VOID\r
+InitializeRamRegions (\r
+  IN EFI_HOB_PLATFORM_INFO  *PlatformInfoHob\r
+  )\r
+{\r
+  PlatformQemuInitializeRam (PlatformInfoHob);\r
+\r
+  SevInitializeRam ();\r
+\r
+  PlatformQemuInitializeRamForS3 (PlatformInfoHob);\r
+}\r