1 | /** @file
|
---|
2 | CPU DXE Module to produce CPU MP Protocol.
|
---|
3 |
|
---|
4 | Copyright (c) 2024, Loongson Technology Corporation Limited. All rights reserved.<BR>
|
---|
5 |
|
---|
6 | SPDX-License-Identifier: BSD-2-Clause-Patent
|
---|
7 | **/
|
---|
8 |
|
---|
9 | #include "CpuDxe.h"
|
---|
10 | #include "CpuMp.h"
|
---|
11 |
|
---|
12 | EFI_HANDLE mMpServiceHandle = NULL;
|
---|
13 | UINTN mNumberOfProcessors = 1;
|
---|
14 |
|
---|
15 | EFI_MP_SERVICES_PROTOCOL mMpServicesTemplate = {
|
---|
16 | GetNumberOfProcessors,
|
---|
17 | GetProcessorInfo,
|
---|
18 | StartupAllAPs,
|
---|
19 | StartupThisAP,
|
---|
20 | SwitchBSP,
|
---|
21 | EnableDisableAP,
|
---|
22 | WhoAmI
|
---|
23 | };
|
---|
24 |
|
---|
25 | /**
|
---|
26 | This service retrieves the number of logical processor in the platform
|
---|
27 | and the number of those logical processors that are enabled on this boot.
|
---|
28 | This service may only be called from the BSP.
|
---|
29 |
|
---|
30 | This function is used to retrieve the following information:
|
---|
31 | - The number of logical processors that are present in the system.
|
---|
32 | - The number of enabled logical processors in the system at the instant
|
---|
33 | this call is made.
|
---|
34 |
|
---|
35 | Because MP Service Protocol provides services to enable and disable processors
|
---|
36 | dynamically, the number of enabled logical processors may vary during the
|
---|
37 | course of a boot session.
|
---|
38 |
|
---|
39 | If this service is called from an AP, then EFI_DEVICE_ERROR is returned.
|
---|
40 | If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then
|
---|
41 | EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors
|
---|
42 | is returned in NumberOfProcessors, the number of currently enabled processor
|
---|
43 | is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.
|
---|
44 |
|
---|
45 | @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
|
---|
46 | instance.
|
---|
47 | @param[out] NumberOfProcessors Pointer to the total number of logical
|
---|
48 | processors in the system, including the BSP
|
---|
49 | and disabled APs.
|
---|
50 | @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical
|
---|
51 | processors that exist in system, including
|
---|
52 | the BSP.
|
---|
53 |
|
---|
54 | @retval EFI_SUCCESS The number of logical processors and enabled
|
---|
55 | logical processors was retrieved.
|
---|
56 | @retval EFI_DEVICE_ERROR The calling processor is an AP.
|
---|
57 | @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.
|
---|
58 | @retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL.
|
---|
59 |
|
---|
60 | **/
|
---|
61 | EFI_STATUS
|
---|
62 | EFIAPI
|
---|
63 | GetNumberOfProcessors (
|
---|
64 | IN EFI_MP_SERVICES_PROTOCOL *This,
|
---|
65 | OUT UINTN *NumberOfProcessors,
|
---|
66 | OUT UINTN *NumberOfEnabledProcessors
|
---|
67 | )
|
---|
68 | {
|
---|
69 | if ((NumberOfProcessors == NULL) || (NumberOfEnabledProcessors == NULL)) {
|
---|
70 | return EFI_INVALID_PARAMETER;
|
---|
71 | }
|
---|
72 |
|
---|
73 | return MpInitLibGetNumberOfProcessors (
|
---|
74 | NumberOfProcessors,
|
---|
75 | NumberOfEnabledProcessors
|
---|
76 | );
|
---|
77 | }
|
---|
78 |
|
---|
79 | /**
|
---|
80 | Gets detailed MP-related information on the requested processor at the
|
---|
81 | instant this call is made. This service may only be called from the BSP.
|
---|
82 |
|
---|
83 | This service retrieves detailed MP-related information about any processor
|
---|
84 | on the platform. Note the following:
|
---|
85 | - The processor information may change during the course of a boot session.
|
---|
86 | - The information presented here is entirely MP related.
|
---|
87 |
|
---|
88 | Information regarding the number of caches and their sizes, frequency of operation,
|
---|
89 | slot numbers is all considered platform-related information and is not provided
|
---|
90 | by this service.
|
---|
91 |
|
---|
92 | @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
|
---|
93 | instance.
|
---|
94 | @param[in] ProcessorNumber The handle number of processor.
|
---|
95 | @param[out] ProcessorInfoBuffer A pointer to the buffer where information for
|
---|
96 | the requested processor is deposited.
|
---|
97 |
|
---|
98 | @retval EFI_SUCCESS Processor information was returned.
|
---|
99 | @retval EFI_DEVICE_ERROR The calling processor is an AP.
|
---|
100 | @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.
|
---|
101 | @retval EFI_NOT_FOUND The processor with the handle specified by
|
---|
102 | ProcessorNumber does not exist in the platform.
|
---|
103 |
|
---|
104 | **/
|
---|
105 | EFI_STATUS
|
---|
106 | EFIAPI
|
---|
107 | GetProcessorInfo (
|
---|
108 | IN EFI_MP_SERVICES_PROTOCOL *This,
|
---|
109 | IN UINTN ProcessorNumber,
|
---|
110 | OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer
|
---|
111 | )
|
---|
112 | {
|
---|
113 | return MpInitLibGetProcessorInfo (ProcessorNumber, ProcessorInfoBuffer, NULL);
|
---|
114 | }
|
---|
115 |
|
---|
116 | /**
|
---|
117 | This service executes a caller provided function on all enabled APs. APs can
|
---|
118 | run either simultaneously or one at a time in sequence. This service supports
|
---|
119 | both blocking and non-blocking requests. The non-blocking requests use EFI
|
---|
120 | events so the BSP can detect when the APs have finished. This service may only
|
---|
121 | be called from the BSP.
|
---|
122 |
|
---|
123 | This function is used to dispatch all the enabled APs to the function specified
|
---|
124 | by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned
|
---|
125 | immediately and Procedure is not started on any AP.
|
---|
126 |
|
---|
127 | If SingleThread is TRUE, all the enabled APs execute the function specified by
|
---|
128 | Procedure one by one, in ascending order of processor handle number. Otherwise,
|
---|
129 | all the enabled APs execute the function specified by Procedure simultaneously.
|
---|
130 |
|
---|
131 | If WaitEvent is NULL, execution is in blocking mode. The BSP waits until all
|
---|
132 | APs finish or TimeoutInMicroseconds expires. Otherwise, execution is in non-blocking
|
---|
133 | mode, and the BSP returns from this service without waiting for APs. If a
|
---|
134 | non-blocking mode is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT
|
---|
135 | is signaled, then EFI_UNSUPPORTED must be returned.
|
---|
136 |
|
---|
137 | If the timeout specified by TimeoutInMicroseconds expires before all APs return
|
---|
138 | from Procedure, then Procedure on the failed APs is terminated. All enabled APs
|
---|
139 | are always available for further calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()
|
---|
140 | and EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). If FailedCpuList is not NULL, its
|
---|
141 | content points to the list of processor handle numbers in which Procedure was
|
---|
142 | terminated.
|
---|
143 |
|
---|
144 | Note: It is the responsibility of the consumer of the EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()
|
---|
145 | to make sure that the nature of the code that is executed on the BSP and the
|
---|
146 | dispatched APs is well controlled. The MP Services Protocol does not guarantee
|
---|
147 | that the Procedure function is MP-safe. Hence, the tasks that can be run in
|
---|
148 | parallel are limited to certain independent tasks and well-controlled exclusive
|
---|
149 | code. EFI services and protocols may not be called by APs unless otherwise
|
---|
150 | specified.
|
---|
151 |
|
---|
152 | In blocking execution mode, BSP waits until all APs finish or
|
---|
153 | TimeoutInMicroseconds expires.
|
---|
154 |
|
---|
155 | In non-blocking execution mode, BSP is freed to return to the caller and then
|
---|
156 | proceed to the next task without having to wait for APs. The following
|
---|
157 | sequence needs to occur in a non-blocking execution mode:
|
---|
158 |
|
---|
159 | -# The caller that intends to use this MP Services Protocol in non-blocking
|
---|
160 | mode creates WaitEvent by calling the EFI CreateEvent() service. The caller
|
---|
161 | invokes EFI_MP_SERVICES_PROTOCOL.StartupAllAPs(). If the parameter WaitEvent
|
---|
162 | is not NULL, then StartupAllAPs() executes in non-blocking mode. It requests
|
---|
163 | the function specified by Procedure to be started on all the enabled APs,
|
---|
164 | and releases the BSP to continue with other tasks.
|
---|
165 | -# The caller can use the CheckEvent() and WaitForEvent() services to check
|
---|
166 | the state of the WaitEvent created in step 1.
|
---|
167 | -# When the APs complete their task or TimeoutInMicroSecondss expires, the MP
|
---|
168 | Service signals WaitEvent by calling the EFI SignalEvent() function. If
|
---|
169 | FailedCpuList is not NULL, its content is available when WaitEvent is
|
---|
170 | signaled. If all APs returned from Procedure prior to the timeout, then
|
---|
171 | FailedCpuList is set to NULL. If not all APs return from Procedure before
|
---|
172 | the timeout, then FailedCpuList is filled in with the list of the failed
|
---|
173 | APs. The buffer is allocated by MP Service Protocol using AllocatePool().
|
---|
174 | It is the caller's responsibility to free the buffer with FreePool() service.
|
---|
175 | -# This invocation of SignalEvent() function informs the caller that invoked
|
---|
176 | EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() that either all the APs completed
|
---|
177 | the specified task or a timeout occurred. The contents of FailedCpuList
|
---|
178 | can be examined to determine which APs did not complete the specified task
|
---|
179 | prior to the timeout.
|
---|
180 |
|
---|
181 | @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
|
---|
182 | instance.
|
---|
183 | @param[in] Procedure A pointer to the function to be run on
|
---|
184 | enabled APs of the system. See type
|
---|
185 | EFI_AP_PROCEDURE.
|
---|
186 | @param[in] SingleThread If TRUE, then all the enabled APs execute
|
---|
187 | the function specified by Procedure one by
|
---|
188 | one, in ascending order of processor handle
|
---|
189 | number. If FALSE, then all the enabled APs
|
---|
190 | execute the function specified by Procedure
|
---|
191 | simultaneously.
|
---|
192 | @param[in] WaitEvent The event created by the caller with CreateEvent()
|
---|
193 | service. If it is NULL, then execute in
|
---|
194 | blocking mode. BSP waits until all APs finish
|
---|
195 | or TimeoutInMicroseconds expires. If it's
|
---|
196 | not NULL, then execute in non-blocking mode.
|
---|
197 | BSP requests the function specified by
|
---|
198 | Procedure to be started on all the enabled
|
---|
199 | APs, and go on executing immediately. If
|
---|
200 | all return from Procedure, or TimeoutInMicroseconds
|
---|
201 | expires, this event is signaled. The BSP
|
---|
202 | can use the CheckEvent() or WaitForEvent()
|
---|
203 | services to check the state of event. Type
|
---|
204 | EFI_EVENT is defined in CreateEvent() in
|
---|
205 | the Unified Extensible Firmware Interface
|
---|
206 | Specification.
|
---|
207 | @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for
|
---|
208 | APs to return from Procedure, either for
|
---|
209 | blocking or non-blocking mode. Zero means
|
---|
210 | infinity. If the timeout expires before
|
---|
211 | all APs return from Procedure, then Procedure
|
---|
212 | on the failed APs is terminated. All enabled
|
---|
213 | APs are available for next function assigned
|
---|
214 | by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()
|
---|
215 | or EFI_MP_SERVICES_PROTOCOL.StartupThisAP().
|
---|
216 | If the timeout expires in blocking mode,
|
---|
217 | BSP returns EFI_TIMEOUT. If the timeout
|
---|
218 | expires in non-blocking mode, WaitEvent
|
---|
219 | is signaled with SignalEvent().
|
---|
220 | @param[in] ProcedureArgument The parameter passed into Procedure for
|
---|
221 | all APs.
|
---|
222 | @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise,
|
---|
223 | if all APs finish successfully, then its
|
---|
224 | content is set to NULL. If not all APs
|
---|
225 | finish before timeout expires, then its
|
---|
226 | content is set to address of the buffer
|
---|
227 | holding handle numbers of the failed APs.
|
---|
228 | The buffer is allocated by MP Service Protocol,
|
---|
229 | and it's the caller's responsibility to
|
---|
230 | free the buffer with FreePool() service.
|
---|
231 | In blocking mode, it is ready for consumption
|
---|
232 | when the call returns. In non-blocking mode,
|
---|
233 | it is ready when WaitEvent is signaled. The
|
---|
234 | list of failed CPU is terminated by
|
---|
235 | END_OF_CPU_LIST.
|
---|
236 |
|
---|
237 | @retval EFI_SUCCESS In blocking mode, all APs have finished before
|
---|
238 | the timeout expired.
|
---|
239 | @retval EFI_SUCCESS In non-blocking mode, function has been dispatched
|
---|
240 | to all enabled APs.
|
---|
241 | @retval EFI_UNSUPPORTED A non-blocking mode request was made after the
|
---|
242 | UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was
|
---|
243 | signaled.
|
---|
244 | @retval EFI_DEVICE_ERROR Caller processor is AP.
|
---|
245 | @retval EFI_NOT_STARTED No enabled APs exist in the system.
|
---|
246 | @retval EFI_NOT_READY Any enabled APs are busy.
|
---|
247 | @retval EFI_TIMEOUT In blocking mode, the timeout expired before
|
---|
248 | all enabled APs have finished.
|
---|
249 | @retval EFI_INVALID_PARAMETER Procedure is NULL.
|
---|
250 |
|
---|
251 | **/
|
---|
252 | EFI_STATUS
|
---|
253 | EFIAPI
|
---|
254 | StartupAllAPs (
|
---|
255 | IN EFI_MP_SERVICES_PROTOCOL *This,
|
---|
256 | IN EFI_AP_PROCEDURE Procedure,
|
---|
257 | IN BOOLEAN SingleThread,
|
---|
258 | IN EFI_EVENT WaitEvent OPTIONAL,
|
---|
259 | IN UINTN TimeoutInMicroseconds,
|
---|
260 | IN VOID *ProcedureArgument OPTIONAL,
|
---|
261 | OUT UINTN **FailedCpuList OPTIONAL
|
---|
262 | )
|
---|
263 | {
|
---|
264 | return MpInitLibStartupAllAPs (
|
---|
265 | Procedure,
|
---|
266 | SingleThread,
|
---|
267 | WaitEvent,
|
---|
268 | TimeoutInMicroseconds,
|
---|
269 | ProcedureArgument,
|
---|
270 | FailedCpuList
|
---|
271 | );
|
---|
272 | }
|
---|
273 |
|
---|
274 | /**
|
---|
275 | This service lets the caller get one enabled AP to execute a caller-provided
|
---|
276 | function. The caller can request the BSP to either wait for the completion
|
---|
277 | of the AP or just proceed with the next task by using the EFI event mechanism.
|
---|
278 | See EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() for more details on non-blocking
|
---|
279 | execution support. This service may only be called from the BSP.
|
---|
280 |
|
---|
281 | This function is used to dispatch one enabled AP to the function specified by
|
---|
282 | Procedure passing in the argument specified by ProcedureArgument. If WaitEvent
|
---|
283 | is NULL, execution is in blocking mode. The BSP waits until the AP finishes or
|
---|
284 | TimeoutInMicroSecondss expires. Otherwise, execution is in non-blocking mode.
|
---|
285 | BSP proceeds to the next task without waiting for the AP. If a non-blocking mode
|
---|
286 | is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled,
|
---|
287 | then EFI_UNSUPPORTED must be returned.
|
---|
288 |
|
---|
289 | If the timeout specified by TimeoutInMicroseconds expires before the AP returns
|
---|
290 | from Procedure, then execution of Procedure by the AP is terminated. The AP is
|
---|
291 | available for subsequent calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() and
|
---|
292 | EFI_MP_SERVICES_PROTOCOL.StartupThisAP().
|
---|
293 |
|
---|
294 | @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
|
---|
295 | instance.
|
---|
296 | @param[in] Procedure A pointer to the function to be run on the
|
---|
297 | designated AP of the system. See type
|
---|
298 | EFI_AP_PROCEDURE.
|
---|
299 | @param[in] ProcessorNumber The handle number of the AP. The range is
|
---|
300 | from 0 to the total number of logical
|
---|
301 | processors minus 1. The total number of
|
---|
302 | logical processors can be retrieved by
|
---|
303 | EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
|
---|
304 | @param[in] WaitEvent The event created by the caller with CreateEvent()
|
---|
305 | service. If it is NULL, then execute in
|
---|
306 | blocking mode. BSP waits until this AP finish
|
---|
307 | or TimeoutInMicroSeconds expires. If it's
|
---|
308 | not NULL, then execute in non-blocking mode.
|
---|
309 | BSP requests the function specified by
|
---|
310 | Procedure to be started on this AP,
|
---|
311 | and go on executing immediately. If this AP
|
---|
312 | return from Procedure or TimeoutInMicroSeconds
|
---|
313 | expires, this event is signaled. The BSP
|
---|
314 | can use the CheckEvent() or WaitForEvent()
|
---|
315 | services to check the state of event. Type
|
---|
316 | EFI_EVENT is defined in CreateEvent() in
|
---|
317 | the Unified Extensible Firmware Interface
|
---|
318 | Specification.
|
---|
319 | @param[in] TimeoutInMicroseconds Indicates the time limit in microseconds for
|
---|
320 | this AP to finish this Procedure, either for
|
---|
321 | blocking or non-blocking mode. Zero means
|
---|
322 | infinity. If the timeout expires before
|
---|
323 | this AP returns from Procedure, then Procedure
|
---|
324 | on the AP is terminated. The
|
---|
325 | AP is available for next function assigned
|
---|
326 | by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()
|
---|
327 | or EFI_MP_SERVICES_PROTOCOL.StartupThisAP().
|
---|
328 | If the timeout expires in blocking mode,
|
---|
329 | BSP returns EFI_TIMEOUT. If the timeout
|
---|
330 | expires in non-blocking mode, WaitEvent
|
---|
331 | is signaled with SignalEvent().
|
---|
332 | @param[in] ProcedureArgument The parameter passed into Procedure on the
|
---|
333 | specified AP.
|
---|
334 | @param[out] Finished If NULL, this parameter is ignored. In
|
---|
335 | blocking mode, this parameter is ignored.
|
---|
336 | In non-blocking mode, if AP returns from
|
---|
337 | Procedure before the timeout expires, its
|
---|
338 | content is set to TRUE. Otherwise, the
|
---|
339 | value is set to FALSE. The caller can
|
---|
340 | determine if the AP returned from Procedure
|
---|
341 | by evaluating this value.
|
---|
342 |
|
---|
343 | @retval EFI_SUCCESS In blocking mode, specified AP finished before
|
---|
344 | the timeout expires.
|
---|
345 | @retval EFI_SUCCESS In non-blocking mode, the function has been
|
---|
346 | dispatched to specified AP.
|
---|
347 | @retval EFI_UNSUPPORTED A non-blocking mode request was made after the
|
---|
348 | UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was
|
---|
349 | signaled.
|
---|
350 | @retval EFI_DEVICE_ERROR The calling processor is an AP.
|
---|
351 | @retval EFI_TIMEOUT In blocking mode, the timeout expired before
|
---|
352 | the specified AP has finished.
|
---|
353 | @retval EFI_NOT_READY The specified AP is busy.
|
---|
354 | @retval EFI_NOT_FOUND The processor with the handle specified by
|
---|
355 | ProcessorNumber does not exist.
|
---|
356 | @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.
|
---|
357 | @retval EFI_INVALID_PARAMETER Procedure is NULL.
|
---|
358 |
|
---|
359 | **/
|
---|
360 | EFI_STATUS
|
---|
361 | EFIAPI
|
---|
362 | StartupThisAP (
|
---|
363 | IN EFI_MP_SERVICES_PROTOCOL *This,
|
---|
364 | IN EFI_AP_PROCEDURE Procedure,
|
---|
365 | IN UINTN ProcessorNumber,
|
---|
366 | IN EFI_EVENT WaitEvent OPTIONAL,
|
---|
367 | IN UINTN TimeoutInMicroseconds,
|
---|
368 | IN VOID *ProcedureArgument OPTIONAL,
|
---|
369 | OUT BOOLEAN *Finished OPTIONAL
|
---|
370 | )
|
---|
371 | {
|
---|
372 | return MpInitLibStartupThisAP (
|
---|
373 | Procedure,
|
---|
374 | ProcessorNumber,
|
---|
375 | WaitEvent,
|
---|
376 | TimeoutInMicroseconds,
|
---|
377 | ProcedureArgument,
|
---|
378 | Finished
|
---|
379 | );
|
---|
380 | }
|
---|
381 |
|
---|
382 | /**
|
---|
383 | This service switches the requested AP to be the BSP from that point onward.
|
---|
384 | This service changes the BSP for all purposes. This call can only be performed
|
---|
385 | by the current BSP.
|
---|
386 |
|
---|
387 | This service switches the requested AP to be the BSP from that point onward.
|
---|
388 | This service changes the BSP for all purposes. The new BSP can take over the
|
---|
389 | execution of the old BSP and continue seamlessly from where the old one left
|
---|
390 | off. This service may not be supported after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT
|
---|
391 | is signaled.
|
---|
392 |
|
---|
393 | If the BSP cannot be switched prior to the return from this service, then
|
---|
394 | EFI_UNSUPPORTED must be returned.
|
---|
395 |
|
---|
396 | @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
|
---|
397 | @param[in] ProcessorNumber The handle number of AP that is to become the new
|
---|
398 | BSP. The range is from 0 to the total number of
|
---|
399 | logical processors minus 1. The total number of
|
---|
400 | logical processors can be retrieved by
|
---|
401 | EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
|
---|
402 | @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an
|
---|
403 | enabled AP. Otherwise, it will be disabled.
|
---|
404 |
|
---|
405 | @retval EFI_SUCCESS BSP successfully switched.
|
---|
406 | @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to
|
---|
407 | this service returning.
|
---|
408 | @retval EFI_UNSUPPORTED Switching the BSP is not supported.
|
---|
409 | @retval EFI_DEVICE_ERROR The calling processor is an AP.
|
---|
410 | @retval EFI_NOT_FOUND The processor with the handle specified by
|
---|
411 | ProcessorNumber does not exist.
|
---|
412 | @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or
|
---|
413 | a disabled AP.
|
---|
414 | @retval EFI_NOT_READY The specified AP is busy.
|
---|
415 |
|
---|
416 | **/
|
---|
417 | EFI_STATUS
|
---|
418 | EFIAPI
|
---|
419 | SwitchBSP (
|
---|
420 | IN EFI_MP_SERVICES_PROTOCOL *This,
|
---|
421 | IN UINTN ProcessorNumber,
|
---|
422 | IN BOOLEAN EnableOldBSP
|
---|
423 | )
|
---|
424 | {
|
---|
425 | return MpInitLibSwitchBSP (ProcessorNumber, EnableOldBSP);
|
---|
426 | }
|
---|
427 |
|
---|
428 | /**
|
---|
429 | This service lets the caller enable or disable an AP from this point onward.
|
---|
430 | This service may only be called from the BSP.
|
---|
431 |
|
---|
432 | This service allows the caller enable or disable an AP from this point onward.
|
---|
433 | The caller can optionally specify the health status of the AP by Health. If
|
---|
434 | an AP is being disabled, then the state of the disabled AP is implementation
|
---|
435 | dependent. If an AP is enabled, then the implementation must guarantee that a
|
---|
436 | complete initialization sequence is performed on the AP, so the AP is in a state
|
---|
437 | that is compatible with an MP operating system. This service may not be supported
|
---|
438 | after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled.
|
---|
439 |
|
---|
440 | If the enable or disable AP operation cannot be completed prior to the return
|
---|
441 | from this service, then EFI_UNSUPPORTED must be returned.
|
---|
442 |
|
---|
443 | @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
|
---|
444 | @param[in] ProcessorNumber The handle number of AP.
|
---|
445 | The range is from 0 to the total number of
|
---|
446 | logical processors minus 1. The total number of
|
---|
447 | logical processors can be retrieved by
|
---|
448 | EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
|
---|
449 | @param[in] EnableAP Specifies the new state for the processor for
|
---|
450 | enabled, FALSE for disabled.
|
---|
451 | @param[in] HealthFlag If not NULL, a pointer to a value that specifies
|
---|
452 | the new health status of the AP. This flag
|
---|
453 | corresponds to StatusFlag defined in
|
---|
454 | EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only
|
---|
455 | the PROCESSOR_HEALTH_STATUS_BIT is used. All other
|
---|
456 | bits are ignored. If it is NULL, this parameter
|
---|
457 | is ignored.
|
---|
458 |
|
---|
459 | @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.
|
---|
460 | @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed
|
---|
461 | prior to this service returning.
|
---|
462 | @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.
|
---|
463 | @retval EFI_DEVICE_ERROR The calling processor is an AP.
|
---|
464 | @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber
|
---|
465 | does not exist.
|
---|
466 | @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.
|
---|
467 |
|
---|
468 | **/
|
---|
469 | EFI_STATUS
|
---|
470 | EFIAPI
|
---|
471 | EnableDisableAP (
|
---|
472 | IN EFI_MP_SERVICES_PROTOCOL *This,
|
---|
473 | IN UINTN ProcessorNumber,
|
---|
474 | IN BOOLEAN EnableAP,
|
---|
475 | IN UINT32 *HealthFlag OPTIONAL
|
---|
476 | )
|
---|
477 | {
|
---|
478 | return MpInitLibEnableDisableAP (ProcessorNumber, EnableAP, HealthFlag);
|
---|
479 | }
|
---|
480 |
|
---|
481 | /**
|
---|
482 | This return the handle number for the calling processor. This service may be
|
---|
483 | called from the BSP and APs.
|
---|
484 |
|
---|
485 | This service returns the processor handle number for the calling processor.
|
---|
486 | The returned value is in the range from 0 to the total number of logical
|
---|
487 | processors minus 1. The total number of logical processors can be retrieved
|
---|
488 | with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be
|
---|
489 | called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER
|
---|
490 | is returned. Otherwise, the current processors handle number is returned in
|
---|
491 | ProcessorNumber, and EFI_SUCCESS is returned.
|
---|
492 |
|
---|
493 | @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
|
---|
494 | @param[out] ProcessorNumber Pointer to the handle number of AP.
|
---|
495 | The range is from 0 to the total number of
|
---|
496 | logical processors minus 1. The total number of
|
---|
497 | logical processors can be retrieved by
|
---|
498 | EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
|
---|
499 |
|
---|
500 | @retval EFI_SUCCESS The current processor handle number was returned
|
---|
501 | in ProcessorNumber.
|
---|
502 | @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.
|
---|
503 |
|
---|
504 | **/
|
---|
505 | EFI_STATUS
|
---|
506 | EFIAPI
|
---|
507 | WhoAmI (
|
---|
508 | IN EFI_MP_SERVICES_PROTOCOL *This,
|
---|
509 | OUT UINTN *ProcessorNumber
|
---|
510 | )
|
---|
511 | {
|
---|
512 | return MpInitLibWhoAmI (ProcessorNumber);
|
---|
513 | }
|
---|
514 |
|
---|
515 | /**
|
---|
516 | Initialize Multi-processor support.
|
---|
517 | **/
|
---|
518 | VOID
|
---|
519 | InitializeMpSupport (
|
---|
520 | VOID
|
---|
521 | )
|
---|
522 | {
|
---|
523 | EFI_STATUS Status;
|
---|
524 | UINTN NumberOfProcessors;
|
---|
525 | UINTN NumberOfEnabledProcessors;
|
---|
526 |
|
---|
527 | //
|
---|
528 | // Wakeup APs to do initialization
|
---|
529 | //
|
---|
530 | Status = MpInitLibInitialize ();
|
---|
531 | ASSERT_EFI_ERROR (Status);
|
---|
532 |
|
---|
533 | MpInitLibGetNumberOfProcessors (&NumberOfProcessors, &NumberOfEnabledProcessors);
|
---|
534 | mNumberOfProcessors = NumberOfProcessors;
|
---|
535 | DEBUG ((DEBUG_INFO, "Detect CPU count: %d\n", mNumberOfProcessors));
|
---|
536 |
|
---|
537 | Status = gBS->InstallMultipleProtocolInterfaces (
|
---|
538 | &mMpServiceHandle,
|
---|
539 | &gEfiMpServiceProtocolGuid,
|
---|
540 | &mMpServicesTemplate,
|
---|
541 | NULL
|
---|
542 | );
|
---|
543 | ASSERT_EFI_ERROR (Status);
|
---|
544 | }
|
---|