summaryrefslogtreecommitdiffstats
path: root/OvmfPkg/PlatformPei
diff options
context:
space:
mode:
authorLaszlo Ersek <lersek@redhat.com>2017-07-04 12:44:05 +0200
committerLaszlo Ersek <lersek@redhat.com>2017-07-05 22:21:27 +0200
commit23bfb5c0aab6bda348ac03e160d4a8432031fac1 (patch)
tree8a8041b87abafc79fa52e52e156b8bc9bdc9b266 /OvmfPkg/PlatformPei
parent5b31f660c92c7c8b9cfc727cb6802602e64eee0d (diff)
downloadedk2-23bfb5c0aab6bda348ac03e160d4a8432031fac1.tar.gz
edk2-23bfb5c0aab6bda348ac03e160d4a8432031fac1.tar.bz2
edk2-23bfb5c0aab6bda348ac03e160d4a8432031fac1.zip
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>
Diffstat (limited to 'OvmfPkg/PlatformPei')
-rw-r--r--OvmfPkg/PlatformPei/MemDetect.c17
-rw-r--r--OvmfPkg/PlatformPei/Platform.c4
-rw-r--r--OvmfPkg/PlatformPei/Platform.h5
3 files changed, 23 insertions, 3 deletions
diff --git a/OvmfPkg/PlatformPei/MemDetect.c b/OvmfPkg/PlatformPei/MemDetect.c
index 78a8e0de34..886d236226 100644
--- a/OvmfPkg/PlatformPei/MemDetect.c
+++ b/OvmfPkg/PlatformPei/MemDetect.c
@@ -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,
diff --git a/OvmfPkg/PlatformPei/Platform.c b/OvmfPkg/PlatformPei/Platform.c
index 3e9fda7c7a..b8a28450d6 100644
--- a/OvmfPkg/PlatformPei/Platform.c
+++ b/OvmfPkg/PlatformPei/Platform.c
@@ -645,6 +645,10 @@ InitializePlatform (
AddressWidthInitialization ();
MaxCpuCountInitialization ();
+ if (FeaturePcdGet (PcdSmmSmramRequire)) {
+ Q35TsegMbytesInitialization ();
+ }
+
PublishPeiMemory ();
InitializeRamRegions ();
diff --git a/OvmfPkg/PlatformPei/Platform.h b/OvmfPkg/PlatformPei/Platform.h
index 18f42c3f0e..d2d627b221 100644
--- a/OvmfPkg/PlatformPei/Platform.h
+++ b/OvmfPkg/PlatformPei/Platform.h
@@ -53,6 +53,11 @@ AddressWidthInitialization (
VOID
);
+VOID
+Q35TsegMbytesInitialization (
+ VOID
+ );
+
EFI_STATUS
PublishPeiMemory (
VOID