MdePkg MpServices: Update return status to follow spec.
[mirror_edk2.git] / MdePkg / Include / Protocol / MpService.h
1 /** @file
2 When installed, the MP Services Protocol produces a collection of services
3 that are needed for MP management.
4
5 The MP Services Protocol provides a generalized way of performing following tasks:
6 - Retrieving information of multi-processor environment and MP-related status of
7 specific processors.
8 - Dispatching user-provided function to APs.
9 - Maintain MP-related processor status.
10
11 The MP Services Protocol must be produced on any system with more than one logical
12 processor.
13
14 The Protocol is available only during boot time.
15
16 MP Services Protocol is hardware-independent. Most of the logic of this protocol
17 is architecturally neutral. It abstracts the multi-processor environment and
18 status of processors, and provides interfaces to retrieve information, maintain,
19 and dispatch.
20
21 MP Services Protocol may be consumed by ACPI module. The ACPI module may use this
22 protocol to retrieve data that are needed for an MP platform and report them to OS.
23 MP Services Protocol may also be used to program and configure processors, such
24 as MTRR synchronization for memory space attributes setting in DXE Services.
25 MP Services Protocol may be used by non-CPU DXE drivers to speed up platform boot
26 by taking advantage of the processing capabilities of the APs, for example, using
27 APs to help test system memory in parallel with other device initialization.
28 Diagnostics applications may also use this protocol for multi-processor.
29
30 Copyright (c) 2006 - 2017, Intel Corporation. All rights reserved.<BR>
31 This program and the accompanying materials are licensed and made available under
32 the terms and conditions of the BSD License that accompanies this distribution.
33 The full text of the license may be found at
34 http://opensource.org/licenses/bsd-license.php.
35
36 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
37 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
38
39 @par Revision Reference:
40 This Protocol is defined in the UEFI Platform Initialization Specification 1.2,
41 Volume 2:Driver Execution Environment Core Interface.
42
43 **/
44
45 #ifndef _MP_SERVICE_PROTOCOL_H_
46 #define _MP_SERVICE_PROTOCOL_H_
47
48 ///
49 /// Global ID for the EFI_MP_SERVICES_PROTOCOL.
50 ///
51 #define EFI_MP_SERVICES_PROTOCOL_GUID \
52 { \
53 0x3fdda605, 0xa76e, 0x4f46, {0xad, 0x29, 0x12, 0xf4, 0x53, 0x1b, 0x3d, 0x08} \
54 }
55
56 ///
57 /// Forward declaration for the EFI_MP_SERVICES_PROTOCOL.
58 ///
59 typedef struct _EFI_MP_SERVICES_PROTOCOL EFI_MP_SERVICES_PROTOCOL;
60
61 ///
62 /// Terminator for a list of failed CPUs returned by StartAllAPs().
63 ///
64 #define END_OF_CPU_LIST 0xffffffff
65
66 ///
67 /// This bit is used in the StatusFlag field of EFI_PROCESSOR_INFORMATION and
68 /// indicates whether the processor is playing the role of BSP. If the bit is 1,
69 /// then the processor is BSP. Otherwise, it is AP.
70 ///
71 #define PROCESSOR_AS_BSP_BIT 0x00000001
72
73 ///
74 /// This bit is used in the StatusFlag field of EFI_PROCESSOR_INFORMATION and
75 /// indicates whether the processor is enabled. If the bit is 1, then the
76 /// processor is enabled. Otherwise, it is disabled.
77 ///
78 #define PROCESSOR_ENABLED_BIT 0x00000002
79
80 ///
81 /// This bit is used in the StatusFlag field of EFI_PROCESSOR_INFORMATION and
82 /// indicates whether the processor is healthy. If the bit is 1, then the
83 /// processor is healthy. Otherwise, some fault has been detected for the processor.
84 ///
85 #define PROCESSOR_HEALTH_STATUS_BIT 0x00000004
86
87 ///
88 /// Structure that describes the pyhiscal location of a logical CPU.
89 ///
90 typedef struct {
91 ///
92 /// Zero-based physical package number that identifies the cartridge of the processor.
93 ///
94 UINT32 Package;
95 ///
96 /// Zero-based physical core number within package of the processor.
97 ///
98 UINT32 Core;
99 ///
100 /// Zero-based logical thread number within core of the processor.
101 ///
102 UINT32 Thread;
103 } EFI_CPU_PHYSICAL_LOCATION;
104
105 ///
106 /// Structure that describes information about a logical CPU.
107 ///
108 typedef struct {
109 ///
110 /// The unique processor ID determined by system hardware. For IA32 and X64,
111 /// the processor ID is the same as the Local APIC ID. Only the lower 8 bits
112 /// are used, and higher bits are reserved. For IPF, the lower 16 bits contains
113 /// id/eid, and higher bits are reserved.
114 ///
115 UINT64 ProcessorId;
116 ///
117 /// Flags indicating if the processor is BSP or AP, if the processor is enabled
118 /// or disabled, and if the processor is healthy. Bits 3..31 are reserved and
119 /// must be 0.
120 ///
121 /// <pre>
122 /// BSP ENABLED HEALTH Description
123 /// === ======= ====== ===================================================
124 /// 0 0 0 Unhealthy Disabled AP.
125 /// 0 0 1 Healthy Disabled AP.
126 /// 0 1 0 Unhealthy Enabled AP.
127 /// 0 1 1 Healthy Enabled AP.
128 /// 1 0 0 Invalid. The BSP can never be in the disabled state.
129 /// 1 0 1 Invalid. The BSP can never be in the disabled state.
130 /// 1 1 0 Unhealthy Enabled BSP.
131 /// 1 1 1 Healthy Enabled BSP.
132 /// </pre>
133 ///
134 UINT32 StatusFlag;
135 ///
136 /// The physical location of the processor, including the physical package number
137 /// that identifies the cartridge, the physical core number within package, and
138 /// logical thread number within core.
139 ///
140 EFI_CPU_PHYSICAL_LOCATION Location;
141 } EFI_PROCESSOR_INFORMATION;
142
143 /**
144 This service retrieves the number of logical processor in the platform
145 and the number of those logical processors that are enabled on this boot.
146 This service may only be called from the BSP.
147
148 This function is used to retrieve the following information:
149 - The number of logical processors that are present in the system.
150 - The number of enabled logical processors in the system at the instant
151 this call is made.
152
153 Because MP Service Protocol provides services to enable and disable processors
154 dynamically, the number of enabled logical processors may vary during the
155 course of a boot session.
156
157 If this service is called from an AP, then EFI_DEVICE_ERROR is returned.
158 If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then
159 EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors
160 is returned in NumberOfProcessors, the number of currently enabled processor
161 is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.
162
163 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
164 instance.
165 @param[out] NumberOfProcessors Pointer to the total number of logical
166 processors in the system, including the BSP
167 and disabled APs.
168 @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical
169 processors that exist in system, including
170 the BSP.
171
172 @retval EFI_SUCCESS The number of logical processors and enabled
173 logical processors was retrieved.
174 @retval EFI_DEVICE_ERROR The calling processor is an AP.
175 @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.
176 @retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL.
177
178 **/
179 typedef
180 EFI_STATUS
181 (EFIAPI *EFI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS)(
182 IN EFI_MP_SERVICES_PROTOCOL *This,
183 OUT UINTN *NumberOfProcessors,
184 OUT UINTN *NumberOfEnabledProcessors
185 );
186
187 /**
188 Gets detailed MP-related information on the requested processor at the
189 instant this call is made. This service may only be called from the BSP.
190
191 This service retrieves detailed MP-related information about any processor
192 on the platform. Note the following:
193 - The processor information may change during the course of a boot session.
194 - The information presented here is entirely MP related.
195
196 Information regarding the number of caches and their sizes, frequency of operation,
197 slot numbers is all considered platform-related information and is not provided
198 by this service.
199
200 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
201 instance.
202 @param[in] ProcessorNumber The handle number of processor.
203 @param[out] ProcessorInfoBuffer A pointer to the buffer where information for
204 the requested processor is deposited.
205
206 @retval EFI_SUCCESS Processor information was returned.
207 @retval EFI_DEVICE_ERROR The calling processor is an AP.
208 @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.
209 @retval EFI_NOT_FOUND The processor with the handle specified by
210 ProcessorNumber does not exist in the platform.
211
212 **/
213 typedef
214 EFI_STATUS
215 (EFIAPI *EFI_MP_SERVICES_GET_PROCESSOR_INFO)(
216 IN EFI_MP_SERVICES_PROTOCOL *This,
217 IN UINTN ProcessorNumber,
218 OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
219 );
220
221 /**
222 This service executes a caller provided function on all enabled APs. APs can
223 run either simultaneously or one at a time in sequence. This service supports
224 both blocking and non-blocking requests. The non-blocking requests use EFI
225 events so the BSP can detect when the APs have finished. This service may only
226 be called from the BSP.
227
228 This function is used to dispatch all the enabled APs to the function specified
229 by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned
230 immediately and Procedure is not started on any AP.
231
232 If SingleThread is TRUE, all the enabled APs execute the function specified by
233 Procedure one by one, in ascending order of processor handle number. Otherwise,
234 all the enabled APs execute the function specified by Procedure simultaneously.
235
236 If WaitEvent is NULL, execution is in blocking mode. The BSP waits until all
237 APs finish or TimeoutInMicroSecs expires. Otherwise, execution is in non-blocking
238 mode, and the BSP returns from this service without waiting for APs. If a
239 non-blocking mode is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT
240 is signaled, then EFI_UNSUPPORTED must be returned.
241
242 If the timeout specified by TimeoutInMicroseconds expires before all APs return
243 from Procedure, then Procedure on the failed APs is terminated. All enabled APs
244 are always available for further calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()
245 and EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). If FailedCpuList is not NULL, its
246 content points to the list of processor handle numbers in which Procedure was
247 terminated.
248
249 Note: It is the responsibility of the consumer of the EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()
250 to make sure that the nature of the code that is executed on the BSP and the
251 dispatched APs is well controlled. The MP Services Protocol does not guarantee
252 that the Procedure function is MP-safe. Hence, the tasks that can be run in
253 parallel are limited to certain independent tasks and well-controlled exclusive
254 code. EFI services and protocols may not be called by APs unless otherwise
255 specified.
256
257 In blocking execution mode, BSP waits until all APs finish or
258 TimeoutInMicroSeconds expires.
259
260 In non-blocking execution mode, BSP is freed to return to the caller and then
261 proceed to the next task without having to wait for APs. The following
262 sequence needs to occur in a non-blocking execution mode:
263
264 -# The caller that intends to use this MP Services Protocol in non-blocking
265 mode creates WaitEvent by calling the EFI CreateEvent() service. The caller
266 invokes EFI_MP_SERVICES_PROTOCOL.StartupAllAPs(). If the parameter WaitEvent
267 is not NULL, then StartupAllAPs() executes in non-blocking mode. It requests
268 the function specified by Procedure to be started on all the enabled APs,
269 and releases the BSP to continue with other tasks.
270 -# The caller can use the CheckEvent() and WaitForEvent() services to check
271 the state of the WaitEvent created in step 1.
272 -# When the APs complete their task or TimeoutInMicroSecondss expires, the MP
273 Service signals WaitEvent by calling the EFI SignalEvent() function. If
274 FailedCpuList is not NULL, its content is available when WaitEvent is
275 signaled. If all APs returned from Procedure prior to the timeout, then
276 FailedCpuList is set to NULL. If not all APs return from Procedure before
277 the timeout, then FailedCpuList is filled in with the list of the failed
278 APs. The buffer is allocated by MP Service Protocol using AllocatePool().
279 It is the caller's responsibility to free the buffer with FreePool() service.
280 -# This invocation of SignalEvent() function informs the caller that invoked
281 EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() that either all the APs completed
282 the specified task or a timeout occurred. The contents of FailedCpuList
283 can be examined to determine which APs did not complete the specified task
284 prior to the timeout.
285
286 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
287 instance.
288 @param[in] Procedure A pointer to the function to be run on
289 enabled APs of the system. See type
290 EFI_AP_PROCEDURE.
291 @param[in] SingleThread If TRUE, then all the enabled APs execute
292 the function specified by Procedure one by
293 one, in ascending order of processor handle
294 number. If FALSE, then all the enabled APs
295 execute the function specified by Procedure
296 simultaneously.
297 @param[in] WaitEvent The event created by the caller with CreateEvent()
298 service. If it is NULL, then execute in
299 blocking mode. BSP waits until all APs finish
300 or TimeoutInMicroSeconds expires. If it's
301 not NULL, then execute in non-blocking mode.
302 BSP requests the function specified by
303 Procedure to be started on all the enabled
304 APs, and go on executing immediately. If
305 all return from Procedure, or TimeoutInMicroSeconds
306 expires, this event is signaled. The BSP
307 can use the CheckEvent() or WaitForEvent()
308 services to check the state of event. Type
309 EFI_EVENT is defined in CreateEvent() in
310 the Unified Extensible Firmware Interface
311 Specification.
312 @param[in] TimeoutInMicrosecsond Indicates the time limit in microseconds for
313 APs to return from Procedure, either for
314 blocking or non-blocking mode. Zero means
315 infinity. If the timeout expires before
316 all APs return from Procedure, then Procedure
317 on the failed APs is terminated. All enabled
318 APs are available for next function assigned
319 by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()
320 or EFI_MP_SERVICES_PROTOCOL.StartupThisAP().
321 If the timeout expires in blocking mode,
322 BSP returns EFI_TIMEOUT. If the timeout
323 expires in non-blocking mode, WaitEvent
324 is signaled with SignalEvent().
325 @param[in] ProcedureArgument The parameter passed into Procedure for
326 all APs.
327 @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise,
328 if all APs finish successfully, then its
329 content is set to NULL. If not all APs
330 finish before timeout expires, then its
331 content is set to address of the buffer
332 holding handle numbers of the failed APs.
333 The buffer is allocated by MP Service Protocol,
334 and it's the caller's responsibility to
335 free the buffer with FreePool() service.
336 In blocking mode, it is ready for consumption
337 when the call returns. In non-blocking mode,
338 it is ready when WaitEvent is signaled. The
339 list of failed CPU is terminated by
340 END_OF_CPU_LIST.
341
342 @retval EFI_SUCCESS In blocking mode, all APs have finished before
343 the timeout expired.
344 @retval EFI_SUCCESS In non-blocking mode, function has been dispatched
345 to all enabled APs.
346 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the
347 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was
348 signaled.
349 @retval EFI_DEVICE_ERROR Caller processor is AP.
350 @retval EFI_NOT_STARTED No enabled APs exist in the system.
351 @retval EFI_NOT_READY Any enabled APs are busy.
352 @retval EFI_TIMEOUT In blocking mode, the timeout expired before
353 all enabled APs have finished.
354 @retval EFI_INVALID_PARAMETER Procedure is NULL.
355
356 **/
357 typedef
358 EFI_STATUS
359 (EFIAPI *EFI_MP_SERVICES_STARTUP_ALL_APS)(
360 IN EFI_MP_SERVICES_PROTOCOL *This,
361 IN EFI_AP_PROCEDURE Procedure,
362 IN BOOLEAN SingleThread,
363 IN EFI_EVENT WaitEvent OPTIONAL,
364 IN UINTN TimeoutInMicroSeconds,
365 IN VOID *ProcedureArgument OPTIONAL,
366 OUT UINTN **FailedCpuList OPTIONAL
367 );
368
369 /**
370 This service lets the caller get one enabled AP to execute a caller-provided
371 function. The caller can request the BSP to either wait for the completion
372 of the AP or just proceed with the next task by using the EFI event mechanism.
373 See EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() for more details on non-blocking
374 execution support. This service may only be called from the BSP.
375
376 This function is used to dispatch one enabled AP to the function specified by
377 Procedure passing in the argument specified by ProcedureArgument. If WaitEvent
378 is NULL, execution is in blocking mode. The BSP waits until the AP finishes or
379 TimeoutInMicroSecondss expires. Otherwise, execution is in non-blocking mode.
380 BSP proceeds to the next task without waiting for the AP. If a non-blocking mode
381 is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled,
382 then EFI_UNSUPPORTED must be returned.
383
384 If the timeout specified by TimeoutInMicroseconds expires before the AP returns
385 from Procedure, then execution of Procedure by the AP is terminated. The AP is
386 available for subsequent calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() and
387 EFI_MP_SERVICES_PROTOCOL.StartupThisAP().
388
389 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
390 instance.
391 @param[in] Procedure A pointer to the function to be run on the
392 designated AP of the system. See type
393 EFI_AP_PROCEDURE.
394 @param[in] ProcessorNumber The handle number of the AP. The range is
395 from 0 to the total number of logical
396 processors minus 1. The total number of
397 logical processors can be retrieved by
398 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
399 @param[in] WaitEvent The event created by the caller with CreateEvent()
400 service. If it is NULL, then execute in
401 blocking mode. BSP waits until this AP finish
402 or TimeoutInMicroSeconds expires. If it's
403 not NULL, then execute in non-blocking mode.
404 BSP requests the function specified by
405 Procedure to be started on this AP,
406 and go on executing immediately. If this AP
407 return from Procedure or TimeoutInMicroSeconds
408 expires, this event is signaled. The BSP
409 can use the CheckEvent() or WaitForEvent()
410 services to check the state of event. Type
411 EFI_EVENT is defined in CreateEvent() in
412 the Unified Extensible Firmware Interface
413 Specification.
414 @param[in] TimeoutInMicrosecsond Indicates the time limit in microseconds for
415 this AP to finish this Procedure, either for
416 blocking or non-blocking mode. Zero means
417 infinity. If the timeout expires before
418 this AP returns from Procedure, then Procedure
419 on the AP is terminated. The
420 AP is available for next function assigned
421 by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()
422 or EFI_MP_SERVICES_PROTOCOL.StartupThisAP().
423 If the timeout expires in blocking mode,
424 BSP returns EFI_TIMEOUT. If the timeout
425 expires in non-blocking mode, WaitEvent
426 is signaled with SignalEvent().
427 @param[in] ProcedureArgument The parameter passed into Procedure on the
428 specified AP.
429 @param[out] Finished If NULL, this parameter is ignored. In
430 blocking mode, this parameter is ignored.
431 In non-blocking mode, if AP returns from
432 Procedure before the timeout expires, its
433 content is set to TRUE. Otherwise, the
434 value is set to FALSE. The caller can
435 determine if the AP returned from Procedure
436 by evaluating this value.
437
438 @retval EFI_SUCCESS In blocking mode, specified AP finished before
439 the timeout expires.
440 @retval EFI_SUCCESS In non-blocking mode, the function has been
441 dispatched to specified AP.
442 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the
443 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was
444 signaled.
445 @retval EFI_DEVICE_ERROR The calling processor is an AP.
446 @retval EFI_TIMEOUT In blocking mode, the timeout expired before
447 the specified AP has finished.
448 @retval EFI_NOT_READY The specified AP is busy.
449 @retval EFI_NOT_FOUND The processor with the handle specified by
450 ProcessorNumber does not exist.
451 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.
452 @retval EFI_INVALID_PARAMETER Procedure is NULL.
453
454 **/
455 typedef
456 EFI_STATUS
457 (EFIAPI *EFI_MP_SERVICES_STARTUP_THIS_AP)(
458 IN EFI_MP_SERVICES_PROTOCOL *This,
459 IN EFI_AP_PROCEDURE Procedure,
460 IN UINTN ProcessorNumber,
461 IN EFI_EVENT WaitEvent OPTIONAL,
462 IN UINTN TimeoutInMicroseconds,
463 IN VOID *ProcedureArgument OPTIONAL,
464 OUT BOOLEAN *Finished OPTIONAL
465 );
466
467 /**
468 This service switches the requested AP to be the BSP from that point onward.
469 This service changes the BSP for all purposes. This call can only be performed
470 by the current BSP.
471
472 This service switches the requested AP to be the BSP from that point onward.
473 This service changes the BSP for all purposes. The new BSP can take over the
474 execution of the old BSP and continue seamlessly from where the old one left
475 off. This service may not be supported after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT
476 is signaled.
477
478 If the BSP cannot be switched prior to the return from this service, then
479 EFI_UNSUPPORTED must be returned.
480
481 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
482 @param[in] ProcessorNumber The handle number of AP that is to become the new
483 BSP. The range is from 0 to the total number of
484 logical processors minus 1. The total number of
485 logical processors can be retrieved by
486 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
487 @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an
488 enabled AP. Otherwise, it will be disabled.
489
490 @retval EFI_SUCCESS BSP successfully switched.
491 @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to
492 this service returning.
493 @retval EFI_UNSUPPORTED Switching the BSP is not supported.
494 @retval EFI_DEVICE_ERROR The calling processor is an AP.
495 @retval EFI_NOT_FOUND The processor with the handle specified by
496 ProcessorNumber does not exist.
497 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or
498 a disabled AP.
499 @retval EFI_NOT_READY The specified AP is busy.
500
501 **/
502 typedef
503 EFI_STATUS
504 (EFIAPI *EFI_MP_SERVICES_SWITCH_BSP)(
505 IN EFI_MP_SERVICES_PROTOCOL *This,
506 IN UINTN ProcessorNumber,
507 IN BOOLEAN EnableOldBSP
508 );
509
510 /**
511 This service lets the caller enable or disable an AP from this point onward.
512 This service may only be called from the BSP.
513
514 This service allows the caller enable or disable an AP from this point onward.
515 The caller can optionally specify the health status of the AP by Health. If
516 an AP is being disabled, then the state of the disabled AP is implementation
517 dependent. If an AP is enabled, then the implementation must guarantee that a
518 complete initialization sequence is performed on the AP, so the AP is in a state
519 that is compatible with an MP operating system. This service may not be supported
520 after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled.
521
522 If the enable or disable AP operation cannot be completed prior to the return
523 from this service, then EFI_UNSUPPORTED must be returned.
524
525 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
526 @param[in] ProcessorNumber The handle number of AP.
527 The range is from 0 to the total number of
528 logical processors minus 1. The total number of
529 logical processors can be retrieved by
530 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
531 @param[in] EnableAP Specifies the new state for the processor for
532 enabled, FALSE for disabled.
533 @param[in] HealthFlag If not NULL, a pointer to a value that specifies
534 the new health status of the AP. This flag
535 corresponds to StatusFlag defined in
536 EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only
537 the PROCESSOR_HEALTH_STATUS_BIT is used. All other
538 bits are ignored. If it is NULL, this parameter
539 is ignored.
540
541 @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.
542 @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed
543 prior to this service returning.
544 @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.
545 @retval EFI_DEVICE_ERROR The calling processor is an AP.
546 @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber
547 does not exist.
548 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.
549
550 **/
551 typedef
552 EFI_STATUS
553 (EFIAPI *EFI_MP_SERVICES_ENABLEDISABLEAP)(
554 IN EFI_MP_SERVICES_PROTOCOL *This,
555 IN UINTN ProcessorNumber,
556 IN BOOLEAN EnableAP,
557 IN UINT32 *HealthFlag OPTIONAL
558 );
559
560 /**
561 This return the handle number for the calling processor. This service may be
562 called from the BSP and APs.
563
564 This service returns the processor handle number for the calling processor.
565 The returned value is in the range from 0 to the total number of logical
566 processors minus 1. The total number of logical processors can be retrieved
567 with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be
568 called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER
569 is returned. Otherwise, the current processors handle number is returned in
570 ProcessorNumber, and EFI_SUCCESS is returned.
571
572 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
573 @param[in] ProcessorNumber Pointer to the handle number of AP.
574 The range is from 0 to the total number of
575 logical processors minus 1. The total number of
576 logical processors can be retrieved by
577 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
578
579 @retval EFI_SUCCESS The current processor handle number was returned
580 in ProcessorNumber.
581 @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.
582
583 **/
584 typedef
585 EFI_STATUS
586 (EFIAPI *EFI_MP_SERVICES_WHOAMI)(
587 IN EFI_MP_SERVICES_PROTOCOL *This,
588 OUT UINTN *ProcessorNumber
589 );
590
591 ///
592 /// When installed, the MP Services Protocol produces a collection of services
593 /// that are needed for MP management.
594 ///
595 /// Before the UEFI event EFI_EVENT_GROUP_READY_TO_BOOT is signaled, the module
596 /// that produces this protocol is required to place all APs into an idle state
597 /// whenever the APs are disabled or the APs are not executing code as requested
598 /// through the StartupAllAPs() or StartupThisAP() services. The idle state of
599 /// an AP before the UEFI event EFI_EVENT_GROUP_READY_TO_BOOT is signaled is
600 /// implementation dependent.
601 ///
602 /// After the UEFI event EFI_EVENT_GROUP_READY_TO_BOOT is signaled, all the APs
603 /// must be placed in the OS compatible CPU state as defined by the UEFI
604 /// Specification. Implementations of this protocol may use the UEFI event
605 /// EFI_EVENT_GROUP_READY_TO_BOOT to force APs into the OS compatible state as
606 /// defined by the UEFI Specification. Modules that use this protocol must
607 /// guarantee that all non-blocking mode requests on all APs have been completed
608 /// before the UEFI event EFI_EVENT_GROUP_READY_TO_BOOT is signaled. Since the
609 /// order that event notification functions in the same event group are executed
610 /// is not deterministic, an event of type EFI_EVENT_GROUP_READY_TO_BOOT cannot
611 /// be used to guarantee that APs have completed their non-blocking mode requests.
612 ///
613 /// When the UEFI event EFI_EVENT_GROUP_READY_TO_BOOT is signaled, the StartAllAPs()
614 /// and StartupThisAp() services must no longer support non-blocking mode requests.
615 /// The support for SwitchBSP() and EnableDisableAP() may no longer be supported
616 /// after this event is signaled. Since UEFI Applications and UEFI OS Loaders
617 /// execute after the UEFI event EFI_EVENT_GROUP_READY_TO_BOOT is signaled, these
618 /// UEFI images must be aware that the functionality of this protocol may be reduced.
619 ///
620 struct _EFI_MP_SERVICES_PROTOCOL {
621 EFI_MP_SERVICES_GET_NUMBER_OF_PROCESSORS GetNumberOfProcessors;
622 EFI_MP_SERVICES_GET_PROCESSOR_INFO GetProcessorInfo;
623 EFI_MP_SERVICES_STARTUP_ALL_APS StartupAllAPs;
624 EFI_MP_SERVICES_STARTUP_THIS_AP StartupThisAP;
625 EFI_MP_SERVICES_SWITCH_BSP SwitchBSP;
626 EFI_MP_SERVICES_ENABLEDISABLEAP EnableDisableAP;
627 EFI_MP_SERVICES_WHOAMI WhoAmI;
628 };
629
630 extern EFI_GUID gEfiMpServiceProtocolGuid;
631
632 #endif