]>
Commit | Line | Data |
---|---|---|
3e8ad6bd JF |
1 | /** @file\r |
2 | MP initialize support functions for DXE phase.\r | |
3 | \r | |
4 | Copyright (c) 2016, 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 "MpLib.h"\r | |
93ca4c0f JF |
16 | CPU_MP_DATA *mCpuMpData = NULL;\r |
17 | \r | |
18 | /**\r | |
19 | Get the pointer to CPU MP Data structure.\r | |
20 | \r | |
21 | @return The pointer to CPU MP Data structure.\r | |
22 | **/\r | |
23 | CPU_MP_DATA *\r | |
24 | GetCpuMpData (\r | |
25 | VOID\r | |
26 | )\r | |
27 | {\r | |
28 | ASSERT (mCpuMpData != NULL);\r | |
29 | return mCpuMpData;\r | |
30 | }\r | |
31 | \r | |
32 | /**\r | |
33 | Save the pointer to CPU MP Data structure.\r | |
34 | \r | |
35 | @param[in] CpuMpData The pointer to CPU MP Data structure will be saved.\r | |
36 | **/\r | |
37 | VOID\r | |
38 | SaveCpuMpData (\r | |
39 | IN CPU_MP_DATA *CpuMpData\r | |
40 | )\r | |
41 | {\r | |
42 | mCpuMpData = CpuMpData;\r | |
43 | }\r | |
44 | \r | |
45 | /**\r | |
46 | Initialize global data for MP support.\r | |
47 | \r | |
48 | @param[in] CpuMpData The pointer to CPU MP Data structure.\r | |
49 | **/\r | |
50 | VOID\r | |
51 | InitMpGlobalData (\r | |
52 | IN CPU_MP_DATA *CpuMpData\r | |
53 | )\r | |
54 | {\r | |
55 | SaveCpuMpData (CpuMpData);\r | |
56 | \r | |
57 | }\r | |
3e8ad6bd JF |
58 | \r |
59 | /**\r | |
60 | This service executes a caller provided function on all enabled APs.\r | |
61 | \r | |
62 | @param[in] Procedure A pointer to the function to be run on\r | |
63 | enabled APs of the system. See type\r | |
64 | EFI_AP_PROCEDURE.\r | |
65 | @param[in] SingleThread If TRUE, then all the enabled APs execute\r | |
66 | the function specified by Procedure one by\r | |
67 | one, in ascending order of processor handle\r | |
68 | number. If FALSE, then all the enabled APs\r | |
69 | execute the function specified by Procedure\r | |
70 | simultaneously.\r | |
71 | @param[in] WaitEvent The event created by the caller with CreateEvent()\r | |
72 | service. If it is NULL, then execute in\r | |
73 | blocking mode. BSP waits until all APs finish\r | |
74 | or TimeoutInMicroSeconds expires. If it's\r | |
75 | not NULL, then execute in non-blocking mode.\r | |
76 | BSP requests the function specified by\r | |
77 | Procedure to be started on all the enabled\r | |
78 | APs, and go on executing immediately. If\r | |
79 | all return from Procedure, or TimeoutInMicroSeconds\r | |
80 | expires, this event is signaled. The BSP\r | |
81 | can use the CheckEvent() or WaitForEvent()\r | |
82 | services to check the state of event. Type\r | |
83 | EFI_EVENT is defined in CreateEvent() in\r | |
84 | the Unified Extensible Firmware Interface\r | |
85 | Specification.\r | |
86 | @param[in] TimeoutInMicrosecsond Indicates the time limit in microseconds for\r | |
87 | APs to return from Procedure, either for\r | |
88 | blocking or non-blocking mode. Zero means\r | |
89 | infinity. If the timeout expires before\r | |
90 | all APs return from Procedure, then Procedure\r | |
91 | on the failed APs is terminated. All enabled\r | |
92 | APs are available for next function assigned\r | |
93 | by MpInitLibStartupAllAPs() or\r | |
94 | MPInitLibStartupThisAP().\r | |
95 | If the timeout expires in blocking mode,\r | |
96 | BSP returns EFI_TIMEOUT. If the timeout\r | |
97 | expires in non-blocking mode, WaitEvent\r | |
98 | is signaled with SignalEvent().\r | |
99 | @param[in] ProcedureArgument The parameter passed into Procedure for\r | |
100 | all APs.\r | |
101 | @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise,\r | |
102 | if all APs finish successfully, then its\r | |
103 | content is set to NULL. If not all APs\r | |
104 | finish before timeout expires, then its\r | |
105 | content is set to address of the buffer\r | |
106 | holding handle numbers of the failed APs.\r | |
107 | The buffer is allocated by MP Initialization\r | |
108 | library, and it's the caller's responsibility to\r | |
109 | free the buffer with FreePool() service.\r | |
110 | In blocking mode, it is ready for consumption\r | |
111 | when the call returns. In non-blocking mode,\r | |
112 | it is ready when WaitEvent is signaled. The\r | |
113 | list of failed CPU is terminated by\r | |
114 | END_OF_CPU_LIST.\r | |
115 | \r | |
116 | @retval EFI_SUCCESS In blocking mode, all APs have finished before\r | |
117 | the timeout expired.\r | |
118 | @retval EFI_SUCCESS In non-blocking mode, function has been dispatched\r | |
119 | to all enabled APs.\r | |
120 | @retval EFI_UNSUPPORTED A non-blocking mode request was made after the\r | |
121 | UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was\r | |
122 | signaled.\r | |
123 | @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not\r | |
124 | supported.\r | |
125 | @retval EFI_DEVICE_ERROR Caller processor is AP.\r | |
126 | @retval EFI_NOT_STARTED No enabled APs exist in the system.\r | |
127 | @retval EFI_NOT_READY Any enabled APs are busy.\r | |
128 | @retval EFI_NOT_READY MP Initialize Library is not initialized.\r | |
129 | @retval EFI_TIMEOUT In blocking mode, the timeout expired before\r | |
130 | all enabled APs have finished.\r | |
131 | @retval EFI_INVALID_PARAMETER Procedure is NULL.\r | |
132 | \r | |
133 | **/\r | |
134 | EFI_STATUS\r | |
135 | EFIAPI\r | |
136 | MpInitLibStartupAllAPs (\r | |
137 | IN EFI_AP_PROCEDURE Procedure,\r | |
138 | IN BOOLEAN SingleThread,\r | |
139 | IN EFI_EVENT WaitEvent OPTIONAL,\r | |
140 | IN UINTN TimeoutInMicroseconds,\r | |
141 | IN VOID *ProcedureArgument OPTIONAL,\r | |
142 | OUT UINTN **FailedCpuList OPTIONAL\r | |
143 | )\r | |
144 | {\r | |
145 | return EFI_UNSUPPORTED;\r | |
146 | }\r | |
147 | \r | |
148 | /**\r | |
149 | This service lets the caller get one enabled AP to execute a caller-provided\r | |
150 | function.\r | |
151 | \r | |
152 | @param[in] Procedure A pointer to the function to be run on the\r | |
153 | designated AP of the system. See type\r | |
154 | EFI_AP_PROCEDURE.\r | |
155 | @param[in] ProcessorNumber The handle number of the AP. The range is\r | |
156 | from 0 to the total number of logical\r | |
157 | processors minus 1. The total number of\r | |
158 | logical processors can be retrieved by\r | |
159 | MpInitLibGetNumberOfProcessors().\r | |
160 | @param[in] WaitEvent The event created by the caller with CreateEvent()\r | |
161 | service. If it is NULL, then execute in\r | |
162 | blocking mode. BSP waits until this AP finish\r | |
163 | or TimeoutInMicroSeconds expires. If it's\r | |
164 | not NULL, then execute in non-blocking mode.\r | |
165 | BSP requests the function specified by\r | |
166 | Procedure to be started on this AP,\r | |
167 | and go on executing immediately. If this AP\r | |
168 | return from Procedure or TimeoutInMicroSeconds\r | |
169 | expires, this event is signaled. The BSP\r | |
170 | can use the CheckEvent() or WaitForEvent()\r | |
171 | services to check the state of event. Type\r | |
172 | EFI_EVENT is defined in CreateEvent() in\r | |
173 | the Unified Extensible Firmware Interface\r | |
174 | Specification.\r | |
175 | @param[in] TimeoutInMicrosecsond Indicates the time limit in microseconds for\r | |
176 | this AP to finish this Procedure, either for\r | |
177 | blocking or non-blocking mode. Zero means\r | |
178 | infinity. If the timeout expires before\r | |
179 | this AP returns from Procedure, then Procedure\r | |
180 | on the AP is terminated. The\r | |
181 | AP is available for next function assigned\r | |
182 | by MpInitLibStartupAllAPs() or\r | |
183 | MpInitLibStartupThisAP().\r | |
184 | If the timeout expires in blocking mode,\r | |
185 | BSP returns EFI_TIMEOUT. If the timeout\r | |
186 | expires in non-blocking mode, WaitEvent\r | |
187 | is signaled with SignalEvent().\r | |
188 | @param[in] ProcedureArgument The parameter passed into Procedure on the\r | |
189 | specified AP.\r | |
190 | @param[out] Finished If NULL, this parameter is ignored. In\r | |
191 | blocking mode, this parameter is ignored.\r | |
192 | In non-blocking mode, if AP returns from\r | |
193 | Procedure before the timeout expires, its\r | |
194 | content is set to TRUE. Otherwise, the\r | |
195 | value is set to FALSE. The caller can\r | |
196 | determine if the AP returned from Procedure\r | |
197 | by evaluating this value.\r | |
198 | \r | |
199 | @retval EFI_SUCCESS In blocking mode, specified AP finished before\r | |
200 | the timeout expires.\r | |
201 | @retval EFI_SUCCESS In non-blocking mode, the function has been\r | |
202 | dispatched to specified AP.\r | |
203 | @retval EFI_UNSUPPORTED A non-blocking mode request was made after the\r | |
204 | UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was\r | |
205 | signaled.\r | |
206 | @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not\r | |
207 | supported.\r | |
208 | @retval EFI_DEVICE_ERROR The calling processor is an AP.\r | |
209 | @retval EFI_TIMEOUT In blocking mode, the timeout expired before\r | |
210 | the specified AP has finished.\r | |
211 | @retval EFI_NOT_READY The specified AP is busy.\r | |
212 | @retval EFI_NOT_READY MP Initialize Library is not initialized.\r | |
213 | @retval EFI_NOT_FOUND The processor with the handle specified by\r | |
214 | ProcessorNumber does not exist.\r | |
215 | @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.\r | |
216 | @retval EFI_INVALID_PARAMETER Procedure is NULL.\r | |
217 | \r | |
218 | **/\r | |
219 | EFI_STATUS\r | |
220 | EFIAPI\r | |
221 | MpInitLibStartupThisAP (\r | |
222 | IN EFI_AP_PROCEDURE Procedure,\r | |
223 | IN UINTN ProcessorNumber,\r | |
224 | IN EFI_EVENT WaitEvent OPTIONAL,\r | |
225 | IN UINTN TimeoutInMicroseconds,\r | |
226 | IN VOID *ProcedureArgument OPTIONAL,\r | |
227 | OUT BOOLEAN *Finished OPTIONAL\r | |
228 | )\r | |
229 | {\r | |
230 | return EFI_UNSUPPORTED;\r | |
231 | }\r | |
232 | \r | |
233 | /**\r | |
234 | This service switches the requested AP to be the BSP from that point onward.\r | |
235 | This service changes the BSP for all purposes. This call can only be performed\r | |
236 | by the current BSP.\r | |
237 | \r | |
238 | @param[in] ProcessorNumber The handle number of AP that is to become the new\r | |
239 | BSP. The range is from 0 to the total number of\r | |
240 | logical processors minus 1. The total number of\r | |
241 | logical processors can be retrieved by\r | |
242 | MpInitLibGetNumberOfProcessors().\r | |
243 | @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an\r | |
244 | enabled AP. Otherwise, it will be disabled.\r | |
245 | \r | |
246 | @retval EFI_SUCCESS BSP successfully switched.\r | |
247 | @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to\r | |
248 | this service returning.\r | |
249 | @retval EFI_UNSUPPORTED Switching the BSP is not supported.\r | |
250 | @retval EFI_DEVICE_ERROR The calling processor is an AP.\r | |
251 | @retval EFI_NOT_FOUND The processor with the handle specified by\r | |
252 | ProcessorNumber does not exist.\r | |
253 | @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or\r | |
254 | a disabled AP.\r | |
255 | @retval EFI_NOT_READY The specified AP is busy.\r | |
256 | @retval EFI_NOT_READY MP Initialize Library is not initialized.\r | |
257 | \r | |
258 | **/\r | |
259 | EFI_STATUS\r | |
260 | EFIAPI\r | |
261 | MpInitLibSwitchBSP (\r | |
262 | IN UINTN ProcessorNumber,\r | |
263 | IN BOOLEAN EnableOldBSP\r | |
264 | )\r | |
265 | {\r | |
266 | return EFI_UNSUPPORTED;\r | |
267 | }\r | |
268 | \r | |
269 | /**\r | |
270 | This service lets the caller enable or disable an AP from this point onward.\r | |
271 | This service may only be called from the BSP.\r | |
272 | \r | |
273 | @param[in] ProcessorNumber The handle number of AP.\r | |
274 | The range is from 0 to the total number of\r | |
275 | logical processors minus 1. The total number of\r | |
276 | logical processors can be retrieved by\r | |
277 | MpInitLibGetNumberOfProcessors().\r | |
278 | @param[in] EnableAP Specifies the new state for the processor for\r | |
279 | enabled, FALSE for disabled.\r | |
280 | @param[in] HealthFlag If not NULL, a pointer to a value that specifies\r | |
281 | the new health status of the AP. This flag\r | |
282 | corresponds to StatusFlag defined in\r | |
283 | EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only\r | |
284 | the PROCESSOR_HEALTH_STATUS_BIT is used. All other\r | |
285 | bits are ignored. If it is NULL, this parameter\r | |
286 | is ignored.\r | |
287 | \r | |
288 | @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.\r | |
289 | @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed\r | |
290 | prior to this service returning.\r | |
291 | @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.\r | |
292 | @retval EFI_DEVICE_ERROR The calling processor is an AP.\r | |
293 | @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber\r | |
294 | does not exist.\r | |
295 | @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.\r | |
296 | @retval EFI_NOT_READY MP Initialize Library is not initialized.\r | |
297 | \r | |
298 | **/\r | |
299 | EFI_STATUS\r | |
300 | EFIAPI\r | |
301 | MpInitLibEnableDisableAP (\r | |
302 | IN UINTN ProcessorNumber,\r | |
303 | IN BOOLEAN EnableAP,\r | |
304 | IN UINT32 *HealthFlag OPTIONAL\r | |
305 | )\r | |
306 | {\r | |
307 | return EFI_UNSUPPORTED;\r | |
308 | }\r |