]> git.proxmox.com Git - mirror_edk2.git/blame - UefiCpuPkg/Library/MpInitLib/PeiMpLib.c
UefiCpuPkg/MpInitLib: Save CPU MP Data pointer
[mirror_edk2.git] / UefiCpuPkg / Library / MpInitLib / PeiMpLib.c
CommitLineData
3e8ad6bd
JF
1/** @file\r
2 MP initialize support functions for PEI phase.\r
3\r
4 Copyright (c) 2016, 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#include "MpLib.h"\r
16\r
93ca4c0f
JF
17/**\r
18 Get pointer to CPU MP Data structure.\r
19\r
20 @return The pointer to CPU MP Data structure.\r
21**/\r
22CPU_MP_DATA *\r
23GetCpuMpData (\r
24 VOID\r
25 )\r
26{\r
27 CPU_MP_DATA *CpuMpData;\r
28\r
29 CpuMpData = GetCpuMpDataFromGuidedHob ();\r
30 ASSERT (CpuMpData != NULL);\r
31 return CpuMpData;\r
32}\r
33\r
34/**\r
35 Save the pointer to CPU MP Data structure.\r
36\r
37 @param[in] CpuMpData The pointer to CPU MP Data structure will be saved.\r
38**/\r
39VOID\r
40SaveCpuMpData (\r
41 IN CPU_MP_DATA *CpuMpData\r
42 )\r
43{\r
44 UINT64 Data64;\r
45 //\r
46 // Build location of CPU MP DATA buffer in HOB\r
47 //\r
48 Data64 = (UINT64) (UINTN) CpuMpData;\r
49 BuildGuidDataHob (\r
50 &mCpuInitMpLibHobGuid,\r
51 (VOID *) &Data64,\r
52 sizeof (UINT64)\r
53 );\r
54}\r
55\r
56\r
57/**\r
58 Initialize global data for MP support.\r
59\r
60 @param[in] CpuMpData The pointer to CPU MP Data structure.\r
61**/\r
62VOID\r
63InitMpGlobalData (\r
64 IN CPU_MP_DATA *CpuMpData\r
65 )\r
66{\r
67\r
68 SaveCpuMpData (CpuMpData);\r
69}\r
70\r
3e8ad6bd
JF
71/**\r
72 This service executes a caller provided function on all enabled APs.\r
73\r
74 @param[in] Procedure A pointer to the function to be run on\r
75 enabled APs of the system. See type\r
76 EFI_AP_PROCEDURE.\r
77 @param[in] SingleThread If TRUE, then all the enabled APs execute\r
78 the function specified by Procedure one by\r
79 one, in ascending order of processor handle\r
80 number. If FALSE, then all the enabled APs\r
81 execute the function specified by Procedure\r
82 simultaneously.\r
83 @param[in] WaitEvent The event created by the caller with CreateEvent()\r
84 service. If it is NULL, then execute in\r
85 blocking mode. BSP waits until all APs finish\r
86 or TimeoutInMicroSeconds expires. If it's\r
87 not NULL, then execute in non-blocking mode.\r
88 BSP requests the function specified by\r
89 Procedure to be started on all the enabled\r
90 APs, and go on executing immediately. If\r
91 all return from Procedure, or TimeoutInMicroSeconds\r
92 expires, this event is signaled. The BSP\r
93 can use the CheckEvent() or WaitForEvent()\r
94 services to check the state of event. Type\r
95 EFI_EVENT is defined in CreateEvent() in\r
96 the Unified Extensible Firmware Interface\r
97 Specification.\r
98 @param[in] TimeoutInMicrosecsond Indicates the time limit in microseconds for\r
99 APs to return from Procedure, either for\r
100 blocking or non-blocking mode. Zero means\r
101 infinity. If the timeout expires before\r
102 all APs return from Procedure, then Procedure\r
103 on the failed APs is terminated. All enabled\r
104 APs are available for next function assigned\r
105 by MpInitLibStartupAllAPs() or\r
106 MPInitLibStartupThisAP().\r
107 If the timeout expires in blocking mode,\r
108 BSP returns EFI_TIMEOUT. If the timeout\r
109 expires in non-blocking mode, WaitEvent\r
110 is signaled with SignalEvent().\r
111 @param[in] ProcedureArgument The parameter passed into Procedure for\r
112 all APs.\r
113 @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise,\r
114 if all APs finish successfully, then its\r
115 content is set to NULL. If not all APs\r
116 finish before timeout expires, then its\r
117 content is set to address of the buffer\r
118 holding handle numbers of the failed APs.\r
119 The buffer is allocated by MP Initialization\r
120 library, and it's the caller's responsibility to\r
121 free the buffer with FreePool() service.\r
122 In blocking mode, it is ready for consumption\r
123 when the call returns. In non-blocking mode,\r
124 it is ready when WaitEvent is signaled. The\r
125 list of failed CPU is terminated by\r
126 END_OF_CPU_LIST.\r
127\r
128 @retval EFI_SUCCESS In blocking mode, all APs have finished before\r
129 the timeout expired.\r
130 @retval EFI_SUCCESS In non-blocking mode, function has been dispatched\r
131 to all enabled APs.\r
132 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the\r
133 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was\r
134 signaled.\r
135 @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not\r
136 supported.\r
137 @retval EFI_DEVICE_ERROR Caller processor is AP.\r
138 @retval EFI_NOT_STARTED No enabled APs exist in the system.\r
139 @retval EFI_NOT_READY Any enabled APs are busy.\r
140 @retval EFI_NOT_READY MP Initialize Library is not initialized.\r
141 @retval EFI_TIMEOUT In blocking mode, the timeout expired before\r
142 all enabled APs have finished.\r
143 @retval EFI_INVALID_PARAMETER Procedure is NULL.\r
144\r
145**/\r
146EFI_STATUS\r
147EFIAPI\r
148MpInitLibStartupAllAPs (\r
149 IN EFI_AP_PROCEDURE Procedure,\r
150 IN BOOLEAN SingleThread,\r
151 IN EFI_EVENT WaitEvent OPTIONAL,\r
152 IN UINTN TimeoutInMicroseconds,\r
153 IN VOID *ProcedureArgument OPTIONAL,\r
154 OUT UINTN **FailedCpuList OPTIONAL\r
155 )\r
156{\r
157 return EFI_UNSUPPORTED;\r
158}\r
159\r
160/**\r
161 This service lets the caller get one enabled AP to execute a caller-provided\r
162 function.\r
163\r
164 @param[in] Procedure A pointer to the function to be run on the\r
165 designated AP of the system. See type\r
166 EFI_AP_PROCEDURE.\r
167 @param[in] ProcessorNumber The handle number of the AP. The range is\r
168 from 0 to the total number of logical\r
169 processors minus 1. The total number of\r
170 logical processors can be retrieved by\r
171 MpInitLibGetNumberOfProcessors().\r
172 @param[in] WaitEvent The event created by the caller with CreateEvent()\r
173 service. If it is NULL, then execute in\r
174 blocking mode. BSP waits until this AP finish\r
175 or TimeoutInMicroSeconds expires. If it's\r
176 not NULL, then execute in non-blocking mode.\r
177 BSP requests the function specified by\r
178 Procedure to be started on this AP,\r
179 and go on executing immediately. If this AP\r
180 return from Procedure or TimeoutInMicroSeconds\r
181 expires, this event is signaled. The BSP\r
182 can use the CheckEvent() or WaitForEvent()\r
183 services to check the state of event. Type\r
184 EFI_EVENT is defined in CreateEvent() in\r
185 the Unified Extensible Firmware Interface\r
186 Specification.\r
187 @param[in] TimeoutInMicrosecsond Indicates the time limit in microseconds for\r
188 this AP to finish this Procedure, either for\r
189 blocking or non-blocking mode. Zero means\r
190 infinity. If the timeout expires before\r
191 this AP returns from Procedure, then Procedure\r
192 on the AP is terminated. The\r
193 AP is available for next function assigned\r
194 by MpInitLibStartupAllAPs() or\r
195 MpInitLibStartupThisAP().\r
196 If the timeout expires in blocking mode,\r
197 BSP returns EFI_TIMEOUT. If the timeout\r
198 expires in non-blocking mode, WaitEvent\r
199 is signaled with SignalEvent().\r
200 @param[in] ProcedureArgument The parameter passed into Procedure on the\r
201 specified AP.\r
202 @param[out] Finished If NULL, this parameter is ignored. In\r
203 blocking mode, this parameter is ignored.\r
204 In non-blocking mode, if AP returns from\r
205 Procedure before the timeout expires, its\r
206 content is set to TRUE. Otherwise, the\r
207 value is set to FALSE. The caller can\r
208 determine if the AP returned from Procedure\r
209 by evaluating this value.\r
210\r
211 @retval EFI_SUCCESS In blocking mode, specified AP finished before\r
212 the timeout expires.\r
213 @retval EFI_SUCCESS In non-blocking mode, the function has been\r
214 dispatched to specified AP.\r
215 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the\r
216 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was\r
217 signaled.\r
218 @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not\r
219 supported.\r
220 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
221 @retval EFI_TIMEOUT In blocking mode, the timeout expired before\r
222 the specified AP has finished.\r
223 @retval EFI_NOT_READY The specified AP is busy.\r
224 @retval EFI_NOT_READY MP Initialize Library is not initialized.\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
230**/\r
231EFI_STATUS\r
232EFIAPI\r
233MpInitLibStartupThisAP (\r
234 IN EFI_AP_PROCEDURE Procedure,\r
235 IN UINTN ProcessorNumber,\r
236 IN EFI_EVENT WaitEvent OPTIONAL,\r
237 IN UINTN TimeoutInMicroseconds,\r
238 IN VOID *ProcedureArgument OPTIONAL,\r
239 OUT BOOLEAN *Finished OPTIONAL\r
240 )\r
241{\r
242 return EFI_UNSUPPORTED;\r
243}\r
244\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. This call can only be performed\r
248 by the current BSP.\r
249\r
250 @param[in] ProcessorNumber The handle number of AP that is to become the new\r
251 BSP. The range is from 0 to the total number of\r
252 logical processors minus 1. The total number of\r
253 logical processors can be retrieved by\r
254 MpInitLibGetNumberOfProcessors().\r
255 @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an\r
256 enabled AP. Otherwise, it will be disabled.\r
257\r
258 @retval EFI_SUCCESS BSP successfully switched.\r
259 @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to\r
260 this service returning.\r
261 @retval EFI_UNSUPPORTED Switching the BSP is not supported.\r
262 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
263 @retval EFI_NOT_FOUND The processor with the handle specified by\r
264 ProcessorNumber does not exist.\r
265 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or\r
266 a disabled AP.\r
267 @retval EFI_NOT_READY The specified AP is busy.\r
268 @retval EFI_NOT_READY MP Initialize Library is not initialized.\r
269\r
270**/\r
271EFI_STATUS\r
272EFIAPI\r
273MpInitLibSwitchBSP (\r
274 IN UINTN ProcessorNumber,\r
275 IN BOOLEAN EnableOldBSP\r
276 )\r
277{\r
278 return EFI_UNSUPPORTED;\r
279}\r
280\r
281/**\r
282 This service lets the caller enable or disable an AP from this point onward.\r
283 This service may only be called from the BSP.\r
284\r
285 @param[in] ProcessorNumber The handle number of AP.\r
286 The range is from 0 to the total number of\r
287 logical processors minus 1. The total number of\r
288 logical processors can be retrieved by\r
289 MpInitLibGetNumberOfProcessors().\r
290 @param[in] EnableAP Specifies the new state for the processor for\r
291 enabled, FALSE for disabled.\r
292 @param[in] HealthFlag If not NULL, a pointer to a value that specifies\r
293 the new health status of the AP. This flag\r
294 corresponds to StatusFlag defined in\r
295 EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only\r
296 the PROCESSOR_HEALTH_STATUS_BIT is used. All other\r
297 bits are ignored. If it is NULL, this parameter\r
298 is ignored.\r
299\r
300 @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.\r
301 @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed\r
302 prior to this service returning.\r
303 @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.\r
304 @retval EFI_DEVICE_ERROR The calling processor is an AP.\r
305 @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber\r
306 does not exist.\r
307 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.\r
308 @retval EFI_NOT_READY MP Initialize Library is not initialized.\r
309\r
310**/\r
311EFI_STATUS\r
312EFIAPI\r
313MpInitLibEnableDisableAP (\r
314 IN UINTN ProcessorNumber,\r
315 IN BOOLEAN EnableAP,\r
316 IN UINT32 *HealthFlag OPTIONAL\r
317 )\r
318{\r
319 return EFI_UNSUPPORTED;\r
320}\r
321\r
322\r