8523bd0dfbafbe4b02aba9b40d1bc9b8ad662bf9
[mirror_edk2.git] / MdePkg / Include / Library / TimerLib.h
1 /** @file
2 Timer Library Functions
3
4 Copyright (c) 2006, Intel Corporation
5 All rights reserved. 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 Module Name: TimerLib.h
14
15 **/
16
17 #ifndef __TIMER_LIB__
18 #define __TIMER_LIB__
19
20 /**
21 Stalls the CPU for at least the given number of microseconds.
22
23 Stalls the CPU for the number of microseconds specified by MicroSeconds.
24
25 @param MicroSeconds The minimum number of microseconds to delay.
26
27 @return MicroSeconds
28
29 **/
30 UINTN
31 EFIAPI
32 MicroSecondDelay (
33 IN UINTN MicroSeconds
34 );
35
36 /**
37 Stalls the CPU for at least the given number of nanoseconds.
38
39 Stalls the CPU for the number of nanoseconds specified by NanoSeconds.
40
41 @param NanoSeconds The minimum number of nanoseconds to delay.
42
43 @return NanoSeconds
44
45 **/
46 UINTN
47 EFIAPI
48 NanoSecondDelay (
49 IN UINTN NanoSeconds
50 );
51
52 /**
53 Retrieves the current value of a 64-bit free running performance counter.
54
55 Retrieves the current value of a 64-bit free running performance counter. The
56 counter can either count up by 1 or count down by 1. If the physical
57 performance counter counts by a larger increment, then the counter values
58 must be translated. The properties of the counter can be retrieved from
59 GetPerformanceCounterProperties().
60
61 @return The current value of the free running performance counter.
62
63 **/
64 UINT64
65 EFIAPI
66 GetPerformanceCounter (
67 VOID
68 );
69
70 /**
71 Retrieves the 64-bit frequency in Hz and the range of performance counter
72 values.
73
74 If StartValue is not NULL, then the value that the performance counter starts
75 with immediately after is it rolls over is returned in StartValue. If
76 EndValue is not NULL, then the value that the performance counter end with
77 immediately before it rolls over is returned in EndValue. The 64-bit
78 frequency of the performance counter in Hz is always returned. If StartValue
79 is less than EndValue, then the performance counter counts up. If StartValue
80 is greater than EndValue, then the performance counter counts down. For
81 example, a 64-bit free running counter that counts up would have a StartValue
82 of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter
83 that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.
84
85 @param StartValue The value the performance counter starts with when it
86 rolls over.
87 @param EndValue The value that the performance counter ends with before
88 it rolls over.
89
90 @return The frequency in Hz.
91
92 **/
93 UINT64
94 EFIAPI
95 GetPerformanceCounterProperties (
96 IN UINT64 *StartValue, OPTIONAL
97 IN UINT64 *EndValue OPTIONAL
98 );
99
100 #endif