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