3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 Portions Copyright (c) 2011 - 2014, ARM Ltd. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
17 #include <Library/CpuExceptionHandlerLib.h>
18 #include <Guid/VectorHandoffTable.h>
21 InitializeExceptions (
22 IN EFI_CPU_ARCH_PROTOCOL
*Cpu
25 EFI_VECTOR_HANDOFF_INFO
*VectorInfoList
;
26 EFI_VECTOR_HANDOFF_INFO
*VectorInfo
;
30 VectorInfo
= (EFI_VECTOR_HANDOFF_INFO
*)NULL
;
31 Status
= EfiGetSystemConfigurationTable(&gEfiVectorHandoffTableGuid
, (VOID
**)&VectorInfoList
);
32 if (Status
== EFI_SUCCESS
&& VectorInfoList
!= NULL
) {
33 VectorInfo
= VectorInfoList
;
36 // intialize the CpuExceptionHandlerLib so we take over the exception vector table from the DXE Core
37 InitializeCpuExceptionHandlers(VectorInfo
);
44 Cpu
->GetInterruptState (Cpu
, &IrqEnabled
);
45 Cpu
->DisableInterrupt (Cpu
);
48 // EFI does not use the FIQ, but a debugger might so we must disable
49 // as we take over the exception vectors.
51 FiqEnabled
= ArmGetFiqState ();
60 // Restore interrupt state
62 Status
= Cpu
->EnableInterrupt (Cpu
);
66 // On a DEBUG build, unmask SErrors so they are delivered right away rather
67 // than when the OS unmasks them. This gives us a better chance of figuring
71 ArmEnableAsynchronousAbort ();
78 This function registers and enables the handler specified by InterruptHandler for a processor
79 interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the
80 handler for the processor interrupt or exception type specified by InterruptType is uninstalled.
81 The installed handler is called once for each processor interrupt or exception.
83 @param InterruptType A pointer to the processor's current interrupt state. Set to TRUE if interrupts
84 are enabled and FALSE if interrupts are disabled.
85 @param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called
86 when a processor interrupt occurs. If this parameter is NULL, then the handler
89 @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.
90 @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was
92 @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not
94 @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported.
98 RegisterInterruptHandler(
99 IN EFI_EXCEPTION_TYPE InterruptType
,
100 IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
102 // pass down to CpuExceptionHandlerLib
103 return (EFI_STATUS
)RegisterCpuInterruptHandler(InterruptType
, InterruptHandler
);