9#ifndef __PERFORMANCE_LIB_H__
10#define __PERFORMANCE_LIB_H__
15#define PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED 0x00000001
20#define PERF_EVENT_ID 0x00
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
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
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
54#define PERF_GENERAL_TYPE 0x0040
82 IN CONST CHAR8 *Module OPTIONAL,
112 IN CONST VOID *Handle OPTIONAL,
113 IN CONST CHAR8 *Token OPTIONAL,
114 IN CONST CHAR8 *Module OPTIONAL,
164 OUT UINT64 *StartTimeStamp,
165 OUT UINT64 *EndTimeStamp
194 IN CONST VOID *Handle OPTIONAL,
195 IN CONST CHAR8 *Token OPTIONAL,
196 IN CONST CHAR8 *Module OPTIONAL,
229 IN CONST VOID *Handle OPTIONAL,
230 IN CONST CHAR8 *Token OPTIONAL,
231 IN CONST CHAR8 *Module OPTIONAL,
284 OUT UINT64 *StartTimeStamp,
285 OUT UINT64 *EndTimeStamp,
286 OUT UINT32 *Identifier
344 IN CONST VOID *CallerIdentifier OPTIONAL,
346 IN CONST CHAR8 *String OPTIONAL,
347 IN UINT64 Address OPTIONAL,
359#define PERF_START_IMAGE_BEGIN(ModuleHandle) \
361 if (LogPerformanceMeasurementEnabled (PERF_CORE_START_IMAGE)) { \
362 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_START_ID); \
374#define PERF_START_IMAGE_END(ModuleHandle) \
376 if (LogPerformanceMeasurementEnabled (PERF_CORE_START_IMAGE)) { \
377 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_END_ID); \
389#define PERF_LOAD_IMAGE_BEGIN(ModuleHandle) \
391 if (LogPerformanceMeasurementEnabled (PERF_CORE_LOAD_IMAGE)) { \
392 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_LOADIMAGE_START_ID); \
404#define PERF_LOAD_IMAGE_END(ModuleHandle) \
406 if (LogPerformanceMeasurementEnabled (PERF_CORE_LOAD_IMAGE)) { \
407 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_LOADIMAGE_END_ID); \
419#define PERF_DRIVER_BINDING_SUPPORT_BEGIN(ModuleHandle, ControllerHandle) \
421 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_SUPPORT)) { \
422 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_SUPPORT_START_ID); \
434#define PERF_DRIVER_BINDING_SUPPORT_END(ModuleHandle, ControllerHandle) \
436 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_SUPPORT)) { \
437 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_SUPPORT_END_ID); \
449#define PERF_DRIVER_BINDING_START_BEGIN(ModuleHandle, ControllerHandle) \
451 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_START)) { \
452 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_START_ID); \
464#define PERF_DRIVER_BINDING_START_END(ModuleHandle, ControllerHandle) \
466 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_START)) { \
467 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_END_ID); \
479#define PERF_DRIVER_BINDING_STOP_BEGIN(ModuleHandle, ControllerHandle) \
481 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_STOP)) { \
482 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_STOP_START_ID); \
494#define PERF_DRIVER_BINDING_STOP_END(ModuleHandle, ControllerHandle) \
496 if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_STOP)) { \
497 LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_STOP_END_ID); \
510#define PERF_EVENT(EventString) \
512 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
513 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, EventString , 0, PERF_EVENT_ID); \
526#define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \
528 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
529 LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_START_ID); \
542#define PERF_EVENT_SIGNAL_END(EventGuid) \
544 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
545 LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __func__ , 0, PERF_EVENTSIGNAL_END_ID); \
558#define PERF_CALLBACK_BEGIN(TriggerGuid) \
560 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
561 LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_START_ID); \
574#define PERF_CALLBACK_END(TriggerGuid) \
576 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
577 LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __func__ , 0, PERF_CALLBACK_END_ID); \
589#define PERF_FUNCTION_BEGIN() \
591 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
592 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_START_ID); \
604#define PERF_FUNCTION_END() \
606 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
607 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __func__ , 0, PERF_FUNCTION_END_ID); \
619#define PERF_INMODULE_BEGIN(MeasurementString) \
621 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
622 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_INMODULE_START_ID); \
634#define PERF_INMODULE_END(MeasurementString) \
636 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
637 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_INMODULE_END_ID); \
650#define PERF_CROSSMODULE_BEGIN(MeasurementString) \
652 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
653 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_CROSSMODULE_START_ID); \
666#define PERF_CROSSMODULE_END(MeasurementString) \
668 if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \
669 LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_CROSSMODULE_END_ID); \
680#define PERF_END(Handle, Token, Module, TimeStamp) \
682 if (PerformanceMeasurementEnabled ()) { \
683 EndPerformanceMeasurement (Handle, Token, Module, TimeStamp); \
694#define PERF_START(Handle, Token, Module, TimeStamp) \
696 if (PerformanceMeasurementEnabled ()) { \
697 StartPerformanceMeasurement (Handle, Token, Module, TimeStamp); \
708#define PERF_END_EX(Handle, Token, Module, TimeStamp, Identifier) \
710 if (PerformanceMeasurementEnabled ()) { \
711 EndPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, Identifier); \
722#define PERF_START_EX(Handle, Token, Module, TimeStamp, Identifier) \
724 if (PerformanceMeasurementEnabled ()) { \
725 StartPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, Identifier); \
737#define PERF_CODE_BEGIN() \
739 if (PerformanceMeasurementEnabled ()) { \
750#define PERF_CODE_END() \
764#define PERF_CODE(Expression) \
765 PERF_CODE_BEGIN (); \