ArmPlatformPkg/MemoryInitPeim: handle memory above 4 GB on 32-bit ARM
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Wed, 9 Sep 2015 14:48:25 +0000 (14:48 +0000)
committerabiesheuvel <abiesheuvel@Edk2>
Wed, 9 Sep 2015 14:48:25 +0000 (14:48 +0000)
Make sure that the PEI memory region is carved out of memory that is
32-bit addressable, by taking MAX_ADDRESS into account (which is
defined as '4 GB - 1' on ARM)

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@18426 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c

index 93ab16c..25baac1 100755 (executable)
@@ -96,7 +96,7 @@ InitializeMemory (
 {\r
   EFI_STATUS                            Status;\r
   UINTN                                 SystemMemoryBase;\r
-  UINT                                SystemMemoryTop;\r
+  UINT64                                SystemMemoryTop;\r
   UINTN                                 FdBase;\r
   UINTN                                 FdTop;\r
   UINTN                                 UefiMemoryBase;\r
@@ -115,7 +115,10 @@ InitializeMemory (
   ASSERT (PcdGet64 (PcdSystemMemorySize) != 0);\r
 \r
   SystemMemoryBase = (UINTN)PcdGet64 (PcdSystemMemoryBase);\r
-  SystemMemoryTop = SystemMemoryBase + (UINTN)PcdGet64 (PcdSystemMemorySize);\r
+  SystemMemoryTop = SystemMemoryBase + PcdGet64 (PcdSystemMemorySize);\r
+  if (SystemMemoryTop - 1 > MAX_ADDRESS) {\r
+    SystemMemoryTop = (UINT64)MAX_ADDRESS + 1;\r
+  }\r
   FdBase = (UINTN)PcdGet64 (PcdFdBaseAddress);\r
   FdTop = FdBase + (UINTN)PcdGet32 (PcdFdSize);\r
 \r