1 | /** @file
|
---|
2 | Provides calibrated delay and performance counter services.
|
---|
3 |
|
---|
4 | Copyright (c) 2006 - 2011, 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 | #ifndef __TIMER_LIB__
|
---|
16 | #define __TIMER_LIB__
|
---|
17 |
|
---|
18 | /**
|
---|
19 | Stalls the CPU for at least the given number of microseconds.
|
---|
20 |
|
---|
21 | Stalls the CPU for the number of microseconds specified by MicroSeconds.
|
---|
22 |
|
---|
23 | @param MicroSeconds The minimum number of microseconds to delay.
|
---|
24 |
|
---|
25 | @return The value of MicroSeconds inputted.
|
---|
26 |
|
---|
27 | **/
|
---|
28 | UINTN
|
---|
29 | EFIAPI
|
---|
30 | MicroSecondDelay (
|
---|
31 | IN UINTN MicroSeconds
|
---|
32 | );
|
---|
33 |
|
---|
34 | /**
|
---|
35 | Stalls the CPU for at least the given number of nanoseconds.
|
---|
36 |
|
---|
37 | Stalls the CPU for the number of nanoseconds specified by NanoSeconds.
|
---|
38 |
|
---|
39 | @param NanoSeconds The minimum number of nanoseconds to delay.
|
---|
40 |
|
---|
41 | @return The value of NanoSeconds inputted.
|
---|
42 |
|
---|
43 | **/
|
---|
44 | UINTN
|
---|
45 | EFIAPI
|
---|
46 | NanoSecondDelay (
|
---|
47 | IN UINTN NanoSeconds
|
---|
48 | );
|
---|
49 |
|
---|
50 | /**
|
---|
51 | Retrieves the current value of a 64-bit free running performance counter.
|
---|
52 |
|
---|
53 | The counter can either count up by 1 or count down by 1. If the physical
|
---|
54 | performance counter counts by a larger increment, then the counter values
|
---|
55 | must be translated. The properties of the counter can be retrieved from
|
---|
56 | GetPerformanceCounterProperties().
|
---|
57 |
|
---|
58 | @return The current value of the free running performance counter.
|
---|
59 |
|
---|
60 | **/
|
---|
61 | UINT64
|
---|
62 | EFIAPI
|
---|
63 | GetPerformanceCounter (
|
---|
64 | VOID
|
---|
65 | );
|
---|
66 |
|
---|
67 | /**
|
---|
68 | Retrieves the 64-bit frequency in Hz and the range of performance counter
|
---|
69 | values.
|
---|
70 |
|
---|
71 | If StartValue is not NULL, then the value that the performance counter starts
|
---|
72 | with immediately after is it rolls over is returned in StartValue. If
|
---|
73 | EndValue is not NULL, then the value that the performance counter end with
|
---|
74 | immediately before it rolls over is returned in EndValue. The 64-bit
|
---|
75 | frequency of the performance counter in Hz is always returned. If StartValue
|
---|
76 | is less than EndValue, then the performance counter counts up. If StartValue
|
---|
77 | is greater than EndValue, then the performance counter counts down. For
|
---|
78 | example, a 64-bit free running counter that counts up would have a StartValue
|
---|
79 | of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter
|
---|
80 | that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.
|
---|
81 |
|
---|
82 | @param StartValue The value the performance counter starts with when it
|
---|
83 | rolls over.
|
---|
84 | @param EndValue The value that the performance counter ends with before
|
---|
85 | it rolls over.
|
---|
86 |
|
---|
87 | @return The frequency in Hz.
|
---|
88 |
|
---|
89 | **/
|
---|
90 | UINT64
|
---|
91 | EFIAPI
|
---|
92 | GetPerformanceCounterProperties (
|
---|
93 | OUT UINT64 *StartValue, OPTIONAL
|
---|
94 | OUT UINT64 *EndValue OPTIONAL
|
---|
95 | );
|
---|
96 |
|
---|
97 | /**
|
---|
98 | Converts elapsed ticks of performance counter to time in nanoseconds.
|
---|
99 |
|
---|
100 | This function converts the elapsed ticks of running performance counter to
|
---|
101 | time value in unit of nanoseconds.
|
---|
102 |
|
---|
103 | @param Ticks The number of elapsed ticks of running performance counter.
|
---|
104 |
|
---|
105 | @return The elapsed time in nanoseconds.
|
---|
106 |
|
---|
107 | **/
|
---|
108 | UINT64
|
---|
109 | EFIAPI
|
---|
110 | GetTimeInNanoSecond (
|
---|
111 | IN UINT64 Ticks
|
---|
112 | );
|
---|
113 |
|
---|
114 | #endif
|
---|