]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmVirtualizationPkg: add padding to FDT allocation
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Sat, 28 Feb 2015 20:26:10 +0000 (20:26 +0000)
committerlersek <lersek@Edk2>
Sat, 28 Feb 2015 20:26:10 +0000 (20:26 +0000)
Our primary user QEMU/mach-virt presents us with a FDT blob padded
to 64 KB with plenty of room to set additional properties. However,
in the general case, we should only add properties after making sure
there is enough room available.

Contributed-under: TianoCore Contribution Agreement 1.0
Reviewed-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Olivier Martin <olivier.martin@arm.com>
Signed-off-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16960 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf

index 7ab2405b8848ecb8d5032895d38db9f21d75c34a..791b45bf500bd15edc6d8273b667d8b4ca57ea9e 100644 (file)
   #\r
   gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x0|UINT64|0x00000001\r
 \r
+  #\r
+  # Padding in bytes to add to the device tree allocation, so that the DTB can\r
+  # be modified in place (default: 256 bytes)\r
+  #\r
+  gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeAllocationPadding|256|UINT32|0x00000002\r
+\r
 [PcdsDynamic, PcdsFixedAtBuild]\r
   #\r
   # ARM PSCI function invocations can be done either through hypervisor\r
index c500d5964b254ba72be82ee01fb4f0e7dc12395f..bdf2b57fcb1e00a2da7329cc6805f4311529739f 100644 (file)
@@ -33,6 +33,7 @@ PlatformPeim (
   VOID               *Base;\r
   VOID               *NewBase;\r
   UINTN              FdtSize;\r
+  UINTN              FdtPages;\r
   UINT64             *FdtHobData;\r
   UINT64             *UartHobData;\r
   INT32              Node, Prev;\r
@@ -47,10 +48,11 @@ PlatformPeim (
   ASSERT (Base != NULL);\r
   ASSERT (fdt_check_header (Base) == 0);\r
 \r
-  FdtSize = fdt_totalsize (Base);\r
-  NewBase = AllocatePages (EFI_SIZE_TO_PAGES (FdtSize));\r
+  FdtSize = fdt_totalsize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding);\r
+  FdtPages = EFI_SIZE_TO_PAGES (FdtSize);\r
+  NewBase = AllocatePages (FdtPages);\r
   ASSERT (NewBase != NULL);\r
-  CopyMem (NewBase, Base, FdtSize);\r
+  fdt_open_into (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages));\r
 \r
   FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof *FdtHobData);\r
   ASSERT (FdtHobData != NULL);\r
index 96019e4009ff0c3e604913c4be4e2d9b2ac7c520..6675a1f91561d22c5ce1373093f918de8199fae6 100644 (file)
@@ -40,6 +40,7 @@
   gArmTokenSpaceGuid.PcdFvBaseAddress\r
   gArmTokenSpaceGuid.PcdFvSize\r
   gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress\r
+  gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeAllocationPadding\r
 \r
 [Guids]\r
   gEarlyPL011BaseAddressGuid\r