<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
{font-family:"Cambria Math";
panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
{font-family:DengXian;
panose-1:2 1 6 0 3 1 1 1 1 1;}
@font-face
{font-family:Calibri;
panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
{font-family:"\@DengXian";
panose-1:2 1 6 0 3 1 1 1 1 1;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
{margin:0in;
font-size:11.0pt;
font-family:"Calibri",sans-serif;}
a:link, span.MsoHyperlink
{mso-style-priority:99;
color:blue;
text-decoration:underline;}
.MsoChpDefault
{mso-style-type:export-only;}
@page WordSection1
{size:8.5in 11.0in;
margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
{page:WordSection1;}
--></style>
</head>
<body lang="EN-US" link="blue" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">Hi Ray,</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">I updated the file names as suggested on the previous round. Do you have any further comments/feedback?</p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">Thanks,</p>
<p class="MsoNormal">Kun</p>
<p class="MsoNormal"><o:p> </o:p></p>
<div style="mso-element:para-border-div;border:none;border-top:solid #E1E1E1 1.0pt;padding:3.0pt 0in 0in 0in">
<p class="MsoNormal" style="border:none;padding:0in"><b>From: </b><a href="mailto:kun.q@outlook.com">Kun Qin</a><br>
<b>Sent: </b>Thursday, January 14, 2021 14:37<br>
<b>To: </b><a href="mailto:devel@edk2.groups.io">devel@edk2.groups.io</a><br>
<b>Cc: </b><a href="mailto:ray.ni@intel.com">Ray Ni</a><br>
<b>Subject: </b>[edk2-devel] [PATCH v3 12/18] PcAtChipsetPkg: AcpiTimerLib: Added StandaloneMm instance of AcpiTimerLib</p>
</div>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="margin-bottom:12.0pt">This change added a new instance of AcpiTimerLib for StandaloneMm core<br>
and drivers. It centralizes the common routines into shared files and<br>
abstract the library constructor into corresponding files to accommodate<br>
each constructor function prototypes.<br>
<br>
Cc: Ray Ni <ray.ni@intel.com><br>
<br>
Signed-off-by: Kun Qin <kun.q@outlook.com><br>
---<br>
<br>
Notes:<br>
v3:<br>
- Renamed "CommonAcpiTimerLib" to "DxeStandaloneMmAcpiTimerLib" to<br>
avoid confusion [Ray]<br>
- Renamed BASE NAME (and file name) to StandaloneMmAcpiTimerLib [Ray]<br>
<br>
v2:<br>
- Removed "EFIAPI" for internal functions.<br>
<br>
PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c | 81 +-------------------<br>
PcAtChipsetPkg/Library/AcpiTimerLib/{DxeAcpiTimerLib.c => DxeStandaloneMmAcpiTimerLib.c} | 9 +--<br>
PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.c | 31 ++++++++<br>
PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf | 2 +<br>
PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.h | 24 ++++++<br>
PcAtChipsetPkg/Library/AcpiTimerLib/{DxeAcpiTimerLib.inf => StandaloneMmAcpiTimerLib.inf} | 19 +++--<br>
PcAtChipsetPkg/PcAtChipsetPkg.dsc | 1 +<br>
7 files changed, 74 insertions(+), 93 deletions(-)<br>
<br>
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c<br>
index 3ad831b15e8a..9ac2a446e365 100644<br>
--- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c<br>
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c<br>
@@ -2,72 +2,14 @@<br>
ACPI Timer implements one instance of Timer Library.<br>
<br>
Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR><br>
+ Copyright (c) Microsoft Corporation.<br>
SPDX-License-Identifier: BSD-2-Clause-Patent<br>
<br>
**/<br>
<br>
#include <PiDxe.h><br>
-#include <Library/TimerLib.h><br>
-#include <Library/BaseLib.h><br>
-#include <Library/HobLib.h><br>
<br>
-extern GUID mFrequencyHobGuid;<br>
-<br>
-/**<br>
- The constructor function enables ACPI IO space.<br>
-<br>
- If ACPI I/O space not enabled, this function will enable it.<br>
- It will always return RETURN_SUCCESS.<br>
-<br>
- @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.<br>
-<br>
-**/<br>
-RETURN_STATUS<br>
-EFIAPI<br>
-AcpiTimerLibConstructor (<br>
- VOID<br>
- );<br>
-<br>
-/**<br>
- Calculate TSC frequency.<br>
-<br>
- The TSC counting frequency is determined by comparing how far it counts<br>
- during a 101.4 us period as determined by the ACPI timer.<br>
- The ACPI timer is used because it counts at a known frequency.<br>
- The TSC is sampled, followed by waiting 363 counts of the ACPI timer,<br>
- or 101.4 us. The TSC is then sampled again. The difference multiplied by<br>
- 9861 is the TSC frequency. There will be a small error because of the<br>
- overhead of reading the ACPI timer. An attempt is made to determine and<br>
- compensate for this error.<br>
-<br>
- @return The number of TSC counts per second.<br>
-<br>
-**/<br>
-UINT64<br>
-InternalCalculateTscFrequency (<br>
- VOID<br>
- );<br>
-<br>
-//<br>
-// Cached performance counter frequency<br>
-//<br>
-UINT64 mPerformanceCounterFrequency = 0;<br>
-<br>
-/**<br>
- Internal function to retrieves the 64-bit frequency in Hz.<br>
-<br>
- Internal function to retrieves the 64-bit frequency in Hz.<br>
-<br>
- @return The frequency in Hz.<br>
-<br>
-**/<br>
-UINT64<br>
-InternalGetPerformanceCounterFrequency (<br>
- VOID<br>
- )<br>
-{<br>
- return mPerformanceCounterFrequency;<br>
-}<br>
+#include "DxeStandaloneMmAcpiTimerLib.h"<br>
<br>
/**<br>
The constructor function enables ACPI IO space, and caches PerformanceCounterFrequency.<br>
@@ -85,22 +27,5 @@ DxeAcpiTimerLibConstructor (<br>
IN EFI_SYSTEM_TABLE *SystemTable<br>
)<br>
{<br>
- EFI_HOB_GUID_TYPE *GuidHob;<br>
-<br>
- //<br>
- // Enable ACPI IO space.<br>
- //<br>
- AcpiTimerLibConstructor ();<br>
-<br>
- //<br>
- // Initialize PerformanceCounterFrequency<br>
- //<br>
- GuidHob = GetFirstGuidHob (&mFrequencyHobGuid);<br>
- if (GuidHob != NULL) {<br>
- mPerformanceCounterFrequency = *(UINT64*)GET_GUID_HOB_DATA (GuidHob);<br>
- } else {<br>
- mPerformanceCounterFrequency = InternalCalculateTscFrequency ();<br>
- }<br>
-<br>
- return EFI_SUCCESS;<br>
+ return CommonAcpiTimerLibConstructor ();<br>
}<br>
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.c<br>
similarity index 86%<br>
copy from PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c<br>
copy to PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.c<br>
index 3ad831b15e8a..0e401194d01d 100644<br>
--- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c<br>
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.c<br>
@@ -72,17 +72,12 @@ InternalGetPerformanceCounterFrequency (<br>
/**<br>
The constructor function enables ACPI IO space, and caches PerformanceCounterFrequency.<br>
<br>
- @param ImageHandle The firmware allocated handle for the EFI image.<br>
- @param SystemTable A pointer to the EFI System Table.<br>
-<br>
@retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.<br>
<br>
**/<br>
EFI_STATUS<br>
-EFIAPI<br>
-DxeAcpiTimerLibConstructor (<br>
- IN EFI_HANDLE ImageHandle,<br>
- IN EFI_SYSTEM_TABLE *SystemTable<br>
+CommonAcpiTimerLibConstructor (<br>
+ VOID<br>
)<br>
{<br>
EFI_HOB_GUID_TYPE *GuidHob;<br>
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.c b/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.c<br>
new file mode 100644<br>
index 000000000000..97aca5606905<br>
--- /dev/null<br>
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.c<br>
@@ -0,0 +1,31 @@<br>
+/** @file<br>
+ ACPI Timer implements one instance of Timer Library.<br>
+<br>
+ Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR><br>
+ Copyright (c) Microsoft Corporation.<br>
+ SPDX-License-Identifier: BSD-2-Clause-Patent<br>
+<br>
+**/<br>
+<br>
+#include <PiMm.h><br>
+<br>
+#include "DxeStandaloneMmAcpiTimerLib.h"<br>
+<br>
+/**<br>
+ The constructor function enables ACPI IO space, and caches PerformanceCounterFrequency.<br>
+<br>
+ @param ImageHandle The firmware allocated handle for the EFI image.<br>
+ @param SystemTable A pointer to the EFI System Table.<br>
+<br>
+ @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+EFIAPI<br>
+StandaloneMmAcpiTimerLibConstructor (<br>
+ IN EFI_HANDLE ImageHandle,<br>
+ IN EFI_MM_SYSTEM_TABLE *SystemTable<br>
+ )<br>
+{<br>
+ return CommonAcpiTimerLibConstructor ();<br>
+}<br>
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf<br>
index d86356f4ff17..93972e53c9c5 100644<br>
--- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf<br>
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf<br>
@@ -25,6 +25,8 @@ [Defines]<br>
[Sources]<br>
AcpiTimerLib.c<br>
DxeAcpiTimerLib.c<br>
+ DxeStandaloneMmAcpiTimerLib.c<br>
+ DxeStandaloneMmAcpiTimerLib.h<br>
<br>
[Packages]<br>
MdePkg/MdePkg.dec<br>
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.h b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.h<br>
new file mode 100644<br>
index 000000000000..6015d684e5bd<br>
--- /dev/null<br>
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.h<br>
@@ -0,0 +1,24 @@<br>
+/** @file<br>
+ Header file internal to ACPI TimerLib.<br>
+<br>
+Copyright (c) Microsoft Corporation.<br>
+SPDX-License-Identifier: BSD-2-Clause-Patent<br>
+<br>
+**/<br>
+<br>
+<br>
+#ifndef _DXE_STANDALONE_MM_ACPI_TIMER_LIB_H_<br>
+#define _DXE_STANDALONE_MM_ACPI_TIMER_LIB_H_<br>
+<br>
+/**<br>
+ The constructor function enables ACPI IO space, and caches PerformanceCounterFrequency.<br>
+<br>
+ @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.<br>
+<br>
+**/<br>
+EFI_STATUS<br>
+CommonAcpiTimerLibConstructor (<br>
+ VOID<br>
+ );<br>
+<br>
+#endif<br>
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf b/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.inf<br>
similarity index 70%<br>
copy from PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf<br>
copy to PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.inf<br>
index d86356f4ff17..c5efdd145d19 100644<br>
--- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf<br>
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.inf<br>
@@ -1,5 +1,5 @@<br>
## @file<br>
-# DXE ACPI Timer Library<br>
+# Standalone MM ACPI Timer Library<br>
#<br>
# Provides basic timer support using the ACPI timer hardware. The performance<br>
# counter features are provided by the processors time stamp counter.<br>
@@ -8,23 +8,26 @@<br>
# is compatible with both 24-bit and 32-bit ACPI timers.<br>
#<br>
# Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR><br>
+# Copyright (c) Microsoft Corporation.<br>
# SPDX-License-Identifier: BSD-2-Clause-Patent<br>
#<br>
##<br>
<br>
[Defines]<br>
INF_VERSION = 0x00010005<br>
- BASE_NAME = DxeAcpiTimerLib<br>
- FILE_GUID = E624B98C-845A-4b94-9B50-B20475D552B9<br>
- MODULE_TYPE = DXE_DRIVER<br>
+ BASE_NAME = StandaloneMmAcpiTimerLib<br>
+ FILE_GUID = C771858D-AF09-4D1A-B2F3-C7F081C3F076<br>
+ MODULE_TYPE = MM_STANDALONE<br>
VERSION_STRING = 1.0<br>
- LIBRARY_CLASS = TimerLib|DXE_CORE DXE_DRIVER DXE_RUNTIME_DRIVER DXE_SMM_DRIVER UEFI_APPLICATION UEFI_DRIVER SMM_CORE<br>
- CONSTRUCTOR = DxeAcpiTimerLibConstructor<br>
- MODULE_UNI_FILE = DxeAcpiTimerLib.uni<br>
+ PI_SPECIFICATION_VERSION = 0x00010032<br>
+ LIBRARY_CLASS = TimerLib|MM_CORE_STANDALONE MM_STANDALONE<br>
+ CONSTRUCTOR = StandaloneMmAcpiTimerLibConstructor<br>
<br>
[Sources]<br>
AcpiTimerLib.c<br>
- DxeAcpiTimerLib.c<br>
+ StandaloneMmAcpiTimerLib.c<br>
+ DxeStandaloneMmAcpiTimerLib.c<br>
+ DxeStandaloneMmAcpiTimerLib.h<br>
<br>
[Packages]<br>
MdePkg/MdePkg.dec<br>
diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dsc b/PcAtChipsetPkg/PcAtChipsetPkg.dsc<br>
index b61b7d1f528e..3d1fb816f54f 100644<br>
--- a/PcAtChipsetPkg/PcAtChipsetPkg.dsc<br>
+++ b/PcAtChipsetPkg/PcAtChipsetPkg.dsc<br>
@@ -53,6 +53,7 @@ [Components]<br>
PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf<br>
PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf<br>
PcAtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.inf<br>
+ PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.inf<br>
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf<br>
<br>
[BuildOptions]<br>
-- <br>
2.30.0.windows.1<br>
<br>
<br>
<br>
<br>
<br>
<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
</div>
</body>
</html>
<div width="1" style="color:white;clear:both">_._,_._,_</div> <hr> Groups.io Links:<p> You receive all messages sent to this group. <p> <a target="_blank" href="https://edk2.groups.io/g/devel/message/70608">View/Reply Online (#70608)</a> | | <a target="_blank" href="https://groups.io/mt/79688592/1813853">Mute This Topic</a> | <a href="https://edk2.groups.io/g/devel/post">New Topic</a><br> <a href="https://edk2.groups.io/g/devel/editsub/1813853">Your Subscription</a> | <a href="mailto:devel+owner@edk2.groups.io">Contact Group Owner</a> | <a href="https://edk2.groups.io/g/devel/unsub">Unsubscribe</a> [edk2-devel-archive@redhat.com]<br> <div width="1" style="color:white;clear:both">_._,_._,_</div>