summaryrefslogtreecommitdiff
path: root/PcAtChipsetPkg
diff options
context:
space:
mode:
Diffstat (limited to 'PcAtChipsetPkg')
-rw-r--r--PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c81
-rw-r--r--PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf2
-rw-r--r--PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.c101
-rw-r--r--PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.h24
-rw-r--r--PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.c31
-rw-r--r--PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.inf53
-rw-r--r--PcAtChipsetPkg/PcAtChipsetPkg.dsc1
7 files changed, 215 insertions, 78 deletions
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c
index 3ad831b..9ac2a44 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 "DxeStandaloneMmAcpiTimerLib.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/DxeAcpiTimerLib.inf b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
index d86356f..93972e5 100644
--- a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
@@ -25,6 +25,8 @@
[Sources]
AcpiTimerLib.c
DxeAcpiTimerLib.c
+ DxeStandaloneMmAcpiTimerLib.c
+ DxeStandaloneMmAcpiTimerLib.h
[Packages]
MdePkg/MdePkg.dec
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.c b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.c
new file mode 100644
index 0000000..0e40119
--- /dev/null
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.c
@@ -0,0 +1,101 @@
+/** @file
+ ACPI Timer implements one instance of Timer Library.
+
+ Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>
+ 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;
+}
+
+/**
+ The constructor function enables ACPI IO space, and caches PerformanceCounterFrequency.
+
+ @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.
+
+**/
+EFI_STATUS
+CommonAcpiTimerLibConstructor (
+ VOID
+ )
+{
+ 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;
+}
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.h b/PcAtChipsetPkg/Library/AcpiTimerLib/DxeStandaloneMmAcpiTimerLib.h
new file mode 100644
index 0000000..6015d68
--- /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 PerformanceCounterFrequency.
+
+ @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.
+
+**/
+EFI_STATUS
+CommonAcpiTimerLibConstructor (
+ VOID
+ );
+
+#endif
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.c b/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.c
new file mode 100644
index 0000000..97aca56
--- /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.<BR>
+ Copyright (c) Microsoft Corporation.
+ SPDX-License-Identifier: BSD-2-Clause-Patent
+
+**/
+
+#include <PiMm.h>
+
+#include "DxeStandaloneMmAcpiTimerLib.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/StandaloneMmAcpiTimerLib.inf b/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.inf
new file mode 100644
index 0000000..c5efdd1
--- /dev/null
+++ b/PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.inf
@@ -0,0 +1,53 @@
+## @file
+# 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.
+#
+# 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.<BR>
+# Copyright (c) Microsoft Corporation.
+# SPDX-License-Identifier: BSD-2-Clause-Patent
+#
+##
+
+[Defines]
+ INF_VERSION = 0x00010005
+ BASE_NAME = StandaloneMmAcpiTimerLib
+ FILE_GUID = C771858D-AF09-4D1A-B2F3-C7F081C3F076
+ MODULE_TYPE = MM_STANDALONE
+ VERSION_STRING = 1.0
+ PI_SPECIFICATION_VERSION = 0x00010032
+ LIBRARY_CLASS = TimerLib|MM_CORE_STANDALONE MM_STANDALONE
+ CONSTRUCTOR = StandaloneMmAcpiTimerLibConstructor
+
+[Sources]
+ AcpiTimerLib.c
+ StandaloneMmAcpiTimerLib.c
+ DxeStandaloneMmAcpiTimerLib.c
+ DxeStandaloneMmAcpiTimerLib.h
+
+[Packages]
+ MdePkg/MdePkg.dec
+ PcAtChipsetPkg/PcAtChipsetPkg.dec
+
+[LibraryClasses]
+ BaseLib
+ PcdLib
+ PciLib
+ IoLib
+ DebugLib
+ HobLib
+
+[Pcd]
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPciBusNumber ## CONSUMES
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPciDeviceNumber ## CONSUMES
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPciFunctionNumber ## CONSUMES
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPciEnableRegisterOffset ## CONSUMES
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoBarEnableMask ## CONSUMES
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPciBarRegisterOffset ## CONSUMES
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPortBaseAddress ## CONSUMES
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiPm1TmrOffset ## CONSUMES
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPortBaseAddressMask ## CONSUMES
diff --git a/PcAtChipsetPkg/PcAtChipsetPkg.dsc b/PcAtChipsetPkg/PcAtChipsetPkg.dsc
index b61b7d1..3d1fb81 100644
--- a/PcAtChipsetPkg/PcAtChipsetPkg.dsc
+++ b/PcAtChipsetPkg/PcAtChipsetPkg.dsc
@@ -53,6 +53,7 @@
PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf
PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf
PcAtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.inf
+ PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.inf
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf
[BuildOptions]