]>
Commit | Line | Data |
---|---|---|
e41aad15 JF |
1 | /** @file\r |
2 | CPU exception handler library implemenation for SMM modules.\r | |
3 | \r | |
1b2f7b3e | 4 | Copyright (c) 2013 - 2017, 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 | |
dd563742 | 12 | CONST UINTN mDoFarReturnFlag = 1;\r |
e41aad15 | 13 | \r |
d91225cf JF |
14 | //\r |
15 | // Spin lock for CPU information display\r | |
16 | //\r | |
17 | SPIN_LOCK mDisplayMessageSpinLock;\r | |
18 | \r | |
d91225cf JF |
19 | RESERVED_VECTORS_DATA mReservedVectorsData[CPU_EXCEPTION_NUM];\r |
20 | EFI_CPU_INTERRUPT_HANDLER mExternalInterruptHandlerTable[CPU_EXCEPTION_NUM];\r | |
2c5873fe | 21 | EXCEPTION_HANDLER_DATA mExceptionHandlerData;\r |
44ecbc28 JF |
22 | /**\r |
23 | Common exception handler.\r | |
24 | \r | |
25 | @param ExceptionType Exception type.\r | |
26 | @param SystemContext Pointer to EFI_SYSTEM_CONTEXT.\r | |
27 | **/\r | |
28 | VOID\r | |
29 | EFIAPI\r | |
30 | CommonExceptionHandler (\r | |
dd563742 | 31 | IN EFI_EXCEPTION_TYPE ExceptionType,\r |
44ecbc28 JF |
32 | IN EFI_SYSTEM_CONTEXT SystemContext\r |
33 | )\r | |
34 | {\r | |
35 | CommonExceptionHandlerWorker (ExceptionType, SystemContext, &mExceptionHandlerData);\r | |
36 | }\r | |
37 | \r | |
e41aad15 JF |
38 | /**\r |
39 | Initializes all CPU exceptions entries and provides the default exception handlers.\r | |
dd563742 | 40 | \r |
e41aad15 JF |
41 | Caller should try to get an array of interrupt and/or exception vectors that are in use and need to\r |
42 | persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.\r | |
dd563742 | 43 | If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.\r |
e41aad15 JF |
44 | If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.\r |
45 | \r | |
46 | @param[in] VectorInfo Pointer to reserved vector list.\r | |
dd563742 JF |
47 | \r |
48 | @retval EFI_SUCCESS CPU Exception Entries have been successfully initialized\r | |
e41aad15 JF |
49 | with default exception handlers.\r |
50 | @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.\r | |
51 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
52 | \r | |
53 | **/\r | |
54 | EFI_STATUS\r | |
55 | EFIAPI\r | |
56 | InitializeCpuExceptionHandlers (\r | |
57 | IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL\r | |
58 | )\r | |
59 | {\r | |
ab95e54d JF |
60 | mExceptionHandlerData.ReservedVectors = mReservedVectorsData;\r |
61 | mExceptionHandlerData.ExternalInterruptHandler = mExternalInterruptHandlerTable;\r | |
62 | InitializeSpinLock (&mExceptionHandlerData.DisplayMessageSpinLock);\r | |
63 | return InitializeCpuExceptionHandlersWorker (VectorInfo, &mExceptionHandlerData);\r | |
e41aad15 JF |
64 | }\r |
65 | \r | |
66 | /**\r | |
67 | Initializes all CPU interrupt/exceptions entries and provides the default interrupt/exception handlers.\r | |
dd563742 | 68 | \r |
e41aad15 JF |
69 | Caller should try to get an array of interrupt and/or exception vectors that are in use and need to\r |
70 | persist by EFI_VECTOR_HANDOFF_INFO defined in PI 1.3 specification.\r | |
dd563742 | 71 | If caller cannot get reserved vector list or it does not exists, set VectorInfo to NULL.\r |
e41aad15 JF |
72 | If VectorInfo is not NULL, the exception vectors will be initialized per vector attribute accordingly.\r |
73 | \r | |
74 | @param[in] VectorInfo Pointer to reserved vector list.\r | |
dd563742 JF |
75 | \r |
76 | @retval EFI_SUCCESS All CPU interrupt/exception entries have been successfully initialized\r | |
e41aad15 JF |
77 | with default interrupt/exception handlers.\r |
78 | @retval EFI_INVALID_PARAMETER VectorInfo includes the invalid content if VectorInfo is not NULL.\r | |
79 | @retval EFI_UNSUPPORTED This function is not supported.\r | |
80 | \r | |
81 | **/\r | |
82 | EFI_STATUS\r | |
83 | EFIAPI\r | |
84 | InitializeCpuInterruptHandlers (\r | |
85 | IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL\r | |
86 | )\r | |
87 | {\r | |
88 | return EFI_UNSUPPORTED;\r | |
89 | }\r | |
90 | \r | |
91 | /**\r | |
92 | Registers a function to be called from the processor interrupt handler.\r | |
93 | \r | |
dd563742 JF |
94 | This function registers and enables the handler specified by InterruptHandler for a processor\r |
95 | interrupt or exception type specified by InterruptType. If InterruptHandler is NULL, then the\r | |
96 | handler for the processor interrupt or exception type specified by InterruptType is uninstalled.\r | |
e41aad15 JF |
97 | The installed handler is called once for each processor interrupt or exception.\r |
98 | NOTE: This function should be invoked after InitializeCpuExceptionHandlers() or\r | |
99 | InitializeCpuInterruptHandlers() invoked, otherwise EFI_UNSUPPORTED returned.\r | |
100 | \r | |
101 | @param[in] InterruptType Defines which interrupt or exception to hook.\r | |
102 | @param[in] InterruptHandler A pointer to a function of type EFI_CPU_INTERRUPT_HANDLER that is called\r | |
103 | when a processor interrupt occurs. If this parameter is NULL, then the handler\r | |
104 | will be uninstalled.\r | |
105 | \r | |
106 | @retval EFI_SUCCESS The handler for the processor interrupt was successfully installed or uninstalled.\r | |
107 | @retval EFI_ALREADY_STARTED InterruptHandler is not NULL, and a handler for InterruptType was\r | |
108 | previously installed.\r | |
109 | @retval EFI_INVALID_PARAMETER InterruptHandler is NULL, and a handler for InterruptType was not\r | |
110 | previously installed.\r | |
111 | @retval EFI_UNSUPPORTED The interrupt specified by InterruptType is not supported,\r | |
112 | or this function is not supported.\r | |
3f25e6ea | 113 | **/\r |
e41aad15 JF |
114 | EFI_STATUS\r |
115 | EFIAPI\r | |
116 | RegisterCpuInterruptHandler (\r | |
117 | IN EFI_EXCEPTION_TYPE InterruptType,\r | |
118 | IN EFI_CPU_INTERRUPT_HANDLER InterruptHandler\r | |
119 | )\r | |
120 | {\r | |
670f13af | 121 | return RegisterCpuInterruptHandlerWorker (InterruptType, InterruptHandler, &mExceptionHandlerData);\r |
0ff5aa9c JW |
122 | }\r |
123 | \r | |
124 | /**\r | |
125 | Initializes all CPU exceptions entries with optional extra initializations.\r | |
126 | \r | |
127 | By default, this method should include all functionalities implemented by\r | |
128 | InitializeCpuExceptionHandlers(), plus extra initialization works, if any.\r | |
129 | This could be done by calling InitializeCpuExceptionHandlers() directly\r | |
130 | in this method besides the extra works.\r | |
131 | \r | |
132 | InitData is optional and its use and content are processor arch dependent.\r | |
133 | The typical usage of it is to convey resources which have to be reserved\r | |
134 | elsewhere and are necessary for the extra initializations of exception.\r | |
135 | \r | |
136 | @param[in] VectorInfo Pointer to reserved vector list.\r | |
137 | @param[in] InitData Pointer to data optional for extra initializations\r | |
138 | of exception.\r | |
139 | \r | |
140 | @retval EFI_SUCCESS The exceptions have been successfully\r | |
141 | initialized.\r | |
142 | @retval EFI_INVALID_PARAMETER VectorInfo or InitData contains invalid\r | |
143 | content.\r | |
144 | \r | |
145 | **/\r | |
146 | EFI_STATUS\r | |
147 | EFIAPI\r | |
148 | InitializeCpuExceptionHandlersEx (\r | |
149 | IN EFI_VECTOR_HANDOFF_INFO *VectorInfo OPTIONAL,\r | |
150 | IN CPU_EXCEPTION_INIT_DATA *InitData OPTIONAL\r | |
151 | )\r | |
152 | {\r | |
153 | return InitializeCpuExceptionHandlers (VectorInfo);\r | |
154 | }\r |