summaryrefslogtreecommitdiff
path: root/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
diff options
context:
space:
mode:
authorArd Biesheuvel <ardb@kernel.org>2022-09-25 16:53:27 +0200
committermergify[bot] <37929162+mergify[bot]@users.noreply.github.com>2022-10-26 17:28:39 +0000
commit7136d5491e225c57f1d73e4a1b7ac27ed656ff72 (patch)
tree16f18103d73b26d7dfc6959afe8a83e23ae5b80a /ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
parentfead469a3b3174fbf9ec2df97f54f3ebcc786ca5 (diff)
downloadedk2-7136d5491e225c57f1d73e4a1b7ac27ed656ff72.zip
edk2-7136d5491e225c57f1d73e4a1b7ac27ed656ff72.tar.gz
edk2-7136d5491e225c57f1d73e4a1b7ac27ed656ff72.tar.bz2
ArmVirtPkg/QemuVirtMemInfoLib: use HOB not PCD to record the memory size
Due to the way we inherited the formerly fixed PCDs to describe the system memory base and size from ArmPlatformPkg, we ended up with a MemoryInit PEIM that relies on dynamic PCDs to communicate the size of system memory between the constructor of one of its library dependencies and the core module. This is unnecessary, and forces us to incorporate the PCD PEIM as well, for no good reason. So instead, let's use a HOB. Signed-off-by: Ard Biesheuvel <ardb@kernel.org>
Diffstat (limited to 'ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c')
-rw-r--r--ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
index 98d90ad..72e5c65 100644
--- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
+++ b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
@@ -52,10 +52,19 @@ MemoryPeim (
{
EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttributes;
UINT64 SystemMemoryTop;
+ UINT64 SystemMemorySize;
+ VOID *Hob;
// Ensure PcdSystemMemorySize has been set
ASSERT (PcdGet64 (PcdSystemMemorySize) != 0);
+ SystemMemorySize = PcdGet64 (PcdSystemMemorySize);
+
+ Hob = GetFirstGuidHob (&gArmVirtSystemMemorySizeGuid);
+ if (Hob != NULL) {
+ SystemMemorySize = *(UINT64 *)GET_GUID_HOB_DATA (Hob);
+ }
+
//
// Now, the permanent memory has been installed, we can call AllocatePages()
//
@@ -66,8 +75,7 @@ MemoryPeim (
EFI_RESOURCE_ATTRIBUTE_TESTED
);
- SystemMemoryTop = PcdGet64 (PcdSystemMemoryBase) +
- PcdGet64 (PcdSystemMemorySize);
+ SystemMemoryTop = PcdGet64 (PcdSystemMemoryBase) + SystemMemorySize;
if (SystemMemoryTop - 1 > MAX_ALLOC_ADDRESS) {
BuildResourceDescriptorHob (
@@ -87,7 +95,7 @@ MemoryPeim (
EFI_RESOURCE_SYSTEM_MEMORY,
ResourceAttributes,
PcdGet64 (PcdSystemMemoryBase),
- PcdGet64 (PcdSystemMemorySize)
+ SystemMemorySize
);
}