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