]> git.proxmox.com Git - mirror_edk2.git/blobdiff - PerformancePkg/Library/TscTimerLib/BaseTscTimerLib.c
Add BaseTscTimerLib, and then merge the three TscTimerLib to one directory.
[mirror_edk2.git] / PerformancePkg / Library / TscTimerLib / BaseTscTimerLib.c
diff --git a/PerformancePkg/Library/TscTimerLib/BaseTscTimerLib.c b/PerformancePkg/Library/TscTimerLib/BaseTscTimerLib.c
new file mode 100644 (file)
index 0000000..77bc04e
--- /dev/null
@@ -0,0 +1,57 @@
+/** @file\r
+  A Base Timer Library implementation which uses the Time Stamp Counter in the processor.\r
+\r
+  For Pentium 4 processors, Intel Xeon processors (family [0FH], models [03H and higher]);\r
+    for Intel Core Solo and Intel Core Duo processors (family [06H], model [0EH]);\r
+    for the Intel Xeon processor 5100 series and Intel Core 2 Duo processors (family [06H], model [0FH]);\r
+    for Intel Core 2 and Intel Xeon processors (family [06H], display_model [17H]);\r
+    for Intel Atom processors (family [06H], display_model [1CH]):\r
+  the time-stamp counter increments at a constant rate.\r
+  That rate may be set by the maximum core-clock to bus-clock ratio of the processor or may be set by\r
+  the maximum resolved frequency at which the processor is booted. The maximum resolved frequency may\r
+  differ from the maximum qualified frequency of the processor.\r
+\r
+  The specific processor configuration determines the behavior. Constant TSC behavior ensures that the\r
+  duration of each clock tick is uniform and supports the use of the TSC as a wall clock timer even if\r
+  the processor core changes frequency. This is the architectural behavior moving forward.\r
+\r
+  A Processor's support for invariant TSC is indicated by CPUID.0x80000007.EDX[8].\r
+\r
+  Copyright (c) 2009 - 2011, 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 "TscTimerLibInternal.h"\r
+\r
+UINT64  mTscFrequency = 0;\r
+\r
+/**  Get TSC frequency.\r
+\r
+  @return The number of TSC counts per second.\r
+\r
+**/\r
+UINT64\r
+InternalGetTscFrequency (\r
+  VOID\r
+  )\r
+{\r
+  UINT64    TscFrequency;\r
+\r
+  if (mTscFrequency != 0) {\r
+    return mTscFrequency;\r
+  }\r
+\r
+  TscFrequency = InternalCalculateTscFrequency ();\r
+\r
+  mTscFrequency = TscFrequency;\r
+\r
+  return TscFrequency;\r
+}\r
+\r