[edk2-devel] [edk2-platforms][PATCH 1/1] Platform/RaspberryPi/RPi4: gain 2MB of RAM back

Andrei Warkentin andrey.warkentin at gmail.com
Thu Mar 5 22:46:05 UTC 2020


From: Andrei Warkentin <awarkentin at vmware.com>

The RPi4 TF-A is much smaller than RPi3 TF-A, and doesn't need
an extra 2MB region.

Note: this depends on the edk2 ArmPlatformPkg/PrePi: fix IS_XIP.

Signed-off-by: Andrei Warkentin <awarkentin at vmware.com>
---
 Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c | 22 ++++++++++++--------
 Platform/RaspberryPi/RPi4/RPi4.dsc                        |  4 ++--
 2 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c b/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c
index 901e5e3e..e795a885 100644
--- a/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c
+++ b/Platform/RaspberryPi/Library/PlatformLib/RaspberryPiMem.c
@@ -39,8 +39,6 @@ STATIC RPI_MEMORY_REGION_INFO   VirtualMemoryInfo[MAX_VIRTUAL_MEMORY_MAP_DESCRIP
                        FixedPcdGet32(PcdFdSize) - \
                        VariablesSize)
 
-#define ATFBase (FixedPcdGet64(PcdFdBaseAddress) + FixedPcdGet32(PcdFdSize))
-
 /**
   Return the Virtual Memory Map of your platform
 
@@ -96,13 +94,19 @@ ArmPlatformGetVirtualMemoryMap (
   VirtualMemoryInfo[Index].Type             = RPI_MEM_RUNTIME_REGION;
   VirtualMemoryInfo[Index++].Name           = L"FD Variables";
 
-  // TF-A reserved RAM
-  VirtualMemoryTable[Index].PhysicalBase    = ATFBase;
-  VirtualMemoryTable[Index].VirtualBase     = VirtualMemoryTable[Index].PhysicalBase;
-  VirtualMemoryTable[Index].Length          = FixedPcdGet64 (PcdSystemMemoryBase) - ATFBase;
-  VirtualMemoryTable[Index].Attributes      = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
-  VirtualMemoryInfo[Index].Type             = RPI_MEM_RESERVED_REGION;
-  VirtualMemoryInfo[Index++].Name           = L"TF-A RAM";
+  if (BCM2711_SOC_REGISTERS == 0) {
+     //
+     // TF-A reserved RAM only exists for the Pi 3 TF-A.
+     //
+     // This is 2MB that directly follows the FD.
+     //
+     VirtualMemoryTable[Index].PhysicalBase    = (FixedPcdGet64(PcdFdBaseAddress) + FixedPcdGet32(PcdFdSize));
+     VirtualMemoryTable[Index].VirtualBase     = VirtualMemoryTable[Index].PhysicalBase;
+     VirtualMemoryTable[Index].Length          = FixedPcdGet64 (PcdSystemMemoryBase) - VirtualMemoryTable[Index].PhysicalBase;
+     VirtualMemoryTable[Index].Attributes      = ARM_MEMORY_REGION_ATTRIBUTE_WRITE_BACK;
+     VirtualMemoryInfo[Index].Type             = RPI_MEM_RESERVED_REGION;
+     VirtualMemoryInfo[Index++].Name           = L"TF-A RAM";
+  }
 
   // Base System RAM
   VirtualMemoryTable[Index].PhysicalBase    = FixedPcdGet64 (PcdSystemMemoryBase);
diff --git a/Platform/RaspberryPi/RPi4/RPi4.dsc b/Platform/RaspberryPi/RPi4/RPi4.dsc
index 79295729..da62dc5b 100644
--- a/Platform/RaspberryPi/RPi4/RPi4.dsc
+++ b/Platform/RaspberryPi/RPi4/RPi4.dsc
@@ -396,8 +396,8 @@
   # This matches PcdFvBaseAddress, since everything less is ATF, and
   # will be reserved away.
   #
-  gArmTokenSpaceGuid.PcdSystemMemoryBase|0x00400000
-  gArmTokenSpaceGuid.PcdSystemMemorySize|0x3fc00000
+  gArmTokenSpaceGuid.PcdSystemMemoryBase|0x00200000
+  gArmTokenSpaceGuid.PcdSystemMemorySize|0x3fe00000
 
   #
   # Device specific addresses
-- 
2.17.1


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.

View/Reply Online (#55562): https://edk2.groups.io/g/devel/message/55562
Mute This Topic: https://groups.io/mt/71761855/1813853
Group Owner: devel+owner at edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub  [edk2-devel-archive at redhat.com]
-=-=-=-=-=-=-=-=-=-=-=-





More information about the edk2-devel-archive mailing list