From edbb27132d4737be1fa54ea9f6e7657daa2bb72a Mon Sep 17 00:00:00 2001 From: Jeff Fan Date: Mon, 25 May 2015 02:46:11 +0000 Subject: SourceLevelDebugPkg/SmmDebugAgent: Initialize Local APIC Timer Now Debug Agent library uses Local APIC Timer to implement time-out mechanism. In SMM, SMM BSP maybe not be the one in DXE phase, its local APIC timer may not work. This fix is to initialize Local APIC timer if it doesn't work as expected at SMM entry. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Jeff Fan Reviewed-by: Ruiyu Ni git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@17500 6f19259b-4bc3-4df7-8a09-765794883524 --- .../Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c index ac96a00240..544067b4d6 100644 --- a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c +++ b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c @@ -190,6 +190,8 @@ InitializeDebugAgent ( DEBUG_AGENT_MAILBOX *Mailbox; UINT64 *MailboxLocation; UINT32 DebugTimerFrequency; + BOOLEAN PeriodicMode; + UINTN TimerCycle; switch (InitFlag) { case DEBUG_AGENT_INIT_SMM: @@ -275,7 +277,15 @@ InitializeDebugAgent ( case DEBUG_AGENT_INIT_ENTER_SMI: SaveDebugRegister (); InitializeDebugIdt (); - + // + // Check if CPU APIC Timer is working, otherwise initialize it. + // + GetApicTimerState (NULL, &PeriodicMode, NULL); + TimerCycle = GetApicTimerInitCount (); + if (PeriodicMode != TRUE || TimerCycle == 0) { + InitializeDebugTimer (NULL); + DisableApicTimerInterrupt (); + } Mailbox = GetMailboxPointer (); if (GetDebugFlag (DEBUG_AGENT_FLAG_AGENT_IN_PROGRESS) == 1) { // -- cgit v1.2.3