RETURN_STATUS
EFIAPI
@@ -31,7 +47,7 @@ ArmGicArchLibInitialize (
// feature is implemented on the CPU. This is also convenient as our GICv3
// driver requires SRE. If only Memory mapped access is available we try to
// drive the GIC as a v2.
- if (ArmReadIdPfr0 () & AARCH64_PFR0_GIC) {
+ if (GicSystemRegistersSupported()) {
// Make sure System Register access is enabled (SRE). This depends on the
// higher privilege level giving us permission, otherwise we will either
// cause an exception here, or the write doesn't stick in which case we need
@@ -46,13 +62,8 @@ ArmGicArchLibInitialize (
}
if (IccSre & ICC_SRE_EL2_SRE) {
mGicArchRevision = ARM_GIC_ARCH_REVISION_3;
- goto Done;
}
}
-
- mGicArchRevision = ARM_GIC_ARCH_REVISION_2;
-
-Done:
return RETURN_SUCCESS;
}
diff --git a/ArmPkg/Library/ArmGicArchLib/Arm/ArmGicArchLib.c b/ArmPkg/Library/ArmGicArchLib/Arm/ArmGicArchLib.c
index f8822a2..75ba156 100644
--- a/ArmPkg/Library/ArmGicArchLib/Arm/ArmGicArchLib.c
+++ b/ArmPkg/Library/ArmGicArchLib/Arm/ArmGicArchLib.c
@@ -15,7 +15,23 @@
#include <Library/ArmLib.h>
#include <Library/ArmGicLib.h>
-STATIC ARM_GIC_ARCH_REVISION mGicArchRevision;
+STATIC ARM_GIC_ARCH_REVISION mGicArchRevision = ARM_GIC_ARCH_REVISION_2;
+
+STATIC
+RETURN_STATUS
+EFIAPI
+GicSystemRegistersSupported (
+ VOID
+ )
+{
+#if defined (MDE_CPU_ARM)
+ return (ArmReadIdPfr1 () & ARM_PFR1_GIC);
+#elif defined(MDE_CPU_AARCH64)
+ return (ArmReadIdPfr0 () & AARCH64_PFR0_GIC);
+#else
+ #error "Unknown chipset."
+#endif
+}
RETURN_STATUS
EFIAPI
@@ -31,7 +47,7 @@ ArmGicArchLibInitialize (
// feature is implemented on the CPU. This is also convenient as our GICv3
// driver requires SRE. If only Memory mapped access is available we try to
// drive the GIC as a v2.
- if (ArmReadIdPfr1 () & ARM_PFR1_GIC) {
+ if (GicSystemRegistersSupported()) {
// Make sure System Register access is enabled (SRE). This depends on the
// higher privilege level giving us permission, otherwise we will either
// cause an exception here, or the write doesn't stick in which case we need
@@ -46,13 +62,8 @@ ArmGicArchLibInitialize (
}
if (IccSre & ICC_SRE_EL2_SRE) {
mGicArchRevision = ARM_GIC_ARCH_REVISION_3;
- goto Done;
}
}
-
- mGicArchRevision = ARM_GIC_ARCH_REVISION_2;
-
-Done:
return RETURN_SUCCESS;
}
--
2.1.0
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.orghttps://lists.01.org/mailman/listinfo/edk2-devel