3 Copyright (c) 2008 - 2009, Apple Inc. All rights reserved.<BR>
4 Portions Copyright (c) 2011 - 2021, Arm Limited. All rights reserved.<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
11 #include <Library/CpuExceptionHandlerLib.h>
12 #include <Guid/VectorHandoffTable.h>
15 InitializeExceptions (
16 IN EFI_CPU_ARCH_PROTOCOL
*Cpu
20 EFI_VECTOR_HANDOFF_INFO
*VectorInfoList
;
21 EFI_VECTOR_HANDOFF_INFO
*VectorInfo
;
25 VectorInfo
= (EFI_VECTOR_HANDOFF_INFO
*)NULL
;
26 Status
= EfiGetSystemConfigurationTable(&gEfiVectorHandoffTableGuid
, (VOID
**)&VectorInfoList
);
27 if (Status
== EFI_SUCCESS
&& VectorInfoList
!= NULL
) {
28 VectorInfo
= VectorInfoList
;
31 // initialize the CpuExceptionHandlerLib so we take over the exception vector table from the DXE Core
32 InitializeCpuExceptionHandlers(VectorInfo
);
39 Cpu
->GetInterruptState (Cpu
, &IrqEnabled
);
40 Cpu
->DisableInterrupt (Cpu
);
43 // EFI does not use the FIQ, but a debugger might so we must disable
44 // as we take over the exception vectors.
46 FiqEnabled
= ArmGetFiqState ();
55 // Restore interrupt state
57 Status
= Cpu
->EnableInterrupt (Cpu
);
61 // On a DEBUG build, unmask SErrors so they are delivered right away rather
62 // than when the OS unmasks them. This gives us a better chance of figuring
66 ArmEnableAsynchronousAbort ();
73 This function registers and enables the handler specified by InterruptHandler for a processor
74 interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the
75 handler for the processor interrupt or exception type specified by InterruptType is uninstalled.
76 The installed handler is called once for each processor interrupt or exception.
78 @param InterruptType A pointer to the processor's current interrupt state. Set to TRUE if interrupts
79 are enabled and FALSE if interrupts are disabled.
80 @param InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called
81 when a processor interrupt occurs. If this parameter is NULL, then the handler
84 @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.
85 @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was
87 @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not
89 @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported.
93 RegisterInterruptHandler(
94 IN EFI_EXCEPTION_TYPE InterruptType
,
95 IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
98 // pass down to CpuExceptionHandlerLib
99 return (EFI_STATUS
)RegisterCpuInterruptHandler(InterruptType
, InterruptHandler
);