]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/CpuDxe/CpuMp.h
UefiCpuPkg/MpService: Put APs to sleep when not busy.
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / CpuMp.h
CommitLineData
6022e28c
JJ
1/** @file\r
2 CPU DXE MP support\r
3\r
4 Copyright (c) 2006 - 2014, 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#ifndef _CPU_MP_H_\r
16#define _CPU_MP_H_\r
17\r
003973d9 18#include <Protocol/MpService.h>\r
03673ae1 19#include <Library/SynchronizationLib.h>\r
003973d9 20\r
6022e28c
JJ
21/**\r
22 Initialize Multi-processor support.\r
23\r
24**/\r
25VOID\r
26InitializeMpSupport (\r
27 VOID\r
28 );\r
29\r
533263ee
JJ
30typedef\r
31VOID\r
32(EFIAPI *STACKLESS_AP_ENTRY_POINT)(\r
33 VOID\r
34 );\r
35\r
36/**\r
37 Starts the Application Processors and directs them to jump to the\r
38 specified routine.\r
39\r
40 The processor jumps to this code in flat mode, but the processor's\r
41 stack is not initialized.\r
42\r
533263ee 43 @retval EFI_SUCCESS The APs were started\r
533263ee
JJ
44\r
45**/\r
46EFI_STATUS\r
47StartApsStackless (\r
fe078dd5 48 VOID\r
533263ee
JJ
49 );\r
50\r
fab82c18
JJ
51/**\r
52 The AP entry point that the Startup-IPI target code will jump to.\r
53\r
54 The processor jumps to this code in flat mode, but the processor's\r
55 stack is not initialized.\r
56\r
57**/\r
58VOID\r
59EFIAPI\r
60AsmApEntryPoint (\r
61 VOID\r
62 );\r
63\r
64/**\r
65 Releases the lock preventing other APs from using the shared AP\r
66 stack.\r
67\r
68 Once the AP has transitioned to using a new stack, it can call this\r
69 function to allow another AP to proceed with using the shared stack.\r
70\r
71**/\r
72VOID\r
73EFIAPI\r
74AsmApDoneWithCommonStack (\r
75 VOID\r
76 );\r
77\r
03673ae1
CF
78typedef enum {\r
79 CpuStateIdle,\r
80 CpuStateBlocked,\r
81 CpuStateReady,\r
b302a978 82 CpuStateBusy,\r
68f06742
CF
83 CpuStateFinished,\r
84 CpuStateSleeping\r
03673ae1
CF
85} CPU_STATE;\r
86\r
87/**\r
88 Define Individual Processor Data block.\r
89\r
90**/\r
91typedef struct {\r
92 EFI_PROCESSOR_INFORMATION Info;\r
93 SPIN_LOCK CpuDataLock;\r
0e724fc1 94 INTN LockSelf;\r
03673ae1
CF
95 volatile CPU_STATE State;\r
96\r
97 EFI_AP_PROCEDURE Procedure;\r
98 VOID *Parameter;\r
3f4f0af8
CF
99 BOOLEAN *Finished;\r
100 INTN Timeout;\r
101 EFI_EVENT WaitEvent;\r
102 BOOLEAN TimeoutActive;\r
103 EFI_EVENT CheckThisAPEvent;\r
ac9dbb3b 104 VOID *TopOfStack;\r
03673ae1
CF
105} CPU_DATA_BLOCK;\r
106\r
107/**\r
108 Define MP data block which consumes individual processor block.\r
109\r
110**/\r
111typedef struct {\r
112 CPU_DATA_BLOCK *CpuDatas;\r
113 UINTN NumberOfProcessors;\r
114 UINTN NumberOfEnabledProcessors;\r
5fee172f
CF
115\r
116 EFI_AP_PROCEDURE Procedure;\r
117 VOID *ProcedureArgument;\r
118 UINTN StartCount;\r
119 UINTN FinishCount;\r
120 BOOLEAN SingleThread;\r
121 UINTN **FailedList;\r
122 UINTN FailedListIndex;\r
123 INTN Timeout;\r
124 EFI_EVENT WaitEvent;\r
125 BOOLEAN TimeoutActive;\r
126 EFI_EVENT CheckAllAPsEvent;\r
03673ae1
CF
127} MP_SYSTEM_DATA;\r
128\r
129/**\r
130 This function is called by all processors (both BSP and AP) once and collects MP related data.\r
131\r
132 @param Bsp TRUE if the CPU is BSP\r
133 @param ProcessorNumber The specific processor number\r
134\r
135 @retval EFI_SUCCESS Data for the processor collected and filled in\r
136\r
137**/\r
138EFI_STATUS\r
139FillInProcessorInformation (\r
140 IN BOOLEAN Bsp,\r
141 IN UINTN ProcessorNumber\r
142 );\r
143\r
d894d8b7
CF
144/**\r
145 This service retrieves the number of logical processor in the platform\r
146 and the number of those logical processors that are enabled on this boot.\r
147 This service may only be called from the BSP.\r
148\r
149 This function is used to retrieve the following information:\r
150 - The number of logical processors that are present in the system.\r
151 - The number of enabled logical processors in the system at the instant\r
152 this call is made.\r
153\r
154 Because MP Service Protocol provides services to enable and disable processors\r
155 dynamically, the number of enabled logical processors may vary during the\r
156 course of a boot session.\r
157\r
158 If this service is called from an AP, then EFI_DEVICE_ERROR is returned.\r
159 If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then\r
160 EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors\r
161 is returned in NumberOfProcessors, the number of currently enabled processor\r
162 is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.\r
163\r
164 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL\r
165 instance.\r
166 @param[out] NumberOfProcessors Pointer to the total number of logical\r
167 processors in the system, including the BSP\r
168 and disabled APs.\r
169 @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical\r
170 processors that exist in system, including\r
171 the BSP.\r
172\r
173 @retval EFI_SUCCESS The number of logical processors and enabled\r
174 logical processors was retrieved.\r
175 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
176 @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.\r
177 @retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL.\r
178\r
179**/\r
180EFI_STATUS\r
181EFIAPI\r
182GetNumberOfProcessors (\r
183 IN EFI_MP_SERVICES_PROTOCOL *This,\r
184 OUT UINTN *NumberOfProcessors,\r
185 OUT UINTN *NumberOfEnabledProcessors\r
186 );\r
187\r
e7938b5a
CF
188/**\r
189 Gets detailed MP-related information on the requested processor at the\r
190 instant this call is made. This service may only be called from the BSP.\r
191\r
192 This service retrieves detailed MP-related information about any processor\r
193 on the platform. Note the following:\r
194 - The processor information may change during the course of a boot session.\r
195 - The information presented here is entirely MP related.\r
196\r
197 Information regarding the number of caches and their sizes, frequency of operation,\r
198 slot numbers is all considered platform-related information and is not provided\r
199 by this service.\r
200\r
201 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL\r
202 instance.\r
203 @param[in] ProcessorNumber The handle number of processor.\r
204 @param[out] ProcessorInfoBuffer A pointer to the buffer where information for\r
205 the requested processor is deposited.\r
206\r
207 @retval EFI_SUCCESS Processor information was returned.\r
208 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
209 @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.\r
210 @retval EFI_NOT_FOUND The processor with the handle specified by\r
211 ProcessorNumber does not exist in the platform.\r
212\r
213**/\r
214EFI_STATUS\r
215EFIAPI\r
216GetProcessorInfo (\r
217 IN EFI_MP_SERVICES_PROTOCOL *This,\r
218 IN UINTN ProcessorNumber,\r
219 OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer\r
220 );\r
221\r
5fee172f
CF
222/**\r
223 This service executes a caller provided function on all enabled APs. APs can\r
224 run either simultaneously or one at a time in sequence. This service supports\r
225 both blocking and non-blocking requests. The non-blocking requests use EFI\r
226 events so the BSP can detect when the APs have finished. This service may only\r
227 be called from the BSP.\r
228\r
229 This function is used to dispatch all the enabled APs to the function specified\r
230 by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned\r
231 immediately and Procedure is not started on any AP.\r
232\r
233 If SingleThread is TRUE, all the enabled APs execute the function specified by\r
234 Procedure one by one, in ascending order of processor handle number. Otherwise,\r
235 all the enabled APs execute the function specified by Procedure simultaneously.\r
236\r
237 If WaitEvent is NULL, execution is in blocking mode. The BSP waits until all\r
238 APs finish or TimeoutInMicroseconds expires. Otherwise, execution is in non-blocking\r
239 mode, and the BSP returns from this service without waiting for APs. If a\r
240 non-blocking mode is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT\r
241 is signaled, then EFI_UNSUPPORTED must be returned.\r
242\r
243 If the timeout specified by TimeoutInMicroseconds expires before all APs return\r
244 from Procedure, then Procedure on the failed APs is terminated. All enabled APs\r
245 are always available for further calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()\r
246 and EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). If FailedCpuList is not NULL, its\r
247 content points to the list of processor handle numbers in which Procedure was\r
248 terminated.\r
249\r
250 Note: It is the responsibility of the consumer of the EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()\r
251 to make sure that the nature of the code that is executed on the BSP and the\r
252 dispatched APs is well controlled. The MP Services Protocol does not guarantee\r
253 that the Procedure function is MP-safe. Hence, the tasks that can be run in\r
254 parallel are limited to certain independent tasks and well-controlled exclusive\r
255 code. EFI services and protocols may not be called by APs unless otherwise\r
256 specified.\r
257\r
258 In blocking execution mode, BSP waits until all APs finish or\r
259 TimeoutInMicroseconds expires.\r
260\r
261 In non-blocking execution mode, BSP is freed to return to the caller and then\r
262 proceed to the next task without having to wait for APs. The following\r
263 sequence needs to occur in a non-blocking execution mode:\r
264\r
265 -# The caller that intends to use this MP Services Protocol in non-blocking\r
266 mode creates WaitEvent by calling the EFI CreateEvent() service. The caller\r
267 invokes EFI_MP_SERVICES_PROTOCOL.StartupAllAPs(). If the parameter WaitEvent\r
268 is not NULL, then StartupAllAPs() executes in non-blocking mode. It requests\r
269 the function specified by Procedure to be started on all the enabled APs,\r
270 and releases the BSP to continue with other tasks.\r
271 -# The caller can use the CheckEvent() and WaitForEvent() services to check\r
272 the state of the WaitEvent created in step 1.\r
273 -# When the APs complete their task or TimeoutInMicroSecondss expires, the MP\r
274 Service signals WaitEvent by calling the EFI SignalEvent() function. If\r
275 FailedCpuList is not NULL, its content is available when WaitEvent is\r
276 signaled. If all APs returned from Procedure prior to the timeout, then\r
277 FailedCpuList is set to NULL. If not all APs return from Procedure before\r
278 the timeout, then FailedCpuList is filled in with the list of the failed\r
279 APs. The buffer is allocated by MP Service Protocol using AllocatePool().\r
280 It is the caller's responsibility to free the buffer with FreePool() service.\r
281 -# This invocation of SignalEvent() function informs the caller that invoked\r
282 EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() that either all the APs completed\r
283 the specified task or a timeout occurred. The contents of FailedCpuList\r
284 can be examined to determine which APs did not complete the specified task\r
285 prior to the timeout.\r
286\r
287 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL\r
288 instance.\r
289 @param[in] Procedure A pointer to the function to be run on\r
290 enabled APs of the system. See type\r
291 EFI_AP_PROCEDURE.\r
292 @param[in] SingleThread If TRUE, then all the enabled APs execute\r
293 the function specified by Procedure one by\r
294 one, in ascending order of processor handle\r
295 number. If FALSE, then all the enabled APs\r
296 execute the function specified by Procedure\r
297 simultaneously.\r
298 @param[in] WaitEvent The event created by the caller with CreateEvent()\r
299 service. If it is NULL, then execute in\r
300 blocking mode. BSP waits until all APs finish\r
301 or TimeoutInMicroseconds expires. If it's\r
302 not NULL, then execute in non-blocking mode.\r
303 BSP requests the function specified by\r
304 Procedure to be started on all the enabled\r
305 APs, and go on executing immediately. If\r
306 all return from Procedure, or TimeoutInMicroseconds\r
307 expires, this event is signaled. The BSP\r
308 can use the CheckEvent() or WaitForEvent()\r
309 services to check the state of event. Type\r
310 EFI_EVENT is defined in CreateEvent() in\r
311 the Unified Extensible Firmware Interface\r
312 Specification.\r
313 @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for\r
314 APs to return from Procedure, either for\r
315 blocking or non-blocking mode. Zero means\r
316 infinity. If the timeout expires before\r
317 all APs return from Procedure, then Procedure\r
318 on the failed APs is terminated. All enabled\r
319 APs are available for next function assigned\r
320 by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()\r
321 or EFI_MP_SERVICES_PROTOCOL.StartupThisAP().\r
322 If the timeout expires in blocking mode,\r
323 BSP returns EFI_TIMEOUT. If the timeout\r
324 expires in non-blocking mode, WaitEvent\r
325 is signaled with SignalEvent().\r
326 @param[in] ProcedureArgument The parameter passed into Procedure for\r
327 all APs.\r
328 @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise,\r
329 if all APs finish successfully, then its\r
330 content is set to NULL. If not all APs\r
331 finish before timeout expires, then its\r
332 content is set to address of the buffer\r
333 holding handle numbers of the failed APs.\r
334 The buffer is allocated by MP Service Protocol,\r
335 and it's the caller's responsibility to\r
336 free the buffer with FreePool() service.\r
337 In blocking mode, it is ready for consumption\r
338 when the call returns. In non-blocking mode,\r
339 it is ready when WaitEvent is signaled. The\r
340 list of failed CPU is terminated by\r
341 END_OF_CPU_LIST.\r
342\r
343 @retval EFI_SUCCESS In blocking mode, all APs have finished before\r
344 the timeout expired.\r
345 @retval EFI_SUCCESS In non-blocking mode, function has been dispatched\r
346 to all enabled APs.\r
347 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the\r
348 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was\r
349 signaled.\r
350 @retval EFI_DEVICE_ERROR Caller processor is AP.\r
351 @retval EFI_NOT_STARTED No enabled APs exist in the system.\r
352 @retval EFI_NOT_READY Any enabled APs are busy.\r
353 @retval EFI_TIMEOUT In blocking mode, the timeout expired before\r
354 all enabled APs have finished.\r
355 @retval EFI_INVALID_PARAMETER Procedure is NULL.\r
356\r
357**/\r
358EFI_STATUS\r
359EFIAPI\r
360StartupAllAPs (\r
361 IN EFI_MP_SERVICES_PROTOCOL *This,\r
362 IN EFI_AP_PROCEDURE Procedure,\r
363 IN BOOLEAN SingleThread,\r
364 IN EFI_EVENT WaitEvent OPTIONAL,\r
365 IN UINTN TimeoutInMicroseconds,\r
366 IN VOID *ProcedureArgument OPTIONAL,\r
367 OUT UINTN **FailedCpuList OPTIONAL\r
368 );\r
369\r
3f4f0af8
CF
370/**\r
371 This service lets the caller get one enabled AP to execute a caller-provided\r
372 function. The caller can request the BSP to either wait for the completion\r
373 of the AP or just proceed with the next task by using the EFI event mechanism.\r
374 See EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() for more details on non-blocking\r
375 execution support. This service may only be called from the BSP.\r
376\r
377 This function is used to dispatch one enabled AP to the function specified by\r
378 Procedure passing in the argument specified by ProcedureArgument. If WaitEvent\r
379 is NULL, execution is in blocking mode. The BSP waits until the AP finishes or\r
380 TimeoutInMicroSecondss expires. Otherwise, execution is in non-blocking mode.\r
381 BSP proceeds to the next task without waiting for the AP. If a non-blocking mode\r
382 is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled,\r
383 then EFI_UNSUPPORTED must be returned.\r
384\r
385 If the timeout specified by TimeoutInMicroseconds expires before the AP returns\r
386 from Procedure, then execution of Procedure by the AP is terminated. The AP is\r
387 available for subsequent calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() and\r
388 EFI_MP_SERVICES_PROTOCOL.StartupThisAP().\r
389\r
390 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL\r
391 instance.\r
392 @param[in] Procedure A pointer to the function to be run on\r
393 enabled APs of the system. See type\r
394 EFI_AP_PROCEDURE.\r
395 @param[in] ProcessorNumber The handle number of the AP. The range is\r
396 from 0 to the total number of logical\r
397 processors minus 1. The total number of\r
398 logical processors can be retrieved by\r
399 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r
400 @param[in] WaitEvent The event created by the caller with CreateEvent()\r
401 service. If it is NULL, then execute in\r
402 blocking mode. BSP waits until all APs finish\r
403 or TimeoutInMicroseconds expires. If it's\r
404 not NULL, then execute in non-blocking mode.\r
405 BSP requests the function specified by\r
406 Procedure to be started on all the enabled\r
407 APs, and go on executing immediately. If\r
408 all return from Procedure or TimeoutInMicroseconds\r
409 expires, this event is signaled. The BSP\r
410 can use the CheckEvent() or WaitForEvent()\r
411 services to check the state of event. Type\r
412 EFI_EVENT is defined in CreateEvent() in\r
413 the Unified Extensible Firmware Interface\r
414 Specification.\r
415 @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for\r
416 APs to return from Procedure, either for\r
417 blocking or non-blocking mode. Zero means\r
418 infinity. If the timeout expires before\r
419 all APs return from Procedure, then Procedure\r
420 on the failed APs is terminated. All enabled\r
421 APs are available for next function assigned\r
422 by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()\r
423 or EFI_MP_SERVICES_PROTOCOL.StartupThisAP().\r
424 If the timeout expires in blocking mode,\r
425 BSP returns EFI_TIMEOUT. If the timeout\r
426 expires in non-blocking mode, WaitEvent\r
427 is signaled with SignalEvent().\r
428 @param[in] ProcedureArgument The parameter passed into Procedure for\r
429 all APs.\r
430 @param[out] Finished If NULL, this parameter is ignored. In\r
431 blocking mode, this parameter is ignored.\r
432 In non-blocking mode, if AP returns from\r
433 Procedure before the timeout expires, its\r
434 content is set to TRUE. Otherwise, the\r
435 value is set to FALSE. The caller can\r
436 determine if the AP returned from Procedure\r
437 by evaluating this value.\r
438\r
439 @retval EFI_SUCCESS In blocking mode, specified AP finished before\r
440 the timeout expires.\r
441 @retval EFI_SUCCESS In non-blocking mode, the function has been\r
442 dispatched to specified AP.\r
443 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the\r
444 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was\r
445 signaled.\r
446 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
447 @retval EFI_TIMEOUT In blocking mode, the timeout expired before\r
448 the specified AP has finished.\r
449 @retval EFI_NOT_READY The specified AP is busy.\r
450 @retval EFI_NOT_FOUND The processor with the handle specified by\r
451 ProcessorNumber does not exist.\r
452 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.\r
453 @retval EFI_INVALID_PARAMETER Procedure is NULL.\r
454\r
455**/\r
456EFI_STATUS\r
457EFIAPI\r
458StartupThisAP (\r
459 IN EFI_MP_SERVICES_PROTOCOL *This,\r
460 IN EFI_AP_PROCEDURE Procedure,\r
461 IN UINTN ProcessorNumber,\r
462 IN EFI_EVENT WaitEvent OPTIONAL,\r
463 IN UINTN TimeoutInMicroseconds,\r
464 IN VOID *ProcedureArgument OPTIONAL,\r
465 OUT BOOLEAN *Finished OPTIONAL\r
466 );\r
467\r
b7c05ba5
CF
468/**\r
469 This service switches the requested AP to be the BSP from that point onward.\r
470 This service changes the BSP for all purposes. This call can only be performed\r
471 by the current BSP.\r
472\r
473 This service switches the requested AP to be the BSP from that point onward.\r
474 This service changes the BSP for all purposes. The new BSP can take over the\r
475 execution of the old BSP and continue seamlessly from where the old one left\r
476 off. This service may not be supported after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT\r
477 is signaled.\r
478\r
479 If the BSP cannot be switched prior to the return from this service, then\r
480 EFI_UNSUPPORTED must be returned.\r
481\r
482 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.\r
483 @param[in] ProcessorNumber The handle number of AP that is to become the new\r
484 BSP. The range is from 0 to the total number of\r
485 logical processors minus 1. The total number of\r
486 logical processors can be retrieved by\r
487 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r
488 @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an\r
489 enabled AP. Otherwise, it will be disabled.\r
490\r
491 @retval EFI_SUCCESS BSP successfully switched.\r
492 @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to\r
493 this service returning.\r
494 @retval EFI_UNSUPPORTED Switching the BSP is not supported.\r
495 @retval EFI_SUCCESS The calling processor is an AP.\r
496 @retval EFI_NOT_FOUND The processor with the handle specified by\r
497 ProcessorNumber does not exist.\r
498 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or\r
499 a disabled AP.\r
500 @retval EFI_NOT_READY The specified AP is busy.\r
501\r
502**/\r
503EFI_STATUS\r
504EFIAPI\r
505SwitchBSP (\r
506 IN EFI_MP_SERVICES_PROTOCOL *This,\r
507 IN UINTN ProcessorNumber,\r
508 IN BOOLEAN EnableOldBSP\r
509 );\r
510\r
fa7ce675
CF
511/**\r
512 This service lets the caller enable or disable an AP from this point onward.\r
513 This service may only be called from the BSP.\r
514\r
515 This service allows the caller enable or disable an AP from this point onward.\r
516 The caller can optionally specify the health status of the AP by Health. If\r
517 an AP is being disabled, then the state of the disabled AP is implementation\r
518 dependent. If an AP is enabled, then the implementation must guarantee that a\r
519 complete initialization sequence is performed on the AP, so the AP is in a state\r
520 that is compatible with an MP operating system. This service may not be supported\r
521 after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled.\r
522\r
523 If the enable or disable AP operation cannot be completed prior to the return\r
524 from this service, then EFI_UNSUPPORTED must be returned.\r
525\r
526 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.\r
527 @param[in] ProcessorNumber The handle number of AP that is to become the new\r
528 BSP. The range is from 0 to the total number of\r
529 logical processors minus 1. The total number of\r
530 logical processors can be retrieved by\r
531 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r
532 @param[in] EnableAP Specifies the new state for the processor for\r
533 enabled, FALSE for disabled.\r
534 @param[in] HealthFlag If not NULL, a pointer to a value that specifies\r
535 the new health status of the AP. This flag\r
536 corresponds to StatusFlag defined in\r
537 EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only\r
538 the PROCESSOR_HEALTH_STATUS_BIT is used. All other\r
539 bits are ignored. If it is NULL, this parameter\r
540 is ignored.\r
541\r
542 @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.\r
543 @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed\r
544 prior to this service returning.\r
545 @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.\r
546 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
547 @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber\r
548 does not exist.\r
549 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.\r
550\r
551**/\r
552EFI_STATUS\r
553EFIAPI\r
554EnableDisableAP (\r
555 IN EFI_MP_SERVICES_PROTOCOL *This,\r
556 IN UINTN ProcessorNumber,\r
557 IN BOOLEAN EnableAP,\r
558 IN UINT32 *HealthFlag OPTIONAL\r
559 );\r
560\r
cfa2fac1
CF
561/**\r
562 This return the handle number for the calling processor. This service may be\r
563 called from the BSP and APs.\r
564\r
565 This service returns the processor handle number for the calling processor.\r
566 The returned value is in the range from 0 to the total number of logical\r
567 processors minus 1. The total number of logical processors can be retrieved\r
568 with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be\r
569 called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER\r
570 is returned. Otherwise, the current processors handle number is returned in\r
571 ProcessorNumber, and EFI_SUCCESS is returned.\r
572\r
573 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.\r
574 @param[out] ProcessorNumber The handle number of AP that is to become the new\r
575 BSP. The range is from 0 to the total number of\r
576 logical processors minus 1. The total number of\r
577 logical processors can be retrieved by\r
578 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().\r
579\r
580 @retval EFI_SUCCESS The current processor handle number was returned\r
581 in ProcessorNumber.\r
582 @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.\r
583\r
584**/\r
585EFI_STATUS\r
586EFIAPI\r
587WhoAmI (\r
588 IN EFI_MP_SERVICES_PROTOCOL *This,\r
589 OUT UINTN *ProcessorNumber\r
590 );\r
591\r
3f4f0af8
CF
592/**\r
593 Terminate AP's task and set it to idle state.\r
594\r
595 This function terminates AP's task due to timeout by sending INIT-SIPI,\r
596 and sends it to idle state.\r
597\r
598 @param CpuData the pointer to CPU_DATA_BLOCK of specified AP\r
599\r
600**/\r
601VOID\r
602ResetProcessorToIdleState (\r
603 IN CPU_DATA_BLOCK *CpuData\r
604 );\r
605\r
fe078dd5
CF
606/**\r
607 Prepares Startup Code for APs.\r
608 This function prepares Startup Code for APs.\r
609\r
610 @retval EFI_SUCCESS The APs were started\r
611 @retval EFI_OUT_OF_RESOURCES Cannot allocate memory to start APs\r
612\r
613**/\r
614EFI_STATUS\r
615PrepareAPStartupCode (\r
616 VOID\r
617 );\r
618\r
619/**\r
620 Free the code buffer of startup AP.\r
621\r
622**/\r
623VOID\r
624FreeApStartupCode (\r
625 VOID\r
626 );\r
627\r
ac9dbb3b
CF
628/**\r
629 Resets the Application Processor and directs it to jump to the\r
630 specified routine.\r
631\r
632 The processor jumps to this code in flat mode, but the processor's\r
633 stack is not initialized.\r
634\r
635 @param ProcessorId the AP of ProcessorId was reset\r
636**/\r
637VOID\r
638ResetApStackless (\r
639 IN UINT32 ProcessorId\r
640 );\r
641\r
6022e28c
JJ
642#endif // _CPU_MP_H_\r
643\r