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