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