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