]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/CpuDxe/CpuMp.h
UefiCpuPkg: Move AsmRelocateApLoopStart from Mpfuncs.nasm to AmdSev.nasm
[mirror_edk2.git] / UefiCpuPkg / CpuDxe / CpuMp.h
1 /** @file
2 CPU DXE MP support
3
4 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
6
7 **/
8
9 #ifndef _CPU_MP_H_
10 #define _CPU_MP_H_
11
12 /**
13 Initialize Multi-processor support.
14
15 **/
16 VOID
17 InitializeMpSupport (
18 VOID
19 );
20
21 /**
22 This service retrieves the number of logical processor in the platform
23 and the number of those logical processors that are enabled on this boot.
24 This service may only be called from the BSP.
25
26 This function is used to retrieve the following information:
27 - The number of logical processors that are present in the system.
28 - The number of enabled logical processors in the system at the instant
29 this call is made.
30
31 Because MP Service Protocol provides services to enable and disable processors
32 dynamically, the number of enabled logical processors may vary during the
33 course of a boot session.
34
35 If this service is called from an AP, then EFI_DEVICE_ERROR is returned.
36 If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then
37 EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors
38 is returned in NumberOfProcessors, the number of currently enabled processor
39 is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.
40
41 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
42 instance.
43 @param[out] NumberOfProcessors Pointer to the total number of logical
44 processors in the system, including the BSP
45 and disabled APs.
46 @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical
47 processors that exist in system, including
48 the BSP.
49
50 @retval EFI_SUCCESS The number of logical processors and enabled
51 logical processors was retrieved.
52 @retval EFI_DEVICE_ERROR The calling processor is an AP.
53 @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.
54 @retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL.
55
56 **/
57 EFI_STATUS
58 EFIAPI
59 GetNumberOfProcessors (
60 IN EFI_MP_SERVICES_PROTOCOL *This,
61 OUT UINTN *NumberOfProcessors,
62 OUT UINTN *NumberOfEnabledProcessors
63 );
64
65 /**
66 Gets detailed MP-related information on the requested processor at the
67 instant this call is made. This service may only be called from the BSP.
68
69 This service retrieves detailed MP-related information about any processor
70 on the platform. Note the following:
71 - The processor information may change during the course of a boot session.
72 - The information presented here is entirely MP related.
73
74 Information regarding the number of caches and their sizes, frequency of operation,
75 slot numbers is all considered platform-related information and is not provided
76 by this service.
77
78 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
79 instance.
80 @param[in] ProcessorNumber The handle number of processor.
81 @param[out] ProcessorInfoBuffer A pointer to the buffer where information for
82 the requested processor is deposited.
83
84 @retval EFI_SUCCESS Processor information was returned.
85 @retval EFI_DEVICE_ERROR The calling processor is an AP.
86 @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.
87 @retval EFI_NOT_FOUND The processor with the handle specified by
88 ProcessorNumber does not exist in the platform.
89
90 **/
91 EFI_STATUS
92 EFIAPI
93 GetProcessorInfo (
94 IN EFI_MP_SERVICES_PROTOCOL *This,
95 IN UINTN ProcessorNumber,
96 OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
97 );
98
99 /**
100 This service executes a caller provided function on all enabled APs. APs can
101 run either simultaneously or one at a time in sequence. This service supports
102 both blocking and non-blocking requests. The non-blocking requests use EFI
103 events so the BSP can detect when the APs have finished. This service may only
104 be called from the BSP.
105
106 This function is used to dispatch all the enabled APs to the function specified
107 by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned
108 immediately and Procedure is not started on any AP.
109
110 If SingleThread is TRUE, all the enabled APs execute the function specified by
111 Procedure one by one, in ascending order of processor handle number. Otherwise,
112 all the enabled APs execute the function specified by Procedure simultaneously.
113
114 If WaitEvent is NULL, execution is in blocking mode. The BSP waits until all
115 APs finish or TimeoutInMicroseconds expires. Otherwise, execution is in non-blocking
116 mode, and the BSP returns from this service without waiting for APs. If a
117 non-blocking mode is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT
118 is signaled, then EFI_UNSUPPORTED must be returned.
119
120 If the timeout specified by TimeoutInMicroseconds expires before all APs return
121 from Procedure, then Procedure on the failed APs is terminated. All enabled APs
122 are always available for further calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()
123 and EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). If FailedCpuList is not NULL, its
124 content points to the list of processor handle numbers in which Procedure was
125 terminated.
126
127 Note: It is the responsibility of the consumer of the EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()
128 to make sure that the nature of the code that is executed on the BSP and the
129 dispatched APs is well controlled. The MP Services Protocol does not guarantee
130 that the Procedure function is MP-safe. Hence, the tasks that can be run in
131 parallel are limited to certain independent tasks and well-controlled exclusive
132 code. EFI services and protocols may not be called by APs unless otherwise
133 specified.
134
135 In blocking execution mode, BSP waits until all APs finish or
136 TimeoutInMicroseconds expires.
137
138 In non-blocking execution mode, BSP is freed to return to the caller and then
139 proceed to the next task without having to wait for APs. The following
140 sequence needs to occur in a non-blocking execution mode:
141
142 -# The caller that intends to use this MP Services Protocol in non-blocking
143 mode creates WaitEvent by calling the EFI CreateEvent() service. The caller
144 invokes EFI_MP_SERVICES_PROTOCOL.StartupAllAPs(). If the parameter WaitEvent
145 is not NULL, then StartupAllAPs() executes in non-blocking mode. It requests
146 the function specified by Procedure to be started on all the enabled APs,
147 and releases the BSP to continue with other tasks.
148 -# The caller can use the CheckEvent() and WaitForEvent() services to check
149 the state of the WaitEvent created in step 1.
150 -# When the APs complete their task or TimeoutInMicroSeconds expires, the MP
151 Service signals WaitEvent by calling the EFI SignalEvent() function. If
152 FailedCpuList is not NULL, its content is available when WaitEvent is
153 signaled. If all APs returned from Procedure prior to the timeout, then
154 FailedCpuList is set to NULL. If not all APs return from Procedure before
155 the timeout, then FailedCpuList is filled in with the list of the failed
156 APs. The buffer is allocated by MP Service Protocol using AllocatePool().
157 It is the caller's responsibility to free the buffer with FreePool() service.
158 -# This invocation of SignalEvent() function informs the caller that invoked
159 EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() that either all the APs completed
160 the specified task or a timeout occurred. The contents of FailedCpuList
161 can be examined to determine which APs did not complete the specified task
162 prior to the timeout.
163
164 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
165 instance.
166 @param[in] Procedure A pointer to the function to be run on
167 enabled APs of the system. See type
168 EFI_AP_PROCEDURE.
169 @param[in] SingleThread If TRUE, then all the enabled APs execute
170 the function specified by Procedure one by
171 one, in ascending order of processor handle
172 number. If FALSE, then all the enabled APs
173 execute the function specified by Procedure
174 simultaneously.
175 @param[in] WaitEvent The event created by the caller with CreateEvent()
176 service. If it is NULL, then execute in
177 blocking mode. BSP waits until all APs finish
178 or TimeoutInMicroseconds expires. If it's
179 not NULL, then execute in non-blocking mode.
180 BSP requests the function specified by
181 Procedure to be started on all the enabled
182 APs, and go on executing immediately. If
183 all return from Procedure, or TimeoutInMicroseconds
184 expires, this event is signaled. The BSP
185 can use the CheckEvent() or WaitForEvent()
186 services to check the state of event. Type
187 EFI_EVENT is defined in CreateEvent() in
188 the Unified Extensible Firmware Interface
189 Specification.
190 @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for
191 APs to return from Procedure, either for
192 blocking or non-blocking mode. Zero means
193 infinity. If the timeout expires before
194 all APs return from Procedure, then Procedure
195 on the failed APs is terminated. All enabled
196 APs are available for next function assigned
197 by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()
198 or EFI_MP_SERVICES_PROTOCOL.StartupThisAP().
199 If the timeout expires in blocking mode,
200 BSP returns EFI_TIMEOUT. If the timeout
201 expires in non-blocking mode, WaitEvent
202 is signaled with SignalEvent().
203 @param[in] ProcedureArgument The parameter passed into Procedure for
204 all APs.
205 @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise,
206 if all APs finish successfully, then its
207 content is set to NULL. If not all APs
208 finish before timeout expires, then its
209 content is set to address of the buffer
210 holding handle numbers of the failed APs.
211 The buffer is allocated by MP Service Protocol,
212 and it's the caller's responsibility to
213 free the buffer with FreePool() service.
214 In blocking mode, it is ready for consumption
215 when the call returns. In non-blocking mode,
216 it is ready when WaitEvent is signaled. The
217 list of failed CPU is terminated by
218 END_OF_CPU_LIST.
219
220 @retval EFI_SUCCESS In blocking mode, all APs have finished before
221 the timeout expired.
222 @retval EFI_SUCCESS In non-blocking mode, function has been dispatched
223 to all enabled APs.
224 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the
225 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was
226 signaled.
227 @retval EFI_DEVICE_ERROR Caller processor is AP.
228 @retval EFI_NOT_STARTED No enabled APs exist in the system.
229 @retval EFI_NOT_READY Any enabled APs are busy.
230 @retval EFI_TIMEOUT In blocking mode, the timeout expired before
231 all enabled APs have finished.
232 @retval EFI_INVALID_PARAMETER Procedure is NULL.
233
234 **/
235 EFI_STATUS
236 EFIAPI
237 StartupAllAPs (
238 IN EFI_MP_SERVICES_PROTOCOL *This,
239 IN EFI_AP_PROCEDURE Procedure,
240 IN BOOLEAN SingleThread,
241 IN EFI_EVENT WaitEvent OPTIONAL,
242 IN UINTN TimeoutInMicroseconds,
243 IN VOID *ProcedureArgument OPTIONAL,
244 OUT UINTN **FailedCpuList OPTIONAL
245 );
246
247 /**
248 This service lets the caller get one enabled AP to execute a caller-provided
249 function. The caller can request the BSP to either wait for the completion
250 of the AP or just proceed with the next task by using the EFI event mechanism.
251 See EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() for more details on non-blocking
252 execution support. This service may only be called from the BSP.
253
254 This function is used to dispatch one enabled AP to the function specified by
255 Procedure passing in the argument specified by ProcedureArgument. If WaitEvent
256 is NULL, execution is in blocking mode. The BSP waits until the AP finishes or
257 TimeoutInMicroSeconds expires. Otherwise, execution is in non-blocking mode.
258 BSP proceeds to the next task without waiting for the AP. If a non-blocking mode
259 is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled,
260 then EFI_UNSUPPORTED must be returned.
261
262 If the timeout specified by TimeoutInMicroseconds expires before the AP returns
263 from Procedure, then execution of Procedure by the AP is terminated. The AP is
264 available for subsequent calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() and
265 EFI_MP_SERVICES_PROTOCOL.StartupThisAP().
266
267 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
268 instance.
269 @param[in] Procedure A pointer to the function to be run on
270 enabled APs of the system. See type
271 EFI_AP_PROCEDURE.
272 @param[in] ProcessorNumber The handle number of the AP. The range is
273 from 0 to the total number of logical
274 processors minus 1. The total number of
275 logical processors can be retrieved by
276 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
277 @param[in] WaitEvent The event created by the caller with CreateEvent()
278 service. If it is NULL, then execute in
279 blocking mode. BSP waits until all APs finish
280 or TimeoutInMicroseconds expires. If it's
281 not NULL, then execute in non-blocking mode.
282 BSP requests the function specified by
283 Procedure to be started on all the enabled
284 APs, and go on executing immediately. If
285 all return from Procedure or TimeoutInMicroseconds
286 expires, this event is signaled. The BSP
287 can use the CheckEvent() or WaitForEvent()
288 services to check the state of event. Type
289 EFI_EVENT is defined in CreateEvent() in
290 the Unified Extensible Firmware Interface
291 Specification.
292 @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for
293 APs to return from Procedure, either for
294 blocking or non-blocking mode. Zero means
295 infinity. If the timeout expires before
296 all APs return from Procedure, then Procedure
297 on the failed APs is terminated. All enabled
298 APs are available for next function assigned
299 by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()
300 or EFI_MP_SERVICES_PROTOCOL.StartupThisAP().
301 If the timeout expires in blocking mode,
302 BSP returns EFI_TIMEOUT. If the timeout
303 expires in non-blocking mode, WaitEvent
304 is signaled with SignalEvent().
305 @param[in] ProcedureArgument The parameter passed into Procedure for
306 all APs.
307 @param[out] Finished If NULL, this parameter is ignored. In
308 blocking mode, this parameter is ignored.
309 In non-blocking mode, if AP returns from
310 Procedure before the timeout expires, its
311 content is set to TRUE. Otherwise, the
312 value is set to FALSE. The caller can
313 determine if the AP returned from Procedure
314 by evaluating this value.
315
316 @retval EFI_SUCCESS In blocking mode, specified AP finished before
317 the timeout expires.
318 @retval EFI_SUCCESS In non-blocking mode, the function has been
319 dispatched to specified AP.
320 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the
321 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was
322 signaled.
323 @retval EFI_DEVICE_ERROR The calling processor is an AP.
324 @retval EFI_TIMEOUT In blocking mode, the timeout expired before
325 the specified AP has finished.
326 @retval EFI_NOT_READY The specified AP is busy.
327 @retval EFI_NOT_FOUND The processor with the handle specified by
328 ProcessorNumber does not exist.
329 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.
330 @retval EFI_INVALID_PARAMETER Procedure is NULL.
331
332 **/
333 EFI_STATUS
334 EFIAPI
335 StartupThisAP (
336 IN EFI_MP_SERVICES_PROTOCOL *This,
337 IN EFI_AP_PROCEDURE Procedure,
338 IN UINTN ProcessorNumber,
339 IN EFI_EVENT WaitEvent OPTIONAL,
340 IN UINTN TimeoutInMicroseconds,
341 IN VOID *ProcedureArgument OPTIONAL,
342 OUT BOOLEAN *Finished OPTIONAL
343 );
344
345 /**
346 This service switches the requested AP to be the BSP from that point onward.
347 This service changes the BSP for all purposes. This call can only be performed
348 by the current BSP.
349
350 This service switches the requested AP to be the BSP from that point onward.
351 This service changes the BSP for all purposes. The new BSP can take over the
352 execution of the old BSP and continue seamlessly from where the old one left
353 off. This service may not be supported after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT
354 is signaled.
355
356 If the BSP cannot be switched prior to the return from this service, then
357 EFI_UNSUPPORTED must be returned.
358
359 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
360 @param[in] ProcessorNumber The handle number of AP that is to become the new
361 BSP. The range is from 0 to the total number of
362 logical processors minus 1. The total number of
363 logical processors can be retrieved by
364 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
365 @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an
366 enabled AP. Otherwise, it will be disabled.
367
368 @retval EFI_SUCCESS BSP successfully switched.
369 @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to
370 this service returning.
371 @retval EFI_UNSUPPORTED Switching the BSP is not supported.
372 @retval EFI_DEVICE_ERROR The calling processor is an AP.
373 @retval EFI_NOT_FOUND The processor with the handle specified by
374 ProcessorNumber does not exist.
375 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or
376 a disabled AP.
377 @retval EFI_NOT_READY The specified AP is busy.
378
379 **/
380 EFI_STATUS
381 EFIAPI
382 SwitchBSP (
383 IN EFI_MP_SERVICES_PROTOCOL *This,
384 IN UINTN ProcessorNumber,
385 IN BOOLEAN EnableOldBSP
386 );
387
388 /**
389 This service lets the caller enable or disable an AP from this point onward.
390 This service may only be called from the BSP.
391
392 This service allows the caller enable or disable an AP from this point onward.
393 The caller can optionally specify the health status of the AP by Health. If
394 an AP is being disabled, then the state of the disabled AP is implementation
395 dependent. If an AP is enabled, then the implementation must guarantee that a
396 complete initialization sequence is performed on the AP, so the AP is in a state
397 that is compatible with an MP operating system. This service may not be supported
398 after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled.
399
400 If the enable or disable AP operation cannot be completed prior to the return
401 from this service, then EFI_UNSUPPORTED must be returned.
402
403 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
404 @param[in] ProcessorNumber The handle number of AP that is to become the new
405 BSP. The range is from 0 to the total number of
406 logical processors minus 1. The total number of
407 logical processors can be retrieved by
408 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
409 @param[in] EnableAP Specifies the new state for the processor for
410 enabled, FALSE for disabled.
411 @param[in] HealthFlag If not NULL, a pointer to a value that specifies
412 the new health status of the AP. This flag
413 corresponds to StatusFlag defined in
414 EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only
415 the PROCESSOR_HEALTH_STATUS_BIT is used. All other
416 bits are ignored. If it is NULL, this parameter
417 is ignored.
418
419 @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.
420 @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed
421 prior to this service returning.
422 @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.
423 @retval EFI_DEVICE_ERROR The calling processor is an AP.
424 @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber
425 does not exist.
426 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.
427
428 **/
429 EFI_STATUS
430 EFIAPI
431 EnableDisableAP (
432 IN EFI_MP_SERVICES_PROTOCOL *This,
433 IN UINTN ProcessorNumber,
434 IN BOOLEAN EnableAP,
435 IN UINT32 *HealthFlag OPTIONAL
436 );
437
438 /**
439 This return the handle number for the calling processor. This service may be
440 called from the BSP and APs.
441
442 This service returns the processor handle number for the calling processor.
443 The returned value is in the range from 0 to the total number of logical
444 processors minus 1. The total number of logical processors can be retrieved
445 with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be
446 called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER
447 is returned. Otherwise, the current processors handle number is returned in
448 ProcessorNumber, and EFI_SUCCESS is returned.
449
450 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
451 @param[out] ProcessorNumber The handle number of AP that is to become the new
452 BSP. The range is from 0 to the total number of
453 logical processors minus 1. The total number of
454 logical processors can be retrieved by
455 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
456
457 @retval EFI_SUCCESS The current processor handle number was returned
458 in ProcessorNumber.
459 @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.
460
461 **/
462 EFI_STATUS
463 EFIAPI
464 WhoAmI (
465 IN EFI_MP_SERVICES_PROTOCOL *This,
466 OUT UINTN *ProcessorNumber
467 );
468
469 #endif // _CPU_MP_H_