]> git.proxmox.com Git - mirror_edk2.git/blobdiff - PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
PcAtChipsetPkg: new AcpiTimerLib libraries.
[mirror_edk2.git] / PcAtChipsetPkg / Library / AcpiTimerLib / BaseAcpiTimerLib.c
diff --git a/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c b/PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
new file mode 100644 (file)
index 0000000..21fdb79
--- /dev/null
@@ -0,0 +1,42 @@
+/** @file\r
+  ACPI Timer implements one instance of Timer Library.\r
+\r
+  Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>\r
+  This program and the accompanying materials\r
+  are licensed and made available under the terms and conditions of the BSD License\r
+  which accompanies this distribution.  The full text of the license may be found at\r
+  http://opensource.org/licenses/bsd-license.php\r
+\r
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#include <Base.h>\r
+#include <Library/TimerLib.h>\r
+#include <Library/BaseLib.h>\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
+  BOOLEAN  InterruptState;\r
+  UINT64   Count;\r
+  UINT64   Frequency;\r
+  \r
+  InterruptState = SaveAndDisableInterrupts ();\r
+  Count = GetPerformanceCounter ();\r
+  MicroSecondDelay (100);\r
+  Frequency = MultU64x32 (GetPerformanceCounter () - Count, 10000);\r
+  SetInterruptState (InterruptState);\r
+  return Frequency;\r
+}\r