]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmGic: Added GicV3 detection
authorOlivier Martin <olivier.martin@arm.com>
Mon, 27 Oct 2014 10:28:44 +0000 (10:28 +0000)
committeroliviermartin <oliviermartin@Edk2>
Mon, 27 Oct 2014 10:28:44 +0000 (10:28 +0000)
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
Signed-off-by: Harry Liebel <Harry.Liebel@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16232 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Drivers/ArmGic/AArch64/ArmGicArchLib.c [new file with mode: 0644]
ArmPkg/Drivers/ArmGic/Arm/ArmGicArchLib.c [new file with mode: 0644]
ArmPkg/Drivers/ArmGic/ArmGicLib.c
ArmPkg/Drivers/ArmGic/ArmGicLib.inf
ArmPkg/Drivers/ArmGic/ArmGicSecLib.inf
ArmPkg/Include/Library/ArmGicLib.h

diff --git a/ArmPkg/Drivers/ArmGic/AArch64/ArmGicArchLib.c b/ArmPkg/Drivers/ArmGic/AArch64/ArmGicArchLib.c
new file mode 100644 (file)
index 0000000..5a7837f
--- /dev/null
@@ -0,0 +1,35 @@
+/** @file\r
+*\r
+*  Copyright (c) 2014, ARM Limited. All rights reserved.\r
+*\r
+*  This program and the accompanying materials are licensed and made available\r
+*  under the terms and conditions of the BSD License which 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,\r
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+*\r
+**/\r
+\r
+#include <Library/ArmLib.h>\r
+#include <Library/ArmGicLib.h>\r
+\r
+ARM_GIC_ARCH_REVISION\r
+EFIAPI\r
+ArmGicGetSupportedArchRevision (\r
+  VOID\r
+  )\r
+{\r
+  // Ideally we would like to use the GICC IIDR Architecture version here, but\r
+  // this does not seem to be very reliable as the implementation could easily\r
+  // get it wrong. It is more reliable to check if the GICv3 System Register\r
+  // feature is implemented on the CPU. This is also convenient as our GICv3\r
+  // driver requires SRE. If only Memory mapped access is available we try to\r
+  // drive the GIC as a v2.\r
+  if (ArmReadIdPfr0 () & AARCH64_PFR0_GIC) {\r
+    return ARM_GIC_ARCH_REVISION_3;\r
+  }\r
+\r
+  return ARM_GIC_ARCH_REVISION_2;\r
+}\r
diff --git a/ArmPkg/Drivers/ArmGic/Arm/ArmGicArchLib.c b/ArmPkg/Drivers/ArmGic/Arm/ArmGicArchLib.c
new file mode 100644 (file)
index 0000000..668858f
--- /dev/null
@@ -0,0 +1,35 @@
+/** @file\r
+*\r
+*  Copyright (c) 2014, ARM Limited. All rights reserved.\r
+*\r
+*  This program and the accompanying materials are licensed and made available\r
+*  under the terms and conditions of the BSD License which 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,\r
+*  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+*\r
+**/\r
+\r
+#include <Library/ArmLib.h>\r
+#include <Library/ArmGicLib.h>\r
+\r
+ARM_GIC_ARCH_REVISION\r
+EFIAPI\r
+ArmGicGetSupportedArchRevision (\r
+  VOID\r
+  )\r
+{\r
+  // Ideally we would like to use the GICC IIDR Architecture version here, but\r
+  // this does not seem to be very reliable as the implementation could easily\r
+  // get it wrong. It is more reliable to check if the GICv3 System Register\r
+  // feature is implemented on the CPU. This is also convenient as our GICv3\r
+  // driver requires SRE. If only Memory mapped access is available we try to\r
+  // drive the GIC as a v2.\r
+  if (ArmReadIdPfr1 () & ARM_PFR1_GIC) {\r
+    return ARM_GIC_ARCH_REVISION_3;\r
+  }\r
+\r
+  return ARM_GIC_ARCH_REVISION_2;\r
+}\r
index 23b312362f36eac9f2632f02e1d0ed09a31fc34b..7d99f9f98ab018d1c9fe4dc1e4125395893c3ce7 100644 (file)
 \r
 #include "GicV2/ArmGicV2Lib.h"\r
 \r
-ARM_GIC_ARCH_REVISION\r
-EFIAPI\r
-ArmGicGetSupportedArchRevision (\r
-  VOID\r
-  )\r
-{\r
-  return ARM_GIC_ARCH_REVISION_2;\r
-}\r
-\r
 UINTN\r
 EFIAPI\r
 ArmGicGetInterfaceIdentification (\r
index def70a0d5e85e0cb5dbf1233c98181a000533fdc..ca5cd1942b0885cbe88ef0aaa06a7020cb7258f5 100644 (file)
   GicV2/ArmGicV2Lib.c\r
   GicV2/ArmGicV2NonSecLib.c\r
 \r
+[Sources.ARM]\r
+  Arm/ArmGicArchLib.c\r
+\r
+[Sources.AARCH64]\r
+  AArch64/ArmGicArchLib.c\r
+\r
 [LibraryClasses]\r
+  ArmLib\r
   DebugLib\r
   IoLib\r
 \r
index 439bb91daeb986d15e6c53e62b35ccea3a2266e4..45382998f01b9f28e1164a7b68e434eb09ebfed0 100644 (file)
   GicV2/ArmGicV2Lib.c\r
   GicV2/ArmGicV2SecLib.c\r
 \r
+[Sources.ARM]\r
+  Arm/ArmGicArchLib.c\r
+\r
+[Sources.AARCH64]\r
+  AArch64/ArmGicArchLib.c\r
+\r
 [Packages]\r
   ArmPkg/ArmPkg.dec\r
   ArmPlatformPkg/ArmPlatformPkg.dec\r
@@ -34,7 +40,5 @@
 \r
 [LibraryClasses]\r
   ArmLib\r
-  ArmPlatformLib\r
   DebugLib\r
   IoLib\r
-  PcdLib\r
index 7ffd026378f6df02189e489c8d44b7efd35d05cc..4f0164ab884efc85d0d03a2373ba547a599fb817 100644 (file)
@@ -19,7 +19,8 @@
 // GIC definitions\r
 //\r
 typedef enum {\r
-  ARM_GIC_ARCH_REVISION_2\r
+  ARM_GIC_ARCH_REVISION_2,\r
+  ARM_GIC_ARCH_REVISION_3\r
 } ARM_GIC_ARCH_REVISION;\r
 \r
 //\r