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