2 EDKII_PEI_MP_SERVICES2_PPI Implementation code.
4 Copyright (c) 2019, Intel Corporation. All rights reserved.<BR>
5 SPDX-License-Identifier: BSD-2-Clause-Patent
12 This service retrieves the number of logical processor in the platform
13 and the number of those logical processors that are enabled on this boot.
14 This service may only be called from the BSP.
16 This function is used to retrieve the following information:
17 - The number of logical processors that are present in the system.
18 - The number of enabled logical processors in the system at the instant
21 Because MP Service Ppi provides services to enable and disable processors
22 dynamically, the number of enabled logical processors may vary during the
23 course of a boot session.
25 If this service is called from an AP, then EFI_DEVICE_ERROR is returned.
26 If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then
27 EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors
28 is returned in NumberOfProcessors, the number of currently enabled processor
29 is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.
31 @param[in] This Pointer to this instance of the PPI.
32 @param[out] NumberOfProcessors Pointer to the total number of logical processors in
33 the system, including the BSP and disabled APs.
34 @param[out] NumberOfEnabledProcessors
35 Number of processors in the system that are enabled.
37 @retval EFI_SUCCESS The number of logical processors and enabled
38 logical processors was retrieved.
39 @retval EFI_DEVICE_ERROR The calling processor is an AP.
40 @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.
41 NumberOfEnabledProcessors is NULL.
45 EdkiiPeiGetNumberOfProcessors (
46 IN EDKII_PEI_MP_SERVICES2_PPI
*This
,
47 OUT UINTN
*NumberOfProcessors
,
48 OUT UINTN
*NumberOfEnabledProcessors
51 if ((NumberOfProcessors
== NULL
) || (NumberOfEnabledProcessors
== NULL
)) {
52 return EFI_INVALID_PARAMETER
;
55 return MpInitLibGetNumberOfProcessors (
57 NumberOfEnabledProcessors
62 Gets detailed MP-related information on the requested processor at the
63 instant this call is made. This service may only be called from the BSP.
65 This service retrieves detailed MP-related information about any processor
66 on the platform. Note the following:
67 - The processor information may change during the course of a boot session.
68 - The information presented here is entirely MP related.
70 Information regarding the number of caches and their sizes, frequency of operation,
71 slot numbers is all considered platform-related information and is not provided
74 @param[in] This Pointer to this instance of the PPI.
75 @param[in] ProcessorNumber Pointer to the total number of logical processors in
76 the system, including the BSP and disabled APs.
77 @param[out] ProcessorInfoBuffer Number of processors in the system that are enabled.
79 @retval EFI_SUCCESS Processor information was returned.
80 @retval EFI_DEVICE_ERROR The calling processor is an AP.
81 @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.
82 @retval EFI_NOT_FOUND The processor with the handle specified by
83 ProcessorNumber does not exist in the platform.
87 EdkiiPeiGetProcessorInfo (
88 IN EDKII_PEI_MP_SERVICES2_PPI
*This
,
89 IN UINTN ProcessorNumber
,
90 OUT EFI_PROCESSOR_INFORMATION
*ProcessorInfoBuffer
93 return MpInitLibGetProcessorInfo (ProcessorNumber
, ProcessorInfoBuffer
, NULL
);
97 This service executes a caller provided function on all enabled APs. APs can
98 run either simultaneously or one at a time in sequence. This service supports
99 both blocking requests only. This service may only
100 be called from the BSP.
102 This function is used to dispatch all the enabled APs to the function specified
103 by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned
104 immediately and Procedure is not started on any AP.
106 If SingleThread is TRUE, all the enabled APs execute the function specified by
107 Procedure one by one, in ascending order of processor handle number. Otherwise,
108 all the enabled APs execute the function specified by Procedure simultaneously.
110 If the timeout specified by TimeoutInMicroSeconds expires before all APs return
111 from Procedure, then Procedure on the failed APs is terminated. All enabled APs
112 are always available for further calls to EDKII_PEI_MP_SERVICES2_PPI.StartupAllAPs()
113 and EDKII_PEI_MP_SERVICES2_PPI.StartupThisAP(). If FailedCpuList is not NULL, its
114 content points to the list of processor handle numbers in which Procedure was
117 Note: It is the responsibility of the consumer of the EDKII_PEI_MP_SERVICES2_PPI.StartupAllAPs()
118 to make sure that the nature of the code that is executed on the BSP and the
119 dispatched APs is well controlled. The MP Services Ppi does not guarantee
120 that the Procedure function is MP-safe. Hence, the tasks that can be run in
121 parallel are limited to certain independent tasks and well-controlled exclusive
122 code. PEI services and Ppis may not be called by APs unless otherwise
125 In blocking execution mode, BSP waits until all APs finish or
126 TimeoutInMicroSeconds expires.
128 @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI instance.
129 @param[in] Procedure A pointer to the function to be run on enabled APs of
131 @param[in] SingleThread If TRUE, then all the enabled APs execute the function
132 specified by Procedure one by one, in ascending order
133 of processor handle number. If FALSE, then all the
134 enabled APs execute the function specified by Procedure
136 @param[in] TimeoutInMicroSeconds
137 Indicates the time limit in microseconds for APs to
138 return from Procedure, for blocking mode only. Zero
139 means infinity. If the timeout expires before all APs
140 return from Procedure, then Procedure on the failed APs
141 is terminated. All enabled APs are available for next
142 function assigned by EDKII_PEI_MP_SERVICES2_PPI.StartupAllAPs()
143 or EDKII_PEI_MP_SERVICES2_PPI.StartupThisAP(). If the
144 timeout expires in blocking mode, BSP returns
146 @param[in] ProcedureArgument The parameter passed into Procedure for all APs.
148 @retval EFI_SUCCESS In blocking mode, all APs have finished before the
150 @retval EFI_DEVICE_ERROR Caller processor is AP.
151 @retval EFI_NOT_STARTED No enabled APs exist in the system.
152 @retval EFI_NOT_READY Any enabled APs are busy.
153 @retval EFI_TIMEOUT In blocking mode, the timeout expired before all
154 enabled APs have finished.
155 @retval EFI_INVALID_PARAMETER Procedure is NULL.
159 EdkiiPeiStartupAllAPs (
160 IN EDKII_PEI_MP_SERVICES2_PPI
*This
,
161 IN EFI_AP_PROCEDURE Procedure
,
162 IN BOOLEAN SingleThread
,
163 IN UINTN TimeoutInMicroSeconds
,
164 IN VOID
*ProcedureArgument OPTIONAL
167 return MpInitLibStartupAllAPs (
171 TimeoutInMicroSeconds
,
178 This service lets the caller get one enabled AP to execute a caller-provided
179 function. The caller can request the BSP to wait for the completion
180 of the AP. This service may only be called from the BSP.
182 This function is used to dispatch one enabled AP to the function specified by
183 Procedure passing in the argument specified by ProcedureArgument.
184 The execution is in blocking mode. The BSP waits until the AP finishes or
185 TimeoutInMicroSecondss expires.
187 If the timeout specified by TimeoutInMicroseconds expires before the AP returns
188 from Procedure, then execution of Procedure by the AP is terminated. The AP is
189 available for subsequent calls to EDKII_PEI_MP_SERVICES2_PPI.StartupAllAPs() and
190 EDKII_PEI_MP_SERVICES2_PPI.StartupThisAP().
192 @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI instance.
193 @param[in] Procedure A pointer to the function to be run on enabled APs of
195 @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the
196 total number of logical processors minus 1. The total
197 number of logical processors can be retrieved by
198 EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfProcessors().
199 @param[in] TimeoutInMicroseconds
200 Indicates the time limit in microseconds for APs to
201 return from Procedure, for blocking mode only. Zero
202 means infinity. If the timeout expires before all APs
203 return from Procedure, then Procedure on the failed APs
204 is terminated. All enabled APs are available for next
205 function assigned by EDKII_PEI_MP_SERVICES2_PPI.StartupAllAPs()
206 or EDKII_PEI_MP_SERVICES2_PPI.StartupThisAP(). If the
207 timeout expires in blocking mode, BSP returns
209 @param[in] ProcedureArgument The parameter passed into Procedure for all APs.
211 @retval EFI_SUCCESS In blocking mode, specified AP finished before the
213 @retval EFI_DEVICE_ERROR The calling processor is an AP.
214 @retval EFI_TIMEOUT In blocking mode, the timeout expired before the
215 specified AP has finished.
216 @retval EFI_NOT_FOUND The processor with the handle specified by
217 ProcessorNumber does not exist.
218 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.
219 @retval EFI_INVALID_PARAMETER Procedure is NULL.
223 EdkiiPeiStartupThisAP (
224 IN EDKII_PEI_MP_SERVICES2_PPI
*This
,
225 IN EFI_AP_PROCEDURE Procedure
,
226 IN UINTN ProcessorNumber
,
227 IN UINTN TimeoutInMicroseconds
,
228 IN VOID
*ProcedureArgument OPTIONAL
231 return MpInitLibStartupThisAP (
235 TimeoutInMicroseconds
,
242 This service switches the requested AP to be the BSP from that point onward.
243 This service changes the BSP for all purposes. This call can only be performed
246 This service switches the requested AP to be the BSP from that point onward.
247 This service changes the BSP for all purposes. The new BSP can take over the
248 execution of the old BSP and continue seamlessly from where the old one left
251 If the BSP cannot be switched prior to the return from this service, then
252 EFI_UNSUPPORTED must be returned.
254 @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI instance.
255 @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the
256 total number of logical processors minus 1. The total
257 number of logical processors can be retrieved by
258 EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfProcessors().
259 @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an enabled
260 AP. Otherwise, it will be disabled.
262 @retval EFI_SUCCESS BSP successfully switched.
263 @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to this
265 @retval EFI_UNSUPPORTED Switching the BSP is not supported.
266 @retval EFI_DEVICE_ERROR The calling processor is an AP.
267 @retval EFI_NOT_FOUND The processor with the handle specified by
268 ProcessorNumber does not exist.
269 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or a disabled
271 @retval EFI_NOT_READY The specified AP is busy.
276 IN EDKII_PEI_MP_SERVICES2_PPI
*This
,
277 IN UINTN ProcessorNumber
,
278 IN BOOLEAN EnableOldBSP
281 return MpInitLibSwitchBSP (ProcessorNumber
, EnableOldBSP
);
285 This service lets the caller enable or disable an AP from this point onward.
286 This service may only be called from the BSP.
288 This service allows the caller enable or disable an AP from this point onward.
289 The caller can optionally specify the health status of the AP by Health. If
290 an AP is being disabled, then the state of the disabled AP is implementation
291 dependent. If an AP is enabled, then the implementation must guarantee that a
292 complete initialization sequence is performed on the AP, so the AP is in a state
293 that is compatible with an MP operating system.
295 If the enable or disable AP operation cannot be completed prior to the return
296 from this service, then EFI_UNSUPPORTED must be returned.
298 @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI instance.
299 @param[in] ProcessorNumber The handle number of the AP. The range is from 0 to the
300 total number of logical processors minus 1. The total
301 number of logical processors can be retrieved by
302 EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfProcessors().
303 @param[in] EnableAP Specifies the new state for the processor for enabled,
305 @param[in] HealthFlag If not NULL, a pointer to a value that specifies the
306 new health status of the AP. This flag corresponds to
307 StatusFlag defined in EDKII_PEI_MP_SERVICES2_PPI.GetProcessorInfo().
308 Only the PROCESSOR_HEALTH_STATUS_BIT is used. All other
309 bits are ignored. If it is NULL, this parameter is
312 @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.
313 @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed prior
314 to this service returning.
315 @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.
316 @retval EFI_DEVICE_ERROR The calling processor is an AP.
317 @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber
319 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.
323 EdkiiPeiEnableDisableAP (
324 IN EDKII_PEI_MP_SERVICES2_PPI
*This
,
325 IN UINTN ProcessorNumber
,
327 IN UINT32
*HealthFlag OPTIONAL
330 return MpInitLibEnableDisableAP (ProcessorNumber
, EnableAP
, HealthFlag
);
334 This return the handle number for the calling processor. This service may be
335 called from the BSP and APs.
337 This service returns the processor handle number for the calling processor.
338 The returned value is in the range from 0 to the total number of logical
339 processors minus 1. The total number of logical processors can be retrieved
340 with EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfProcessors(). This service may be
341 called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER
342 is returned. Otherwise, the current processors handle number is returned in
343 ProcessorNumber, and EFI_SUCCESS is returned.
345 @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI instance.
346 @param[out] ProcessorNumber The handle number of the AP. The range is from 0 to the
347 total number of logical processors minus 1. The total
348 number of logical processors can be retrieved by
349 EDKII_PEI_MP_SERVICES2_PPI.GetNumberOfProcessors().
351 @retval EFI_SUCCESS The current processor handle number was returned in
353 @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.
358 IN EDKII_PEI_MP_SERVICES2_PPI
*This
,
359 OUT UINTN
*ProcessorNumber
362 return MpInitLibWhoAmI (ProcessorNumber
);
366 This service executes a caller provided function on all enabled CPUs. CPUs can
367 run either simultaneously or one at a time in sequence. This service may only
368 be called from the BSP.
370 @param[in] This A pointer to the EDKII_PEI_MP_SERVICES2_PPI instance.
371 @param[in] Procedure A pointer to the function to be run on enabled APs of
373 @param[in] TimeoutInMicroSeconds
374 Indicates the time limit in microseconds for APs to
375 return from Procedure, for blocking mode only. Zero
376 means infinity. If the timeout expires in blocking
377 mode, BSP returns EFI_TIMEOUT.
378 @param[in] ProcedureArgument The parameter passed into Procedure for all CPUs.
380 @retval EFI_SUCCESS In blocking mode, all APs have finished before the
382 @retval EFI_DEVICE_ERROR Caller processor is AP.
383 @retval EFI_NOT_READY Any enabled APs are busy.
384 @retval EFI_TIMEOUT In blocking mode, the timeout expired before all
385 enabled APs have finished.
386 @retval EFI_INVALID_PARAMETER Procedure is NULL.
390 EdkiiPeiStartupAllCPUs (
391 IN EDKII_PEI_MP_SERVICES2_PPI
*This
,
392 IN EFI_AP_PROCEDURE Procedure
,
393 IN UINTN TimeoutInMicroSeconds
,
394 IN VOID
*ProcedureArgument OPTIONAL
397 return MpInitLibStartupAllCPUs (
399 TimeoutInMicroSeconds
,
405 // CPU MP2 PPI to be installed
407 EDKII_PEI_MP_SERVICES2_PPI mMpServices2Ppi
= {
408 EdkiiPeiGetNumberOfProcessors
,
409 EdkiiPeiGetProcessorInfo
,
410 EdkiiPeiStartupAllAPs
,
411 EdkiiPeiStartupThisAP
,
413 EdkiiPeiEnableDisableAP
,
415 EdkiiPeiStartupAllCPUs