]>
Commit | Line | Data |
---|---|---|
3e8ad6bd JF |
1 | /** @file\r |
2 | MP initialize support functions for PEI 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 | |
6dc05093 JF |
16 | #include <Ppi/EndOfPeiPhase.h>\r |
17 | #include <Library/PeiServicesLib.h>\r | |
18 | \r | |
19 | //\r | |
20 | // Global PEI notify function descriptor on EndofPei event\r | |
21 | //\r | |
22 | GLOBAL_REMOVE_IF_UNREFERENCED EFI_PEI_NOTIFY_DESCRIPTOR mMpInitLibNotifyList = {\r | |
23 | (EFI_PEI_PPI_DESCRIPTOR_NOTIFY_CALLBACK | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),\r | |
24 | &gEfiEndOfPeiSignalPpiGuid,\r | |
25 | CpuMpEndOfPeiCallback\r | |
26 | };\r | |
3e8ad6bd | 27 | \r |
43c9fdcc JF |
28 | \r |
29 | /**\r | |
30 | Enable Debug Agent to support source debugging on AP function.\r | |
31 | \r | |
32 | **/\r | |
33 | VOID\r | |
34 | EnableDebugAgent (\r | |
35 | VOID\r | |
36 | )\r | |
37 | {\r | |
38 | }\r | |
39 | \r | |
93ca4c0f JF |
40 | /**\r |
41 | Get pointer to CPU MP Data structure.\r | |
42 | \r | |
43 | @return The pointer to CPU MP Data structure.\r | |
44 | **/\r | |
45 | CPU_MP_DATA *\r | |
46 | GetCpuMpData (\r | |
47 | VOID\r | |
48 | )\r | |
49 | {\r | |
50 | CPU_MP_DATA *CpuMpData;\r | |
51 | \r | |
52 | CpuMpData = GetCpuMpDataFromGuidedHob ();\r | |
53 | ASSERT (CpuMpData != NULL);\r | |
54 | return CpuMpData;\r | |
55 | }\r | |
56 | \r | |
57 | /**\r | |
58 | Save the pointer to CPU MP Data structure.\r | |
59 | \r | |
60 | @param[in] CpuMpData The pointer to CPU MP Data structure will be saved.\r | |
61 | **/\r | |
62 | VOID\r | |
63 | SaveCpuMpData (\r | |
64 | IN CPU_MP_DATA *CpuMpData\r | |
65 | )\r | |
66 | {\r | |
67 | UINT64 Data64;\r | |
68 | //\r | |
69 | // Build location of CPU MP DATA buffer in HOB\r | |
70 | //\r | |
71 | Data64 = (UINT64) (UINTN) CpuMpData;\r | |
72 | BuildGuidDataHob (\r | |
73 | &mCpuInitMpLibHobGuid,\r | |
74 | (VOID *) &Data64,\r | |
75 | sizeof (UINT64)\r | |
76 | );\r | |
77 | }\r | |
78 | \r | |
6dc05093 JF |
79 | /**\r |
80 | Notify function on End Of PEI PPI.\r | |
81 | \r | |
82 | On S3 boot, this function will restore wakeup buffer data.\r | |
83 | On normal boot, this function will flag wakeup buffer to be un-used type.\r | |
84 | \r | |
85 | @param[in] PeiServices The pointer to the PEI Services Table.\r | |
86 | @param[in] NotifyDescriptor Address of the notification descriptor data structure.\r | |
87 | @param[in] Ppi Address of the PPI that was installed.\r | |
88 | \r | |
89 | @retval EFI_SUCCESS When everything is OK.\r | |
90 | **/\r | |
91 | EFI_STATUS\r | |
92 | EFIAPI\r | |
93 | CpuMpEndOfPeiCallback (\r | |
94 | IN EFI_PEI_SERVICES **PeiServices,\r | |
95 | IN EFI_PEI_NOTIFY_DESCRIPTOR *NotifyDescriptor,\r | |
96 | IN VOID *Ppi\r | |
97 | )\r | |
98 | {\r | |
ed66e0e3 JF |
99 | EFI_STATUS Status;\r |
100 | EFI_BOOT_MODE BootMode;\r | |
101 | CPU_MP_DATA *CpuMpData;\r | |
102 | EFI_PEI_HOB_POINTERS Hob;\r | |
103 | EFI_HOB_MEMORY_ALLOCATION *MemoryHob;\r | |
6dc05093 JF |
104 | \r |
105 | DEBUG ((DEBUG_INFO, "PeiMpInitLib: CpuMpEndOfPeiCallback () invoked\n"));\r | |
106 | \r | |
ed66e0e3 JF |
107 | Status = PeiServicesGetBootMode (&BootMode);\r |
108 | ASSERT_EFI_ERROR (Status);\r | |
109 | \r | |
110 | CpuMpData = GetCpuMpData ();\r | |
111 | if (BootMode != BOOT_ON_S3_RESUME) {\r | |
112 | //\r | |
113 | // Get the HOB list for processing\r | |
114 | //\r | |
115 | Hob.Raw = GetHobList ();\r | |
116 | //\r | |
117 | // Collect memory ranges\r | |
118 | //\r | |
119 | while (!END_OF_HOB_LIST (Hob)) {\r | |
120 | if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) {\r | |
121 | MemoryHob = Hob.MemoryAllocation;\r | |
122 | if (MemoryHob->AllocDescriptor.MemoryBaseAddress == CpuMpData->WakeupBuffer) {\r | |
123 | //\r | |
124 | // Flag this HOB type to un-used\r | |
125 | //\r | |
126 | GET_HOB_TYPE (Hob) = EFI_HOB_TYPE_UNUSED;\r | |
127 | break;\r | |
128 | }\r | |
129 | }\r | |
130 | Hob.Raw = GET_NEXT_HOB (Hob);\r | |
131 | }\r | |
132 | } else {\r | |
d11f10d1 | 133 | CpuMpData->SaveRestoreFlag = TRUE;\r |
ed66e0e3 JF |
134 | RestoreWakeupBuffer (CpuMpData);\r |
135 | }\r | |
6dc05093 JF |
136 | return EFI_SUCCESS;\r |
137 | }\r | |
ed66e0e3 JF |
138 | \r |
139 | /**\r | |
140 | Check if AP wakeup buffer is overlapped with existing allocated buffer.\r | |
141 | \r | |
142 | @param[in] WakeupBufferStart AP wakeup buffer start address.\r | |
143 | @param[in] WakeupBufferEnd AP wakeup buffer end address.\r | |
144 | \r | |
145 | @retval TRUE There is overlap.\r | |
146 | @retval FALSE There is no overlap.\r | |
147 | **/\r | |
148 | BOOLEAN\r | |
149 | CheckOverlapWithAllocatedBuffer (\r | |
150 | IN UINTN WakeupBufferStart,\r | |
151 | IN UINTN WakeupBufferEnd\r | |
152 | )\r | |
153 | {\r | |
154 | EFI_PEI_HOB_POINTERS Hob;\r | |
155 | EFI_HOB_MEMORY_ALLOCATION *MemoryHob;\r | |
156 | BOOLEAN Overlapped;\r | |
157 | UINTN MemoryStart;\r | |
158 | UINTN MemoryEnd;\r | |
159 | \r | |
160 | Overlapped = FALSE;\r | |
161 | //\r | |
162 | // Get the HOB list for processing\r | |
163 | //\r | |
164 | Hob.Raw = GetHobList ();\r | |
165 | //\r | |
166 | // Collect memory ranges\r | |
167 | //\r | |
168 | while (!END_OF_HOB_LIST (Hob)) {\r | |
169 | if (Hob.Header->HobType == EFI_HOB_TYPE_MEMORY_ALLOCATION) {\r | |
170 | MemoryHob = Hob.MemoryAllocation;\r | |
171 | MemoryStart = (UINTN) MemoryHob->AllocDescriptor.MemoryBaseAddress;\r | |
172 | MemoryEnd = (UINTN) (MemoryHob->AllocDescriptor.MemoryBaseAddress +\r | |
173 | MemoryHob->AllocDescriptor.MemoryLength);\r | |
174 | if (!((WakeupBufferStart >= MemoryEnd) || (WakeupBufferEnd <= MemoryStart))) {\r | |
175 | Overlapped = TRUE;\r | |
176 | break;\r | |
177 | }\r | |
178 | }\r | |
179 | Hob.Raw = GET_NEXT_HOB (Hob);\r | |
180 | }\r | |
181 | return Overlapped;\r | |
182 | }\r | |
183 | \r | |
184 | /**\r | |
185 | Get available system memory below 1MB by specified size.\r | |
186 | \r | |
187 | @param[in] WakeupBufferSize Wakeup buffer size required\r | |
188 | \r | |
189 | @retval other Return wakeup buffer address below 1MB.\r | |
190 | @retval -1 Cannot find free memory below 1MB.\r | |
191 | **/\r | |
192 | UINTN\r | |
193 | GetWakeupBuffer (\r | |
194 | IN UINTN WakeupBufferSize\r | |
195 | )\r | |
196 | {\r | |
197 | EFI_PEI_HOB_POINTERS Hob;\r | |
198 | UINTN WakeupBufferStart;\r | |
199 | UINTN WakeupBufferEnd;\r | |
200 | \r | |
201 | WakeupBufferSize = (WakeupBufferSize + SIZE_4KB - 1) & ~(SIZE_4KB - 1);\r | |
202 | \r | |
203 | //\r | |
204 | // Get the HOB list for processing\r | |
205 | //\r | |
206 | Hob.Raw = GetHobList ();\r | |
207 | \r | |
208 | //\r | |
209 | // Collect memory ranges\r | |
210 | //\r | |
211 | while (!END_OF_HOB_LIST (Hob)) {\r | |
212 | if (Hob.Header->HobType == EFI_HOB_TYPE_RESOURCE_DESCRIPTOR) {\r | |
213 | if ((Hob.ResourceDescriptor->PhysicalStart < BASE_1MB) &&\r | |
214 | (Hob.ResourceDescriptor->ResourceType == EFI_RESOURCE_SYSTEM_MEMORY) &&\r | |
215 | ((Hob.ResourceDescriptor->ResourceAttribute &\r | |
216 | (EFI_RESOURCE_ATTRIBUTE_READ_PROTECTED |\r | |
217 | EFI_RESOURCE_ATTRIBUTE_WRITE_PROTECTED |\r | |
218 | EFI_RESOURCE_ATTRIBUTE_EXECUTION_PROTECTED\r | |
219 | )) == 0)\r | |
220 | ) {\r | |
221 | //\r | |
222 | // Need memory under 1MB to be collected here\r | |
223 | //\r | |
224 | WakeupBufferEnd = (UINTN) (Hob.ResourceDescriptor->PhysicalStart + Hob.ResourceDescriptor->ResourceLength);\r | |
225 | if (WakeupBufferEnd > BASE_1MB) {\r | |
226 | //\r | |
227 | // Wakeup buffer should be under 1MB\r | |
228 | //\r | |
229 | WakeupBufferEnd = BASE_1MB;\r | |
230 | }\r | |
231 | while (WakeupBufferEnd > WakeupBufferSize) {\r | |
232 | //\r | |
233 | // Wakeup buffer should be aligned on 4KB\r | |
234 | //\r | |
235 | WakeupBufferStart = (WakeupBufferEnd - WakeupBufferSize) & ~(SIZE_4KB - 1);\r | |
236 | if (WakeupBufferStart < Hob.ResourceDescriptor->PhysicalStart) {\r | |
237 | break;\r | |
238 | }\r | |
239 | if (CheckOverlapWithAllocatedBuffer (WakeupBufferStart, WakeupBufferEnd)) {\r | |
240 | //\r | |
241 | // If this range is overlapped with existing allocated buffer, skip it\r | |
242 | // and find the next range\r | |
243 | //\r | |
244 | WakeupBufferEnd -= WakeupBufferSize;\r | |
245 | continue;\r | |
246 | }\r | |
247 | DEBUG ((DEBUG_INFO, "WakeupBufferStart = %x, WakeupBufferSize = %x\n",\r | |
248 | WakeupBufferStart, WakeupBufferSize));\r | |
249 | //\r | |
250 | // Create a memory allocation HOB.\r | |
251 | //\r | |
252 | BuildMemoryAllocationHob (\r | |
253 | WakeupBufferStart,\r | |
254 | WakeupBufferSize,\r | |
255 | EfiBootServicesData\r | |
256 | );\r | |
257 | return WakeupBufferStart;\r | |
258 | }\r | |
259 | }\r | |
260 | }\r | |
261 | //\r | |
262 | // Find the next HOB\r | |
263 | //\r | |
264 | Hob.Raw = GET_NEXT_HOB (Hob);\r | |
265 | }\r | |
266 | \r | |
267 | return (UINTN) -1;\r | |
268 | }\r | |
269 | \r | |
270 | /**\r | |
271 | Allocate reset vector buffer.\r | |
272 | \r | |
273 | @param[in, out] CpuMpData The pointer to CPU MP Data structure.\r | |
274 | **/\r | |
275 | VOID\r | |
276 | AllocateResetVector (\r | |
277 | IN OUT CPU_MP_DATA *CpuMpData\r | |
278 | )\r | |
279 | {\r | |
280 | UINTN ApResetVectorSize;\r | |
281 | \r | |
282 | if (CpuMpData->WakeupBuffer == (UINTN) -1) {\r | |
283 | ApResetVectorSize = CpuMpData->AddressMap.RendezvousFunnelSize +\r | |
284 | sizeof (MP_CPU_EXCHANGE_INFO);\r | |
285 | \r | |
286 | CpuMpData->WakeupBuffer = GetWakeupBuffer (ApResetVectorSize);\r | |
287 | CpuMpData->MpCpuExchangeInfo = (MP_CPU_EXCHANGE_INFO *) (UINTN)\r | |
288 | (CpuMpData->WakeupBuffer + CpuMpData->AddressMap.RendezvousFunnelSize);\r | |
289 | BackupAndPrepareWakeupBuffer (CpuMpData);\r | |
290 | }\r | |
291 | \r | |
d11f10d1 | 292 | if (CpuMpData->SaveRestoreFlag) {\r |
ed66e0e3 JF |
293 | BackupAndPrepareWakeupBuffer (CpuMpData);\r |
294 | }\r | |
295 | }\r | |
296 | \r | |
297 | /**\r | |
298 | Free AP reset vector buffer.\r | |
299 | \r | |
300 | @param[in] CpuMpData The pointer to CPU MP Data structure.\r | |
301 | **/\r | |
302 | VOID\r | |
303 | FreeResetVector (\r | |
304 | IN CPU_MP_DATA *CpuMpData\r | |
305 | )\r | |
306 | {\r | |
d11f10d1 | 307 | if (CpuMpData->SaveRestoreFlag) {\r |
ed66e0e3 JF |
308 | RestoreWakeupBuffer (CpuMpData);\r |
309 | }\r | |
310 | }\r | |
311 | \r | |
08085f08 JF |
312 | /**\r |
313 | Checks APs status and updates APs status if needed.\r | |
314 | \r | |
315 | **/\r | |
316 | VOID\r | |
317 | CheckAndUpdateApsStatus (\r | |
318 | VOID\r | |
319 | )\r | |
320 | {\r | |
321 | }\r | |
322 | \r | |
93ca4c0f JF |
323 | /**\r |
324 | Initialize global data for MP support.\r | |
325 | \r | |
326 | @param[in] CpuMpData The pointer to CPU MP Data structure.\r | |
327 | **/\r | |
328 | VOID\r | |
329 | InitMpGlobalData (\r | |
330 | IN CPU_MP_DATA *CpuMpData\r | |
331 | )\r | |
332 | {\r | |
6dc05093 | 333 | EFI_STATUS Status;\r |
93ca4c0f JF |
334 | \r |
335 | SaveCpuMpData (CpuMpData);\r | |
14e8137c JF |
336 | \r |
337 | if (CpuMpData->CpuCount == 1) {\r | |
338 | //\r | |
339 | // If only BSP exists, return\r | |
340 | //\r | |
341 | return;\r | |
342 | }\r | |
343 | \r | |
6dc05093 JF |
344 | //\r |
345 | // Register an event for EndOfPei\r | |
346 | //\r | |
347 | Status = PeiServicesNotifyPpi (&mMpInitLibNotifyList);\r | |
348 | ASSERT_EFI_ERROR (Status);\r | |
93ca4c0f JF |
349 | }\r |
350 | \r | |
3e8ad6bd JF |
351 | /**\r |
352 | This service executes a caller provided function on all enabled APs.\r | |
353 | \r | |
354 | @param[in] Procedure A pointer to the function to be run on\r | |
355 | enabled APs of the system. See type\r | |
356 | EFI_AP_PROCEDURE.\r | |
357 | @param[in] SingleThread If TRUE, then all the enabled APs execute\r | |
358 | the function specified by Procedure one by\r | |
359 | one, in ascending order of processor handle\r | |
360 | number. If FALSE, then all the enabled APs\r | |
361 | execute the function specified by Procedure\r | |
362 | simultaneously.\r | |
363 | @param[in] WaitEvent The event created by the caller with CreateEvent()\r | |
364 | service. If it is NULL, then execute in\r | |
365 | blocking mode. BSP waits until all APs finish\r | |
366 | or TimeoutInMicroSeconds expires. If it's\r | |
367 | not NULL, then execute in non-blocking mode.\r | |
368 | BSP requests the function specified by\r | |
369 | Procedure to be started on all the enabled\r | |
370 | APs, and go on executing immediately. If\r | |
371 | all return from Procedure, or TimeoutInMicroSeconds\r | |
372 | expires, this event is signaled. The BSP\r | |
373 | can use the CheckEvent() or WaitForEvent()\r | |
374 | services to check the state of event. Type\r | |
375 | EFI_EVENT is defined in CreateEvent() in\r | |
376 | the Unified Extensible Firmware Interface\r | |
377 | Specification.\r | |
367284e7 | 378 | @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for\r |
3e8ad6bd JF |
379 | APs to return from Procedure, either for\r |
380 | blocking or non-blocking mode. Zero means\r | |
381 | infinity. If the timeout expires before\r | |
382 | all APs return from Procedure, then Procedure\r | |
383 | on the failed APs is terminated. All enabled\r | |
384 | APs are available for next function assigned\r | |
385 | by MpInitLibStartupAllAPs() or\r | |
386 | MPInitLibStartupThisAP().\r | |
387 | If the timeout expires in blocking mode,\r | |
388 | BSP returns EFI_TIMEOUT. If the timeout\r | |
389 | expires in non-blocking mode, WaitEvent\r | |
390 | is signaled with SignalEvent().\r | |
391 | @param[in] ProcedureArgument The parameter passed into Procedure for\r | |
392 | all APs.\r | |
393 | @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise,\r | |
394 | if all APs finish successfully, then its\r | |
395 | content is set to NULL. If not all APs\r | |
396 | finish before timeout expires, then its\r | |
397 | content is set to address of the buffer\r | |
398 | holding handle numbers of the failed APs.\r | |
399 | The buffer is allocated by MP Initialization\r | |
400 | library, and it's the caller's responsibility to\r | |
401 | free the buffer with FreePool() service.\r | |
402 | In blocking mode, it is ready for consumption\r | |
403 | when the call returns. In non-blocking mode,\r | |
404 | it is ready when WaitEvent is signaled. The\r | |
405 | list of failed CPU is terminated by\r | |
406 | END_OF_CPU_LIST.\r | |
407 | \r | |
408 | @retval EFI_SUCCESS In blocking mode, all APs have finished before\r | |
409 | the timeout expired.\r | |
410 | @retval EFI_SUCCESS In non-blocking mode, function has been dispatched\r | |
411 | to all enabled APs.\r | |
412 | @retval EFI_UNSUPPORTED A non-blocking mode request was made after the\r | |
413 | UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was\r | |
414 | signaled.\r | |
415 | @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not\r | |
416 | supported.\r | |
417 | @retval EFI_DEVICE_ERROR Caller processor is AP.\r | |
418 | @retval EFI_NOT_STARTED No enabled APs exist in the system.\r | |
419 | @retval EFI_NOT_READY Any enabled APs are busy.\r | |
420 | @retval EFI_NOT_READY MP Initialize Library is not initialized.\r | |
421 | @retval EFI_TIMEOUT In blocking mode, the timeout expired before\r | |
422 | all enabled APs have finished.\r | |
423 | @retval EFI_INVALID_PARAMETER Procedure is NULL.\r | |
424 | \r | |
425 | **/\r | |
426 | EFI_STATUS\r | |
427 | EFIAPI\r | |
428 | MpInitLibStartupAllAPs (\r | |
429 | IN EFI_AP_PROCEDURE Procedure,\r | |
430 | IN BOOLEAN SingleThread,\r | |
431 | IN EFI_EVENT WaitEvent OPTIONAL,\r | |
432 | IN UINTN TimeoutInMicroseconds,\r | |
433 | IN VOID *ProcedureArgument OPTIONAL,\r | |
434 | OUT UINTN **FailedCpuList OPTIONAL\r | |
435 | )\r | |
436 | {\r | |
86efe976 JF |
437 | if (WaitEvent != NULL) {\r |
438 | return EFI_UNSUPPORTED;\r | |
439 | }\r | |
440 | \r | |
441 | return StartupAllAPsWorker (\r | |
442 | Procedure,\r | |
443 | SingleThread,\r | |
444 | NULL,\r | |
445 | TimeoutInMicroseconds,\r | |
446 | ProcedureArgument,\r | |
447 | FailedCpuList\r | |
448 | );\r | |
3e8ad6bd JF |
449 | }\r |
450 | \r | |
451 | /**\r | |
452 | This service lets the caller get one enabled AP to execute a caller-provided\r | |
453 | function.\r | |
454 | \r | |
455 | @param[in] Procedure A pointer to the function to be run on the\r | |
456 | designated AP of the system. See type\r | |
457 | EFI_AP_PROCEDURE.\r | |
458 | @param[in] ProcessorNumber The handle number of the AP. The range is\r | |
459 | from 0 to the total number of logical\r | |
460 | processors minus 1. The total number of\r | |
461 | logical processors can be retrieved by\r | |
462 | MpInitLibGetNumberOfProcessors().\r | |
463 | @param[in] WaitEvent The event created by the caller with CreateEvent()\r | |
464 | service. If it is NULL, then execute in\r | |
465 | blocking mode. BSP waits until this AP finish\r | |
466 | or TimeoutInMicroSeconds expires. If it's\r | |
467 | not NULL, then execute in non-blocking mode.\r | |
468 | BSP requests the function specified by\r | |
469 | Procedure to be started on this AP,\r | |
470 | and go on executing immediately. If this AP\r | |
471 | return from Procedure or TimeoutInMicroSeconds\r | |
472 | expires, this event is signaled. The BSP\r | |
473 | can use the CheckEvent() or WaitForEvent()\r | |
474 | services to check the state of event. Type\r | |
475 | EFI_EVENT is defined in CreateEvent() in\r | |
476 | the Unified Extensible Firmware Interface\r | |
477 | Specification.\r | |
367284e7 | 478 | @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for\r |
3e8ad6bd JF |
479 | this AP to finish this Procedure, either for\r |
480 | blocking or non-blocking mode. Zero means\r | |
481 | infinity. If the timeout expires before\r | |
482 | this AP returns from Procedure, then Procedure\r | |
483 | on the AP is terminated. The\r | |
484 | AP is available for next function assigned\r | |
485 | by MpInitLibStartupAllAPs() or\r | |
486 | MpInitLibStartupThisAP().\r | |
487 | If the timeout expires in blocking mode,\r | |
488 | BSP returns EFI_TIMEOUT. If the timeout\r | |
489 | expires in non-blocking mode, WaitEvent\r | |
490 | is signaled with SignalEvent().\r | |
491 | @param[in] ProcedureArgument The parameter passed into Procedure on the\r | |
492 | specified AP.\r | |
493 | @param[out] Finished If NULL, this parameter is ignored. In\r | |
494 | blocking mode, this parameter is ignored.\r | |
495 | In non-blocking mode, if AP returns from\r | |
496 | Procedure before the timeout expires, its\r | |
497 | content is set to TRUE. Otherwise, the\r | |
498 | value is set to FALSE. The caller can\r | |
499 | determine if the AP returned from Procedure\r | |
500 | by evaluating this value.\r | |
501 | \r | |
502 | @retval EFI_SUCCESS In blocking mode, specified AP finished before\r | |
503 | the timeout expires.\r | |
504 | @retval EFI_SUCCESS In non-blocking mode, the function has been\r | |
505 | dispatched to specified AP.\r | |
506 | @retval EFI_UNSUPPORTED A non-blocking mode request was made after the\r | |
507 | UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was\r | |
508 | signaled.\r | |
509 | @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not\r | |
510 | supported.\r | |
511 | @retval EFI_DEVICE_ERROR The calling processor is an AP.\r | |
512 | @retval EFI_TIMEOUT In blocking mode, the timeout expired before\r | |
513 | the specified AP has finished.\r | |
514 | @retval EFI_NOT_READY The specified AP is busy.\r | |
515 | @retval EFI_NOT_READY MP Initialize Library is not initialized.\r | |
516 | @retval EFI_NOT_FOUND The processor with the handle specified by\r | |
517 | ProcessorNumber does not exist.\r | |
518 | @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.\r | |
519 | @retval EFI_INVALID_PARAMETER Procedure is NULL.\r | |
520 | \r | |
521 | **/\r | |
522 | EFI_STATUS\r | |
523 | EFIAPI\r | |
524 | MpInitLibStartupThisAP (\r | |
525 | IN EFI_AP_PROCEDURE Procedure,\r | |
526 | IN UINTN ProcessorNumber,\r | |
527 | IN EFI_EVENT WaitEvent OPTIONAL,\r | |
528 | IN UINTN TimeoutInMicroseconds,\r | |
529 | IN VOID *ProcedureArgument OPTIONAL,\r | |
530 | OUT BOOLEAN *Finished OPTIONAL\r | |
531 | )\r | |
532 | {\r | |
20ae5774 JF |
533 | if (WaitEvent != NULL) {\r |
534 | return EFI_UNSUPPORTED;\r | |
535 | }\r | |
536 | \r | |
537 | return StartupThisAPWorker (\r | |
538 | Procedure,\r | |
539 | ProcessorNumber,\r | |
540 | NULL,\r | |
541 | TimeoutInMicroseconds,\r | |
542 | ProcedureArgument,\r | |
543 | Finished\r | |
544 | );\r | |
3e8ad6bd JF |
545 | }\r |
546 | \r | |
547 | /**\r | |
548 | This service switches the requested AP to be the BSP from that point onward.\r | |
549 | This service changes the BSP for all purposes. This call can only be performed\r | |
550 | by the current BSP.\r | |
551 | \r | |
552 | @param[in] ProcessorNumber The handle number of AP that is to become the new\r | |
553 | BSP. The range is from 0 to the total number of\r | |
554 | logical processors minus 1. The total number of\r | |
555 | logical processors can be retrieved by\r | |
556 | MpInitLibGetNumberOfProcessors().\r | |
557 | @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an\r | |
558 | enabled AP. Otherwise, it will be disabled.\r | |
559 | \r | |
560 | @retval EFI_SUCCESS BSP successfully switched.\r | |
561 | @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to\r | |
562 | this service returning.\r | |
563 | @retval EFI_UNSUPPORTED Switching the BSP is not supported.\r | |
564 | @retval EFI_DEVICE_ERROR The calling processor is an AP.\r | |
565 | @retval EFI_NOT_FOUND The processor with the handle specified by\r | |
566 | ProcessorNumber does not exist.\r | |
567 | @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or\r | |
568 | a disabled AP.\r | |
569 | @retval EFI_NOT_READY The specified AP is busy.\r | |
570 | @retval EFI_NOT_READY MP Initialize Library is not initialized.\r | |
571 | \r | |
572 | **/\r | |
573 | EFI_STATUS\r | |
574 | EFIAPI\r | |
575 | MpInitLibSwitchBSP (\r | |
576 | IN UINTN ProcessorNumber,\r | |
577 | IN BOOLEAN EnableOldBSP\r | |
578 | )\r | |
579 | {\r | |
41be0da5 | 580 | return SwitchBSPWorker (ProcessorNumber, EnableOldBSP);\r |
3e8ad6bd JF |
581 | }\r |
582 | \r | |
583 | /**\r | |
584 | This service lets the caller enable or disable an AP from this point onward.\r | |
585 | This service may only be called from the BSP.\r | |
586 | \r | |
587 | @param[in] ProcessorNumber The handle number of AP.\r | |
588 | The range is from 0 to the total number of\r | |
589 | logical processors minus 1. The total number of\r | |
590 | logical processors can be retrieved by\r | |
591 | MpInitLibGetNumberOfProcessors().\r | |
592 | @param[in] EnableAP Specifies the new state for the processor for\r | |
593 | enabled, FALSE for disabled.\r | |
594 | @param[in] HealthFlag If not NULL, a pointer to a value that specifies\r | |
595 | the new health status of the AP. This flag\r | |
596 | corresponds to StatusFlag defined in\r | |
597 | EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only\r | |
598 | the PROCESSOR_HEALTH_STATUS_BIT is used. All other\r | |
599 | bits are ignored. If it is NULL, this parameter\r | |
600 | is ignored.\r | |
601 | \r | |
602 | @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.\r | |
603 | @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed\r | |
604 | prior to this service returning.\r | |
605 | @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.\r | |
606 | @retval EFI_DEVICE_ERROR The calling processor is an AP.\r | |
607 | @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber\r | |
608 | does not exist.\r | |
609 | @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.\r | |
610 | @retval EFI_NOT_READY MP Initialize Library is not initialized.\r | |
611 | \r | |
612 | **/\r | |
613 | EFI_STATUS\r | |
614 | EFIAPI\r | |
615 | MpInitLibEnableDisableAP (\r | |
616 | IN UINTN ProcessorNumber,\r | |
617 | IN BOOLEAN EnableAP,\r | |
618 | IN UINT32 *HealthFlag OPTIONAL\r | |
619 | )\r | |
620 | {\r | |
e37109bc | 621 | return EnableDisableApWorker (ProcessorNumber, EnableAP, HealthFlag);\r |
3e8ad6bd JF |
622 | }\r |
623 | \r | |
624 | \r |