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