TianoCore EDK2 master
MpLib.c File Reference
#include "MpLib.h"
#include <Library/VmgExitLib.h>
#include <Register/Amd/Fam17Msr.h>
#include <Register/Amd/Ghcb.h>

Go to the source code of this file.

Functions

BOOLEAN IsBspExecuteDisableEnabled (VOID)
 
VOID EFIAPI FutureBSPProc (IN VOID *Buffer)
 
CPU_STATE GetApState (IN CPU_AP_DATA *CpuData)
 
VOID SetApState (IN CPU_AP_DATA *CpuData, IN CPU_STATE State)
 
VOID SaveLocalApicTimerSetting (IN CPU_MP_DATA *CpuMpData)
 
VOID SyncLocalApicTimerSetting (IN CPU_MP_DATA *CpuMpData)
 
VOID SaveVolatileRegisters (OUT CPU_VOLATILE_REGISTERS *VolatileRegisters)
 
VOID RestoreVolatileRegisters (IN CPU_VOLATILE_REGISTERS *VolatileRegisters, IN BOOLEAN IsRestoreDr)
 
BOOLEAN IsMwaitSupport (VOID)
 
UINT8 GetApLoopMode (OUT UINT32 *MonitorFilterSize)
 
VOID SortApicId (IN CPU_MP_DATA *CpuMpData)
 
VOID EFIAPI ApFuncEnableX2Apic (IN OUT VOID *Buffer)
 
VOID EFIAPI ApInitializeSync (IN OUT VOID *Buffer)
 
EFI_STATUS GetProcessorNumber (IN CPU_MP_DATA *CpuMpData, OUT UINTN *ProcessorNumber)
 
UINTN CollectProcessorCount (IN CPU_MP_DATA *CpuMpData)
 
VOID InitializeApData (IN OUT CPU_MP_DATA *CpuMpData, IN UINTN ProcessorNumber, IN UINT32 BistData, IN UINT64 ApTopOfStack)
 
VOID EFIAPI ApWakeupFunction (IN MP_CPU_EXCHANGE_INFO *ExchangeInfo, IN UINTN ApIndex)
 
VOID WaitApWakeup (IN volatile UINT32 *ApStartupSignalBuffer)
 
STATIC VOID GetApResetVectorSize (IN MP_ASSEMBLY_ADDRESS_MAP *AddressMap, OUT UINTN *SizeBelow1Mb OPTIONAL, OUT UINTN *SizeAbove1Mb OPTIONAL)
 
VOID FillExchangeInfoData (IN CPU_MP_DATA *CpuMpData)
 
VOID TimedWaitForApFinish (IN CPU_MP_DATA *CpuMpData, IN UINT32 FinishedApLimit, IN UINT32 TimeLimit)
 
VOID BackupAndPrepareWakeupBuffer (IN CPU_MP_DATA *CpuMpData)
 
VOID RestoreWakeupBuffer (IN CPU_MP_DATA *CpuMpData)
 
VOID AllocateResetVectorBelow1Mb (IN OUT CPU_MP_DATA *CpuMpData)
 
VOID FreeResetVector (IN CPU_MP_DATA *CpuMpData)
 
VOID WakeUpAP (IN CPU_MP_DATA *CpuMpData, IN BOOLEAN Broadcast, IN UINTN ProcessorNumber, IN EFI_AP_PROCEDURE Procedure OPTIONAL, IN VOID *ProcedureArgument OPTIONAL, IN BOOLEAN WakeUpDisabledAps)
 
UINT64 CalculateTimeout (IN UINTN TimeoutInMicroseconds, OUT UINT64 *CurrentTime)
 
BOOLEAN CheckTimeout (IN OUT UINT64 *PreviousTime, IN UINT64 *TotalTime, IN UINT64 Timeout)
 
VOID ResetProcessorToIdleState (IN UINTN ProcessorNumber)
 
EFI_STATUS GetNextWaitingProcessorNumber (OUT UINTN *NextProcessorNumber)
 
EFI_STATUS CheckThisAP (IN UINTN ProcessorNumber)
 
EFI_STATUS CheckAllAPs (VOID)
 
EFI_STATUS EFIAPI MpInitLibInitialize (VOID)
 
EFI_STATUS EFIAPI MpInitLibGetProcessorInfo (IN UINTN ProcessorNumber, OUT EFI_PROCESSOR_INFORMATION *ProcessorInfoBuffer, OUT EFI_HEALTH_FLAGS *HealthData OPTIONAL)
 
EFI_STATUS SwitchBSPWorker (IN UINTN ProcessorNumber, IN BOOLEAN EnableOldBSP)
 
EFI_STATUS EnableDisableApWorker (IN UINTN ProcessorNumber, IN BOOLEAN EnableAP, IN UINT32 *HealthFlag OPTIONAL)
 
EFI_STATUS EFIAPI MpInitLibWhoAmI (OUT UINTN *ProcessorNumber)
 
EFI_STATUS EFIAPI MpInitLibGetNumberOfProcessors (OUT UINTN *NumberOfProcessors OPTIONAL, OUT UINTN *NumberOfEnabledProcessors OPTIONAL)
 
EFI_STATUS StartupAllCPUsWorker (IN EFI_AP_PROCEDURE Procedure, IN BOOLEAN SingleThread, IN BOOLEAN ExcludeBsp, IN EFI_EVENT WaitEvent OPTIONAL, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL, OUT UINTN **FailedCpuList OPTIONAL)
 
EFI_STATUS StartupThisAPWorker (IN EFI_AP_PROCEDURE Procedure, IN UINTN ProcessorNumber, IN EFI_EVENT WaitEvent OPTIONAL, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL, OUT BOOLEAN *Finished OPTIONAL)
 
CPU_MP_DATAGetCpuMpDataFromGuidedHob (VOID)
 
EFI_STATUS EFIAPI MpInitLibStartupAllCPUs (IN EFI_AP_PROCEDURE Procedure, IN UINTN TimeoutInMicroseconds, IN VOID *ProcedureArgument OPTIONAL)
 
STATIC BOOLEAN AmdMemEncryptionAttrCheck (IN UINT64 CurrentAttr, IN CONFIDENTIAL_COMPUTING_GUEST_ATTR Attr)
 
BOOLEAN EFIAPI ConfidentialComputingGuestHas (IN CONFIDENTIAL_COMPUTING_GUEST_ATTR Attr)
 

Variables

EFI_GUID mCpuInitMpLibHobGuid = CPU_INIT_MP_LIB_HOB_GUID
 

Detailed Description

CPU MP Initialize Library common functions.

Copyright (c) 2016 - 2021, Intel Corporation. All rights reserved.
Copyright (c) 2020, AMD Inc. All rights reserved.

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file MpLib.c.

Function Documentation

◆ AllocateResetVectorBelow1Mb()

VOID AllocateResetVectorBelow1Mb ( IN OUT CPU_MP_DATA CpuMpData)

Allocate reset vector buffer.

Parameters
[in,out]CpuMpDataThe pointer to CPU MP Data structure.

Definition at line 1026 of file MpLib.c.

◆ AmdMemEncryptionAttrCheck()

STATIC BOOLEAN AmdMemEncryptionAttrCheck ( IN UINT64  CurrentAttr,
IN CONFIDENTIAL_COMPUTING_GUEST_ATTR  Attr 
)

The function check if the specified Attr is set.

Parameters
[in]CurrentAttrThe current attribute.
[in]AttrThe attribute to check.
Return values
TRUEThe specified Attr is set.
FALSEThe specified Attr is not set.

Definition at line 2795 of file MpLib.c.

◆ ApFuncEnableX2Apic()

VOID EFIAPI ApFuncEnableX2Apic ( IN OUT VOID Buffer)

Enable x2APIC mode on APs.

Parameters
[in,out]BufferPointer to private data buffer.

Definition at line 400 of file MpLib.c.

◆ ApInitializeSync()

VOID EFIAPI ApInitializeSync ( IN OUT VOID Buffer)

Do sync on APs.

Parameters
[in,out]BufferPointer to private data buffer.

Definition at line 414 of file MpLib.c.

◆ ApWakeupFunction()

VOID EFIAPI ApWakeupFunction ( IN MP_CPU_EXCHANGE_INFO ExchangeInfo,
IN UINTN  ApIndex 
)

This function will be called from AP reset code if BSP uses WakeUpAP.

Parameters
[in]ExchangeInfoPointer to the MP exchange info buffer
[in]ApIndexNumber of current executing AP

Definition at line 612 of file MpLib.c.

◆ BackupAndPrepareWakeupBuffer()

VOID BackupAndPrepareWakeupBuffer ( IN CPU_MP_DATA CpuMpData)

Get available system memory below 1MB by specified size.

Parameters
[in]CpuMpDataThe pointer to CPU MP Data structure.

Definition at line 987 of file MpLib.c.

◆ CalculateTimeout()

UINT64 CalculateTimeout ( IN UINTN  TimeoutInMicroseconds,
OUT UINT64 CurrentTime 
)

Calculate timeout value and return the current performance counter value.

Calculate the number of performance counter ticks required for a timeout. If TimeoutInMicroseconds is 0, return value is also 0, which is recognized as infinity.

Parameters
[in]TimeoutInMicrosecondsTimeout value in microseconds.
[out]CurrentTimeReturns the current value of the performance counter.
Returns
Expected time stamp counter for timeout. If TimeoutInMicroseconds is 0, return value is also 0, which is recognized as infinity.

Definition at line 1342 of file MpLib.c.

◆ CheckAllAPs()

EFI_STATUS CheckAllAPs ( VOID  )

Checks status of all APs.

This function checks whether all APs have finished task assigned by StartupAllAPs(), and whether timeout expires.

Return values
EFI_SUCCESSAll APs have finished task assigned by StartupAllAPs().
EFI_TIMEOUTThe timeout expires.
EFI_NOT_READYAPs have not finished task and timeout has not expired.

Definition at line 1641 of file MpLib.c.

◆ CheckThisAP()

EFI_STATUS CheckThisAP ( IN UINTN  ProcessorNumber)

Checks status of specified AP.

This function checks whether the specified AP has finished the task assigned by StartupThisAP(), and whether timeout expires.

Parameters
[in]ProcessorNumberThe handle number of processor.
Return values
EFI_SUCCESSSpecified AP has finished task assigned by StartupThisAPs().
EFI_TIMEOUTThe timeout expires.
EFI_NOT_READYSpecified AP has not finished task and timeout has not expired.

Definition at line 1584 of file MpLib.c.

◆ CheckTimeout()

BOOLEAN CheckTimeout ( IN OUT UINT64 PreviousTime,
IN UINT64 TotalTime,
IN UINT64  Timeout 
)

Checks whether timeout expires.

Check whether the number of elapsed performance counter ticks required for a timeout condition has been reached. If Timeout is zero, which means infinity, return value is always FALSE.

Parameters
[in,out]PreviousTimeOn input, the value of the performance counter when it was last read. On output, the current value of the performance counter
[in]TotalTimeThe total amount of elapsed time in performance counter ticks.
[in]TimeoutThe number of performance counter ticks required to reach a timeout condition.
Return values
TRUEA timeout condition has been reached.
FALSEA timeout condition has not been reached.

Definition at line 1418 of file MpLib.c.

◆ CollectProcessorCount()

UINTN CollectProcessorCount ( IN CPU_MP_DATA CpuMpData)

This function will get CPU count in the system.

Parameters
[in]CpuMpDataPointer to PEI CPU MP Data
Returns
CPU count detected

Definition at line 477 of file MpLib.c.

◆ ConfidentialComputingGuestHas()

BOOLEAN EFIAPI ConfidentialComputingGuestHas ( IN CONFIDENTIAL_COMPUTING_GUEST_ATTR  Attr)

Check if the specified confidential computing attribute is active.

Parameters
[in]AttrThe attribute to check.
Return values
TRUEThe specified Attr is active.
FALSEThe specified Attr is not active.

Definition at line 2829 of file MpLib.c.

◆ EnableDisableApWorker()

EFI_STATUS EnableDisableApWorker ( IN UINTN  ProcessorNumber,
IN BOOLEAN  EnableAP,
IN UINT32 *HealthFlag  OPTIONAL 
)

Worker function to let the caller enable or disable an AP from this point onward. This service may only be called from the BSP.

Parameters
[in]ProcessorNumberThe handle number of AP.
[in]EnableAPSpecifies the new state for the processor for enabled, FALSE for disabled.
[in]HealthFlagIf not NULL, a pointer to a value that specifies the new health status of the AP.
Return values
EFI_SUCCESSThe specified AP was enabled or disabled successfully.
othersFailed to Enable/Disable AP.

Definition at line 2295 of file MpLib.c.

◆ FillExchangeInfoData()

VOID FillExchangeInfoData ( IN CPU_MP_DATA CpuMpData)

This function will fill the exchange info structure.

Parameters
[in]CpuMpDataPointer to CPU MP Data

Definition at line 882 of file MpLib.c.

◆ FreeResetVector()

VOID FreeResetVector ( IN CPU_MP_DATA CpuMpData)

Free AP reset vector buffer.

Parameters
[in]CpuMpDataThe pointer to CPU MP Data structure.

Definition at line 1093 of file MpLib.c.

◆ FutureBSPProc()

VOID EFIAPI FutureBSPProc ( IN VOID Buffer)

Worker function for SwitchBSP().

Worker function for SwitchBSP(), assigned to the AP which is intended to become BSP.

Parameters
[in]BufferPointer to CPU MP Data

Definition at line 79 of file MpLib.c.

◆ GetApLoopMode()

UINT8 GetApLoopMode ( OUT UINT32 MonitorFilterSize)

Get AP loop mode.

Parameters
[out]MonitorFilterSizeReturns the largest monitor-line size in bytes.
Returns
The AP loop mode.

Definition at line 278 of file MpLib.c.

◆ GetApResetVectorSize()

STATIC VOID GetApResetVectorSize ( IN MP_ASSEMBLY_ADDRESS_MAP AddressMap,
OUT UINTN *SizeBelow1Mb  OPTIONAL,
OUT UINTN *SizeAbove1Mb  OPTIONAL 
)

Calculate the size of the reset vector.

Parameters
[in]AddressMapThe pointer to Address Map structure.
[out]SizeBelow1MbReturn the size of below 1MB memory for AP reset area.
[out]SizeAbove1MbReturn the size of abvoe 1MB memory for AP reset area.

Definition at line 860 of file MpLib.c.

◆ GetApState()

CPU_STATE GetApState ( IN CPU_AP_DATA CpuData)

Get the Application Processors state.

Parameters
[in]CpuDataThe pointer to CPU_AP_DATA of specified AP
Returns
The AP status

Definition at line 97 of file MpLib.c.

◆ GetCpuMpDataFromGuidedHob()

CPU_MP_DATA * GetCpuMpDataFromGuidedHob ( VOID  )

Get pointer to CPU MP Data structure from GUIDed HOB.

Returns
The pointer to CPU MP Data structure.

Definition at line 2720 of file MpLib.c.

◆ GetNextWaitingProcessorNumber()

EFI_STATUS GetNextWaitingProcessorNumber ( OUT UINTN NextProcessorNumber)

Searches for the next waiting AP.

Search for the next AP that is put in waiting state by single-threaded StartupAllAPs().

Parameters
[out]NextProcessorNumberPointer to the processor number of the next waiting AP.
Return values
EFI_SUCCESSThe next waiting AP has been found.
EFI_NOT_FOUNDNo waiting AP exists.

Definition at line 1553 of file MpLib.c.

◆ GetProcessorNumber()

EFI_STATUS GetProcessorNumber ( IN CPU_MP_DATA CpuMpData,
OUT UINTN ProcessorNumber 
)

Find the current Processor number by APIC ID.

Parameters
[in]CpuMpDataPointer to PEI CPU MP Data
[out]ProcessorNumberReturn the pocessor number found
Return values
EFI_SUCCESSProcessorNumber is found and returned.
EFI_NOT_FOUNDProcessorNumber is not found.

Definition at line 445 of file MpLib.c.

◆ InitializeApData()

VOID InitializeApData ( IN OUT CPU_MP_DATA CpuMpData,
IN UINTN  ProcessorNumber,
IN UINT32  BistData,
IN UINT64  ApTopOfStack 
)

Initialize CPU AP Data when AP is wakeup at the first time.

Parameters
[in,out]CpuMpDataPointer to PEI CPU MP Data
[in]ProcessorNumberThe handle number of processor
[in]BistDataProcessor BIST data
[in]ApTopOfStackTop of AP stack

Definition at line 565 of file MpLib.c.

◆ IsBspExecuteDisableEnabled()

BOOLEAN IsBspExecuteDisableEnabled ( VOID  )

The function will check if BSP Execute Disable is enabled.

DxeIpl may have enabled Execute Disable for BSP, APs need to get the status and sync up the settings. If BSP's CR0.Paging is not set, BSP execute Disble feature is not working actually.

Return values
TRUEBSP Execute Disable is enabled.
FALSEBSP Execute Disable is not enabled.

Definition at line 30 of file MpLib.c.

◆ IsMwaitSupport()

BOOLEAN IsMwaitSupport ( VOID  )

Detect whether Mwait-monitor feature is supported.

Return values
TRUEMwait-monitor feature is supported.
FALSEMwait-monitor feature is not supported.

Definition at line 260 of file MpLib.c.

◆ MpInitLibGetNumberOfProcessors()

EFI_STATUS EFIAPI MpInitLibGetNumberOfProcessors ( OUT UINTN *NumberOfProcessors  OPTIONAL,
OUT UINTN *NumberOfEnabledProcessors  OPTIONAL 
)

Retrieves the number of logical processor in the platform and the number of those logical processors that are enabled on this boot. This service may only be called from the BSP.

Parameters
[out]NumberOfProcessorsPointer to the total number of logical processors in the system, including the BSP and disabled APs.
[out]NumberOfEnabledProcessorsPointer to the number of enabled logical processors that exist in system, including the BSP.
Return values
EFI_SUCCESSThe number of logical processors and enabled logical processors was retrieved.
EFI_DEVICE_ERRORThe calling processor is an AP.
EFI_INVALID_PARAMETERNumberOfProcessors is NULL and NumberOfEnabledProcessors is NULL.
EFI_NOT_READYMP Initialize Library is not initialized.

Definition at line 2391 of file MpLib.c.

◆ MpInitLibGetProcessorInfo()

EFI_STATUS EFIAPI MpInitLibGetProcessorInfo ( IN UINTN  ProcessorNumber,
OUT EFI_PROCESSOR_INFORMATION ProcessorInfoBuffer,
OUT EFI_HEALTH_FLAGS *HealthData  OPTIONAL 
)

Gets detailed MP-related information on the requested processor at the instant this call is made. This service may only be called from the BSP.

Parameters
[in]ProcessorNumberThe handle number of processor.
[out]ProcessorInfoBufferA pointer to the buffer where information for the requested processor is deposited.
[out]HealthDataReturn processor health data.
Return values
EFI_SUCCESSProcessor information was returned.
EFI_DEVICE_ERRORThe calling processor is an AP.
EFI_INVALID_PARAMETERProcessorInfoBuffer is NULL.
EFI_NOT_FOUNDThe processor with the handle specified by ProcessorNumber does not exist in the platform.
EFI_NOT_READYMP Initialize Library is not initialized.

Definition at line 2059 of file MpLib.c.

◆ MpInitLibInitialize()

EFI_STATUS EFIAPI MpInitLibInitialize ( VOID  )

MP Initialize Library initialization.

This service will allocate AP reset vector and wakeup all APs to do APs initialization.

This service must be invoked before all other MP Initialize Library service are invoked.

Return values
EFI_SUCCESSMP initialization succeeds.
OthersMP initialization fails.

Definition at line 1764 of file MpLib.c.

◆ MpInitLibStartupAllCPUs()

EFI_STATUS EFIAPI MpInitLibStartupAllCPUs ( IN EFI_AP_PROCEDURE  Procedure,
IN UINTN  TimeoutInMicroseconds,
IN VOID *ProcedureArgument  OPTIONAL 
)

This service executes a caller provided function on all enabled CPUs.

Parameters
[in]ProcedureA pointer to the function to be run on enabled APs of the system. See type EFI_AP_PROCEDURE.
[in]TimeoutInMicrosecondsIndicates the time limit in microseconds for APs to return from Procedure, either for blocking or non-blocking mode. Zero means infinity. TimeoutInMicroseconds is ignored for BSP.
[in]ProcedureArgumentThe parameter passed into Procedure for all APs.
Return values
EFI_SUCCESSIn blocking mode, all CPUs have finished before the timeout expired.
EFI_SUCCESSIn non-blocking mode, function has been dispatched to all enabled CPUs.
EFI_DEVICE_ERRORCaller processor is AP.
EFI_NOT_READYAny enabled APs are busy.
EFI_NOT_READYMP Initialize Library is not initialized.
EFI_TIMEOUTIn blocking mode, the timeout expired before all enabled APs have finished.
EFI_INVALID_PARAMETERProcedure is NULL.

Definition at line 2766 of file MpLib.c.

◆ MpInitLibWhoAmI()

EFI_STATUS EFIAPI MpInitLibWhoAmI ( OUT UINTN ProcessorNumber)

This return the handle number for the calling processor. This service may be called from the BSP and APs.

Parameters
[out]ProcessorNumberPointer to the handle number of AP. The range is from 0 to the total number of logical processors minus 1. The total number of logical processors can be retrieved by MpInitLibGetNumberOfProcessors().
Return values
EFI_SUCCESSThe current processor handle number was returned in ProcessorNumber.
EFI_INVALID_PARAMETERProcessorNumber is NULL.
EFI_NOT_READYMP Initialize Library is not initialized.

Definition at line 2354 of file MpLib.c.

◆ ResetProcessorToIdleState()

VOID ResetProcessorToIdleState ( IN UINTN  ProcessorNumber)

Reset an AP to Idle state.

Any task being executed by the AP will be aborted and the AP will be waiting for a new task in Wait-For-SIPI state.

Parameters
[in]ProcessorNumberThe handle number of processor.

Definition at line 1522 of file MpLib.c.

◆ RestoreVolatileRegisters()

VOID RestoreVolatileRegisters ( IN CPU_VOLATILE_REGISTERS VolatileRegisters,
IN BOOLEAN  IsRestoreDr 
)

Restore the volatile registers following INIT IPI.

Parameters
[in]VolatileRegistersPointer to volatile resisters
[in]IsRestoreDrTRUE: Restore DRx if supported FALSE: Do not restore DRx

Definition at line 211 of file MpLib.c.

◆ RestoreWakeupBuffer()

VOID RestoreWakeupBuffer ( IN CPU_MP_DATA CpuMpData)

Restore wakeup buffer data.

Parameters
[in]CpuMpDataThe pointer to CPU MP Data structure.

Definition at line 1009 of file MpLib.c.

◆ SaveLocalApicTimerSetting()

VOID SaveLocalApicTimerSetting ( IN CPU_MP_DATA CpuMpData)

Save BSP's local APIC timer setting.

Parameters
[in]CpuMpDataPointer to CPU MP Data

Definition at line 127 of file MpLib.c.

◆ SaveVolatileRegisters()

VOID SaveVolatileRegisters ( OUT CPU_VOLATILE_REGISTERS VolatileRegisters)

Save the volatile registers required to be restored following INIT IPI.

Parameters
[out]VolatileRegistersReturns buffer saved the volatile resisters

Definition at line 174 of file MpLib.c.

◆ SetApState()

VOID SetApState ( IN CPU_AP_DATA CpuData,
IN CPU_STATE  State 
)

Set the Application Processors state.

Parameters
[in]CpuDataThe pointer to CPU_AP_DATA of specified AP
[in]StateThe AP status

Definition at line 111 of file MpLib.c.

◆ SortApicId()

VOID SortApicId ( IN CPU_MP_DATA CpuMpData)

Sort the APIC ID of all processors.

This function sorts the APIC ID of all processors so that processor number is assigned in the ascending order of APIC ID which eases MP debugging.

Parameters
[in]CpuMpDataPointer to PEI CPU MP Data

Definition at line 332 of file MpLib.c.

◆ StartupAllCPUsWorker()

EFI_STATUS StartupAllCPUsWorker ( IN EFI_AP_PROCEDURE  Procedure,
IN BOOLEAN  SingleThread,
IN BOOLEAN  ExcludeBsp,
IN EFI_EVENT WaitEvent  OPTIONAL,
IN UINTN  TimeoutInMicroseconds,
IN VOID *ProcedureArgument  OPTIONAL,
OUT UINTN **FailedCpuList  OPTIONAL 
)

Worker function to execute a caller provided function on all enabled APs.

Parameters
[in]ProcedureA pointer to the function to be run on enabled APs of the system.
[in]SingleThreadIf TRUE, then all the enabled APs execute the function specified by Procedure one by one, in ascending order of processor handle number. If FALSE, then all the enabled APs execute the function specified by Procedure simultaneously.
[in]ExcludeBspWhether let BSP also trig this task.
[in]WaitEventThe event created by the caller with CreateEvent() service.
[in]TimeoutInMicrosecondsIndicates the time limit in microseconds for APs to return from Procedure, either for blocking or non-blocking mode.
[in]ProcedureArgumentThe parameter passed into Procedure for all APs.
[out]FailedCpuListIf all APs finish successfully, then its content is set to NULL. If not all APs finish before timeout expires, then its content is set to address of the buffer holding handle numbers of the failed APs.
Return values
EFI_SUCCESSIn blocking mode, all APs have finished before the timeout expired.
EFI_SUCCESSIn non-blocking mode, function has been dispatched to all enabled APs.
othersFailed to Startup all APs.

Definition at line 2468 of file MpLib.c.

◆ StartupThisAPWorker()

EFI_STATUS StartupThisAPWorker ( IN EFI_AP_PROCEDURE  Procedure,
IN UINTN  ProcessorNumber,
IN EFI_EVENT WaitEvent  OPTIONAL,
IN UINTN  TimeoutInMicroseconds,
IN VOID *ProcedureArgument  OPTIONAL,
OUT BOOLEAN *Finished  OPTIONAL 
)

Worker function to let the caller get one enabled AP to execute a caller-provided function.

Parameters
[in]ProcedureA pointer to the function to be run on enabled APs of the system.
[in]ProcessorNumberThe handle number of the AP.
[in]WaitEventThe event created by the caller with CreateEvent() service.
[in]TimeoutInMicrosecondsIndicates the time limit in microseconds for APs to return from Procedure, either for blocking or non-blocking mode.
[in]ProcedureArgumentThe parameter passed into Procedure for all APs.
[out]FinishedIf AP returns from Procedure before the timeout expires, its content is set to TRUE. Otherwise, the value is set to FALSE.
Return values
EFI_SUCCESSIn blocking mode, specified AP finished before the timeout expires.
othersFailed to Startup AP.

Definition at line 2626 of file MpLib.c.

◆ SwitchBSPWorker()

EFI_STATUS SwitchBSPWorker ( IN UINTN  ProcessorNumber,
IN BOOLEAN  EnableOldBSP 
)

Worker function to switch the requested AP to be the BSP from that point onward.

Parameters
[in]ProcessorNumberThe handle number of AP that is to become the new BSP.
[in]EnableOldBSPIf TRUE, then the old BSP will be listed as an enabled AP. Otherwise, it will be disabled.
Return values
EFI_SUCCESSBSP successfully switched.
othersFailed to switch BSP.

Definition at line 2152 of file MpLib.c.

◆ SyncLocalApicTimerSetting()

VOID SyncLocalApicTimerSetting ( IN CPU_MP_DATA CpuMpData)

Sync local APIC timer setting from BSP to AP.

Parameters
[in]CpuMpDataPointer to CPU MP Data

Definition at line 149 of file MpLib.c.

◆ TimedWaitForApFinish()

VOID TimedWaitForApFinish ( IN CPU_MP_DATA CpuMpData,
IN UINT32  FinishedApLimit,
IN UINT32  TimeLimit 
)

Helper function that waits until the finished AP count reaches the specified limit, or the specified timeout elapses (whichever comes first).

Parameters
[in]CpuMpDataPointer to CPU MP Data.
[in]FinishedApLimitThe number of finished APs to wait for.
[in]TimeLimitThe number of microseconds to wait for.

Definition at line 1469 of file MpLib.c.

◆ WaitApWakeup()

VOID WaitApWakeup ( IN volatile UINT32 ApStartupSignalBuffer)

Wait for AP wakeup and write AP start-up signal till AP is waken up.

Parameters
[in]ApStartupSignalBufferPointer to AP wakeup signal

Definition at line 833 of file MpLib.c.

◆ WakeUpAP()

VOID WakeUpAP ( IN CPU_MP_DATA CpuMpData,
IN BOOLEAN  Broadcast,
IN UINTN  ProcessorNumber,
IN EFI_AP_PROCEDURE Procedure  OPTIONAL,
IN VOID *ProcedureArgument  OPTIONAL,
IN BOOLEAN  WakeUpDisabledAps 
)

This function will be called by BSP to wakeup AP.

Parameters
[in]CpuMpDataPointer to CPU MP Data
[in]BroadcastTRUE: Send broadcast IPI to all APs FALSE: Send IPI to AP by ApicId
[in]ProcessorNumberThe handle number of specified processor
[in]ProcedureThe function to be invoked by AP
[in]ProcedureArgumentThe argument to be passed into AP function
[in]WakeUpDisabledApsWhether need to wake up disabled APs in broadcast mode.

Definition at line 1120 of file MpLib.c.

Variable Documentation

◆ mCpuInitMpLibHobGuid

EFI_GUID mCpuInitMpLibHobGuid = CPU_INIT_MP_LIB_HOB_GUID

Definition at line 16 of file MpLib.c.