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