2 MP initialize support functions for PEI phase.
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
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.
18 Get pointer to CPU MP Data structure.
20 @return The pointer to CPU MP Data structure.
27 CPU_MP_DATA
*CpuMpData
;
29 CpuMpData
= GetCpuMpDataFromGuidedHob ();
30 ASSERT (CpuMpData
!= NULL
);
35 Save the pointer to CPU MP Data structure.
37 @param[in] CpuMpData The pointer to CPU MP Data structure will be saved.
41 IN CPU_MP_DATA
*CpuMpData
46 // Build location of CPU MP DATA buffer in HOB
48 Data64
= (UINT64
) (UINTN
) CpuMpData
;
50 &mCpuInitMpLibHobGuid
,
58 Initialize global data for MP support.
60 @param[in] CpuMpData The pointer to CPU MP Data structure.
64 IN CPU_MP_DATA
*CpuMpData
68 SaveCpuMpData (CpuMpData
);
72 This service executes a caller provided function on all enabled APs.
74 @param[in] Procedure A pointer to the function to be run on
75 enabled APs of the system. See type
77 @param[in] SingleThread If TRUE, then all the enabled APs execute
78 the function specified by Procedure one by
79 one, in ascending order of processor handle
80 number. If FALSE, then all the enabled APs
81 execute the function specified by Procedure
83 @param[in] WaitEvent The event created by the caller with CreateEvent()
84 service. If it is NULL, then execute in
85 blocking mode. BSP waits until all APs finish
86 or TimeoutInMicroSeconds expires. If it's
87 not NULL, then execute in non-blocking mode.
88 BSP requests the function specified by
89 Procedure to be started on all the enabled
90 APs, and go on executing immediately. If
91 all return from Procedure, or TimeoutInMicroSeconds
92 expires, this event is signaled. The BSP
93 can use the CheckEvent() or WaitForEvent()
94 services to check the state of event. Type
95 EFI_EVENT is defined in CreateEvent() in
96 the Unified Extensible Firmware Interface
98 @param[in] TimeoutInMicrosecsond Indicates the time limit in microseconds for
99 APs to return from Procedure, either for
100 blocking or non-blocking mode. Zero means
101 infinity. If the timeout expires before
102 all APs return from Procedure, then Procedure
103 on the failed APs is terminated. All enabled
104 APs are available for next function assigned
105 by MpInitLibStartupAllAPs() or
106 MPInitLibStartupThisAP().
107 If the timeout expires in blocking mode,
108 BSP returns EFI_TIMEOUT. If the timeout
109 expires in non-blocking mode, WaitEvent
110 is signaled with SignalEvent().
111 @param[in] ProcedureArgument The parameter passed into Procedure for
113 @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise,
114 if all APs finish successfully, then its
115 content is set to NULL. If not all APs
116 finish before timeout expires, then its
117 content is set to address of the buffer
118 holding handle numbers of the failed APs.
119 The buffer is allocated by MP Initialization
120 library, and it's the caller's responsibility to
121 free the buffer with FreePool() service.
122 In blocking mode, it is ready for consumption
123 when the call returns. In non-blocking mode,
124 it is ready when WaitEvent is signaled. The
125 list of failed CPU is terminated by
128 @retval EFI_SUCCESS In blocking mode, all APs have finished before
130 @retval EFI_SUCCESS In non-blocking mode, function has been dispatched
132 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the
133 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was
135 @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not
137 @retval EFI_DEVICE_ERROR Caller processor is AP.
138 @retval EFI_NOT_STARTED No enabled APs exist in the system.
139 @retval EFI_NOT_READY Any enabled APs are busy.
140 @retval EFI_NOT_READY MP Initialize Library is not initialized.
141 @retval EFI_TIMEOUT In blocking mode, the timeout expired before
142 all enabled APs have finished.
143 @retval EFI_INVALID_PARAMETER Procedure is NULL.
148 MpInitLibStartupAllAPs (
149 IN EFI_AP_PROCEDURE Procedure
,
150 IN BOOLEAN SingleThread
,
151 IN EFI_EVENT WaitEvent OPTIONAL
,
152 IN UINTN TimeoutInMicroseconds
,
153 IN VOID
*ProcedureArgument OPTIONAL
,
154 OUT UINTN
**FailedCpuList OPTIONAL
157 return EFI_UNSUPPORTED
;
161 This service lets the caller get one enabled AP to execute a caller-provided
164 @param[in] Procedure A pointer to the function to be run on the
165 designated AP of the system. See type
167 @param[in] ProcessorNumber The handle number of the AP. The range is
168 from 0 to the total number of logical
169 processors minus 1. The total number of
170 logical processors can be retrieved by
171 MpInitLibGetNumberOfProcessors().
172 @param[in] WaitEvent The event created by the caller with CreateEvent()
173 service. If it is NULL, then execute in
174 blocking mode. BSP waits until this AP finish
175 or TimeoutInMicroSeconds expires. If it's
176 not NULL, then execute in non-blocking mode.
177 BSP requests the function specified by
178 Procedure to be started on this AP,
179 and go on executing immediately. If this AP
180 return from Procedure or TimeoutInMicroSeconds
181 expires, this event is signaled. The BSP
182 can use the CheckEvent() or WaitForEvent()
183 services to check the state of event. Type
184 EFI_EVENT is defined in CreateEvent() in
185 the Unified Extensible Firmware Interface
187 @param[in] TimeoutInMicrosecsond Indicates the time limit in microseconds for
188 this AP to finish this Procedure, either for
189 blocking or non-blocking mode. Zero means
190 infinity. If the timeout expires before
191 this AP returns from Procedure, then Procedure
192 on the AP is terminated. The
193 AP is available for next function assigned
194 by MpInitLibStartupAllAPs() or
195 MpInitLibStartupThisAP().
196 If the timeout expires in blocking mode,
197 BSP returns EFI_TIMEOUT. If the timeout
198 expires in non-blocking mode, WaitEvent
199 is signaled with SignalEvent().
200 @param[in] ProcedureArgument The parameter passed into Procedure on the
202 @param[out] Finished If NULL, this parameter is ignored. In
203 blocking mode, this parameter is ignored.
204 In non-blocking mode, if AP returns from
205 Procedure before the timeout expires, its
206 content is set to TRUE. Otherwise, the
207 value is set to FALSE. The caller can
208 determine if the AP returned from Procedure
209 by evaluating this value.
211 @retval EFI_SUCCESS In blocking mode, specified AP finished before
213 @retval EFI_SUCCESS In non-blocking mode, the function has been
214 dispatched to specified AP.
215 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the
216 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was
218 @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not
220 @retval EFI_DEVICE_ERROR The calling processor is an AP.
221 @retval EFI_TIMEOUT In blocking mode, the timeout expired before
222 the specified AP has finished.
223 @retval EFI_NOT_READY The specified AP is busy.
224 @retval EFI_NOT_READY MP Initialize Library is not initialized.
225 @retval EFI_NOT_FOUND The processor with the handle specified by
226 ProcessorNumber does not exist.
227 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.
228 @retval EFI_INVALID_PARAMETER Procedure is NULL.
233 MpInitLibStartupThisAP (
234 IN EFI_AP_PROCEDURE Procedure
,
235 IN UINTN ProcessorNumber
,
236 IN EFI_EVENT WaitEvent OPTIONAL
,
237 IN UINTN TimeoutInMicroseconds
,
238 IN VOID
*ProcedureArgument OPTIONAL
,
239 OUT BOOLEAN
*Finished OPTIONAL
242 return EFI_UNSUPPORTED
;
246 This service switches the requested AP to be the BSP from that point onward.
247 This service changes the BSP for all purposes. This call can only be performed
250 @param[in] ProcessorNumber The handle number of AP that is to become the new
251 BSP. The range is from 0 to the total number of
252 logical processors minus 1. The total number of
253 logical processors can be retrieved by
254 MpInitLibGetNumberOfProcessors().
255 @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an
256 enabled AP. Otherwise, it will be disabled.
258 @retval EFI_SUCCESS BSP successfully switched.
259 @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to
260 this service returning.
261 @retval EFI_UNSUPPORTED Switching the BSP is not supported.
262 @retval EFI_DEVICE_ERROR The calling processor is an AP.
263 @retval EFI_NOT_FOUND The processor with the handle specified by
264 ProcessorNumber does not exist.
265 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or
267 @retval EFI_NOT_READY The specified AP is busy.
268 @retval EFI_NOT_READY MP Initialize Library is not initialized.
274 IN UINTN ProcessorNumber
,
275 IN BOOLEAN EnableOldBSP
278 return EFI_UNSUPPORTED
;
282 This service lets the caller enable or disable an AP from this point onward.
283 This service may only be called from the BSP.
285 @param[in] ProcessorNumber The handle number of AP.
286 The range is from 0 to the total number of
287 logical processors minus 1. The total number of
288 logical processors can be retrieved by
289 MpInitLibGetNumberOfProcessors().
290 @param[in] EnableAP Specifies the new state for the processor for
291 enabled, FALSE for disabled.
292 @param[in] HealthFlag If not NULL, a pointer to a value that specifies
293 the new health status of the AP. This flag
294 corresponds to StatusFlag defined in
295 EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only
296 the PROCESSOR_HEALTH_STATUS_BIT is used. All other
297 bits are ignored. If it is NULL, this parameter
300 @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.
301 @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed
302 prior to this service returning.
303 @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.
304 @retval EFI_DEVICE_ERROR The calling processor is an AP.
305 @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber
307 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.
308 @retval EFI_NOT_READY MP Initialize Library is not initialized.
313 MpInitLibEnableDisableAP (
314 IN UINTN ProcessorNumber
,
316 IN UINT32
*HealthFlag OPTIONAL
319 return EFI_UNSUPPORTED
;