summaryrefslogtreecommitdiff
path: root/ArmPkg/Library
diff options
context:
space:
mode:
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2013-04-14 09:36:41 +0000
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>2013-04-14 09:36:41 +0000
commit387653a431766dbaaf76f7743cefc7aa5350b967 (patch)
tree10fae53cf737b06acdc429b3630d34f498f02497 /ArmPkg/Library
parentac0fb62f03289b8ff41cd15debb96d5af3e6a03f (diff)
downloadedk2-platforms-387653a431766dbaaf76f7743cefc7aa5350b967.tar.xz
ArmPkg/BdsLib: Added support for FDT alignment through PcdArmLinuxFdtAlignment
Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Olivier Martin <olivier.martin@arm.com> git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@14274 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'ArmPkg/Library')
-rw-r--r--ArmPkg/Library/BdsLib/BdsLib.inf1
-rw-r--r--ArmPkg/Library/BdsLib/BdsLinuxFdt.c17
2 files changed, 16 insertions, 2 deletions
diff --git a/ArmPkg/Library/BdsLib/BdsLib.inf b/ArmPkg/Library/BdsLib/BdsLib.inf
index 335f4d6c59..b6712a4fe2 100644
--- a/ArmPkg/Library/BdsLib/BdsLib.inf
+++ b/ArmPkg/Library/BdsLib/BdsLib.inf
@@ -76,6 +76,7 @@
gArmTokenSpaceGuid.PcdArmMachineType
gArmTokenSpaceGuid.PcdArmLinuxFdtMaxOffset
+ gArmTokenSpaceGuid.PcdArmLinuxFdtAlignment
gArmTokenSpaceGuid.PcdArmLinuxKernelMaxOffset
gArmTokenSpaceGuid.PcdArmLinuxAtagMaxOffset
diff --git a/ArmPkg/Library/BdsLib/BdsLinuxFdt.c b/ArmPkg/Library/BdsLib/BdsLinuxFdt.c
index b6d08944ab..43daf5dd2a 100644
--- a/ArmPkg/Library/BdsLib/BdsLinuxFdt.c
+++ b/ArmPkg/Library/BdsLib/BdsLinuxFdt.c
@@ -214,7 +214,9 @@ PrepareFdt (
{
EFI_STATUS Status;
EFI_PHYSICAL_ADDRESS NewFdtBlobBase;
+ EFI_PHYSICAL_ADDRESS NewFdtBlobAllocation;
UINTN NewFdtBlobSize;
+ UINT32 FdtAlignment;
VOID* fdt;
INTN err;
INTN node;
@@ -295,9 +297,15 @@ PrepareFdt (
//
NewFdtBlobSize = OriginalFdtSize + FDT_ADDITIONAL_ENTRIES_SIZE;
+ // If FDT load address needs to be aligned, allocate more space.
+ FdtAlignment = PcdGet32 (PcdArmLinuxFdtAlignment);
+ if (FdtAlignment != 0) {
+ NewFdtBlobSize += FdtAlignment;
+ }
+
// Try below a watermark address
Status = EFI_NOT_FOUND;
- if (PcdGet32(PcdArmLinuxFdtMaxOffset) != 0) {
+ if (PcdGet32 (PcdArmLinuxFdtMaxOffset) != 0) {
NewFdtBlobBase = LINUX_FDT_MAX_OFFSET;
Status = gBS->AllocatePages (AllocateMaxAddress, EfiBootServicesData, EFI_SIZE_TO_PAGES(NewFdtBlobSize), &NewFdtBlobBase);
if (EFI_ERROR(Status)) {
@@ -316,6 +324,11 @@ PrepareFdt (
}
}
+ NewFdtBlobAllocation = NewFdtBlobBase;
+ if (FdtAlignment != 0) {
+ NewFdtBlobBase = ALIGN (NewFdtBlobBase, FdtAlignment);
+ }
+
// Load the Original FDT tree into the new region
fdt = (VOID*)(UINTN)NewFdtBlobBase;
err = fdt_open_into((VOID*)(UINTN)(*FdtBlobBase), fdt, NewFdtBlobSize);
@@ -530,7 +543,7 @@ PrepareFdt (
return EFI_SUCCESS;
FAIL_NEW_FDT:
- gBS->FreePages (NewFdtBlobBase, EFI_SIZE_TO_PAGES (NewFdtBlobSize));
+ gBS->FreePages (NewFdtBlobAllocation, EFI_SIZE_TO_PAGES (NewFdtBlobSize));
FAIL_ALLOCATE_NEW_FDT:
*FdtBlobSize = (UINTN)fdt_totalsize ((VOID*)(UINTN)(*FdtBlobBase));