]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/PlatformPei: PeiMemory: stop using mPlatformInfoHob
authorGerd Hoffmann <kraxel@redhat.com>
Fri, 2 Dec 2022 13:10:01 +0000 (14:10 +0100)
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
Wed, 14 Dec 2022 17:45:41 +0000 (17:45 +0000)
Stop using the mPlatformInfoHob global variable in PublishPeiMemory()
and GetPeiMemoryCap() functions.  Pass a pointer to the PlatformInfoHob
instead.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Tested-by: Tom Lendacky <thomas.lendacky@amd.com>
Acked-by: Ard Biesheuvel <ardb@kernel.org>
OvmfPkg/PlatformPei/MemDetect.c
OvmfPkg/PlatformPei/Platform.c
OvmfPkg/PlatformPei/Platform.h

index b9207107b4d95e6b66fc1a90e7ff9c255e4e57e2..3d8375320dcb3beda2caa5893bcb6aad8471d045 100644 (file)
@@ -188,7 +188,7 @@ AddressWidthInitialization (
 STATIC\r
 UINT32\r
 GetPeiMemoryCap (\r
-  VOID\r
+  IN EFI_HOB_PLATFORM_INFO  *PlatformInfoHob\r
   )\r
 {\r
   BOOLEAN  Page1GSupport;\r
@@ -225,15 +225,15 @@ GetPeiMemoryCap (
     }\r
   }\r
 \r
-  if (mPlatformInfoHob.PhysMemAddressWidth <= 39) {\r
+  if (PlatformInfoHob->PhysMemAddressWidth <= 39) {\r
     Pml4Entries = 1;\r
-    PdpEntries  = 1 << (mPlatformInfoHob.PhysMemAddressWidth - 30);\r
+    PdpEntries  = 1 << (PlatformInfoHob->PhysMemAddressWidth - 30);\r
     ASSERT (PdpEntries <= 0x200);\r
   } else {\r
-    if (mPlatformInfoHob.PhysMemAddressWidth > 48) {\r
+    if (PlatformInfoHob->PhysMemAddressWidth > 48) {\r
       Pml4Entries = 0x200;\r
     } else {\r
-      Pml4Entries = 1 << (mPlatformInfoHob.PhysMemAddressWidth - 39);\r
+      Pml4Entries = 1 << (PlatformInfoHob->PhysMemAddressWidth - 39);\r
     }\r
 \r
     ASSERT (Pml4Entries <= 0x200);\r
@@ -260,7 +260,7 @@ GetPeiMemoryCap (
 **/\r
 EFI_STATUS\r
 PublishPeiMemory (\r
-  VOID\r
+  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob\r
   )\r
 {\r
   EFI_STATUS            Status;\r
@@ -271,12 +271,12 @@ PublishPeiMemory (
   UINT32                S3AcpiReservedMemoryBase;\r
   UINT32                S3AcpiReservedMemorySize;\r
 \r
-  LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (&mPlatformInfoHob);\r
-  if (mPlatformInfoHob.SmmSmramRequire) {\r
+  LowerMemorySize = PlatformGetSystemMemorySizeBelow4gb (PlatformInfoHob);\r
+  if (PlatformInfoHob->SmmSmramRequire) {\r
     //\r
     // TSEG is chipped from the end of low RAM\r
     //\r
-    LowerMemorySize -= mPlatformInfoHob.Q35TsegMbytes * SIZE_1MB;\r
+    LowerMemorySize -= PlatformInfoHob->Q35TsegMbytes * SIZE_1MB;\r
   }\r
 \r
   S3AcpiReservedMemoryBase = 0;\r
@@ -287,27 +287,27 @@ PublishPeiMemory (
   // downwards. Its size is primarily dictated by CpuMpPei. The formula below\r
   // is an approximation.\r
   //\r
-  if (mPlatformInfoHob.S3Supported) {\r
+  if (PlatformInfoHob->S3Supported) {\r
     S3AcpiReservedMemorySize = SIZE_512KB +\r
-                               mPlatformInfoHob.PcdCpuMaxLogicalProcessorNumber *\r
+                               PlatformInfoHob->PcdCpuMaxLogicalProcessorNumber *\r
                                PcdGet32 (PcdCpuApStackSize);\r
     S3AcpiReservedMemoryBase = LowerMemorySize - S3AcpiReservedMemorySize;\r
     LowerMemorySize          = S3AcpiReservedMemoryBase;\r
   }\r
 \r
-  mPlatformInfoHob.S3AcpiReservedMemoryBase = S3AcpiReservedMemoryBase;\r
-  mPlatformInfoHob.S3AcpiReservedMemorySize = S3AcpiReservedMemorySize;\r
+  PlatformInfoHob->S3AcpiReservedMemoryBase = S3AcpiReservedMemoryBase;\r
+  PlatformInfoHob->S3AcpiReservedMemorySize = S3AcpiReservedMemorySize;\r
 \r
-  if (mPlatformInfoHob.BootMode == BOOT_ON_S3_RESUME) {\r
+  if (PlatformInfoHob->BootMode == BOOT_ON_S3_RESUME) {\r
     MemoryBase = S3AcpiReservedMemoryBase;\r
     MemorySize = S3AcpiReservedMemorySize;\r
   } else {\r
-    PeiMemoryCap = GetPeiMemoryCap ();\r
+    PeiMemoryCap = GetPeiMemoryCap (PlatformInfoHob);\r
     DEBUG ((\r
       DEBUG_INFO,\r
       "%a: PhysMemAddressWidth=%d PeiMemoryCap=%u KB\n",\r
       __FUNCTION__,\r
-      mPlatformInfoHob.PhysMemAddressWidth,\r
+      PlatformInfoHob->PhysMemAddressWidth,\r
       PeiMemoryCap >> 10\r
       ));\r
 \r
@@ -321,7 +321,7 @@ PublishPeiMemory (
     // allocation HOB, and other allocations served from the permanent PEI RAM\r
     // shouldn't overlap with that HOB.\r
     //\r
-    MemoryBase = mPlatformInfoHob.S3Supported && mPlatformInfoHob.SmmSmramRequire ?\r
+    MemoryBase = PlatformInfoHob->S3Supported && PlatformInfoHob->SmmSmramRequire ?\r
                  PcdGet32 (PcdOvmfDecompressionScratchEnd) :\r
                  PcdGet32 (PcdOvmfDxeMemFvBase) + PcdGet32 (PcdOvmfDxeMemFvSize);\r
     MemorySize = LowerMemorySize - MemoryBase;\r
@@ -336,7 +336,7 @@ PublishPeiMemory (
   // normal boot permanent PEI RAM. Regarding the S3 boot path, the S3\r
   // permanent PEI RAM is located even higher.\r
   //\r
-  if (mPlatformInfoHob.SmmSmramRequire && mPlatformInfoHob.Q35SmramAtDefaultSmbase) {\r
+  if (PlatformInfoHob->SmmSmramRequire && PlatformInfoHob->Q35SmramAtDefaultSmbase) {\r
     ASSERT (SMM_DEFAULT_SMBASE + MCH_DEFAULT_SMBASE_SIZE <= MemoryBase);\r
   }\r
 \r
index 8b055fb451d7260b9a6a10863a184ca27aa4aced..4cd77fd5f84fc72334be2a23aca7d1dc6f6795ca 100644 (file)
@@ -361,7 +361,7 @@ InitializePlatform (
     Q35SmramAtDefaultSmbaseInitialization (&mPlatformInfoHob);\r
   }\r
 \r
-  PublishPeiMemory ();\r
+  PublishPeiMemory (&mPlatformInfoHob);\r
 \r
   PlatformQemuUc32BaseInitialization (&mPlatformInfoHob);\r
 \r
index 7baa5e1d289ff6165926b13c221f0b5ede2d48b5..d0c673c5a346ec06242f51edae37d1178c22a984 100644 (file)
@@ -32,7 +32,7 @@ Q35SmramAtDefaultSmbaseInitialization (
 \r
 EFI_STATUS\r
 PublishPeiMemory (\r
-  VOID\r
+  IN OUT EFI_HOB_PLATFORM_INFO  *PlatformInfoHob\r
   );\r
 \r
 VOID\r