SourceLevelDebugPkg/DebugAgent: Disable Debug Timer as early

InitializeApicTimer() will enable Local APIC timer interrupt. Even though we
disable CPU interrupt at the beginning and enable CPU Interrupt after debug
agent initialized completely, some Boot Service may invoke RestoreTpl () which
may enable CPU interrupt.
We should disable Local APIC timer in InitializeDebugTimer () to avoid Debug
Timer interrupt happens during debug port and debug agent initialization phase.
And enable Debug Timer interrupt after debug agent is initialized.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Jeff Fan <jeff.fan@intel.com>
Reviewed-by: Ruiyu Ni <ruiyu.ni@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17572 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Jeff Fan 2015-06-08 06:36:41 +00:00 committed by vanjeff
parent 9ade433965
commit 2befbc82cc
5 changed files with 22 additions and 1 deletions

View File

@ -2535,6 +2535,7 @@ InterruptProcess (
CurrentDebugTimerInitCount = GetApicTimerInitCount ();
if (mDebugMpContext.DebugTimerInitCount != CurrentDebugTimerInitCount) {
InitializeDebugTimer (NULL, FALSE);
SaveAndSetDebugTimerInterrupt (TRUE);
}
}

View File

@ -46,6 +46,11 @@ InitializeDebugTimer (
);
InitializeApicTimer (ApicTimerDivisor, InitialCount, TRUE, DEBUG_TIMER_VECTOR);
//
// Disable Debug Timer interrupt to avoid it is delivered before Debug Port
// is initialized
//
DisableApicTimerInterrupt ();
if (DumpFlag) {
DEBUG ((EFI_D_INFO, "Debug Timer: FSB Clock = %d\n", PcdGet32(PcdFSBClock)));

View File

@ -428,6 +428,10 @@ InitializeDebugAgent (
//
InternalConstructorWorker ();
//
// Enable Debug Timer interrupt
//
SaveAndSetDebugTimerInterrupt (TRUE);
//
// Enable interrupt to receive Debug Timer interrupt
//
EnableInterrupts ();
@ -482,6 +486,10 @@ InitializeDebugAgent (
//
SetupDebugAgentEnvironment (Mailbox);
//
// Enable Debug Timer interrupt
//
SaveAndSetDebugTimerInterrupt (TRUE);
//
// Enable interrupt to receive Debug Timer interrupt
//
EnableInterrupts ();

View File

@ -611,6 +611,10 @@ InitializeDebugAgent (
break;
}
//
// Enable Debug Timer interrupt
//
SaveAndSetDebugTimerInterrupt (TRUE);
//
// Enable CPU interrupts so debug timer interrupts can be delivered
//

View File

@ -284,7 +284,6 @@ InitializeDebugAgent (
TimerCycle = GetApicTimerInitCount ();
if (!PeriodicMode || TimerCycle == 0) {
InitializeDebugTimer (NULL, FALSE);
DisableApicTimerInterrupt ();
}
Mailbox = GetMailboxPointer ();
if (GetDebugFlag (DEBUG_AGENT_FLAG_AGENT_IN_PROGRESS) == 1) {
@ -350,6 +349,10 @@ InitializeDebugAgent (
//
InitializeDebugTimer (&DebugTimerFrequency, TRUE);
UpdateMailboxContent (mMailboxPointer, DEBUG_MAILBOX_DEBUG_TIMER_FREQUENCY, DebugTimerFrequency);
//
// Enable Debug Timer interrupt and CPU interrupt
//
SaveAndSetDebugTimerInterrupt (TRUE);
EnableInterrupts ();
FindAndReportModuleImageInfo (SIZE_4KB);