diff --git a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c index e294612f14..2d8bf25b0a 100644 --- a/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c +++ b/UefiCpuPkg/Library/MpInitLib/DxeMpLib.c @@ -13,7 +13,16 @@ **/ #include "MpLib.h" + +#include +#include + +#define AP_CHECK_INTERVAL (EFI_TIMER_PERIOD_MILLISECONDS (100)) + CPU_MP_DATA *mCpuMpData = NULL; +EFI_EVENT mCheckAllApsEvent = NULL; +volatile BOOLEAN mStopCheckAllApsStatus = TRUE; + /** Get the pointer to CPU MP Data structure. @@ -42,6 +51,43 @@ SaveCpuMpData ( mCpuMpData = CpuMpData; } +/** +/** + Checks APs status and updates APs status if needed. + +**/ +VOID +CheckAndUpdateApsStatus ( + VOID + ) +{ +} + +/** + Checks APs' status periodically. + + This function is triggerred by timer perodically to check the + state of APs for StartupAllAPs() and StartupThisAP() executed + in non-blocking mode. + + @param[in] Event Event triggered. + @param[in] Context Parameter passed with the event. + +**/ +VOID +EFIAPI +CheckApsStatus ( + IN EFI_EVENT Event, + IN VOID *Context + ) +{ + // + // If CheckApsStatus() is not stopped, otherwise return immediately. + // + if (!mStopCheckAllApsStatus) { + CheckAndUpdateApsStatus (); + } +} /** Initialize global data for MP support. @@ -52,8 +98,28 @@ InitMpGlobalData ( IN CPU_MP_DATA *CpuMpData ) { + EFI_STATUS Status; + SaveCpuMpData (CpuMpData); + Status = gBS->CreateEvent ( + EVT_TIMER | EVT_NOTIFY_SIGNAL, + TPL_NOTIFY, + CheckApsStatus, + NULL, + &mCheckAllApsEvent + ); + ASSERT_EFI_ERROR (Status); + + // + // Set timer to check all APs status. + // + Status = gBS->SetTimer ( + mCheckAllApsEvent, + TimerPeriodic, + AP_CHECK_INTERVAL + ); + ASSERT_EFI_ERROR (Status); } /**