22STATIC ARM_GIC_ARCH_REVISION mGicArchRevision;
26ArmVirtGicArchLibConstructor (
34 UINTN AddressCells, SizeCells;
37 UINT64 DistBase, CpuBase, RedistBase;
38 RETURN_STATUS PcdStatus;
40 Status =
gBS->LocateProtocol (
41 &gFdtClientProtocolGuid,
48 Status = FdtClient->FindCompatibleNodeReg (
56 if (Status == EFI_NOT_FOUND) {
58 Status = FdtClient->FindCompatibleNodeReg (
68 if (EFI_ERROR (Status)) {
72 switch (GicRevision) {
86 ASSERT (RegSize >= 32);
90 ASSERT (DistBase < MAX_UINTN);
94 ASSERT (RedistBase < MAX_UINTN);
96 PcdStatus =
PcdSet64S (PcdGicDistributorBase, DistBase);
98 PcdStatus =
PcdSet64S (PcdGicRedistributorsBase, RedistBase);
103 "Found GIC v3 (re)distributor @ 0x%Lx (0x%Lx)\n",
113 IccSre = ArmGicV3GetControlSystemRegisterEnable ();
114 if (!(IccSre & ICC_SRE_EL2_SRE)) {
115 ArmGicV3SetControlSystemRegisterEnable (IccSre | ICC_SRE_EL2_SRE);
116 IccSre = ArmGicV3GetControlSystemRegisterEnable ();
124 ASSERT (IccSre & ICC_SRE_EL2_SRE);
126 mGicArchRevision = ARM_GIC_ARCH_REVISION_3;
135 ASSERT ((RegSize == 32) || (RegSize == 64));
139 ASSERT (DistBase < MAX_UINTN);
140 ASSERT (CpuBase < MAX_UINTN);
142 PcdStatus =
PcdSet64S (PcdGicDistributorBase, DistBase);
144 PcdStatus =
PcdSet64S (PcdGicInterruptInterfaceBase, CpuBase);
147 DEBUG ((DEBUG_INFO,
"Found GIC @ 0x%Lx/0x%Lx\n", DistBase, CpuBase));
149 mGicArchRevision = ARM_GIC_ARCH_REVISION_2;
153 DEBUG ((DEBUG_ERROR,
"%a: No GIC revision specified!\n", __func__));
162ArmGicGetSupportedArchRevision (
166 return mGicArchRevision;
UINT64 EFIAPI SwapBytes64(IN UINT64 Value)
#define ASSERT_EFI_ERROR(StatusParameter)
#define ASSERT_RETURN_ERROR(StatusParameter)
#define DEBUG(Expression)
#define PcdSet64S(TokenName, Value)