]>
Commit | Line | Data |
---|---|---|
e1f414b6 | 1 | /** @file\r |
2 | Base Performance Library which provides no service.\r | |
3 | \r | |
2c5b667e | 4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
9344f092 | 5 | SPDX-License-Identifier: BSD-2-Clause-Patent\r |
e1f414b6 | 6 | \r |
e1f414b6 | 7 | **/\r |
8 | \r | |
c7d265a9 | 9 | #include <Base.h>\r |
c892d846 | 10 | \r |
c7d265a9 | 11 | #include <Library/PerformanceLib.h>\r |
12 | #include <Library/DebugLib.h>\r | |
13 | #include <Library/PcdLib.h>\r | |
e1f414b6 | 14 | \r |
15 | /**\r | |
9095d37b LG |
16 | Creates a record for the beginning of a performance measurement.\r |
17 | \r | |
e1f414b6 | 18 | Creates a record that contains the Handle, Token, and Module.\r |
19 | If TimeStamp is not zero, then TimeStamp is added to the record as the start time.\r | |
20 | If TimeStamp is zero, then this function reads the current time stamp\r | |
21 | and adds that time stamp value to the record as the start time.\r | |
22 | \r | |
2fc59a00 | 23 | @param Handle The pointer to environment specific context used\r |
e1f414b6 | 24 | to identify the component being measured.\r |
2fc59a00 | 25 | @param Token The pointer to a Null-terminated ASCII string\r |
e1f414b6 | 26 | that identifies the component being measured.\r |
2fc59a00 | 27 | @param Module The pointer to a Null-terminated ASCII string\r |
e1f414b6 | 28 | that identifies the module being measured.\r |
29 | @param TimeStamp 64-bit time stamp.\r | |
30 | \r | |
31 | @retval RETURN_SUCCESS The start of the measurement was recorded.\r | |
32 | @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r | |
8404146c | 33 | @retval RETURN_DEVICE_ERROR A device error reading the time stamp.\r |
e1f414b6 | 34 | \r |
35 | **/\r | |
36 | RETURN_STATUS\r | |
37 | EFIAPI\r | |
38 | StartPerformanceMeasurement (\r | |
d0e2f823 MK |
39 | IN CONST VOID *Handle OPTIONAL,\r |
40 | IN CONST CHAR8 *Token OPTIONAL,\r | |
41 | IN CONST CHAR8 *Module OPTIONAL,\r | |
e1f414b6 | 42 | IN UINT64 TimeStamp\r |
43 | )\r | |
44 | {\r | |
45 | return RETURN_SUCCESS;\r | |
46 | }\r | |
47 | \r | |
48 | /**\r | |
9095d37b LG |
49 | Fills in the end time of a performance measurement.\r |
50 | \r | |
e1f414b6 | 51 | Looks up the record that matches Handle, Token, and Module.\r |
52 | If the record can not be found then return RETURN_NOT_FOUND.\r | |
53 | If the record is found and TimeStamp is not zero,\r | |
54 | then TimeStamp is added to the record as the end time.\r | |
55 | If the record is found and TimeStamp is zero, then this function reads\r | |
56 | the current time stamp and adds that time stamp value to the record as the end time.\r | |
e1f414b6 | 57 | \r |
2fc59a00 | 58 | @param Handle The pointer to environment specific context used\r |
e1f414b6 | 59 | to identify the component being measured.\r |
2fc59a00 | 60 | @param Token The pointer to a Null-terminated ASCII string\r |
e1f414b6 | 61 | that identifies the component being measured.\r |
2fc59a00 | 62 | @param Module The pointer to a Null-terminated ASCII string\r |
e1f414b6 | 63 | that identifies the module being measured.\r |
64 | @param TimeStamp 64-bit time stamp.\r | |
65 | \r | |
2fc59a00 | 66 | @retval RETURN_SUCCESS The end of the measurement was recorded.\r |
e1f414b6 | 67 | @retval RETURN_NOT_FOUND The specified measurement record could not be found.\r |
8404146c | 68 | @retval RETURN_DEVICE_ERROR A device error reading the time stamp.\r |
e1f414b6 | 69 | \r |
70 | **/\r | |
71 | RETURN_STATUS\r | |
72 | EFIAPI\r | |
73 | EndPerformanceMeasurement (\r | |
d0e2f823 MK |
74 | IN CONST VOID *Handle OPTIONAL,\r |
75 | IN CONST CHAR8 *Token OPTIONAL,\r | |
76 | IN CONST CHAR8 *Module OPTIONAL,\r | |
e1f414b6 | 77 | IN UINT64 TimeStamp\r |
78 | )\r | |
79 | {\r | |
80 | return RETURN_SUCCESS;\r | |
81 | }\r | |
82 | \r | |
83 | /**\r | |
9095d37b | 84 | Attempts to retrieve a performance measurement log entry from the performance measurement log.\r |
ba14539c SZ |
85 | It can also retrieve the log created by StartPerformanceMeasurementEx and EndPerformanceMeasurementEx,\r |
86 | and then eliminate the Identifier.\r | |
87 | \r | |
e1f414b6 | 88 | Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is\r |
89 | zero on entry, then an attempt is made to retrieve the first entry from the performance log,\r | |
90 | and the key for the second entry in the log is returned. If the performance log is empty,\r | |
91 | then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance\r | |
92 | log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is\r | |
93 | returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is\r | |
94 | retrieved and an implementation specific non-zero key value that specifies the end of the performance\r | |
95 | log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry\r | |
96 | is retrieved and zero is returned. In the cases where a performance log entry can be returned,\r | |
97 | the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.\r | |
98 | If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().\r | |
99 | If Handle is NULL, then ASSERT().\r | |
100 | If Token is NULL, then ASSERT().\r | |
101 | If Module is NULL, then ASSERT().\r | |
102 | If StartTimeStamp is NULL, then ASSERT().\r | |
103 | If EndTimeStamp is NULL, then ASSERT().\r | |
104 | \r | |
105 | @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.\r | |
106 | 0, then the first performance measurement log entry is retrieved.\r | |
107 | On exit, the key of the next performance lof entry entry.\r | |
2fc59a00 | 108 | @param Handle The pointer to environment specific context used to identify the component\r |
9095d37b | 109 | being measured.\r |
2fc59a00 | 110 | @param Token The pointer to a Null-terminated ASCII string that identifies the component\r |
9095d37b | 111 | being measured.\r |
2fc59a00 | 112 | @param Module The pointer to a Null-terminated ASCII string that identifies the module\r |
e1f414b6 | 113 | being measured.\r |
2fc59a00 | 114 | @param StartTimeStamp The pointer to the 64-bit time stamp that was recorded when the measurement\r |
e1f414b6 | 115 | was started.\r |
2fc59a00 | 116 | @param EndTimeStamp The pointer to the 64-bit time stamp that was recorded when the measurement\r |
e1f414b6 | 117 | was ended.\r |
118 | \r | |
119 | @return The key for the next performance log entry (in general case).\r | |
120 | \r | |
121 | **/\r | |
122 | UINTN\r | |
123 | EFIAPI\r | |
124 | GetPerformanceMeasurement (\r | |
2f88bd3a MK |
125 | IN UINTN LogEntryKey,\r |
126 | OUT CONST VOID **Handle,\r | |
127 | OUT CONST CHAR8 **Token,\r | |
128 | OUT CONST CHAR8 **Module,\r | |
129 | OUT UINT64 *StartTimeStamp,\r | |
130 | OUT UINT64 *EndTimeStamp\r | |
e1f414b6 | 131 | )\r |
132 | {\r | |
133 | ASSERT (Handle != NULL);\r | |
134 | ASSERT (Token != NULL);\r | |
135 | ASSERT (Module != NULL);\r | |
136 | ASSERT (StartTimeStamp != NULL);\r | |
137 | ASSERT (EndTimeStamp != NULL);\r | |
138 | \r | |
139 | return 0;\r | |
140 | }\r | |
141 | \r | |
ba14539c SZ |
142 | /**\r |
143 | Creates a record for the beginning of a performance measurement.\r | |
144 | \r | |
145 | Creates a record that contains the Handle, Token, Module and Identifier.\r | |
146 | If TimeStamp is not zero, then TimeStamp is added to the record as the start time.\r | |
147 | If TimeStamp is zero, then this function reads the current time stamp\r | |
148 | and adds that time stamp value to the record as the start time.\r | |
149 | \r | |
150 | @param Handle Pointer to environment specific context used\r | |
151 | to identify the component being measured.\r | |
152 | @param Token Pointer to a Null-terminated ASCII string\r | |
153 | that identifies the component being measured.\r | |
154 | @param Module Pointer to a Null-terminated ASCII string\r | |
155 | that identifies the module being measured.\r | |
156 | @param TimeStamp 64-bit time stamp.\r | |
157 | @param Identifier 32-bit identifier. If the value is 0, the created record\r | |
158 | is same as the one created by StartPerformanceMeasurement.\r | |
159 | \r | |
160 | @retval RETURN_SUCCESS The start of the measurement was recorded.\r | |
161 | @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r | |
162 | @retval RETURN_DEVICE_ERROR A device error reading the time stamp.\r | |
163 | \r | |
164 | **/\r | |
165 | RETURN_STATUS\r | |
166 | EFIAPI\r | |
167 | StartPerformanceMeasurementEx (\r | |
d0e2f823 MK |
168 | IN CONST VOID *Handle OPTIONAL,\r |
169 | IN CONST CHAR8 *Token OPTIONAL,\r | |
170 | IN CONST CHAR8 *Module OPTIONAL,\r | |
ba14539c SZ |
171 | IN UINT64 TimeStamp,\r |
172 | IN UINT32 Identifier\r | |
173 | )\r | |
174 | {\r | |
175 | return RETURN_SUCCESS;\r | |
176 | }\r | |
177 | \r | |
178 | /**\r | |
179 | Fills in the end time of a performance measurement.\r | |
180 | \r | |
181 | Looks up the record that matches Handle, Token, Module and Identifier.\r | |
182 | If the record can not be found then return RETURN_NOT_FOUND.\r | |
183 | If the record is found and TimeStamp is not zero,\r | |
184 | then TimeStamp is added to the record as the end time.\r | |
185 | If the record is found and TimeStamp is zero, then this function reads\r | |
186 | the current time stamp and adds that time stamp value to the record as the end time.\r | |
187 | \r | |
188 | @param Handle Pointer to environment specific context used\r | |
189 | to identify the component being measured.\r | |
190 | @param Token Pointer to a Null-terminated ASCII string\r | |
191 | that identifies the component being measured.\r | |
192 | @param Module Pointer to a Null-terminated ASCII string\r | |
193 | that identifies the module being measured.\r | |
194 | @param TimeStamp 64-bit time stamp.\r | |
195 | @param Identifier 32-bit identifier. If the value is 0, the found record\r | |
196 | is same as the one found by EndPerformanceMeasurement.\r | |
197 | \r | |
198 | @retval RETURN_SUCCESS The end of the measurement was recorded.\r | |
199 | @retval RETURN_NOT_FOUND The specified measurement record could not be found.\r | |
200 | @retval RETURN_DEVICE_ERROR A device error reading the time stamp.\r | |
201 | \r | |
202 | **/\r | |
203 | RETURN_STATUS\r | |
204 | EFIAPI\r | |
205 | EndPerformanceMeasurementEx (\r | |
d0e2f823 MK |
206 | IN CONST VOID *Handle OPTIONAL,\r |
207 | IN CONST CHAR8 *Token OPTIONAL,\r | |
208 | IN CONST CHAR8 *Module OPTIONAL,\r | |
ba14539c SZ |
209 | IN UINT64 TimeStamp,\r |
210 | IN UINT32 Identifier\r | |
211 | )\r | |
212 | {\r | |
213 | return RETURN_SUCCESS;\r | |
214 | }\r | |
215 | \r | |
216 | /**\r | |
217 | Attempts to retrieve a performance measurement log entry from the performance measurement log.\r | |
218 | It can also retrieve the log created by StartPerformanceMeasurement and EndPerformanceMeasurement,\r | |
219 | and then assign the Identifier with 0.\r | |
220 | \r | |
221 | Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is\r | |
222 | zero on entry, then an attempt is made to retrieve the first entry from the performance log,\r | |
223 | and the key for the second entry in the log is returned. If the performance log is empty,\r | |
224 | then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance\r | |
225 | log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is\r | |
226 | returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is\r | |
227 | retrieved and an implementation specific non-zero key value that specifies the end of the performance\r | |
228 | log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry\r | |
229 | is retrieved and zero is returned. In the cases where a performance log entry can be returned,\r | |
230 | the log entry is returned in Handle, Token, Module, StartTimeStamp, EndTimeStamp and Identifier.\r | |
231 | If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().\r | |
232 | If Handle is NULL, then ASSERT().\r | |
233 | If Token is NULL, then ASSERT().\r | |
234 | If Module is NULL, then ASSERT().\r | |
235 | If StartTimeStamp is NULL, then ASSERT().\r | |
236 | If EndTimeStamp is NULL, then ASSERT().\r | |
237 | If Identifier is NULL, then ASSERT().\r | |
238 | \r | |
239 | @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.\r | |
240 | 0, then the first performance measurement log entry is retrieved.\r | |
241 | On exit, the key of the next performance lof entry entry.\r | |
242 | @param Handle Pointer to environment specific context used to identify the component\r | |
243 | being measured.\r | |
244 | @param Token Pointer to a Null-terminated ASCII string that identifies the component\r | |
245 | being measured.\r | |
246 | @param Module Pointer to a Null-terminated ASCII string that identifies the module\r | |
247 | being measured.\r | |
248 | @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r | |
249 | was started.\r | |
250 | @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r | |
251 | was ended.\r | |
252 | @param Identifier Pointer to the 32-bit identifier that was recorded.\r | |
253 | \r | |
254 | @return The key for the next performance log entry (in general case).\r | |
255 | \r | |
256 | **/\r | |
257 | UINTN\r | |
258 | EFIAPI\r | |
259 | GetPerformanceMeasurementEx (\r | |
2f88bd3a MK |
260 | IN UINTN LogEntryKey,\r |
261 | OUT CONST VOID **Handle,\r | |
262 | OUT CONST CHAR8 **Token,\r | |
263 | OUT CONST CHAR8 **Module,\r | |
264 | OUT UINT64 *StartTimeStamp,\r | |
265 | OUT UINT64 *EndTimeStamp,\r | |
266 | OUT UINT32 *Identifier\r | |
ba14539c SZ |
267 | )\r |
268 | {\r | |
269 | ASSERT (Handle != NULL);\r | |
270 | ASSERT (Token != NULL);\r | |
271 | ASSERT (Module != NULL);\r | |
272 | ASSERT (StartTimeStamp != NULL);\r | |
273 | ASSERT (EndTimeStamp != NULL);\r | |
274 | ASSERT (Identifier != NULL);\r | |
275 | \r | |
276 | return 0;\r | |
277 | }\r | |
278 | \r | |
e1f414b6 | 279 | /**\r |
9095d37b LG |
280 | Returns TRUE if the performance measurement macros are enabled.\r |
281 | \r | |
e1f414b6 | 282 | This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r |
283 | PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.\r | |
284 | \r | |
285 | @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r | |
286 | PcdPerformanceLibraryPropertyMask is set.\r | |
287 | @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r | |
288 | PcdPerformanceLibraryPropertyMask is clear.\r | |
289 | \r | |
290 | **/\r | |
291 | BOOLEAN\r | |
292 | EFIAPI\r | |
293 | PerformanceMeasurementEnabled (\r | |
294 | VOID\r | |
295 | )\r | |
296 | {\r | |
2f88bd3a | 297 | return (BOOLEAN)((PcdGet8 (PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);\r |
e1f414b6 | 298 | }\r |
2c5b667e BD |
299 | \r |
300 | /**\r | |
301 | Create performance record with event description and a timestamp.\r | |
302 | \r | |
303 | @param CallerIdentifier - Image handle or pointer to caller ID GUID\r | |
304 | @param Guid - Pointer to a GUID\r | |
305 | @param String - Pointer to a string describing the measurement\r | |
306 | @param Address - Pointer to a location in memory relevant to the measurement\r | |
307 | @param Identifier - Performance identifier describing the type of measurement\r | |
308 | \r | |
309 | @retval RETURN_SUCCESS - Successfully created performance record\r | |
310 | @retval RETURN_OUT_OF_RESOURCES - Ran out of space to store the records\r | |
311 | @retval RETURN_INVALID_PARAMETER - Invalid parameter passed to function - NULL\r | |
312 | pointer or invalid PerfId\r | |
313 | \r | |
314 | **/\r | |
315 | RETURN_STATUS\r | |
316 | EFIAPI\r | |
317 | LogPerformanceMeasurement (\r | |
d0e2f823 MK |
318 | IN CONST VOID *CallerIdentifier OPTIONAL,\r |
319 | IN CONST VOID *Guid OPTIONAL,\r | |
320 | IN CONST CHAR8 *String OPTIONAL,\r | |
321 | IN UINT64 Address OPTIONAL,\r | |
2c5b667e BD |
322 | IN UINT32 Identifier\r |
323 | )\r | |
324 | {\r | |
325 | return RETURN_SUCCESS;\r | |
326 | }\r | |
327 | \r | |
328 | /**\r | |
329 | Check whether the specified performance measurement can be logged.\r | |
330 | \r | |
331 | This function returns TRUE when the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set\r | |
332 | and the Type disable bit in PcdPerformanceLibraryPropertyMask is not set.\r | |
333 | \r | |
334 | @param Type - Type of the performance measurement entry.\r | |
335 | \r | |
336 | @retval TRUE The performance measurement can be logged.\r | |
337 | @retval FALSE The performance measurement can NOT be logged.\r | |
338 | \r | |
339 | **/\r | |
340 | BOOLEAN\r | |
341 | EFIAPI\r | |
342 | LogPerformanceMeasurementEnabled (\r | |
2f88bd3a | 343 | IN CONST UINTN Type\r |
2c5b667e BD |
344 | )\r |
345 | {\r | |
346 | //\r | |
347 | // When Performance measurement is enabled and the type is not filtered, the performance can be logged.\r | |
348 | //\r | |
2f88bd3a | 349 | if (PerformanceMeasurementEnabled () && ((PcdGet8 (PcdPerformanceLibraryPropertyMask) & Type) == 0)) {\r |
2c5b667e BD |
350 | return TRUE;\r |
351 | }\r | |
2f88bd3a | 352 | \r |
2c5b667e BD |
353 | return FALSE;\r |
354 | }\r |