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