]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Include/Library/MpInitLib.h
UefiCpuPkg: Make the comments align with the functions
[mirror_edk2.git] / UefiCpuPkg / Include / Library / MpInitLib.h
CommitLineData
87896d03
JF
1/** @file\r
2 Multiple-Processor initialization Library.\r
3\r
4 Copyright (c) 2016, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef __MP_INIT_LIB_H__\r
16#define __MP_INIT_LIB_H__\r
17\r
18#include <Ppi/SecPlatformInformation.h>\r
19#include <Protocol/MpService.h>\r
20\r
21/**\r
22 MP Initialize Library initialization.\r
23\r
24 This service will allocate AP reset vector and wakeup all APs to do APs\r
25 initialization.\r
26\r
27 This service must be invoked before all other MP Initialize Library\r
28 service are invoked.\r
29\r
30 @retval EFI_SUCCESS MP initialization succeeds.\r
31 @retval Others MP initialization fails.\r
32\r
33**/\r
34EFI_STATUS\r
35EFIAPI\r
36MpInitLibInitialize (\r
37 VOID\r
38 );\r
39\r
40/**\r
41 Retrieves the number of logical processor in the platform and the number of\r
42 those logical processors that are enabled on this boot. This service may only\r
43 be called from the BSP.\r
44\r
45 @param[out] NumberOfProcessors Pointer to the total number of logical\r
46 processors in the system, including the BSP\r
47 and disabled APs.\r
48 @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical\r
49 processors that exist in system, including\r
50 the BSP.\r
51\r
52 @retval EFI_SUCCESS The number of logical processors and enabled\r
53 logical processors was retrieved.\r
54 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
55 @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL and NumberOfEnabledProcessors\r
56 is NULL.\r
57 @retval EFI_NOT_READY MP Initialize Library is not initialized.\r
58\r
59**/\r
60EFI_STATUS\r
61EFIAPI\r
62MpInitLibGetNumberOfProcessors (\r
63 OUT UINTN *NumberOfProcessors, OPTIONAL\r
64 OUT UINTN *NumberOfEnabledProcessors OPTIONAL\r
65 );\r
66\r
67/**\r
68 Gets detailed MP-related information on the requested processor at the\r
69 instant this call is made. This service may only be called from the BSP.\r
70\r
71 @param[in] ProcessorNumber The handle number of processor.\r
72 @param[out] ProcessorInfoBuffer A pointer to the buffer where information for\r
73 the requested processor is deposited.\r
74 @param[out] HealthData Return processor health data.\r
75\r
76 @retval EFI_SUCCESS Processor information was returned.\r
77 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
78 @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.\r
79 @retval EFI_NOT_FOUND The processor with the handle specified by\r
80 ProcessorNumber does not exist in the platform.\r
81 @retval EFI_NOT_READY MP Initialize Library is not initialized.\r
82\r
83**/\r
84EFI_STATUS\r
85EFIAPI\r
86MpInitLibGetProcessorInfo (\r
87 IN UINTN ProcessorNumber,\r
88 OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer,\r
89 OUT EFI_HEALTH_FLAGS *HealthData OPTIONAL\r
90 );\r
91\r
92/**\r
93 This service executes a caller provided function on all enabled APs.\r
94\r
95 @param[in] Procedure A pointer to the function to be run on\r
96 enabled APs of the system. See type\r
97 EFI_AP_PROCEDURE.\r
98 @param[in] SingleThread If TRUE, then all the enabled APs execute\r
99 the function specified by Procedure one by\r
100 one, in ascending order of processor handle\r
101 number. If FALSE, then all the enabled APs\r
102 execute the function specified by Procedure\r
103 simultaneously.\r
104 @param[in] WaitEvent The event created by the caller with CreateEvent()\r
105 service. If it is NULL, then execute in\r
106 blocking mode. BSP waits until all APs finish\r
107 or TimeoutInMicroSeconds expires. If it's\r
108 not NULL, then execute in non-blocking mode.\r
109 BSP requests the function specified by\r
110 Procedure to be started on all the enabled\r
111 APs, and go on executing immediately. If\r
112 all return from Procedure, or TimeoutInMicroSeconds\r
113 expires, this event is signaled. The BSP\r
114 can use the CheckEvent() or WaitForEvent()\r
115 services to check the state of event. Type\r
116 EFI_EVENT is defined in CreateEvent() in\r
117 the Unified Extensible Firmware Interface\r
118 Specification.\r
367284e7 119 @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for\r
87896d03
JF
120 APs to return from Procedure, either for\r
121 blocking or non-blocking mode. Zero means\r
122 infinity. If the timeout expires before\r
123 all APs return from Procedure, then Procedure\r
124 on the failed APs is terminated. All enabled\r
125 APs are available for next function assigned\r
126 by MpInitLibStartupAllAPs() or\r
127 MPInitLibStartupThisAP().\r
128 If the timeout expires in blocking mode,\r
129 BSP returns EFI_TIMEOUT. If the timeout\r
130 expires in non-blocking mode, WaitEvent\r
131 is signaled with SignalEvent().\r
132 @param[in] ProcedureArgument The parameter passed into Procedure for\r
133 all APs.\r
134 @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise,\r
135 if all APs finish successfully, then its\r
136 content is set to NULL. If not all APs\r
137 finish before timeout expires, then its\r
138 content is set to address of the buffer\r
139 holding handle numbers of the failed APs.\r
140 The buffer is allocated by MP Initialization\r
141 library, and it's the caller's responsibility to\r
142 free the buffer with FreePool() service.\r
143 In blocking mode, it is ready for consumption\r
144 when the call returns. In non-blocking mode,\r
145 it is ready when WaitEvent is signaled. The\r
146 list of failed CPU is terminated by\r
147 END_OF_CPU_LIST.\r
148\r
149 @retval EFI_SUCCESS In blocking mode, all APs have finished before\r
150 the timeout expired.\r
151 @retval EFI_SUCCESS In non-blocking mode, function has been dispatched\r
152 to all enabled APs.\r
153 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the\r
154 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was\r
155 signaled.\r
156 @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not\r
157 supported.\r
158 @retval EFI_DEVICE_ERROR Caller processor is AP.\r
159 @retval EFI_NOT_STARTED No enabled APs exist in the system.\r
160 @retval EFI_NOT_READY Any enabled APs are busy.\r
161 @retval EFI_NOT_READY MP Initialize Library is not initialized.\r
162 @retval EFI_TIMEOUT In blocking mode, the timeout expired before\r
163 all enabled APs have finished.\r
164 @retval EFI_INVALID_PARAMETER Procedure is NULL.\r
165\r
166**/\r
167EFI_STATUS\r
168EFIAPI\r
169MpInitLibStartupAllAPs (\r
170 IN EFI_AP_PROCEDURE Procedure,\r
171 IN BOOLEAN SingleThread,\r
172 IN EFI_EVENT WaitEvent OPTIONAL,\r
173 IN UINTN TimeoutInMicroseconds,\r
174 IN VOID *ProcedureArgument OPTIONAL,\r
175 OUT UINTN **FailedCpuList OPTIONAL\r
176 );\r
177\r
178/**\r
179 This service lets the caller get one enabled AP to execute a caller-provided\r
180 function.\r
181\r
182 @param[in] Procedure A pointer to the function to be run on the\r
183 designated AP of the system. See type\r
184 EFI_AP_PROCEDURE.\r
185 @param[in] ProcessorNumber The handle number of the AP. The range is\r
186 from 0 to the total number of logical\r
187 processors minus 1. The total number of\r
188 logical processors can be retrieved by\r
189 MpInitLibGetNumberOfProcessors().\r
190 @param[in] WaitEvent The event created by the caller with CreateEvent()\r
191 service. If it is NULL, then execute in\r
192 blocking mode. BSP waits until this AP finish\r
193 or TimeoutInMicroSeconds expires. If it's\r
194 not NULL, then execute in non-blocking mode.\r
195 BSP requests the function specified by\r
196 Procedure to be started on this AP,\r
197 and go on executing immediately. If this AP\r
198 return from Procedure or TimeoutInMicroSeconds\r
199 expires, this event is signaled. The BSP\r
200 can use the CheckEvent() or WaitForEvent()\r
201 services to check the state of event. Type\r
202 EFI_EVENT is defined in CreateEvent() in\r
203 the Unified Extensible Firmware Interface\r
204 Specification.\r
367284e7 205 @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for\r
87896d03
JF
206 this AP to finish this Procedure, either for\r
207 blocking or non-blocking mode. Zero means\r
208 infinity. If the timeout expires before\r
209 this AP returns from Procedure, then Procedure\r
210 on the AP is terminated. The\r
211 AP is available for next function assigned\r
212 by MpInitLibStartupAllAPs() or\r
213 MpInitLibStartupThisAP().\r
214 If the timeout expires in blocking mode,\r
215 BSP returns EFI_TIMEOUT. If the timeout\r
216 expires in non-blocking mode, WaitEvent\r
217 is signaled with SignalEvent().\r
218 @param[in] ProcedureArgument The parameter passed into Procedure on the\r
219 specified AP.\r
220 @param[out] Finished If NULL, this parameter is ignored. In\r
221 blocking mode, this parameter is ignored.\r
222 In non-blocking mode, if AP returns from\r
223 Procedure before the timeout expires, its\r
224 content is set to TRUE. Otherwise, the\r
225 value is set to FALSE. The caller can\r
226 determine if the AP returned from Procedure\r
227 by evaluating this value.\r
228\r
229 @retval EFI_SUCCESS In blocking mode, specified AP finished before\r
230 the timeout expires.\r
231 @retval EFI_SUCCESS In non-blocking mode, the function has been\r
232 dispatched to specified AP.\r
233 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the\r
234 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was\r
235 signaled.\r
236 @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not\r
237 supported.\r
238 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
239 @retval EFI_TIMEOUT In blocking mode, the timeout expired before\r
240 the specified AP has finished.\r
241 @retval EFI_NOT_READY The specified AP is busy.\r
242 @retval EFI_NOT_READY MP Initialize Library is not initialized.\r
243 @retval EFI_NOT_FOUND The processor with the handle specified by\r
244 ProcessorNumber does not exist.\r
245 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.\r
246 @retval EFI_INVALID_PARAMETER Procedure is NULL.\r
247\r
248**/\r
249EFI_STATUS\r
250EFIAPI\r
251MpInitLibStartupThisAP (\r
252 IN EFI_AP_PROCEDURE Procedure,\r
253 IN UINTN ProcessorNumber,\r
254 IN EFI_EVENT WaitEvent OPTIONAL,\r
255 IN UINTN TimeoutInMicroseconds,\r
256 IN VOID *ProcedureArgument OPTIONAL,\r
257 OUT BOOLEAN *Finished OPTIONAL\r
258 );\r
259\r
260/**\r
261 This service switches the requested AP to be the BSP from that point onward.\r
262 This service changes the BSP for all purposes. This call can only be performed\r
263 by the current BSP.\r
264\r
265 @param[in] ProcessorNumber The handle number of AP that is to become the new\r
266 BSP. The range is from 0 to the total number of\r
267 logical processors minus 1. The total number of\r
268 logical processors can be retrieved by\r
269 MpInitLibGetNumberOfProcessors().\r
270 @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an\r
271 enabled AP. Otherwise, it will be disabled.\r
272\r
273 @retval EFI_SUCCESS BSP successfully switched.\r
274 @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to\r
275 this service returning.\r
276 @retval EFI_UNSUPPORTED Switching the BSP is not supported.\r
277 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
278 @retval EFI_NOT_FOUND The processor with the handle specified by\r
279 ProcessorNumber does not exist.\r
280 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or\r
281 a disabled AP.\r
282 @retval EFI_NOT_READY The specified AP is busy.\r
283 @retval EFI_NOT_READY MP Initialize Library is not initialized.\r
284\r
285**/\r
286EFI_STATUS\r
287EFIAPI\r
288MpInitLibSwitchBSP (\r
289 IN UINTN ProcessorNumber,\r
290 IN BOOLEAN EnableOldBSP\r
291 );\r
292\r
293/**\r
294 This service lets the caller enable or disable an AP from this point onward.\r
295 This service may only be called from the BSP.\r
296\r
297 @param[in] ProcessorNumber The handle number of AP.\r
298 The range is from 0 to the total number of\r
299 logical processors minus 1. The total number of\r
300 logical processors can be retrieved by\r
301 MpInitLibGetNumberOfProcessors().\r
302 @param[in] EnableAP Specifies the new state for the processor for\r
303 enabled, FALSE for disabled.\r
304 @param[in] HealthFlag If not NULL, a pointer to a value that specifies\r
305 the new health status of the AP. This flag\r
306 corresponds to StatusFlag defined in\r
307 EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only\r
308 the PROCESSOR_HEALTH_STATUS_BIT is used. All other\r
309 bits are ignored. If it is NULL, this parameter\r
310 is ignored.\r
311\r
312 @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.\r
313 @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed\r
314 prior to this service returning.\r
315 @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.\r
316 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
317 @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber\r
318 does not exist.\r
319 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.\r
320 @retval EFI_NOT_READY MP Initialize Library is not initialized.\r
321\r
322**/\r
323EFI_STATUS\r
324EFIAPI\r
325MpInitLibEnableDisableAP (\r
326 IN UINTN ProcessorNumber,\r
327 IN BOOLEAN EnableAP,\r
328 IN UINT32 *HealthFlag OPTIONAL\r
329 );\r
330\r
331/**\r
332 This return the handle number for the calling processor. This service may be\r
333 called from the BSP and APs.\r
334\r
335 @param[out] ProcessorNumber Pointer to the handle number of AP.\r
336 The range is from 0 to the total number of\r
337 logical processors minus 1. The total number of\r
338 logical processors can be retrieved by\r
339 MpInitLibGetNumberOfProcessors().\r
340\r
341 @retval EFI_SUCCESS The current processor handle number was returned\r
342 in ProcessorNumber.\r
343 @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.\r
344 @retval EFI_NOT_READY MP Initialize Library is not initialized.\r
345\r
346**/\r
347EFI_STATUS\r
348EFIAPI\r
349MpInitLibWhoAmI (\r
350 OUT UINTN *ProcessorNumber\r
351 );\r
352\r
353#endif\r