UefiCpuPkg/MpInitLib: Disable and restore system timer interrupt

We need to disable system timer interrup to avoid generating the pending
interrupt on the old BSP.

Cc: Feng Tian <feng.tian@intel.com>
Cc: Kinney Michael D <michael.d.kinney@intel.com>
Cc: Ruiyu Ni <ruiyu.ni@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Feng Tian <feng.tian@intel.com>
This commit is contained in:
Jeff Fan 2016-12-26 19:13:44 +08:00
parent 26b43433c1
commit b6e45716c3
2 changed files with 33 additions and 1 deletions

View File

@ -57,6 +57,9 @@
UefiBootServicesTableLib
DebugAgentLib
[Protocols]
gEfiTimerArchProtocolGuid ## SOMETIMES_CONSUMES
[Guids]
gEfiEventExitBootServicesGuid ## CONSUMES ## Event
gEfiEventLegacyBootGuid ## CONSUMES ## Event

View File

@ -18,6 +18,8 @@
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DebugAgentLib.h>
#include <Protocol/Timer.h>
#define AP_CHECK_INTERVAL (EFI_TIMER_PERIOD_MILLISECONDS (100))
#define AP_SAFE_STACK_SIZE 128
@ -646,10 +648,37 @@ MpInitLibSwitchBSP (
)
{
EFI_STATUS Status;
EFI_TIMER_ARCH_PROTOCOL *Timer;
UINT64 TimerPeriod;
//
// Locate Timer Arch Protocol
//
Status = gBS->LocateProtocol (&gEfiTimerArchProtocolGuid, NULL, (VOID **) &Timer);
if (EFI_ERROR (Status)) {
Timer = NULL;
}
if (Timer != NULL) {
//
// Save current rate of DXE Timer
//
Timer->GetTimerPeriod (Timer, &TimerPeriod);
//
// Disable DXE Timer and drain pending interrupts
//
Timer->SetTimerPeriod (Timer, 0);
}
Status = SwitchBSPWorker (ProcessorNumber, EnableOldBSP);
if (Timer != NULL) {
//
// Enable and restore rate of DXE Timer
//
Timer->SetTimerPeriod (Timer, TimerPeriod);
}
return Status;
}