]> git.proxmox.com Git - mirror_edk2.git/blame - PcAtChipsetPkg/Library/AcpiTimerLib/BaseAcpiTimerLib.c
PcAtChipsetPkg: Replace BSD License with BSD+Patent License
[mirror_edk2.git] / PcAtChipsetPkg / Library / AcpiTimerLib / BaseAcpiTimerLib.c
CommitLineData
83d1ffb9
LG
1/** @file\r
2 ACPI Timer implements one instance of Timer Library.\r
3\r
5a702acd 4 Copyright (c) 2013 - 2018, Intel Corporation. All rights reserved.<BR>\r
e1d302e5 5 SPDX-License-Identifier: BSD-2-Clause-Patent\r
83d1ffb9
LG
6\r
7**/\r
8\r
9#include <Base.h>\r
10#include <Library/TimerLib.h>\r
11#include <Library/BaseLib.h>\r
12\r
62b8b5be
SZ
13/**\r
14 Calculate TSC frequency.\r
15\r
16 The TSC counting frequency is determined by comparing how far it counts\r
a012df5e
SZ
17 during a 101.4 us period as determined by the ACPI timer.\r
18 The ACPI timer is used because it counts at a known frequency.\r
19 The TSC is sampled, followed by waiting 363 counts of the ACPI timer,\r
20 or 101.4 us. The TSC is then sampled again. The difference multiplied by\r
21 9861 is the TSC frequency. There will be a small error because of the\r
22 overhead of reading the ACPI timer. An attempt is made to determine and\r
23 compensate for this error.\r
62b8b5be
SZ
24\r
25 @return The number of TSC counts per second.\r
26\r
27**/\r
28UINT64\r
29InternalCalculateTscFrequency (\r
30 VOID\r
31 );\r
32\r
83d1ffb9
LG
33/**\r
34 Internal function to retrieves the 64-bit frequency in Hz.\r
35\r
36 Internal function to retrieves the 64-bit frequency in Hz.\r
37\r
38 @return The frequency in Hz.\r
39\r
40**/\r
41UINT64\r
42InternalGetPerformanceCounterFrequency (\r
43 VOID\r
5a702acd 44 )\r
83d1ffb9 45{\r
62b8b5be 46 return InternalCalculateTscFrequency ();\r
83d1ffb9 47}\r