summaryrefslogtreecommitdiffstats
path: root/ArmPlatformPkg/MemoryInitPei
diff options
context:
space:
mode:
authorOlivier Martin <Olivier.Martin@arm.com>2015-07-06 16:55:29 +0000
committeroliviermartin <oliviermartin@Edk2>2015-07-06 16:55:29 +0000
commit40a3f38f67cee7046feb5a5666883cc75a6962ff (patch)
tree8260296fd8ac70eee235c50e83fe42b479eaaff4 /ArmPlatformPkg/MemoryInitPei
parentb1179c1929386b16adf755637810dc96dcbda6cc (diff)
downloadedk2-40a3f38f67cee7046feb5a5666883cc75a6962ff.tar.gz
edk2-40a3f38f67cee7046feb5a5666883cc75a6962ff.tar.bz2
edk2-40a3f38f67cee7046feb5a5666883cc75a6962ff.zip
ArmPlatformPkg/MemoryInitPei: Check if the main System Memory resource has been declared
The PlatformLib could have declared the resource hob for the main system memory region. This change would prevent to get this system memory resource to be declared twice. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <Olivier.Martin@arm.com> Reviewed-by: Ronald Cron <Ronald.Cron@arm.com> git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17834 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPlatformPkg/MemoryInitPei')
-rwxr-xr-xArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c64
1 files changed, 44 insertions, 20 deletions
diff --git a/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c b/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c
index 577b288400..f54ec3672a 100755
--- a/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c
+++ b/ArmPlatformPkg/MemoryInitPei/MemoryInitPeiLib.c
@@ -1,6 +1,6 @@
/** @file
*
-* Copyright (c) 2011-2014, ARM Limited. All rights reserved.
+* Copyright (c) 2011-2015, ARM Limited. All rights reserved.
*
* This program and the accompanying materials
* are licensed and made available under the terms and conditions of the BSD License
@@ -25,19 +25,17 @@ BuildMemoryTypeInformationHob (
VOID
);
+STATIC
VOID
InitMmu (
- VOID
+ IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable
)
{
- ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable;
+
VOID *TranslationTableBase;
UINTN TranslationTableSize;
RETURN_STATUS Status;
- // Get Virtual Memory Map from the Platform Library
- ArmPlatformGetVirtualMemoryMap (&MemoryTable);
-
//Note: Because we called PeiServicesInstallPeiMemory() before to call InitMmu() the MMU Page Table resides in
// DRAM (even at the top of DRAM as it is the first permanent memory allocation)
Status = ArmConfigureMmu (MemoryTable, &TranslationTableBase, &TranslationTableSize);
@@ -69,13 +67,17 @@ MemoryPeim (
IN UINT64 UefiMemorySize
)
{
- EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttributes;
- UINT64 ResourceLength;
- EFI_PEI_HOB_POINTERS NextHob;
- EFI_PHYSICAL_ADDRESS FdTop;
- EFI_PHYSICAL_ADDRESS SystemMemoryTop;
- EFI_PHYSICAL_ADDRESS ResourceTop;
- BOOLEAN Found;
+ ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable;
+ EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttributes;
+ UINT64 ResourceLength;
+ EFI_PEI_HOB_POINTERS NextHob;
+ EFI_PHYSICAL_ADDRESS FdTop;
+ EFI_PHYSICAL_ADDRESS SystemMemoryTop;
+ EFI_PHYSICAL_ADDRESS ResourceTop;
+ BOOLEAN Found;
+
+ // Get Virtual Memory Map from the Platform Library
+ ArmPlatformGetVirtualMemoryMap (&MemoryTable);
// Ensure PcdSystemMemorySize has been set
ASSERT (PcdGet64 (PcdSystemMemorySize) != 0);
@@ -93,13 +95,35 @@ MemoryPeim (
EFI_RESOURCE_ATTRIBUTE_TESTED
);
+ //
+ // Check if the resource for the main system memory has been declared
+ //
+ Found = FALSE;
+ NextHob.Raw = GetHobList ();
+ while ((NextHob.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, NextHob.Raw)) != NULL) {
+ if ((NextHob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) &&
+ (PcdGet64 (PcdSystemMemoryBase) >= NextHob.ResourceDescriptor->PhysicalStart) &&
+ (NextHob.ResourceDescriptor->PhysicalStart + NextHob.ResourceDescriptor->ResourceLength <= PcdGet64 (PcdSystemMemoryBase) + PcdGet64 (PcdSystemMemorySize)))
+ {
+ Found = TRUE;
+ break;
+ }
+ NextHob.Raw = GET_NEXT_HOB (NextHob);
+ }
+
+ if (!Found) {
+ // Reserved the memory space occupied by the firmware volume
+ BuildResourceDescriptorHob (
+ EFI_RESOURCE_SYSTEM_MEMORY,
+ ResourceAttributes,
+ PcdGet64 (PcdSystemMemoryBase),
+ PcdGet64 (PcdSystemMemorySize)
+ );
+ }
+
+ //
// Reserved the memory space occupied by the firmware volume
- BuildResourceDescriptorHob (
- EFI_RESOURCE_SYSTEM_MEMORY,
- ResourceAttributes,
- PcdGet64 (PcdSystemMemoryBase),
- PcdGet64 (PcdSystemMemorySize)
- );
+ //
SystemMemoryTop = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdSystemMemoryBase) + (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdSystemMemorySize);
FdTop = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFdBaseAddress) + (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFdSize);
@@ -163,7 +187,7 @@ MemoryPeim (
}
// Build Memory Allocation Hob
- InitMmu ();
+ InitMmu (MemoryTable);
if (FeaturePcdGet (PcdPrePiProduceMemoryTypeInformationHob)) {
// Optional feature that helps prevent EFI memory map fragmentation.