[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH v4 04/29] ArmVirtualizationPkg: add GICv3 detection to VirtFdtDxe
This adds support for detecting the presence of a GICv3 interrupt controller from the device tree, and recording its distributor and redistributor base addresses in their respective PCDs. Contributed-under: TianoCore Contribution Agreement 1.0 Reviewed-by: Olivier Martin <olivier.martin@xxxxxxx> Acked-by: Laszlo Ersek <lersek@xxxxxxxxxx> Signed-off-by: Ard Biesheuvel <ard.biesheuvel@xxxxxxxxxx> --- ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc | 1 + ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c | 34 +++++++++++++++++++++++++++++++++- ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf | 1 + 3 files changed, 35 insertions(+), 1 deletion(-) diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc index 32c8deb3b1d6..066108f66d28 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc +++ b/ArmPlatformPkg/ArmVirtualizationPkg/ArmVirtualizationQemu.dsc @@ -172,6 +172,7 @@ # ARM General Interrupt Controller # gArmTokenSpaceGuid.PcdGicDistributorBase|0x0 + gArmTokenSpaceGuid.PcdGicRedistributorsBase|0x0 gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase|0x0 ## PL031 RealTimeClock diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c index 1d44f9ba02b3..a12bd8686fcc 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c +++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.c @@ -46,6 +46,7 @@ typedef enum { PropertyTypeTimer, PropertyTypePsci, PropertyTypeFwCfg, + PropertyTypeGicV3, } PROPERTY_TYPE; typedef struct { @@ -62,6 +63,7 @@ STATIC CONST PROPERTY CompatibleProperties[] = { { PropertyTypeTimer, "arm,armv8-timer" }, { PropertyTypePsci, "arm,psci-0.2" }, { PropertyTypeFwCfg, "qemu,fw-cfg-mmio" }, + { PropertyTypeGicV3, "arm,gic-v3" }, { PropertyTypeUnknown, "" } }; @@ -114,7 +116,7 @@ InitializeVirtFdtDxe ( VIRTIO_TRANSPORT_DEVICE_PATH *DevicePath; EFI_HANDLE Handle; UINT64 RegBase; - UINT64 DistBase, CpuBase; + UINT64 DistBase, CpuBase, RedistBase; CONST INTERRUPT_PROPERTY *InterruptProp; INT32 SecIntrNum, IntrNum, VirtIntrNum, HypIntrNum; CONST CHAR8 *PsciMethod; @@ -256,6 +258,36 @@ InitializeVirtFdtDxe ( DEBUG ((EFI_D_INFO, "Found GIC @ 0x%Lx/0x%Lx\n", DistBase, CpuBase)); break; + case PropertyTypeGicV3: + // + // The GIC v3 DT binding describes a series of at least 3 physical (base + // addresses, size) pairs: the distributor interface (GICD), at least one + // redistributor region (GICR) containing dedicated redistributor + // interfaces for all individual CPUs, and the CPU interface (GICC). + // Under virtualization, we assume that the first redistributor region + // listed covers the boot CPU. Also, our GICv3 driver only supports the + // system register CPU interface, so we can safely ignore the MMIO version + // which is listed after the sequence of redistributor interfaces. + // This means we are only interested in the first two memory regions + // supplied, and ignore everything else. + // + ASSERT (Len >= 32); + + // RegProp[0..1] == { GICD base, GICD size } + DistBase = fdt64_to_cpu (((UINT64 *)RegProp)[0]); + ASSERT (DistBase < MAX_UINT32); + + // RegProp[2..3] == { GICR base, GICR size } + RedistBase = fdt64_to_cpu (((UINT64 *)RegProp)[2]); + ASSERT (RedistBase < MAX_UINT32); + + PcdSet32 (PcdGicDistributorBase, (UINT32)DistBase); + PcdSet32 (PcdGicRedistributorsBase, (UINT32)RedistBase); + + DEBUG ((EFI_D_INFO, "Found GIC v3 (re)distributor @ 0x%Lx (0x%Lx)\n", + DistBase, RedistBase)); + break; + case PropertyTypeRtc: ASSERT (Len == 16); diff --git a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf index 514ce2fdf658..1ed02b6f3750 100644 --- a/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf +++ b/ArmPlatformPkg/ArmVirtualizationPkg/VirtFdtDxe/VirtFdtDxe.inf @@ -51,6 +51,7 @@ gArmVirtualizationTokenSpaceGuid.PcdFwCfgSelectorAddress gArmVirtualizationTokenSpaceGuid.PcdFwCfgDataAddress gArmTokenSpaceGuid.PcdGicDistributorBase + gArmTokenSpaceGuid.PcdGicRedistributorsBase gArmTokenSpaceGuid.PcdGicInterruptInterfaceBase gArmTokenSpaceGuid.PcdArmArchTimerSecIntrNum gArmTokenSpaceGuid.PcdArmArchTimerIntrNum -- 1.8.3.2 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx http://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |