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