On 32-bit ARM, split system memory into a region below (and up to) 4 GB
and a region above 4 GB. This is necessary to get the DXE core to consider
the former as the resource descriptor that describes the primary memory
region that also covers the PHIT region.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <[email protected]>
---
 ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c | 31 
++++++++++++++++----
 1 file changed, 25 insertions(+), 6 deletions(-)

diff --git 
a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c 
b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
index 8ce63b4596e2..310d51b19358 100644
--- a/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
+++ b/ArmVirtPkg/Library/ArmVirtMemoryInitPeiLib/ArmVirtMemoryInitPeiLib.c
@@ -56,6 +56,7 @@ MemoryPeim (
   )
 {
   EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttributes;
+  UINT64                      SystemMemoryTop;
 
   // Ensure PcdSystemMemorySize has been set
   ASSERT (PcdGet64 (PcdSystemMemorySize) != 0);
@@ -73,12 +74,30 @@ MemoryPeim (
       EFI_RESOURCE_ATTRIBUTE_TESTED
   );
 
-  BuildResourceDescriptorHob (
-      EFI_RESOURCE_SYSTEM_MEMORY,
-      ResourceAttributes,
-      PcdGet64 (PcdSystemMemoryBase),
-      PcdGet64 (PcdSystemMemorySize)
-  );
+  SystemMemoryTop = PcdGet64 (PcdSystemMemoryBase) +
+                    PcdGet64 (PcdSystemMemorySize);
+
+  if (SystemMemoryTop - 1 > MAX_ADDRESS) {
+    BuildResourceDescriptorHob (
+        EFI_RESOURCE_SYSTEM_MEMORY,
+        ResourceAttributes,
+        PcdGet64 (PcdSystemMemoryBase),
+        (UINT64) MAX_ADDRESS - PcdGet64 (PcdSystemMemoryBase) + 1
+        );
+    BuildResourceDescriptorHob (
+        EFI_RESOURCE_SYSTEM_MEMORY,
+        ResourceAttributes,
+        (UINT64) MAX_ADDRESS + 1,
+        SystemMemoryTop - MAX_ADDRESS - 1
+        );
+  } else {
+    BuildResourceDescriptorHob (
+        EFI_RESOURCE_SYSTEM_MEMORY,
+        ResourceAttributes,
+        PcdGet64 (PcdSystemMemoryBase),
+        PcdGet64 (PcdSystemMemorySize)
+        );
+  }
 
   //
   // When running under virtualization, the PI/UEFI memory region may be
-- 
1.9.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to