mirror of https://github.com/acidanthera/audk.git
ArmVirtPkg: ArmVirtPlatformLib: find the lowest memory node
While QEMU NUMA support on ARM will introduce more than one /memory node in the device tree, it needs to find the lowest one and set PcdSystemMemorySize with the actual size of this memory node. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Shannon Zhao <shannon.zhao@linaro.org> Reviewed-by: Laszlo Ersek <lersek@redhat.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@19123 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
parent
17247f53d5
commit
45f9bb91b0
|
@ -72,8 +72,8 @@ ArmPlatformInitializeSystemMemory (
|
||||||
{
|
{
|
||||||
VOID *DeviceTreeBase;
|
VOID *DeviceTreeBase;
|
||||||
INT32 Node, Prev;
|
INT32 Node, Prev;
|
||||||
UINT64 NewBase;
|
UINT64 NewBase, CurBase;
|
||||||
UINT64 NewSize;
|
UINT64 NewSize, CurSize;
|
||||||
CONST CHAR8 *Type;
|
CONST CHAR8 *Type;
|
||||||
INT32 Len;
|
INT32 Len;
|
||||||
CONST UINT64 *RegProp;
|
CONST UINT64 *RegProp;
|
||||||
|
@ -90,7 +90,7 @@ ArmPlatformInitializeSystemMemory (
|
||||||
ASSERT (fdt_check_header (DeviceTreeBase) == 0);
|
ASSERT (fdt_check_header (DeviceTreeBase) == 0);
|
||||||
|
|
||||||
//
|
//
|
||||||
// Look for a memory node
|
// Look for the lowest memory node
|
||||||
//
|
//
|
||||||
for (Prev = 0;; Prev = Node) {
|
for (Prev = 0;; Prev = Node) {
|
||||||
Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
|
Node = fdt_next_node (DeviceTreeBase, Prev, NULL);
|
||||||
|
@ -110,25 +110,29 @@ ArmPlatformInitializeSystemMemory (
|
||||||
RegProp = fdt_getprop (DeviceTreeBase, Node, "reg", &Len);
|
RegProp = fdt_getprop (DeviceTreeBase, Node, "reg", &Len);
|
||||||
if (RegProp != 0 && Len == (2 * sizeof (UINT64))) {
|
if (RegProp != 0 && Len == (2 * sizeof (UINT64))) {
|
||||||
|
|
||||||
NewBase = fdt64_to_cpu (ReadUnaligned64 (RegProp));
|
CurBase = fdt64_to_cpu (ReadUnaligned64 (RegProp));
|
||||||
NewSize = fdt64_to_cpu (ReadUnaligned64 (RegProp + 1));
|
CurSize = fdt64_to_cpu (ReadUnaligned64 (RegProp + 1));
|
||||||
|
|
||||||
//
|
|
||||||
// Make sure the start of DRAM matches our expectation
|
|
||||||
//
|
|
||||||
ASSERT (FixedPcdGet64 (PcdSystemMemoryBase) == NewBase);
|
|
||||||
PcdSet64 (PcdSystemMemorySize, NewSize);
|
|
||||||
|
|
||||||
DEBUG ((EFI_D_INFO, "%a: System RAM @ 0x%lx - 0x%lx\n",
|
DEBUG ((EFI_D_INFO, "%a: System RAM @ 0x%lx - 0x%lx\n",
|
||||||
__FUNCTION__, NewBase, NewBase + NewSize - 1));
|
__FUNCTION__, CurBase, CurBase + CurSize - 1));
|
||||||
|
|
||||||
|
if (NewBase > CurBase || NewBase == 0) {
|
||||||
|
NewBase = CurBase;
|
||||||
|
NewSize = CurSize;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
DEBUG ((EFI_D_ERROR, "%a: Failed to parse FDT memory node\n",
|
DEBUG ((EFI_D_ERROR, "%a: Failed to parse FDT memory node\n",
|
||||||
__FUNCTION__));
|
__FUNCTION__));
|
||||||
}
|
}
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Make sure the start of DRAM matches our expectation
|
||||||
|
//
|
||||||
|
ASSERT (FixedPcdGet64 (PcdSystemMemoryBase) == NewBase);
|
||||||
|
PcdSet64 (PcdSystemMemorySize, NewSize);
|
||||||
|
|
||||||
//
|
//
|
||||||
// We need to make sure that the machine we are running on has at least
|
// We need to make sure that the machine we are running on has at least
|
||||||
// 128 MB of memory configured, and is currently executing this binary from
|
// 128 MB of memory configured, and is currently executing this binary from
|
||||||
|
|
Loading…
Reference in New Issue