]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Library/BasePerformanceLibNull/PerformanceLib.c
MdePkg/BaseLib: Support IA32 processors without CLFLUSH
[mirror_edk2.git] / MdePkg / Library / BasePerformanceLibNull / PerformanceLib.c
CommitLineData
e1f414b6 1/** @file\r
2 Base Performance Library which provides no service.\r
3\r
05570a7e 4 Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
19388d29 5 This program and the accompanying materials\r
e1f414b6 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
2fc59a00 8 http://opensource.org/licenses/bsd-license.php.\r
e1f414b6 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
e1f414b6 13**/\r
14\r
c892d846 15\r
c7d265a9 16#include <Base.h>\r
c892d846 17\r
18\r
c7d265a9 19#include <Library/PerformanceLib.h>\r
20#include <Library/DebugLib.h>\r
21#include <Library/PcdLib.h>\r
e1f414b6 22\r
23/**\r
24 Creates a record for the beginning of a performance measurement. \r
25 \r
26 Creates a record that contains the Handle, Token, and Module.\r
27 If TimeStamp is not zero, then TimeStamp is added to the record as the start time.\r
28 If TimeStamp is zero, then this function reads the current time stamp\r
29 and adds that time stamp value to the record as the start time.\r
30\r
2fc59a00 31 @param Handle The pointer to environment specific context used\r
e1f414b6 32 to identify the component being measured.\r
2fc59a00 33 @param Token The pointer to a Null-terminated ASCII string\r
e1f414b6 34 that identifies the component being measured.\r
2fc59a00 35 @param Module The pointer to a Null-terminated ASCII string\r
e1f414b6 36 that identifies the module being measured.\r
37 @param TimeStamp 64-bit time stamp.\r
38\r
39 @retval RETURN_SUCCESS The start of the measurement was recorded.\r
40 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r
8404146c 41 @retval RETURN_DEVICE_ERROR A device error reading the time stamp.\r
e1f414b6 42\r
43**/\r
44RETURN_STATUS\r
45EFIAPI\r
46StartPerformanceMeasurement (\r
efb23117 47 IN CONST VOID *Handle, OPTIONAL\r
48 IN CONST CHAR8 *Token, OPTIONAL\r
49 IN CONST CHAR8 *Module, OPTIONAL\r
e1f414b6 50 IN UINT64 TimeStamp\r
51 )\r
52{\r
53 return RETURN_SUCCESS;\r
54}\r
55\r
56/**\r
57 Fills in the end time of a performance measurement. \r
58 \r
59 Looks up the record that matches Handle, Token, and Module.\r
60 If the record can not be found then return RETURN_NOT_FOUND.\r
61 If the record is found and TimeStamp is not zero,\r
62 then TimeStamp is added to the record as the end time.\r
63 If the record is found and TimeStamp is zero, then this function reads\r
64 the current time stamp and adds that time stamp value to the record as the end time.\r
e1f414b6 65\r
2fc59a00 66 @param Handle The pointer to environment specific context used\r
e1f414b6 67 to identify the component being measured.\r
2fc59a00 68 @param Token The pointer to a Null-terminated ASCII string\r
e1f414b6 69 that identifies the component being measured.\r
2fc59a00 70 @param Module The pointer to a Null-terminated ASCII string\r
e1f414b6 71 that identifies the module being measured.\r
72 @param TimeStamp 64-bit time stamp.\r
73\r
2fc59a00 74 @retval RETURN_SUCCESS The end of the measurement was recorded.\r
e1f414b6 75 @retval RETURN_NOT_FOUND The specified measurement record could not be found.\r
8404146c 76 @retval RETURN_DEVICE_ERROR A device error reading the time stamp.\r
e1f414b6 77\r
78**/\r
79RETURN_STATUS\r
80EFIAPI\r
81EndPerformanceMeasurement (\r
82 IN CONST VOID *Handle, OPTIONAL\r
41083587 83 IN CONST CHAR8 *Token, OPTIONAL\r
84 IN CONST CHAR8 *Module, OPTIONAL\r
e1f414b6 85 IN UINT64 TimeStamp\r
86 )\r
87{\r
88 return RETURN_SUCCESS;\r
89}\r
90\r
91/**\r
92 Attempts to retrieve a performance measurement log entry from the performance measurement log. \r
ba14539c
SZ
93 It can also retrieve the log created by StartPerformanceMeasurementEx and EndPerformanceMeasurementEx,\r
94 and then eliminate the Identifier.\r
95\r
e1f414b6 96 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is\r
97 zero on entry, then an attempt is made to retrieve the first entry from the performance log,\r
98 and the key for the second entry in the log is returned. If the performance log is empty,\r
99 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance\r
100 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is\r
101 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is\r
102 retrieved and an implementation specific non-zero key value that specifies the end of the performance\r
103 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry\r
104 is retrieved and zero is returned. In the cases where a performance log entry can be returned,\r
105 the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.\r
106 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().\r
107 If Handle is NULL, then ASSERT().\r
108 If Token is NULL, then ASSERT().\r
109 If Module is NULL, then ASSERT().\r
110 If StartTimeStamp is NULL, then ASSERT().\r
111 If EndTimeStamp is NULL, then ASSERT().\r
112\r
113 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.\r
114 0, then the first performance measurement log entry is retrieved.\r
115 On exit, the key of the next performance lof entry entry.\r
2fc59a00 116 @param Handle The pointer to environment specific context used to identify the component\r
e1f414b6 117 being measured. \r
2fc59a00 118 @param Token The pointer to a Null-terminated ASCII string that identifies the component\r
e1f414b6 119 being measured. \r
2fc59a00 120 @param Module The pointer to a Null-terminated ASCII string that identifies the module\r
e1f414b6 121 being measured.\r
2fc59a00 122 @param StartTimeStamp The pointer to the 64-bit time stamp that was recorded when the measurement\r
e1f414b6 123 was started.\r
2fc59a00 124 @param EndTimeStamp The pointer to the 64-bit time stamp that was recorded when the measurement\r
e1f414b6 125 was ended.\r
126\r
127 @return The key for the next performance log entry (in general case).\r
128\r
129**/\r
130UINTN\r
131EFIAPI\r
132GetPerformanceMeasurement (\r
133 IN UINTN LogEntryKey, \r
134 OUT CONST VOID **Handle,\r
135 OUT CONST CHAR8 **Token,\r
136 OUT CONST CHAR8 **Module,\r
137 OUT UINT64 *StartTimeStamp,\r
138 OUT UINT64 *EndTimeStamp\r
139 )\r
140{\r
141 ASSERT (Handle != NULL);\r
142 ASSERT (Token != NULL);\r
143 ASSERT (Module != NULL);\r
144 ASSERT (StartTimeStamp != NULL);\r
145 ASSERT (EndTimeStamp != NULL);\r
146\r
147 return 0;\r
148}\r
149\r
ba14539c
SZ
150/**\r
151 Creates a record for the beginning of a performance measurement.\r
152\r
153 Creates a record that contains the Handle, Token, Module and Identifier.\r
154 If TimeStamp is not zero, then TimeStamp is added to the record as the start time.\r
155 If TimeStamp is zero, then this function reads the current time stamp\r
156 and adds that time stamp value to the record as the start time.\r
157\r
158 @param Handle Pointer to environment specific context used\r
159 to identify the component being measured.\r
160 @param Token Pointer to a Null-terminated ASCII string\r
161 that identifies the component being measured.\r
162 @param Module Pointer to a Null-terminated ASCII string\r
163 that identifies the module being measured.\r
164 @param TimeStamp 64-bit time stamp.\r
165 @param Identifier 32-bit identifier. If the value is 0, the created record\r
166 is same as the one created by StartPerformanceMeasurement.\r
167\r
168 @retval RETURN_SUCCESS The start of the measurement was recorded.\r
169 @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r
170 @retval RETURN_DEVICE_ERROR A device error reading the time stamp.\r
171\r
172**/\r
173RETURN_STATUS\r
174EFIAPI\r
175StartPerformanceMeasurementEx (\r
176 IN CONST VOID *Handle, OPTIONAL\r
177 IN CONST CHAR8 *Token, OPTIONAL\r
178 IN CONST CHAR8 *Module, OPTIONAL\r
179 IN UINT64 TimeStamp,\r
180 IN UINT32 Identifier\r
181 )\r
182{\r
183 return RETURN_SUCCESS;\r
184}\r
185\r
186/**\r
187 Fills in the end time of a performance measurement.\r
188\r
189 Looks up the record that matches Handle, Token, Module and Identifier.\r
190 If the record can not be found then return RETURN_NOT_FOUND.\r
191 If the record is found and TimeStamp is not zero,\r
192 then TimeStamp is added to the record as the end time.\r
193 If the record is found and TimeStamp is zero, then this function reads\r
194 the current time stamp and adds that time stamp value to the record as the end time.\r
195\r
196 @param Handle Pointer to environment specific context used\r
197 to identify the component being measured.\r
198 @param Token Pointer to a Null-terminated ASCII string\r
199 that identifies the component being measured.\r
200 @param Module Pointer to a Null-terminated ASCII string\r
201 that identifies the module being measured.\r
202 @param TimeStamp 64-bit time stamp.\r
203 @param Identifier 32-bit identifier. If the value is 0, the found record\r
204 is same as the one found by EndPerformanceMeasurement.\r
205\r
206 @retval RETURN_SUCCESS The end of the measurement was recorded.\r
207 @retval RETURN_NOT_FOUND The specified measurement record could not be found.\r
208 @retval RETURN_DEVICE_ERROR A device error reading the time stamp.\r
209\r
210**/\r
211RETURN_STATUS\r
212EFIAPI\r
213EndPerformanceMeasurementEx (\r
214 IN CONST VOID *Handle, OPTIONAL\r
215 IN CONST CHAR8 *Token, OPTIONAL\r
216 IN CONST CHAR8 *Module, OPTIONAL\r
217 IN UINT64 TimeStamp,\r
218 IN UINT32 Identifier\r
219 )\r
220{\r
221 return RETURN_SUCCESS;\r
222}\r
223\r
224/**\r
225 Attempts to retrieve a performance measurement log entry from the performance measurement log.\r
226 It can also retrieve the log created by StartPerformanceMeasurement and EndPerformanceMeasurement,\r
227 and then assign the Identifier with 0.\r
228\r
229 Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is\r
230 zero on entry, then an attempt is made to retrieve the first entry from the performance log,\r
231 and the key for the second entry in the log is returned. If the performance log is empty,\r
232 then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance\r
233 log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is\r
234 returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is\r
235 retrieved and an implementation specific non-zero key value that specifies the end of the performance\r
236 log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry\r
237 is retrieved and zero is returned. In the cases where a performance log entry can be returned,\r
238 the log entry is returned in Handle, Token, Module, StartTimeStamp, EndTimeStamp and Identifier.\r
239 If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().\r
240 If Handle is NULL, then ASSERT().\r
241 If Token is NULL, then ASSERT().\r
242 If Module is NULL, then ASSERT().\r
243 If StartTimeStamp is NULL, then ASSERT().\r
244 If EndTimeStamp is NULL, then ASSERT().\r
245 If Identifier is NULL, then ASSERT().\r
246\r
247 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.\r
248 0, then the first performance measurement log entry is retrieved.\r
249 On exit, the key of the next performance lof entry entry.\r
250 @param Handle Pointer to environment specific context used to identify the component\r
251 being measured.\r
252 @param Token Pointer to a Null-terminated ASCII string that identifies the component\r
253 being measured.\r
254 @param Module Pointer to a Null-terminated ASCII string that identifies the module\r
255 being measured.\r
256 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r
257 was started.\r
258 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r
259 was ended.\r
260 @param Identifier Pointer to the 32-bit identifier that was recorded.\r
261\r
262 @return The key for the next performance log entry (in general case).\r
263\r
264**/\r
265UINTN\r
266EFIAPI\r
267GetPerformanceMeasurementEx (\r
268 IN UINTN LogEntryKey, \r
269 OUT CONST VOID **Handle,\r
270 OUT CONST CHAR8 **Token,\r
271 OUT CONST CHAR8 **Module,\r
272 OUT UINT64 *StartTimeStamp,\r
273 OUT UINT64 *EndTimeStamp,\r
274 OUT UINT32 *Identifier\r
275 )\r
276{\r
277 ASSERT (Handle != NULL);\r
278 ASSERT (Token != NULL);\r
279 ASSERT (Module != NULL);\r
280 ASSERT (StartTimeStamp != NULL);\r
281 ASSERT (EndTimeStamp != NULL);\r
282 ASSERT (Identifier != NULL);\r
283\r
284 return 0;\r
285}\r
286\r
e1f414b6 287/**\r
288 Returns TRUE if the performance measurement macros are enabled. \r
289 \r
290 This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
291 PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.\r
292\r
293 @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
294 PcdPerformanceLibraryPropertyMask is set.\r
295 @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r
296 PcdPerformanceLibraryPropertyMask is clear.\r
297\r
298**/\r
299BOOLEAN\r
300EFIAPI\r
301PerformanceMeasurementEnabled (\r
302 VOID\r
303 )\r
304{\r
305 return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);\r
306}\r