ArmVirtualizationPkg: use a HOB to store device tree blob
authorArd Biesheuvel <ard.biesheuvel@linaro.org>
Sat, 28 Feb 2015 20:26:00 +0000 (20:26 +0000)
committerlersek <lersek@Edk2>
Sat, 28 Feb 2015 20:26:00 +0000 (20:26 +0000)
Instead of using a dynamic PCD, store the device tree address in a HOB
so that we can also run under a configuration that does not support
dynamic PCDs.

This also adds MemoryAllocationLib to the [LibraryClasses] section of
ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf, as this
dependency was formerly satisfied transitively through one of the
library dependencies that were dropped.

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@16959 6f19259b-4bc3-4df7-8a09-765794883524

ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationPkg.dec
ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc
ArmPlatformPkg/ArmVirtualizationPkg/Library/ArmVirtualizationPlatformLib/ArmVirtualizationPlatformLib.inf
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.c
ArmPlatformPkg/ArmVirtualizationPkg/Library/PlatformPeiLib/PlatformPeiLib.inf
ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c
ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf
EmbeddedPkg/EmbeddedPkg.dec
EmbeddedPkg/Include/Guid/FdtHob.h [new file with mode: 0644]

index ddb7990..7ab2405 100644 (file)
@@ -44,8 +44,6 @@
   gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x0|UINT64|0x00000001\r
 \r
 [PcdsDynamic, PcdsFixedAtBuild]\r
-  gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress|0x0|UINT64|0x00000002\r
-\r
   #\r
   # ARM PSCI function invocations can be done either through hypervisor\r
   # calls (HVC) or secure monitor calls (SMC).\r
index 0da1224..2fd641f 100644 (file)
   # System Memory Size -- 1 MB initially, actual size will be fetched from DT\r
   gArmTokenSpaceGuid.PcdSystemMemorySize|0x00100000\r
 \r
-  # location of the device tree blob passed by QEMU\r
-  gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress|0x0\r
-\r
   gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|0x0\r
   gArmTokenSpaceGuid.PcdArmArchTimerIntrNum|0x0\r
   gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum|0x0\r
index 58bc2b8..c500d59 100644 (file)
@@ -22,6 +22,7 @@
 #include <libfdt.h>\r
 \r
 #include <Guid/EarlyPL011BaseAddress.h>\r
+#include <Guid/FdtHob.h>\r
 \r
 EFI_STATUS\r
 EFIAPI\r
@@ -32,6 +33,7 @@ PlatformPeim (
   VOID               *Base;\r
   VOID               *NewBase;\r
   UINTN              FdtSize;\r
+  UINT64             *FdtHobData;\r
   UINT64             *UartHobData;\r
   INT32              Node, Prev;\r
   CONST CHAR8        *Compatible;\r
@@ -41,15 +43,18 @@ PlatformPeim (
   UINT64             UartBase;\r
 \r
 \r
-  Base = (VOID*)(UINTN)FixedPcdGet64 (PcdDeviceTreeInitialBaseAddress);\r
+  Base = (VOID*)(UINTN)PcdGet64 (PcdDeviceTreeInitialBaseAddress);\r
+  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
   ASSERT (NewBase != NULL);\r
-\r
   CopyMem (NewBase, Base, FdtSize);\r
-  PcdSet64 (PcdDeviceTreeBaseAddress, (UINT64)(UINTN)NewBase);\r
+\r
+  FdtHobData = BuildGuidHob (&gFdtHobGuid, sizeof *FdtHobData);\r
+  ASSERT (FdtHobData != NULL);\r
+  *FdtHobData = (UINTN)NewBase;\r
 \r
   UartHobData = BuildGuidHob (&gEarlyPL011BaseAddressGuid, sizeof *UartHobData);\r
   ASSERT (UartHobData != NULL);\r
index a376fbd..96019e4 100644 (file)
   gArmTokenSpaceGuid.PcdFvSize\r
   gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress\r
 \r
-[Pcd]\r
-  gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress\r
-\r
 [Guids]\r
   gEarlyPL011BaseAddressGuid\r
+  gFdtHobGuid\r
 \r
 [Depex]\r
   gEfiPeiMemoryDiscoveredPpiGuid\r
index 041ad88..e63294a 100644 (file)
 #include <Library/DevicePathLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/DxeServicesLib.h>\r
+#include <Library/HobLib.h>\r
 #include <libfdt.h>\r
 \r
 #include <Guid/Fdt.h>\r
 #include <Guid/VirtioMmioTransport.h>\r
+#include <Guid/FdtHob.h>\r
 \r
 #pragma pack (1)\r
 typedef struct {\r
@@ -277,6 +279,7 @@ InitializeVirtFdtDxe (
   IN EFI_SYSTEM_TABLE     *SystemTable\r
   )\r
 {\r
+  VOID                           *Hob;\r
   VOID                           *DeviceTreeBase;\r
   INT32                          Node, Prev;\r
   INT32                          RtcNode;\r
@@ -297,8 +300,11 @@ InitializeVirtFdtDxe (
   UINT64                         FwCfgDataAddress;\r
   UINT64                         FwCfgDataSize;\r
 \r
-  DeviceTreeBase = (VOID *)(UINTN)PcdGet64 (PcdDeviceTreeBaseAddress);\r
-  ASSERT (DeviceTreeBase != NULL);\r
+  Hob = GetFirstGuidHob(&gFdtHobGuid);\r
+  if (Hob == NULL || GET_GUID_HOB_DATA_SIZE (Hob) != sizeof (UINT64)) {\r
+    return EFI_NOT_FOUND;\r
+  }\r
+  DeviceTreeBase = (VOID *)(UINTN)*(UINT64 *)GET_GUID_HOB_DATA (Hob);\r
 \r
   if (fdt_check_header (DeviceTreeBase) != 0) {\r
     DEBUG ((EFI_D_ERROR, "%a: No DTB found @ 0x%p\n", __FUNCTION__, DeviceTreeBase));\r
index cdfca61..bca0f0b 100644 (file)
   DxeServicesLib\r
   FdtLib\r
   VirtioMmioDeviceLib\r
+  HobLib\r
 \r
 [Guids]\r
   gFdtTableGuid\r
   gVirtioMmioTransportGuid\r
+  gFdtHobGuid\r
 \r
 [Pcd]\r
-  gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress\r
   gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod\r
   gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress\r
   gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress\r
index 1a498d2..1acfd4e 100644 (file)
@@ -52,6 +52,8 @@
   ## FDT Configuration Table\r
   # Include/Guid/Fdt.h\r
   gFdtTableGuid = { 0xb1b621d5, 0xf19c, 0x41a5, { 0x83, 0x0b, 0xd9, 0x15, 0x2c, 0x69, 0xaa, 0xe0 } }\r
+  # Include/Guid/FdtHob.h\r
+  gFdtHobGuid   = { 0x16958446, 0x19B7, 0x480B, { 0xB0, 0x47, 0x74, 0x85, 0xAD, 0x3F, 0x71, 0x6D } }\r
   gFdtVariableGuid = { 0x25a4fd4a, 0x9703, 0x4ba9, { 0xa1, 0x90, 0xb7, 0xc8, 0x4e, 0xfb, 0x3e, 0x57 } }\r
 \r
 [Protocols.common]\r
diff --git a/EmbeddedPkg/Include/Guid/FdtHob.h b/EmbeddedPkg/Include/Guid/FdtHob.h
new file mode 100644 (file)
index 0000000..287729e
--- /dev/null
@@ -0,0 +1,26 @@
+/** @file\r
+  GUID for the HOB that contains the copy of the flattened device tree blob\r
+\r
+  Copyright (C) 2014, Linaro Ltd.\r
+\r
+  This program and the accompanying materials are licensed and made available\r
+  under the terms and conditions of the BSD License that accompanies this\r
+  distribution. The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php.\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, WITHOUT\r
+  WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef __FDT_HOB_H__\r
+#define __FDT_HOB_H__\r
+\r
+#define FDT_HOB_GUID { \\r
+          0x16958446, 0x19B7, 0x480B, \\r
+          { 0xB0, 0x47, 0x74, 0x85, 0xAD, 0x3F, 0x71, 0x6D } \\r
+        }\r
+\r
+extern EFI_GUID gFdtHobGuid;\r
+\r
+#endif\r