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.93; helo=mga11.intel.com; envelope-from=liming.gao@intel.com; receiver=edk2-devel@lists.01.org Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) (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 C0D812232BE0E for ; Mon, 22 Jan 2018 07:19:03 -0800 (PST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Jan 2018 07:24:29 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.46,397,1511856000"; d="scan'208";a="21343506" Received: from fmsmsx108.amr.corp.intel.com ([10.18.124.206]) by orsmga003.jf.intel.com with ESMTP; 22 Jan 2018 07:24:28 -0800 Received: from fmsmsx153.amr.corp.intel.com (10.18.125.6) by FMSMSX108.amr.corp.intel.com (10.18.124.206) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 22 Jan 2018 07:24:28 -0800 Received: from shsmsx101.ccr.corp.intel.com (10.239.4.153) by FMSMSX153.amr.corp.intel.com (10.18.125.6) with Microsoft SMTP Server (TLS) id 14.3.319.2; Mon, 22 Jan 2018 07:24:27 -0800 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; Mon, 22 Jan 2018 23:24:26 +0800 From: "Gao, Liming" To: "Zeng, Star" , "edk2-devel@lists.01.org" Thread-Topic: [Patch] PcAtChipsetPkg: Add PeiAcpiTimerLib to save PerformanceCounterFrequency in HOB Thread-Index: AQHTk4oupbzkwKTKJk2XMmd5GLRAoaOAAaJw Date: Mon, 22 Jan 2018 15:24:25 +0000 Message-ID: <4A89E2EF3DFEDB4C8BFDE51014F606A14E1A87DF@SHSMSX104.ccr.corp.intel.com> References: <1516599528-12756-1-git-send-email-liming.gao@intel.com> <0C09AFA07DD0434D9E2A0C6AEB0483103BA00B12@shsmsx102.ccr.corp.intel.com> In-Reply-To: <0C09AFA07DD0434D9E2A0C6AEB0483103BA00B12@shsmsx102.ccr.corp.intel.com> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: dlp-product: dlpe-windows dlp-version: 11.0.0.116 dlp-reaction: no-action x-originating-ip: [10.239.127.40] MIME-Version: 1.0 Subject: Re: [Patch] PcAtChipsetPkg: Add PeiAcpiTimerLib to save PerformanceCounterFrequency in HOB X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 22 Jan 2018 15:19:04 -0000 Content-Language: en-US Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Star: PeiAcpiTimerLib just build, no link. PcAtChipsetPkg has no PEIM to build.= So, no PEI hob library instance is specified. For INF base name, I will up= date it. And, I will update DXE Constructor to cache the Frequency in the e= ntry point. Please help review my V2 patch.=20 Thanks Liming > -----Original Message----- > From: Zeng, Star > Sent: Monday, January 22, 2018 10:06 PM > To: Gao, Liming ; edk2-devel@lists.01.org > Cc: Zeng, Star > Subject: RE: [Patch] PcAtChipsetPkg: Add PeiAcpiTimerLib to save Performa= nceCounterFrequency in HOB >=20 > How could PeiAcpiTimerLib build pass with DxeHobLib >=20 > Why the BASE_NAME is DxeAcpiTimerLib in PeiAcpiTimerLib.inf? >=20 >=20 > Thanks, > Star > -----Original Message----- > From: Gao, Liming > Sent: Monday, January 22, 2018 1:39 PM > To: edk2-devel@lists.01.org > Cc: Zeng, Star > Subject: [Patch] PcAtChipsetPkg: Add PeiAcpiTimerLib to save PerformanceC= ounterFrequency in HOB >=20 > PeiAcpiTimerLib caches PerformanceCounterFrequency in HOB, then Pei and D= xe AcpiTimerLib can share the same > PerformanceCounterFrequency. >=20 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Liming Gao > Cc: Star Zeng > --- > PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c | 4 +- > .../Library/AcpiTimerLib/DxeAcpiTimerLib.c | 14 ++++- > .../Library/AcpiTimerLib/DxeAcpiTimerLib.inf | 3 +- > .../Library/AcpiTimerLib/PeiAcpiTimerLib.c | 68 ++++++++++++++++= ++++++ > .../Library/AcpiTimerLib/PeiAcpiTimerLib.inf | 55 ++++++++++++++++= + > .../Library/AcpiTimerLib/PeiAcpiTimerLib.uni | 23 ++++++++ > PcAtChipsetPkg/PcAtChipsetPkg.dsc | 4 +- > 7 files changed, 166 insertions(+), 5 deletions(-) create mode 100644 P= cAtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.c > create mode 100644 PcAtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.i= nf > create mode 100644 PcAtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.u= ni >=20 > diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c b/PcAtChi= psetPkg/Library/AcpiTimerLib/AcpiTimerLib.c > index 792781a..2f3cb4b 100644 > --- a/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c > +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/AcpiTimerLib.c > @@ -1,7 +1,7 @@ > /** @file > ACPI Timer implements one instance of Timer Library. >=20 > - Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.
> + Copyright (c) 2013 - 2018, Intel Corporation. All rights > + reserved.
> This program and the accompanying materials > are licensed and made available under the terms and conditions of the = BSD License > which accompanies this distribution. The full text of the license may= be found at @@ -21,6 +21,8 @@ #include > #include >=20 > +GUID mFrequencyHobGuid =3D { 0x3fca54f6, 0xe1a2, 0x4b20, { 0xbe, 0x76, > +0x92, 0x6b, 0x4b, 0x48, 0xbf, 0xaa }}; > + > /** > Internal function to retrieves the 64-bit frequency in Hz. >=20 > diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c b/PcAt= ChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c > index b141c68..9b912c0 100644 > --- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c > +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c > @@ -12,9 +12,12 @@ >=20 > **/ >=20 > -#include > +#include > #include > #include > +#include > + > +extern GUID mFrequencyHobGuid; >=20 > /** > Calculate TSC frequency. > @@ -54,8 +57,15 @@ InternalGetPerformanceCounterFrequency ( > VOID > ) > { > + EFI_HOB_GUID_TYPE *GuidHob; > + > if (mPerformanceCounterFrequency =3D=3D 0) { > - mPerformanceCounterFrequency =3D InternalCalculateTscFrequency (); > + GuidHob =3D GetFirstGuidHob (&mFrequencyHobGuid); > + if (GuidHob !=3D NULL) { > + mPerformanceCounterFrequency =3D *(UINT64*)GET_GUID_HOB_DATA (Guid= Hob); > + } else { > + mPerformanceCounterFrequency =3D InternalCalculateTscFrequency (); > + } > } > return mPerformanceCounterFrequency; } diff --git a/PcAtChipsetPkg/L= ibrary/AcpiTimerLib/DxeAcpiTimerLib.inf > b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf > index 2c1cc7d..307e3f9 100644 > --- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf > +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf > @@ -7,7 +7,7 @@ > # Note: The implementation uses the lower 24-bits of the ACPI timer and= # is compatible with both 24-bit and 32-bit ACPI > timers. > # > -# Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved. > +# Copyright (c) 2013 - 2018, Intel Corporation. All rights > +reserved.
> # This program and the accompanying materials # are licensed and made= available under the terms and conditions of the BSD > License # which accompanies this distribution. The full text of the li= cense may be found at @@ -42,6 +42,7 @@ > PciLib > IoLib > DebugLib > + HobLib >=20 > [Pcd] > gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPciBusNumber ## CON= SUMES > diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.c b/PcAt= ChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.c > new file mode 100644 > index 0000000..a4ed6a4 > --- /dev/null > +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.c > @@ -0,0 +1,68 @@ > +/** @file > + ACPI Timer implements one instance of Timer Library. > + > + Copyright (c) 2013 - 2018, Intel Corporation. All rights > + reserved.
This program and the accompanying materials are > + licensed and made available under the terms and conditions of the BSD > + License which accompanies this distribution. The full text of the > + license may be found at > + http://opensource.org/licenses/bsd-license.php > + > + THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, > + WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IM= PLIED. > + > +**/ > + > +#include > +#include > +#include > +#include > + > +extern GUID mFrequencyHobGuid; > + > +/** > + Calculate TSC frequency. > + > + The TSC counting frequency is determined by comparing how far it > + counts during a 101.4 us period as determined by the ACPI timer. > + The ACPI timer is used because it counts at a known frequency. > + The TSC is sampled, followed by waiting 363 counts of the ACPI timer, > + or 101.4 us. The TSC is then sampled again. The difference multiplied > + by > + 9861 is the TSC frequency. There will be a small error because of the > + overhead of reading the ACPI timer. An attempt is made to determine > + and compensate for this error. > + > + @return The number of TSC counts per second. > + > +**/ > +UINT64 > +InternalCalculateTscFrequency ( > + VOID > + ); > + > +/** > + Internal function to retrieves the 64-bit frequency in Hz. > + > + Internal function to retrieves the 64-bit frequency in Hz. > + > + @return The frequency in Hz. > + > +**/ > +UINT64 > +InternalGetPerformanceCounterFrequency ( > + VOID > + ) > +{ > + UINT64 *PerformanceCounterFrequency; > + EFI_HOB_GUID_TYPE *GuidHob; > + > + PerformanceCounterFrequency =3D NULL; > + GuidHob =3D GetFirstGuidHob (&mFrequencyHobGuid); if (GuidHob =3D=3D = NULL) > + { > + PerformanceCounterFrequency =3D (UINT64*)BuildGuidHob(&mFrequencyHo= bGuid, sizeof (*PerformanceCounterFrequency)); > + *PerformanceCounterFrequency =3D InternalCalculateTscFrequency (); > + return *PerformanceCounterFrequency; } > + PerformanceCounterFrequency =3D (UINT64*)GET_GUID_HOB_DATA (GuidHob); > + > + return *PerformanceCounterFrequency; } > diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.inf b/Pc= AtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.inf > new file mode 100644 > index 0000000..794d2a3 > --- /dev/null > +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.inf > @@ -0,0 +1,55 @@ > +## @file > +# PEI ACPI Timer Library > +# > +# Provides basic timer support using the ACPI timer hardware. The > +performance # counter features are provided by the processors time stam= p counter. > +# > +# Note: The implementation uses the lower 24-bits of the ACPI timer > +and # is compatible with both 24-bit and 32-bit ACPI timers. > +# > +# Copyright (c) 2013 - 2018, Intel Corporation. All rights > +reserved.
# This program and the accompanying materials # are > +licensed and made available under the terms and conditions of the BSD > +License # which accompanies this distribution. The full text of the > +license may be found at # > +http://opensource.org/licenses/bsd-license.php > +# > +# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > +BASIS, # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPR= ESS OR IMPLIED. > +# > +## > + > +[Defines] > + INF_VERSION =3D 0x00010005 > + BASE_NAME =3D DxeAcpiTimerLib > + FILE_GUID =3D 3FCA54F6-E1A2-4B20-BE76-926B4B48BFA= A > + MODULE_TYPE =3D PEIM > + VERSION_STRING =3D 1.0 > + LIBRARY_CLASS =3D TimerLib|PEI_CORE PEIM > + MODULE_UNI_FILE =3D PeiAcpiTimerLib.uni > + > +[Sources] > + AcpiTimerLib.c > + PeiAcpiTimerLib.c > + > +[Packages] > + MdePkg/MdePkg.dec > + PcAtChipsetPkg/PcAtChipsetPkg.dec > + > +[LibraryClasses] > + BaseLib > + PcdLib > + PciLib > + IoLib > + DebugLib > + HobLib > + > +[Pcd] > + gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPciBusNumber ## CON= SUMES > + gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPciDeviceNumber ## CON= SUMES > + gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPciFunctionNumber ## CON= SUMES > + gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPciEnableRegisterOffset ## CON= SUMES > + gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoBarEnableMask ## CON= SUMES > + gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPciBarRegisterOffset ## CON= SUMES > + gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPortBaseAddress ## CON= SUMES > + gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiPm1TmrOffset ## CON= SUMES > + gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPortBaseAddressMask ## CON= SUMES > diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.uni b/Pc= AtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.uni > new file mode 100644 > index 0000000..668161b > --- /dev/null > +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.uni > @@ -0,0 +1,23 @@ > +// /** @file > +// PEI ACPI Timer Library > +// > +// Provides basic timer support using the ACPI timer hardware. The > +performance // counter features are provided by the processors time stam= p counter. > +// > +// Copyright (c) 2018, Intel Corporation. All rights reserved.
// > +// This program and the accompanying materials // are licensed and made > +available under the terms and conditions of the BSD License // which > +accompanies this distribution. The full text of the license may be > +found at // http://opensource.org/licenses/bsd-license.php > +// > +// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" > +BASIS, // WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPR= ESS OR IMPLIED. > +// > +// **/ > + > + > +#string STR_MODULE_ABSTRACT #language en-US "ACPI Timer Libr= ary" > + > +#string STR_MODULE_DESCRIPTION #language en-US "Provides basic = timer support using the ACPI timer hardware." > + > diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dsc b/PcAtChipsetPkg/PcAtChips= etPkg.dsc > index b740f00..2395e9c 100644 > --- a/PcAtChipsetPkg/PcAtChipsetPkg.dsc > +++ b/PcAtChipsetPkg/PcAtChipsetPkg.dsc > @@ -1,7 +1,7 @@ > ## @file > # PC/AT Chipset Package > # > -# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved. > +# Copyright (c) 2007 - 2018, Intel Corporation. All rights > +reserved.
> # > # This program and the accompanying materials # are licensed and made= available under the terms and conditions of the BSD > License @@ -46,6 +46,7 @@ > IoApicLib|PcAtChipsetPkg/Library/BaseIoApicLib/BaseIoApicLib.inf > LocalApicLib|UefiCpuPkg/Library/BaseXApicLib/BaseXApicLib.inf > ReportStatusCodeLib|MdePkg/Library/BaseReportStatusCodeLibNull/BaseRep= ortStatusCodeLibNull.inf > + HobLib|MdePkg/Library/DxeHobLib/DxeHobLib.inf >=20 > [Components] > PcAtChipsetPkg/8254TimerDxe/8254Timer.inf > @@ -57,6 +58,7 @@ > PcAtChipsetPkg/Library/BaseIoApicLib/BaseIoApicLib.inf > PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf > PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf > + PcAtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.inf > PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe= .inf >=20 > [BuildOptions] > -- > 2.8.0.windows.1