]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ArmPkg/ArmGic: Move the installation and the registration to InstallAndRegisterInterr...
authorOlivier Martin <olivier.martin@arm.com>
Fri, 4 Jul 2014 11:25:29 +0000 (11:25 +0000)
committeroliviermartin <oliviermartin@6f19259b-4bc3-4df7-8a09-765794883524>
Fri, 4 Jul 2014 11:25:29 +0000 (11:25 +0000)
It will allow reusing the same code for GICv2 and GICv3 only drivers.

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@15623 6f19259b-4bc3-4df7-8a09-765794883524

ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c [new file with mode: 0644]
ArmPkg/Drivers/ArmGic/ArmGicDxe.c
ArmPkg/Drivers/ArmGic/ArmGicDxe.h [new file with mode: 0644]
ArmPkg/Drivers/ArmGic/ArmGicDxe.inf

diff --git a/ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c b/ArmPkg/Drivers/ArmGic/ArmGicCommonDxe.c
new file mode 100644 (file)
index 0000000..346d0bc
--- /dev/null
@@ -0,0 +1,99 @@
+/*++\r
+\r
+Copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR>\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 "ArmGicDxe.h"\r
+\r
+VOID\r
+EFIAPI\r
+IrqInterruptHandler (\r
+  IN EFI_EXCEPTION_TYPE           InterruptType,\r
+  IN EFI_SYSTEM_CONTEXT           SystemContext\r
+  );\r
+\r
+VOID\r
+EFIAPI\r
+ExitBootServicesEvent (\r
+  IN EFI_EVENT  Event,\r
+  IN VOID       *Context\r
+  );\r
+\r
+//\r
+// Making this global saves a few bytes in image size\r
+//\r
+EFI_HANDLE  gHardwareInterruptHandle = NULL;\r
+\r
+//\r
+// Notifications\r
+//\r
+EFI_EVENT EfiExitBootServicesEvent      = (EFI_EVENT)NULL;\r
+\r
+// Maximum Number of Interrupts\r
+UINTN mGicNumInterrupts                 = 0;\r
+\r
+HARDWARE_INTERRUPT_HANDLER  *gRegisteredInterruptHandlers = NULL;\r
+\r
+EFI_STATUS\r
+InstallAndRegisterInterruptService (\r
+  IN EFI_HARDWARE_INTERRUPT_PROTOCOL   *InterruptProtocol,\r
+  IN EFI_CPU_INTERRUPT_HANDLER          InterruptHandler,\r
+  IN EFI_EVENT_NOTIFY                   ExitBootServicesEvent\r
+  )\r
+{\r
+  EFI_STATUS               Status;\r
+  EFI_CPU_ARCH_PROTOCOL   *Cpu;\r
+\r
+  // Initialize the array for the Interrupt Handlers\r
+  gRegisteredInterruptHandlers = (HARDWARE_INTERRUPT_HANDLER*)AllocateZeroPool (sizeof(HARDWARE_INTERRUPT_HANDLER) * mGicNumInterrupts);\r
+  if (gRegisteredInterruptHandlers == NULL) {\r
+    return EFI_OUT_OF_RESOURCES;\r
+  }\r
+\r
+  Status = gBS->InstallMultipleProtocolInterfaces (\r
+                  &gHardwareInterruptHandle,\r
+                  &gHardwareInterruptProtocolGuid, InterruptProtocol,\r
+                  NULL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Get the CPU protocol that this driver requires.\r
+  //\r
+  Status = gBS->LocateProtocol (&gEfiCpuArchProtocolGuid, NULL, (VOID **)&Cpu);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Unregister the default exception handler.\r
+  //\r
+  Status = Cpu->RegisterInterruptHandler (Cpu, ARM_ARCH_EXCEPTION_IRQ, NULL);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Register to receive interrupts\r
+  //\r
+  Status = Cpu->RegisterInterruptHandler (Cpu, ARM_ARCH_EXCEPTION_IRQ, InterruptHandler);\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  // Register for an ExitBootServicesEvent\r
+  Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_NOTIFY, ExitBootServicesEvent, NULL, &EfiExitBootServicesEvent);\r
+\r
+  return Status;\r
+}\r
index c360d113be3d1a1901196c220c9ea405cbc158d3..ab912d79be4f8d8053246554af1b2ab3da9adf39 100644 (file)
@@ -24,34 +24,19 @@ Abstract:
 \r
 #include <PiDxe.h>\r
 \r
-#include <Library/ArmLib.h>\r
 #include <Library/BaseLib.h>\r
-#include <Library/DebugLib.h>\r
 #include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/UefiLib.h>\r
 #include <Library/PcdLib.h>\r
 #include <Library/IoLib.h>\r
 #include <Library/ArmGicLib.h>\r
 \r
-#include <Protocol/Cpu.h>\r
-#include <Protocol/HardwareInterrupt.h>\r
+#include "ArmGicDxe.h"\r
 \r
 #define ARM_GIC_DEFAULT_PRIORITY  0x80\r
 \r
 extern EFI_HARDWARE_INTERRUPT_PROTOCOL gHardwareInterruptProtocol;\r
 \r
-//\r
-// Notifications\r
-//\r
-EFI_EVENT EfiExitBootServicesEvent      = (EFI_EVENT)NULL;\r
-\r
-// Maximum Number of Interrupts\r
-UINTN mGicNumInterrupts                 = 0;\r
-\r
-HARDWARE_INTERRUPT_HANDLER  *gRegisteredInterruptHandlers = NULL;\r
-\r
 /**\r
   Register Handler for the specified interrupt source.\r
 \r
@@ -244,11 +229,6 @@ IrqInterruptHandler (
   EndOfInterrupt (&gHardwareInterruptProtocol, GicInterrupt);\r
 }\r
 \r
-//\r
-// Making this global saves a few bytes in image size\r
-//\r
-EFI_HANDLE  gHardwareInterruptHandle = NULL;\r
-\r
 //\r
 // The protocol instance produced by this driver\r
 //\r
@@ -315,7 +295,6 @@ InterruptDxeInitialize (
   UINTN                   Index;\r
   UINT32                  RegOffset;\r
   UINTN                   RegShift;\r
-  EFI_CPU_ARCH_PROTOCOL   *Cpu;\r
   UINT32                  CpuTarget;\r
   \r
   // Make sure the Interrupt Controller Protocol is not already installed in the system.\r
@@ -370,37 +349,8 @@ InterruptDxeInitialize (
   // Enable gic distributor\r
   ArmGicEnableDistributor (PcdGet32(PcdGicDistributorBase));\r
 \r
-  // Initialize the array for the Interrupt Handlers\r
-  gRegisteredInterruptHandlers = (HARDWARE_INTERRUPT_HANDLER*)AllocateZeroPool (sizeof(HARDWARE_INTERRUPT_HANDLER) * mGicNumInterrupts);\r
-\r
-  Status = gBS->InstallMultipleProtocolInterfaces (\r
-                  &gHardwareInterruptHandle,\r
-                  &gHardwareInterruptProtocolGuid,   &gHardwareInterruptProtocol,\r
-                  NULL\r
-                  );\r
-  ASSERT_EFI_ERROR (Status);\r
-\r
-  //\r
-  // Get the CPU protocol that this driver requires.\r
-  //\r
-  Status = gBS->LocateProtocol(&gEfiCpuArchProtocolGuid, NULL, (VOID **)&Cpu);\r
-  ASSERT_EFI_ERROR(Status);\r
-\r
-  //\r
-  // Unregister the default exception handler.\r
-  //\r
-  Status = Cpu->RegisterInterruptHandler(Cpu, ARM_ARCH_EXCEPTION_IRQ, NULL);\r
-  ASSERT_EFI_ERROR(Status);\r
-\r
-  //\r
-  // Register to receive interrupts\r
-  //\r
-  Status = Cpu->RegisterInterruptHandler(Cpu, ARM_ARCH_EXCEPTION_IRQ, IrqInterruptHandler);\r
-  ASSERT_EFI_ERROR(Status);\r
-\r
-  // Register for an ExitBootServicesEvent\r
-  Status = gBS->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES, TPL_NOTIFY, ExitBootServicesEvent, NULL, &EfiExitBootServicesEvent);\r
-  ASSERT_EFI_ERROR (Status);\r
+  Status = InstallAndRegisterInterruptService (\r
+      &gHardwareInterruptProtocol, IrqInterruptHandler, ExitBootServicesEvent);\r
 \r
   return Status;\r
 }\r
diff --git a/ArmPkg/Drivers/ArmGic/ArmGicDxe.h b/ArmPkg/Drivers/ArmGic/ArmGicDxe.h
new file mode 100644 (file)
index 0000000..4fc65b1
--- /dev/null
@@ -0,0 +1,39 @@
+/*++\r
+\r
+Copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR>\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_DXE_H__\r
+#define __ARM_GIC_DXE_H__\r
+\r
+#include <Library/ArmLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+\r
+#include <Protocol/Cpu.h>\r
+#include <Protocol/HardwareInterrupt.h>\r
+\r
+extern UINTN                        mGicNumInterrupts;\r
+extern HARDWARE_INTERRUPT_HANDLER  *gRegisteredInterruptHandlers;\r
+\r
+//\r
+// Common API\r
+//\r
+EFI_STATUS\r
+InstallAndRegisterInterruptService (\r
+  IN EFI_HARDWARE_INTERRUPT_PROTOCOL   *InterruptProtocol,\r
+  IN EFI_CPU_INTERRUPT_HANDLER          InterruptHandler,\r
+  IN EFI_EVENT_NOTIFY                   ExitBootServicesEvent\r
+  );\r
+\r
+#endif\r
index c6e7140c6ee4b983f8eb18db935b33d95c6525bf..1a70215bc1fd463c8f8e5b8a394319c3d9db702f 100644 (file)
@@ -24,6 +24,7 @@
 \r
 [Sources.common]\r
   ArmGicDxe.c\r
+  ArmGicCommonDxe.c\r
 \r
 [Packages]\r
   MdePkg/MdePkg.dec\r