]> git.proxmox.com Git - mirror_edk2.git/blame - InOsEmuPkg/Library/DxeCoreTimerLib/DxeCoreTimerLib.c
Clarify the requirements for the Destination parameter of UnicodeStrToAsciiStr.
[mirror_edk2.git] / InOsEmuPkg / Library / DxeCoreTimerLib / DxeCoreTimerLib.c
CommitLineData
1ef41207 1/** @file\r
2 A non-functional instance of the Timer Library.\r
3\r
4 Copyright (c) 2007 - 2010, 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 <PiPei.h>\r
16#include <Library/TimerLib.h>\r
17#include <Library/DebugLib.h>\r
18#include <Library/EmuThunkLib.h>\r
19#include <Library/UefiBootServicesTableLib.h>\r
20#include <Library/UefiLib.h>\r
21\r
22#include <Protocol/Timer.h>\r
23\r
24\r
25\r
26/**\r
27 Stalls the CPU for at least the given number of microseconds.\r
28\r
29 Stalls the CPU for the number of microseconds specified by MicroSeconds.\r
30\r
31 @param MicroSeconds The minimum number of microseconds to delay.\r
32\r
33 @return The value of MicroSeconds inputted.\r
34\r
35**/\r
36UINTN\r
37EFIAPI\r
38MicroSecondDelay (\r
39 IN UINTN MicroSeconds\r
40 )\r
41{\r
42 return NanoSecondDelay (MicroSeconds * 1000);\r
43}\r
44\r
45\r
46/**\r
47 Stalls the CPU for at least the given number of nanoseconds.\r
48\r
49 Stalls the CPU for the number of nanoseconds specified by NanoSeconds.\r
50\r
51 @param NanoSeconds The minimum number of nanoseconds to delay.\r
52\r
53 @return The value of NanoSeconds inputted.\r
54\r
55**/\r
56UINTN\r
57EFIAPI\r
58NanoSecondDelay (\r
59 IN UINTN NanoSeconds\r
60 )\r
61{\r
62 gEmuThunk->Sleep (NanoSeconds);\r
63 return NanoSeconds;\r
64}\r
65\r
66\r
67/**\r
68 Retrieves the current value of a 64-bit free running performance counter.\r
69\r
70 The counter can either count up by 1 or count down by 1. If the physical\r
71 performance counter counts by a larger increment, then the counter values\r
72 must be translated. The properties of the counter can be retrieved from\r
73 GetPerformanceCounterProperties().\r
74\r
75 @return The current value of the free running performance counter.\r
76\r
77**/\r
78UINT64\r
79EFIAPI\r
80GetPerformanceCounter (\r
81 VOID\r
82 )\r
83{\r
84 return gEmuThunk->QueryPerformanceCounter ();\r
85}\r
86\r
87/**\r
88 Retrieves the 64-bit frequency in Hz and the range of performance counter\r
89 values.\r
90\r
91 If StartValue is not NULL, then the value that the performance counter starts\r
92 with immediately after is it rolls over is returned in StartValue. If\r
93 EndValue is not NULL, then the value that the performance counter end with\r
94 immediately before it rolls over is returned in EndValue. The 64-bit\r
95 frequency of the performance counter in Hz is always returned. If StartValue\r
96 is less than EndValue, then the performance counter counts up. If StartValue\r
97 is greater than EndValue, then the performance counter counts down. For\r
98 example, a 64-bit free running counter that counts up would have a StartValue\r
99 of 0 and an EndValue of 0xFFFFFFFFFFFFFFFF. A 24-bit free running counter\r
100 that counts down would have a StartValue of 0xFFFFFF and an EndValue of 0.\r
101\r
102 @param StartValue The value the performance counter starts with when it\r
103 rolls over.\r
104 @param EndValue The value that the performance counter ends with before\r
105 it rolls over.\r
106\r
107 @return The frequency in Hz.\r
108\r
109**/\r
110UINT64\r
111EFIAPI\r
112GetPerformanceCounterProperties (\r
113 OUT UINT64 *StartValue, OPTIONAL\r
114 OUT UINT64 *EndValue OPTIONAL\r
115 )\r
116{\r
117\r
118 if (StartValue != NULL) {\r
119 *StartValue = 0ULL;\r
120 }\r
121 if (EndValue != NULL) {\r
122 *EndValue = (UINT64)-1LL;\r
123 }\r
124 \r
125 return gEmuThunk->QueryPerformanceFrequency ();\r
126}\r
127\r
128\r