UefiCpuPkg/MpInitLib: Implementation of MpInitLibSwitchBSP()
v4: 1. Simply the internal function SwitchBSPWorker()'s comment header due to it is duplicated with MpInitLibSwitchBSP(). v3: 1. Rename MpInitLibSwitchBsp to MpInitLibSwitchBSP. Cc: Michael Kinney <michael.d.kinney@intel.com> Cc: Feng Tian <feng.tian@intel.com> Cc: Giri P Mudusuru <giri.p.mudusuru@intel.com> Cc: Laszlo Ersek <lersek@redhat.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan <jeff.fan@intel.com> Reviewed-by: Michael Kinney <michael.d.kinney@intel.com> Tested-by: Laszlo Ersek <lersek@redhat.com> Tested-by: Michael Kinney <michael.d.kinney@intel.com>
This commit is contained in:
@@ -42,6 +42,23 @@
|
||||
0x58eb6a19, 0x3699, 0x4c68, { 0xa8, 0x36, 0xda, 0xcd, 0x8e, 0xdc, 0xad, 0x4a } \
|
||||
}
|
||||
|
||||
//
|
||||
// The MP data for switch BSP
|
||||
//
|
||||
#define CPU_SWITCH_STATE_IDLE 0
|
||||
#define CPU_SWITCH_STATE_STORED 1
|
||||
#define CPU_SWITCH_STATE_LOADED 2
|
||||
|
||||
//
|
||||
// CPU exchange information for switch BSP
|
||||
//
|
||||
typedef struct {
|
||||
UINT8 State; // offset 0
|
||||
UINTN StackPointer; // offset 4 / 8
|
||||
IA32_DESCRIPTOR Gdtr; // offset 8 / 16
|
||||
IA32_DESCRIPTOR Idtr; // offset 14 / 26
|
||||
} CPU_EXCHANGE_ROLE_INFO;
|
||||
|
||||
//
|
||||
// AP loop state when APs are in idle state
|
||||
// It's value is the same with PcdCpuApLoopMode
|
||||
@@ -198,6 +215,9 @@ struct _CPU_MP_DATA {
|
||||
|
||||
AP_INIT_STATE InitFlag;
|
||||
BOOLEAN X2ApicEnable;
|
||||
BOOLEAN SwitchBspFlag;
|
||||
CPU_EXCHANGE_ROLE_INFO BSPInfo;
|
||||
CPU_EXCHANGE_ROLE_INFO APInfo;
|
||||
MTRR_SETTINGS MtrrTable;
|
||||
UINT8 ApLoopMode;
|
||||
UINT8 ApTargetCState;
|
||||
@@ -242,6 +262,22 @@ AsmGetAddressMap (
|
||||
OUT MP_ASSEMBLY_ADDRESS_MAP *AddressMap
|
||||
);
|
||||
|
||||
/**
|
||||
This function is called by both the BSP and the AP which is to become the BSP to
|
||||
Exchange execution context including stack between them. After return from this
|
||||
function, the BSP becomes AP and the AP becomes the BSP.
|
||||
|
||||
@param[in] MyInfo Pointer to buffer holding the exchanging information for the executing processor.
|
||||
@param[in] OthersInfo Pointer to buffer holding the exchanging information for the peer.
|
||||
|
||||
**/
|
||||
VOID
|
||||
EFIAPI
|
||||
AsmExchangeRole (
|
||||
IN CPU_EXCHANGE_ROLE_INFO *MyInfo,
|
||||
IN CPU_EXCHANGE_ROLE_INFO *OthersInfo
|
||||
);
|
||||
|
||||
/**
|
||||
Get the pointer to CPU MP Data structure.
|
||||
|
||||
@@ -311,6 +347,23 @@ InitMpGlobalData (
|
||||
IN CPU_MP_DATA *CpuMpData
|
||||
);
|
||||
|
||||
/**
|
||||
Worker function to switch the requested AP to be the BSP from that point onward.
|
||||
|
||||
@param[in] ProcessorNumber The handle number of AP that is to become the new BSP.
|
||||
@param[in] EnableOldBSP If TRUE, then the old BSP will be listed as an
|
||||
enabled AP. Otherwise, it will be disabled.
|
||||
|
||||
@retval EFI_SUCCESS BSP successfully switched.
|
||||
@retval others Failed to switch BSP.
|
||||
|
||||
**/
|
||||
EFI_STATUS
|
||||
SwitchBSPWorker (
|
||||
IN UINTN ProcessorNumber,
|
||||
IN BOOLEAN EnableOldBSP
|
||||
);
|
||||
|
||||
/**
|
||||
Get pointer to CPU MP Data structure from GUIDed HOB.
|
||||
|
||||
|
Reference in New Issue
Block a user