]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/CpuMpPei/PeiMpServices.h
036d12e57a9c6b80cfe0343c92ae3d8ab477195e
[mirror_edk2.git] / UefiCpuPkg / CpuMpPei / PeiMpServices.h
1 /** @file
2 Functions prototype of Multiple Processor PPI services.
3
4 Copyright (c) 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 _PEI_MP_SERVICES_H_
16 #define _PEI_MP_SERVICES_H_
17
18 #include "CpuMpPei.h"
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 Ppi 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] PeiServices An indirect pointer to the PEI Services Table
42 published by the PEI Foundation.
43 @param[in] This Pointer to this instance of the PPI.
44 @param[out] NumberOfProcessors Pointer to the total number of logical processors in
45 the system, including the BSP and disabled APs.
46 @param[out] NumberOfEnabledProcessors
47 Number of processors in the system that are enabled.
48
49 @retval EFI_SUCCESS The number of logical processors and enabled
50 logical processors was retrieved.
51 @retval EFI_DEVICE_ERROR The calling processor is an AP.
52 @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.
53 NumberOfEnabledProcessors is NULL.
54 **/
55 EFI_STATUS
56 EFIAPI
57 PeiGetNumberOfProcessors (
58 IN CONST EFI_PEI_SERVICES **PeiServices,
59 IN EFI_PEI_MP_SERVICES_PPI *This,
60 OUT UINTN *NumberOfProcessors,
61 OUT UINTN *NumberOfEnabledProcessors
62 );
63
64 /**
65 Gets detailed MP-related information on the requested processor at the
66 instant this call is made. This service may only be called from the BSP.
67
68 This service retrieves detailed MP-related information about any processor
69 on the platform. Note the following:
70 - The processor information may change during the course of a boot session.
71 - The information presented here is entirely MP related.
72
73 Information regarding the number of caches and their sizes, frequency of operation,
74 slot numbers is all considered platform-related information and is not provided
75 by this service.
76
77 @param[in] PeiServices An indirect pointer to the PEI Services Table
78 published by the PEI Foundation.
79 @param[in] This Pointer to this instance of the PPI.
80 @param[in] ProcessorNumber Pointer to the total number of logical processors in
81 the system, including the BSP and disabled APs.
82 @param[out] ProcessorInfoBuffer Number of processors in the system that are enabled.
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 EFI_STATUS
91 EFIAPI
92 PeiGetProcessorInfo (
93 IN CONST EFI_PEI_SERVICES **PeiServices,
94 IN EFI_PEI_MP_SERVICES_PPI *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 requests only. This service may only
103 be called from the BSP.
104
105 This function is used to dispatch all the enabled APs to the function specified
106 by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned
107 immediately and Procedure is not started on any AP.
108
109 If SingleThread is TRUE, all the enabled APs execute the function specified by
110 Procedure one by one, in ascending order of processor handle number. Otherwise,
111 all the enabled APs execute the function specified by Procedure simultaneously.
112
113 If the timeout specified by TimeoutInMicroSeconds expires before all APs return
114 from Procedure, then Procedure on the failed APs is terminated. All enabled APs
115 are always available for further calls to EFI_PEI_MP_SERVICES_PPI.StartupAllAPs()
116 and EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If FailedCpuList is not NULL, its
117 content points to the list of processor handle numbers in which Procedure was
118 terminated.
119
120 Note: It is the responsibility of the consumer of the EFI_PEI_MP_SERVICES_PPI.StartupAllAPs()
121 to make sure that the nature of the code that is executed on the BSP and the
122 dispatched APs is well controlled. The MP Services Ppi does not guarantee
123 that the Procedure function is MP-safe. Hence, the tasks that can be run in
124 parallel are limited to certain independent tasks and well-controlled exclusive
125 code. PEI services and Ppis may not be called by APs unless otherwise
126 specified.
127
128 In blocking execution mode, BSP waits until all APs finish or
129 TimeoutInMicroSeconds expires.
130
131 @param[in] PeiServices An indirect pointer to the PEI Services Table
132 published by the PEI Foundation.
133 @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
134 @param[in] Procedure A pointer to the function to be run on enabled APs of
135 the system.
136 @param[in] SingleThread If TRUE, then all the enabled APs execute the function
137 specified by Procedure one by one, in ascending order
138 of processor handle number. If FALSE, then all the
139 enabled APs execute the function specified by Procedure
140 simultaneously.
141 @param[in] TimeoutInMicroSeconds
142 Indicates the time limit in microseconds for APs to
143 return from Procedure, for blocking mode only. Zero
144 means infinity. If the timeout expires before all APs
145 return from Procedure, then Procedure on the failed APs
146 is terminated. All enabled APs are available for next
147 function assigned by EFI_PEI_MP_SERVICES_PPI.StartupAllAPs()
148 or EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If the
149 timeout expires in blocking mode, BSP returns
150 EFI_TIMEOUT.
151 @param[in] ProcedureArgument The parameter passed into Procedure for all APs.
152
153 @retval EFI_SUCCESS In blocking mode, all APs have finished before the
154 timeout expired.
155 @retval EFI_DEVICE_ERROR Caller processor is AP.
156 @retval EFI_NOT_STARTED No enabled APs exist in the system.
157 @retval EFI_NOT_READY Any enabled APs are busy.
158 @retval EFI_TIMEOUT In blocking mode, the timeout expired before all
159 enabled APs have finished.
160 @retval EFI_INVALID_PARAMETER Procedure is NULL.
161 **/
162 EFI_STATUS
163 EFIAPI
164 PeiStartupAllAPs (
165 IN CONST EFI_PEI_SERVICES **PeiServices,
166 IN EFI_PEI_MP_SERVICES_PPI *This,
167 IN EFI_AP_PROCEDURE Procedure,
168 IN BOOLEAN SingleThread,
169 IN UINTN TimeoutInMicroSeconds,
170 IN VOID *ProcedureArgument OPTIONAL
171 );
172
173 /**
174 This service lets the caller get one enabled AP to execute a caller-provided
175 function. The caller can request the BSP to wait for the completion
176 of the AP. This service may only be called from the BSP.
177
178 This function is used to dispatch one enabled AP to the function specified by
179 Procedure passing in the argument specified by ProcedureArgument.
180 The execution is in blocking mode. The BSP waits until the AP finishes or
181 TimeoutInMicroSecondss expires.
182
183 If the timeout specified by TimeoutInMicroseconds expires before the AP returns
184 from Procedure, then execution of Procedure by the AP is terminated. The AP is
185 available for subsequent calls to EFI_PEI_MP_SERVICES_PPI.StartupAllAPs() and
186 EFI_PEI_MP_SERVICES_PPI.StartupThisAP().
187
188 @param[in] PeiServices An indirect pointer to the PEI Services Table
189 published by the PEI Foundation.
190 @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
191 @param[in] Procedure A pointer to the function to be run on enabled APs of
192 the system.
193 @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the
194 total number of logical processors minus 1. The total
195 number of logical processors can be retrieved by
196 EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors().
197 @param[in] TimeoutInMicroseconds
198 Indicates the time limit in microseconds for APs to
199 return from Procedure, for blocking mode only. Zero
200 means infinity. If the timeout expires before all APs
201 return from Procedure, then Procedure on the failed APs
202 is terminated. All enabled APs are available for next
203 function assigned by EFI_PEI_MP_SERVICES_PPI.StartupAllAPs()
204 or EFI_PEI_MP_SERVICES_PPI.StartupThisAP(). If the
205 timeout expires in blocking mode, BSP returns
206 EFI_TIMEOUT.
207 @param[in] ProcedureArgument The parameter passed into Procedure for all APs.
208
209 @retval EFI_SUCCESS In blocking mode, specified AP finished before the
210 timeout expires.
211 @retval EFI_DEVICE_ERROR The calling processor is an AP.
212 @retval EFI_TIMEOUT In blocking mode, the timeout expired before the
213 specified AP has finished.
214 @retval EFI_NOT_FOUND The processor with the handle specified by
215 ProcessorNumber does not exist.
216 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.
217 @retval EFI_INVALID_PARAMETER Procedure is NULL.
218 **/
219 EFI_STATUS
220 EFIAPI
221 PeiStartupThisAP (
222 IN CONST EFI_PEI_SERVICES **PeiServices,
223 IN EFI_PEI_MP_SERVICES_PPI *This,
224 IN EFI_AP_PROCEDURE Procedure,
225 IN UINTN ProcessorNumber,
226 IN UINTN TimeoutInMicroseconds,
227 IN VOID *ProcedureArgument OPTIONAL
228 );
229
230 /**
231 This service switches the requested AP to be the BSP from that point onward.
232 This service changes the BSP for all purposes. This call can only be performed
233 by the current BSP.
234
235 This service switches the requested AP to be the BSP from that point onward.
236 This service changes the BSP for all purposes. The new BSP can take over the
237 execution of the old BSP and continue seamlessly from where the old one left
238 off.
239
240 If the BSP cannot be switched prior to the return from this service, then
241 EFI_UNSUPPORTED must be returned.
242
243 @param[in] PeiServices An indirect pointer to the PEI Services Table
244 published by the PEI Foundation.
245 @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
246 @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the
247 total number of logical processors minus 1. The total
248 number of logical processors can be retrieved by
249 EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors().
250 @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an enabled
251 AP. Otherwise, it will be disabled.
252
253 @retval EFI_SUCCESS BSP successfully switched.
254 @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to this
255 service returning.
256 @retval EFI_UNSUPPORTED Switching the BSP is not supported.
257 @retval EFI_SUCCESS The calling processor is an AP.
258 @retval EFI_NOT_FOUND The processor with the handle specified by
259 ProcessorNumber does not exist.
260 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or a disabled
261 AP.
262 @retval EFI_NOT_READY The specified AP is busy.
263 **/
264 EFI_STATUS
265 EFIAPI
266 PeiSwitchBSP (
267 IN CONST EFI_PEI_SERVICES **PeiServices,
268 IN EFI_PEI_MP_SERVICES_PPI *This,
269 IN UINTN ProcessorNumber,
270 IN BOOLEAN EnableOldBSP
271 );
272
273 /**
274 This service lets the caller enable or disable an AP from this point onward.
275 This service may only be called from the BSP.
276
277 This service allows the caller enable or disable an AP from this point onward.
278 The caller can optionally specify the health status of the AP by Health. If
279 an AP is being disabled, then the state of the disabled AP is implementation
280 dependent. If an AP is enabled, then the implementation must guarantee that a
281 complete initialization sequence is performed on the AP, so the AP is in a state
282 that is compatible with an MP operating system.
283
284 If the enable or disable AP operation cannot be completed prior to the return
285 from this service, then EFI_UNSUPPORTED must be returned.
286
287 @param[in] PeiServices An indirect pointer to the PEI Services Table
288 published by the PEI Foundation.
289 @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
290 @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the
291 total number of logical processors minus 1. The total
292 number of logical processors can be retrieved by
293 EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors().
294 @param[in] EnableAP Specifies the new state for the processor for enabled,
295 FALSE for disabled.
296 @param[in] HealthFlag If not NULL, a pointer to a value that specifies the
297 new health status of the AP. This flag corresponds to
298 StatusFlag defined in EFI_PEI_MP_SERVICES_PPI.GetProcessorInfo().
299 Only the PROCESSOR_HEALTH_STATUS_BIT is used. All other
300 bits are ignored. If it is NULL, this parameter is
301 ignored.
302
303 @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.
304 @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed prior
305 to this service returning.
306 @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.
307 @retval EFI_DEVICE_ERROR The calling processor is an AP.
308 @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber
309 does not exist.
310 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.
311 **/
312 EFI_STATUS
313 EFIAPI
314 PeiEnableDisableAP (
315 IN CONST EFI_PEI_SERVICES **PeiServices,
316 IN EFI_PEI_MP_SERVICES_PPI *This,
317 IN UINTN ProcessorNumber,
318 IN BOOLEAN EnableAP,
319 IN UINT32 *HealthFlag OPTIONAL
320 );
321
322 /**
323 This return the handle number for the calling processor. This service may be
324 called from the BSP and APs.
325
326 This service returns the processor handle number for the calling processor.
327 The returned value is in the range from 0 to the total number of logical
328 processors minus 1. The total number of logical processors can be retrieved
329 with EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors(). This service may be
330 called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER
331 is returned. Otherwise, the current processors handle number is returned in
332 ProcessorNumber, and EFI_SUCCESS is returned.
333
334 @param[in] PeiServices An indirect pointer to the PEI Services Table
335 published by the PEI Foundation.
336 @param[in] This A pointer to the EFI_PEI_MP_SERVICES_PPI instance.
337 @param[out] ProcessorNumber The handle number of the AP. The range is from 0 to the
338 total number of logical processors minus 1. The total
339 number of logical processors can be retrieved by
340 EFI_PEI_MP_SERVICES_PPI.GetNumberOfProcessors().
341
342 @retval EFI_SUCCESS The current processor handle number was returned in
343 ProcessorNumber.
344 @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.
345 **/
346 EFI_STATUS
347 EFIAPI
348 PeiWhoAmI (
349 IN CONST EFI_PEI_SERVICES **PeiServices,
350 IN EFI_PEI_MP_SERVICES_PPI *This,
351 OUT UINTN *ProcessorNumber
352 );
353
354 #endif