]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/BdsLib: Added support for FDT alignment through PcdArmLinuxFdtAlignment
authoroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 14 Apr 2013 09:36:41 +0000 (09:36 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Sun, 14 Apr 2013 09:36:41 +0000 (09:36 +0000)
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

ArmPkg/ArmPkg.dec
ArmPkg/Library/BdsLib/BdsLib.inf
ArmPkg/Library/BdsLib/BdsLinuxFdt.c

index cb711b2e31ccc2bfb56837166a826f901e2de407..81c4db6a6f109236ca388ca8679dd7ba1becbe53 100644 (file)
@@ -2,7 +2,7 @@
 # ARM processor package.\r
 #\r
 # Copyright (c) 2009 - 2010, Apple Inc. All rights reserved.<BR>\r
-# Copyright (c) 2011 - 2012, ARM Limited. All rights reserved.\r
+# Copyright (c) 2011 - 2013, 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
   # 0xC00 = cp10 | cp11\r
   gArmTokenSpaceGuid.PcdArmNsacr|0xC00|UINT32|0x00000039\r
   \r
-  gArmTokenSpaceGuid.PcdArmNonSecModeTransition|0x0|UINT32|0x0000003E\r
-\r
   # System Memory (DRAM): These PCDs define the region of in-built system memory\r
   # Some platforms can get DRAM extensions, these additional regions will be declared\r
   # to UEFI by ArmPLatformPlib   \r
   gArmTokenSpaceGuid.PcdArmLinuxKernelMaxOffset|0x08000000|UINT32|0x0000001F\r
   # The Linux ATAGs are expected to be under 0x4000 (16KB) from the beginning of the System Memory\r
   gArmTokenSpaceGuid.PcdArmLinuxAtagMaxOffset|0x4000|UINT32|0x00000020\r
-  # If the fixed FDT address is not available, then it should be loaded the below the kernel\r
-  # The recommandation from the Linux kernel is to have the FDT below 16KB\r
-  gArmTokenSpaceGuid.PcdArmLinuxFdtMaxOffset|0x4000|UINT32|0x00000023\r
 \r
   #\r
   # ARM Architectural Timer\r
   # ARM Architectural Timer Interrupt(GIC PPI) number\r
   gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|29|UINT32|0x00000035  \r
   gArmTokenSpaceGuid.PcdArmArchTimerIntrNum|30|UINT32|0x00000036\r
+\r
+[PcdsFixedAtBuild.ARM]\r
+  # By default we do not do a transition to non-secure mode\r
+  gArmTokenSpaceGuid.PcdArmNonSecModeTransition|0x0|UINT32|0x0000003E\r
+  # If the fixed FDT address is not available, then it should be loaded below the kernel.\r
+  # The recommendation from the Linux kernel is to have the FDT below 16KB.\r
+  # (see the kernel doc: Documentation/arm/Booting)\r
+  gArmTokenSpaceGuid.PcdArmLinuxFdtMaxOffset|0x4000|UINT32|0x00000023\r
+  # The FDT blob must be loaded at a 64bit aligned address.\r
+  gArmTokenSpaceGuid.PcdArmLinuxFdtAlignment|0x8|UINT32|0x00000026\r
index 335f4d6c59c80da17ef04c00481def0ac8876c6c..b6712a4fe2802617504437d75fe12f5ca813360f 100644 (file)
@@ -76,6 +76,7 @@
 \r
   gArmTokenSpaceGuid.PcdArmMachineType\r
   gArmTokenSpaceGuid.PcdArmLinuxFdtMaxOffset\r
+  gArmTokenSpaceGuid.PcdArmLinuxFdtAlignment\r
   gArmTokenSpaceGuid.PcdArmLinuxKernelMaxOffset\r
   gArmTokenSpaceGuid.PcdArmLinuxAtagMaxOffset\r
   \r
index b6d08944abd08b3b03802ad97a0fbaf4ca3b9f42..43daf5dd2a277d471558e290c663d0cc41702698 100644 (file)
@@ -214,7 +214,9 @@ PrepareFdt (
 {\r
   EFI_STATUS            Status;\r
   EFI_PHYSICAL_ADDRESS  NewFdtBlobBase;\r
+  EFI_PHYSICAL_ADDRESS  NewFdtBlobAllocation;\r
   UINTN                 NewFdtBlobSize;\r
+  UINT32                FdtAlignment;\r
   VOID*                 fdt;\r
   INTN                  err;\r
   INTN                  node;\r
@@ -295,9 +297,15 @@ PrepareFdt (
   //\r
   NewFdtBlobSize = OriginalFdtSize + FDT_ADDITIONAL_ENTRIES_SIZE;\r
 \r
+  // If FDT load address needs to be aligned, allocate more space.\r
+  FdtAlignment = PcdGet32 (PcdArmLinuxFdtAlignment);\r
+  if (FdtAlignment != 0) {\r
+    NewFdtBlobSize += FdtAlignment;\r
+  }\r
+\r
   // Try below a watermark address\r
   Status = EFI_NOT_FOUND;\r
-  if (PcdGet32(PcdArmLinuxFdtMaxOffset) != 0) {\r
+  if (PcdGet32 (PcdArmLinuxFdtMaxOffset) != 0) {\r
     NewFdtBlobBase = LINUX_FDT_MAX_OFFSET;\r
     Status = gBS->AllocatePages (AllocateMaxAddress, EfiBootServicesData, EFI_SIZE_TO_PAGES(NewFdtBlobSize), &NewFdtBlobBase);\r
     if (EFI_ERROR(Status)) {\r
@@ -316,6 +324,11 @@ PrepareFdt (
     }\r
   }\r
 \r
+  NewFdtBlobAllocation = NewFdtBlobBase;\r
+  if (FdtAlignment != 0) {\r
+    NewFdtBlobBase = ALIGN (NewFdtBlobBase, FdtAlignment);\r
+  }\r
+\r
   // Load the Original FDT tree into the new region\r
   fdt = (VOID*)(UINTN)NewFdtBlobBase;\r
   err = fdt_open_into((VOID*)(UINTN)(*FdtBlobBase), fdt, NewFdtBlobSize);\r
@@ -530,7 +543,7 @@ PrepareFdt (
   return EFI_SUCCESS;\r
 \r
 FAIL_NEW_FDT:\r
-  gBS->FreePages (NewFdtBlobBase, EFI_SIZE_TO_PAGES (NewFdtBlobSize));\r
+  gBS->FreePages (NewFdtBlobAllocation, EFI_SIZE_TO_PAGES (NewFdtBlobSize));\r
 \r
 FAIL_ALLOCATE_NEW_FDT:\r
   *FdtBlobSize = (UINTN)fdt_totalsize ((VOID*)(UINTN)(*FdtBlobBase));\r