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