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