3 Copyright (c) 2013-2014, ARM Ltd. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include "ArmGicDxe.h"
20 IN EFI_EXCEPTION_TYPE InterruptType
,
21 IN EFI_SYSTEM_CONTEXT SystemContext
26 ExitBootServicesEvent (
32 // Making this global saves a few bytes in image size
34 EFI_HANDLE gHardwareInterruptHandle
= NULL
;
39 EFI_EVENT EfiExitBootServicesEvent
= (EFI_EVENT
)NULL
;
41 // Maximum Number of Interrupts
42 UINTN mGicNumInterrupts
= 0;
44 HARDWARE_INTERRUPT_HANDLER
*gRegisteredInterruptHandlers
= NULL
;
47 InstallAndRegisterInterruptService (
48 IN EFI_HARDWARE_INTERRUPT_PROTOCOL
*InterruptProtocol
,
49 IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
,
50 IN EFI_EVENT_NOTIFY ExitBootServicesEvent
54 EFI_CPU_ARCH_PROTOCOL
*Cpu
;
56 // Initialize the array for the Interrupt Handlers
57 gRegisteredInterruptHandlers
= (HARDWARE_INTERRUPT_HANDLER
*)AllocateZeroPool (sizeof(HARDWARE_INTERRUPT_HANDLER
) * mGicNumInterrupts
);
58 if (gRegisteredInterruptHandlers
== NULL
) {
59 return EFI_OUT_OF_RESOURCES
;
62 Status
= gBS
->InstallMultipleProtocolInterfaces (
63 &gHardwareInterruptHandle
,
64 &gHardwareInterruptProtocolGuid
, InterruptProtocol
,
67 if (EFI_ERROR (Status
)) {
72 // Get the CPU protocol that this driver requires.
74 Status
= gBS
->LocateProtocol (&gEfiCpuArchProtocolGuid
, NULL
, (VOID
**)&Cpu
);
75 if (EFI_ERROR (Status
)) {
80 // Unregister the default exception handler.
82 Status
= Cpu
->RegisterInterruptHandler (Cpu
, ARM_ARCH_EXCEPTION_IRQ
, NULL
);
83 if (EFI_ERROR (Status
)) {
88 // Register to receive interrupts
90 Status
= Cpu
->RegisterInterruptHandler (Cpu
, ARM_ARCH_EXCEPTION_IRQ
, InterruptHandler
);
91 if (EFI_ERROR (Status
)) {
95 // Register for an ExitBootServicesEvent
96 Status
= gBS
->CreateEvent (EVT_SIGNAL_EXIT_BOOT_SERVICES
, TPL_NOTIFY
, ExitBootServicesEvent
, NULL
, &EfiExitBootServicesEvent
);