2 CPU exception handler library implementation for SMM modules.
4 Copyright (c) 2013 - 2022, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
10 #include "CpuExceptionCommon.h"
12 CONST UINTN mDoFarReturnFlag
= 1;
14 RESERVED_VECTORS_DATA mReservedVectorsData
[CPU_EXCEPTION_NUM
];
15 EFI_CPU_INTERRUPT_HANDLER mExternalInterruptHandlerTable
[CPU_EXCEPTION_NUM
];
16 EXCEPTION_HANDLER_DATA mExceptionHandlerData
= {
20 mExternalInterruptHandlerTable
24 Common exception handler.
26 @param ExceptionType Exception type.
27 @param SystemContext Pointer to EFI_SYSTEM_CONTEXT.
31 CommonExceptionHandler (
32 IN EFI_EXCEPTION_TYPE ExceptionType
,
33 IN EFI_SYSTEM_CONTEXT SystemContext
36 CommonExceptionHandlerWorker (ExceptionType
, SystemContext
, &mExceptionHandlerData
);
40 Initializes all CPU exceptions entries and provides the default exception handlers.
42 Caller should try to get an array of interrupt and/or exception vectors that are in use and need to
43 persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.
44 If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.
45 If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.
47 @param[in] VectorInfo Pointer to reserved vector list.
49 @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized
50 with default exception handlers.
51 @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.
52 @retval EFI_UNSUPPORTED This function is not supported.
57 InitializeCpuExceptionHandlers (
58 IN EFI_VECTOR_HANDOFF_INFO
*VectorInfo OPTIONAL
61 InitializeSpinLock (&mExceptionHandlerData
.DisplayMessageSpinLock
);
62 return InitializeCpuExceptionHandlersWorker (VectorInfo
, &mExceptionHandlerData
);
66 Registers a function to be called from the processor interrupt handler.
68 This function registers and enables the handler specified by InterruptHandler for a processor
69 interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the
70 handler for the processor interrupt or exception type specified by InterruptType is uninstalled.
71 The installed handler is called once for each processor interrupt or exception.
72 NOTE: This function should be invoked after InitializeCpuExceptionHandlers() is invoked,
73 otherwise EFI_UNSUPPORTED returned.
75 @param[in] InterruptType Defines which interrupt or exception to hook.
76 @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called
77 when a processor interrupt occurs. If this parameter is NULL, then the handler
80 @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.
81 @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was
83 @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not
85 @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported,
86 or this function is not supported.
90 RegisterCpuInterruptHandler (
91 IN EFI_EXCEPTION_TYPE InterruptType
,
92 IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler
95 return RegisterCpuInterruptHandlerWorker (InterruptType
, InterruptHandler
, &mExceptionHandlerData
);
99 Setup separate stacks for certain exception handlers.
101 InitData is optional and processor arch dependent.
103 @param[in] InitData Pointer to data optional for information about how
104 to assign stacks for certain exception handlers.
106 @retval EFI_SUCCESS The stacks are assigned successfully.
107 @retval EFI_UNSUPPORTED This function is not supported.
112 InitializeSeparateExceptionStacks (
113 IN CPU_EXCEPTION_INIT_DATA
*InitData OPTIONAL
116 return EFI_UNSUPPORTED
;