public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Ni, Ray" <ray.ni@intel.com>
To: "devel@edk2.groups.io" <devel@edk2.groups.io>,
	"kun.q@outlook.com" <kun.q@outlook.com>
Subject: Re: [edk2-devel] [PATCH v2 11/16] PcAtChipsetPkg: AcpiTimerLib: Added StandaloneMm instance of AcpiTimerLib
Date: Wed, 13 Jan 2021 06:50:15 +0000	[thread overview]
Message-ID: <CO1PR11MB49306BF70DCC8F6B98947ACE8CA90@CO1PR11MB4930.namprd11.prod.outlook.com> (raw)
In-Reply-To: <MWHPR06MB31024BBAFF8342B0C942D313F3D10@MWHPR06MB3102.namprd06.prod.outlook.com>

1. With this change, there will be two common C files which look confusing to me:
AcpiTimerLib.c
CommonAcpiTimerLib.c

With a deep look, the first one is shared by Base/Pei/Dxe instances.
The second one is shared by Dxe and StandaloneMm instances.
Can you rename CommonAcpiTimerLib.c to DxeStandaloneMmAcpiTimerLib.c?
Or do you have any better idea to avoid the confusion?

2. Can you rename the BASE NAME from "StandaloneAcpiTimerLib" to
"StandaloneMmAcpiTimerLib"? I am not sure everyone could map "Standalone"
to "StandaloneMm".

Thanks,
Ray

> -----Original Message-----
> From: devel@edk2.groups.io <devel@edk2.groups.io> On Behalf Of Kun Qin
> Sent: Wednesday, January 6, 2021 3:00 AM
> To: devel@edk2.groups.io
> Cc: Ni, Ray <ray.ni@intel.com>
> 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 =>
> CommonAcpiTimerLib.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 =>
> StandaloneAcpiTimerLib.inf} | 19 +++--
>  PcAtChipsetPkg/PcAtChipsetPkg.dsc                                                       |  1 +
>  7 files changed, 74 insertions(+), 93 deletions(-)
> 
> diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c
> b/PcAtChipsetPkg/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
> PerformanceCounterFrequency.
> 
> -  @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/PcAtChipsetPkg/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.<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 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 = 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
> PerformanceCounterFrequency.
> @@ -85,22 +27,5 @@ DxeAcpiTimerLibConstructor (
>    IN EFI_SYSTEM_TABLE  *SystemTable
>    )
>  {
> -  EFI_HOB_GUID_TYPE   *GuidHob;
> -
> -  //
> -  // Enable ACPI IO space.
> -  //
> -  AcpiTimerLibConstructor ();
> -
> -  //
> -  // Initialize PerformanceCounterFrequency
> -  //
> -  GuidHob = GetFirstGuidHob (&mFrequencyHobGuid);
> -  if (GuidHob != NULL) {
> -    mPerformanceCounterFrequency = *(UINT64*)GET_GUID_HOB_DATA
> (GuidHob);
> -  } else {
> -    mPerformanceCounterFrequency = 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.<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
> PerformanceCounterFrequency.
> +
> +  @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/PcAtChipsetPkg/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
> PerformanceCounterFrequency.
> +
> +  @retval EFI_SUCCESS   The constructor always returns RETURN_SUCCESS.
> +
> +**/
> +EFI_STATUS
> +CommonAcpiTimerLibConstructor (
> +  VOID
> +  );
> +
> +#endif
> diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
> b/PcAtChipsetPkg/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/PcAtChipsetPkg/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
> performance
>  #  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.<BR>
> +#  Copyright (c) Microsoft Corporation.
>  #  SPDX-License-Identifier: BSD-2-Clause-Patent
>  #
>  ##
> 
>  [Defines]
>    INF_VERSION                    = 0x00010005
> -  BASE_NAME                      = DxeAcpiTimerLib
> -  FILE_GUID                      = E624B98C-845A-4b94-9B50-B20475D552B9
> -  MODULE_TYPE                    = DXE_DRIVER
> +  BASE_NAME                      = StandaloneAcpiTimerLib
> +  FILE_GUID                      = C771858D-AF09-4D1A-B2F3-C7F081C3F076
> +  MODULE_TYPE                    = MM_STANDALONE
>    VERSION_STRING                 = 1.0
> -  LIBRARY_CLASS                  = TimerLib|DXE_CORE DXE_DRIVER
> DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER
> SMM_CORE
> -  CONSTRUCTOR                    = DxeAcpiTimerLibConstructor
> -  MODULE_UNI_FILE                = DxeAcpiTimerLib.uni
> +  PI_SPECIFICATION_VERSION       = 0x00010032
> +  LIBRARY_CLASS                  = TimerLib|MM_CORE_STANDALONE
> MM_STANDALONE
> +  CONSTRUCTOR                    = StandaloneMmAcpiTimerLibConstructor
> 
>  [Sources]
>    AcpiTimerLib.c
> -  DxeAcpiTimerLib.c
> +  StandaloneAcpiTimerLib.c
> +  CommonAcpiTimerLib.c
> +  CommonAcpiTimerLib.h
> 
>  [Packages]
>    MdePkg/MdePkg.dec
> diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dsc
> b/PcAtChipsetPkg/PcAtChipsetPkg.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/PcatRealTimeClockRuntimeDx
> e.inf
> 
>  [BuildOptions]
> --
> 2.30.0.windows.1
> 
> 
> 
> 
> 


  reply	other threads:[~2021-01-13  6:50 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210105185935.3769-1-kun.q@outlook.com>
2021-01-05 18:59 ` [PATCH v2 01/16] StandaloneMmPkg: StandaloneMmCoreEntryPoint: Extends support for X64 Kun Qin
2021-01-05 18:59 ` [PATCH v2 02/16] StandaloneMmPkg: StandaloneMmCoreHobLib: Extend support for x64 Mm Core Kun Qin
2021-01-05 18:59 ` [PATCH v2 03/16] StandaloneMmPkg: StandaloneMmCoreMemoryAllocationLib: Fix compiler warning Kun Qin
2021-01-06  3:33   ` Yao, Jiewen
2021-01-05 18:59 ` [PATCH v2 04/16] StandaloneMmPkg: StandaloneMmMemLib: Extends support for X64 architecture Kun Qin
2021-01-06  3:38   ` Yao, Jiewen
2021-01-06  6:37     ` [edk2-devel] " Kun Qin
2021-01-05 18:59 ` [PATCH v2 05/16] MdeModulePkg: SmmLockBoxSmmLib: Support StandaloneMm for SmmLockBoxLib Kun Qin
2021-01-05 18:59 ` [PATCH v2 06/16] MdeModulePkg: SmmReportStatusCodeLib: ReportStatusCodeLib in StandaloneMm Kun Qin
2021-01-06  3:24   ` [edk2-devel] " Wu, Hao A
2021-01-05 18:59 ` [PATCH v2 07/16] MdeModulePkg: StatusCodeHandler: StatusCodeHandler driver " Kun Qin
2021-01-06  3:24   ` Wu, Hao A
2021-01-05 18:59 ` [PATCH v2 08/16] MdeModulePkg: FirmwarePerformanceDataTable: Added StandaloneMm support Kun Qin
2021-01-06  3:24   ` Wu, Hao A
2021-01-05 18:59 ` [PATCH v2 09/16] MdeModulePkg: ReportStatusCodeRouter: Support StandaloneMm RSC Router Kun Qin
2021-01-06  3:24   ` Wu, Hao A
2021-01-05 18:59 ` [PATCH v2 10/16] MdePkg: UefiDevicePathLib: Support UefiDevicePathLib under StandaloneMm Kun Qin
2021-01-05 18:59 ` [PATCH v2 11/16] PcAtChipsetPkg: AcpiTimerLib: Added StandaloneMm instance of AcpiTimerLib Kun Qin
2021-01-13  6:50   ` Ni, Ray [this message]
2021-01-13 18:38     ` [edk2-devel] " Kun Qin
2021-01-05 18:59 ` [PATCH v2 12/16] SecurityPkg: Tcg2PhysicalPresenceLib: Introduce StandaloneMm instance Kun Qin
2021-01-05 18:59 ` [PATCH v2 13/16] SecurityPkg: Tcg2PpVendorLibNull: Added support for MM_STANDALONE type Kun Qin
2021-01-05 18:59 ` [PATCH v2 14/16] SecurityPkg: Tpm2DeviceLibDTpm: Introduce StandaloneMm instance Kun Qin
2021-01-05 18:59 ` [PATCH v2 15/16] UefiCpuPkg: CpuIo2Smm: Support of CpuIo driver under StandaloneMm Kun Qin
2021-01-06 15:46   ` Laszlo Ersek
2021-01-06 15:51     ` Laszlo Ersek
2021-01-06 19:02       ` [edk2-devel] " Kun Qin
2021-01-06 19:07         ` Laszlo Ersek
2021-01-07 19:05     ` Leif Lindholm
2021-01-05 18:59 ` [PATCH v2 16/16] UefiCpuPkg: SmmCpuExceptionHandlerLib: Added StandaloneMm module support Kun Qin
2021-01-06 15:48   ` Laszlo Ersek
     [not found] ` <16576B257D31F1E6.24224@groups.io>
2021-01-12  3:24   ` [edk2-devel] [PATCH v2 11/16] PcAtChipsetPkg: AcpiTimerLib: Added StandaloneMm instance of AcpiTimerLib Kun Qin
     [not found] ` <16576B256B69BE5C.24224@groups.io>
2021-01-12  3:26   ` [edk2-devel] [PATCH v2 10/16] MdePkg: UefiDevicePathLib: Support UefiDevicePathLib under StandaloneMm Kun Qin
2021-01-13  1:14     ` 回复: " gaoliming

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CO1PR11MB49306BF70DCC8F6B98947ACE8CA90@CO1PR11MB4930.namprd11.prod.outlook.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox