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