From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=134.134.136.31; helo=mga06.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 45B4D208F7903 for ; Tue, 10 Oct 2017 03:01:06 -0700 (PDT) Received: from orsmga003.jf.intel.com ([10.7.209.27]) by orsmga104.jf.intel.com with ESMTP; 10 Oct 2017 03:04:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,504,1500966000"; d="scan'208";a="1023596498" Received: from shwde7172.ccr.corp.intel.com ([10.239.9.14]) by orsmga003.jf.intel.com with ESMTP; 10 Oct 2017 03:04:33 -0700 From: Liming Gao To: edk2-devel@lists.01.org Cc: Ruiyu Ni Date: Tue, 10 Oct 2017 18:04:12 +0800 Message-Id: <1507629852-9700-1-git-send-email-liming.gao@intel.com> X-Mailer: git-send-email 2.8.0.windows.1 Subject: [Patch] SourceLevelDebugPkg: Update SmmDebugAgentLib to restore APIC timer X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 Oct 2017 10:01:06 -0000 In enter SMI, APIC timer may be initialized. After exit SMI, APIC timer will be restore. Contributed-under: TianoCore Contribution Agreement 1.1 Signed-off-by: Liming Gao Cc: Ruiyu Ni --- .../DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c index 11afd32..6be8c54 100644 --- a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c +++ b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebugAgentLib.c @@ -20,6 +20,11 @@ UINTN mSavedDebugRegisters[6]; IA32_IDT_GATE_DESCRIPTOR mIdtEntryTable[33]; BOOLEAN mSkipBreakpoint = FALSE; BOOLEAN mSmmDebugIdtInitFlag = FALSE; +BOOLEAN mApicTimerRestore = FALSE; +BOOLEAN mPeriodicMode; +UINT32 mTimerCycle; +UINTN mApicTimerDivisor; +UINT8 mVector; CHAR8 mWarningMsgIgnoreSmmEntryBreak[] = "Ignore smmentrybreak setting for SMI issued during DXE debugging!\r\n"; @@ -191,8 +196,6 @@ InitializeDebugAgent ( DEBUG_AGENT_MAILBOX *Mailbox; UINT64 *MailboxLocation; UINT32 DebugTimerFrequency; - BOOLEAN PeriodicMode; - UINTN TimerCycle; switch (InitFlag) { case DEBUG_AGENT_INIT_SMM: @@ -289,9 +292,10 @@ InitializeDebugAgent ( // Check if CPU APIC Timer is working, otherwise initialize it. // InitializeLocalApicSoftwareEnable (TRUE); - GetApicTimerState (NULL, &PeriodicMode, NULL); - TimerCycle = GetApicTimerInitCount (); - if (!PeriodicMode || TimerCycle == 0) { + GetApicTimerState (&mApicTimerDivisor, &mPeriodicMode, &mVector); + mTimerCycle = GetApicTimerInitCount (); + if (!mPeriodicMode || mTimerCycle == 0) { + mApicTimerRestore = TRUE; InitializeDebugTimer (NULL, FALSE); } Mailbox = GetMailboxPointer (); @@ -327,6 +331,13 @@ InitializeDebugAgent ( // mSkipBreakpoint = FALSE; RestoreDebugRegister (); + // + // Restore APIC Timer + // + if (mApicTimerRestore) { + InitializeApicTimer (mApicTimerDivisor, mTimerCycle, mPeriodicMode, mVector); + mApicTimerRestore = FALSE; + } break; case DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64: -- 2.8.0.windows.1