OvmfPkg/PlatformPei: prepare for PcdQ35TsegMbytes becoming dynamic

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>
This commit is contained in:
Laszlo Ersek 2017-07-04 12:44:05 +02:00
parent 5b31f660c9
commit 23bfb5c0aa
3 changed files with 23 additions and 3 deletions

View File

@ -42,6 +42,17 @@ UINT8 mPhysMemAddressWidth;
STATIC UINT32 mS3AcpiReservedMemoryBase;
STATIC UINT32 mS3AcpiReservedMemorySize;
STATIC UINT16 mQ35TsegMbytes;
VOID
Q35TsegMbytesInitialization (
VOID
)
{
mQ35TsegMbytes = PcdGet16 (PcdQ35TsegMbytes);
}
UINT32
GetSystemMemorySizeBelow4gb (
VOID
@ -348,7 +359,7 @@ PublishPeiMemory (
//
// TSEG is chipped from the end of low RAM
//
LowerMemorySize -= FixedPcdGet16 (PcdQ35TsegMbytes) * SIZE_1MB;
LowerMemorySize -= mQ35TsegMbytes * SIZE_1MB;
}
//
@ -456,7 +467,7 @@ QemuInitializeRam (
if (FeaturePcdGet (PcdSmmSmramRequire)) {
UINT32 TsegSize;
TsegSize = FixedPcdGet16 (PcdQ35TsegMbytes) * SIZE_1MB;
TsegSize = mQ35TsegMbytes * SIZE_1MB;
AddMemoryRangeHob (BASE_1MB, LowerMemorySize - TsegSize);
AddReservedMemoryBaseSizeHob (LowerMemorySize - TsegSize, TsegSize,
TRUE);
@ -605,7 +616,7 @@ InitializeRamRegions (
// Make sure the TSEG area that we reported as a reserved memory resource
// cannot be used for reserved memory allocations.
//
TsegSize = FixedPcdGet16 (PcdQ35TsegMbytes) * SIZE_1MB;
TsegSize = mQ35TsegMbytes * SIZE_1MB;
BuildMemoryAllocationHob (
GetSystemMemorySizeBelow4gb() - TsegSize,
TsegSize,

View File

@ -645,6 +645,10 @@ InitializePlatform (
AddressWidthInitialization ();
MaxCpuCountInitialization ();
if (FeaturePcdGet (PcdSmmSmramRequire)) {
Q35TsegMbytesInitialization ();
}
PublishPeiMemory ();
InitializeRamRegions ();

View File

@ -53,6 +53,11 @@ AddressWidthInitialization (
VOID
);
VOID
Q35TsegMbytesInitialization (
VOID
);
EFI_STATUS
PublishPeiMemory (
VOID