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