]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmGic: Introduced support for GicV2 to ArmGicLib
authorOlivier Martin <olivier.martin@arm.com>
Fri, 4 Jul 2014 14:36:42 +0000 (14:36 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 4 Jul 2014 14:36:42 +0000 (14:36 +0000)
The support for GIcV2 was already existing. This change separate the GicV2
specific functions from the common Gic code (in preparation for GicV3 support).

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Olivier Martin <olivier.martin@arm.com>
git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@15626 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Drivers/ArmGic/ArmGicLib.c
ArmPkg/Drivers/ArmGic/ArmGicLib.inf
ArmPkg/Drivers/ArmGic/ArmGicNonSecLib.c
ArmPkg/Drivers/ArmGic/ArmGicSecLib.c
ArmPkg/Drivers/ArmGic/ArmGicSecLib.inf
ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Lib.c [new file with mode: 0644]
ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Lib.h [new file with mode: 0644]
ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c [new file with mode: 0644]
ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2SecLib.c [new file with mode: 0644]
ArmPkg/Include/Library/ArmGicLib.h

index c0f3bfb4c2ff13dc1a0e1047650c093115145527..666008638ce74d560f42e9f6628343e6a104ca3d 100644 (file)
@@ -16,6 +16,8 @@
 #include <Library/ArmGicLib.h>\r
 #include <Library/IoLib.h>\r
 \r
+#include "GicV2/ArmGicV2Lib.h"\r
+\r
 UINTN\r
 EFIAPI\r
 ArmGicGetInterfaceIdentification (\r
@@ -53,8 +55,7 @@ ArmGicAcknowledgeInterrupt (
   IN  UINTN          GicInterruptInterfaceBase\r
   )\r
 {\r
-  // Read the Interrupt Acknowledge Register\r
-  return MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCIAR);\r
+  return ArmGicV2AcknowledgeInterrupt (GicInterruptInterfaceBase);\r
 }\r
 \r
 VOID\r
@@ -64,7 +65,7 @@ ArmGicEndOfInterrupt (
   IN UINTN                  Source\r
   )\r
 {\r
-  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCEIOR, Source);\r
+  ArmGicV2EndOfInterrupt (GicInterruptInterfaceBase, Source);\r
 }\r
 \r
 VOID\r
@@ -129,3 +130,21 @@ ArmGicDisableDistributor (
   // Disable Gic Distributor\r
   MmioWrite32 (GicDistributorBase + ARM_GIC_ICDDCR, 0x0);\r
 }\r
+
+VOID\r
+EFIAPI\r
+ArmGicEnableInterruptInterface (\r
+  IN  INTN          GicInterruptInterfaceBase\r
+  )\r
+{\r
+  return ArmGicV2EnableInterruptInterface (GicInterruptInterfaceBase);\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+ArmGicDisableInterruptInterface (\r
+  IN  INTN          GicInterruptInterfaceBase\r
+  )\r
+{\r
+  return ArmGicV2DisableInterruptInterface (GicInterruptInterfaceBase);\r
+}\r
index a6e9d7e6767ed433adbeef5606d635a5bedd51e8..a3e110e69f13093cfff70b0a51a9a038a8171ce3 100644 (file)
@@ -23,6 +23,9 @@
   ArmGicLib.c\r
   ArmGicNonSecLib.c\r
 \r
+  GicV2/ArmGicV2Lib.c\r
+  GicV2/ArmGicV2NonSecLib.c\r
+\r
 [LibraryClasses]\r
   IoLib\r
 \r
index 3ff9b4888c71b200ecd8c2edb6e91ad56980fabe..06367f9d77af075800407022cedc8d11734beab8 100644 (file)
 #include <Library/IoLib.h>\r
 #include <Library/ArmGicLib.h>\r
 \r
-\r
-VOID\r
-EFIAPI\r
-ArmGicEnableInterruptInterface (\r
-  IN  INTN          GicInterruptInterfaceBase\r
-  )\r
-{  \r
-  /*\r
-  * Enable the CPU interface in Non-Secure world\r
-  * Note: The ICCICR register is banked when Security extensions are implemented\r
-  */\r
-  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCICR, 0x1);\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-ArmGicDisableInterruptInterface (\r
-  IN  INTN          GicInterruptInterfaceBase\r
-  )\r
-{\r
-  // Disable Gic Interface\r
-  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCICR, 0x0);\r
-  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCPMR, 0x0);\r
-}\r
-\r
 VOID\r
 EFIAPI\r
 ArmGicEnableDistributor (\r
index f249eac36a3aa3b780522a06ac4dfcd814014b7b..1fdd4d73bd7d77be46a27846a00143dce9e608ea 100644 (file)
@@ -1,70 +1,23 @@
 /** @file\r
 *\r
-*  Copyright (c) 2011-2013, ARM Limited. All rights reserved.\r
-*  \r
-*  This program and the accompanying materials                          \r
-*  are licensed and made available under the terms and conditions of the BSD License         \r
-*  which accompanies this distribution.  The full text of the license may be found at        \r
-*  http://opensource.org/licenses/bsd-license.php                                            \r
+*  Copyright (c) 2011-2014, ARM Limited. All rights reserved.\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
+*  This program and the accompanying materials\r
+*  are licensed and made available under the terms and conditions of the BSD License\r
+*  which accompanies this 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 <Base.h>\r
-#include <Library/ArmLib.h>\r
-#include <Library/ArmPlatformLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/IoLib.h>\r
 #include <Library/ArmGicLib.h>\r
 \r
-/*\r
- * This function configures the all interrupts to be Non-secure.\r
- *\r
- */\r
-VOID\r
-EFIAPI\r
-ArmGicSetupNonSecure (\r
-  IN  UINTN         MpId,\r
-  IN  INTN          GicDistributorBase,\r
-  IN  INTN          GicInterruptInterfaceBase\r
-  )\r
-{\r
-  UINTN InterruptId;\r
-  UINTN CachedPriorityMask;\r
-  UINTN Index;\r
-\r
-  CachedPriorityMask = MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCPMR);\r
-\r
-  // Set priority Mask so that no interrupts get through to CPU\r
-  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCPMR, 0);\r
-\r
-  InterruptId = MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCIAR);\r
-\r
-  // Only try to clear valid interrupts. Ignore spurious interrupts.\r
-  while ((InterruptId & 0x3FF) < ArmGicGetMaxNumInterrupts (GicDistributorBase))   {\r
-    // Some of the SGI's are still pending, read Ack register and send End of Interrupt Signal\r
-    ArmGicEndOfInterrupt (GicInterruptInterfaceBase, InterruptId);\r
-\r
-    // Next\r
-    InterruptId = MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCIAR);\r
-  }\r
-\r
-  // Only the primary core should set the Non Secure bit to the SPIs (Shared Peripheral Interrupt).\r
-  if (ArmPlatformIsPrimaryCore (MpId)) {\r
-    // Ensure all GIC interrupts are Non-Secure\r
-    for (Index = 0; Index < (ArmGicGetMaxNumInterrupts (GicDistributorBase) / 32); Index++) {\r
-      MmioWrite32 (GicDistributorBase + ARM_GIC_ICDISR + (Index * 4), 0xffffffff);\r
-    }\r
-  } else {\r
-    // The secondary cores only set the Non Secure bit to their banked PPIs\r
-    MmioWrite32 (GicDistributorBase + ARM_GIC_ICDISR, 0xffffffff);\r
-  }\r
-\r
-  // Ensure all interrupts can get through the priority mask\r
-  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCPMR, CachedPriorityMask);\r
-}\r
+#include "GicV2/ArmGicV2Lib.h"\r
 \r
 /*\r
  * This function configures the interrupts set by the mask to be secure.\r
@@ -93,41 +46,21 @@ ArmGicSetSecureInterrupts (
 \r
 VOID\r
 EFIAPI\r
-ArmGicEnableInterruptInterface (\r
-  IN  INTN          GicInterruptInterfaceBase\r
+ArmGicEnableDistributor (\r
+  IN  INTN          GicDistributorBase\r
   )\r
 {\r
-  // Set Priority Mask to allow interrupts\r
-  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCPMR, 0x000000FF);\r
-\r
-  // Enable CPU interface in Secure world\r
-  // Enable CPU interface in Non-secure World\r
-  // Signal Secure Interrupts to CPU using FIQ line *\r
-  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCICR,\r
-      ARM_GIC_ICCICR_ENABLE_SECURE |\r
-      ARM_GIC_ICCICR_ENABLE_NS |\r
-      ARM_GIC_ICCICR_SIGNAL_SECURE_TO_FIQ);\r
+  // Turn on the GIC distributor\r
+  MmioWrite32 (GicDistributorBase + ARM_GIC_ICDDCR, 1);\r
 }\r
 \r
 VOID\r
 EFIAPI\r
-ArmGicDisableInterruptInterface (\r
+ArmGicSetupNonSecure (\r
+  IN  UINTN         MpId,\r
+  IN  INTN          GicDistributorBase,\r
   IN  INTN          GicInterruptInterfaceBase\r
   )\r
 {\r
-  UINT32    ControlValue;\r
-\r
-  // Disable CPU interface in Secure world and Non-secure World\r
-  ControlValue = MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCICR);\r
-  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCICR, ControlValue & ~(ARM_GIC_ICCICR_ENABLE_SECURE | ARM_GIC_ICCICR_ENABLE_NS));\r
-}\r
-\r
-VOID\r
-EFIAPI\r
-ArmGicEnableDistributor (\r
-  IN  INTN          GicDistributorBase\r
-  )\r
-{\r
-  // Turn on the GIC distributor\r
-  MmioWrite32 (GicDistributorBase + ARM_GIC_ICDDCR, 1);\r
+  ArmGicV2SetupNonSecure (MpId, GicDistributorBase, GicInterruptInterfaceBase);\r
 }\r
index 0b25c8e093a5c3ef0492eddbe46772e40651ed7b..439bb91daeb986d15e6c53e62b35ccea3a2266e4 100644 (file)
@@ -23,6 +23,9 @@
   ArmGicLib.c\r
   ArmGicSecLib.c\r
 \r
+  GicV2/ArmGicV2Lib.c\r
+  GicV2/ArmGicV2SecLib.c\r
+\r
 [Packages]\r
   ArmPkg/ArmPkg.dec\r
   ArmPlatformPkg/ArmPlatformPkg.dec\r
diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Lib.c b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Lib.c
new file mode 100644 (file)
index 0000000..5ac1d89
--- /dev/null
@@ -0,0 +1,36 @@
+/** @file\r
+*\r
+*  Copyright (c) 2013-2014, ARM Limited. All rights reserved.\r
+*\r
+*  This program and the accompanying materials\r
+*  are licensed and made available under the terms and conditions of the BSD License\r
+*  which accompanies this 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/ArmGicLib.h>\r
+#include <Library/IoLib.h>\r
+\r
+UINTN\r
+EFIAPI\r
+ArmGicV2AcknowledgeInterrupt (\r
+  IN  UINTN          GicInterruptInterfaceBase\r
+  )\r
+{\r
+  // Read the Interrupt Acknowledge Register\r
+  return MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCIAR);\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+ArmGicV2EndOfInterrupt (\r
+  IN  UINTN                 GicInterruptInterfaceBase,\r
+  IN UINTN                  Source\r
+  )\r
+{\r
+  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCEIOR, Source);\r
+}\r
diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Lib.h b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2Lib.h
new file mode 100644 (file)
index 0000000..bfe9040
--- /dev/null
@@ -0,0 +1,101 @@
+/** @file\r
+*\r
+*  Copyright (c) 2013-2014, ARM Limited. All rights reserved.\r
+*\r
+*  This program and the accompanying materials\r
+*  are licensed and made available under the terms and conditions of the BSD License\r
+*  which accompanies this 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
+#ifndef _ARM_GIC_V2_H_\r
+#define _ARM_GIC_V2_H_\r
+\r
+//\r
+// GIC definitions\r
+//\r
+\r
+//\r
+// GIC Distributor\r
+//\r
+#define ARM_GIC_ICDDCR          0x000 // Distributor Control Register\r
+#define ARM_GIC_ICDICTR         0x004 // Interrupt Controller Type Register\r
+#define ARM_GIC_ICDIIDR         0x008 // Implementer Identification Register\r
+\r
+// Each reg base below repeats for VE_NUM_ARM_GIC_REG_PER_INT_BITS (see GIC spec)\r
+#define ARM_GIC_ICDISR          0x080 // Interrupt Security Registers\r
+#define ARM_GIC_ICDISER         0x100 // Interrupt Set-Enable Registers\r
+#define ARM_GIC_ICDICER         0x180 // Interrupt Clear-Enable Registers\r
+#define ARM_GIC_ICDSPR          0x200 // Interrupt Set-Pending Registers\r
+#define ARM_GIC_ICDICPR         0x280 // Interrupt Clear-Pending Registers\r
+#define ARM_GIC_ICDABR          0x300 // Active Bit Registers\r
+\r
+// Each reg base below repeats for VE_NUM_ARM_GIC_REG_PER_INT_BYTES\r
+#define ARM_GIC_ICDIPR          0x400 // Interrupt Priority Registers\r
+\r
+// Each reg base below repeats for VE_NUM_ARM_GIC_INTERRUPTS\r
+#define ARM_GIC_ICDIPTR         0x800 // Interrupt Processor Target Registers\r
+#define ARM_GIC_ICDICFR         0xC00 // Interrupt Configuration Registers\r
+\r
+#define ARM_GIC_ICDPPISR        0xD00 // PPI Status register\r
+\r
+// just one of these\r
+#define ARM_GIC_ICDSGIR         0xF00 // Software Generated Interrupt Register\r
+\r
+//\r
+// GIC Cpu interface\r
+//\r
+#define ARM_GIC_ICCICR          0x00  // CPU Interface Control Register\r
+#define ARM_GIC_ICCPMR          0x04  // Interrupt Priority Mask Register\r
+#define ARM_GIC_ICCBPR          0x08  // Binary Point Register\r
+#define ARM_GIC_ICCIAR          0x0C  // Interrupt Acknowledge Register\r
+#define ARM_GIC_ICCEIOR         0x10  // End Of Interrupt Register\r
+#define ARM_GIC_ICCRPR          0x14  // Running Priority Register\r
+#define ARM_GIC_ICCPIR          0x18  // Highest Pending Interrupt Register\r
+#define ARM_GIC_ICCABPR         0x1C  // Aliased Binary Point Register\r
+#define ARM_GIC_ICCIIDR         0xFC  // Identification Register\r
+\r
+// Bit Mask for\r
+#define ARM_GIC_ICCIAR_ACKINTID                 0x3FF\r
+\r
+// Interrupts from 1020 to 1023 are considered as special interrupts (eg: spurious interrupts)\r
+#define ARM_GIC_IS_SPECIAL_INTERRUPTS(Interrupt) (((Interrupt) >= 1020) && ((Interrupt) <= 1023))\r
+\r
+VOID\r
+EFIAPI\r
+ArmGicV2SetupNonSecure (\r
+  IN  UINTN         MpId,\r
+  IN  INTN          GicDistributorBase,\r
+  IN  INTN          GicInterruptInterfaceBase\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+ArmGicV2EnableInterruptInterface (\r
+  IN  INTN          GicInterruptInterfaceBase\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+ArmGicV2DisableInterruptInterface (\r
+  IN  INTN          GicInterruptInterfaceBase\r
+  );\r
+\r
+UINTN\r
+EFIAPI\r
+ArmGicV2AcknowledgeInterrupt (\r
+  IN  UINTN          GicInterruptInterfaceBase\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+ArmGicV2EndOfInterrupt (\r
+  IN UINTN                  GicInterruptInterfaceBase,\r
+  IN UINTN                  Source\r
+  );\r
+\r
+#endif\r
diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2NonSecLib.c
new file mode 100644 (file)
index 0000000..92b764f
--- /dev/null
@@ -0,0 +1,42 @@
+/** @file\r
+*\r
+*  Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
+*\r
+*  This program and the accompanying materials\r
+*  are licensed and made available under the terms and conditions of the BSD License\r
+*  which accompanies this 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 <Uefi.h>\r
+#include <Library/IoLib.h>\r
+#include <Library/ArmGicLib.h>\r
+\r
+\r
+VOID\r
+EFIAPI\r
+ArmGicV2EnableInterruptInterface (\r
+  IN  INTN          GicInterruptInterfaceBase\r
+  )\r
+{\r
+  /*\r
+  * Enable the CPU interface in Non-Secure world\r
+  * Note: The ICCICR register is banked when Security extensions are implemented\r
+  */\r
+  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCICR, 0x1);\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+ArmGicV2DisableInterruptInterface (\r
+  IN  INTN          GicInterruptInterfaceBase\r
+  )\r
+{\r
+  // Disable Gic Interface\r
+  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCICR, 0x0);\r
+  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCPMR, 0x0);\r
+}\r
diff --git a/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2SecLib.c b/ArmPkg/Drivers/ArmGic/GicV2/ArmGicV2SecLib.c
new file mode 100644 (file)
index 0000000..ac1e0e4
--- /dev/null
@@ -0,0 +1,100 @@
+/** @file\r
+*\r
+*  Copyright (c) 2011-2014, ARM Limited. All rights reserved.\r
+*\r
+*  This program and the accompanying materials\r
+*  are licensed and made available under the terms and conditions of the BSD License\r
+*  which accompanies this 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 <Base.h>\r
+#include <Library/ArmLib.h>\r
+#include <Library/ArmPlatformLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/IoLib.h>\r
+#include <Library/ArmGicLib.h>\r
+\r
+/*\r
+ * This function configures the all interrupts to be Non-secure.\r
+ *\r
+ */\r
+VOID\r
+EFIAPI\r
+ArmGicV2SetupNonSecure (\r
+  IN  UINTN         MpId,\r
+  IN  INTN          GicDistributorBase,\r
+  IN  INTN          GicInterruptInterfaceBase\r
+  )\r
+{\r
+  UINTN InterruptId;\r
+  UINTN CachedPriorityMask;\r
+  UINTN Index;\r
+  UINTN MaxInterrupts;\r
+\r
+  CachedPriorityMask = MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCPMR);\r
+\r
+  // Set priority Mask so that no interrupts get through to CPU\r
+  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCPMR, 0);\r
+\r
+  InterruptId   = MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCIAR);\r
+  MaxInterrupts = ArmGicGetMaxNumInterrupts (GicDistributorBase);\r
+\r
+  // Only try to clear valid interrupts. Ignore spurious interrupts.\r
+  while ((InterruptId & 0x3FF) < MaxInterrupts) {\r
+    // Some of the SGI's are still pending, read Ack register and send End of Interrupt Signal\r
+    ArmGicEndOfInterrupt (GicInterruptInterfaceBase, InterruptId);\r
+\r
+    // Next\r
+    InterruptId = MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCIAR);\r
+  }\r
+\r
+  // Only the primary core should set the Non Secure bit to the SPIs (Shared Peripheral Interrupt).\r
+  if (ArmPlatformIsPrimaryCore (MpId)) {\r
+    // Ensure all GIC interrupts are Non-Secure\r
+    for (Index = 0; Index < (MaxInterrupts / 32); Index++) {\r
+      MmioWrite32 (GicDistributorBase + ARM_GIC_ICDISR + (Index * 4), 0xffffffff);\r
+    }\r
+  } else {\r
+    // The secondary cores only set the Non Secure bit to their banked PPIs\r
+    MmioWrite32 (GicDistributorBase + ARM_GIC_ICDISR, 0xffffffff);\r
+  }\r
+\r
+  // Ensure all interrupts can get through the priority mask\r
+  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCPMR, CachedPriorityMask);\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+ArmGicV2EnableInterruptInterface (\r
+  IN  INTN          GicInterruptInterfaceBase\r
+  )\r
+{\r
+  // Set Priority Mask to allow interrupts\r
+  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCPMR, 0x000000FF);\r
+\r
+  // Enable CPU interface in Secure world\r
+  // Enable CPU interface in Non-secure World\r
+  // Signal Secure Interrupts to CPU using FIQ line *\r
+  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCICR,\r
+      ARM_GIC_ICCICR_ENABLE_SECURE |\r
+      ARM_GIC_ICCICR_ENABLE_NS |\r
+      ARM_GIC_ICCICR_SIGNAL_SECURE_TO_FIQ);\r
+}\r
+\r
+VOID\r
+EFIAPI\r
+ArmGicV2DisableInterruptInterface (\r
+  IN  INTN          GicInterruptInterfaceBase\r
+  )\r
+{\r
+  UINT32    ControlValue;\r
+\r
+  // Disable CPU interface in Secure world and Non-secure World\r
+  ControlValue = MmioRead32 (GicInterruptInterfaceBase + ARM_GIC_ICCICR);\r
+  MmioWrite32 (GicInterruptInterfaceBase + ARM_GIC_ICCICR, ControlValue & ~(ARM_GIC_ICCICR_ENABLE_SECURE | ARM_GIC_ICCICR_ENABLE_NS));\r
+}\r
index 24f1966b56c181fded87c77aabe282a43964cca5..f2d4c7b27ce02b982460e87941f2f14d6cd377e9 100644 (file)
@@ -76,9 +76,6 @@
 #define ARM_GIC_ICCIIDR_GET_REVISION(IccIidr)     (((IccIidr) >> 12) & 0xF)\r
 #define ARM_GIC_ICCIIDR_GET_IMPLEMENTER(IccIidr)  ((IccIidr) & 0xFFF)\r
 \r
-// Bit Mask for\r
-#define ARM_GIC_ICCIAR_ACKINTID                 0x3FF\r
-\r
 UINTN\r
 EFIAPI\r
 ArmGicGetInterfaceIdentification (\r