From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (NAM10-DM6-obe.outbound.protection.outlook.com [40.92.41.56]) by mx.groups.io with SMTP id smtpd.web08.4422.1610421864293929374 for ; Mon, 11 Jan 2021 19:24:24 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@outlook.com header.s=selector1 header.b=TbpMeU7d; spf=pass (domain: outlook.com, ip: 40.92.41.56, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Z83eReqPh0XyXNQnINNmta1CIPnkYJgyJy33OXLzjM8Jy2H6udEMQ+PnKz+V7viqRc19KGGcE2ms6OPlwrpOAWYVmH8yOQjTV7hxGuGWEjhV85Nhid4B76a8rFLO0zTFv/oXq9q5BLXKhPYDF/vMQV/Gn0QddWd/caVo47JD7GcMlz/865uNZxL68ed8WUxGtbDJa7SUdo+nM3Im9WyXiqFql3Kb9OQ8KDgW/oaIddgsBZGO60BUWCO0XjyQBeZfb53HUzauzHy205TPhfUWHNfJNcGGK82mdu9oDPtS50MxnFZ3eEuytzksyRxnl/uM9ne/Kepovu+nIXNvZHKZHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uC2qp4DeuLKPaXvrjbFqckepEnZAhXX4CehvSz42x3Q=; b=WCeQtRRXdxEh8cbvZwqM7NeY3YoJp4lwz8PjyNlAcct2ltvML/VTGxzTBFJTakzD/pcEI2Sa8Ub7rx7mFd7CHMyjf6DqiVX4Wj02YUgzQd0GoPh9LCUaevka+7eaHoD2uaT9QDphJXRHFyHBDITF/gT9jIynhPLbMr9yhXnehseRyT40heN112nIcvpj6PLr8WDZN6blm6MXiuMJiC9US/KMQxPskI3157sKCJIIFe7yuDAMLRK/OlK7zeXxsKAlaqhKvgDtMG0Jmi0XoXQZtniGPxQBxbZ1AmYJa2b/en15KC3j79UfAKpe2Sq8DF95rIrVtAuXI1fT7ooqm9cDMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=outlook.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=uC2qp4DeuLKPaXvrjbFqckepEnZAhXX4CehvSz42x3Q=; b=TbpMeU7dn3+BzTc2oXZg9W3ml1Sew4yPtIaAvT7hgD9GA035UZ3qwFD9cOH2t8kWOyVaJ8OwURNUyuywQtwzTBRowTbi9sIoo0hOZCZHNwmKd+oNB1W+d5h4ZCeGNk/QPtqLwGze0dnxCGBjUM4iXEENJK1EJWQQDytPMCUwd46GQtABvmLRDQo9TfiTDbV13F2orOqORcWU7D1Xjoa3D7ICTHYDAc85asiXMjsTcANaLHqHIzFnTaEX/An/IfDDna2F00zQ9WLNc/98/SwNCaM/MpCJfpAvKN1s+I0bduA/iwLOSfsQHfhvOZhTupPnRCWe4Q740dA7Y5MTrcQYIA== Received: from BN7NAM10FT004.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::53) by BN7NAM10HT036.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::72) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.9; Tue, 12 Jan 2021 03:24:23 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:7e8f::47) by BN7NAM10FT004.mail.protection.outlook.com (2a01:111:e400:7e8f::414) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3742.9 via Frontend Transport; Tue, 12 Jan 2021 03:24:23 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::acb3:ab69:563d:b0d6]) by MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::acb3:ab69:563d:b0d6%5]) with mapi id 15.20.3742.012; Tue, 12 Jan 2021 03:24:22 +0000 From: "Kun Qin" To: "devel@edk2.groups.io" , Ray Ni Subject: Re: [edk2-devel] [PATCH v2 11/16] PcAtChipsetPkg: AcpiTimerLib: Added StandaloneMm instance of AcpiTimerLib Thread-Topic: [edk2-devel] [PATCH v2 11/16] PcAtChipsetPkg: AcpiTimerLib: Added StandaloneMm instance of AcpiTimerLib Thread-Index: AQHW45T9LTcPJZS2R0uRNw8guHRtO6ojXUgY Date: Tue, 12 Jan 2021 03:24:22 +0000 Message-ID: References: <20210105185935.3769-1-kun.q@outlook.com>,<16576B257D31F1E6.24224@groups.io> In-Reply-To: <16576B257D31F1E6.24224@groups.io> Accept-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-incomingtopheadermarker: OriginalChecksum:C12984FF50A8AA19ACF0CE7C4B693AD082174005F408AE5B45D27B75189A5B51;UpperCasedChecksum:2B3BAA20F7DF06B9B6B876114E231E57E38865EFF8438EC0096CC6F6EF701BEC;SizeAsReceived:6916;Count:43 x-tmn: [mt73Mb+4Oq/kGoTBwy3ugE8Or68Y6DtI] x-ms-publictraffictype: Email x-incomingheadercount: 43 x-eopattributedmessage: 0 x-ms-office365-filtering-correlation-id: bdd6f119-fee2-403a-d55f-08d8b6a98e6b x-ms-traffictypediagnostic: BN7NAM10HT036: x-microsoft-antispam: BCL:0; x-microsoft-antispam-message-info: rhI4zs8lhdWpIQBc6rZdeQqLEbVplPMeckJDAatRLi+GhWt0rzFYN5dJrHolBlLS+OVgTSh27kTiMlrMJ7ukleqBtrqCOgBZSMNeyFVHpg1+3SvRjxdkcIV9ErrKch/VEL47giGgZtzzmGWUUlohhm6+XRKSPOWyUCnOyNV0BMPoS6ncD5tfExp9SMb0Hp+c+TuT2yh3qCfbOi6S415Ep4nMb/2XYW9OTMFtxcxCFxC1mL3Cvw5AZnXypOLl0GKLLb4YVIBYj3KrOkgJs3JNW3VxLCjRLgxeDxiTUJ9aFuA= x-ms-exchange-antispam-messagedata: Jzdi21x+ywnvhxDYswnSz771gzwpuN0PyoMvBjKY4tIWLNad63vhw0CknzFQCNuvKTuBH+Rtez+od2FK5E2fuN/I8f41b89Ect7V6IjI/jrjcRCw6Qs9ky3ezGBwiBEF5O8Okx8Jp8/3Hyox/SCwlQ== x-ms-exchange-transport-forked: True MIME-Version: 1.0 X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-AuthSource: BN7NAM10FT004.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-CrossTenant-Network-Message-Id: bdd6f119-fee2-403a-d55f-08d8b6a98e6b X-MS-Exchange-CrossTenant-originalarrivaltime: 12 Jan 2021 03:24:22.7005 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Internet X-MS-Exchange-CrossTenant-id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-rms-persistedconsumerorg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7NAM10HT036 Content-Language: en-US Content-Type: multipart/alternative; boundary="_000_MWHPR06MB3102BB33ACB4A826A25827D0F3AA0MWHPR06MB3102namp_" --_000_MWHPR06MB3102BB33ACB4A826A25827D0F3AA0MWHPR06MB3102namp_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Hi Ray, Is there any feedback on this patch before I send out v3 patch series? Any= input is appreciated. Regards, Kun From: Kun Qin Sent: Tuesday, January 5, 2021 11:00 To: devel@edk2.groups.io Cc: Ray Ni Subject: [edk2-devel] [PATCH v2 11/16] PcAtChipsetPkg: AcpiTimerLib: Added= StandaloneMm instance of AcpiTimerLib This change added a new instance of AcpiTimerLib for StandaloneMm core and drivers. It centralizes the common routines into shared files and abstract the library constructor into corresponding files to accommodate each constructor function prototypes. Cc: Ray Ni Signed-off-by: Kun Qin --- Notes: v2: - Removed "EFIAPI" for internal functions. PcAtChipsetPkg/Library/AcpiTimerLib/{DxeAcpiTimerLib.c =3D> CommonAcpiTim= erLib.c} | 9 +-- PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c = | 81 +------------------- PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneAcpiTimerLib.c = | 31 ++++++++ PcAtChipsetPkg/Library/AcpiTimerLib/CommonAcpiTimerLib.h = | 24 ++++++ PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf = | 2 + PcAtChipsetPkg/Library/AcpiTimerLib/{DxeAcpiTimerLib.inf =3D> StandaloneA= cpiTimerLib.inf} | 19 +++-- PcAtChipsetPkg/PcAtChipsetPkg.dsc = | 1 + 7 files changed, 74 insertions(+), 93 deletions(-) diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c b/PcAtC= hipsetPkg/Library/AcpiTimerLib/CommonAcpiTimerLib.c similarity index 86% copy from PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c copy to PcAtChipsetPkg/Library/AcpiTimerLib/CommonAcpiTimerLib.c index 3ad831b15e8a..0e401194d01d 100644 --- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/CommonAcpiTimerLib.c @@ -72,17 +72,12 @@ InternalGetPerformanceCounterFrequency ( /** The constructor function enables ACPI IO space, and caches PerformanceC= ounterFrequency. - @param ImageHandle The firmware allocated handle for the EFI image. - @param SystemTable A pointer to the EFI System Table. - @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. **/ EFI_STATUS -EFIAPI -DxeAcpiTimerLibConstructor ( - IN EFI_HANDLE ImageHandle, - IN EFI_SYSTEM_TABLE *SystemTable +CommonAcpiTimerLibConstructor ( + VOID ) { EFI_HOB_GUID_TYPE *GuidHob; diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c b/PcAtC= hipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c index 3ad831b15e8a..e519ad8ed07e 100644 --- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c @@ -2,72 +2,14 @@ ACPI Timer implements one instance of Timer Library. Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent **/ #include -#include -#include -#include -extern GUID mFrequencyHobGuid; - -/** - The constructor function enables ACPI IO space. - - If ACPI I/O space not enabled, this function will enable it. - It will always return RETURN_SUCCESS. - - @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. - -**/ -RETURN_STATUS -EFIAPI -AcpiTimerLibConstructor ( - VOID - ); - -/** - 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 b= y - 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 - ); - -// -// Cached performance counter frequency -// -UINT64 mPerformanceCounterFrequency =3D 0; - -/** - 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 - ) -{ - return mPerformanceCounterFrequency; -} +#include "CommonAcpiTimerLib.h" /** The constructor function enables ACPI IO space, and caches PerformanceC= ounterFrequency. @@ -85,22 +27,5 @@ DxeAcpiTimerLibConstructor ( IN EFI_SYSTEM_TABLE *SystemTable ) { - EFI_HOB_GUID_TYPE *GuidHob; - - // - // Enable ACPI IO space. - // - AcpiTimerLibConstructor (); - - // - // Initialize PerformanceCounterFrequency - // - GuidHob =3D GetFirstGuidHob (&mFrequencyHobGuid); - if (GuidHob !=3D NULL) { - mPerformanceCounterFrequency =3D *(UINT64*)GET_GUID_HOB_DATA (GuidHob= ); - } else { - mPerformanceCounterFrequency =3D InternalCalculateTscFrequency (); - } - - return EFI_SUCCESS; + return CommonAcpiTimerLibConstructor (); } diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneAcpiTimerLib.c = b/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneAcpiTimerLib.c new file mode 100644 index 000000000000..8509f94ba7cb --- /dev/null +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneAcpiTimerLib.c @@ -0,0 +1,31 @@ +/** @file + ACPI Timer implements one instance of Timer Library. + + Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) Microsoft Corporation. + SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + +#include + +#include "CommonAcpiTimerLib.h" + +/** + The constructor function enables ACPI IO space, and caches PerformanceC= ounterFrequency. + + @param ImageHandle The firmware allocated handle for the EFI image. + @param SystemTable A pointer to the EFI System Table. + + @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. + +**/ +EFI_STATUS +EFIAPI +StandaloneMmAcpiTimerLibConstructor ( + IN EFI_HANDLE ImageHandle, + IN EFI_MM_SYSTEM_TABLE *SystemTable + ) +{ + return CommonAcpiTimerLibConstructor (); +} diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/CommonAcpiTimerLib.h b/Pc= AtChipsetPkg/Library/AcpiTimerLib/CommonAcpiTimerLib.h new file mode 100644 index 000000000000..1bbdaef04cce --- /dev/null +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/CommonAcpiTimerLib.h @@ -0,0 +1,24 @@ +/** @file + Header file internal to ACPI TimerLib. + +Copyright (c) Microsoft Corporation. +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + + +#ifndef _COMMON_ACPI_TIMER_LIB_H_ +#define _COMMON_ACPI_TIMER_LIB_H_ + +/** + The constructor function enables ACPI IO space, and caches PerformanceC= ounterFrequency. + + @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. + +**/ +EFI_STATUS +CommonAcpiTimerLibConstructor ( + VOID + ); + +#endif diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf b/PcA= tChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf index d86356f4ff17..bbf14b3b5b53 100644 --- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf @@ -25,6 +25,8 @@ [Defines] [Sources] AcpiTimerLib.c DxeAcpiTimerLib.c + CommonAcpiTimerLib.c + CommonAcpiTimerLib.h [Packages] MdePkg/MdePkg.dec diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf b/PcA= tChipsetPkg/Library/AcpiTimerLib/StandaloneAcpiTimerLib.inf similarity index 70% copy from PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf copy to PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneAcpiTimerLib.inf index d86356f4ff17..aa8f0012f744 100644 --- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneAcpiTimerLib.inf @@ -1,5 +1,5 @@ ## @file -# DXE ACPI Timer Library +# Standalone MM ACPI Timer Library # # Provides basic timer support using the ACPI timer hardware. The perfo= rmance # counter features are provided by the processors time stamp counter. @@ -8,23 +8,26 @@ # is compatible with both 24-bit and 32-bit ACPI timers. # # Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
+# Copyright (c) Microsoft Corporation. # SPDX-License-Identifier: BSD-2-Clause-Patent # ## [Defines] INF_VERSION =3D 0x00010005 - BASE_NAME =3D DxeAcpiTimerLib - FILE_GUID =3D E624B98C-845A-4b94-9B50-B20475D552B9 - MODULE_TYPE =3D DXE_DRIVER + BASE_NAME =3D StandaloneAcpiTimerLib + FILE_GUID =3D C771858D-AF09-4D1A-B2F3-C7F081C3F076 + MODULE_TYPE =3D MM_STANDALONE VERSION_STRING =3D 1.0 - LIBRARY_CLASS =3D TimerLib|DXE_CORE DXE_DRIVER DXE_RUN= TIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE - CONSTRUCTOR =3D DxeAcpiTimerLibConstructor - MODULE_UNI_FILE =3D DxeAcpiTimerLib.uni + PI_SPECIFICATION_VERSION =3D 0x00010032 + LIBRARY_CLASS =3D TimerLib|MM_CORE_STANDALONE MM_STAND= ALONE + CONSTRUCTOR =3D StandaloneMmAcpiTimerLibConstructor [Sources] AcpiTimerLib.c - DxeAcpiTimerLib.c + StandaloneAcpiTimerLib.c + CommonAcpiTimerLib.c + CommonAcpiTimerLib.h [Packages] MdePkg/MdePkg.dec diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dsc b/PcAtChipsetPkg/PcAtChipse= tPkg.dsc index b61b7d1f528e..8862ca7a0006 100644 --- a/PcAtChipsetPkg/PcAtChipsetPkg.dsc +++ b/PcAtChipsetPkg/PcAtChipsetPkg.dsc @@ -53,6 +53,7 @@ [Components] PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf PcAtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.inf + PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneAcpiTimerLib.inf PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.= inf [BuildOptions] -- 2.30.0.windows.1 --_000_MWHPR06MB3102BB33ACB4A826A25827D0F3AA0MWHPR06MB3102namp_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Hi Ray,

 

Is there any feedback on this patch before I send o= ut v3 patch series? Any input is appreciated.

 

Regards,

Kun

 

From: Kun Qin
Sent: Tuesday, January 5, 2021 11:00
To: devel@edk2.groups.io
Cc:
Ray Ni
Subject: [edk2-devel] [PATCH v2 11/16] PcAtChipsetPkg: AcpiTimerLib= : Added StandaloneMm instance of AcpiTimerLib

 

This change added a = new instance of AcpiTimerLib for StandaloneMm core
and drivers. It centralizes the common routines into shared files and
abstract the library constructor into corresponding files to accommodate each constructor function prototypes.

Cc: Ray Ni <ray.ni@intel.com>

Signed-off-by: Kun Qin <kun.q@outlook.com>
---

Notes:
    v2:
    - Removed "EFIAPI" for internal functions.
 PcAtChipsetPkg/Library/AcpiTimerLib/{DxeAcpiTimerLib.c =3D> Commo= nAcpiTimerLib.c}         |  9 = +--
 PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c  &nb= sp;            =             &nb= sp;       | 81 +-------------------
 PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneAcpiTimerLib.c &n= bsp;            = ;            &n= bsp; | 31 ++++++++
 PcAtChipsetPkg/Library/AcpiTimerLib/CommonAcpiTimerLib.h  =             &nb= sp;            =      | 24 ++++++
 PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf  &= nbsp;           &nbs= p;            &= nbsp;     |  2 +
 PcAtChipsetPkg/Library/AcpiTimerLib/{DxeAcpiTimerLib.inf =3D> Sta= ndaloneAcpiTimerLib.inf} | 19 +++--
 PcAtChipsetPkg/PcAtChipsetPkg.dsc      = ;            &n= bsp;            = ;            &n= bsp;           |  1 = +
 7 files changed, 74 insertions(+), 93 deletions(-)

diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c b/PcAtC= hipsetPkg/Library/AcpiTimerLib/CommonAcpiTimerLib.c
similarity index 86%
copy from PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c
copy to PcAtChipsetPkg/Library/AcpiTimerLib/CommonAcpiTimerLib.c
index 3ad831b15e8a..0e401194d01d 100644
--- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/CommonAcpiTimerLib.c
@@ -72,17 +72,12 @@ InternalGetPerformanceCounterFrequency (
 /**
   The constructor function enables ACPI IO space, and caches Pe= rformanceCounterFrequency.
 
-  @param  ImageHandle   The firmware allocated handle= for the EFI image.
-  @param  SystemTable   A pointer to the EFI System T= able.
-
   @retval EFI_SUCCESS   The constructor always return= s RETURN_SUCCESS.
 
 **/
 EFI_STATUS
-EFIAPI
-DxeAcpiTimerLibConstructor (
-  IN EFI_HANDLE        ImageHandl= e,
-  IN EFI_SYSTEM_TABLE  *SystemTable
+CommonAcpiTimerLibConstructor (
+  VOID
   )
 {
   EFI_HOB_GUID_TYPE   *GuidHob;
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c b/PcAtC= hipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c
index 3ad831b15e8a..e519ad8ed07e 100644
--- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c
@@ -2,72 +2,14 @@
   ACPI Timer implements one instance of Timer Library.
 
   Copyright (c) 2013 - 2018, Intel Corporation. All rights rese= rved.<BR>
+  Copyright (c) Microsoft Corporation.
   SPDX-License-Identifier: BSD-2-Clause-Patent
 
 **/
 
 #include <PiDxe.h>
-#include <Library/TimerLib.h>
-#include <Library/BaseLib.h>
-#include <Library/HobLib.h>
 
-extern GUID mFrequencyHobGuid;
-
-/**
-  The constructor function enables ACPI IO space.
-
-  If ACPI I/O space not enabled, this function will enable it.
-  It will always return RETURN_SUCCESS.
-
-  @retval EFI_SUCCESS   The constructor always returns RET= URN_SUCCESS.
-
-**/
-RETURN_STATUS
-EFIAPI
-AcpiTimerLibConstructor (
-  VOID
-  );
-
-/**
-  Calculate TSC frequency.
-
-  The TSC counting frequency is determined by comparing how far it c= ounts
-  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 tim= er,
-  or 101.4 us. The TSC is then sampled again. The difference multipl= ied 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 determin= e and
-  compensate for this error.
-
-  @return The number of TSC counts per second.
-
-**/
-UINT64
-InternalCalculateTscFrequency (
-  VOID
-  );
-
-//
-// Cached performance counter frequency
-//
-UINT64  mPerformanceCounterFrequency =3D 0;
-
-/**
-  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
-  )
-{
-  return  mPerformanceCounterFrequency;
-}
+#include "CommonAcpiTimerLib.h"
 
 /**
   The constructor function enables ACPI IO space, and caches Pe= rformanceCounterFrequency.
@@ -85,22 +27,5 @@ DxeAcpiTimerLibConstructor (
   IN EFI_SYSTEM_TABLE  *SystemTable
   )
 {
-  EFI_HOB_GUID_TYPE   *GuidHob;
-
-  //
-  // Enable ACPI IO space.
-  //
-  AcpiTimerLibConstructor ();
-
-  //
-  // Initialize PerformanceCounterFrequency
-  //
-  GuidHob =3D GetFirstGuidHob (&mFrequencyHobGuid);
-  if (GuidHob !=3D NULL) {
-    mPerformanceCounterFrequency =3D *(UINT64*)GET_GUID_HO= B_DATA (GuidHob);
-  } else {
-    mPerformanceCounterFrequency =3D InternalCalculateTscF= requency ();
-  }
-
-  return EFI_SUCCESS;
+  return CommonAcpiTimerLibConstructor ();
 }
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneAcpiTimerLib.c = b/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneAcpiTimerLib.c
new file mode 100644
index 000000000000..8509f94ba7cb
--- /dev/null
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneAcpiTimerLib.c
@@ -0,0 +1,31 @@
+/** @file
+  ACPI Timer implements one instance of Timer Library.
+
+  Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.= <BR>
+  Copyright (c) Microsoft Corporation.
+  SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiMm.h>
+
+#include "CommonAcpiTimerLib.h"
+
+/**
+  The constructor function enables ACPI IO space, and caches Perform= anceCounterFrequency.
+
+  @param  ImageHandle   The firmware allocated handle= for the EFI image.
+  @param  SystemTable   A pointer to the EFI System T= able.
+
+  @retval EFI_SUCCESS   The constructor always returns RET= URN_SUCCESS.
+
+**/
+EFI_STATUS
+EFIAPI
+StandaloneMmAcpiTimerLibConstructor (
+  IN EFI_HANDLE         = ;  ImageHandle,
+  IN EFI_MM_SYSTEM_TABLE  *SystemTable
+  )
+{
+  return CommonAcpiTimerLibConstructor ();
+}
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/CommonAcpiTimerLib.h b/Pc= AtChipsetPkg/Library/AcpiTimerLib/CommonAcpiTimerLib.h
new file mode 100644
index 000000000000..1bbdaef04cce
--- /dev/null
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/CommonAcpiTimerLib.h
@@ -0,0 +1,24 @@
+/** @file
+  Header file internal to ACPI TimerLib.
+
+Copyright (c) Microsoft Corporation.
+SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+
+#ifndef _COMMON_ACPI_TIMER_LIB_H_
+#define _COMMON_ACPI_TIMER_LIB_H_
+
+/**
+  The constructor function enables ACPI IO space, and caches Perform= anceCounterFrequency.
+
+  @retval EFI_SUCCESS   The constructor always returns RET= URN_SUCCESS.
+
+**/
+EFI_STATUS
+CommonAcpiTimerLibConstructor (
+  VOID
+  );
+
+#endif
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf b/PcA= tChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
index d86356f4ff17..bbf14b3b5b53 100644
--- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
@@ -25,6 +25,8 @@ [Defines]
 [Sources]
   AcpiTimerLib.c
   DxeAcpiTimerLib.c
+  CommonAcpiTimerLib.c
+  CommonAcpiTimerLib.h
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf b/PcA= tChipsetPkg/Library/AcpiTimerLib/StandaloneAcpiTimerLib.inf
similarity index 70%
copy from PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
copy to PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneAcpiTimerLib.inf
index d86356f4ff17..aa8f0012f744 100644
--- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneAcpiTimerLib.inf
@@ -1,5 +1,5 @@
 ## @file
-#  DXE ACPI Timer Library
+#  Standalone MM ACPI Timer Library
 #
 #  Provides basic timer support using the ACPI timer hardware.&= nbsp; The performance
 #  counter features are provided by the processors time stamp c= ounter.
@@ -8,23 +8,26 @@
 #  is compatible with both 24-bit and 32-bit ACPI timers.
 #
 #  Copyright (c) 2013 - 2018, Intel Corporation. All rights res= erved.<BR>
+#  Copyright (c) Microsoft Corporation.
 #  SPDX-License-Identifier: BSD-2-Clause-Patent
 #
 ##
 
 [Defines]
   INF_VERSION        &n= bsp;           =3D 0x0001= 0005
-  BASE_NAME         &nb= sp;            =3D D= xeAcpiTimerLib
-  FILE_GUID         &nb= sp;            =3D E= 624B98C-845A-4b94-9B50-B20475D552B9
-  MODULE_TYPE         &= nbsp;          =3D DXE_DRIVER<= br> +  BASE_NAME         &nb= sp;            =3D S= tandaloneAcpiTimerLib
+  FILE_GUID         &nb= sp;            =3D C= 771858D-AF09-4D1A-B2F3-C7F081C3F076
+  MODULE_TYPE         &= nbsp;          =3D MM_STANDALO= NE
   VERSION_STRING        = ;         =3D 1.0
-  LIBRARY_CLASS         = ;         =3D TimerLib|DXE_CORE DXE= _DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_= CORE
-  CONSTRUCTOR         &= nbsp;          =3D DxeAcpiTime= rLibConstructor
-  MODULE_UNI_FILE        &nb= sp;       =3D DxeAcpiTimerLib.uni
+  PI_SPECIFICATION_VERSION       =3D 0= x00010032
+  LIBRARY_CLASS         = ;         =3D TimerLib|MM_CORE_STAN= DALONE MM_STANDALONE
+  CONSTRUCTOR         &= nbsp;          =3D StandaloneM= mAcpiTimerLibConstructor
 
 [Sources]
   AcpiTimerLib.c
-  DxeAcpiTimerLib.c
+  StandaloneAcpiTimerLib.c
+  CommonAcpiTimerLib.c
+  CommonAcpiTimerLib.h
 
 [Packages]
   MdePkg/MdePkg.dec
diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dsc b/PcAtChipsetPkg/PcAtChipse= tPkg.dsc
index b61b7d1f528e..8862ca7a0006 100644
--- a/PcAtChipsetPkg/PcAtChipsetPkg.dsc
+++ b/PcAtChipsetPkg/PcAtChipsetPkg.dsc
@@ -53,6 +53,7 @@ [Components]
   PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf
   PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
   PcAtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.inf
+  PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneAcpiTimerLib.inf
   PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockR= untimeDxe.inf
 
 [BuildOptions]
--
2.30.0.windows.1





 

--_000_MWHPR06MB3102BB33ACB4A826A25827D0F3AA0MWHPR06MB3102namp_--