]>
Commit | Line | Data |
---|---|---|
fb3df220 | 1 | /** @file\r |
50a64e5b | 2 | Provides services to log the execution times and retrieve them later.\r |
fb3df220 | 3 | \r |
2c5b667e | 4 | Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r |
9df063a0 | 5 | This program and the accompanying materials\r |
50a64e5b | 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 | |
fb3df220 | 9 | \r |
50a64e5b | 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 | |
fb3df220 | 12 | \r |
fb3df220 | 13 | **/\r |
14 | \r | |
15 | #ifndef __PERFORMANCE_LIB_H__\r | |
16 | #define __PERFORMANCE_LIB_H__\r | |
17 | \r | |
fc30687f | 18 | ///\r |
19 | /// Performance library propery mask bits\r | |
20 | ///\r | |
fb3df220 | 21 | #define PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED 0x00000001\r |
22 | \r | |
2c5b667e BD |
23 | //\r |
24 | // Public Progress Identifiers for Event Records.\r | |
25 | //\r | |
26 | #define PERF_EVENT_ID 0x00\r | |
27 | \r | |
28 | #define MODULE_START_ID 0x01\r | |
29 | #define MODULE_END_ID 0x02\r | |
30 | #define MODULE_LOADIMAGE_START_ID 0x03\r | |
31 | #define MODULE_LOADIMAGE_END_ID 0x04\r | |
32 | #define MODULE_DB_START_ID 0x05\r | |
33 | #define MODULE_DB_END_ID 0x06\r | |
34 | #define MODULE_DB_SUPPORT_START_ID 0x07\r | |
35 | #define MODULE_DB_SUPPORT_END_ID 0x08\r | |
36 | #define MODULE_DB_STOP_START_ID 0x09\r | |
37 | #define MODULE_DB_STOP_END_ID 0x0A\r | |
38 | \r | |
39 | #define PERF_EVENTSIGNAL_START_ID 0x10\r | |
40 | #define PERF_EVENTSIGNAL_END_ID 0x11\r | |
41 | #define PERF_CALLBACK_START_ID 0x20\r | |
42 | #define PERF_CALLBACK_END_ID 0x21\r | |
43 | #define PERF_FUNCTION_START_ID 0x30\r | |
44 | #define PERF_FUNCTION_END_ID 0x31\r | |
45 | #define PERF_INMODULE_START_ID 0x40\r | |
46 | #define PERF_INMODULE_END_ID 0x41\r | |
47 | #define PERF_CROSSMODULE_START_ID 0x50\r | |
48 | #define PERF_CROSSMODULE_END_ID 0x51\r | |
49 | \r | |
50 | //\r | |
51 | // Declare bits for PcdPerformanceLibraryPropertyMask and\r | |
52 | // also used as the Type parameter of LogPerformanceMeasurementEnabled().\r | |
53 | //\r | |
54 | #define PERF_CORE_START_IMAGE 0x0002\r | |
55 | #define PERF_CORE_LOAD_IMAGE 0x0004\r | |
56 | #define PERF_CORE_DB_SUPPORT 0x0008\r | |
57 | #define PERF_CORE_DB_START 0x0010\r | |
58 | #define PERF_CORE_DB_STOP 0x0020\r | |
59 | \r | |
60 | #define PERF_GENERAL_TYPE 0x0040\r | |
61 | \r | |
fb3df220 | 62 | /**\r |
9095d37b LG |
63 | Creates a record for the beginning of a performance measurement.\r |
64 | \r | |
fb3df220 | 65 | Creates a record that contains the Handle, Token, and Module.\r |
66 | If TimeStamp is not zero, then TimeStamp is added to the record as the start time.\r | |
67 | If TimeStamp is zero, then this function reads the current time stamp\r | |
68 | and adds that time stamp value to the record as the start time.\r | |
69 | \r | |
70 | @param Handle Pointer to environment specific context used\r | |
71 | to identify the component being measured.\r | |
72 | @param Token Pointer to a Null-terminated ASCII string\r | |
73 | that identifies the component being measured.\r | |
74 | @param Module Pointer to a Null-terminated ASCII string\r | |
75 | that identifies the module being measured.\r | |
76 | @param TimeStamp 64-bit time stamp.\r | |
77 | \r | |
78 | @retval RETURN_SUCCESS The start of the measurement was recorded.\r | |
79 | @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r | |
8404146c | 80 | @retval RETURN_DEVICE_ERROR A device error reading the time stamp.\r |
fb3df220 | 81 | \r |
82 | **/\r | |
83 | RETURN_STATUS\r | |
84 | EFIAPI\r | |
85 | StartPerformanceMeasurement (\r | |
86 | IN CONST VOID *Handle, OPTIONAL\r | |
87 | IN CONST CHAR8 *Token, OPTIONAL\r | |
88 | IN CONST CHAR8 *Module, OPTIONAL\r | |
89 | IN UINT64 TimeStamp\r | |
90 | );\r | |
91 | \r | |
92 | /**\r | |
9095d37b LG |
93 | Fills in the end time of a performance measurement.\r |
94 | \r | |
fb3df220 | 95 | Looks up the record that matches Handle, Token, and Module.\r |
96 | If the record can not be found then return RETURN_NOT_FOUND.\r | |
97 | If the record is found and TimeStamp is not zero,\r | |
98 | then TimeStamp is added to the record as the end time.\r | |
99 | If the record is found and TimeStamp is zero, then this function reads\r | |
100 | the current time stamp and adds that time stamp value to the record as the end time.\r | |
fb3df220 | 101 | \r |
102 | @param Handle Pointer to environment specific context used\r | |
103 | to identify the component being measured.\r | |
104 | @param Token Pointer to a Null-terminated ASCII string\r | |
105 | that identifies the component being measured.\r | |
106 | @param Module Pointer to a Null-terminated ASCII string\r | |
107 | that identifies the module being measured.\r | |
108 | @param TimeStamp 64-bit time stamp.\r | |
109 | \r | |
110 | @retval RETURN_SUCCESS The end of the measurement was recorded.\r | |
111 | @retval RETURN_NOT_FOUND The specified measurement record could not be found.\r | |
8404146c | 112 | @retval RETURN_DEVICE_ERROR A device error reading the time stamp.\r |
fb3df220 | 113 | \r |
114 | **/\r | |
115 | RETURN_STATUS\r | |
116 | EFIAPI\r | |
117 | EndPerformanceMeasurement (\r | |
118 | IN CONST VOID *Handle, OPTIONAL\r | |
119 | IN CONST CHAR8 *Token, OPTIONAL\r | |
120 | IN CONST CHAR8 *Module, OPTIONAL\r | |
121 | IN UINT64 TimeStamp\r | |
122 | );\r | |
123 | \r | |
124 | /**\r | |
9095d37b | 125 | Attempts to retrieve a performance measurement log entry from the performance measurement log.\r |
ba14539c SZ |
126 | It can also retrieve the log created by StartPerformanceMeasurementEx and EndPerformanceMeasurementEx,\r |
127 | and then eliminate the Identifier.\r | |
128 | \r | |
fb3df220 | 129 | Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is\r |
130 | zero on entry, then an attempt is made to retrieve the first entry from the performance log,\r | |
131 | and the key for the second entry in the log is returned. If the performance log is empty,\r | |
132 | then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance\r | |
133 | log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is\r | |
134 | returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is\r | |
135 | retrieved and an implementation specific non-zero key value that specifies the end of the performance\r | |
136 | log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry\r | |
137 | is retrieved and zero is returned. In the cases where a performance log entry can be returned,\r | |
138 | the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.\r | |
139 | If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().\r | |
140 | If Handle is NULL, then ASSERT().\r | |
141 | If Token is NULL, then ASSERT().\r | |
142 | If Module is NULL, then ASSERT().\r | |
143 | If StartTimeStamp is NULL, then ASSERT().\r | |
144 | If EndTimeStamp is NULL, then ASSERT().\r | |
145 | \r | |
146 | @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.\r | |
147 | 0, then the first performance measurement log entry is retrieved.\r | |
148 | On exit, the key of the next performance lof entry entry.\r | |
149 | @param Handle Pointer to environment specific context used to identify the component\r | |
9095d37b | 150 | being measured.\r |
fb3df220 | 151 | @param Token Pointer to a Null-terminated ASCII string that identifies the component\r |
9095d37b | 152 | being measured.\r |
fb3df220 | 153 | @param Module Pointer to a Null-terminated ASCII string that identifies the module\r |
154 | being measured.\r | |
155 | @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r | |
156 | was started.\r | |
157 | @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r | |
158 | was ended.\r | |
159 | \r | |
160 | @return The key for the next performance log entry (in general case).\r | |
161 | \r | |
162 | **/\r | |
163 | UINTN\r | |
164 | EFIAPI\r | |
165 | GetPerformanceMeasurement (\r | |
9095d37b | 166 | IN UINTN LogEntryKey,\r |
fb3df220 | 167 | OUT CONST VOID **Handle,\r |
168 | OUT CONST CHAR8 **Token,\r | |
169 | OUT CONST CHAR8 **Module,\r | |
170 | OUT UINT64 *StartTimeStamp,\r | |
171 | OUT UINT64 *EndTimeStamp\r | |
172 | );\r | |
173 | \r | |
ba14539c SZ |
174 | /**\r |
175 | Creates a record for the beginning of a performance measurement.\r | |
176 | \r | |
177 | Creates a record that contains the Handle, Token, Module and Identifier.\r | |
178 | If TimeStamp is not zero, then TimeStamp is added to the record as the start time.\r | |
179 | If TimeStamp is zero, then this function reads the current time stamp\r | |
180 | and adds that time stamp value to the record as the start time.\r | |
181 | \r | |
182 | @param Handle Pointer to environment specific context used\r | |
183 | to identify the component being measured.\r | |
184 | @param Token Pointer to a Null-terminated ASCII string\r | |
185 | that identifies the component being measured.\r | |
186 | @param Module Pointer to a Null-terminated ASCII string\r | |
187 | that identifies the module being measured.\r | |
188 | @param TimeStamp 64-bit time stamp.\r | |
189 | @param Identifier 32-bit identifier. If the value is 0, the created record\r | |
190 | is same as the one created by StartPerformanceMeasurement.\r | |
191 | \r | |
192 | @retval RETURN_SUCCESS The start of the measurement was recorded.\r | |
193 | @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.\r | |
194 | @retval RETURN_DEVICE_ERROR A device error reading the time stamp.\r | |
195 | \r | |
196 | **/\r | |
197 | RETURN_STATUS\r | |
198 | EFIAPI\r | |
199 | StartPerformanceMeasurementEx (\r | |
200 | IN CONST VOID *Handle, OPTIONAL\r | |
201 | IN CONST CHAR8 *Token, OPTIONAL\r | |
202 | IN CONST CHAR8 *Module, OPTIONAL\r | |
203 | IN UINT64 TimeStamp,\r | |
204 | IN UINT32 Identifier\r | |
205 | );\r | |
206 | \r | |
207 | /**\r | |
208 | Fills in the end time of a performance measurement.\r | |
209 | \r | |
ef8d4170 | 210 | Looks up the record that matches Handle, Token and Module.\r |
ba14539c SZ |
211 | If the record can not be found then return RETURN_NOT_FOUND.\r |
212 | If the record is found and TimeStamp is not zero,\r | |
213 | then TimeStamp is added to the record as the end time.\r | |
214 | If the record is found and TimeStamp is zero, then this function reads\r | |
215 | the current time stamp and adds that time stamp value to the record as the end time.\r | |
216 | \r | |
217 | @param Handle Pointer to environment specific context used\r | |
218 | to identify the component being measured.\r | |
219 | @param Token Pointer to a Null-terminated ASCII string\r | |
220 | that identifies the component being measured.\r | |
221 | @param Module Pointer to a Null-terminated ASCII string\r | |
222 | that identifies the module being measured.\r | |
223 | @param TimeStamp 64-bit time stamp.\r | |
224 | @param Identifier 32-bit identifier. If the value is 0, the found record\r | |
225 | is same as the one found by EndPerformanceMeasurement.\r | |
226 | \r | |
227 | @retval RETURN_SUCCESS The end of the measurement was recorded.\r | |
228 | @retval RETURN_NOT_FOUND The specified measurement record could not be found.\r | |
229 | @retval RETURN_DEVICE_ERROR A device error reading the time stamp.\r | |
230 | \r | |
231 | **/\r | |
232 | RETURN_STATUS\r | |
233 | EFIAPI\r | |
234 | EndPerformanceMeasurementEx (\r | |
235 | IN CONST VOID *Handle, OPTIONAL\r | |
236 | IN CONST CHAR8 *Token, OPTIONAL\r | |
237 | IN CONST CHAR8 *Module, OPTIONAL\r | |
238 | IN UINT64 TimeStamp,\r | |
239 | IN UINT32 Identifier\r | |
240 | );\r | |
241 | \r | |
242 | /**\r | |
243 | Attempts to retrieve a performance measurement log entry from the performance measurement log.\r | |
244 | It can also retrieve the log created by StartPerformanceMeasurement and EndPerformanceMeasurement,\r | |
245 | and then assign the Identifier with 0.\r | |
246 | \r | |
247 | Attempts to retrieve the performance log entry specified by LogEntryKey. If LogEntryKey is\r | |
248 | zero on entry, then an attempt is made to retrieve the first entry from the performance log,\r | |
249 | and the key for the second entry in the log is returned. If the performance log is empty,\r | |
250 | then no entry is retrieved and zero is returned. If LogEntryKey is not zero, then the performance\r | |
251 | log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is\r | |
252 | returned. If LogEntryKey is the key for the last entry in the log, then the last log entry is\r | |
253 | retrieved and an implementation specific non-zero key value that specifies the end of the performance\r | |
254 | log is returned. If LogEntryKey is equal this implementation specific non-zero key value, then no entry\r | |
255 | is retrieved and zero is returned. In the cases where a performance log entry can be returned,\r | |
256 | the log entry is returned in Handle, Token, Module, StartTimeStamp, EndTimeStamp and Identifier.\r | |
257 | If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().\r | |
258 | If Handle is NULL, then ASSERT().\r | |
259 | If Token is NULL, then ASSERT().\r | |
260 | If Module is NULL, then ASSERT().\r | |
261 | If StartTimeStamp is NULL, then ASSERT().\r | |
262 | If EndTimeStamp is NULL, then ASSERT().\r | |
263 | If Identifier is NULL, then ASSERT().\r | |
264 | \r | |
265 | @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.\r | |
266 | 0, then the first performance measurement log entry is retrieved.\r | |
267 | On exit, the key of the next performance of entry entry.\r | |
268 | @param Handle Pointer to environment specific context used to identify the component\r | |
269 | being measured.\r | |
270 | @param Token Pointer to a Null-terminated ASCII string that identifies the component\r | |
271 | being measured.\r | |
272 | @param Module Pointer to a Null-terminated ASCII string that identifies the module\r | |
273 | being measured.\r | |
274 | @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r | |
275 | was started.\r | |
276 | @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r | |
277 | was ended.\r | |
278 | @param Identifier Pointer to the 32-bit identifier that was recorded.\r | |
279 | \r | |
280 | @return The key for the next performance log entry (in general case).\r | |
281 | \r | |
282 | **/\r | |
283 | UINTN\r | |
284 | EFIAPI\r | |
285 | GetPerformanceMeasurementEx (\r | |
9095d37b | 286 | IN UINTN LogEntryKey,\r |
ba14539c SZ |
287 | OUT CONST VOID **Handle,\r |
288 | OUT CONST CHAR8 **Token,\r | |
289 | OUT CONST CHAR8 **Module,\r | |
290 | OUT UINT64 *StartTimeStamp,\r | |
291 | OUT UINT64 *EndTimeStamp,\r | |
292 | OUT UINT32 *Identifier\r | |
293 | );\r | |
294 | \r | |
fb3df220 | 295 | /**\r |
9095d37b LG |
296 | Returns TRUE if the performance measurement macros are enabled.\r |
297 | \r | |
fb3df220 | 298 | This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r |
299 | PcdPerformanceLibraryPropertyMask is set. Otherwise FALSE is returned.\r | |
300 | \r | |
301 | @retval TRUE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r | |
302 | PcdPerformanceLibraryPropertyMask is set.\r | |
303 | @retval FALSE The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of\r | |
304 | PcdPerformanceLibraryPropertyMask is clear.\r | |
305 | \r | |
306 | **/\r | |
307 | BOOLEAN\r | |
308 | EFIAPI\r | |
309 | PerformanceMeasurementEnabled (\r | |
310 | VOID\r | |
311 | );\r | |
312 | \r | |
2c5b667e BD |
313 | \r |
314 | /**\r | |
315 | Check whether the specified performance measurement can be logged.\r | |
316 | \r | |
317 | This function returns TRUE when the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set\r | |
318 | and the Type disable bit in PcdPerformanceLibraryPropertyMask is not set.\r | |
319 | \r | |
320 | @param Type - Type of the performance measurement entry.\r | |
321 | \r | |
322 | @retval TRUE The performance measurement can be logged.\r | |
323 | @retval FALSE The performance measurement can NOT be logged.\r | |
324 | \r | |
325 | **/\r | |
326 | BOOLEAN\r | |
327 | EFIAPI\r | |
328 | LogPerformanceMeasurementEnabled (\r | |
329 | IN CONST UINTN Type\r | |
330 | );\r | |
331 | \r | |
332 | /**\r | |
333 | Create performance record with event description.\r | |
334 | \r | |
335 | @param CallerIdentifier - Image handle or pointer to caller ID GUID\r | |
336 | @param Guid - Pointer to a GUID.\r | |
337 | Used for event signal perf and callback perf to cache the event guid.\r | |
338 | @param String - Pointer to a string describing the measurement\r | |
339 | @param Address - Pointer to a location in memory relevant to the measurement.\r | |
340 | @param Identifier - Performance identifier describing the type of measurement.\r | |
341 | \r | |
342 | @retval RETURN_SUCCESS - Successfully created performance record\r | |
343 | @retval RETURN_OUT_OF_RESOURCES - Ran out of space to store the records\r | |
344 | @retval RETURN_INVALID_PARAMETER - Invalid parameter passed to function - NULL\r | |
345 | pointer or invalid Identifier.\r | |
346 | \r | |
347 | **/\r | |
348 | RETURN_STATUS\r | |
349 | EFIAPI\r | |
350 | LogPerformanceMeasurement (\r | |
351 | IN CONST VOID *CallerIdentifier, OPTIONAL\r | |
352 | IN CONST VOID *Guid, OPTIONAL\r | |
353 | IN CONST CHAR8 *String, OPTIONAL\r | |
354 | IN UINT64 Address, OPTIONAL\r | |
355 | IN UINT32 Identifier\r | |
356 | );\r | |
357 | \r | |
358 | /**\r | |
359 | Begin Macro to measure the performance of StartImage in core.\r | |
360 | \r | |
361 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
362 | and the BIT1(dsiable PERF_CORE_START_IMAGE) of PcdPerformanceLibraryPropertyMask is not set.\r | |
363 | then LogPerformanceMeasurement() is called.\r | |
364 | \r | |
365 | **/\r | |
366 | #define PERF_START_IMAGE_BEGIN(ModuleHandle) \\r | |
367 | do { \\r | |
368 | if (LogPerformanceMeasurementEnabled (PERF_CORE_START_IMAGE)) { \\r | |
369 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_START_ID); \\r | |
370 | } \\r | |
371 | } while (FALSE)\r | |
372 | \r | |
373 | /**\r | |
374 | End Macro to measure the performance of StartImage in core.\r | |
375 | \r | |
376 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
377 | and the BIT1 (dsiable PERF_CORE_START_IMAGE)of PcdPerformanceLibraryPropertyMask is not set.\r | |
378 | then LogPerformanceMeasurement() is called.\r | |
379 | \r | |
380 | **/\r | |
381 | #define PERF_START_IMAGE_END(ModuleHandle) \\r | |
382 | do { \\r | |
383 | if (LogPerformanceMeasurementEnabled (PERF_CORE_START_IMAGE)) { \\r | |
384 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_END_ID); \\r | |
385 | } \\r | |
386 | } while (FALSE)\r | |
387 | \r | |
388 | /**\r | |
389 | Begin Macro to measure the performance of LoadImage in core.\r | |
390 | \r | |
391 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
392 | and the BIT2 (dsiable PERF_CORE_LOAD_IAMGE) of PcdPerformanceLibraryPropertyMask is not set.\r | |
393 | then LogPerformanceMeasurement() is called.\r | |
394 | \r | |
395 | **/\r | |
396 | #define PERF_LOAD_IMAGE_BEGIN(ModuleHandle) \\r | |
397 | do { \\r | |
398 | if (LogPerformanceMeasurementEnabled (PERF_CORE_LOAD_IMAGE)) { \\r | |
399 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_LOADIMAGE_START_ID); \\r | |
400 | } \\r | |
401 | } while (FALSE)\r | |
402 | \r | |
403 | /**\r | |
404 | End Macro to measure the performance of LoadImage in core.\r | |
405 | \r | |
406 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
407 | and the BIT2 (dsiable PERF_CORE_LOAD_IAMGE) of PcdPerformanceLibraryPropertyMask is not set.\r | |
408 | then LogPerformanceMeasurement() is called.\r | |
409 | \r | |
410 | **/\r | |
411 | #define PERF_LOAD_IMAGE_END(ModuleHandle) \\r | |
412 | do { \\r | |
413 | if (LogPerformanceMeasurementEnabled (PERF_CORE_LOAD_IMAGE)) { \\r | |
414 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_LOADIMAGE_END_ID); \\r | |
415 | } \\r | |
416 | } while (FALSE)\r | |
417 | \r | |
418 | /**\r | |
419 | Start Macro to measure the performance of DriverBinding Support in core.\r | |
420 | \r | |
421 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
422 | and the BIT3 (dsiable PERF_CORE_DB_SUPPORT) of PcdPerformanceLibraryPropertyMask is not set.\r | |
423 | then LogPerformanceMeasurement() is called.\r | |
424 | \r | |
425 | **/\r | |
426 | #define PERF_DRIVER_BINDING_SUPPORT_BEGIN(ModuleHandle, ControllerHandle) \\r | |
427 | do { \\r | |
428 | if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_SUPPORT)) { \\r | |
429 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_SUPPORT_START_ID); \\r | |
430 | } \\r | |
431 | } while (FALSE)\r | |
432 | \r | |
433 | /**\r | |
434 | End Macro to measure the performance of DriverBinding Support in core.\r | |
435 | \r | |
436 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
437 | and the BIT3 (dsiable PERF_CORE_DB_SUPPORT) of PcdPerformanceLibraryPropertyMask is not set.\r | |
438 | then LogPerformanceMeasurement() is called.\r | |
439 | \r | |
440 | **/\r | |
441 | #define PERF_DRIVER_BINDING_SUPPORT_END(ModuleHandle, ControllerHandle) \\r | |
442 | do { \\r | |
443 | if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_SUPPORT)) { \\r | |
444 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_SUPPORT_END_ID); \\r | |
445 | } \\r | |
446 | } while (FALSE)\r | |
447 | \r | |
448 | /**\r | |
449 | Begin Macro to measure the performance of DriverBinding Start in core.\r | |
450 | \r | |
451 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
452 | and the BIT4 (dsiable PERF_CORE_DB_START) of PcdPerformanceLibraryPropertyMask is not set.\r | |
453 | then LogPerformanceMeasurement() is called.\r | |
454 | \r | |
455 | **/\r | |
456 | #define PERF_DRIVER_BINDING_START_BEGIN(ModuleHandle, ControllerHandle) \\r | |
457 | do { \\r | |
458 | if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_START)) { \\r | |
459 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_START_ID); \\r | |
460 | } \\r | |
461 | } while (FALSE)\r | |
462 | \r | |
463 | /**\r | |
464 | End Macro to measure the performance of DriverBinding Start in core.\r | |
465 | \r | |
466 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
467 | and the BIT4 (dsiable PERF_CORE_DB_START) of PcdPerformanceLibraryPropertyMask is not set.\r | |
468 | then LogPerformanceMeasurement() is called.\r | |
469 | \r | |
470 | **/\r | |
471 | #define PERF_DRIVER_BINDING_START_END(ModuleHandle, ControllerHandle) \\r | |
472 | do { \\r | |
473 | if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_START)) { \\r | |
474 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_END_ID); \\r | |
475 | } \\r | |
476 | } while (FALSE)\r | |
477 | \r | |
478 | /**\r | |
479 | Start Macro to measure the performance of DriverBinding Stop in core.\r | |
480 | \r | |
481 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
482 | and the BIT5 (dsiable PERF_CORE_DB_STOP) of PcdPerformanceLibraryPropertyMask is not set.\r | |
483 | then LogPerformanceMeasurement() is called.\r | |
484 | \r | |
485 | **/\r | |
486 | #define PERF_DRIVER_BINDING_STOP_BEGIN(ModuleHandle, ControllerHandle) \\r | |
487 | do { \\r | |
488 | if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_STOP)) { \\r | |
489 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_STOP_START_ID); \\r | |
490 | } \\r | |
491 | } while (FALSE)\r | |
492 | \r | |
493 | /**\r | |
494 | End Macro to measure the performance of DriverBinding Stop in core.\r | |
495 | \r | |
496 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
497 | and the BIT5 (dsiable PERF_CORE_DB_STOP) of PcdPerformanceLibraryPropertyMask is not set.\r | |
498 | then LogPerformanceMeasurement() is called.\r | |
499 | \r | |
500 | **/\r | |
501 | #define PERF_DRIVER_BINDING_STOP_END(ModuleHandle, ControllerHandle) \\r | |
502 | do { \\r | |
503 | if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_STOP)) { \\r | |
504 | LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_STOP_END_ID); \\r | |
505 | } \\r | |
506 | } while (FALSE)\r | |
507 | \r | |
508 | /**\r | |
509 | Macro to measure the time from power-on to this macro execution.\r | |
510 | It can be used to log a meaningful thing which happens at a time point.\r | |
511 | \r | |
512 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
513 | and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r | |
514 | then LogPerformanceMeasurement() is called.\r | |
515 | \r | |
516 | **/\r | |
517 | #define PERF_EVENT(EventString) \\r | |
518 | do { \\r | |
519 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r | |
520 | LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, EventString , 0, PERF_EVENT_ID); \\r | |
521 | } \\r | |
522 | } while (FALSE)\r | |
523 | \r | |
524 | /**\r | |
525 | Begin Macro to measure the perofrmance of evnent signal behavior in any module.\r | |
526 | The event guid will be passed with this macro.\r | |
527 | \r | |
528 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
529 | and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r | |
530 | then LogPerformanceMeasurement() is called.\r | |
531 | \r | |
532 | **/\r | |
533 | #define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \\r | |
534 | do { \\r | |
535 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r | |
536 | LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_START_ID); \\r | |
537 | } \\r | |
538 | } while (FALSE)\r | |
539 | \r | |
540 | /**\r | |
541 | End Macro to measure the perofrmance of evnent signal behavior in any module.\r | |
542 | The event guid will be passed with this macro.\r | |
543 | \r | |
544 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
545 | and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r | |
546 | then LogPerformanceMeasurement() is called.\r | |
547 | \r | |
548 | **/\r | |
549 | #define PERF_EVENT_SIGNAL_END(EventGuid) \\r | |
550 | do { \\r | |
551 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r | |
552 | LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_END_ID); \\r | |
553 | } \\r | |
554 | } while (FALSE)\r | |
555 | \r | |
556 | /**\r | |
557 | Begin Macro to measure the perofrmance of a callback function in any module.\r | |
558 | The event guid which trigger the callback function will be passed with this macro.\r | |
559 | \r | |
560 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
561 | and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r | |
562 | then LogPerformanceMeasurement() is called.\r | |
563 | \r | |
564 | **/\r | |
565 | #define PERF_CALLBACK_BEGIN(TriggerGuid) \\r | |
566 | do { \\r | |
567 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r | |
568 | LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_START_ID); \\r | |
569 | } \\r | |
570 | } while (FALSE)\r | |
571 | \r | |
572 | /**\r | |
573 | End Macro to measure the perofrmance of a callback function in any module.\r | |
574 | The event guid which trigger the callback function will be passed with this macro.\r | |
575 | \r | |
576 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
577 | and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r | |
578 | then LogPerformanceMeasurement() is called.\r | |
579 | \r | |
580 | **/\r | |
581 | #define PERF_CALLBACK_END(TriggerGuid) \\r | |
582 | do { \\r | |
583 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r | |
584 | LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_END_ID); \\r | |
585 | } \\r | |
586 | } while (FALSE)\r | |
587 | \r | |
588 | /**\r | |
589 | Begin Macro to measure the perofrmance of a general function in any module.\r | |
590 | \r | |
591 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
592 | and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r | |
593 | then LogPerformanceMeasurement() is called.\r | |
594 | \r | |
595 | **/\r | |
596 | #define PERF_FUNCTION_BEGIN() \\r | |
597 | do { \\r | |
598 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r | |
599 | LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_START_ID); \\r | |
600 | } \\r | |
601 | } while (FALSE)\r | |
602 | \r | |
603 | /**\r | |
604 | End Macro to measure the perofrmance of a general function in any module.\r | |
605 | \r | |
606 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
607 | and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r | |
608 | then LogPerformanceMeasurement() is called.\r | |
609 | \r | |
610 | **/\r | |
611 | #define PERF_FUNCTION_END() \\r | |
612 | do { \\r | |
613 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r | |
614 | LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_END_ID); \\r | |
615 | } \\r | |
616 | } while (FALSE)\r | |
617 | \r | |
618 | /**\r | |
619 | Begin Macro to measure the perofrmance of a behavior within one module.\r | |
620 | \r | |
621 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
622 | and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r | |
623 | then LogPerformanceMeasurement() is called.\r | |
624 | \r | |
625 | **/\r | |
626 | #define PERF_INMODULE_BEGIN(MeasurementString) \\r | |
627 | do { \\r | |
628 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r | |
629 | LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_INMODULE_START_ID); \\r | |
630 | } \\r | |
631 | } while (FALSE)\r | |
632 | \r | |
633 | /**\r | |
634 | End Macro to measure the perofrmance of a behavior within one module.\r | |
635 | \r | |
636 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
637 | and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r | |
638 | then LogPerformanceMeasurement() is called.\r | |
639 | \r | |
640 | **/\r | |
641 | #define PERF_INMODULE_END(MeasurementString) \\r | |
642 | do { \\r | |
643 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r | |
644 | LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_INMODULE_END_ID); \\r | |
645 | } \\r | |
646 | } while (FALSE)\r | |
647 | \r | |
648 | /**\r | |
649 | Begin Macro to measure the perofrmance of a behavior in different modules.\r | |
650 | Such as the performance of PEI phase, DXE phase, BDS phase.\r | |
651 | \r | |
652 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
653 | and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r | |
654 | then LogPerformanceMeasurement() is called.\r | |
655 | \r | |
656 | **/\r | |
657 | #define PERF_CROSSMODULE_BEGIN(MeasurementString) \\r | |
658 | do { \\r | |
659 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r | |
660 | LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_CROSSMODULE_START_ID); \\r | |
661 | } \\r | |
662 | } while (FALSE)\r | |
663 | \r | |
664 | /**\r | |
665 | End Macro to measure the perofrmance of a behavior in different modules.\r | |
666 | Such as the performance of PEI phase, DXE phase, BDS phase.\r | |
667 | \r | |
668 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
669 | and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r | |
670 | then LogPerformanceMeasurement() is called.\r | |
671 | \r | |
672 | **/\r | |
673 | #define PERF_CROSSMODULE_END(MeasurementString) \\r | |
674 | do { \\r | |
675 | if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r | |
676 | LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_CROSSMODULE_END_ID); \\r | |
677 | } \\r | |
678 | } while (FALSE)\r | |
679 | \r | |
fb3df220 | 680 | /**\r |
681 | Macro that calls EndPerformanceMeasurement().\r | |
682 | \r | |
683 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
684 | then EndPerformanceMeasurement() is called.\r | |
685 | \r | |
686 | **/\r | |
687 | #define PERF_END(Handle, Token, Module, TimeStamp) \\r | |
688 | do { \\r | |
689 | if (PerformanceMeasurementEnabled ()) { \\r | |
690 | EndPerformanceMeasurement (Handle, Token, Module, TimeStamp); \\r | |
691 | } \\r | |
692 | } while (FALSE)\r | |
693 | \r | |
694 | /**\r | |
695 | Macro that calls StartPerformanceMeasurement().\r | |
696 | \r | |
697 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
698 | then StartPerformanceMeasurement() is called.\r | |
699 | \r | |
700 | **/\r | |
701 | #define PERF_START(Handle, Token, Module, TimeStamp) \\r | |
702 | do { \\r | |
703 | if (PerformanceMeasurementEnabled ()) { \\r | |
704 | StartPerformanceMeasurement (Handle, Token, Module, TimeStamp); \\r | |
705 | } \\r | |
706 | } while (FALSE)\r | |
707 | \r | |
ba14539c SZ |
708 | /**\r |
709 | Macro that calls EndPerformanceMeasurementEx().\r | |
710 | \r | |
711 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
712 | then EndPerformanceMeasurementEx() is called.\r | |
713 | \r | |
714 | **/\r | |
715 | #define PERF_END_EX(Handle, Token, Module, TimeStamp, Identifier) \\r | |
716 | do { \\r | |
717 | if (PerformanceMeasurementEnabled ()) { \\r | |
718 | EndPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, Identifier); \\r | |
719 | } \\r | |
720 | } while (FALSE)\r | |
721 | \r | |
722 | /**\r | |
723 | Macro that calls StartPerformanceMeasurementEx().\r | |
724 | \r | |
725 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
726 | then StartPerformanceMeasurementEx() is called.\r | |
727 | \r | |
728 | **/\r | |
729 | #define PERF_START_EX(Handle, Token, Module, TimeStamp, Identifier) \\r | |
730 | do { \\r | |
731 | if (PerformanceMeasurementEnabled ()) { \\r | |
732 | StartPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, Identifier); \\r | |
733 | } \\r | |
734 | } while (FALSE)\r | |
735 | \r | |
fb3df220 | 736 | /**\r |
737 | Macro that marks the beginning of performance measurement source code.\r | |
738 | \r | |
739 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
740 | then this macro marks the beginning of source code that is included in a module.\r | |
741 | Otherwise, the source lines between PERF_CODE_BEGIN() and PERF_CODE_END() are not included in a module.\r | |
742 | \r | |
743 | **/\r | |
744 | #define PERF_CODE_BEGIN() do { if (PerformanceMeasurementEnabled ()) { UINT8 __PerformanceCodeLocal\r | |
745 | \r | |
746 | /**\r | |
747 | Macro that marks the end of performance measurement source code.\r | |
748 | \r | |
749 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
750 | then this macro marks the end of source code that is included in a module.\r | |
751 | Otherwise, the source lines between PERF_CODE_BEGIN() and PERF_CODE_END() are not included in a module.\r | |
752 | \r | |
753 | **/\r | |
754 | #define PERF_CODE_END() __PerformanceCodeLocal = 0; __PerformanceCodeLocal++; } } while (FALSE)\r | |
755 | \r | |
756 | /**\r | |
757 | Macro that declares a section of performance measurement source code.\r | |
758 | \r | |
759 | If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r | |
760 | then the source code specified by Expression is included in a module.\r | |
761 | Otherwise, the source specified by Expression is not included in a module.\r | |
762 | \r | |
763 | @param Expression Performance measurement source code to include in a module.\r | |
764 | \r | |
765 | **/\r | |
766 | #define PERF_CODE(Expression) \\r | |
767 | PERF_CODE_BEGIN (); \\r | |
768 | Expression \\r | |
769 | PERF_CODE_END ()\r | |
770 | \r | |
771 | \r | |
772 | #endif\r |