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 <jeff....@intel.com>
CC: Ruiyu Ni <ruiyu...@intel.com>
---
 .../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 ac96a00..544067b 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) {
       //
-- 
1.9.5.msysgit.0


------------------------------------------------------------------------------
One dashboard for servers and applications across Physical-Virtual-Cloud 
Widest out-of-the-box monitoring support with 50+ applications
Performance metrics, stats and reports that give you Actionable Insights
Deep dive visibility with transaction tracing using APM Insight.
http://ad.doubleclick.net/ddm/clk/290420510;117567292;y
_______________________________________________
edk2-devel mailing list
edk2-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/edk2-devel

Reply via email to