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>
This commit is contained in:
Ard Biesheuvel
2022-09-25 16:53:27 +02:00
committed by mergify[bot]
parent fead469a3b
commit 7136d5491e
8 changed files with 75 additions and 25 deletions

View File

@@ -6,9 +6,10 @@
**/
#include <Base.h>
#include <Uefi.h>
#include <Pi/PiMultiPhase.h>
#include <Library/DebugLib.h>
#include <Library/PcdLib.h>
#include <Library/HobLib.h>
#include <libfdt.h>
RETURN_STATUS
@@ -17,14 +18,14 @@ QemuVirtMemInfoPeiLibConstructor (
VOID
)
{
VOID *DeviceTreeBase;
INT32 Node, Prev;
UINT64 NewBase, CurBase;
UINT64 NewSize, CurSize;
CONST CHAR8 *Type;
INT32 Len;
CONST UINT64 *RegProp;
RETURN_STATUS PcdStatus;
VOID *DeviceTreeBase;
INT32 Node, Prev;
UINT64 NewBase, CurBase;
UINT64 NewSize, CurSize;
CONST CHAR8 *Type;
INT32 Len;
CONST UINT64 *RegProp;
VOID *Hob;
NewBase = 0;
NewSize = 0;
@@ -86,8 +87,13 @@ QemuVirtMemInfoPeiLibConstructor (
// Make sure the start of DRAM matches our expectation
//
ASSERT (FixedPcdGet64 (PcdSystemMemoryBase) == NewBase);
PcdStatus = PcdSet64S (PcdSystemMemorySize, NewSize);
ASSERT_RETURN_ERROR (PcdStatus);
Hob = BuildGuidDataHob (
&gArmVirtSystemMemorySizeGuid,
&NewSize,
sizeof NewSize
);
ASSERT (Hob != NULL);
//
// We need to make sure that the machine we are running on has at least