mirror of
https://github.com/tianocore/edk2
synced 2026-08-27 00:23:19 -04:00
ArmPlatformPkg: MemoryInitPeiLib: Read PCDs into local variable
Current MemoryPeim has excessive amount of PCD get notations. This makes the code less readable and introduced long if statements. This change reads most of the PCD get calls into local variables and reference the variables instead. Signed-off-by: Kun Qin <kuqin12@gmail.com>
This commit is contained in:
parent
99f9327740
commit
6310b11b41
1 changed files with 12 additions and 6 deletions
|
|
@ -66,6 +66,7 @@ MemoryPeim (
|
|||
UINT64 ResourceLength;
|
||||
EFI_PEI_HOB_POINTERS NextHob;
|
||||
EFI_PHYSICAL_ADDRESS FdTop;
|
||||
EFI_PHYSICAL_ADDRESS SystemMemoryBase;
|
||||
EFI_PHYSICAL_ADDRESS SystemMemoryTop;
|
||||
EFI_PHYSICAL_ADDRESS ResourceTop;
|
||||
BOOLEAN Found;
|
||||
|
|
@ -88,6 +89,12 @@ MemoryPeim (
|
|||
EFI_RESOURCE_ATTRIBUTE_TESTED
|
||||
);
|
||||
|
||||
//
|
||||
// Use local variable to avoid multiple PcdGet64 calls
|
||||
//
|
||||
SystemMemoryBase = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdSystemMemoryBase);
|
||||
SystemMemoryTop = SystemMemoryBase + (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdSystemMemorySize);
|
||||
|
||||
//
|
||||
// Check if the resource for the main system memory has been declared
|
||||
//
|
||||
|
|
@ -95,8 +102,8 @@ MemoryPeim (
|
|||
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)))
|
||||
(SystemMemoryBase >= NextHob.ResourceDescriptor->PhysicalStart) &&
|
||||
(NextHob.ResourceDescriptor->PhysicalStart + NextHob.ResourceDescriptor->ResourceLength <= SystemMemoryTop))
|
||||
{
|
||||
Found = TRUE;
|
||||
break;
|
||||
|
|
@ -110,7 +117,7 @@ MemoryPeim (
|
|||
BuildResourceDescriptorHob (
|
||||
EFI_RESOURCE_SYSTEM_MEMORY,
|
||||
ResourceAttributes,
|
||||
PcdGet64 (PcdSystemMemoryBase),
|
||||
SystemMemoryBase,
|
||||
PcdGet64 (PcdSystemMemorySize)
|
||||
);
|
||||
}
|
||||
|
|
@ -119,13 +126,12 @@ MemoryPeim (
|
|||
// Reserved the memory space occupied by the firmware volume
|
||||
//
|
||||
|
||||
SystemMemoryTop = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdSystemMemoryBase) + (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdSystemMemorySize);
|
||||
FdTop = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFdBaseAddress) + (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFdSize);
|
||||
FdTop = (EFI_PHYSICAL_ADDRESS)PcdGet64 (PcdFdBaseAddress) + (EFI_PHYSICAL_ADDRESS)PcdGet32 (PcdFdSize);
|
||||
|
||||
// EDK2 does not have the concept of boot firmware copied into DRAM. To avoid the DXE
|
||||
// core to overwrite this area we must create a memory allocation HOB for the region,
|
||||
// but this only works if we split off the underlying resource descriptor as well.
|
||||
if ((PcdGet64 (PcdFdBaseAddress) >= PcdGet64 (PcdSystemMemoryBase)) && (FdTop <= SystemMemoryTop)) {
|
||||
if ((PcdGet64 (PcdFdBaseAddress) >= SystemMemoryBase) && (FdTop <= SystemMemoryTop)) {
|
||||
Found = FALSE;
|
||||
|
||||
// Search for System Memory Hob that contains the firmware
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue