]> git.proxmox.com Git - mirror_edk2.git/commitdiff
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 ddb79904fa8571f5536005ea5bff784d26a836d2..7ab2405b8848ecb8d5032895d38db9f21d75c34a 100644 (file)
@@ -44,8 +44,6 @@
   gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress|0x0|UINT64|0x00000001\r
 \r
 [PcdsDynamic, PcdsFixedAtBuild]\r
   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
   #\r
   # ARM PSCI function invocations can be done either through hypervisor\r
   # calls (HVC) or secure monitor calls (SMC).\r
index 0da1224649dc4eaa8c0f4382f248548e43f02319..2fd641fb65e3f7937c6704a43b04e2a925e8ba42 100644 (file)
   # System Memory Size -- 1 MB initially, actual size will be fetched from DT\r
   gArmTokenSpaceGuid.PcdSystemMemorySize|0x00100000\r
 \r
   # 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
   gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum|0x0\r
   gArmTokenSpaceGuid.PcdArmArchTimerIntrNum|0x0\r
   gArmTokenSpaceGuid.PcdArmArchTimerVirtIntrNum|0x0\r
index 43b3c6ca1befb6fe5483ab661cebf3b252e2e9f7..2cff4b62ea0cd4343a70f088807fdc3668a7ea51 100644 (file)
 \r
 [LibraryClasses]\r
   IoLib\r
 \r
 [LibraryClasses]\r
   IoLib\r
+  MemoryAllocationLib\r
   ArmLib\r
   PrintLib\r
   FdtLib\r
   ArmLib\r
   PrintLib\r
   FdtLib\r
-  SerialPortLib\r
-  HobLib\r
 \r
 [Sources.common]\r
   Virt.c\r
 \r
 [Sources.common]\r
   Virt.c\r
index 58bc2b828dcd8da001b5f9670175667e8558dc8b..c500d5964b254ba72be82ee01fb4f0e7dc12395f 100644 (file)
@@ -22,6 +22,7 @@
 #include <libfdt.h>\r
 \r
 #include <Guid/EarlyPL011BaseAddress.h>\r
 #include <libfdt.h>\r
 \r
 #include <Guid/EarlyPL011BaseAddress.h>\r
+#include <Guid/FdtHob.h>\r
 \r
 EFI_STATUS\r
 EFIAPI\r
 \r
 EFI_STATUS\r
 EFIAPI\r
@@ -32,6 +33,7 @@ PlatformPeim (
   VOID               *Base;\r
   VOID               *NewBase;\r
   UINTN              FdtSize;\r
   VOID               *Base;\r
   VOID               *NewBase;\r
   UINTN              FdtSize;\r
+  UINT64             *FdtHobData;\r
   UINT64             *UartHobData;\r
   INT32              Node, Prev;\r
   CONST CHAR8        *Compatible;\r
   UINT64             *UartHobData;\r
   INT32              Node, Prev;\r
   CONST CHAR8        *Compatible;\r
@@ -41,15 +43,18 @@ PlatformPeim (
   UINT64             UartBase;\r
 \r
 \r
   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
   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
   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
 \r
   UartHobData = BuildGuidHob (&gEarlyPL011BaseAddressGuid, sizeof *UartHobData);\r
   ASSERT (UartHobData != NULL);\r
index a376fbd1f345d36e37fbf7e8152fa104fede3280..96019e4009ff0c3e604913c4be4e2d9b2ac7c520 100644 (file)
   gArmTokenSpaceGuid.PcdFvSize\r
   gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress\r
 \r
   gArmTokenSpaceGuid.PcdFvSize\r
   gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress\r
 \r
-[Pcd]\r
-  gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress\r
-\r
 [Guids]\r
   gEarlyPL011BaseAddressGuid\r
 [Guids]\r
   gEarlyPL011BaseAddressGuid\r
+  gFdtHobGuid\r
 \r
 [Depex]\r
   gEfiPeiMemoryDiscoveredPpiGuid\r
 \r
 [Depex]\r
   gEfiPeiMemoryDiscoveredPpiGuid\r
index 041ad88e10bcb2cfb06cf77e2ba5f1f6cf36dbf7..e63294a12e11ddb5df340f489545151054cfecf9 100644 (file)
 #include <Library/DevicePathLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/DxeServicesLib.h>\r
 #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 <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
 \r
 #pragma pack (1)\r
 typedef struct {\r
@@ -277,6 +279,7 @@ InitializeVirtFdtDxe (
   IN EFI_SYSTEM_TABLE     *SystemTable\r
   )\r
 {\r
   IN EFI_SYSTEM_TABLE     *SystemTable\r
   )\r
 {\r
+  VOID                           *Hob;\r
   VOID                           *DeviceTreeBase;\r
   INT32                          Node, Prev;\r
   INT32                          RtcNode;\r
   VOID                           *DeviceTreeBase;\r
   INT32                          Node, Prev;\r
   INT32                          RtcNode;\r
@@ -297,8 +300,11 @@ InitializeVirtFdtDxe (
   UINT64                         FwCfgDataAddress;\r
   UINT64                         FwCfgDataSize;\r
 \r
   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
 \r
   if (fdt_check_header (DeviceTreeBase) != 0) {\r
     DEBUG ((EFI_D_ERROR, "%a: No DTB found @ 0x%p\n", __FUNCTION__, DeviceTreeBase));\r
index cdfca610604a8f3fd9ed35ccb7bdef9a5b71ae1f..bca0f0b5f39bf0723b3597320c38195986dd486d 100644 (file)
   DxeServicesLib\r
   FdtLib\r
   VirtioMmioDeviceLib\r
   DxeServicesLib\r
   FdtLib\r
   VirtioMmioDeviceLib\r
+  HobLib\r
 \r
 [Guids]\r
   gFdtTableGuid\r
   gVirtioMmioTransportGuid\r
 \r
 [Guids]\r
   gFdtTableGuid\r
   gVirtioMmioTransportGuid\r
+  gFdtHobGuid\r
 \r
 [Pcd]\r
 \r
 [Pcd]\r
-  gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress\r
   gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod\r
   gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress\r
   gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress\r
   gArmVirtualizationTokenSpaceGuid.PcdArmPsciMethod\r
   gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress\r
   gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress\r
index 1a498d2446fb293bf04081b13c154f982f2c0ed4..1acfd4e5c10b254607f93b692c365c4aa40b5137 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
   ## 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
   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