]> git.proxmox.com Git - mirror_edk2.git/blob - UefiCpuPkg/Library/MpInitLib/DxeMpLib.c
8f5074b43816d4ba97ef3e69f1dfc17e93b8db2f
[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
17 #include <Library/UefiLib.h>
18 #include <Library/UefiBootServicesTableLib.h>
19
20 #define AP_CHECK_INTERVAL (EFI_TIMER_PERIOD_MILLISECONDS (100))
21 #define AP_SAFE_STACK_SIZE 128
22
23 CPU_MP_DATA *mCpuMpData = NULL;
24 EFI_EVENT mCheckAllApsEvent = NULL;
25 EFI_EVENT mMpInitExitBootServicesEvent = NULL;
26 EFI_EVENT mLegacyBootEvent = NULL;
27 volatile BOOLEAN mStopCheckAllApsStatus = TRUE;
28 VOID *mReservedApLoopFunc = NULL;
29 UINTN mReservedTopOfApStack;
30 volatile UINT32 mNumberToFinish = 0;
31
32 /**
33 Get the pointer to CPU MP Data structure.
34
35 @return The pointer to CPU MP Data structure.
36 **/
37 CPU_MP_DATA *
38 GetCpuMpData (
39 VOID
40 )
41 {
42 ASSERT (mCpuMpData != NULL);
43 return mCpuMpData;
44 }
45
46 /**
47 Save the pointer to CPU MP Data structure.
48
49 @param[in] CpuMpData The pointer to CPU MP Data structure will be saved.
50 **/
51 VOID
52 SaveCpuMpData (
53 IN CPU_MP_DATA *CpuMpData
54 )
55 {
56 mCpuMpData = CpuMpData;
57 }
58
59 /**
60 Allocate reset vector buffer.
61
62 @param[in, out] CpuMpData The pointer to CPU MP Data structure.
63 **/
64 VOID
65 AllocateResetVector (
66 IN OUT CPU_MP_DATA *CpuMpData
67 )
68 {
69 EFI_STATUS Status;
70 UINTN ApResetVectorSize;
71 EFI_PHYSICAL_ADDRESS StartAddress;
72
73 if (CpuMpData->SaveRestoreFlag) {
74 BackupAndPrepareWakeupBuffer (CpuMpData);
75 } else {
76 ApResetVectorSize = CpuMpData->AddressMap.RendezvousFunnelSize +
77 sizeof (MP_CPU_EXCHANGE_INFO);
78
79 StartAddress = BASE_1MB;
80 Status = gBS->AllocatePages (
81 AllocateMaxAddress,
82 EfiACPIMemoryNVS,
83 EFI_SIZE_TO_PAGES (ApResetVectorSize),
84 &StartAddress
85 );
86 ASSERT_EFI_ERROR (Status);
87
88 CpuMpData->WakeupBuffer = (UINTN) StartAddress;
89 CpuMpData->MpCpuExchangeInfo = (MP_CPU_EXCHANGE_INFO *) (UINTN)
90 (CpuMpData->WakeupBuffer + CpuMpData->AddressMap.RendezvousFunnelSize);
91 //
92 // copy AP reset code in it
93 //
94 CopyMem (
95 (VOID *) CpuMpData->WakeupBuffer,
96 (VOID *) CpuMpData->AddressMap.RendezvousFunnelAddress,
97 CpuMpData->AddressMap.RendezvousFunnelSize
98 );
99 }
100 }
101
102 /**
103 Free AP reset vector buffer.
104
105 @param[in] CpuMpData The pointer to CPU MP Data structure.
106 **/
107 VOID
108 FreeResetVector (
109 IN CPU_MP_DATA *CpuMpData
110 )
111 {
112 EFI_STATUS Status;
113 UINTN ApResetVectorSize;
114
115 if (CpuMpData->SaveRestoreFlag) {
116 RestoreWakeupBuffer (CpuMpData);
117 } else {
118 ApResetVectorSize = CpuMpData->AddressMap.RendezvousFunnelSize +
119 sizeof (MP_CPU_EXCHANGE_INFO);
120 Status = gBS->FreePages(
121 (EFI_PHYSICAL_ADDRESS)CpuMpData->WakeupBuffer,
122 EFI_SIZE_TO_PAGES (ApResetVectorSize)
123 );
124 ASSERT_EFI_ERROR (Status);
125 }
126 }
127
128 /**
129 Checks APs status and updates APs status if needed.
130
131 **/
132 VOID
133 CheckAndUpdateApsStatus (
134 VOID
135 )
136 {
137 UINTN ProcessorNumber;
138 EFI_STATUS Status;
139 CPU_MP_DATA *CpuMpData;
140
141 CpuMpData = GetCpuMpData ();
142
143 //
144 // First, check whether pending StartupAllAPs() exists.
145 //
146 if (CpuMpData->WaitEvent != NULL) {
147
148 Status = CheckAllAPs ();
149 //
150 // If all APs finish for StartupAllAPs(), signal the WaitEvent for it.
151 //
152 if (Status != EFI_NOT_READY) {
153 Status = gBS->SignalEvent (CpuMpData->WaitEvent);
154 CpuMpData->WaitEvent = NULL;
155 }
156 }
157
158 //
159 // Second, check whether pending StartupThisAPs() callings exist.
160 //
161 for (ProcessorNumber = 0; ProcessorNumber < CpuMpData->CpuCount; ProcessorNumber++) {
162
163 if (CpuMpData->CpuData[ProcessorNumber].WaitEvent == NULL) {
164 continue;
165 }
166
167 Status = CheckThisAP (ProcessorNumber);
168
169 if (Status != EFI_NOT_READY) {
170 gBS->SignalEvent (CpuMpData->CpuData[ProcessorNumber].WaitEvent);
171 CpuMpData->CpuData[ProcessorNumber].WaitEvent = NULL;
172 }
173 }
174 }
175
176 /**
177 Checks APs' status periodically.
178
179 This function is triggered by timer periodically to check the
180 state of APs for StartupAllAPs() and StartupThisAP() executed
181 in non-blocking mode.
182
183 @param[in] Event Event triggered.
184 @param[in] Context Parameter passed with the event.
185
186 **/
187 VOID
188 EFIAPI
189 CheckApsStatus (
190 IN EFI_EVENT Event,
191 IN VOID *Context
192 )
193 {
194 //
195 // If CheckApsStatus() is not stopped, otherwise return immediately.
196 //
197 if (!mStopCheckAllApsStatus) {
198 CheckAndUpdateApsStatus ();
199 }
200 }
201
202 /**
203 Get Protected mode code segment from current GDT table.
204
205 @return Protected mode code segment value.
206 **/
207 UINT16
208 GetProtectedModeCS (
209 VOID
210 )
211 {
212 IA32_DESCRIPTOR GdtrDesc;
213 IA32_SEGMENT_DESCRIPTOR *GdtEntry;
214 UINTN GdtEntryCount;
215 UINT16 Index;
216
217 Index = (UINT16) -1;
218 AsmReadGdtr (&GdtrDesc);
219 GdtEntryCount = (GdtrDesc.Limit + 1) / sizeof (IA32_SEGMENT_DESCRIPTOR);
220 GdtEntry = (IA32_SEGMENT_DESCRIPTOR *) GdtrDesc.Base;
221 for (Index = 0; Index < GdtEntryCount; Index++) {
222 if (GdtEntry->Bits.L == 0) {
223 if (GdtEntry->Bits.Type > 8 && GdtEntry->Bits.L == 0) {
224 break;
225 }
226 }
227 GdtEntry++;
228 }
229 ASSERT (Index != -1);
230 return Index * 8;
231 }
232
233 /**
234 Do sync on APs.
235
236 @param[in, out] Buffer Pointer to private data buffer.
237 **/
238 VOID
239 EFIAPI
240 RelocateApLoop (
241 IN OUT VOID *Buffer
242 )
243 {
244 CPU_MP_DATA *CpuMpData;
245 BOOLEAN MwaitSupport;
246 ASM_RELOCATE_AP_LOOP AsmRelocateApLoopFunc;
247 UINTN ProcessorNumber;
248
249 MpInitLibWhoAmI (&ProcessorNumber);
250 CpuMpData = GetCpuMpData ();
251 MwaitSupport = IsMwaitSupport ();
252 AsmRelocateApLoopFunc = (ASM_RELOCATE_AP_LOOP) (UINTN) mReservedApLoopFunc;
253 AsmRelocateApLoopFunc (
254 MwaitSupport,
255 CpuMpData->ApTargetCState,
256 CpuMpData->PmCodeSegment,
257 mReservedTopOfApStack - ProcessorNumber * AP_SAFE_STACK_SIZE,
258 (UINTN) &mNumberToFinish
259 );
260 //
261 // It should never reach here
262 //
263 ASSERT (FALSE);
264 }
265
266 /**
267 Callback function for ExitBootServices.
268
269 @param[in] Event Event whose notification function is being invoked.
270 @param[in] Context The pointer to the notification function's context,
271 which is implementation-dependent.
272
273 **/
274 VOID
275 EFIAPI
276 MpInitChangeApLoopCallback (
277 IN EFI_EVENT Event,
278 IN VOID *Context
279 )
280 {
281 CPU_MP_DATA *CpuMpData;
282
283 CpuMpData = GetCpuMpData ();
284 CpuMpData->SaveRestoreFlag = TRUE;
285 CpuMpData->PmCodeSegment = GetProtectedModeCS ();
286 CpuMpData->ApLoopMode = PcdGet8 (PcdCpuApLoopMode);
287 mNumberToFinish = CpuMpData->CpuCount - 1;
288 WakeUpAP (CpuMpData, TRUE, 0, RelocateApLoop, NULL);
289 while (mNumberToFinish > 0) {
290 CpuPause ();
291 }
292 DEBUG ((DEBUG_INFO, "%a() done!\n", __FUNCTION__));
293 }
294
295 /**
296 Initialize global data for MP support.
297
298 @param[in] CpuMpData The pointer to CPU MP Data structure.
299 **/
300 VOID
301 InitMpGlobalData (
302 IN CPU_MP_DATA *CpuMpData
303 )
304 {
305 EFI_STATUS Status;
306 EFI_PHYSICAL_ADDRESS Address;
307 UINTN ApSafeBufferSize;
308
309 SaveCpuMpData (CpuMpData);
310
311 if (CpuMpData->CpuCount == 1) {
312 //
313 // If only BSP exists, return
314 //
315 return;
316 }
317
318 //
319 // Avoid APs access invalid buffer data which allocated by BootServices,
320 // so we will allocate reserved data for AP loop code. We also need to
321 // allocate this buffer below 4GB due to APs may be transferred to 32bit
322 // protected mode on long mode DXE.
323 // Allocating it in advance since memory services are not available in
324 // Exit Boot Services callback function.
325 //
326 ApSafeBufferSize = CpuMpData->AddressMap.RelocateApLoopFuncSize;
327 ApSafeBufferSize += CpuMpData->CpuCount * AP_SAFE_STACK_SIZE;
328
329 Address = BASE_4GB - 1;
330 Status = gBS->AllocatePages (
331 AllocateMaxAddress,
332 EfiReservedMemoryType,
333 EFI_SIZE_TO_PAGES (ApSafeBufferSize),
334 &Address
335 );
336 ASSERT_EFI_ERROR (Status);
337 mReservedApLoopFunc = (VOID *) (UINTN) Address;
338 ASSERT (mReservedApLoopFunc != NULL);
339 mReservedTopOfApStack = (UINTN) Address + EFI_PAGES_TO_SIZE (EFI_SIZE_TO_PAGES (ApSafeBufferSize));
340 ASSERT ((mReservedTopOfApStack & (UINTN)(CPU_STACK_ALIGNMENT - 1)) == 0);
341 CopyMem (
342 mReservedApLoopFunc,
343 CpuMpData->AddressMap.RelocateApLoopFuncAddress,
344 CpuMpData->AddressMap.RelocateApLoopFuncSize
345 );
346
347 Status = gBS->CreateEvent (
348 EVT_TIMER | EVT_NOTIFY_SIGNAL,
349 TPL_NOTIFY,
350 CheckApsStatus,
351 NULL,
352 &mCheckAllApsEvent
353 );
354 ASSERT_EFI_ERROR (Status);
355
356 //
357 // Set timer to check all APs status.
358 //
359 Status = gBS->SetTimer (
360 mCheckAllApsEvent,
361 TimerPeriodic,
362 AP_CHECK_INTERVAL
363 );
364 ASSERT_EFI_ERROR (Status);
365
366 Status = gBS->CreateEvent (
367 EVT_SIGNAL_EXIT_BOOT_SERVICES,
368 TPL_CALLBACK,
369 MpInitChangeApLoopCallback,
370 NULL,
371 &mMpInitExitBootServicesEvent
372 );
373 ASSERT_EFI_ERROR (Status);
374
375 Status = gBS->CreateEventEx (
376 EVT_NOTIFY_SIGNAL,
377 TPL_CALLBACK,
378 MpInitChangeApLoopCallback,
379 NULL,
380 &gEfiEventLegacyBootGuid,
381 &mLegacyBootEvent
382 );
383 ASSERT_EFI_ERROR (Status);
384 }
385
386 /**
387 This service executes a caller provided function on all enabled APs.
388
389 @param[in] Procedure A pointer to the function to be run on
390 enabled APs of the system. See type
391 EFI_AP_PROCEDURE.
392 @param[in] SingleThread If TRUE, then all the enabled APs execute
393 the function specified by Procedure one by
394 one, in ascending order of processor handle
395 number. If FALSE, then all the enabled APs
396 execute the function specified by Procedure
397 simultaneously.
398 @param[in] WaitEvent The event created by the caller with CreateEvent()
399 service. If it is NULL, then execute in
400 blocking mode. BSP waits until all APs finish
401 or TimeoutInMicroSeconds expires. If it's
402 not NULL, then execute in non-blocking mode.
403 BSP requests the function specified by
404 Procedure to be started on all the enabled
405 APs, and go on executing immediately. If
406 all return from Procedure, or TimeoutInMicroSeconds
407 expires, this event is signaled. The BSP
408 can use the CheckEvent() or WaitForEvent()
409 services to check the state of event. Type
410 EFI_EVENT is defined in CreateEvent() in
411 the Unified Extensible Firmware Interface
412 Specification.
413 @param[in] TimeoutInMicrosecsond Indicates the time limit in microseconds for
414 APs to return from Procedure, either for
415 blocking or non-blocking mode. Zero means
416 infinity. If the timeout expires before
417 all APs return from Procedure, then Procedure
418 on the failed APs is terminated. All enabled
419 APs are available for next function assigned
420 by MpInitLibStartupAllAPs() or
421 MPInitLibStartupThisAP().
422 If the timeout expires in blocking mode,
423 BSP returns EFI_TIMEOUT. If the timeout
424 expires in non-blocking mode, WaitEvent
425 is signaled with SignalEvent().
426 @param[in] ProcedureArgument The parameter passed into Procedure for
427 all APs.
428 @param[out] FailedCpuList If NULL, this parameter is ignored. Otherwise,
429 if all APs finish successfully, then its
430 content is set to NULL. If not all APs
431 finish before timeout expires, then its
432 content is set to address of the buffer
433 holding handle numbers of the failed APs.
434 The buffer is allocated by MP Initialization
435 library, and it's the caller's responsibility to
436 free the buffer with FreePool() service.
437 In blocking mode, it is ready for consumption
438 when the call returns. In non-blocking mode,
439 it is ready when WaitEvent is signaled. The
440 list of failed CPU is terminated by
441 END_OF_CPU_LIST.
442
443 @retval EFI_SUCCESS In blocking mode, all APs have finished before
444 the timeout expired.
445 @retval EFI_SUCCESS In non-blocking mode, function has been dispatched
446 to all enabled APs.
447 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the
448 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was
449 signaled.
450 @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not
451 supported.
452 @retval EFI_DEVICE_ERROR Caller processor is AP.
453 @retval EFI_NOT_STARTED No enabled APs exist in the system.
454 @retval EFI_NOT_READY Any enabled APs are busy.
455 @retval EFI_NOT_READY MP Initialize Library is not initialized.
456 @retval EFI_TIMEOUT In blocking mode, the timeout expired before
457 all enabled APs have finished.
458 @retval EFI_INVALID_PARAMETER Procedure is NULL.
459
460 **/
461 EFI_STATUS
462 EFIAPI
463 MpInitLibStartupAllAPs (
464 IN EFI_AP_PROCEDURE Procedure,
465 IN BOOLEAN SingleThread,
466 IN EFI_EVENT WaitEvent OPTIONAL,
467 IN UINTN TimeoutInMicroseconds,
468 IN VOID *ProcedureArgument OPTIONAL,
469 OUT UINTN **FailedCpuList OPTIONAL
470 )
471 {
472 EFI_STATUS Status;
473
474 //
475 // Temporarily stop checkAllApsStatus for avoid resource dead-lock.
476 //
477 mStopCheckAllApsStatus = TRUE;
478
479 Status = StartupAllAPsWorker (
480 Procedure,
481 SingleThread,
482 WaitEvent,
483 TimeoutInMicroseconds,
484 ProcedureArgument,
485 FailedCpuList
486 );
487
488 //
489 // Start checkAllApsStatus
490 //
491 mStopCheckAllApsStatus = FALSE;
492
493 return Status;
494 }
495
496 /**
497 This service lets the caller get one enabled AP to execute a caller-provided
498 function.
499
500 @param[in] Procedure A pointer to the function to be run on the
501 designated AP of the system. See type
502 EFI_AP_PROCEDURE.
503 @param[in] ProcessorNumber The handle number of the AP. The range is
504 from 0 to the total number of logical
505 processors minus 1. The total number of
506 logical processors can be retrieved by
507 MpInitLibGetNumberOfProcessors().
508 @param[in] WaitEvent The event created by the caller with CreateEvent()
509 service. If it is NULL, then execute in
510 blocking mode. BSP waits until this AP finish
511 or TimeoutInMicroSeconds expires. If it's
512 not NULL, then execute in non-blocking mode.
513 BSP requests the function specified by
514 Procedure to be started on this AP,
515 and go on executing immediately. If this AP
516 return from Procedure or TimeoutInMicroSeconds
517 expires, this event is signaled. The BSP
518 can use the CheckEvent() or WaitForEvent()
519 services to check the state of event. Type
520 EFI_EVENT is defined in CreateEvent() in
521 the Unified Extensible Firmware Interface
522 Specification.
523 @param[in] TimeoutInMicrosecsond Indicates the time limit in microseconds for
524 this AP to finish this Procedure, either for
525 blocking or non-blocking mode. Zero means
526 infinity. If the timeout expires before
527 this AP returns from Procedure, then Procedure
528 on the AP is terminated. The
529 AP is available for next function assigned
530 by MpInitLibStartupAllAPs() or
531 MpInitLibStartupThisAP().
532 If the timeout expires in blocking mode,
533 BSP returns EFI_TIMEOUT. If the timeout
534 expires in non-blocking mode, WaitEvent
535 is signaled with SignalEvent().
536 @param[in] ProcedureArgument The parameter passed into Procedure on the
537 specified AP.
538 @param[out] Finished If NULL, this parameter is ignored. In
539 blocking mode, this parameter is ignored.
540 In non-blocking mode, if AP returns from
541 Procedure before the timeout expires, its
542 content is set to TRUE. Otherwise, the
543 value is set to FALSE. The caller can
544 determine if the AP returned from Procedure
545 by evaluating this value.
546
547 @retval EFI_SUCCESS In blocking mode, specified AP finished before
548 the timeout expires.
549 @retval EFI_SUCCESS In non-blocking mode, the function has been
550 dispatched to specified AP.
551 @retval EFI_UNSUPPORTED A non-blocking mode request was made after the
552 UEFI event EFI_EVENT_GROUP_READY_TO_BOOT was
553 signaled.
554 @retval EFI_UNSUPPORTED WaitEvent is not NULL if non-blocking mode is not
555 supported.
556 @retval EFI_DEVICE_ERROR The calling processor is an AP.
557 @retval EFI_TIMEOUT In blocking mode, the timeout expired before
558 the specified AP has finished.
559 @retval EFI_NOT_READY The specified AP is busy.
560 @retval EFI_NOT_READY MP Initialize Library is not initialized.
561 @retval EFI_NOT_FOUND The processor with the handle specified by
562 ProcessorNumber does not exist.
563 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP or disabled AP.
564 @retval EFI_INVALID_PARAMETER Procedure is NULL.
565
566 **/
567 EFI_STATUS
568 EFIAPI
569 MpInitLibStartupThisAP (
570 IN EFI_AP_PROCEDURE Procedure,
571 IN UINTN ProcessorNumber,
572 IN EFI_EVENT WaitEvent OPTIONAL,
573 IN UINTN TimeoutInMicroseconds,
574 IN VOID *ProcedureArgument OPTIONAL,
575 OUT BOOLEAN *Finished OPTIONAL
576 )
577 {
578 EFI_STATUS Status;
579
580 //
581 // temporarily stop checkAllApsStatus for avoid resource dead-lock.
582 //
583 mStopCheckAllApsStatus = TRUE;
584
585 Status = StartupThisAPWorker (
586 Procedure,
587 ProcessorNumber,
588 WaitEvent,
589 TimeoutInMicroseconds,
590 ProcedureArgument,
591 Finished
592 );
593
594 mStopCheckAllApsStatus = FALSE;
595
596 return Status;
597 }
598
599 /**
600 This service switches the requested AP to be the BSP from that point onward.
601 This service changes the BSP for all purposes. This call can only be performed
602 by the current BSP.
603
604 @param[in] ProcessorNumber The handle number of AP that is to become the new
605 BSP. The range is from 0 to the total number of
606 logical processors minus 1. The total number of
607 logical processors can be retrieved by
608 MpInitLibGetNumberOfProcessors().
609 @param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an
610 enabled AP. Otherwise, it will be disabled.
611
612 @retval EFI_SUCCESS BSP successfully switched.
613 @retval EFI_UNSUPPORTED Switching the BSP cannot be completed prior to
614 this service returning.
615 @retval EFI_UNSUPPORTED Switching the BSP is not supported.
616 @retval EFI_DEVICE_ERROR The calling processor is an AP.
617 @retval EFI_NOT_FOUND The processor with the handle specified by
618 ProcessorNumber does not exist.
619 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the current BSP or
620 a disabled AP.
621 @retval EFI_NOT_READY The specified AP is busy.
622 @retval EFI_NOT_READY MP Initialize Library is not initialized.
623
624 **/
625 EFI_STATUS
626 EFIAPI
627 MpInitLibSwitchBSP (
628 IN UINTN ProcessorNumber,
629 IN BOOLEAN EnableOldBSP
630 )
631 {
632 EFI_STATUS Status;
633 BOOLEAN OldInterruptState;
634
635 //
636 // Before send both BSP and AP to a procedure to exchange their roles,
637 // interrupt must be disabled. This is because during the exchange role
638 // process, 2 CPU may use 1 stack. If interrupt happens, the stack will
639 // be corrupted, since interrupt return address will be pushed to stack
640 // by hardware.
641 //
642 OldInterruptState = SaveAndDisableInterrupts ();
643
644 //
645 // Mask LINT0 & LINT1 for the old BSP
646 //
647 DisableLvtInterrupts ();
648
649 Status = SwitchBSPWorker (ProcessorNumber, EnableOldBSP);
650
651 //
652 // Restore interrupt state.
653 //
654 SetInterruptState (OldInterruptState);
655
656 return Status;
657 }
658
659 /**
660 This service lets the caller enable or disable an AP from this point onward.
661 This service may only be called from the BSP.
662
663 @param[in] ProcessorNumber The handle number of AP.
664 The range is from 0 to the total number of
665 logical processors minus 1. The total number of
666 logical processors can be retrieved by
667 MpInitLibGetNumberOfProcessors().
668 @param[in] EnableAP Specifies the new state for the processor for
669 enabled, FALSE for disabled.
670 @param[in] HealthFlag If not NULL, a pointer to a value that specifies
671 the new health status of the AP. This flag
672 corresponds to StatusFlag defined in
673 EFI_MP_SERVICES_PROTOCOL.GetProcessorInfo(). Only
674 the PROCESSOR_HEALTH_STATUS_BIT is used. All other
675 bits are ignored. If it is NULL, this parameter
676 is ignored.
677
678 @retval EFI_SUCCESS The specified AP was enabled or disabled successfully.
679 @retval EFI_UNSUPPORTED Enabling or disabling an AP cannot be completed
680 prior to this service returning.
681 @retval EFI_UNSUPPORTED Enabling or disabling an AP is not supported.
682 @retval EFI_DEVICE_ERROR The calling processor is an AP.
683 @retval EFI_NOT_FOUND Processor with the handle specified by ProcessorNumber
684 does not exist.
685 @retval EFI_INVALID_PARAMETER ProcessorNumber specifies the BSP.
686 @retval EFI_NOT_READY MP Initialize Library is not initialized.
687
688 **/
689 EFI_STATUS
690 EFIAPI
691 MpInitLibEnableDisableAP (
692 IN UINTN ProcessorNumber,
693 IN BOOLEAN EnableAP,
694 IN UINT32 *HealthFlag OPTIONAL
695 )
696 {
697 EFI_STATUS Status;
698 BOOLEAN TempStopCheckState;
699
700 TempStopCheckState = FALSE;
701 //
702 // temporarily stop checkAllAPsStatus for initialize parameters.
703 //
704 if (!mStopCheckAllApsStatus) {
705 mStopCheckAllApsStatus = TRUE;
706 TempStopCheckState = TRUE;
707 }
708
709 Status = EnableDisableApWorker (ProcessorNumber, EnableAP, HealthFlag);
710
711 if (TempStopCheckState) {
712 mStopCheckAllApsStatus = FALSE;
713 }
714
715 return Status;
716 }