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