]> git.proxmox.com Git - mirror_edk2.git/blame - PcAtChipsetPkg/Library/AcpiTimerLib/DxeAcpiTimerLib.c
MdePkg RVCT: add definition of UNREACHABLE
[mirror_edk2.git] / PcAtChipsetPkg / Library / AcpiTimerLib / DxeAcpiTimerLib.c
CommitLineData
83d1ffb9
LG
1/** @file\r
2 ACPI Timer implements one instance of Timer Library.\r
3\r
4 Copyright (c) 2013 - 2014, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#include <Base.h>\r
16#include <Library/TimerLib.h>\r
17#include <Library/BaseLib.h>\r
18\r
19//\r
20// Cached performance counter frequency\r
21//\r
22UINT64 mPerformanceCounterFrequency = 0;\r
23\r
24/**\r
25 Internal function to retrieves the 64-bit frequency in Hz.\r
26\r
27 Internal function to retrieves the 64-bit frequency in Hz.\r
28\r
29 @return The frequency in Hz.\r
30\r
31**/\r
32UINT64\r
33InternalGetPerformanceCounterFrequency (\r
34 VOID\r
35 ) \r
36{\r
37 BOOLEAN InterruptState;\r
38 UINT64 Count;\r
39\r
40 if (mPerformanceCounterFrequency == 0) {\r
41 InterruptState = SaveAndDisableInterrupts ();\r
42 Count = GetPerformanceCounter ();\r
43 MicroSecondDelay (100);\r
44 mPerformanceCounterFrequency = MultU64x32 (GetPerformanceCounter () - Count, 10000);\r
45 SetInterruptState (InterruptState);\r
46 }\r
47 return mPerformanceCounterFrequency;\r
48}\r