]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/PlatformPei: Refactor InitializeRamRegions
authorMin Xu <min.m.xu@intel.com>
Mon, 7 Mar 2022 13:54:30 +0000 (21:54 +0800)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Sat, 2 Apr 2022 08:15:12 +0000 (08:15 +0000)
BZ: https://bugzilla.tianocore.org/show_bug.cgi?id=3863

InitializeRamRegions is refactored into 3 calls:
 - PlatformQemuInitializeRam
 - SevInitializeRam
 - PlatformQemuInitializeRamForS3

SevInitializeRam is not in PlatformInitLib. Because in the first stage
PlatformInitLib only support the basic platform featues.

PlatformQemuInitializeRamForS3 wraps the code which was previously in
InitializeRamRegions (many code in 2 if-checks).

Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Brijesh Singh <brijesh.singh@amd.com>
Cc: Erdem Aktas <erdemaktas@google.com>
Cc: James Bottomley <jejb@linux.ibm.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Cc: Gerd Hoffmann <kraxel@redhat.com>
Cc: Sebastien Boeuf <sebastien.boeuf@intel.com>
Acked-by: Gerd Hoffmann <kraxel@redhat.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
Signed-off-by: Min Xu <min.m.xu@intel.com>
OvmfPkg/PlatformPei/MemDetect.c
OvmfPkg/PlatformPei/Platform.c
OvmfPkg/PlatformPei/Platform.h

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
index 1275c9187e867a4e0ffaf351100626d4ce84a78a..f89d14493ecf16a3ae151342fdd642936aca91ce 100644 (file)
@@ -79,7 +79,7 @@ MemMapInitialization (
     return;\r
   }\r
 \r
-  TopOfLowRam  = GetSystemMemorySizeBelow4gb (PlatformInfoHob);\r
+  TopOfLowRam  = PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob);\r
   PciExBarBase = 0;\r
   if (PlatformInfoHob->HostBridgeDevId == INTEL_Q35_MCH_DEVICE_ID) {\r
     //\r
index 038a806a1e1bb1b056884f85931c5e6613273463..635d58379a243b92335db6ebc391b9a093a2254a 100644 (file)
@@ -35,7 +35,8 @@ PublishPeiMemory (
   );\r
 \r
 UINT32\r
-GetSystemMemorySizeBelow4gb (\r
+EFIAPI\r
+PlatformGetSystemMemorySizeBelow4gb (\r
   IN EFI_HOB_PLATFORM_INFO  *PlatformInfoHob\r
   );\r
 \r