--- /dev/null
+/*++\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
\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
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
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
// 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
--- /dev/null
+/*++\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
\r
[Sources.common]\r
ArmGicDxe.c\r
+ ArmGicCommonDxe.c\r
\r
[Packages]\r
MdePkg/MdePkg.dec\r