]> git.proxmox.com Git - mirror_edk2.git/commitdiff
OvmfPkg/PlatformPei: prepare for PcdQ35TsegMbytes becoming dynamic
authorLaszlo Ersek <lersek@redhat.com>
Tue, 4 Jul 2017 10:44:05 +0000 (12:44 +0200)
committerLaszlo Ersek <lersek@redhat.com>
Wed, 5 Jul 2017 20:21:27 +0000 (22:21 +0200)
In one of the next patches we'll turn PcdQ35TsegMbytes into a dynamic PCD,
to be set by PlatformPei. Introduce the Q35TsegMbytesInitialization()
function and the "mQ35TsegMbytes" global variable to support this.

Q35TsegMbytesInitialization() manages the PCD and caches its final value
into "mQ35TsegMbytes". Call Q35TsegMbytesInitialization() from
InitializePlatform() just in time for the current PCD consumers,
PublishPeiMemory(), InitializeRamRegions() and QemuInitializeRam() --
which is called from InitializeRamRegions() -- to be rebased on top of
"mQ35TsegMbytes".

Call Q35TsegMbytesInitialization() only when PcdSmmSmramRequire is TRUE,
given that PcdQ35TsegMbytes is consumed in that case only.

Cc: Jordan Justen <jordan.l.justen@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Jordan Justen <jordan.l.justen@intel.com>
OvmfPkg/PlatformPei/MemDetect.c
OvmfPkg/PlatformPei/Platform.c
OvmfPkg/PlatformPei/Platform.h

index 78a8e0de346cba798c54dc4f3244eed058edbecb..886d236226650ebfaf2aba09879b6ba948d4c1d8 100644 (file)
@@ -42,6 +42,17 @@ UINT8 mPhysMemAddressWidth;
 STATIC UINT32 mS3AcpiReservedMemoryBase;\r
 STATIC UINT32 mS3AcpiReservedMemorySize;\r
 \r
+STATIC UINT16 mQ35TsegMbytes;\r
+\r
+VOID\r
+Q35TsegMbytesInitialization (\r
+  VOID\r
+  )\r
+{\r
+  mQ35TsegMbytes = PcdGet16 (PcdQ35TsegMbytes);\r
+}\r
+\r
+\r
 UINT32\r
 GetSystemMemorySizeBelow4gb (\r
   VOID\r
@@ -348,7 +359,7 @@ PublishPeiMemory (
     //\r
     // TSEG is chipped from the end of low RAM\r
     //\r
-    LowerMemorySize -= FixedPcdGet16 (PcdQ35TsegMbytes) * SIZE_1MB;\r
+    LowerMemorySize -= mQ35TsegMbytes * SIZE_1MB;\r
   }\r
 \r
   //\r
@@ -456,7 +467,7 @@ QemuInitializeRam (
     if (FeaturePcdGet (PcdSmmSmramRequire)) {\r
       UINT32 TsegSize;\r
 \r
-      TsegSize = FixedPcdGet16 (PcdQ35TsegMbytes) * SIZE_1MB;\r
+      TsegSize = mQ35TsegMbytes * SIZE_1MB;\r
       AddMemoryRangeHob (BASE_1MB, LowerMemorySize - TsegSize);\r
       AddReservedMemoryBaseSizeHob (LowerMemorySize - TsegSize, TsegSize,\r
         TRUE);\r
@@ -605,7 +616,7 @@ InitializeRamRegions (
       // Make sure the TSEG area that we reported as a reserved memory resource\r
       // cannot be used for reserved memory allocations.\r
       //\r
-      TsegSize = FixedPcdGet16 (PcdQ35TsegMbytes) * SIZE_1MB;\r
+      TsegSize = mQ35TsegMbytes * SIZE_1MB;\r
       BuildMemoryAllocationHob (\r
         GetSystemMemorySizeBelow4gb() - TsegSize,\r
         TsegSize,\r
index 3e9fda7c7ab019c11fe4b32b5ca75d7a33a88196..b8a28450d6c54ab39356c04fdb6c24d2bde21ba8 100644 (file)
@@ -645,6 +645,10 @@ InitializePlatform (
   AddressWidthInitialization ();\r
   MaxCpuCountInitialization ();\r
 \r
+  if (FeaturePcdGet (PcdSmmSmramRequire)) {\r
+    Q35TsegMbytesInitialization ();\r
+  }\r
+\r
   PublishPeiMemory ();\r
 \r
   InitializeRamRegions ();\r
index 18f42c3f0ea8e29b1c105bece168278255a44f03..d2d627b221c44178006d1162512a4cc3c29f8611 100644 (file)
@@ -53,6 +53,11 @@ AddressWidthInitialization (
   VOID\r
   );\r
 \r
+VOID\r
+Q35TsegMbytesInitialization (\r
+  VOID\r
+  );\r
+\r
 EFI_STATUS\r
 PublishPeiMemory (\r
   VOID\r