summaryrefslogtreecommitdiff
path: root/ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c
diff options
context:
space:
mode:
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-07-06 16:27:21 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2011-07-06 16:27:21 +0000
commitd269095b712ba45fd4aca55331b5e6f3045ce1ad (patch)
tree45ee937196347b33f6eeddf11cd3fa29c431a1f0 /ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c
parenta6caee65ac3bba2ac649f20bf1c63f0a87050f17 (diff)
ArmPlatformPkg: Change the memory model for the ARM Platform components
In the former memory model, the UEFI firmware was expected to be located at the top of the system memory. Stacks & Pi memory regions were set below the firmware. On some platform, the UEFI firmware could be shadowed by the ROM firmware (case of the BeagleBoard) and in some cases the firmware is copied at the beginning of the system memory. With this new memory model, stack and Pi/DXE memory regions are set at the top of the system memory wherever the UEFI firmware is located in the memory map. Because DXE core does not support shadowed firmwares, the system memory covered by the UEFI firmware is marked as 'Non Present' to avoid to be overlapped by DXE allocations. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@11992 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c')
-rwxr-xr-xArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c40
1 files changed, 30 insertions, 10 deletions
diff --git a/ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c b/ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c
index f4c27c5750..3559e08862 100755
--- a/ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c
+++ b/ArmPlatformPkg/MemoryInitPei/MemoryInitPeim.c
@@ -95,7 +95,10 @@ InitializeMemory (
)
{
EFI_STATUS Status;
+ UINTN SystemMemoryBase;
UINTN SystemMemoryTop;
+ UINTN FdBase;
+ UINTN FdTop;
UINTN UefiMemoryBase;
DEBUG ((EFI_D_ERROR, "Memory Init PEIM Loaded\n"));
@@ -103,27 +106,44 @@ InitializeMemory (
// Ensure PcdSystemMemorySize has been set
ASSERT (FixedPcdGet32 (PcdSystemMemorySize) != 0);
- SystemMemoryTop = (UINTN)FixedPcdGet32 (PcdSystemMemoryBase) + (UINTN)FixedPcdGet32 (PcdSystemMemorySize);
+ SystemMemoryBase = (UINTN)FixedPcdGet32 (PcdSystemMemoryBase);
+ SystemMemoryTop = SystemMemoryBase + (UINTN)FixedPcdGet32 (PcdSystemMemorySize);
+ FdBase = (UINTN)PcdGet32 (PcdNormalFdBaseAddress);
+ FdTop = FdBase + (UINTN)PcdGet32 (PcdNormalFdSize);
//
// Initialize the System Memory (DRAM)
//
- if (PcdGet32 (PcdStandalone)) {
- // In case of a standalone version, the DRAM is already initialized
- ArmPlatformInitializeSystemMemory();
+ if (!FeaturePcdGet (PcdSystemMemoryInitializeInSec)) {
+ // In case the DRAM has not been initialized by the secure firmware
+ ArmPlatformInitializeSystemMemory ();
}
//
// Declare the UEFI memory to PEI
//
- if (PcdGet32 (PcdStandalone)) {
- // In case of standalone UEFI, we set the UEFI memory region at the top of the DRAM
- UefiMemoryBase = SystemMemoryTop - FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
+
+ // In case the firmware has been shadowed in the System Memory
+ if ((FdBase >= SystemMemoryBase) && (FdTop <= SystemMemoryTop)) {
+ // Check if there is enough space between the top of the system memory and the top of the
+ // firmware to place the UEFI memory (for PEI & DXE phases)
+ if (SystemMemoryTop - FdTop >= FixedPcdGet32 (PcdSystemMemoryUefiRegionSize)) {
+ UefiMemoryBase = SystemMemoryTop - FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
+ } else {
+ // Check there is enough space for the UEFI memory
+ ASSERT (SystemMemoryBase + FixedPcdGet32 (PcdSystemMemoryUefiRegionSize) <= FdBase);
+
+ UefiMemoryBase = FdBase - FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
+ }
} else {
- // In case of a non standalone UEFI, we set the UEFI memory below the Firmware Volume
- UefiMemoryBase = FixedPcdGet32 (PcdNormalFdBaseAddress) - FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
+ // Check the Firmware does not overlapped with the system memory
+ ASSERT ((FdBase < SystemMemoryBase) || (FdBase >= SystemMemoryTop));
+ ASSERT ((FdTop <= SystemMemoryBase) || (FdTop > SystemMemoryTop));
+
+ UefiMemoryBase = SystemMemoryTop - FixedPcdGet32 (PcdSystemMemoryUefiRegionSize);
}
- Status = PeiServicesInstallPeiMemory (UefiMemoryBase,FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));
+
+ Status = PeiServicesInstallPeiMemory (UefiMemoryBase, FixedPcdGet32 (PcdSystemMemoryUefiRegionSize));
ASSERT_EFI_ERROR (Status);
// Initialize MMU and Memory HOBs (Resource Descriptor HOBs)