]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Library/CpuExceptionHandlerLib/SmmException.c
CpuException: Remove InitializeCpuInterruptHandlers
[mirror_edk2.git] / UefiCpuPkg / Library / CpuExceptionHandlerLib / SmmException.c
CommitLineData
e41aad15 1/** @file\r
418aded9 2 CPU exception handler library implementation for SMM modules.\r
e41aad15 3\r
2a09527e 4 Copyright (c) 2013 - 2022, Intel Corporation. All rights reserved.<BR>\r
0acd8697 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
e41aad15
JF
6\r
7**/\r
8\r
9#include <PiSmm.h>\r
10#include "CpuExceptionCommon.h"\r
11\r
053e878b 12CONST UINTN mDoFarReturnFlag = 1;\r
e41aad15 13\r
053e878b
MK
14RESERVED_VECTORS_DATA mReservedVectorsData[CPU_EXCEPTION_NUM];\r
15EFI_CPU_INTERRUPT_HANDLER mExternalInterruptHandlerTable[CPU_EXCEPTION_NUM];\r
34d50512 16EXCEPTION_HANDLER_DATA mExceptionHandlerData = {\r
2a09527e
RN
17 CPU_EXCEPTION_NUM,\r
18 0, // To be fixed\r
34d50512
RN
19 mReservedVectorsData,\r
20 mExternalInterruptHandlerTable\r
21};\r
d91225cf 22\r
44ecbc28
JF
23/**\r
24 Common exception handler.\r
25\r
26 @param ExceptionType Exception type.\r
27 @param SystemContext Pointer to EFI_SYSTEM_CONTEXT.\r
28**/\r
29VOID\r
30EFIAPI\r
31CommonExceptionHandler (\r
053e878b
MK
32 IN EFI_EXCEPTION_TYPE ExceptionType,\r
33 IN EFI_SYSTEM_CONTEXT SystemContext\r
44ecbc28
JF
34 )\r
35{\r
36 CommonExceptionHandlerWorker (ExceptionType, SystemContext, &mExceptionHandlerData);\r
37}\r
38\r
e41aad15
JF
39/**\r
40 Initializes all CPU exceptions entries and provides the default exception handlers.\r
dd563742 41\r
e41aad15
JF
42 Caller should try to get an array of interrupt and/or exception vectors that are in use and need to\r
43 persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.\r
dd563742 44 If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.\r
e41aad15
JF
45 If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.\r
46\r
47 @param[in] VectorInfo Pointer to reserved vector list.\r
dd563742
JF
48\r
49 @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized\r
e41aad15
JF
50 with default exception handlers.\r
51 @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.\r
52 @retval EFI_UNSUPPORTED This function is not supported.\r
53\r
54**/\r
55EFI_STATUS\r
56EFIAPI\r
57InitializeCpuExceptionHandlers (\r
053e878b 58 IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL\r
e41aad15
JF
59 )\r
60{\r
ab95e54d
JF
61 InitializeSpinLock (&mExceptionHandlerData.DisplayMessageSpinLock);\r
62 return InitializeCpuExceptionHandlersWorker (VectorInfo, &mExceptionHandlerData);\r
e41aad15
JF
63}\r
64\r
e41aad15
JF
65/**\r
66 Registers a function to be called from the processor interrupt handler.\r
67\r
dd563742
JF
68 This function registers and enables the handler specified by InterruptHandler for a processor\r
69 interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the\r
70 handler for the processor interrupt or exception type specified by InterruptType is uninstalled.\r
e41aad15 71 The installed handler is called once for each processor interrupt or exception.\r
2a09527e
RN
72 NOTE: This function should be invoked after InitializeCpuExceptionHandlers() is invoked,\r
73 otherwise EFI_UNSUPPORTED returned.\r
e41aad15
JF
74\r
75 @param[in] InterruptType Defines which interrupt or exception to hook.\r
76 @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called\r
77 when a processor interrupt occurs. If this parameter is NULL, then the handler\r
78 will be uninstalled.\r
79\r
80 @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.\r
81 @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was\r
82 previously installed.\r
83 @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not\r
84 previously installed.\r
85 @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported,\r
86 or this function is not supported.\r
3f25e6ea 87**/\r
e41aad15
JF
88EFI_STATUS\r
89EFIAPI\r
90RegisterCpuInterruptHandler (\r
053e878b
MK
91 IN EFI_EXCEPTION_TYPE InterruptType,\r
92 IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler\r
e41aad15
JF
93 )\r
94{\r
670f13af 95 return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler, &mExceptionHandlerData);\r
0ff5aa9c
JW
96}\r
97\r
98/**\r
99 Initializes all CPU exceptions entries with optional extra initializations.\r
100\r
101 By default, this method should include all functionalities implemented by\r
102 InitializeCpuExceptionHandlers(), plus extra initialization works, if any.\r
103 This could be done by calling InitializeCpuExceptionHandlers() directly\r
104 in this method besides the extra works.\r
105\r
106 InitData is optional and its use and content are processor arch dependent.\r
107 The typical usage of it is to convey resources which have to be reserved\r
108 elsewhere and are necessary for the extra initializations of exception.\r
109\r
110 @param[in] VectorInfo Pointer to reserved vector list.\r
111 @param[in] InitData Pointer to data optional for extra initializations\r
112 of exception.\r
113\r
114 @retval EFI_SUCCESS The exceptions have been successfully\r
115 initialized.\r
116 @retval EFI_INVALID_PARAMETER VectorInfo or InitData contains invalid\r
117 content.\r
118\r
119**/\r
120EFI_STATUS\r
121EFIAPI\r
122InitializeCpuExceptionHandlersEx (\r
053e878b
MK
123 IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL,\r
124 IN CPU_EXCEPTION_INIT_DATA *InitData OPTIONAL\r
0ff5aa9c
JW
125 )\r
126{\r
127 return InitializeCpuExceptionHandlers (VectorInfo);\r
128}\r