ACPI Timer implements one instance of Timer Library.\r
\r
Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) Microsoft Corporation.\r
SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
#include <PiDxe.h>\r
-#include <Library/TimerLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/HobLib.h>\r
\r
-extern GUID mFrequencyHobGuid;\r
-\r
-/**\r
- The constructor function enables ACPI IO space.\r
-\r
- If ACPI I/O space not enabled, this function will enable it.\r
- It will always return RETURN_SUCCESS.\r
-\r
- @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.\r
-\r
-**/\r
-RETURN_STATUS\r
-EFIAPI\r
-AcpiTimerLibConstructor (\r
- VOID\r
- );\r
-\r
-/**\r
- Calculate TSC frequency.\r
-\r
- The TSC counting frequency is determined by comparing how far it counts\r
- during a 101.4 us period as determined by the ACPI timer.\r
- The ACPI timer is used because it counts at a known frequency.\r
- The TSC is sampled, followed by waiting 363 counts of the ACPI timer,\r
- or 101.4 us. The TSC is then sampled again. The difference multiplied by\r
- 9861 is the TSC frequency. There will be a small error because of the\r
- overhead of reading the ACPI timer. An attempt is made to determine and\r
- compensate for this error.\r
-\r
- @return The number of TSC counts per second.\r
-\r
-**/\r
-UINT64\r
-InternalCalculateTscFrequency (\r
- VOID\r
- );\r
-\r
-//\r
-// Cached performance counter frequency\r
-//\r
-UINT64 mPerformanceCounterFrequency = 0;\r
-\r
-/**\r
- Internal function to retrieves the 64-bit frequency in Hz.\r
-\r
- Internal function to retrieves the 64-bit frequency in Hz.\r
-\r
- @return The frequency in Hz.\r
-\r
-**/\r
-UINT64\r
-InternalGetPerformanceCounterFrequency (\r
- VOID\r
- )\r
-{\r
- return mPerformanceCounterFrequency;\r
-}\r
+#include "DxeStandaloneMmAcpiTimerLib.h"\r
\r
/**\r
The constructor function enables ACPI IO space, and caches PerformanceCounterFrequency.\r
IN EFI_SYSTEM_TABLE *SystemTable\r
)\r
{\r
- EFI_HOB_GUID_TYPE *GuidHob;\r
-\r
- //\r
- // Enable ACPI IO space.\r
- //\r
- AcpiTimerLibConstructor ();\r
-\r
- //\r
- // Initialize PerformanceCounterFrequency\r
- //\r
- GuidHob = GetFirstGuidHob (&mFrequencyHobGuid);\r
- if (GuidHob != NULL) {\r
- mPerformanceCounterFrequency = *(UINT64*)GET_GUID_HOB_DATA (GuidHob);\r
- } else {\r
- mPerformanceCounterFrequency = InternalCalculateTscFrequency ();\r
- }\r
-\r
- return EFI_SUCCESS;\r
+ return CommonAcpiTimerLibConstructor ();\r
}\r
[Sources]\r
AcpiTimerLib.c\r
DxeAcpiTimerLib.c\r
+ DxeStandaloneMmAcpiTimerLib.c\r
+ DxeStandaloneMmAcpiTimerLib.h\r
\r
[Packages]\r
MdePkg/MdePkg.dec\r
--- /dev/null
+/** @file\r
+ ACPI Timer implements one instance of Timer Library.\r
+\r
+ Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <PiDxe.h>\r
+#include <Library/TimerLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/HobLib.h>\r
+\r
+extern GUID mFrequencyHobGuid;\r
+\r
+/**\r
+ The constructor function enables ACPI IO space.\r
+\r
+ If ACPI I/O space not enabled, this function will enable it.\r
+ It will always return RETURN_SUCCESS.\r
+\r
+ @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+AcpiTimerLibConstructor (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Calculate TSC frequency.\r
+\r
+ The TSC counting frequency is determined by comparing how far it counts\r
+ during a 101.4 us period as determined by the ACPI timer.\r
+ The ACPI timer is used because it counts at a known frequency.\r
+ The TSC is sampled, followed by waiting 363 counts of the ACPI timer,\r
+ or 101.4 us. The TSC is then sampled again. The difference multiplied by\r
+ 9861 is the TSC frequency. There will be a small error because of the\r
+ overhead of reading the ACPI timer. An attempt is made to determine and\r
+ compensate for this error.\r
+\r
+ @return The number of TSC counts per second.\r
+\r
+**/\r
+UINT64\r
+InternalCalculateTscFrequency (\r
+ VOID\r
+ );\r
+\r
+//\r
+// Cached performance counter frequency\r
+//\r
+UINT64 mPerformanceCounterFrequency = 0;\r
+\r
+/**\r
+ Internal function to retrieves the 64-bit frequency in Hz.\r
+\r
+ Internal function to retrieves the 64-bit frequency in Hz.\r
+\r
+ @return The frequency in Hz.\r
+\r
+**/\r
+UINT64\r
+InternalGetPerformanceCounterFrequency (\r
+ VOID\r
+ )\r
+{\r
+ return mPerformanceCounterFrequency;\r
+}\r
+\r
+/**\r
+ The constructor function enables ACPI IO space, and caches PerformanceCounterFrequency.\r
+\r
+ @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+CommonAcpiTimerLibConstructor (\r
+ VOID\r
+ )\r
+{\r
+ EFI_HOB_GUID_TYPE *GuidHob;\r
+\r
+ //\r
+ // Enable ACPI IO space.\r
+ //\r
+ AcpiTimerLibConstructor ();\r
+\r
+ //\r
+ // Initialize PerformanceCounterFrequency\r
+ //\r
+ GuidHob = GetFirstGuidHob (&mFrequencyHobGuid);\r
+ if (GuidHob != NULL) {\r
+ mPerformanceCounterFrequency = *(UINT64*)GET_GUID_HOB_DATA (GuidHob);\r
+ } else {\r
+ mPerformanceCounterFrequency = InternalCalculateTscFrequency ();\r
+ }\r
+\r
+ return EFI_SUCCESS;\r
+}\r
--- /dev/null
+/** @file\r
+ Header file internal to ACPI TimerLib.\r
+\r
+Copyright (c) Microsoft Corporation.\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+\r
+#ifndef _DXE_STANDALONE_MM_ACPI_TIMER_LIB_H_\r
+#define _DXE_STANDALONE_MM_ACPI_TIMER_LIB_H_\r
+\r
+/**\r
+ The constructor function enables ACPI IO space, and caches PerformanceCounterFrequency.\r
+\r
+ @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+CommonAcpiTimerLibConstructor (\r
+ VOID\r
+ );\r
+\r
+#endif\r
--- /dev/null
+/** @file\r
+ ACPI Timer implements one instance of Timer Library.\r
+\r
+ Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
+ Copyright (c) Microsoft Corporation.\r
+ SPDX-License-Identifier: BSD-2-Clause-Patent\r
+\r
+**/\r
+\r
+#include <PiMm.h>\r
+\r
+#include "DxeStandaloneMmAcpiTimerLib.h"\r
+\r
+/**\r
+ The constructor function enables ACPI IO space, and caches PerformanceCounterFrequency.\r
+\r
+ @param ImageHandle The firmware allocated handle for the EFI image.\r
+ @param SystemTable A pointer to the EFI System Table.\r
+\r
+ @retval EFI_SUCCESS The constructor always returns RETURN_SUCCESS.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+StandaloneMmAcpiTimerLibConstructor (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_MM_SYSTEM_TABLE *SystemTable\r
+ )\r
+{\r
+ return CommonAcpiTimerLibConstructor ();\r
+}\r
--- /dev/null
+## @file\r
+# Standalone MM ACPI Timer Library\r
+#\r
+# Provides basic timer support using the ACPI timer hardware. The performance\r
+# counter features are provided by the processors time stamp counter.\r
+#\r
+# Note: The implementation uses the lower 24-bits of the ACPI timer and\r
+# is compatible with both 24-bit and 32-bit ACPI timers.\r
+#\r
+# Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) Microsoft Corporation.\r
+# SPDX-License-Identifier: BSD-2-Clause-Patent\r
+#\r
+##\r
+\r
+[Defines]\r
+ INF_VERSION = 0x00010005\r
+ BASE_NAME = StandaloneMmAcpiTimerLib\r
+ FILE_GUID = C771858D-AF09-4D1A-B2F3-C7F081C3F076\r
+ MODULE_TYPE = MM_STANDALONE\r
+ VERSION_STRING = 1.0\r
+ PI_SPECIFICATION_VERSION = 0x00010032\r
+ LIBRARY_CLASS = TimerLib|MM_CORE_STANDALONE MM_STANDALONE\r
+ CONSTRUCTOR = StandaloneMmAcpiTimerLibConstructor\r
+\r
+[Sources]\r
+ AcpiTimerLib.c\r
+ StandaloneMmAcpiTimerLib.c\r
+ DxeStandaloneMmAcpiTimerLib.c\r
+ DxeStandaloneMmAcpiTimerLib.h\r
+\r
+[Packages]\r
+ MdePkg/MdePkg.dec\r
+ PcAtChipsetPkg/PcAtChipsetPkg.dec\r
+\r
+[LibraryClasses]\r
+ BaseLib\r
+ PcdLib\r
+ PciLib\r
+ IoLib\r
+ DebugLib\r
+ HobLib\r
+\r
+[Pcd]\r
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPciBusNumber ## CONSUMES\r
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPciDeviceNumber ## CONSUMES\r
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPciFunctionNumber ## CONSUMES\r
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPciEnableRegisterOffset ## CONSUMES\r
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoBarEnableMask ## CONSUMES\r
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPciBarRegisterOffset ## CONSUMES\r
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPortBaseAddress ## CONSUMES\r
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiPm1TmrOffset ## CONSUMES\r
+ gPcAtChipsetPkgTokenSpaceGuid.PcdAcpiIoPortBaseAddressMask ## CONSUMES\r
PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.inf\r
PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.inf\r
PcAtChipsetPkg/Library/AcpiTimerLib/PeiAcpiTimerLib.inf\r
+ PcAtChipsetPkg/Library/AcpiTimerLib/StandaloneMmAcpiTimerLib.inf\r
PcAtChipsetPkg/PcatRealTimeClockRuntimeDxe/PcatRealTimeClockRuntimeDxe.inf\r
\r
[BuildOptions]\r