2 Construct MP Services Protocol on top of the EMU Thread protocol.
3 This code makes APs show up in the emulator. PcdEmuApCount is the
4 number of APs the emulator should produce.
6 The MP Services Protocol provides a generalized way of performing following tasks:
7 - Retrieving information of multi-processor environment and MP-related status of
9 - Dispatching user-provided function to APs.
10 - Maintain MP-related processor status.
12 The MP Services Protocol must be produced on any system with more than one logical
15 The Protocol is available only during boot time.
17 MP Services Protocol is hardware-independent. Most of the logic of this protocol
18 is architecturally neutral. It abstracts the multi-processor environment and
19 status of processors, and provides interfaces to retrieve information, maintain,
22 MP Services Protocol may be consumed by ACPI module. The ACPI module may use this
23 protocol to retrieve data that are needed for an MP platform and report them to OS.
24 MP Services Protocol may also be used to program and configure processors, such
25 as MTRR synchronization for memory space attributes setting in DXE Services.
26 MP Services Protocol may be used by non-CPU DXE drivers to speed up platform boot
27 by taking advantage of the processing capabilities of the APs, for example, using
28 APs to help test system memory in parallel with other device initialization.
29 Diagnostics applications may also use this protocol for multi-processor.
31 Copyright (c) 2006 - 2011, Intel Corporation. All rights reserved.<BR>
32 Portitions Copyright (c) 2011, Apple Inc. All rights reserved.
33 This program and the accompanying materials are licensed and made available under
34 the terms and conditions of the BSD License that accompanies this distribution.
35 The full text of the license may be found at
36 http://opensource.org/licenses/bsd-license.php.
38 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
39 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
44 #include "CpuDriver.h"
47 MP_SYSTEM_DATA gMPSystem
;
48 EMU_THREAD_THUNK_PROTOCOL
*gThread
= NULL
;
49 EFI_EVENT gReadToBootEvent
;
50 BOOLEAN gReadToBoot
= FALSE
;
60 UINTN ProcessorNumber
;
62 Status
= CpuMpServicesWhoAmI (&mMpSercicesTemplate
, &ProcessorNumber
);
63 if (EFI_ERROR (Status
)) {
67 return (gMPSystem
.ProcessorData
[ProcessorNumber
].Info
.StatusFlag
& PROCESSOR_AS_BSP_BIT
) != 0;
73 IN PROCESSOR_DATA_BLOCK
*Processor
,
74 IN EFI_AP_PROCEDURE Procedure
,
75 IN VOID
*ProcedureArgument
78 gThread
->MutexLock (Processor
->ProcedureLock
);
79 Processor
->Parameter
= ProcedureArgument
;
80 Processor
->Procedure
= Procedure
;
81 gThread
->MutexUnlock (Processor
->ProcedureLock
);
86 GetNextBlockedNumber (
91 PROCESSOR_STATE ProcessorState
;
92 PROCESSOR_DATA_BLOCK
*Data
;
94 for (Number
= 0; Number
< gMPSystem
.NumberOfProcessors
; Number
++) {
95 Data
= &gMPSystem
.ProcessorData
[Number
];
96 if ((Data
->Info
.StatusFlag
& PROCESSOR_AS_BSP_BIT
) != 0) {
101 gThread
->MutexLock (Data
->StateLock
);
102 ProcessorState
= Data
->State
;
103 gThread
->MutexUnlock (Data
->StateLock
);
105 if (ProcessorState
== CPU_STATE_BLOCKED
) {
106 *NextNumber
= Number
;
111 return EFI_NOT_FOUND
;
118 This service retrieves the number of logical processor in the platform
119 and the number of those logical processors that are enabled on this boot.
120 This service may only be called from the BSP.
122 This function is used to retrieve the following information:
123 - The number of logical processors that are present in the system.
124 - The number of enabled logical processors in the system at the instant
127 Because MP Service Protocol provides services to enable and disable processors
128 dynamically, the number of enabled logical processors may vary during the
129 course of a boot session.
131 If this service is called from an AP, then EFI_DEVICE_ERROR is returned.
132 If NumberOfProcessors or NumberOfEnabledProcessors is NULL, then
133 EFI_INVALID_PARAMETER is returned. Otherwise, the total number of processors
134 is returned in NumberOfProcessors, the number of currently enabled processor
135 is returned in NumberOfEnabledProcessors, and EFI_SUCCESS is returned.
137 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
139 @param[out] NumberOfProcessors Pointer to the total number of logical
140 processors in the system, including the BSP
142 @param[out] NumberOfEnabledProcessors Pointer to the number of enabled logical
143 processors that exist in system, including
146 @retval EFI_SUCCESS The number of logical processors and enabled
147 logical processors was retrieved.
148 @retval EFI_DEVICE_ERROR The calling processor is an AP.
149 @retval EFI_INVALID_PARAMETER NumberOfProcessors is NULL.
150 @retval EFI_INVALID_PARAMETER NumberOfEnabledProcessors is NULL.
155 CpuMpServicesGetNumberOfProcessors (
156 IN EFI_MP_SERVICES_PROTOCOL
*This
,
157 OUT UINTN
*NumberOfProcessors
,
158 OUT UINTN
*NumberOfEnabledProcessors
161 if ((NumberOfProcessors
== NULL
) || (NumberOfEnabledProcessors
== NULL
)) {
162 return EFI_INVALID_PARAMETER
;
166 return EFI_DEVICE_ERROR
;
169 *NumberOfProcessors
= gMPSystem
.NumberOfProcessors
;
170 *NumberOfEnabledProcessors
= gMPSystem
.NumberOfEnabledProcessors
;
177 Gets detailed MP-related information on the requested processor at the
178 instant this call is made. This service may only be called from the BSP.
180 This service retrieves detailed MP-related information about any processor
181 on the platform. Note the following:
182 - The processor information may change during the course of a boot session.
183 - The information presented here is entirely MP related.
185 Information regarding the number of caches and their sizes, frequency of operation,
186 slot numbers is all considered platform-related information and is not provided
189 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
191 @param[in] ProcessorNumber The handle number of processor.
192 @param[out] ProcessorInfoBuffer A pointer to the buffer where information for
193 the requested processor is deposited.
195 @retval EFI_SUCCESS Processor information was returned.
196 @retval EFI_DEVICE_ERROR The calling processor is an AP.
197 @retval EFI_INVALID_PARAMETER ProcessorInfoBuffer is NULL.
198 @retval EFI_NOT_FOUND The processor with the handle specified by
199 ProcessorNumber does not exist in the platform.
204 CpuMpServicesGetProcessorInfo (
205 IN EFI_MP_SERVICES_PROTOCOL
*This
,
206 IN UINTN ProcessorNumber
,
207 OUT EFI_PROCESSOR_INFORMATION
*ProcessorInfoBuffer
210 if (ProcessorInfoBuffer
== NULL
) {
211 return EFI_INVALID_PARAMETER
;
215 return EFI_DEVICE_ERROR
;
218 if (ProcessorNumber
>= gMPSystem
.NumberOfProcessors
) {
219 return EFI_NOT_FOUND
;
222 CopyMem (ProcessorInfoBuffer
, &gMPSystem
.ProcessorData
[ProcessorNumber
], sizeof (EFI_PROCESSOR_INFORMATION
));
228 This service executes a caller provided function on all enabled APs. APs can
229 run either simultaneously or one at a time in sequence. This service supports
230 both blocking and non-blocking requests. The non-blocking requests use EFI
231 events so the BSP can detect when the APs have finished. This service may only
232 be called from the BSP.
234 This function is used to dispatch all the enabled APs to the function specified
235 by Procedure. If any enabled AP is busy, then EFI_NOT_READY is returned
236 immediately and Procedure is not started on any AP.
238 If SingleThread is TRUE, all the enabled APs execute the function specified by
239 Procedure one by one, in ascending order of processor handle number. Otherwise,
240 all the enabled APs execute the function specified by Procedure simultaneously.
242 If WaitEvent is NULL, execution is in blocking mode. The BSP waits until all
243 APs finish or TimeoutInMicroseconds expires. Otherwise, execution is in non-blocking
244 mode, and the BSP returns from this service without waiting for APs. If a
245 non-blocking mode is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT
246 is signaled, then EFI_UNSUPPORTED must be returned.
248 If the timeout specified by TimeoutInMicroseconds expires before all APs return
249 from Procedure, then Procedure on the failed APs is terminated. All enabled APs
250 are always available for further calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()
251 and EFI_MP_SERVICES_PROTOCOL.StartupThisAP(). If FailedCpuList is not NULL, its
252 content points to the list of processor handle numbers in which Procedure was
255 Note: It is the responsibility of the consumer of the EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()
256 to make sure that the nature of the code that is executed on the BSP and the
257 dispatched APs is well controlled. The MP Services Protocol does not guarantee
258 that the Procedure function is MP-safe. Hence, the tasks that can be run in
259 parallel are limited to certain independent tasks and well-controlled exclusive
260 code. EFI services and protocols may not be called by APs unless otherwise
263 In blocking execution mode, BSP waits until all APs finish or
264 TimeoutInMicroseconds expires.
266 In non-blocking execution mode, BSP is freed to return to the caller and then
267 proceed to the next task without having to wait for APs. The following
268 sequence needs to occur in a non-blocking execution mode:
270 -# The caller that intends to use this MP Services Protocol in non-blocking
271 mode creates WaitEvent by calling the EFI CreateEvent() service. The caller
272 invokes EFI_MP_SERVICES_PROTOCOL.StartupAllAPs(). If the parameter WaitEvent
273 is not NULL, then StartupAllAPs() executes in non-blocking mode. It requests
274 the function specified by Procedure to be started on all the enabled APs,
275 and releases the BSP to continue with other tasks.
276 -# The caller can use the CheckEvent() and WaitForEvent() services to check
277 the state of the WaitEvent created in step 1.
278 -# When the APs complete their task or TimeoutInMicroSecondss expires, the MP
279 Service signals WaitEvent by calling the EFI SignalEvent() function. If
280 FailedCpuList is not NULL, its content is available when WaitEvent is
281 signaled. If all APs returned from Procedure prior to the timeout, then
282 FailedCpuList is set to NULL. If not all APs return from Procedure before
283 the timeout, then FailedCpuList is filled in with the list of the failed
284 APs. The buffer is allocated by MP Service Protocol using AllocatePool().
285 It is the caller's responsibility to free the buffer with FreePool() service.
286 -# This invocation of SignalEvent() function informs the caller that invoked
287 EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() that either all the APs completed
288 the specified task or a timeout occurred. The contents of FailedCpuList
289 can be examined to determine which APs did not complete the specified task
290 prior to the timeout.
292 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
294 @param[in] Procedure A pointer to the function to be run on
295 enabled APs of the system. See type
297 @param[in] SingleThread If TRUE, then all the enabled APs execute
298 the function specified by Procedure one by
299 one, in ascending order of processor handle
300 number. If FALSE, then all the enabled APs
301 execute the function specified by Procedure
303 @param[in] WaitEvent The event created by the caller with CreateEvent()
304 service. If it is NULL, then execute in
305 blocking mode. BSP waits until all APs finish
306 or TimeoutInMicroseconds expires. If it's
307 not NULL, then execute in non-blocking mode.
308 BSP requests the function specified by
309 Procedure to be started on all the enabled
310 APs, and go on executing immediately. If
311 all return from Procedure, or TimeoutInMicroseconds
312 expires, this event is signaled. The BSP
313 can use the CheckEvent() or WaitForEvent()
314 services to check the state of event. Type
315 EFI_EVENT is defined in CreateEvent() in
316 the Unified Extensible Firmware Interface
318 @param[in] TimeoutInMicrosecsond Indicates the time limit in microseconds for
319 APs to return from Procedure, either for
320 blocking or non-blocking mode. Zero means
321 infinity. If the timeout expires before
322 all APs return from Procedure, then Procedure
323 on the failed APs is terminated. All enabled
324 APs are available for next function assigned
325 by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()
326 or EFI_MP_SERVICES_PROTOCOL.StartupThisAP().
327 If the timeout expires in blocking mode,
328 BSP returns EFI_TIMEOUT. If the timeout
329 expires in non-blocking mode, WaitEvent
330 is signaled with SignalEvent().
331 @param[in] ProcedureArgument The parameter passed into Procedure for
333 @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise,
334 if all APs finish successfully, then its
335 content is set to NULL. If not all APs
336 finish before timeout expires, then its
337 content is set to address of the buffer
338 holding handle numbers of the failed APs.
339 The buffer is allocated by MP Service Protocol,
340 and it's the caller's responsibility to
341 free the buffer with FreePool() service.
342 In blocking mode, it is ready for consumption
343 when the call returns. In non-blocking mode,
344 it is ready when WaitEvent is signaled. The
345 list of failed CPU is terminated by
348 @retval EFI_SUCCESS In blocking mode, all APs have finished before
350 @retval EFI_SUCCESS In non-blocking mode, function has been dispatched
352 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the
353 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was
355 @retval EFI_DEVICE_ERROR Caller processor is AP.
356 @retval EFI_NOT_STARTED No enabled APs exist in the system.
357 @retval EFI_NOT_READY Any enabled APs are busy.
358 @retval EFI_TIMEOUT In blocking mode, the timeout expired before
359 all enabled APs have finished.
360 @retval EFI_INVALID_PARAMETER Procedure is NULL.
365 CpuMpServicesStartupAllAps (
366 IN EFI_MP_SERVICES_PROTOCOL
*This
,
367 IN EFI_AP_PROCEDURE Procedure
,
368 IN BOOLEAN SingleThread
,
369 IN EFI_EVENT WaitEvent OPTIONAL
,
370 IN UINTN TimeoutInMicroseconds
,
371 IN VOID
*ProcedureArgument OPTIONAL
,
372 OUT UINTN
**FailedCpuList OPTIONAL
376 PROCESSOR_DATA_BLOCK
*ProcessorData
;
380 PROCESSOR_STATE APInitialState
;
381 PROCESSOR_STATE ProcessorState
;
386 return EFI_DEVICE_ERROR
;
389 if (gMPSystem
.NumberOfProcessors
== 1) {
390 return EFI_NOT_STARTED
;
393 if (Procedure
== NULL
) {
394 return EFI_INVALID_PARAMETER
;
397 if ((WaitEvent
!= NULL
) && gReadToBoot
) {
398 return EFI_UNSUPPORTED
;
402 if (FailedCpuList
!= NULL
) {
403 gMPSystem
.FailedList
= AllocatePool ((gMPSystem
.NumberOfProcessors
+ 1) * sizeof (UINTN
));
404 if (gMPSystem
.FailedList
== NULL
) {
405 return EFI_OUT_OF_RESOURCES
;
407 SetMemN (gMPSystem
.FailedList
, (gMPSystem
.NumberOfProcessors
+ 1) * sizeof (UINTN
), END_OF_CPU_LIST
);
408 gMPSystem
.FailedListIndex
= 0;
409 *FailedCpuList
= gMPSystem
.FailedList
;
412 Timeout
= TimeoutInMicroseconds
;
415 ProcessorData
= NULL
;
417 gMPSystem
.FinishCount
= 0;
418 gMPSystem
.StartCount
= 0;
419 gMPSystem
.SingleThread
= SingleThread
;
420 APInitialState
= CPU_STATE_READY
;
422 for (Number
= 0; Number
< gMPSystem
.NumberOfProcessors
; Number
++) {
423 ProcessorData
= &gMPSystem
.ProcessorData
[Number
];
425 if ((ProcessorData
->Info
.StatusFlag
& PROCESSOR_AS_BSP_BIT
) == PROCESSOR_AS_BSP_BIT
) {
430 if ((ProcessorData
->Info
.StatusFlag
& PROCESSOR_ENABLED_BIT
) == 0) {
431 // Skip Disabled processors
432 gMPSystem
.FailedList
[gMPSystem
.FailedListIndex
++] = Number
;
437 // Get APs prepared, and put failing APs into FailedCpuList
438 // if "SingleThread", only 1 AP will put to ready state, other AP will be put to ready
439 // state 1 by 1, until the previous 1 finished its task
440 // if not "SingleThread", all APs are put to ready state from the beginning
442 if (ProcessorData
->State
== CPU_STATE_IDLE
) {
443 gMPSystem
.StartCount
++;
445 gThread
->MutexLock (&ProcessorData
->StateLock
);
446 ProcessorData
->State
= APInitialState
;
447 gThread
->MutexUnlock (&ProcessorData
->StateLock
);
450 APInitialState
= CPU_STATE_BLOCKED
;
453 return EFI_NOT_READY
;
457 if (WaitEvent
!= NULL
) {
458 for (Number
= 0; Number
< gMPSystem
.NumberOfProcessors
; Number
++) {
459 ProcessorData
= &gMPSystem
.ProcessorData
[Number
];
460 if ((ProcessorData
->Info
.StatusFlag
& PROCESSOR_AS_BSP_BIT
) == PROCESSOR_AS_BSP_BIT
) {
465 if ((ProcessorData
->Info
.StatusFlag
& PROCESSOR_ENABLED_BIT
) == 0) {
466 // Skip Disabled processors
470 SetApProcedure (ProcessorData
, Procedure
, ProcedureArgument
);
474 // Save data into private data structure, and create timer to poll AP state before exiting
476 gMPSystem
.Procedure
= Procedure
;
477 gMPSystem
.ProcedureArgument
= ProcedureArgument
;
478 gMPSystem
.WaitEvent
= WaitEvent
;
479 gMPSystem
.Timeout
= TimeoutInMicroseconds
;
480 gMPSystem
.TimeoutActive
= (BOOLEAN
)(TimeoutInMicroseconds
!= 0);
481 Status
= gBS
->SetTimer (
482 gMPSystem
.CheckAllAPsEvent
,
491 for (Number
= 0; Number
< gMPSystem
.NumberOfProcessors
; Number
++) {
492 ProcessorData
= &gMPSystem
.ProcessorData
[Number
];
493 if ((ProcessorData
->Info
.StatusFlag
& PROCESSOR_AS_BSP_BIT
) == PROCESSOR_AS_BSP_BIT
) {
498 if ((ProcessorData
->Info
.StatusFlag
& PROCESSOR_ENABLED_BIT
) == 0) {
499 // Skip Disabled processors
503 gThread
->MutexLock (ProcessorData
->StateLock
);
504 ProcessorState
= ProcessorData
->State
;
505 gThread
->MutexUnlock (ProcessorData
->StateLock
);
507 switch (ProcessorState
) {
508 case CPU_STATE_READY
:
509 SetApProcedure (ProcessorData
, Procedure
, ProcedureArgument
);
512 case CPU_STATE_FINISHED
:
513 gMPSystem
.FinishCount
++;
515 Status
= GetNextBlockedNumber (&NextNumber
);
516 if (!EFI_ERROR (Status
)) {
517 gMPSystem
.ProcessorData
[NextNumber
].State
= CPU_STATE_READY
;
521 ProcessorData
->State
= CPU_STATE_IDLE
;
529 if (gMPSystem
.FinishCount
== gMPSystem
.StartCount
) {
530 Status
= EFI_SUCCESS
;
534 if ((TimeoutInMicroseconds
!= 0) && (Timeout
< 0)) {
535 Status
= EFI_TIMEOUT
;
539 gBS
->Stall (gPollInterval
);
540 Timeout
-= gPollInterval
;
544 if (FailedCpuList
!= NULL
) {
545 if (gMPSystem
.FailedListIndex
== 0) {
546 FreePool (*FailedCpuList
);
547 *FailedCpuList
= NULL
;
556 This service lets the caller get one enabled AP to execute a caller-provided
557 function. The caller can request the BSP to either wait for the completion
558 of the AP or just proceed with the next task by using the EFI event mechanism.
559 See EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() for more details on non-blocking
560 execution support. This service may only be called from the BSP.
562 This function is used to dispatch one enabled AP to the function specified by
563 Procedure passing in the argument specified by ProcedureArgument. If WaitEvent
564 is NULL, execution is in blocking mode. The BSP waits until the AP finishes or
565 TimeoutInMicroSecondss expires. Otherwise, execution is in non-blocking mode.
566 BSP proceeds to the next task without waiting for the AP. If a non-blocking mode
567 is requested after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled,
568 then EFI_UNSUPPORTED must be returned.
570 If the timeout specified by TimeoutInMicroseconds expires before the AP returns
571 from Procedure, then execution of Procedure by the AP is terminated. The AP is
572 available for subsequent calls to EFI_MP_SERVICES_PROTOCOL.StartupAllAPs() and
573 EFI_MP_SERVICES_PROTOCOL.StartupThisAP().
575 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL
577 @param[in] Procedure A pointer to the function to be run on
578 enabled APs of the system. See type
580 @param[in] ProcessorNumber The handle number of the AP. The range is
581 from 0 to the total number of logical
582 processors minus 1. The total number of
583 logical processors can be retrieved by
584 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
585 @param[in] WaitEvent The event created by the caller with CreateEvent()
586 service. If it is NULL, then execute in
587 blocking mode. BSP waits until all APs finish
588 or TimeoutInMicroseconds expires. If it's
589 not NULL, then execute in non-blocking mode.
590 BSP requests the function specified by
591 Procedure to be started on all the enabled
592 APs, and go on executing immediately. If
593 all return from Procedure or TimeoutInMicroseconds
594 expires, this event is signaled. The BSP
595 can use the CheckEvent() or WaitForEvent()
596 services to check the state of event. Type
597 EFI_EVENT is defined in CreateEvent() in
598 the Unified Extensible Firmware Interface
600 @param[in] TimeoutInMicrosecsond Indicates the time limit in microseconds for
601 APs to return from Procedure, either for
602 blocking or non-blocking mode. Zero means
603 infinity. If the timeout expires before
604 all APs return from Procedure, then Procedure
605 on the failed APs is terminated. All enabled
606 APs are available for next function assigned
607 by EFI_MP_SERVICES_PROTOCOL.StartupAllAPs()
608 or EFI_MP_SERVICES_PROTOCOL.StartupThisAP().
609 If the timeout expires in blocking mode,
610 BSP returns EFI_TIMEOUT. If the timeout
611 expires in non-blocking mode, WaitEvent
612 is signaled with SignalEvent().
613 @param[in] ProcedureArgument The parameter passed into Procedure for
615 @param[out] Finished If NULL, this parameter is ignored. In
616 blocking mode, this parameter is ignored.
617 In non-blocking mode, if AP returns from
618 Procedure before the timeout expires, its
619 content is set to TRUE. Otherwise, the
620 value is set to FALSE. The caller can
621 determine if the AP returned from Procedure
622 by evaluating this value.
624 @retval EFI_SUCCESS In blocking mode, specified AP finished before
626 @retval EFI_SUCCESS In non-blocking mode, the function has been
627 dispatched to specified AP.
628 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the
629 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was
631 @retval EFI_DEVICE_ERROR The calling processor is an AP.
632 @retval EFI_TIMEOUT In blocking mode, the timeout expired before
633 the specified AP has finished.
634 @retval EFI_NOT_READY The specified AP is busy.
635 @retval EFI_NOT_FOUND The processor with the handle specified by
636 ProcessorNumber does not exist.
637 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.
638 @retval EFI_INVALID_PARAMETER Procedure is NULL.
643 CpuMpServicesStartupThisAP (
644 IN EFI_MP_SERVICES_PROTOCOL
*This
,
645 IN EFI_AP_PROCEDURE Procedure
,
646 IN UINTN ProcessorNumber
,
647 IN EFI_EVENT WaitEvent OPTIONAL
,
648 IN UINTN TimeoutInMicroseconds
,
649 IN VOID
*ProcedureArgument OPTIONAL
,
650 OUT BOOLEAN
*Finished OPTIONAL
657 return EFI_DEVICE_ERROR
;
660 if (Procedure
== NULL
) {
661 return EFI_INVALID_PARAMETER
;
664 if (ProcessorNumber
>= gMPSystem
.NumberOfProcessors
) {
665 return EFI_NOT_FOUND
;
668 if ((gMPSystem
.ProcessorData
[ProcessorNumber
].Info
.StatusFlag
& PROCESSOR_AS_BSP_BIT
) != 0) {
669 return EFI_INVALID_PARAMETER
;
672 if (gMPSystem
.ProcessorData
[ProcessorNumber
].State
!= CPU_STATE_IDLE
) {
673 return EFI_NOT_READY
;
676 if ((WaitEvent
!= NULL
) && gReadToBoot
) {
677 return EFI_UNSUPPORTED
;
680 Timeout
= TimeoutInMicroseconds
;
682 gMPSystem
.StartCount
= 1;
683 gMPSystem
.FinishCount
= 0;
685 SetApProcedure (&gMPSystem
.ProcessorData
[ProcessorNumber
], Procedure
, ProcedureArgument
);
687 if (WaitEvent
!= NULL
) {
689 gMPSystem
.WaitEvent
= WaitEvent
;
690 Status
= gBS
->SetTimer (
691 gMPSystem
.ProcessorData
[ProcessorNumber
].CheckThisAPEvent
,
700 gThread
->MutexLock (&gMPSystem
.ProcessorData
[ProcessorNumber
].StateLock
);
701 if (gMPSystem
.ProcessorData
[ProcessorNumber
].State
== CPU_STATE_FINISHED
) {
702 gMPSystem
.ProcessorData
[ProcessorNumber
].State
= CPU_STATE_IDLE
;
703 gThread
->MutexUnlock (&gMPSystem
.ProcessorData
[ProcessorNumber
].StateLock
);
707 gThread
->MutexUnlock (&gMPSystem
.ProcessorData
[ProcessorNumber
].StateLock
);
709 if ((TimeoutInMicroseconds
!= 0) && (Timeout
< 0)) {
713 gBS
->Stall (gPollInterval
);
714 Timeout
-= gPollInterval
;
723 This service switches the requested AP to be the BSP from that point onward.
724 This service changes the BSP for all purposes. This call can only be performed
727 This service switches the requested AP to be the BSP from that point onward.
728 This service changes the BSP for all purposes. The new BSP can take over the
729 execution of the old BSP and continue seamlessly from where the old one left
730 off. This service may not be supported after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT
733 If the BSP cannot be switched prior to the return from this service, then
734 EFI_UNSUPPORTED must be returned.
736 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
737 @param[in] ProcessorNumber The handle number of AP that is to become the new
738 BSP. The range is from 0 to the total number of
739 logical processors minus 1. The total number of
740 logical processors can be retrieved by
741 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
742 @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an
743 enabled AP. Otherwise, it will be disabled.
745 @retval EFI_SUCCESS BSP successfully switched.
746 @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to
747 this service returning.
748 @retval EFI_UNSUPPORTED Switching the BSP is not supported.
749 @retval EFI_SUCCESS The calling processor is an AP.
750 @retval EFI_NOT_FOUND The processor with the handle specified by
751 ProcessorNumber does not exist.
752 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or
754 @retval EFI_NOT_READY The specified AP is busy.
759 CpuMpServicesSwitchBSP (
760 IN EFI_MP_SERVICES_PROTOCOL
*This
,
761 IN UINTN ProcessorNumber
,
762 IN BOOLEAN EnableOldBSP
768 return EFI_DEVICE_ERROR
;
771 if (ProcessorNumber
>= gMPSystem
.NumberOfProcessors
) {
772 return EFI_NOT_FOUND
;
775 if ((gMPSystem
.ProcessorData
[ProcessorNumber
].Info
.StatusFlag
& PROCESSOR_ENABLED_BIT
) == 0) {
776 return EFI_INVALID_PARAMETER
;
779 if ((gMPSystem
.ProcessorData
[ProcessorNumber
].Info
.StatusFlag
& PROCESSOR_AS_BSP_BIT
) != 0) {
780 return EFI_INVALID_PARAMETER
;
783 for (Index
= 0; Index
< gMPSystem
.NumberOfProcessors
; Index
++) {
784 if ((gMPSystem
.ProcessorData
[Index
].Info
.StatusFlag
& PROCESSOR_AS_BSP_BIT
) != 0) {
788 ASSERT (Index
!= gMPSystem
.NumberOfProcessors
);
790 if (gMPSystem
.ProcessorData
[ProcessorNumber
].State
!= CPU_STATE_IDLE
) {
791 return EFI_NOT_READY
;
794 // Skip for now as we need switch a bunch of stack stuff around and it's complex
795 // May not be worth it?
796 return EFI_NOT_READY
;
801 This service lets the caller enable or disable an AP from this point onward.
802 This service may only be called from the BSP.
804 This service allows the caller enable or disable an AP from this point onward.
805 The caller can optionally specify the health status of the AP by Health. If
806 an AP is being disabled, then the state of the disabled AP is implementation
807 dependent. If an AP is enabled, then the implementation must guarantee that a
808 complete initialization sequence is performed on the AP, so the AP is in a state
809 that is compatible with an MP operating system. This service may not be supported
810 after the UEFI Event EFI_EVENT_GROUP_READY_TO_BOOT is signaled.
812 If the enable or disable AP operation cannot be completed prior to the return
813 from this service, then EFI_UNSUPPORTED must be returned.
815 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
816 @param[in] ProcessorNumber The handle number of AP that is to become the new
817 BSP. The range is from 0 to the total number of
818 logical processors minus 1. The total number of
819 logical processors can be retrieved by
820 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
821 @param[in] EnableAP Specifies the new state for the processor for
822 enabled, FALSE for disabled.
823 @param[in] HealthFlag If not NULL, a pointer to a value that specifies
824 the new health status of the AP. This flag
825 corresponds to StatusFlag defined in
826 EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only
827 the PROCESSOR_HEALTH_STATUS_BIT is used. All other
828 bits are ignored. If it is NULL, this parameter
831 @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.
832 @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed
833 prior to this service returning.
834 @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.
835 @retval EFI_DEVICE_ERROR The calling processor is an AP.
836 @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber
838 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.
843 CpuMpServicesEnableDisableAP (
844 IN EFI_MP_SERVICES_PROTOCOL
*This
,
845 IN UINTN ProcessorNumber
,
847 IN UINT32
*HealthFlag OPTIONAL
851 return EFI_DEVICE_ERROR
;
854 if (ProcessorNumber
>= gMPSystem
.NumberOfProcessors
) {
855 return EFI_NOT_FOUND
;
858 if ((gMPSystem
.ProcessorData
[ProcessorNumber
].Info
.StatusFlag
& PROCESSOR_AS_BSP_BIT
) != 0) {
859 return EFI_INVALID_PARAMETER
;
862 if (gMPSystem
.ProcessorData
[ProcessorNumber
].State
!= CPU_STATE_IDLE
) {
863 return EFI_UNSUPPORTED
;
866 gThread
->MutexLock (&gMPSystem
.ProcessorData
[ProcessorNumber
].StateLock
);
869 if ((gMPSystem
.ProcessorData
[ProcessorNumber
].Info
.StatusFlag
& PROCESSOR_ENABLED_BIT
) == 0 ) {
870 gMPSystem
.NumberOfEnabledProcessors
++;
872 gMPSystem
.ProcessorData
[ProcessorNumber
].Info
.StatusFlag
|= PROCESSOR_ENABLED_BIT
;
874 if ((gMPSystem
.ProcessorData
[ProcessorNumber
].Info
.StatusFlag
& PROCESSOR_ENABLED_BIT
) == PROCESSOR_ENABLED_BIT
) {
875 gMPSystem
.NumberOfEnabledProcessors
--;
877 gMPSystem
.ProcessorData
[ProcessorNumber
].Info
.StatusFlag
&= ~PROCESSOR_ENABLED_BIT
;
880 if (HealthFlag
!= NULL
) {
881 gMPSystem
.ProcessorData
[ProcessorNumber
].Info
.StatusFlag
&= ~PROCESSOR_HEALTH_STATUS_BIT
;
882 gMPSystem
.ProcessorData
[ProcessorNumber
].Info
.StatusFlag
|= (*HealthFlag
& PROCESSOR_HEALTH_STATUS_BIT
);
885 gThread
->MutexUnlock (&gMPSystem
.ProcessorData
[ProcessorNumber
].StateLock
);
892 This return the handle number for the calling processor. This service may be
893 called from the BSP and APs.
895 This service returns the processor handle number for the calling processor.
896 The returned value is in the range from 0 to the total number of logical
897 processors minus 1. The total number of logical processors can be retrieved
898 with EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors(). This service may be
899 called from the BSP and APs. If ProcessorNumber is NULL, then EFI_INVALID_PARAMETER
900 is returned. Otherwise, the current processors handle number is returned in
901 ProcessorNumber, and EFI_SUCCESS is returned.
903 @param[in] This A pointer to the EFI_MP_SERVICES_PROTOCOL instance.
904 @param[in] ProcessorNumber The handle number of AP that is to become the new
905 BSP. The range is from 0 to the total number of
906 logical processors minus 1. The total number of
907 logical processors can be retrieved by
908 EFI_MP_SERVICES_PROTOCOL.GetNumberOfProcessors().
910 @retval EFI_SUCCESS The current processor handle number was returned
912 @retval EFI_INVALID_PARAMETER ProcessorNumber is NULL.
917 CpuMpServicesWhoAmI (
918 IN EFI_MP_SERVICES_PROTOCOL
*This
,
919 OUT UINTN
*ProcessorNumber
925 if (ProcessorNumber
== NULL
) {
926 return EFI_INVALID_PARAMETER
;
929 ProcessorId
= gThread
->Self ();
930 for (Index
= 0; Index
< gMPSystem
.NumberOfProcessors
; Index
++) {
931 if (gMPSystem
.ProcessorData
[Index
].Info
.ProcessorId
== ProcessorId
) {
936 *ProcessorNumber
= Index
;
942 EFI_MP_SERVICES_PROTOCOL mMpSercicesTemplate
= {
943 CpuMpServicesGetNumberOfProcessors
,
944 CpuMpServicesGetProcessorInfo
,
945 CpuMpServicesStartupAllAps
,
946 CpuMpServicesStartupThisAP
,
947 CpuMpServicesSwitchBSP
,
948 CpuMpServicesEnableDisableAP
,
955 If timeout occurs in StartupAllAps(), a timer is set, which invokes this
956 procedure periodically to check whether all APs have finished.
962 CpuCheckAllAPsStatus (
967 UINTN ProcessorNumber
;
969 PROCESSOR_DATA_BLOCK
*ProcessorData
;
970 PROCESSOR_DATA_BLOCK
*NextData
;
972 PROCESSOR_STATE ProcessorState
;
976 if (gMPSystem
.TimeoutActive
) {
977 gMPSystem
.Timeout
-= gPollInterval
;
980 ProcessorData
= (PROCESSOR_DATA_BLOCK
*) Context
;
982 for (ProcessorNumber
= 0; ProcessorNumber
< gMPSystem
.NumberOfProcessors
; ProcessorNumber
++) {
983 if ((ProcessorData
[ProcessorNumber
].Info
.StatusFlag
& PROCESSOR_AS_BSP_BIT
) == PROCESSOR_AS_BSP_BIT
) {
988 if ((ProcessorData
->Info
.StatusFlag
& PROCESSOR_ENABLED_BIT
) == 0) {
989 // Skip Disabled processors
993 // This is an Interrupt Service routine.
994 // This can grab a lock that is held in a non-interrupt
995 // context. Meaning deadlock. Which is a bad thing.
996 // So, try lock it. If we can get it, cool, do our thing.
997 // otherwise, just dump out & try again on the next iteration.
998 Status
= gThread
->MutexTryLock (gMPSystem
.ProcessorData
[ProcessorNumber
].StateLock
);
999 if (EFI_ERROR(Status
)) {
1002 ProcessorState
= gMPSystem
.ProcessorData
[ProcessorNumber
].State
;
1003 gThread
->MutexUnlock (gMPSystem
.ProcessorData
[ProcessorNumber
].StateLock
);
1005 switch (ProcessorState
) {
1006 case CPU_STATE_READY
:
1007 SetApProcedure (ProcessorData
, gMPSystem
.Procedure
, gMPSystem
.ProcedureArgument
);
1010 case CPU_STATE_FINISHED
:
1011 if (gMPSystem
.SingleThread
) {
1012 Status
= GetNextBlockedNumber (&NextNumber
);
1013 if (!EFI_ERROR (Status
)) {
1014 NextData
= &gMPSystem
.ProcessorData
[NextNumber
];
1016 gThread
->MutexLock (&NextData
->ProcedureLock
);
1017 NextData
->State
= CPU_STATE_READY
;
1018 gThread
->MutexUnlock (&NextData
->ProcedureLock
);
1020 SetApProcedure (NextData
, gMPSystem
.Procedure
, gMPSystem
.ProcedureArgument
);
1024 gMPSystem
.ProcessorData
[ProcessorNumber
].State
= CPU_STATE_IDLE
;
1025 gMPSystem
.FinishCount
++;
1033 if (gMPSystem
.TimeoutActive
&& gMPSystem
.Timeout
< 0) {
1037 if (gMPSystem
.FailedList
!= NULL
) {
1038 for (ProcessorNumber
= 0; ProcessorNumber
< gMPSystem
.NumberOfProcessors
; ProcessorNumber
++) {
1039 if ((ProcessorData
[ProcessorNumber
].Info
.StatusFlag
& PROCESSOR_AS_BSP_BIT
) == PROCESSOR_AS_BSP_BIT
) {
1044 if ((ProcessorData
->Info
.StatusFlag
& PROCESSOR_ENABLED_BIT
) == 0) {
1045 // Skip Disabled processors
1050 Status
= gThread
->MutexTryLock (gMPSystem
.ProcessorData
[ProcessorNumber
].StateLock
);
1051 if (EFI_ERROR(Status
)) {
1054 ProcessorState
= gMPSystem
.ProcessorData
[ProcessorNumber
].State
;
1055 gThread
->MutexUnlock (gMPSystem
.ProcessorData
[ProcessorNumber
].StateLock
);
1057 if (ProcessorState
!= CPU_STATE_IDLE
) {
1058 // If we are retrying make sure we don't double count
1059 for (Cpu
= 0, Found
= FALSE
; Cpu
< gMPSystem
.NumberOfProcessors
; Cpu
++) {
1060 if (gMPSystem
.FailedList
[Cpu
] == END_OF_CPU_LIST
) {
1063 if (gMPSystem
.FailedList
[ProcessorNumber
] == Cpu
) {
1069 gMPSystem
.FailedList
[gMPSystem
.FailedListIndex
++] = Cpu
;
1074 // Force terminal exit
1075 gMPSystem
.FinishCount
= gMPSystem
.StartCount
;
1078 if (gMPSystem
.FinishCount
!= gMPSystem
.StartCount
) {
1083 gMPSystem
.CheckAllAPsEvent
,
1088 if (gMPSystem
.FailedListIndex
== 0) {
1089 if (gMPSystem
.FailedList
!= NULL
) {
1090 FreePool (gMPSystem
.FailedList
);
1091 gMPSystem
.FailedList
= NULL
;
1095 Status
= gBS
->SignalEvent (gMPSystem
.WaitEvent
);
1102 CpuCheckThisAPStatus (
1108 PROCESSOR_DATA_BLOCK
*ProcessorData
;
1109 PROCESSOR_STATE ProcessorState
;
1111 ProcessorData
= (PROCESSOR_DATA_BLOCK
*) Context
;
1114 // This is an Interrupt Service routine.
1115 // that can grab a lock that is held in a non-interrupt
1116 // context. Meaning deadlock. Which is a badddd thing.
1117 // So, try lock it. If we can get it, cool, do our thing.
1118 // otherwise, just dump out & try again on the next iteration.
1120 Status
= gThread
->MutexTryLock (ProcessorData
->StateLock
);
1121 if (EFI_ERROR(Status
)) {
1124 ProcessorState
= ProcessorData
->State
;
1125 gThread
->MutexUnlock (ProcessorData
->StateLock
);
1127 if (ProcessorState
== CPU_STATE_FINISHED
) {
1128 Status
= gBS
->SetTimer (ProcessorData
->CheckThisAPEvent
, TimerCancel
, 0);
1129 ASSERT_EFI_ERROR (Status
);
1131 Status
= gBS
->SignalEvent (gMPSystem
.WaitEvent
);
1132 ASSERT_EFI_ERROR (Status
);
1134 gThread
->MutexLock (ProcessorData
->StateLock
);
1135 ProcessorData
->State
= CPU_STATE_IDLE
;
1136 gThread
->MutexUnlock (ProcessorData
->StateLock
);
1144 This function is called by all processors (both BSP and AP) once and collects MP related data
1146 MPSystemData - Pointer to the data structure containing MP related data
1147 BSP - TRUE if the CPU is BSP
1149 EFI_SUCCESS - Data for the processor collected and filled in
1153 FillInProcessorInformation (
1155 IN UINTN ProcessorNumber
1158 PROCESSOR_DATA_BLOCK
*ProcessorData
;
1160 ProcessorData
= &gMPSystem
.ProcessorData
[ProcessorNumber
];
1162 gMPSystem
.ProcessorData
[ProcessorNumber
].Info
.ProcessorId
= gThread
->Self ();
1163 gMPSystem
.ProcessorData
[ProcessorNumber
].Info
.StatusFlag
= PROCESSOR_ENABLED_BIT
| PROCESSOR_HEALTH_STATUS_BIT
;
1165 gMPSystem
.ProcessorData
[ProcessorNumber
].Info
.StatusFlag
|= PROCESSOR_AS_BSP_BIT
;
1168 gMPSystem
.ProcessorData
[ProcessorNumber
].Info
.Location
.Package
= ProcessorNumber
;
1169 gMPSystem
.ProcessorData
[ProcessorNumber
].Info
.Location
.Core
= 0;
1170 gMPSystem
.ProcessorData
[ProcessorNumber
].Info
.Location
.Thread
= 0;
1171 gMPSystem
.ProcessorData
[ProcessorNumber
].State
= BSP
? CPU_STATE_BUSY
: CPU_STATE_IDLE
;
1173 gMPSystem
.ProcessorData
[ProcessorNumber
].Procedure
= NULL
;
1174 gMPSystem
.ProcessorData
[ProcessorNumber
].Parameter
= NULL
;
1175 gMPSystem
.ProcessorData
[ProcessorNumber
].StateLock
= gThread
->MutexInit ();
1176 gMPSystem
.ProcessorData
[ProcessorNumber
].ProcedureLock
= gThread
->MutexInit ();
1183 CpuDriverApIdolLoop (
1187 EFI_AP_PROCEDURE Procedure
;
1189 UINTN ProcessorNumber
;
1190 PROCESSOR_DATA_BLOCK
*ProcessorData
;
1192 ProcessorNumber
= (UINTN
)Context
;
1193 ProcessorData
= &gMPSystem
.ProcessorData
[ProcessorNumber
];
1195 ProcessorData
->Info
.ProcessorId
= gThread
->Self ();
1199 // Make a local copy on the stack to be extra safe
1201 gThread
->MutexLock (ProcessorData
->ProcedureLock
);
1202 Procedure
= ProcessorData
->Procedure
;
1203 Parameter
= ProcessorData
->Parameter
;
1204 gThread
->MutexUnlock (ProcessorData
->ProcedureLock
);
1206 if (Procedure
!= NULL
) {
1207 gThread
->MutexLock (ProcessorData
->StateLock
);
1208 ProcessorData
->State
= CPU_STATE_BUSY
;
1209 gThread
->MutexUnlock (ProcessorData
->StateLock
);
1211 Procedure (Parameter
);
1213 gThread
->MutexLock (ProcessorData
->ProcedureLock
);
1214 ProcessorData
->Procedure
= NULL
;
1215 gThread
->MutexUnlock (ProcessorData
->ProcedureLock
);
1217 gThread
->MutexLock (ProcessorData
->StateLock
);
1218 ProcessorData
->State
= CPU_STATE_FINISHED
;
1219 gThread
->MutexUnlock (ProcessorData
->StateLock
);
1222 // Poll 5 times a seconds, 200ms
1223 // Don't want to burn too many system resources doing nothing.
1224 gEmuThunk
->Sleep (200 * 1000);
1232 InitializeMpSystemData (
1233 IN UINTN NumberOfProcessors
1241 // Clear the data structure area first.
1243 ZeroMem (&gMPSystem
, sizeof (MP_SYSTEM_DATA
));
1246 // First BSP fills and inits all known values, including it's own records.
1248 gMPSystem
.NumberOfProcessors
= NumberOfProcessors
;
1249 gMPSystem
.NumberOfEnabledProcessors
= NumberOfProcessors
;
1251 gMPSystem
.ProcessorData
= AllocateZeroPool (gMPSystem
.NumberOfProcessors
* sizeof (PROCESSOR_DATA_BLOCK
));
1252 ASSERT (gMPSystem
.ProcessorData
!= NULL
);
1254 FillInProcessorInformation (TRUE
, 0);
1256 Status
= gBS
->CreateEvent (
1257 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
1259 CpuCheckAllAPsStatus
,
1261 &gMPSystem
.CheckAllAPsEvent
1263 ASSERT_EFI_ERROR (Status
);
1266 for (Index
= 0; Index
< gMPSystem
.NumberOfProcessors
; Index
++) {
1267 if ((gMPSystem
.ProcessorData
[Index
].Info
.StatusFlag
& PROCESSOR_AS_BSP_BIT
) == PROCESSOR_AS_BSP_BIT
) {
1272 FillInProcessorInformation (FALSE
, Index
);
1274 Status
= gThread
->CreateThread (
1275 (VOID
*)&gMPSystem
.ProcessorData
[Index
].Info
.ProcessorId
,
1277 CpuDriverApIdolLoop
,
1282 Status
= gBS
->CreateEvent (
1283 EVT_TIMER
| EVT_NOTIFY_SIGNAL
,
1285 CpuCheckThisAPStatus
,
1286 (VOID
*) &gMPSystem
.ProcessorData
[Index
],
1287 &gMPSystem
.ProcessorData
[Index
].CheckThisAPEvent
1297 Invoke a notification event
1299 @param Event Event whose notification function is being invoked.
1300 @param Context The pointer to the notification function's context,
1301 which is implementation-dependent.
1306 CpuReadToBootFunction (
1323 EMU_IO_THUNK_PROTOCOL
*IoThunk
;
1328 IoThunk
= GetIoThunkInstance (&gEmuThreadThunkProtocolGuid
, 0);
1329 if (IoThunk
!= NULL
) {
1330 Status
= IoThunk
->Open (IoThunk
);
1331 if (!EFI_ERROR (Status
)) {
1332 if (IoThunk
->ConfigString
!= NULL
) {
1333 MaxCpus
+= StrDecimalToUintn (IoThunk
->ConfigString
);
1334 gThread
= IoThunk
->Interface
;
1340 // We are not MP so nothing to do
1344 gPollInterval
= PcdGet64 (PcdEmuMpServicesPollingInterval
);
1346 Status
= InitializeMpSystemData (MaxCpus
);
1347 if (EFI_ERROR (Status
)) {
1351 Status
= EfiCreateEventReadyToBootEx (TPL_CALLBACK
, CpuReadToBootFunction
, NULL
, &gReadToBootEvent
);
1352 ASSERT_EFI_ERROR (Status
);
1355 // Now install the MP services protocol.
1358 Status
= gBS
->InstallMultipleProtocolInterfaces (
1360 &gEfiMpServiceProtocolGuid
, &mMpSercicesTemplate
,