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