Revision: 16960
          http://sourceforge.net/p/edk2/code/16960
Author:   lersek
Date:     2015-02-28 20:26:10 +0000 (Sat, 28 Feb 2015)
Log Message:
-----------
ArmVirtualizationPkg: add padding to FDT allocation

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 <[email protected]>
Reviewed-by: Olivier Martin <[email protected]>
Signed-off-by: Ard Biesheuvel <[email protected]>
Signed-off-by: Laszlo Ersek <[email protected]>

Modified Paths:
--------------
    trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
    
trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c
    
trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf

Modified: 
trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
===================================================================
--- trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec     
2015-02-28 20:26:00 UTC (rev 16959)
+++ trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec     
2015-02-28 20:26:10 UTC (rev 16960)
@@ -43,6 +43,12 @@
   #
   
gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x0|UINT64|0x00000001
 
+  #
+  # Padding in bytes to add to the device tree allocation, so that the DTB can
+  # be modified in place (default: 256 bytes)
+  #
+  
gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeAllocationPadding|256|UINT32|0x00000002
+
 [PcdsDynamic, PcdsFixedAtBuild]
   #
   # ARM PSCI function invocations can be done either through hypervisor

Modified: 
trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c
===================================================================
--- 
trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c
      2015-02-28 20:26:00 UTC (rev 16959)
+++ 
trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c
      2015-02-28 20:26:10 UTC (rev 16960)
@@ -33,6 +33,7 @@
   VOID               *Base;
   VOID               *NewBase;
   UINTN              FdtSize;
+  UINTN              FdtPages;
   UINT64             *FdtHobData;
   UINT64             *UartHobData;
   INT32              Node, Prev;
@@ -47,10 +48,11 @@
   ASSERT (Base != NULL);
   ASSERT (fdt_check_header (Base) == 0);
 
-  FdtSize = fdt_totalsize (Base);
-  NewBase = AllocatePages (EFI_SIZE_TO_PAGES (FdtSize));
+  FdtSize = fdt_totalsize (Base) + PcdGet32 (PcdDeviceTreeAllocationPadding);
+  FdtPages = EFI_SIZE_TO_PAGES (FdtSize);
+  NewBase = AllocatePages (FdtPages);
   ASSERT (NewBase != NULL);
-  CopyMem (NewBase, Base, FdtSize);
+  fdt_open_into (Base, NewBase, EFI_PAGES_TO_SIZE (FdtPages));
 
   FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof *FdtHobData);
   ASSERT (FdtHobData != NULL);

Modified: 
trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf
===================================================================
--- 
trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf
    2015-02-28 20:26:00 UTC (rev 16959)
+++ 
trunk/edk2/ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf
    2015-02-28 20:26:10 UTC (rev 16960)
@@ -40,6 +40,7 @@
   gArmTokenSpaceGuid.PcdFvBaseAddress
   gArmTokenSpaceGuid.PcdFvSize
   gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress
+  gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeAllocationPadding
 
 [Guids]
   gEarlyPL011BaseAddressGuid


------------------------------------------------------------------------------
Dive into the World of Parallel Programming The Go Parallel Website, sponsored
by Intel and developed in partnership with Slashdot Media, is your hub for all
things parallel software development, from weekly thought leadership blogs to
news, videos, case studies, tutorials and more. Take a look and join the 
conversation now. http://goparallel.sourceforge.net/
_______________________________________________
edk2-commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/edk2-commits

Reply via email to