TianoCore EDK2 master
Loading...
Searching...
No Matches
PerformanceLib.h
Go to the documentation of this file.
1
9#ifndef __PERFORMANCE_LIB_H__
10#define __PERFORMANCE_LIB_H__
11
15#define PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED 0x00000001
16
17//
18// Public Progress Identifiers for Event Records.
19//
20#define PERF_EVENT_ID 0x00
21
22#define MODULE_START_ID 0x01
23#define MODULE_END_ID 0x02
24#define MODULE_LOADIMAGE_START_ID 0x03
25#define MODULE_LOADIMAGE_END_ID 0x04
26#define MODULE_DB_START_ID 0x05
27#define MODULE_DB_END_ID 0x06
28#define MODULE_DB_SUPPORT_START_ID 0x07
29#define MODULE_DB_SUPPORT_END_ID 0x08
30#define MODULE_DB_STOP_START_ID 0x09
31#define MODULE_DB_STOP_END_ID 0x0A
32
33#define PERF_EVENTSIGNAL_START_ID 0x10
34#define PERF_EVENTSIGNAL_END_ID 0x11
35#define PERF_CALLBACK_START_ID 0x20
36#define PERF_CALLBACK_END_ID 0x21
37#define PERF_FUNCTION_START_ID 0x30
38#define PERF_FUNCTION_END_ID 0x31
39#define PERF_INMODULE_START_ID 0x40
40#define PERF_INMODULE_END_ID 0x41
41#define PERF_CROSSMODULE_START_ID 0x50
42#define PERF_CROSSMODULE_END_ID 0x51
43
44//
45// Declare bits for PcdPerformanceLibraryPropertyMask and
46// also used as the Type parameter of LogPerformanceMeasurementEnabled().
47//
48#define PERF_CORE_START_IMAGE 0x0002
49#define PERF_CORE_LOAD_IMAGE 0x0004
50#define PERF_CORE_DB_SUPPORT 0x0008
51#define PERF_CORE_DB_START 0x0010
52#define PERF_CORE_DB_STOP 0x0020
53
54#define PERF_GENERAL_TYPE 0x0040
55
77RETURN_STATUS
78EFIAPI
80 IN CONST VOID *Handle OPTIONAL,
81 IN CONST CHAR8 *Token OPTIONAL,
82 IN CONST CHAR8 *Module OPTIONAL,
83 IN UINT64 TimeStamp
84 );
85
109RETURN_STATUS
110EFIAPI
112 IN CONST VOID *Handle OPTIONAL,
113 IN CONST CHAR8 *Token OPTIONAL,
114 IN CONST CHAR8 *Module OPTIONAL,
115 IN UINT64 TimeStamp
116 );
117
157UINTN
158EFIAPI
160 IN UINTN LogEntryKey,
161 OUT CONST VOID **Handle,
162 OUT CONST CHAR8 **Token,
163 OUT CONST CHAR8 **Module,
164 OUT UINT64 *StartTimeStamp,
165 OUT UINT64 *EndTimeStamp
166 );
167
191RETURN_STATUS
192EFIAPI
194 IN CONST VOID *Handle OPTIONAL,
195 IN CONST CHAR8 *Token OPTIONAL,
196 IN CONST CHAR8 *Module OPTIONAL,
197 IN UINT64 TimeStamp,
198 IN UINT32 Identifier
199 );
200
226RETURN_STATUS
227EFIAPI
229 IN CONST VOID *Handle OPTIONAL,
230 IN CONST CHAR8 *Token OPTIONAL,
231 IN CONST CHAR8 *Module OPTIONAL,
232 IN UINT64 TimeStamp,
233 IN UINT32 Identifier
234 );
235
277UINTN
278EFIAPI
280 IN UINTN LogEntryKey,
281 OUT CONST VOID **Handle,
282 OUT CONST CHAR8 **Token,
283 OUT CONST CHAR8 **Module,
284 OUT UINT64 *StartTimeStamp,
285 OUT UINT64 *EndTimeStamp,
286 OUT UINT32 *Identifier
287 );
288
301BOOLEAN
302EFIAPI
304 VOID
305 );
306
319BOOLEAN
320EFIAPI
322 IN CONST UINTN Type
323 );
324
341RETURN_STATUS
342EFIAPI
344 IN CONST VOID *CallerIdentifier OPTIONAL,
345 IN CONST VOID *Guid OPTIONAL,
346 IN CONST CHAR8 *String OPTIONAL,
347 IN UINT64 Address OPTIONAL,
348 IN UINT32 Identifier
349 );
350
359#define PERF_START_IMAGE_BEGIN(ModuleHandle) \
360 do { \
361 if (LogPerformanceMeasurementEnabled (PERF_CORE_START_IMAGE)) { \
362 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_START_ID); \
363 } \
364 } while (FALSE)
365
374#define PERF_START_IMAGE_END(ModuleHandle) \
375 do { \
376 if (LogPerformanceMeasurementEnabled (PERF_CORE_START_IMAGE)) { \
377 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_END_ID); \
378 } \
379 } while (FALSE)
380
389#define PERF_LOAD_IMAGE_BEGIN(ModuleHandle) \
390 do { \
391 if (LogPerformanceMeasurementEnabled (PERF_CORE_LOAD_IMAGE)) { \
392 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_LOADIMAGE_START_ID); \
393 } \
394 } while (FALSE)
395
404#define PERF_LOAD_IMAGE_END(ModuleHandle) \
405 do { \
406 if (LogPerformanceMeasurementEnabled (PERF_CORE_LOAD_IMAGE)) { \
407 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_LOADIMAGE_END_ID); \
408 } \
409 } while (FALSE)
410
419#define PERF_DRIVER_BINDING_SUPPORT_BEGIN(ModuleHandle, ControllerHandle) \
420 do { \
421 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_SUPPORT)) { \
422 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_SUPPORT_START_ID); \
423 } \
424 } while (FALSE)
425
434#define PERF_DRIVER_BINDING_SUPPORT_END(ModuleHandle, ControllerHandle) \
435 do { \
436 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_SUPPORT)) { \
437 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_SUPPORT_END_ID); \
438 } \
439 } while (FALSE)
440
449#define PERF_DRIVER_BINDING_START_BEGIN(ModuleHandle, ControllerHandle) \
450 do { \
451 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_START)) { \
452 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_START_ID); \
453 } \
454 } while (FALSE)
455
464#define PERF_DRIVER_BINDING_START_END(ModuleHandle, ControllerHandle) \
465 do { \
466 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_START)) { \
467 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_END_ID); \
468 } \
469 } while (FALSE)
470
479#define PERF_DRIVER_BINDING_STOP_BEGIN(ModuleHandle, ControllerHandle) \
480 do { \
481 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_STOP)) { \
482 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_STOP_START_ID); \
483 } \
484 } while (FALSE)
485
494#define PERF_DRIVER_BINDING_STOP_END(ModuleHandle, ControllerHandle) \
495 do { \
496 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_STOP)) { \
497 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_STOP_END_ID); \
498 } \
499 } while (FALSE)
500
510#define PERF_EVENT(EventString) \
511 do { \
512 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
513 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, EventString , 0, PERF_EVENT_ID); \
514 } \
515 } while (FALSE)
516
526#define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \
527 do { \
528 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
529 LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_START_ID); \
530 } \
531 } while (FALSE)
532
542#define PERF_EVENT_SIGNAL_END(EventGuid) \
543 do { \
544 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
545 LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_END_ID); \
546 } \
547 } while (FALSE)
548
558#define PERF_CALLBACK_BEGIN(TriggerGuid) \
559 do { \
560 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
561 LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_START_ID); \
562 } \
563 } while (FALSE)
564
574#define PERF_CALLBACK_END(TriggerGuid) \
575 do { \
576 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
577 LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_END_ID); \
578 } \
579 } while (FALSE)
580
589#define PERF_FUNCTION_BEGIN() \
590 do { \
591 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
592 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_START_ID); \
593 } \
594 } while (FALSE)
595
604#define PERF_FUNCTION_END() \
605 do { \
606 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
607 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_END_ID); \
608 } \
609 } while (FALSE)
610
619#define PERF_INMODULE_BEGIN(MeasurementString) \
620 do { \
621 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
622 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_INMODULE_START_ID); \
623 } \
624 } while (FALSE)
625
634#define PERF_INMODULE_END(MeasurementString) \
635 do { \
636 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
637 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_INMODULE_END_ID); \
638 } \
639 } while (FALSE)
640
650#define PERF_CROSSMODULE_BEGIN(MeasurementString) \
651 do { \
652 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
653 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_CROSSMODULE_START_ID); \
654 } \
655 } while (FALSE)
656
666#define PERF_CROSSMODULE_END(MeasurementString) \
667 do { \
668 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
669 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_CROSSMODULE_END_ID); \
670 } \
671 } while (FALSE)
672
680#define PERF_END(Handle, Token, Module, TimeStamp) \
681 do { \
682 if (PerformanceMeasurementEnabled ()) { \
683 EndPerformanceMeasurement (Handle, Token, Module, TimeStamp); \
684 } \
685 } while (FALSE)
686
694#define PERF_START(Handle, Token, Module, TimeStamp) \
695 do { \
696 if (PerformanceMeasurementEnabled ()) { \
697 StartPerformanceMeasurement (Handle, Token, Module, TimeStamp); \
698 } \
699 } while (FALSE)
700
708#define PERF_END_EX(Handle, Token, Module, TimeStamp, Identifier) \
709 do { \
710 if (PerformanceMeasurementEnabled ()) { \
711 EndPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, Identifier); \
712 } \
713 } while (FALSE)
714
722#define PERF_START_EX(Handle, Token, Module, TimeStamp, Identifier) \
723 do { \
724 if (PerformanceMeasurementEnabled ()) { \
725 StartPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, Identifier); \
726 } \
727 } while (FALSE)
728
737#define PERF_CODE_BEGIN() \
738 do { \
739 if (PerformanceMeasurementEnabled ()) { \
740 do { } while (FALSE)
741
750#define PERF_CODE_END() \
751 } \
752 } while (FALSE)
753
764#define PERF_CODE(Expression) \
765 PERF_CODE_BEGIN (); \
766 Expression \
767 PERF_CODE_END ()
768
769#endif
UINT64 UINTN
#define CONST
Definition: Base.h:259
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
RETURN_STATUS EFIAPI EndPerformanceMeasurementEx(IN CONST VOID *Handle OPTIONAL, IN CONST CHAR8 *Token OPTIONAL, IN CONST CHAR8 *Module OPTIONAL, IN UINT64 TimeStamp, IN UINT32 Identifier)
UINTN EFIAPI GetPerformanceMeasurement(IN UINTN LogEntryKey, OUT CONST VOID **Handle, OUT CONST CHAR8 **Token, OUT CONST CHAR8 **Module, OUT UINT64 *StartTimeStamp, OUT UINT64 *EndTimeStamp)
RETURN_STATUS EFIAPI StartPerformanceMeasurementEx(IN CONST VOID *Handle OPTIONAL, IN CONST CHAR8 *Token OPTIONAL, IN CONST CHAR8 *Module OPTIONAL, IN UINT64 TimeStamp, IN UINT32 Identifier)
BOOLEAN EFIAPI LogPerformanceMeasurementEnabled(IN CONST UINTN Type)
BOOLEAN EFIAPI PerformanceMeasurementEnabled(VOID)
UINTN EFIAPI GetPerformanceMeasurementEx(IN UINTN LogEntryKey, OUT CONST VOID **Handle, OUT CONST CHAR8 **Token, OUT CONST CHAR8 **Module, OUT UINT64 *StartTimeStamp, OUT UINT64 *EndTimeStamp, OUT UINT32 *Identifier)
RETURN_STATUS EFIAPI EndPerformanceMeasurement(IN CONST VOID *Handle OPTIONAL, IN CONST CHAR8 *Token OPTIONAL, IN CONST CHAR8 *Module OPTIONAL, IN UINT64 TimeStamp)
RETURN_STATUS EFIAPI LogPerformanceMeasurement(IN CONST VOID *CallerIdentifier OPTIONAL, IN CONST VOID *Guid OPTIONAL, IN CONST CHAR8 *String OPTIONAL, IN UINT64 Address OPTIONAL, IN UINT32 Identifier)
RETURN_STATUS EFIAPI StartPerformanceMeasurement(IN CONST VOID *Handle OPTIONAL, IN CONST CHAR8 *Token OPTIONAL, IN CONST CHAR8 *Module OPTIONAL, IN UINT64 TimeStamp)