]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdePkg/PerformanceLib.h: Add new Perf macros
authorBi, Dandan <dandan.bi@intel.com>
Fri, 22 Jun 2018 08:56:17 +0000 (16:56 +0800)
committerLiming Gao <liming.gao@intel.com>
Tue, 26 Jun 2018 07:36:43 +0000 (15:36 +0800)
1. Add new Perf macros for performance measurement
and related APIs and definitions in Performance
library class.

2. Update NULL performance library instance in MdePkg.

Cc: Liming Gao <liming.gao@intel.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdePkg/Include/Library/PerformanceLib.h
MdePkg/Library/BasePerformanceLibNull/PerformanceLib.c
MdePkg/MdePkg.dec
MdePkg/MdePkg.uni

index 3ecd62bd20121bf6515f87cbfba74999fb87f35c..8a8f5e3694ae2b53821ae6c7889e5c4163661e2a 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Provides services to log the execution times and retrieve them later.\r
 \r
-Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
 This program and the accompanying materials\r
 are licensed and made available under the terms and conditions of the BSD License\r
 which accompanies this distribution.  The full text of the license may be found at\r
@@ -20,6 +20,45 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 ///\r
 #define PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED  0x00000001\r
 \r
+//\r
+// Public Progress Identifiers for Event Records.\r
+//\r
+#define PERF_EVENT_ID                   0x00\r
+\r
+#define MODULE_START_ID                 0x01\r
+#define MODULE_END_ID                   0x02\r
+#define MODULE_LOADIMAGE_START_ID       0x03\r
+#define MODULE_LOADIMAGE_END_ID         0x04\r
+#define MODULE_DB_START_ID              0x05\r
+#define MODULE_DB_END_ID                0x06\r
+#define MODULE_DB_SUPPORT_START_ID      0x07\r
+#define MODULE_DB_SUPPORT_END_ID        0x08\r
+#define MODULE_DB_STOP_START_ID         0x09\r
+#define MODULE_DB_STOP_END_ID           0x0A\r
+\r
+#define PERF_EVENTSIGNAL_START_ID       0x10\r
+#define PERF_EVENTSIGNAL_END_ID         0x11\r
+#define PERF_CALLBACK_START_ID          0x20\r
+#define PERF_CALLBACK_END_ID            0x21\r
+#define PERF_FUNCTION_START_ID          0x30\r
+#define PERF_FUNCTION_END_ID            0x31\r
+#define PERF_INMODULE_START_ID          0x40\r
+#define PERF_INMODULE_END_ID            0x41\r
+#define PERF_CROSSMODULE_START_ID       0x50\r
+#define PERF_CROSSMODULE_END_ID         0x51\r
+\r
+//\r
+// Declare bits for PcdPerformanceLibraryPropertyMask and\r
+// also used as the Type parameter of LogPerformanceMeasurementEnabled().\r
+//\r
+#define PERF_CORE_START_IMAGE            0x0002\r
+#define PERF_CORE_LOAD_IMAGE             0x0004\r
+#define PERF_CORE_DB_SUPPORT             0x0008\r
+#define PERF_CORE_DB_START               0x0010\r
+#define PERF_CORE_DB_STOP                0x0020\r
+\r
+#define PERF_GENERAL_TYPE                0x0040\r
+\r
 /**\r
   Creates a record for the beginning of a performance measurement. \r
   \r
@@ -271,6 +310,373 @@ PerformanceMeasurementEnabled (
   VOID\r
   );\r
 \r
+\r
+/**\r
+  Check whether the specified performance measurement can be logged.\r
+\r
+  This function returns TRUE when the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set\r
+  and the Type disable bit in PcdPerformanceLibraryPropertyMask is not set.\r
+\r
+  @param Type        - Type of the performance measurement entry.\r
+\r
+  @retval TRUE         The performance measurement can be logged.\r
+  @retval FALSE        The performance measurement can NOT be logged.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+LogPerformanceMeasurementEnabled (\r
+  IN  CONST UINTN        Type\r
+  );\r
+\r
+/**\r
+  Create performance record with event description.\r
+\r
+  @param CallerIdentifier - Image handle or pointer to caller ID GUID\r
+  @param Guid             - Pointer to a GUID.\r
+                            Used for event signal perf and callback perf to cache the event guid.\r
+  @param String           - Pointer to a string describing the measurement\r
+  @param Address          - Pointer to a location in memory relevant to the measurement.\r
+  @param Identifier       - Performance identifier describing the type of measurement.\r
+\r
+  @retval RETURN_SUCCESS           - Successfully created performance record\r
+  @retval RETURN_OUT_OF_RESOURCES  - Ran out of space to store the records\r
+  @retval RETURN_INVALID_PARAMETER - Invalid parameter passed to function - NULL\r
+                                     pointer or invalid Identifier.\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LogPerformanceMeasurement (\r
+  IN CONST VOID   *CallerIdentifier, OPTIONAL\r
+  IN CONST VOID   *Guid,    OPTIONAL\r
+  IN CONST CHAR8  *String,  OPTIONAL\r
+  IN UINT64       Address,  OPTIONAL\r
+  IN UINT32       Identifier\r
+  );\r
+\r
+/**\r
+  Begin Macro to measure the performance of StartImage in core.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT1(dsiable PERF_CORE_START_IMAGE) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_START_IMAGE_BEGIN(ModuleHandle) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_CORE_START_IMAGE)) { \\r
+      LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_START_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  End Macro to measure the performance of StartImage in core.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT1 (dsiable PERF_CORE_START_IMAGE)of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_START_IMAGE_END(ModuleHandle) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_CORE_START_IMAGE)) { \\r
+      LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_END_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  Begin Macro to measure the performance of LoadImage in core.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT2 (dsiable PERF_CORE_LOAD_IAMGE) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_LOAD_IMAGE_BEGIN(ModuleHandle) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_CORE_LOAD_IMAGE)) { \\r
+      LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_LOADIMAGE_START_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  End Macro to measure the performance of LoadImage in core.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT2 (dsiable PERF_CORE_LOAD_IAMGE) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_LOAD_IMAGE_END(ModuleHandle) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_CORE_LOAD_IMAGE)) { \\r
+      LogPerformanceMeasurement (ModuleHandle, NULL, NULL, 0, MODULE_LOADIMAGE_END_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  Start Macro to measure the performance of DriverBinding Support in core.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT3 (dsiable PERF_CORE_DB_SUPPORT) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_DRIVER_BINDING_SUPPORT_BEGIN(ModuleHandle, ControllerHandle) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_SUPPORT)) { \\r
+      LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_SUPPORT_START_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  End Macro to measure the performance of DriverBinding Support in core.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT3 (dsiable PERF_CORE_DB_SUPPORT) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_DRIVER_BINDING_SUPPORT_END(ModuleHandle, ControllerHandle) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_SUPPORT)) { \\r
+      LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_SUPPORT_END_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  Begin Macro to measure the performance of DriverBinding Start in core.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT4 (dsiable PERF_CORE_DB_START) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_DRIVER_BINDING_START_BEGIN(ModuleHandle, ControllerHandle) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_START)) { \\r
+      LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_START_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  End Macro to measure the performance of DriverBinding Start in core.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT4 (dsiable PERF_CORE_DB_START) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_DRIVER_BINDING_START_END(ModuleHandle, ControllerHandle) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_START)) { \\r
+      LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_END_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  Start Macro to measure the performance of DriverBinding Stop in core.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT5 (dsiable PERF_CORE_DB_STOP) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_DRIVER_BINDING_STOP_BEGIN(ModuleHandle, ControllerHandle) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_STOP)) { \\r
+      LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_STOP_START_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  End Macro to measure the performance of DriverBinding Stop in core.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT5 (dsiable PERF_CORE_DB_STOP) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_DRIVER_BINDING_STOP_END(ModuleHandle, ControllerHandle) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_CORE_DB_STOP)) { \\r
+      LogPerformanceMeasurement (ModuleHandle, NULL, NULL, (UINT64)(UINTN)ControllerHandle, MODULE_DB_STOP_END_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  Macro to measure the time from power-on to this macro execution.\r
+  It can be used to log a meaningful thing which happens at a time point.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_EVENT(EventString) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r
+      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, EventString , 0, PERF_EVENT_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  Begin Macro to measure the perofrmance of evnent signal behavior in any module.\r
+  The event guid will be passed with this macro.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_EVENT_SIGNAL_BEGIN(EventGuid) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r
+      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_START_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  End Macro to measure the perofrmance of evnent signal behavior in any module.\r
+  The event guid will be passed with this macro.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_EVENT_SIGNAL_END(EventGuid) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r
+      LogPerformanceMeasurement (&gEfiCallerIdGuid, EventGuid, __FUNCTION__ , 0, PERF_EVENTSIGNAL_END_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  Begin Macro to measure the perofrmance of a callback function in any module.\r
+  The event guid which trigger the callback function will be passed with this macro.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_CALLBACK_BEGIN(TriggerGuid) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r
+      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_START_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  End Macro to measure the perofrmance of a callback function in any module.\r
+  The event guid which trigger the callback function will be passed with this macro.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_CALLBACK_END(TriggerGuid) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r
+      LogPerformanceMeasurement (&gEfiCallerIdGuid, TriggerGuid, __FUNCTION__ , 0, PERF_CALLBACK_END_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  Begin Macro to measure the perofrmance of a general function in any module.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_FUNCTION_BEGIN() \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r
+      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_START_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  End Macro to measure the perofrmance of a general function in any module.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_FUNCTION_END() \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r
+      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, __FUNCTION__ , 0, PERF_FUNCTION_END_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  Begin Macro to measure the perofrmance of a behavior within one module.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_INMODULE_BEGIN(MeasurementString) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r
+      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_INMODULE_START_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  End Macro to measure the perofrmance of a behavior within one module.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_INMODULE_END(MeasurementString) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r
+      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_INMODULE_END_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  Begin Macro to measure the perofrmance of a behavior in different modules.\r
+  Such as the performance of PEI phase, DXE phase, BDS phase.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_CROSSMODULE_BEGIN(MeasurementString) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r
+      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_CROSSMODULE_START_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
+/**\r
+  End Macro to measure the perofrmance of a behavior in different modules.\r
+  Such as the performance of PEI phase, DXE phase, BDS phase.\r
+\r
+  If the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set,\r
+  and the BIT6 (dsiable PERF_GENERAL_TYPE) of PcdPerformanceLibraryPropertyMask is not set.\r
+  then LogPerformanceMeasurement() is called.\r
+\r
+**/\r
+#define PERF_CROSSMODULE_END(MeasurementString) \\r
+  do { \\r
+    if (LogPerformanceMeasurementEnabled (PERF_GENERAL_TYPE)) { \\r
+      LogPerformanceMeasurement (&gEfiCallerIdGuid, NULL, MeasurementString, 0, PERF_CROSSMODULE_END_ID); \\r
+    } \\r
+  } while (FALSE)\r
+\r
 /**\r
   Macro that calls EndPerformanceMeasurement().\r
 \r
index e35235d9a29228b5554b88dd85f2531d2e562610..a68ea90d4f06f17fb76648a38830882f4792f0ed 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Base Performance Library which provides no service.\r
 \r
-  Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -304,3 +304,58 @@ PerformanceMeasurementEnabled (
 {\r
   return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);\r
 }\r
+\r
+/**\r
+  Create performance record with event description and a timestamp.\r
+\r
+  @param CallerIdentifier  - Image handle or pointer to caller ID GUID\r
+  @param Guid              - Pointer to a GUID\r
+  @param String            - Pointer to a string describing the measurement\r
+  @param Address           - Pointer to a location in memory relevant to the measurement\r
+  @param Identifier        - Performance identifier describing the type of measurement\r
+\r
+  @retval RETURN_SUCCESS           - Successfully created performance record\r
+  @retval RETURN_OUT_OF_RESOURCES  - Ran out of space to store the records\r
+  @retval RETURN_INVALID_PARAMETER - Invalid parameter passed to function - NULL\r
+                                     pointer or invalid PerfId\r
+\r
+**/\r
+RETURN_STATUS\r
+EFIAPI\r
+LogPerformanceMeasurement (\r
+  IN CONST VOID   *CallerIdentifier,OPTIONAL\r
+  IN CONST VOID   *Guid,    OPTIONAL\r
+  IN CONST CHAR8  *String,  OPTIONAL\r
+  IN UINT64       Address,  OPTIONAL\r
+  IN UINT32       Identifier\r
+  )\r
+{\r
+  return RETURN_SUCCESS;\r
+}\r
+\r
+/**\r
+  Check whether the specified performance measurement can be logged.\r
+\r
+  This function returns TRUE when the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set\r
+  and the Type disable bit in PcdPerformanceLibraryPropertyMask is not set.\r
+\r
+  @param Type        - Type of the performance measurement entry.\r
+\r
+  @retval TRUE         The performance measurement can be logged.\r
+  @retval FALSE        The performance measurement can NOT be logged.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+LogPerformanceMeasurementEnabled (\r
+  IN  CONST UINTN        Type\r
+  )\r
+{\r
+  //\r
+  // When Performance measurement is enabled and the type is not filtered, the performance can be logged.\r
+  //\r
+  if (PerformanceMeasurementEnabled () && (PcdGet8(PcdPerformanceLibraryPropertyMask) & Type) == 0) {\r
+    return TRUE;\r
+  }\r
+  return FALSE;\r
+}\r
index 0e64f22f4a747f3c1b529d33492b182852d4a143..432de804c5dda6f80b11b482eca06833b73ec400 100644 (file)
 \r
   ## The mask is used to control PerformanceLib behavior.<BR><BR>\r
   #  BIT0 - Enable Performance Measurement.<BR>\r
+  #  BIT1 - Disable Start Image Logging.<BR>\r
+  #  BIT2 - Disable Load Image logging.<BR>\r
+  #  BIT3 - Disable Binding Support logging.<BR>\r
+  #  BIT4 - Disable Binding Start logging.<BR>\r
+  #  BIT5 - Disable Binding Stop logging.<BR>\r
+  #  BIT6 - Disable all other general Perfs.<BR>\r
+  #  BIT1-BIT6 are evaluated when BIT0 is set.<BR>\r
   # @Prompt Performance Measurement Property.\r
-  # @Expression  0x80000002 | (gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask & 0xFE) == 0\r
+  # @Expression  0x80000002 | (gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask & 0x80) == 0\r
   gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask|0|UINT8|0x00000009\r
 \r
   ## The mask is used to control PostCodeLib behavior.<BR><BR>\r
index a110e453df8dda297d195ca72f14c0b725115a2a..18bb01f2199b43491c75af8af245706d89c4eb1b 100644 (file)
 \r
 #string STR_gEfiMdePkgTokenSpaceGuid_PcdPerformanceLibraryPropertyMask_HELP  #language en-US "The mask is used to control PerformanceLib behavior.<BR><BR>\n"\r
                                                                                              "BIT0 - Enable Performance Measurement.<BR>"\r
+                                                                                             "BIT1 - Disable Start Image Logging.<BR>"\r
+                                                                                             "BIT2 - Disable Load Image logging.<BR>"\r
+                                                                                             "BIT3 - Disable Binding Support logging.<BR>"\r
+                                                                                             "BIT4 - Disable Binding Start logging.<BR>"\r
+                                                                                             "BIT5 - Disable Binding Stop logging.<BR>"\r
+                                                                                             "BIT6 - Disable all other general Perfs.<BR>"\r
 \r
 #string STR_gEfiMdePkgTokenSpaceGuid_PcdPostCodePropertyMask_PROMPT  #language en-US "Post Code Property"\r
 \r