TianoCore EDK2 master
Loading...
Searching...
No Matches
MpLib.h File Reference

Go to the source code of this file.

Data Structures

struct  CPU_AP_DATA
 
struct  CPU_INFO_IN_HOB
 
struct  MP_CPU_EXCHANGE_INFO
 
struct  MP_CPU_DATA
 

Macros

#define WAKEUP_AP_SIGNAL   SIGNATURE_32 ('S', 'T', 'A', 'P')
 
#define CPU_INIT_MP_LIB_HOB_GUID
 

Typedefs

typedef struct MP_CPU_DATA CPU_MP_DATA
 

Enumerations

enum  AP_LOOP_MODE {
  ApInHltLoop = 1 , ApInRunLoop = 2 , ApInHltLoop = 1 , ApInMwaitLoop = 2 ,
  ApInRunLoop = 3
}
 
enum  AP_INIT_STATE {
  ApInitConfig = 1 , ApInitReconfig = 2 , ApInitDone = 3 , ApInitConfig = 1 ,
  ApInitDone = 2
}
 
enum  CPU_STATE {
  CpuStateIdle , CpuStateReady , CpuStateBlocked , CpuStateBusy ,
  CpuStateFinished , CpuStateDisabled , CpuStateIdle , CpuStateReady ,
  CpuStateBusy , CpuStateFinished , CpuStateDisabled , CpuStateIdle ,
  CpuStateReady , CpuStateBusy , CpuStateFinished , CpuStateDisabled
}
 

Functions

CPU_MP_DATAGetCpuMpData (VOID)
 
VOID SaveCpuMpData (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)
 
VOID InitMpGlobalData (IN CPU_MP_DATA *CpuMpData)
 
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)
 
EFI_STATUS EnableDisableApWorker (IN UINTN ProcessorNumber, IN BOOLEAN EnableAP, IN UINT32 *HealthFlag OPTIONAL)
 
CPU_MP_DATAGetCpuMpDataFromGuidedHob (VOID)
 
EFI_STATUS CheckThisAP (IN UINTN ProcessorNumber)
 
EFI_STATUS CheckAllAPs (VOID)
 
VOID CheckAndUpdateApsStatus (VOID)
 
VOID EnableDebugAgent (VOID)
 

Variables

EFI_GUID mCpuInitMpLibHobGuid
 

Detailed Description

Common header file for LoongArch MP Initialize Library.

Copyright (c) 2024, Loongson Technology Corporation Limited. All rights reserved.

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

Definition in file MpLib.h.

Macro Definition Documentation

◆ CPU_INIT_MP_LIB_HOB_GUID

#define CPU_INIT_MP_LIB_HOB_GUID
Value:
{ \
0x58eb6a19, 0x3699, 0x4c68, { 0xa8, 0x36, 0xda, 0xcd, 0x8e, 0xdc, 0xad, 0x4a } \
}

Definition at line 29 of file MpLib.h.

◆ WAKEUP_AP_SIGNAL

#define WAKEUP_AP_SIGNAL   SIGNATURE_32 ('S', 'T', 'A', 'P')

Definition at line 27 of file MpLib.h.

Typedef Documentation

◆ CPU_MP_DATA

typedef struct MP_CPU_DATA CPU_MP_DATA

Definition at line 94 of file MpLib.h.

Enumeration Type Documentation

◆ AP_INIT_STATE

enum AP_INIT_STATE

Definition at line 46 of file MpLib.h.

◆ AP_LOOP_MODE

enum AP_LOOP_MODE

Definition at line 38 of file MpLib.h.

◆ CPU_STATE

enum CPU_STATE

Definition at line 55 of file MpLib.h.

Function Documentation

◆ 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 910 of file MpLib.c.

◆ CheckAndUpdateApsStatus()

VOID CheckAndUpdateApsStatus ( VOID  )

Checks APs status and updates APs status if needed.

Definition at line 235 of file DxeMpLib.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 863 of file MpLib.c.

◆ EnableDebugAgent()

VOID EnableDebugAgent ( VOID  )

Enable Debug Agent to support source debugging on AP function. This instance will added in the future.

Enable Debug Agent to support source debugging on AP function.

Definition at line 40 of file DxeMpLib.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. This instance will be added in the future.

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.

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 2745 of file MpLib.c.

◆ GetCpuMpData()

CPU_MP_DATA * GetCpuMpData ( VOID  )

Get the pointer to CPU MP Data structure.

Returns
The pointer to CPU MP Data structure.

Get pointer to CPU MP Data structure.

Returns
The pointer to CPU MP Data structure.

Get pointer to CPU MP Data structure. For BSP, the pointer is retrieved from HOB. For AP, the structure is stored in the top of each AP's stack.

Returns
The pointer to CPU MP Data structure.

Definition at line 56 of file DxeMpLib.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 1609 of file MpLib.c.

◆ InitMpGlobalData()

VOID InitMpGlobalData ( IN CPU_MP_DATA CpuMpData)

Initialize global data for MP support.

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

Install Notify

Definition at line 499 of file DxeMpLib.c.

◆ SaveCpuMpData()

VOID SaveCpuMpData ( IN CPU_MP_DATA CpuMpData)

Save the pointer to CPU MP Data structure.

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

Definition at line 70 of file DxeMpLib.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]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.

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 1019 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 1176 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.

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. Currently not used on LoongArch.

Definition at line 672 of file MpLib.c.

Variable Documentation

◆ mCpuInitMpLibHobGuid

EFI_GUID mCpuInitMpLibHobGuid
extern

Definition at line 17 of file MpLib.c.