public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [patch 0/3] Add PeiPerformancePpiLib
@ 2018-07-30  6:59 Dandan Bi
  2018-07-30  6:59 ` [patch 1/3] MdeModulePkg: Add the definition of performance measurement PPI Dandan Bi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dandan Bi @ 2018-07-30  6:59 UTC (permalink / raw)
  To: edk2-devel; +Cc: Dmitry Antipov, Michael D Kinney, Liming Gao, Star Zeng

Enhance the PeiPerformanceLib to install the Performance
Measurement PPI.

Add a new "thin" PerformanceLib instance
PeiPerformancePpiLib which will locate a
Performance measurement Ppi to log performance data.

Platform can link the "thin" PeiPerformancePpiLib
to log the performance data for PEIMs.
It also can link the PeiPerformanceLib in PEI phase
to keep the compatibility.

Cc: Dmitry Antipov <dmanti@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>

Dandan Bi (3):
  MdeModulePkg: Add the definition of performance measurement PPI
  MdeModulePkg/PeiPerformanceLib: Produce the new PerformancePpi
  MdeModulePkg/PeiPerformancePpiLib: Add PeiPerformancePpiLib

 MdeModulePkg/Include/Guid/PerformanceMeasurement.h |  14 +
 .../Library/PeiPerformanceLib/PeiPerformanceLib.c  |  81 ++++
 .../PeiPerformanceLib/PeiPerformanceLib.inf        |   1 +
 .../PeiPerformancePpiLib/PeiPerformancePpiLib.c    | 420 +++++++++++++++++++++
 .../PeiPerformancePpiLib/PeiPerformancePpiLib.inf  |  49 +++
 .../PeiPerformancePpiLib/PeiPerformancePpiLib.uni  |  23 ++
 MdeModulePkg/MdeModulePkg.dec                      |   1 +
 MdeModulePkg/MdeModulePkg.dsc                      |   1 +
 8 files changed, 590 insertions(+)
 create mode 100644 MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.c
 create mode 100644 MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.inf
 create mode 100644 MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.uni

-- 
2.14.3.windows.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [patch 1/3] MdeModulePkg: Add the definition of performance measurement PPI
  2018-07-30  6:59 [patch 0/3] Add PeiPerformancePpiLib Dandan Bi
@ 2018-07-30  6:59 ` Dandan Bi
  2018-07-30  6:59 ` [patch 2/3] MdeModulePkg/PeiPerformanceLib: Produce the new PerformancePpi Dandan Bi
  2018-07-30  6:59 ` [patch 3/3] MdeModulePkg/PeiPerformancePpiLib: Add PeiPerformancePpiLib Dandan Bi
  2 siblings, 0 replies; 4+ messages in thread
From: Dandan Bi @ 2018-07-30  6:59 UTC (permalink / raw)
  To: edk2-devel; +Cc: Dmitry Antipov, Michael D Kinney, Liming Gao, Star Zeng

Cc: Dmitry Antipov <dmanti@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 MdeModulePkg/Include/Guid/PerformanceMeasurement.h | 14 ++++++++++++++
 MdeModulePkg/MdeModulePkg.dec                      |  1 +
 2 files changed, 15 insertions(+)

diff --git a/MdeModulePkg/Include/Guid/PerformanceMeasurement.h b/MdeModulePkg/Include/Guid/PerformanceMeasurement.h
index 0c3eb593a0..099504c6d6 100644
--- a/MdeModulePkg/Include/Guid/PerformanceMeasurement.h
+++ b/MdeModulePkg/Include/Guid/PerformanceMeasurement.h
@@ -73,6 +73,20 @@ struct _EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL {
 };
 
 extern EFI_GUID gEdkiiPerformanceMeasurementProtocolGuid;
 extern EFI_GUID gEdkiiSmmPerformanceMeasurementProtocolGuid;
 
+//
+// Performance measurement PPI.
+//
+#define PERFORMANCE_MEASUREMENT_PPI_GUID \
+  { 0x0eca9ae3, 0xa792, 0x418c, {0xbd, 0x36, 0X6c, 0x2e, 0xca, 0x5c, 0x59, 0xfc } }
+
+typedef struct _EDKII_PERFORMANCE_MEASUREMENT_PPI EDKII_PERFORMANCE_MEASUREMENT_PPI;
+
+struct _EDKII_PERFORMANCE_MEASUREMENT_PPI {
+  CREATE_PERFORMANCE_MEASUREMENT       CreatePerformanceMeasurementPpi;
+};
+
+extern EFI_GUID gEdkiiPerformanceMeasurementPpiGuid;
+
 #endif // _PERFORMANCE_MEASUREMENT_H_
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec
index 6a6d9660ed..3db97f536e 100644
--- a/MdeModulePkg/MdeModulePkg.dec
+++ b/MdeModulePkg/MdeModulePkg.dec
@@ -261,10 +261,11 @@
   gPerformanceExProtocolGuid     = { 0x1ea81bec, 0xf01a, 0x4d98, { 0xa2, 0x1,  0x4a, 0x61, 0xce, 0x2f, 0xc0, 0x22 } }
   gSmmPerformanceExProtocolGuid  = { 0x931fc048, 0xc71d, 0x4455, { 0x89, 0x30, 0x47, 0x6,  0x30, 0xe3, 0xe,  0xe5 } }
   #  Include/Guid/PerformanceMeasurement.h
   gEdkiiPerformanceMeasurementProtocolGuid      = { 0xc85d06be, 0x5f75, 0x48ce, { 0xa8, 0x0f, 0x12, 0x36, 0xba, 0x3b, 0x87, 0xb1 } }
   gEdkiiSmmPerformanceMeasurementProtocolGuid   = { 0xd56b6d73, 0x1a7b, 0x4015, { 0x9b, 0xb4, 0x7b, 0x07, 0x17, 0x29, 0xed, 0x24 } }
+  gEdkiiPerformanceMeasurementPpiGuid           = { 0x0eca9ae3, 0xa792, 0x418c, { 0xbd, 0x36, 0X6c, 0x2e, 0xca, 0x5c, 0x59, 0xfc } }
 
   ## Guid is defined for CRC32 encapsulation scheme.
   #  Include/Guid/Crc32GuidedSectionExtraction.h
   gEfiCrc32GuidedSectionExtractionGuid = { 0xFC1BCDB0, 0x7D31, 0x49aa, {0x93, 0x6A, 0xA4, 0x60, 0x0D, 0x9D, 0xD0, 0x83 } }
 
-- 
2.14.3.windows.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [patch 2/3] MdeModulePkg/PeiPerformanceLib: Produce the new PerformancePpi
  2018-07-30  6:59 [patch 0/3] Add PeiPerformancePpiLib Dandan Bi
  2018-07-30  6:59 ` [patch 1/3] MdeModulePkg: Add the definition of performance measurement PPI Dandan Bi
@ 2018-07-30  6:59 ` Dandan Bi
  2018-07-30  6:59 ` [patch 3/3] MdeModulePkg/PeiPerformancePpiLib: Add PeiPerformancePpiLib Dandan Bi
  2 siblings, 0 replies; 4+ messages in thread
From: Dandan Bi @ 2018-07-30  6:59 UTC (permalink / raw)
  To: edk2-devel; +Cc: Dmitry Antipov, Michael D Kinney, Liming Gao, Star Zeng

Enhance the PeiPerformanceLib to produce the Performance
Measurement PPI.

Cc: Dmitry Antipov <dmanti@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 .../Library/PeiPerformanceLib/PeiPerformanceLib.c  | 81 ++++++++++++++++++++++
 .../PeiPerformanceLib/PeiPerformanceLib.inf        |  1 +
 2 files changed, 82 insertions(+)

diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
index 808a63501e..528bf12303 100644
--- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
+++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c
@@ -30,14 +30,52 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/HobLib.h>
 #include <Library/BaseLib.h>
 #include <Library/TimerLib.h>
 #include <Library/PcdLib.h>
 #include <Library/BaseMemoryLib.h>
+#include <Library/PeiServicesLib.h>
 
 #define  STRING_SIZE            (FPDT_STRING_EVENT_RECORD_NAME_LENGTH * sizeof (CHAR8))
 #define  PEI_MAX_RECORD_SIZE    (sizeof (FPDT_DUAL_GUID_STRING_EVENT_RECORD) + STRING_SIZE)
 
+/**
+  Create performance record with event description and a timestamp.
+
+  @param CallerIdentifier  - Image handle or pointer to caller ID GUID.
+  @param Guid              - Pointer to a GUID.
+  @param String            - Pointer to a string describing the measurement.
+  @param TimeStamp         - 64-bit time stamp.
+  @param Address           - Pointer to a location in memory relevant to the measurement.
+  @param Identifier        - Performance identifier describing the type of measurement.
+  @param Attribute         - The attribute of the measurement. According to attribute can create a start
+                             record for PERF_START/PERF_START_EX, or a end record for PERF_END/PERF_END_EX,
+                             or a general record for other Perf macros.
+
+  @retval EFI_SUCCESS           - Successfully created performance record.
+  @retval EFI_OUT_OF_RESOURCES  - Ran out of space to store the records.
+  @retval EFI_INVALID_PARAMETER - Invalid parameter passed to function - NULL
+                                  pointer or invalid PerfId.
+**/
+EFI_STATUS
+EFIAPI
+CreatePerformanceMeasurementPpi (
+  IN CONST VOID                        *CallerIdentifier,
+  IN CONST VOID                        *Guid,   OPTIONAL
+  IN CONST CHAR8                       *String, OPTIONAL
+  IN       UINT64                      TimeStamp,
+  IN       UINT64                      Address,  OPTIONAL
+  IN       UINT32                      Identifier,
+  IN       PERF_MEASUREMENT_ATTRIBUTE  Attribute
+  );
+
+EDKII_PERFORMANCE_MEASUREMENT_PPI mPerformancePpi = {CreatePerformanceMeasurementPpi};
+
+EFI_PEI_PPI_DESCRIPTOR  mPerformancePpiDesc = {
+  (EFI_PEI_PPI_DESCRIPTOR_PPI | EFI_PEI_PPI_DESCRIPTOR_TERMINATE_LIST),
+  &gEdkiiPerformanceMeasurementPpiGuid,
+  &mPerformancePpi
+};
 
 /**
   Return the pointer to the FPDT record in the allocated memory.
 
   @param  RecordSize                The size of FPDT record.
@@ -56,10 +94,12 @@ GetFpdtRecordPtr (
 {
   UINT16                                PeiPerformanceLogEntries;
   UINTN                                 PeiPerformanceSize;
   UINT8                                 *PeiFirmwarePerformance;
   EFI_HOB_GUID_TYPE                     *GuidHob;
+  EFI_HOB_GUID_TYPE                     *FirstGuidHob;
+  EFI_STATUS                            Status;
 
   //
   // Get the number of PeiPerformanceLogEntries form PCD.
   //
   PeiPerformanceLogEntries = (UINT16) (PcdGet16 (PcdMaxPeiPerformanceLogEntries16) != 0 ?
@@ -68,10 +108,11 @@ GetFpdtRecordPtr (
 
   //
   // Create GUID HOB Data.
   //
   GuidHob = GetFirstGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid);
+  FirstGuidHob = GuidHob;
   PeiFirmwarePerformance = NULL;
   while (GuidHob != NULL) {
     //
     // PEI Performance HOB was found, then return the existing one.
     //
@@ -89,10 +130,16 @@ GetFpdtRecordPtr (
     //
     GuidHob = GetNextGuidHob (&gEdkiiFpdtExtendedFirmwarePerformanceGuid, GET_NEXT_HOB (GuidHob));
   }
 
   if (GuidHob == NULL) {
+    if (FirstGuidHob == NULL) {
+      Status = PeiServicesInstallPpi(&mPerformancePpiDesc);
+      if (EFI_ERROR(Status)) {
+        DEBUG((DEBUG_ERROR, "PeiCorePerformanceLib - %a - InstallPpi returned %r!\n", __FUNCTION__, Status));
+      }
+    }
     //
     // PEI Performance HOB was not found, then build one.
     //
     PeiPerformanceSize      = sizeof (FPDT_PEI_EXT_PERF_HEADER) +
                               PEI_MAX_RECORD_SIZE * PeiPerformanceLogEntries;
@@ -513,10 +560,44 @@ InsertFpdtRecord (
   PeiPerformanceLogHeader->SizeOfAllEntries += FpdtRecordPtr.RecordHeader->Length;
 
   return EFI_SUCCESS;
 }
 
+/**
+  Create performance record with event description and a timestamp.
+
+  @param CallerIdentifier  - Image handle or pointer to caller ID GUID.
+  @param Guid              - Pointer to a GUID.
+  @param String            - Pointer to a string describing the measurement.
+  @param TimeStamp         - 64-bit time stamp.
+  @param Address           - Pointer to a location in memory relevant to the measurement.
+  @param Identifier        - Performance identifier describing the type of measurement.
+  @param Attribute         - The attribute of the measurement. According to attribute can create a start
+                             record for PERF_START/PERF_START_EX, or a end record for PERF_END/PERF_END_EX,
+                             or a general record for other Perf macros.
+
+  @retval EFI_SUCCESS           - Successfully created performance record.
+  @retval EFI_OUT_OF_RESOURCES  - Ran out of space to store the records.
+  @retval EFI_INVALID_PARAMETER - Invalid parameter passed to function - NULL
+                                  pointer or invalid PerfId.
+**/
+EFI_STATUS
+EFIAPI
+CreatePerformanceMeasurementPpi (
+  IN CONST VOID                        *CallerIdentifier,
+  IN CONST VOID                        *Guid,   OPTIONAL
+  IN CONST CHAR8                       *String, OPTIONAL
+  IN       UINT64                      TimeStamp,
+  IN       UINT64                      Address,  OPTIONAL
+  IN       UINT32                      Identifier,
+  IN       PERF_MEASUREMENT_ATTRIBUTE  Attribute
+  )
+{
+  return InsertFpdtRecord (CallerIdentifier, Guid, String, TimeStamp, Address, (UINT16)Identifier, Attribute);
+
+}
+
 /**
   Creates a record for the beginning of a performance measurement.
 
   If TimeStamp is zero, then this function reads the current time stamp
   and adds that time stamp value to the record as the start time.
diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf
index cad3a120a2..9b40af0738 100644
--- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf
+++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf
@@ -52,10 +52,11 @@
 
 [Guids]
   ## PRODUCES ## HOB
   ## CONSUMES ## HOB
   gEdkiiFpdtExtendedFirmwarePerformanceGuid
+  gEdkiiPerformanceMeasurementPpiGuid
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries     ## CONSUMES
   gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries16   ## CONSUMES
   gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask        ## CONSUMES
-- 
2.14.3.windows.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [patch 3/3] MdeModulePkg/PeiPerformancePpiLib: Add PeiPerformancePpiLib
  2018-07-30  6:59 [patch 0/3] Add PeiPerformancePpiLib Dandan Bi
  2018-07-30  6:59 ` [patch 1/3] MdeModulePkg: Add the definition of performance measurement PPI Dandan Bi
  2018-07-30  6:59 ` [patch 2/3] MdeModulePkg/PeiPerformanceLib: Produce the new PerformancePpi Dandan Bi
@ 2018-07-30  6:59 ` Dandan Bi
  2 siblings, 0 replies; 4+ messages in thread
From: Dandan Bi @ 2018-07-30  6:59 UTC (permalink / raw)
  To: edk2-devel; +Cc: Dmitry Antipov, Michael D Kinney, Liming Gao, Star Zeng

Add a new "thin" PerformanceLib instance
PeiPerformancePpiLib which will locate a
Performance measurement Ppi to log performance data.

Platform can link the "thin" PeiPerformancePpiLib
to log the performance data for PEIMs.
It also can link the PeiPerformanceLib in PEI phase
to keep the compatibility.

Cc: Dmitry Antipov <dmanti@microsoft.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Star Zeng <star.zeng@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
---
 .../PeiPerformancePpiLib/PeiPerformancePpiLib.c    | 420 +++++++++++++++++++++
 .../PeiPerformancePpiLib/PeiPerformancePpiLib.inf  |  49 +++
 .../PeiPerformancePpiLib/PeiPerformancePpiLib.uni  |  23 ++
 MdeModulePkg/MdeModulePkg.dsc                      |   1 +
 4 files changed, 493 insertions(+)
 create mode 100644 MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.c
 create mode 100644 MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.inf
 create mode 100644 MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.uni

diff --git a/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.c b/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.c
new file mode 100644
index 0000000000..e1ac6b6b61
--- /dev/null
+++ b/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.c
@@ -0,0 +1,420 @@
+/** @file
+Performance library instance used for PEIMs
+
+This library provides the performance measurement interfaces in PEI phase, It locates
+performance measurement PPI to log the performance data.
+
+Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+This program and the accompanying materials
+are licensed and made available under the terms and conditions of the BSD License
+which accompanies this distribution.  The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include <PiPei.h>
+
+#include <Guid/PerformanceMeasurement.h>
+
+#include <Library/PeiServicesLib.h>
+#include <Library/PerformanceLib.h>
+#include <Library/DebugLib.h>
+#include <Library/PcdLib.h>
+
+/**
+  Create performance record with event description and a timestamp.
+  This function locates the Performance PPI and calls it with the same parameters.
+
+  @param CallerIdentifier  - Image handle or pointer to caller ID GUID.
+  @param Guid              - Pointer to a GUID.
+  @param String            - Pointer to a string describing the measurement.
+  @param TimeStamp         - 64-bit time stamp.
+  @param Address           - Pointer to a location in memory relevant to the measurement.
+  @param Identifier        - Performance identifier describing the type of measurement.
+  @param Attribute         - The attribute of the measurement. According to attribute can create a start
+                             record for PERF_START/PERF_START_EX, or a end record for PERF_END/PERF_END_EX,
+                             or a general record for other Perf macros.
+
+  @retval EFI_SUCCESS           - Successfully created performance record.
+  @retval EFI_OUT_OF_RESOURCES  - Ran out of space to store the records.
+  @retval EFI_INVALID_PARAMETER - Invalid parameter passed to function - NULL
+                                  pointer or invalid PerfId.
+**/
+RETURN_STATUS
+CreatePerformanceMeasurement (
+  IN CONST VOID                  *CallerIdentifier,  OPTIONAL
+  IN CONST VOID                  *Guid,    OPTIONAL
+  IN CONST CHAR8                 *String,  OPTIONAL
+  IN UINT64                      TimeStamp,OPTIONAL
+  IN UINT64                      Address,  OPTIONAL
+  IN UINT32                      Identifier,
+  IN PERF_MEASUREMENT_ATTRIBUTE  Attribute
+  )
+{
+  EFI_STATUS                          Status;
+  EDKII_PERFORMANCE_MEASUREMENT_PPI   *PerformancePpi;
+
+  Status = PeiServicesLocatePpi (
+                &gEdkiiPerformanceMeasurementPpiGuid,
+                0,
+                NULL,
+                (VOID **) &PerformancePpi
+                );
+
+  if (!EFI_ERROR(Status)) {
+    return (RETURN_STATUS) PerformancePpi->CreatePerformanceMeasurementPpi(CallerIdentifier, Guid, String, TimeStamp, Address, Identifier, Attribute);
+  } else {
+    return RETURN_NOT_READY;
+  }
+}
+
+/**
+  Creates a record for the beginning of a performance measurement.
+
+  If TimeStamp is zero, then this function reads the current time stamp
+  and adds that time stamp value to the record as the start time.
+
+  If TimeStamp is one, then this function reads 0 as the start time.
+
+  If TimeStamp is other value, then TimeStamp is added to the record as the start time.
+
+  @param  Handle                  Pointer to environment specific context used
+                                  to identify the component being measured.
+  @param  Token                   Pointer to a Null-terminated ASCII string
+                                  that identifies the component being measured.
+  @param  Module                  Pointer to a Null-terminated ASCII string
+                                  that identifies the module being measured.
+  @param  TimeStamp               64-bit time stamp.
+  @param  Identifier              32-bit identifier. If the value is 0, the created record
+                                  is same as the one created by StartPerformanceMeasurement.
+
+  @retval RETURN_SUCCESS          The start of the measurement was recorded.
+  @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
+
+**/
+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
+  )
+{
+  CONST CHAR8     *String;
+
+  if (Token != NULL) {
+    String = Token;
+  } else if (Module != NULL) {
+    String = Module;
+  } else {
+    String = NULL;
+  }
+
+  return CreatePerformanceMeasurement (Handle, NULL, String, TimeStamp, 0, Identifier, PerfStartEntry);
+
+}
+
+/**
+
+  Creates a record for the end of a performance measurement.
+
+  If the TimeStamp is not zero or one, then TimeStamp is added to the record as the end time.
+  If the TimeStamp is zero, then this function reads the current time stamp and adds that time stamp value to the record as the end time.
+  If the TimeStamp is one, then this function reads 0 as the end time.
+
+  @param  Handle                  Pointer to environment specific context used
+                                  to identify the component being measured.
+  @param  Token                   Pointer to a Null-terminated ASCII string
+                                  that identifies the component being measured.
+  @param  Module                  Pointer to a Null-terminated ASCII string
+                                  that identifies the module being measured.
+  @param  TimeStamp               64-bit time stamp.
+  @param  Identifier              32-bit identifier. If the value is 0, the found record
+                                  is same as the one found by EndPerformanceMeasurement.
+
+  @retval RETURN_SUCCESS          The end of  the measurement was recorded.
+  @retval RETURN_NOT_FOUND        The specified measurement record could not be found.
+
+**/
+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
+  )
+{
+  CONST CHAR8     *String;
+
+  if (Token != NULL) {
+    String = Token;
+  } else if (Module != NULL) {
+    String = Module;
+  } else {
+    String = NULL;
+  }
+
+  return CreatePerformanceMeasurement (Handle, NULL, String, TimeStamp, 0, Identifier, PerfEndEntry);
+}
+
+/**
+  Attempts to retrieve a performance measurement log entry from the performance measurement log.
+  It can also retrieve the log created by StartPerformanceMeasurement and EndPerformanceMeasurement,
+  and then assign the Identifier with 0.
+
+  Attempts to retrieve the performance log entry specified by LogEntryKey.  If LogEntryKey is
+  zero on entry, then an attempt is made to retrieve the first entry from the performance log,
+  and the key for the second entry in the log is returned.  If the performance log is empty,
+  then no entry is retrieved and zero is returned.  If LogEntryKey is not zero, then the performance
+  log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
+  returned.  If LogEntryKey is the key for the last entry in the log, then the last log entry is
+  retrieved and an implementation specific non-zero key value that specifies the end of the performance
+  log is returned.  If LogEntryKey is equal this implementation specific non-zero key value, then no entry
+  is retrieved and zero is returned.  In the cases where a performance log entry can be returned,
+  the log entry is returned in Handle, Token, Module, StartTimeStamp, EndTimeStamp and Identifier.
+  If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
+  If Handle is NULL, then ASSERT().
+  If Token is NULL, then ASSERT().
+  If Module is NULL, then ASSERT().
+  If StartTimeStamp is NULL, then ASSERT().
+  If EndTimeStamp is NULL, then ASSERT().
+  If Identifier is NULL, then ASSERT().
+
+  !!!NOT Support yet!!!
+
+  @param  LogEntryKey             On entry, the key of the performance measurement log entry to retrieve.
+                                  0, then the first performance measurement log entry is retrieved.
+                                  On exit, the key of the next performance of entry entry.
+  @param  Handle                  Pointer to environment specific context used to identify the component
+                                  being measured.
+  @param  Token                   Pointer to a Null-terminated ASCII string that identifies the component
+                                  being measured.
+  @param  Module                  Pointer to a Null-terminated ASCII string that identifies the module
+                                  being measured.
+  @param  StartTimeStamp          Pointer to the 64-bit time stamp that was recorded when the measurement
+                                  was started.
+  @param  EndTimeStamp            Pointer to the 64-bit time stamp that was recorded when the measurement
+                                  was ended.
+  @param  Identifier              Pointer to the 32-bit identifier that was recorded.
+
+  @return The key for the next performance log entry (in general case).
+
+**/
+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 0;
+}
+
+/**
+  Creates a record for the beginning of a performance measurement.
+
+  If TimeStamp is zero, then this function reads the current time stamp
+  and adds that time stamp value to the record as the start time.
+
+  If TimeStamp is one, then this function reads 0 as the start time.
+
+  If TimeStamp is other value, then TimeStamp is added to the record as the start time.
+
+  @param  Handle                  Pointer to environment specific context used
+                                  to identify the component being measured.
+  @param  Token                   Pointer to a Null-terminated ASCII string
+                                  that identifies the component being measured.
+  @param  Module                  Pointer to a Null-terminated ASCII string
+                                  that identifies the module being measured.
+  @param  TimeStamp               64-bit time stamp.
+
+  @retval RETURN_SUCCESS          The start of the measurement was recorded.
+  @retval RETURN_OUT_OF_RESOURCES There are not enough resources to record the measurement.
+
+**/
+RETURN_STATUS
+EFIAPI
+StartPerformanceMeasurement (
+  IN CONST VOID   *Handle,  OPTIONAL
+  IN CONST CHAR8  *Token,   OPTIONAL
+  IN CONST CHAR8  *Module,  OPTIONAL
+  IN UINT64       TimeStamp
+  )
+{
+  return StartPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0);
+}
+
+/**
+
+  Creates a record for the end of a performance measurement.
+
+  If the TimeStamp is not zero or one, then TimeStamp is added to the record as the end time.
+  If the TimeStamp is zero, then this function reads the current time stamp and adds that time stamp value to the record as the end time.
+  If the TimeStamp is one, then this function reads 0 as the end time.
+
+  @param  Handle                  Pointer to environment specific context used
+                                  to identify the component being measured.
+  @param  Token                   Pointer to a Null-terminated ASCII string
+                                  that identifies the component being measured.
+  @param  Module                  Pointer to a Null-terminated ASCII string
+                                  that identifies the module being measured.
+  @param  TimeStamp               64-bit time stamp.
+
+  @retval RETURN_SUCCESS          The end of  the measurement was recorded.
+  @retval RETURN_NOT_FOUND        The specified measurement record could not be found.
+
+**/
+RETURN_STATUS
+EFIAPI
+EndPerformanceMeasurement (
+  IN CONST VOID   *Handle,  OPTIONAL
+  IN CONST CHAR8  *Token,   OPTIONAL
+  IN CONST CHAR8  *Module,  OPTIONAL
+  IN UINT64       TimeStamp
+  )
+{
+  return EndPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0);
+}
+
+/**
+  Attempts to retrieve a performance measurement log entry from the performance measurement log.
+  It can also retrieve the log created by StartPerformanceMeasurementEx and EndPerformanceMeasurementEx,
+  and then eliminate the Identifier.
+
+  Attempts to retrieve the performance log entry specified by LogEntryKey.  If LogEntryKey is
+  zero on entry, then an attempt is made to retrieve the first entry from the performance log,
+  and the key for the second entry in the log is returned.  If the performance log is empty,
+  then no entry is retrieved and zero is returned.  If LogEntryKey is not zero, then the performance
+  log entry associated with LogEntryKey is retrieved, and the key for the next entry in the log is
+  returned.  If LogEntryKey is the key for the last entry in the log, then the last log entry is
+  retrieved and an implementation specific non-zero key value that specifies the end of the performance
+  log is returned.  If LogEntryKey is equal this implementation specific non-zero key value, then no entry
+  is retrieved and zero is returned.  In the cases where a performance log entry can be returned,
+  the log entry is returned in Handle, Token, Module, StartTimeStamp, and EndTimeStamp.
+  If LogEntryKey is not a valid log entry key for the performance measurement log, then ASSERT().
+  If Handle is NULL, then ASSERT().
+  If Token is NULL, then ASSERT().
+  If Module is NULL, then ASSERT().
+  If StartTimeStamp is NULL, then ASSERT().
+  If EndTimeStamp is NULL, then ASSERT().
+
+  NOT Support yet.
+
+  @param  LogEntryKey             On entry, the key of the performance measurement log entry to retrieve.
+                                  0, then the first performance measurement log entry is retrieved.
+                                  On exit, the key of the next performance of entry entry.
+  @param  Handle                  Pointer to environment specific context used to identify the component
+                                  being measured.
+  @param  Token                   Pointer to a Null-terminated ASCII string that identifies the component
+                                  being measured.
+  @param  Module                  Pointer to a Null-terminated ASCII string that identifies the module
+                                  being measured.
+  @param  StartTimeStamp          Pointer to the 64-bit time stamp that was recorded when the measurement
+                                  was started.
+  @param  EndTimeStamp            Pointer to the 64-bit time stamp that was recorded when the measurement
+                                  was ended.
+
+  @return The key for the next performance log entry (in general case).
+
+**/
+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 0;
+}
+
+/**
+  Returns TRUE if the performance measurement macros are enabled.
+
+  This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
+  PcdPerformanceLibraryPropertyMask is set.  Otherwise FALSE is returned.
+
+  @retval TRUE                    The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
+                                  PcdPerformanceLibraryPropertyMask is set.
+  @retval FALSE                   The PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
+                                  PcdPerformanceLibraryPropertyMask is clear.
+
+**/
+BOOLEAN
+EFIAPI
+PerformanceMeasurementEnabled (
+  VOID
+  )
+{
+  return (BOOLEAN) ((PcdGet8(PcdPerformanceLibraryPropertyMask) & PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED) != 0);
+}
+
+/**
+  Create performance record with event description and a timestamp.
+
+  @param CallerIdentifier  - Image handle or pointer to caller ID GUID
+  @param Guid              - Pointer to a GUID
+  @param String            - Pointer to a string describing the measurement
+  @param Address           - Pointer to a location in memory relevant to the measurement
+  @param Identifier        - Performance identifier describing the type of measurement
+
+  @retval RETURN_SUCCESS           - Successfully created performance record
+  @retval RETURN_OUT_OF_RESOURCES  - Ran out of space to store the records
+  @retval RETURN_INVALID_PARAMETER - Invalid parameter passed to function - NULL
+                                     pointer or invalid PerfId
+
+**/
+RETURN_STATUS
+EFIAPI
+LogPerformanceMeasurement (
+  IN CONST VOID   *CallerIdentifier,
+  IN CONST VOID   *Guid,    OPTIONAL
+  IN CONST CHAR8  *String,  OPTIONAL
+  IN UINT64       Address, OPTIONAL
+  IN UINT32       Identifier
+  )
+{
+  return (RETURN_STATUS)CreatePerformanceMeasurement (CallerIdentifier, Guid, String, 0, Address, (UINT16)Identifier, PerfEntry);
+}
+
+/**
+  Check whether the specified performance measurement can be logged.
+
+  This function returns TRUE when the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of PcdPerformanceLibraryPropertyMask is set
+  and the Type disable bit in PcdPerformanceLibraryPropertyMask is not set.
+
+  @param Type        - Type of the performance measurement entry.
+
+  @retval TRUE         The performance measurement can be logged.
+  @retval FALSE        The performance measurement can NOT be logged.
+
+**/
+BOOLEAN
+EFIAPI
+LogPerformanceMeasurementEnabled (
+  IN  CONST UINTN        Type
+  )
+{
+  //
+  // When Performance measurement is enabled and the type is not filtered, the performance can be logged.
+  //
+  if (PerformanceMeasurementEnabled () && (PcdGet8(PcdPerformanceLibraryPropertyMask) & Type) == 0) {
+    return TRUE;
+  }
+  return FALSE;
+}
diff --git a/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.inf b/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.inf
new file mode 100644
index 0000000000..c1e2599453
--- /dev/null
+++ b/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.inf
@@ -0,0 +1,49 @@
+## @file
+#  Performance library instance used for PEIMs.
+#
+#  This library provides the performance measurement interfaces in PEI phase, it locates
+#  performance measurement PPI to log the performance data.
+#
+#  Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which accompanies this distribution.  The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php
+#
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010005
+  BASE_NAME                      = PeiPerformancePpiLib
+  MODULE_UNI_FILE                = PeiPerformancePpiLib.uni
+  FILE_GUID                      = 9B94A34B-7B29-4358-9AB1-09960806FB9A
+  MODULE_TYPE                    = PEIM
+  VERSION_STRING                 = 1.0
+  LIBRARY_CLASS                  = PerformanceLib|PEIM SEC
+
+#
+# The following information is for reference only and not required by the build tools.
+#
+# VALID_ARCHITECTURES           = IA32 X64 EBC (EBC is for build only)
+#
+
+[Sources]
+  PeiPerformancePpiLib.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+  PcdLib
+  DebugLib
+  PeiServicesLib
+
+[Guids]
+  gEdkiiPerformanceMeasurementPpiGuid
+
+[Pcd]
+  gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask         ## CONSUMES
diff --git a/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.uni b/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.uni
new file mode 100644
index 0000000000..081f3767e1
--- /dev/null
+++ b/MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.uni
@@ -0,0 +1,23 @@
+// /** @file
+// Performance library instance used for PEIMs.
+//
+// This library provides the performance measurement interfaces in PEI phase, it locates
+// performance measurement PPI to log the performance data.
+//
+// Copyright (c) 2018, Intel Corporation. All rights reserved.<BR>
+//
+// This program and the accompanying materials
+// are licensed and made available under the terms and conditions of the BSD License
+// which accompanies this distribution.  The full text of the license may be found at
+// http://opensource.org/licenses/bsd-license.php
+//
+// THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+// WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+//
+// **/
+
+
+#string STR_MODULE_ABSTRACT             #language en-US "Performance library instance used for PEIMs"
+
+#string STR_MODULE_DESCRIPTION          #language en-US "This library provides the performance measurement interfaces in the PEI phase, it locates performance measurement PPI to log the performance data."
+
diff --git a/MdeModulePkg/MdeModulePkg.dsc b/MdeModulePkg/MdeModulePkg.dsc
index bb7744894a..ef7b46fedc 100644
--- a/MdeModulePkg/MdeModulePkg.dsc
+++ b/MdeModulePkg/MdeModulePkg.dsc
@@ -288,10 +288,11 @@
   MdeModulePkg/Library/DxeResetSystemLib/DxeResetSystemLib.inf
   MdeModulePkg/Library/DxeUdpIoLib/DxeUdpIoLib.inf
   MdeModulePkg/Library/DxePrintLibPrint2Protocol/DxePrintLibPrint2Protocol.inf
   MdeModulePkg/Library/PeiCrc32GuidedSectionExtractLib/PeiCrc32GuidedSectionExtractLib.inf
   MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf
+  MdeModulePkg/Library/PeiPerformancePpiLib/PeiPerformancePpiLib.inf
   MdeModulePkg/Library/PeiRecoveryLibNull/PeiRecoveryLibNull.inf
   MdeModulePkg/Library/PeiResetSystemLib/PeiResetSystemLib.inf
   MdeModulePkg/Library/PeiS3LibNull/PeiS3LibNull.inf
   MdeModulePkg/Library/UefiHiiLib/UefiHiiLib.inf
   MdeModulePkg/Library/ResetUtilityLib/ResetUtilityLib.inf
-- 
2.14.3.windows.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-07-30  7:00 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-07-30  6:59 [patch 0/3] Add PeiPerformancePpiLib Dandan Bi
2018-07-30  6:59 ` [patch 1/3] MdeModulePkg: Add the definition of performance measurement PPI Dandan Bi
2018-07-30  6:59 ` [patch 2/3] MdeModulePkg/PeiPerformanceLib: Produce the new PerformancePpi Dandan Bi
2018-07-30  6:59 ` [patch 3/3] MdeModulePkg/PeiPerformancePpiLib: Add PeiPerformancePpiLib Dandan Bi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox