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
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
# 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
\r
[LibraryClasses]\r
IoLib\r
+ MemoryAllocationLib\r
ArmLib\r
PrintLib\r
FdtLib\r
- SerialPortLib\r
- HobLib\r
\r
[Sources.common]\r
Virt.c\r
#include <libfdt.h>\r
\r
#include <Guid/EarlyPL011BaseAddress.h>\r
+#include <Guid/FdtHob.h>\r
\r
EFI_STATUS\r
EFIAPI\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 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
gArmTokenSpaceGuid.PcdFvSize\r
gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeInitialBaseAddress\r
\r
-[Pcd]\r
- gArmVirtualizationTokenSpaceGuid.PcdDeviceTreeBaseAddress\r
-\r
[Guids]\r
gEarlyPL011BaseAddressGuid\r
+ gFdtHobGuid\r
\r
[Depex]\r
gEfiPeiMemoryDiscoveredPpiGuid\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 <Guid/FdtHob.h>\r
\r
#pragma pack (1)\r
typedef struct {\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
{\r
+ VOID *Hob;\r
VOID *DeviceTreeBase;\r
INT32 Node, Prev;\r
INT32 RtcNode;\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
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
## 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
--- /dev/null
+/** @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