From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (NAM10-BN7-obe.outbound.protection.outlook.com [40.92.40.23]) by mx.groups.io with SMTP id smtpd.web08.18063.1611690454092966450 for ; Tue, 26 Jan 2021 11:47:34 -0800 Authentication-Results: mx.groups.io; dkim=fail reason="body hash did not verify" header.i=@outlook.com header.s=selector1 header.b=UmM97zdv; spf=pass (domain: outlook.com, ip: 40.92.40.23, mailfrom: kun.q@outlook.com) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=i/wIiDctQMYmaKciYTXeiTu+/Qn2nIDEgnhQKfV4uPKnwt6nkfMT+EyHggh4jXwV6nTRw39kCOl5Z/DbYaKbKoA7WLDiDr8nSUROejmdZ9IdrzUq0kg4s3fLu2X0DdRNBbDs2b0TSGohDDLyhZ4EPrU/WVY3MydmgP7/dtkCsyFaCninBHyfSpxznMfyCdWLhs94Ens4X12ZnrLd2jYH89LzQvKLAlsCVYsnvqhV4cN4rgr4OgApBjyjqSVWD2pwRHyBeib5SrYIF9LqunDzrZN9L3GyCLzCd6/zFvDeoiIzEQEnCdblJw9Xm5tRzJfUAOMUtT3j7Bo5T8FvwkrQyQ== 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=w59tfFku82unAYodNN8og/A6TgNIpbYBP/XzJvnTlIE=; b=eLORYGJhi0WlEWRnvkyZHSIf5mhq5dGFqGjarouoHFADUnYwNlrlnxYyQIcYsTDFOoOuSRtsY/bmvB4b9P++7/UKkk78gc2//WeaonwwPATwqICeB02avb694FRHvmFCyhSDrUT3fEbQRs1h9dmj7ybvBiHS13pwGbk1yE7XHjP5ygL9yWIJvUG08PjTEvBl1meVFxs66iqfrBxmQfRwUKN/Mi41ZHqi+d3578TWC9YevaH/qQ+WNq5CB8twAVRcx2PBhU0saWiJrTIIkuz3WyNQYfM/Z4zqJRTSMEQFJhnX/abWVZ5nTCmc43U/+MbWL0r5/Xjiv0PpXF839uxI7A== 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=w59tfFku82unAYodNN8og/A6TgNIpbYBP/XzJvnTlIE=; b=UmM97zdvM9if4mUdJrV31qeUPI1WxHVPWwhqqy5wtnWWQ2q33jA2dpYkQ1QHCrtf13Gbdu2b7PB6RUXMtRg2Y4DsxatT6wzxl2x5MqXZKmHXRRdLYhc/EjrYdieivfZHNJkYGD6/eOLR9jEy+V7LZ0JQK62o4ESdTnmv7E1z3j09tOvoVtSnOidutQ72ZcCfBjhxtelv4pRwCJgzZako+XK8/dhODTzUo+vPwLGY1IvchwQeiie8UcgxowDyKBodSUbe3vEjy1M5ndeamNWN0///sB/orPWCDKGHHXoynF5NlNgi7CIwQlRY+fsh74oNvbn1uGLf5R8RQigrKFiVdw== Received: from BN7NAM10FT059.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::4c) by BN7NAM10HT056.eop-nam10.prod.protection.outlook.com (2a01:111:e400:7e8f::64) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11; Tue, 26 Jan 2021 19:47:33 +0000 Received: from MWHPR06MB3102.namprd06.prod.outlook.com (2a01:111:e400:7e8f::4c) by BN7NAM10FT059.mail.protection.outlook.com (2a01:111:e400:7e8f::447) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.11 via Frontend Transport; Tue, 26 Jan 2021 19:47:32 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:37BE0FB223AD818181455EEE63B8CF4A83A56EE8841F94A8FB717C34F86FE074;UpperCasedChecksum:3BA01F19CDCCD5D56FB8FB287B5189F08620EFB4069A18B98B1D6862183C8489;SizeAsReceived:7377;Count:47 Received: from MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::d4ee:1260:6f53:3f7b]) by MWHPR06MB3102.namprd06.prod.outlook.com ([fe80::d4ee:1260:6f53:3f7b%6]) with mapi id 15.20.3784.017; Tue, 26 Jan 2021 19:47:32 +0000 From: "Kun Qin" To: devel@edk2.groups.io CC: Ray Ni Subject: [PATCH v4 13/20] PcAtChipsetPkg: AcpiTimerLib: Added StandaloneMm instance of AcpiTimerLib Date: Tue, 26 Jan 2021 11:47:03 -0800 Message-ID: X-Mailer: git-send-email 2.30.0.windows.1 In-Reply-To: <20210126194710.2248-1-kun.q@outlook.com> References: <20210126194710.2248-1-kun.q@outlook.com> X-TMN: [cKn5hYHcxCV8IoGcMzMTyTmKDFLaxYok] X-ClientProxiedBy: MWHPR11CA0001.namprd11.prod.outlook.com (2603:10b6:301:1::11) To MWHPR06MB3102.namprd06.prod.outlook.com (2603:10b6:301:3e::35) Return-Path: kun.q@outlook.com X-Microsoft-Original-Message-ID: <20210126194710.2248-11-kun.q@outlook.com> MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from localhost.localdomain (50.35.88.161) by MWHPR11CA0001.namprd11.prod.outlook.com (2603:10b6:301:1::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.3784.14 via Frontend Transport; Tue, 26 Jan 2021 19:47:29 +0000 X-MS-PublicTrafficType: Email X-IncomingHeaderCount: 47 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-Correlation-Id: 076f4d22-009f-4764-5862-08d8c2333748 X-MS-TrafficTypeDiagnostic: BN7NAM10HT056: X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Fra5NseQBF92oIuDwfK3+TDxMXlL4DZSYV1empKd9VuN3wZcx1PRMeITFaAd99f/QF4pk5qi+SB22nPF2thxEXBfymZfZfc3EUG0JmXXUsCtnS/cDVjlLDI2piLlGB588c5LeTUsF2/SKLwmvlJYXgB43cZORstgJ56jQAh8986kZLv17apXBsXZ/i/mVCLVjvtO7SnS3jEdKyoF26yp5EWCQDFV10VIPC/S0qrcMvqqkiGdQnVgCpLdv5A1c+73 X-MS-Exchange-AntiSpam-MessageData: G0x7OOe+3mSZg0NKG3klArhK2zMPkTtHQY13ND8QGHM7P41RqNLxP8wK0eBrq4uiAaE4R2uVlCTSpinXjSBdTUL4Uikt3+vY26LhwNe54QMFzjLq0vUQpqTFpjXD9OrIThgSyZYs+lScOqQllRjmUA== X-OriginatorOrg: outlook.com X-MS-Exchange-CrossTenant-Network-Message-Id: 076f4d22-009f-4764-5862-08d8c2333748 X-MS-Exchange-CrossTenant-OriginalArrivalTime: 26 Jan 2021 19:47:30.1652 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-AuthSource: BN7NAM10FT059.eop-nam10.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: Internet X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN7NAM10HT056 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain 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 Reviewed-by: Ray Ni --- Notes: v4: - Added reviewed-by tag [Ray] =20 v3: - Renamed "CommonAcpiTimerLib" to "DxeStandaloneMmAcpiTimerLib" to avoid confusion [Ray] - Renamed BASE NAME (and file name) to StandaloneMmAcpiTimerLib [Ray] =20 v2: - Removed "EFIAPI" for internal functions. PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c = | 81 +------------------- PcAtChipsetPkg/Library/AcpiTimerLib/{DxeAcpiTimerLib.c =3D> DxeStandaloneM= mAcpiTimerLib.c} | 9 +-- PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.c = | 31 ++++++++ PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf = | 2 + PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.h = | 24 ++++++ PcAtChipsetPkg/Library/AcpiTimerLib/{DxeAcpiTimerLib.inf =3D> StandaloneMm= AcpiTimerLib.inf} | 19 +++-- PcAtChipsetPkg/PcAtChipsetPkg.dsc = | 1 + 7 files changed, 74 insertions(+), 93 deletions(-) diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c b/PcAtCh= ipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c index 3ad831b15e8a..9ac2a446e365 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. =20 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.
+ Copyright (c) Microsoft Corporation. SPDX-License-Identifier: BSD-2-Clause-Patent =20 **/ =20 #include -#include -#include -#include =20 -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 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 - ); - -// -// 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 "DxeStandaloneMmAcpiTimerLib.h" =20 /** The constructor function enables ACPI IO space, and caches PerformanceCo= unterFrequency. @@ -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/DxeAcpiTimerLib.c b/PcAtCh= ipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.c similarity index 86% copy from PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c copy to PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.c index 3ad831b15e8a..0e401194d01d 100644 --- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.c @@ -72,17 +72,12 @@ InternalGetPerformanceCounterFrequency ( /** The constructor function enables ACPI IO space, and caches PerformanceCo= unterFrequency. =20 - @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. =20 **/ 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/StandaloneMmAcpiTimerLib.c= b/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.c new file mode 100644 index 000000000000..97aca5606905 --- /dev/null +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.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 "DxeStandaloneMmAcpiTimerLib.h" + +/** + The constructor function enables ACPI IO space, and caches PerformanceCo= unterFrequency. + + @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/DxeAcpiTimerLib.inf b/PcAt= ChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf index d86356f4ff17..93972e53c9c5 100644 --- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf @@ -25,6 +25,8 @@ [Defines] [Sources] AcpiTimerLib.c DxeAcpiTimerLib.c + DxeStandaloneMmAcpiTimerLib.c + DxeStandaloneMmAcpiTimerLib.h =20 [Packages] MdePkg/MdePkg.dec diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLi= b.h b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.h new file mode 100644 index 000000000000..6015d684e5bd --- /dev/null +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.h @@ -0,0 +1,24 @@ +/** @file + Header file internal to ACPI TimerLib. + +Copyright (c) Microsoft Corporation. +SPDX-License-Identifier: BSD-2-Clause-Patent + +**/ + + +#ifndef _DXE_STANDALONE_MM_ACPI_TIMER_LIB_H_ +#define _DXE_STANDALONE_MM_ACPI_TIMER_LIB_H_ + +/** + The constructor function enables ACPI IO space, and caches PerformanceCo= unterFrequency. + + @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS. + +**/ +EFI_STATUS +CommonAcpiTimerLibConstructor ( + VOID + ); + +#endif diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf b/PcAt= ChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.inf similarity index 70% copy from PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf copy to PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.inf index d86356f4ff17..c5efdd145d19 100644 --- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf +++ b/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.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 perfor= mance # 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 # ## =20 [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 StandaloneMmAcpiTimerLib + 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_RUNT= IME_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_STANDA= LONE + CONSTRUCTOR =3D StandaloneMmAcpiTimerLibConstructor =20 [Sources] AcpiTimerLib.c - DxeAcpiTimerLib.c + StandaloneMmAcpiTimerLib.c + DxeStandaloneMmAcpiTimerLib.c + DxeStandaloneMmAcpiTimerLib.h =20 [Packages] MdePkg/MdePkg.dec diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dsc b/PcAtChipsetPkg/PcAtChipset= Pkg.dsc index b61b7d1f528e..3d1fb816f54f 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/StandaloneMmAcpiTimerLib.inf PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.i= nf =20 [BuildOptions] --=20 2.30.0.windows.1