/** @file\r
*\r
-* Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
+* Copyright (c) 2011-2015, ARM Limited. All rights reserved.\r
*\r
* This program and the accompanying materials\r
* are licensed and made available under the terms and conditions of the BSD License\r
VOID\r
);\r
\r
+STATIC\r
VOID\r
InitMmu (\r
- VOID\r
+ IN ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable\r
)\r
{\r
- ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable;\r
+\r
VOID *TranslationTableBase;\r
UINTN TranslationTableSize;\r
RETURN_STATUS Status;\r
\r
- // Get Virtual Memory Map from the Platform Library\r
- ArmPlatformGetVirtualMemoryMap (&MemoryTable);\r
-\r
//Note: Because we called PeiServicesInstallPeiMemory() before to call InitMmu() the MMU Page Table resides in\r
// DRAM (even at the top of DRAM as it is the first permanent memory allocation)\r
Status = ArmConfigureMmu (MemoryTable, &TranslationTableBase, &TranslationTableSize);\r
IN UINT64 UefiMemorySize\r
)\r
{\r
- EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttributes;\r
- UINT64 ResourceLength;\r
- EFI_PEI_HOB_POINTERS NextHob;\r
- EFI_PHYSICAL_ADDRESS FdTop;\r
- EFI_PHYSICAL_ADDRESS SystemMemoryTop;\r
- EFI_PHYSICAL_ADDRESS ResourceTop;\r
- BOOLEAN Found;\r
+ ARM_MEMORY_REGION_DESCRIPTOR *MemoryTable;\r
+ EFI_RESOURCE_ATTRIBUTE_TYPE ResourceAttributes;\r
+ UINT64 ResourceLength;\r
+ EFI_PEI_HOB_POINTERS NextHob;\r
+ EFI_PHYSICAL_ADDRESS FdTop;\r
+ EFI_PHYSICAL_ADDRESS SystemMemoryTop;\r
+ EFI_PHYSICAL_ADDRESS ResourceTop;\r
+ BOOLEAN Found;\r
+\r
+ // Get Virtual Memory Map from the Platform Library\r
+ ArmPlatformGetVirtualMemoryMap (&MemoryTable);\r
\r
// Ensure PcdSystemMemorySize has been set\r
ASSERT (PcdGet64 (PcdSystemMemorySize) != 0);\r
EFI_RESOURCE_ATTRIBUTE_TESTED\r
);\r
\r
+ //\r
+ // Check if the resource for the main system memory has been declared\r
+ //\r
+ Found = FALSE;\r
+ NextHob.Raw = GetHobList ();\r
+ while ((NextHob.Raw = GetNextHob (EFI_HOB_TYPE_RESOURCE_DESCRIPTOR, NextHob.Raw)) != NULL) {\r
+ if ((NextHob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) &&\r
+ (PcdGet64 (PcdSystemMemoryBase) >= NextHob.ResourceDescriptor->PhysicalStart) &&\r
+ (NextHob.ResourceDescriptor->PhysicalStart + NextHob.ResourceDescriptor->ResourceLength <= PcdGet64 (PcdSystemMemoryBase) + PcdGet64 (PcdSystemMemorySize)))\r
+ {\r
+ Found = TRUE;\r
+ break;\r
+ }\r
+ NextHob.Raw = GET_NEXT_HOB (NextHob);\r
+ }\r
+\r
+ if (!Found) {\r
+ // Reserved the memory space occupied by the firmware volume\r
+ BuildResourceDescriptorHob (\r
+ EFI_RESOURCE_SYSTEM_MEMORY,\r
+ ResourceAttributes,\r
+ PcdGet64 (PcdSystemMemoryBase),\r
+ PcdGet64 (PcdSystemMemorySize)\r
+ );\r
+ }\r
+\r
+ //\r
// Reserved the memory space occupied by the firmware volume\r
- BuildResourceDescriptorHob (\r
- EFI_RESOURCE_SYSTEM_MEMORY,\r
- ResourceAttributes,\r
- PcdGet64 (PcdSystemMemoryBase),\r
- PcdGet64 (PcdSystemMemorySize)\r
- );\r
+ //\r
\r
SystemMemoryTop = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdSystemMemoryBase) + (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdSystemMemorySize);\r
FdTop = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFdBaseAddress) + (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFdSize);\r
}\r
\r
// Build Memory Allocation Hob\r
- InitMmu ();\r
+ InitMmu (MemoryTable);\r
\r
if (FeaturePcdGet (PcdPrePiProduceMemoryTypeInformationHob)) {\r
// Optional feature that helps prevent EFI memory map fragmentation.\r