From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=192.55.52.88; helo=mga01.intel.com; envelope-from=ruiyu.ni@intel.com; receiver=edk2-devel@lists.01.org Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) (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 9AA8B21EA15C4 for ; Wed, 11 Oct 2017 02:44:29 -0700 (PDT) Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga101.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 11 Oct 2017 02:47:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.43,360,1503385200"; d="scan'208";a="159246856" Received: from fmsmsx105.amr.corp.intel.com ([10.18.124.203]) by orsmga005.jf.intel.com with ESMTP; 11 Oct 2017 02:47:58 -0700 Received: from fmsmsx152.amr.corp.intel.com (10.18.125.5) by FMSMSX105.amr.corp.intel.com (10.18.124.203) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 11 Oct 2017 02:47:57 -0700 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX152.amr.corp.intel.com (10.18.125.5) with Microsoft SMTP Server (TLS) id 14.3.319.2; Wed, 11 Oct 2017 02:47:57 -0700 Received: from shsmsx104.ccr.corp.intel.com ([169.254.5.152]) by SHSMSX101.ccr.corp.intel.com ([169.254.1.159]) with mapi id 14.03.0319.002; Wed, 11 Oct 2017 17:47:55 +0800 From: "Ni, Ruiyu" To: "Gao, Liming" , "edk2-devel@lists.01.org" Thread-Topic: [Patch] SourceLevelDebugPkg: Update SmmDebugAgentLib to restore APIC timer Thread-Index: AQHTQa87U+10+7+gJkWX+y37+b4CnqLeaEQw Date: Wed, 11 Oct 2017 09:47:54 +0000 Deferred-Delivery: Wed, 11 Oct 2017 09:47:00 +0000 Message-ID: <734D49CCEBEEF84792F5B80ED585239D5BA92C9D@SHSMSX104.ccr.corp.intel.com> References: <1507629852-9700-1-git-send-email-liming.gao@intel.com> In-Reply-To: <1507629852-9700-1-git-send-email-liming.gao@intel.com> Accept-Language: en-US, zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [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: Wed, 11 Oct 2017 09:44:29 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Reviewed-by: Ruiyu Ni Thanks/Ray > -----Original Message----- > From: Gao, Liming > Sent: Tuesday, October 10, 2017 6:04 PM > To: edk2-devel@lists.01.org > Cc: Ni, Ruiyu > Subject: [Patch] SourceLevelDebugPkg: Update SmmDebugAgentLib to > restore APIC timer >=20 > In enter SMI, APIC timer may be initialized. After exit SMI, APIC timer w= ill be > restore. >=20 > 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(-) >=20 > diff --git > a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebug > AgentLib.c > b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebu > gAgentLib.c > index 11afd32..6be8c54 100644 > --- > a/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebug > AgentLib.c > +++ > b/SourceLevelDebugPkg/Library/DebugAgent/SmmDebugAgent/SmmDebu > gAgent > +++ Lib.c > @@ -20,6 +20,11 @@ UINTN mSavedDebugRegisters[6]; > IA32_IDT_GATE_DESCRIPTOR mIdtEntryTable[33]; > BOOLEAN mSkipBreakpoint =3D FALSE; > BOOLEAN mSmmDebugIdtInitFlag =3D FALSE; > +BOOLEAN mApicTimerRestore =3D FALSE; > +BOOLEAN mPeriodicMode; > +UINT32 mTimerCycle; > +UINTN mApicTimerDivisor; > +UINT8 mVector; >=20 > CHAR8 mWarningMsgIgnoreSmmEntryBreak[] =3D "Ignore smmentrybreak > setting for SMI issued during DXE debugging!\r\n"; >=20 > @@ -191,8 +196,6 @@ InitializeDebugAgent ( > DEBUG_AGENT_MAILBOX *Mailbox; > UINT64 *MailboxLocation; > UINT32 DebugTimerFrequency; > - BOOLEAN PeriodicMode; > - UINTN TimerCycle; >=20 > 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 =3D GetApicTimerInitCount (); > - if (!PeriodicMode || TimerCycle =3D=3D 0) { > + GetApicTimerState (&mApicTimerDivisor, &mPeriodicMode, &mVector); > + mTimerCycle =3D GetApicTimerInitCount (); > + if (!mPeriodicMode || mTimerCycle =3D=3D 0) { > + mApicTimerRestore =3D TRUE; > InitializeDebugTimer (NULL, FALSE); > } > Mailbox =3D GetMailboxPointer (); > @@ -327,6 +331,13 @@ InitializeDebugAgent ( > // > mSkipBreakpoint =3D FALSE; > RestoreDebugRegister (); > + // > + // Restore APIC Timer > + // > + if (mApicTimerRestore) { > + InitializeApicTimer (mApicTimerDivisor, mTimerCycle, mPeriodicMode= , > mVector); > + mApicTimerRestore =3D FALSE; > + } > break; >=20 > case DEBUG_AGENT_INIT_THUNK_PEI_IA32TOX64: > -- > 2.8.0.windows.1