From: Dandan Bi <dandan.bi@intel.com>
To: edk2-devel@lists.01.org
Cc: Liming Gao <liming.gao@intel.com>, Star Zeng <star.zeng@intel.com>
Subject: [patch V2 2/9] MdeModulePkg: Update Performance instances to use new protocol
Date: Fri, 22 Jun 2018 16:56:16 +0800 [thread overview]
Message-ID: <20180622085623.154924-3-dandan.bi@intel.com> (raw)
In-Reply-To: <20180622085623.154924-1-dandan.bi@intel.com>
Update Performance instances in MdeModulePkg to use new
PerformanceMeasurement protocol.
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>
---
.../DxeCorePerformanceLib/DxeCorePerformanceLib.c | 325 +++++---------------
.../DxeCorePerformanceLib.inf | 6 +-
.../DxeCorePerformanceLibInternal.h | 216 ++------------
.../Library/DxePerformanceLib/DxePerformanceLib.c | 125 +++-----
.../DxePerformanceLib/DxePerformanceLib.inf | 5 +-
.../SmmCorePerformanceLib/SmmCorePerformanceLib.c | 327 +++++----------------
.../SmmCorePerformanceLib.inf | 7 +-
.../SmmCorePerformanceLibInternal.h | 215 ++------------
.../Library/SmmPerformanceLib/SmmPerformanceLib.c | 130 +++-----
.../SmmPerformanceLib/SmmPerformanceLib.inf | 5 +-
10 files changed, 283 insertions(+), 1078 deletions(-)
diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
index 68b29ac5a9e..79820605184 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c
@@ -80,25 +80,14 @@ UINT8 *mBootRecordBuffer = NULL;
BOOLEAN mLockInsertRecord = FALSE;
EFI_DEVICE_PATH_TO_TEXT_PROTOCOL *mDevicePathToText = NULL;
//
-// Interfaces for Performance Protocol.
+// Interfaces for PerformanceMeasurement Protocol.
//
-PERFORMANCE_PROTOCOL mPerformanceInterface = {
- StartGauge,
- EndGauge,
- GetGauge
- };
-
-//
-// Interfaces for PerformanceEx Protocol.
-//
-PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = {
- StartGaugeEx,
- EndGaugeEx,
- GetGaugeEx
+EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface = {
+ CreatePerformanceMeasurement,
};
PERFORMANCE_PROPERTY mPerformanceProperty;
/**
@@ -797,22 +786,15 @@ InsertFpdtMeasurement (
StringPtr = NULL;
UseModuleName = FALSE;
ZeroMem (ModuleName, sizeof (ModuleName));
- if (mLockInsertRecord) {
- return EFI_UNSUPPORTED;
- }
-
- mLockInsertRecord = TRUE;
-
//
// Get record info (type, size, ProgressID and Module Guid).
//
Status = GetFpdtRecordInfo (IsStart, Handle, Token, Module, &RecordInfo, &UseModuleName);
if (EFI_ERROR (Status)) {
- mLockInsertRecord = FALSE;
return Status;
}
//
// If PERF_START()/PERF_END() have specified the ProgressID,it has high priority.
@@ -822,11 +804,10 @@ InsertFpdtMeasurement (
// If it is start pref: the lower 4 bits of the ID should be 0.
// If it is end pref: the lower 4 bits of the ID should not be 0.
// If input ID doesn't follow the rule, we will adjust it.
//
if ((Identifier != 0) && (IsKnownID (Identifier)) && (!IsKnownTokens (Token))) {
- mLockInsertRecord = FALSE;
return EFI_UNSUPPORTED;
} else if ((Identifier != 0) && (!IsKnownID (Identifier)) && (!IsKnownTokens (Token))) {
if (IsStart && ((Identifier & 0x000F) != 0)) {
Identifier &= 0xFFF0;
} else if ((!IsStart) && ((Identifier & 0x000F) == 0)) {
@@ -842,11 +823,10 @@ InsertFpdtMeasurement (
if (mBootRecordSize + RecordInfo.RecordSize > mBootRecordMaxSize) {
if (!mLackSpaceIsReported) {
DEBUG ((DEBUG_INFO, "DxeCorePerformanceLib: No enough space to save boot records\n"));
mLackSpaceIsReported = TRUE;
}
- mLockInsertRecord = FALSE;
return EFI_OUT_OF_RESOURCES;
} else {
//
// Save boot record into BootPerformance table
//
@@ -864,11 +844,10 @@ InsertFpdtMeasurement (
mPerformanceLength + RecordInfo.RecordSize + FIRMWARE_RECORD_BUFFER,
mPerformancePointer
);
if (mPerformancePointer == NULL) {
- mLockInsertRecord = FALSE;
return EFI_OUT_OF_RESOURCES;
}
mMaxPerformanceLength = mPerformanceLength + RecordInfo.RecordSize + FIRMWARE_RECORD_BUFFER;
}
//
@@ -961,15 +940,13 @@ InsertFpdtMeasurement (
default:
//
// Record is not supported in current DXE phase, return EFI_ABORTED
//
- mLockInsertRecord = FALSE;
return EFI_UNSUPPORTED;
}
- mLockInsertRecord = FALSE;
return EFI_SUCCESS;
}
/**
Dumps all the PEI performance.
@@ -1061,223 +1038,10 @@ ReportFpdtRecordBuffer (
//
mFpdtBufferIsReported = TRUE;
}
}
-/**
- Adds a record at the end of the performance measurement log
- that records the start time of a performance measurement.
-
- Adds a record to the end of the performance measurement log
- that contains the Handle, Token, Module and Identifier.
- The end time of the new record must be set to zero.
- If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
- If TimeStamp is zero, the start time in the record is filled in with the value
- read from the current time stamp.
-
- @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 StartGauge of PERFORMANCE_PROTOCOL.
-
- @retval EFI_SUCCESS The data was read correctly from the device.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
-
-**/
-EFI_STATUS
-EFIAPI
-StartGaugeEx (
- IN CONST VOID *Handle, OPTIONAL
- IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp,
- IN UINT32 Identifier
- )
-{
- return InsertFpdtMeasurement (TRUE, Handle, Token, Module, TimeStamp, Identifier);
-}
-
-/**
- Searches the performance measurement log from the beginning of the log
- for the first matching record that contains a zero end time and fills in a valid end time.
-
- Searches the performance measurement log from the beginning of the log
- for the first record that matches Handle, Token, Module and Identifier and has an end time value of zero.
- If the record can not be found then return EFI_NOT_FOUND.
- If the record is found and TimeStamp is not zero,
- then the end time in the record is filled in with the value specified by TimeStamp.
- If the record is found and TimeStamp is zero, then the end time in the matching record
- is filled in with the current time stamp value.
-
- @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 EndGauge of PERFORMANCE_PROTOCOL.
-
- @retval EFI_SUCCESS The end of the measurement was recorded.
- @retval EFI_NOT_FOUND The specified measurement record could not be found.
-
-**/
-EFI_STATUS
-EFIAPI
-EndGaugeEx (
- IN CONST VOID *Handle, OPTIONAL
- IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp,
- IN UINT32 Identifier
- )
-{
- return InsertFpdtMeasurement (FALSE, Handle, Token, Module, TimeStamp, Identifier);
-}
-
-/**
- Retrieves a previously logged performance measurement.
- It can also retrieve the log created by StartGauge and EndGauge of PERFORMANCE_PROTOCOL,
- and then assign the Identifier with 0.
-
- !!! Not support!!!
-
- Retrieves the performance log entry from the performance log specified by LogEntryKey.
- If it stands for a valid entry, then EFI_SUCCESS is returned and
- GaugeDataEntryEx stores the pointer to that entry.
-
- @param LogEntryKey The key for the previous performance measurement log entry.
- If 0, then the first performance measurement log entry is retrieved.
- @param GaugeDataEntryEx The indirect pointer to the extended gauge data entry specified by LogEntryKey
- if the retrieval is successful.
-
- @retval EFI_SUCCESS The GuageDataEntryEx is successfully found based on LogEntryKey.
- @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).
- @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).
- @retval EFI_INVALIDE_PARAMETER GaugeDataEntryEx is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-GetGaugeEx (
- IN UINTN LogEntryKey,
- OUT GAUGE_DATA_ENTRY_EX **GaugeDataEntryEx
- )
-{
- return EFI_UNSUPPORTED;
-}
-
-/**
- Adds a record at the end of the performance measurement log
- that records the start time of a performance measurement.
-
- Adds a record to the end of the performance measurement log
- that contains the Handle, Token, and Module.
- The end time of the new record must be set to zero.
- If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
- If TimeStamp is zero, the start time in the record is filled in with the value
- read from the current time stamp.
-
- @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 EFI_SUCCESS The data was read correctly from the device.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
-
-**/
-EFI_STATUS
-EFIAPI
-StartGauge (
- IN CONST VOID *Handle, OPTIONAL
- IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
- )
-{
- return StartGaugeEx (Handle, Token, Module, TimeStamp, 0);
-}
-
-/**
- Searches the performance measurement log from the beginning of the log
- for the first matching record that contains a zero end time and fills in a valid end time.
-
- Searches the performance measurement log from the beginning of the log
- for the first record that matches Handle, Token, and Module and has an end time value of zero.
- If the record can not be found then return EFI_NOT_FOUND.
- If the record is found and TimeStamp is not zero,
- then the end time in the record is filled in with the value specified by TimeStamp.
- If the record is found and TimeStamp is zero, then the end time in the matching record
- is filled in with the current time stamp value.
-
- @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 EFI_SUCCESS The end of the measurement was recorded.
- @retval EFI_NOT_FOUND The specified measurement record could not be found.
-
-**/
-EFI_STATUS
-EFIAPI
-EndGauge (
- IN CONST VOID *Handle, OPTIONAL
- IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
- )
-{
- return EndGaugeEx (Handle, Token, Module, TimeStamp, 0);
-}
-
-/**
- Retrieves a previously logged performance measurement.
- It can also retrieve the log created by StartGaugeEx and EndGaugeEx of PERFORMANCE_EX_PROTOCOL,
- and then eliminate the Identifier.
-
- !!! Not support!!!
-
- Retrieves the performance log entry from the performance log specified by LogEntryKey.
- If it stands for a valid entry, then EFI_SUCCESS is returned and
- GaugeDataEntry stores the pointer to that entry.
-
- @param LogEntryKey The key for the previous performance measurement log entry.
- If 0, then the first performance measurement log entry is retrieved.
- @param GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey
- if the retrieval is successful.
-
- @retval EFI_SUCCESS The GuageDataEntry is successfully found based on LogEntryKey.
- @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).
- @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).
- @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-GetGauge (
- IN UINTN LogEntryKey,
- OUT GAUGE_DATA_ENTRY **GaugeDataEntry
- )
-{
- return EFI_UNSUPPORTED;
-}
-
-
/**
The constructor function initializes Performance infrastructure for DXE phase.
The constructor function publishes Performance and PerformanceEx protocol, allocates memory to log DXE performance
and merges PEI performance data to DXE performance log.
@@ -1317,14 +1081,12 @@ DxeCorePerformanceLibConstructor (
// Install the protocol interfaces for DXE performance library instance.
//
Handle = NULL;
Status = gBS->InstallMultipleProtocolInterfaces (
&Handle,
- &gPerformanceProtocolGuid,
- &mPerformanceInterface,
- &gPerformanceExProtocolGuid,
- &mPerformanceExInterface,
+ &gEdkiiPerformanceMeasurementProtocolGuid,
+ &mPerformanceMeasurementInterface,
NULL
);
ASSERT_EFI_ERROR (Status);
//
@@ -1357,10 +1119,59 @@ DxeCorePerformanceLibConstructor (
}
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
+CreatePerformanceMeasurement (
+ 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
+ )
+{
+ EFI_STATUS Status;
+
+ Status = EFI_SUCCESS;
+
+ if (mLockInsertRecord) {
+ return EFI_INVALID_PARAMETER;
+ }
+ mLockInsertRecord = TRUE;
+
+ if (Attribute == PerfStartEntry) {
+ Status = InsertFpdtMeasurement (TRUE, CallerIdentifier, String, String, TimeStamp, Identifier);
+ } else if (Attribute == PerfEndEntry) {
+ Status = InsertFpdtMeasurement (FALSE, CallerIdentifier, String, String, TimeStamp, Identifier);
+ }
+ mLockInsertRecord = FALSE;
+
+ return Status;
+}
+
/**
Adds a record at the end of the performance measurement log
that records the start time of a performance measurement.
Adds a record to the end of the performance measurement log
@@ -1392,11 +1203,21 @@ StartPerformanceMeasurementEx (
IN CONST CHAR8 *Module, OPTIONAL
IN UINT64 TimeStamp,
IN UINT32 Identifier
)
{
- return InsertFpdtMeasurement (TRUE, Handle, Token, Module, TimeStamp, Identifier);
+ CONST CHAR8 *String;
+
+ if (Token != NULL) {
+ String = Token;
+ } else if (Module != NULL) {
+ String = Module;
+ } else {
+ String = NULL;
+ }
+
+ return (RETURN_STATUS)CreatePerformanceMeasurement (Handle, NULL, String, TimeStamp, 0, Identifier, PerfStartEntry);
}
/**
Searches the performance measurement log from the beginning of the log
for the first matching record that contains a zero end time and fills in a valid end time.
@@ -1431,11 +1252,21 @@ EndPerformanceMeasurementEx (
IN CONST CHAR8 *Module, OPTIONAL
IN UINT64 TimeStamp,
IN UINT32 Identifier
)
{
- return InsertFpdtMeasurement (FALSE, Handle, Token, Module, TimeStamp, Identifier);
+ CONST CHAR8 *String;
+
+ if (Token != NULL) {
+ String = Token;
+ } else if (Module != NULL) {
+ String = Module;
+ } else {
+ String = NULL;
+ }
+
+ return (RETURN_STATUS)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,
@@ -1525,11 +1356,11 @@ StartPerformanceMeasurement (
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
IN UINT64 TimeStamp
)
{
- return InsertFpdtMeasurement (TRUE, Handle, Token, Module, TimeStamp, 0);
+ return StartPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0);
}
/**
Searches the performance measurement log from the beginning of the log
for the first matching record that contains a zero end time and fills in a valid end time.
@@ -1561,11 +1392,11 @@ EndPerformanceMeasurement (
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
IN UINT64 TimeStamp
)
{
- return InsertFpdtMeasurement (FALSE, Handle, Token, Module, TimeStamp, 0);
+ 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,
diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf
index e752a93d837..68cd76da5b3 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf
@@ -65,22 +65,18 @@
[Protocols]
gEfiSmmCommunicationProtocolGuid ## SOMETIMES_CONSUMES
[Guids]
- ## SOMETIMES_CONSUMES ## HOB
- ## PRODUCES ## UNDEFINED # Install protocol
## PRODUCES ## SystemTable
gPerformanceProtocolGuid
- ## SOMETIMES_CONSUMES ## HOB
- ## PRODUCES ## UNDEFINED # Install protocol
- gPerformanceExProtocolGuid
gZeroGuid ## SOMETIMES_CONSUMES ## GUID
gEfiFirmwarePerformanceGuid ## SOMETIMES_PRODUCES ## UNDEFINED # StatusCode Data
gEdkiiFpdtExtendedFirmwarePerformanceGuid ## SOMETIMES_CONSUMES ## HOB # StatusCode Data
gEfiEventReadyToBootGuid ## CONSUMES ## Event
gEdkiiPiSmmCommunicationRegionTableGuid ## SOMETIMES_CONSUMES ## SystemTable
+ gEdkiiPerformanceMeasurementProtocolGuid ## PRODUCES ## UNDEFINED # Install protocol
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdEdkiiFpdtStringRecordEnableOnly ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdExtFpdtBootRecordPadSize ## CONSUMES
diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h
index 7e79675f940..f9800e34941 100644
--- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h
+++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h
@@ -20,10 +20,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <PiDxe.h>
#include <Guid/Performance.h>
+#include <Guid/PerformanceMeasurement.h>
#include <Guid/ExtendedFirmwarePerformance.h>
#include <Guid/ZeroGuid.h>
#include <Guid/EventGroup.h>
#include <Guid/FirmwarePerformance.h>
#include <Guid/PiSmmCommunicationRegionTable.h>
@@ -47,203 +48,36 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/UefiLib.h>
#include <Library/ReportStatusCodeLib.h>
#include <Library/DxeServicesLib.h>
#include <Library/PeCoffGetEntryPointLib.h>
-//
-// Interface declarations for PerformanceEx Protocol.
-//
/**
- Adds a record at the end of the performance measurement log
- that records the start time of a performance measurement.
-
- Adds a record to the end of the performance measurement log
- that contains the Handle, Token, Module and Identifier.
- The end time of the new record must be set to zero.
- If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
- If TimeStamp is zero, the start time in the record is filled in with the value
- read from the current time stamp.
-
- @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 StartGauge of PERFORMANCE_PROTOCOL.
-
- @retval EFI_SUCCESS The data was read correctly from the device.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
-
-**/
-EFI_STATUS
-EFIAPI
-StartGaugeEx (
- IN CONST VOID *Handle, OPTIONAL
- IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp,
- IN UINT32 Identifier
- );
-
-/**
- Searches the performance measurement log from the beginning of the log
- for the first matching record that contains a zero end time and fills in a valid end time.
-
- Searches the performance measurement log from the beginning of the log
- for the first record that matches Handle, Token, Module and Identifier and has an end time value of zero.
- If the record can not be found then return EFI_NOT_FOUND.
- If the record is found and TimeStamp is not zero,
- then the end time in the record is filled in with the value specified by TimeStamp.
- If the record is found and TimeStamp is zero, then the end time in the matching record
- is filled in with the current time stamp value.
-
- @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 EndGauge of PERFORMANCE_PROTOCOL.
-
- @retval EFI_SUCCESS The end of the measurement was recorded.
- @retval EFI_NOT_FOUND The specified measurement record could not be found.
-
+ 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
-EndGaugeEx (
- IN CONST VOID *Handle, OPTIONAL
- IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp,
- IN UINT32 Identifier
+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
);
-/**
- Retrieves a previously logged performance measurement.
- It can also retrieve the log created by StartGauge and EndGauge of PERFORMANCE_PROTOCOL,
- and then assign the Identifier with 0.
-
- Retrieves the performance log entry from the performance log specified by LogEntryKey.
- If it stands for a valid entry, then EFI_SUCCESS is returned and
- GaugeDataEntryEx stores the pointer to that entry.
-
- @param LogEntryKey The key for the previous performance measurement log entry.
- If 0, then the first performance measurement log entry is retrieved.
- @param GaugeDataEntryEx The indirect pointer to the extended gauge data entry specified by LogEntryKey
- if the retrieval is successful.
-
- @retval EFI_SUCCESS The GuageDataEntryEx is successfully found based on LogEntryKey.
- @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).
- @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).
- @retval EFI_INVALIDE_PARAMETER GaugeDataEntryEx is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-GetGaugeEx (
- IN UINTN LogEntryKey,
- OUT GAUGE_DATA_ENTRY_EX **GaugeDataEntryEx
- );
-
-//
-// Interface declarations for Performance Protocol.
-//
-/**
- Adds a record at the end of the performance measurement log
- that records the start time of a performance measurement.
-
- Adds a record to the end of the performance measurement log
- that contains the Handle, Token, and Module.
- The end time of the new record must be set to zero.
- If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
- If TimeStamp is zero, the start time in the record is filled in with the value
- read from the current time stamp.
-
- @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 EFI_SUCCESS The data was read correctly from the device.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
-
-**/
-EFI_STATUS
-EFIAPI
-StartGauge (
- IN CONST VOID *Handle, OPTIONAL
- IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
- );
-
-/**
- Searches the performance measurement log from the beginning of the log
- for the first matching record that contains a zero end time and fills in a valid end time.
-
- Searches the performance measurement log from the beginning of the log
- for the first record that matches Handle, Token, and Module and has an end time value of zero.
- If the record can not be found then return EFI_NOT_FOUND.
- If the record is found and TimeStamp is not zero,
- then the end time in the record is filled in with the value specified by TimeStamp.
- If the record is found and TimeStamp is zero, then the end time in the matching record
- is filled in with the current time stamp value.
-
- @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 EFI_SUCCESS The end of the measurement was recorded.
- @retval EFI_NOT_FOUND The specified measurement record could not be found.
-
-**/
-EFI_STATUS
-EFIAPI
-EndGauge (
- IN CONST VOID *Handle, OPTIONAL
- IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
- );
-
-/**
- Retrieves a previously logged performance measurement.
- It can also retrieve the log created by StartGaugeEx and EndGaugeEx of PERFORMANCE_EX_PROTOCOL,
- and then eliminate the Identifier.
-
- Retrieves the performance log entry from the performance log specified by LogEntryKey.
- If it stands for a valid entry, then EFI_SUCCESS is returned and
- GaugeDataEntry stores the pointer to that entry.
-
- @param LogEntryKey The key for the previous performance measurement log entry.
- If 0, then the first performance measurement log entry is retrieved.
- @param GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey
- if the retrieval is successful.
-
- @retval EFI_SUCCESS The GuageDataEntry is successfully found based on LogEntryKey.
- @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).
- @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).
- @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-GetGauge (
- IN UINTN LogEntryKey,
- OUT GAUGE_DATA_ENTRY **GaugeDataEntry
- );
-
-
#endif
diff --git a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c
index cb62d522f3d..9ed50d22b8d 100644
--- a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c
+++ b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c
@@ -18,22 +18,21 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <PiDxe.h>
-#include <Guid/Performance.h>
+#include <Guid/PerformanceMeasurement.h>
#include <Library/PerformanceLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/PcdLib.h>
//
// The cached Performance Protocol and PerformanceEx Protocol interface.
//
-PERFORMANCE_PROTOCOL *mPerformance = NULL;
-PERFORMANCE_EX_PROTOCOL *mPerformanceEx = NULL;
+EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *mPerformanceMeasurement = NULL;
/**
The function caches the pointers to PerformanceEx protocol and Performance Protocol.
The function locates PerformanceEx protocol and Performance Protocol from protocol database.
@@ -41,39 +40,28 @@ PERFORMANCE_EX_PROTOCOL *mPerformanceEx = NULL;
@retval EFI_SUCCESS PerformanceEx protocol or Performance Protocol is successfully located.
@retval EFI_NOT_FOUND Both PerformanceEx protocol and Performance Protocol are not located to log performance.
**/
EFI_STATUS
-GetPerformanceProtocol (
+GetPerformanceMeasurementProtocol (
VOID
)
{
EFI_STATUS Status;
- PERFORMANCE_PROTOCOL *Performance;
- PERFORMANCE_EX_PROTOCOL *PerformanceEx;
+ EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *PerformanceMeasurement;
- if (mPerformanceEx != NULL || mPerformance != NULL) {
+ if (mPerformanceMeasurement != NULL) {
return EFI_SUCCESS;
}
- Status = gBS->LocateProtocol (&gPerformanceExProtocolGuid, NULL, (VOID **) &PerformanceEx);
+ Status = gBS->LocateProtocol (&gEdkiiPerformanceMeasurementProtocolGuid, NULL, (VOID **) &PerformanceMeasurement);
if (!EFI_ERROR (Status)) {
- ASSERT (PerformanceEx != NULL);
+ ASSERT (PerformanceMeasurement != NULL);
//
- // Cache PerformanceEx Protocol.
+ // Cache PerformanceMeasurement Protocol.
//
- mPerformanceEx = PerformanceEx;
- return EFI_SUCCESS;
- }
-
- Status = gBS->LocateProtocol (&gPerformanceProtocolGuid, NULL, (VOID **) &Performance);
- if (!EFI_ERROR (Status)) {
- ASSERT (Performance != NULL);
- //
- // Cache performance protocol.
- //
- mPerformance = Performance;
+ mPerformanceMeasurement = PerformanceMeasurement;
return EFI_SUCCESS;
}
return EFI_NOT_FOUND;
}
@@ -108,21 +96,28 @@ StartPerformanceMeasurementEx (
IN CONST CHAR8 *Module, OPTIONAL
IN UINT64 TimeStamp,
IN UINT32 Identifier
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ CONST CHAR8* String;
- Status = GetPerformanceProtocol ();
+ Status = GetPerformanceMeasurementProtocol ();
if (EFI_ERROR (Status)) {
- return RETURN_OUT_OF_RESOURCES;
+ return RETURN_NOT_FOUND;
+ }
+
+ if (Token != NULL) {
+ String = Token;
+ } else if (Module != NULL) {
+ String = Module;
+ } else {
+ String = NULL;
}
- if (mPerformanceEx != NULL) {
- Status = mPerformanceEx->StartGaugeEx (Handle, Token, Module, TimeStamp, Identifier);
- } else if (mPerformance != NULL) {
- Status = mPerformance->StartGauge (Handle, Token, Module, TimeStamp);
+ if (mPerformanceMeasurement != NULL) {
+ Status = mPerformanceMeasurement->CreatePerformanceMeasurement (Handle, NULL, String, TimeStamp, 0, Identifier, PerfStartEntry);
} else {
ASSERT (FALSE);
}
return (RETURN_STATUS) Status;
@@ -160,21 +155,28 @@ EndPerformanceMeasurementEx (
IN CONST CHAR8 *Module, OPTIONAL
IN UINT64 TimeStamp,
IN UINT32 Identifier
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ CONST CHAR8* String;
- Status = GetPerformanceProtocol ();
+ Status = GetPerformanceMeasurementProtocol ();
if (EFI_ERROR (Status)) {
return RETURN_NOT_FOUND;
}
- if (mPerformanceEx != NULL) {
- Status = mPerformanceEx->EndGaugeEx (Handle, Token, Module, TimeStamp, Identifier);
- } else if (mPerformance != NULL) {
- Status = mPerformance->EndGauge (Handle, Token, Module, TimeStamp);
+ if (Token != NULL) {
+ String = Token;
+ } else if (Module != NULL) {
+ String = Module;
+ } else {
+ String = NULL;
+ }
+
+ if (mPerformanceMeasurement != NULL) {
+ Status = mPerformanceMeasurement->CreatePerformanceMeasurement (Handle, NULL, String, TimeStamp, 0, Identifier, PerfEndEntry);
} else {
ASSERT (FALSE);
}
return (RETURN_STATUS) Status;
@@ -231,62 +233,12 @@ GetPerformanceMeasurementEx (
OUT UINT64 *StartTimeStamp,
OUT UINT64 *EndTimeStamp,
OUT UINT32 *Identifier
)
{
- EFI_STATUS Status;
- GAUGE_DATA_ENTRY_EX *GaugeData;
-
- GaugeData = NULL;
-
- ASSERT (Handle != NULL);
- ASSERT (Token != NULL);
- ASSERT (Module != NULL);
- ASSERT (StartTimeStamp != NULL);
- ASSERT (EndTimeStamp != NULL);
- ASSERT (Identifier != NULL);
-
- Status = GetPerformanceProtocol ();
- if (EFI_ERROR (Status)) {
- return 0;
- }
-
- if (mPerformanceEx != NULL) {
- Status = mPerformanceEx->GetGaugeEx (LogEntryKey++, &GaugeData);
- } else if (mPerformance != NULL) {
- Status = mPerformance->GetGauge (LogEntryKey++, (GAUGE_DATA_ENTRY **) &GaugeData);
- } else {
- ASSERT (FALSE);
- return 0;
- }
-
- //
- // Make sure that LogEntryKey is a valid log entry key,
- //
- ASSERT (Status != EFI_INVALID_PARAMETER);
-
- if (EFI_ERROR (Status)) {
- //
- // The LogEntryKey is the last entry (equals to the total entry number).
- //
- return 0;
- }
-
- ASSERT (GaugeData != NULL);
-
- *Handle = (VOID *) (UINTN) GaugeData->Handle;
- *Token = GaugeData->Token;
- *Module = GaugeData->Module;
- *StartTimeStamp = GaugeData->StartTimeStamp;
- *EndTimeStamp = GaugeData->EndTimeStamp;
- if (mPerformanceEx != NULL) {
- *Identifier = GaugeData->Identifier;
- } else {
- *Identifier = 0;
- }
+ return 0;
- return LogEntryKey;
}
/**
Creates a record for the beginning of a performance measurement.
@@ -401,12 +353,11 @@ GetPerformanceMeasurement (
OUT CONST CHAR8 **Module,
OUT UINT64 *StartTimeStamp,
OUT UINT64 *EndTimeStamp
)
{
- UINT32 Identifier;
- return GetPerformanceMeasurementEx (LogEntryKey, Handle, Token, Module, StartTimeStamp, EndTimeStamp, &Identifier);
+ return 0;
}
/**
Returns TRUE if the performance measurement macros are enabled.
diff --git a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
index edc63c6f0b6..c7d06a3a1b1 100644
--- a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
+++ b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf
@@ -4,11 +4,11 @@
# This library instance provides infrastructure for DXE phase drivers to log performance
# data. It consumes PerformanceEx or Performance Protocol published by DxeCorePerformanceLib
# to log performance data. If both PerformanceEx and Performance Protocol are not available,
# it does not log any performance information.
#
-# Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 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
#
@@ -46,12 +46,11 @@
UefiBootServicesTableLib
DebugLib
[Guids]
- gPerformanceProtocolGuid ## SOMETIMES_CONSUMES ## UNDEFINED # Locate protocol
- gPerformanceExProtocolGuid ## SOMETIMES_CONSUMES ## UNDEFINED # Locate protocol
+ gEdkiiPerformanceMeasurementProtocolGuid ## SOMETIMES_CONSUMES ## UNDEFINED # Locate protocol
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask ## CONSUMES
diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
index dbc1166f254..e630773562f 100644
--- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
+++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c
@@ -52,25 +52,14 @@ BOOLEAN mLackSpaceIsReport = FALSE;
CHAR8 *mPlatformLanguage = NULL;
SPIN_LOCK mSmmFpdtLock;
PERFORMANCE_PROPERTY mPerformanceProperty;
//
-// Interfaces for SMM Performance Protocol.
+// Interfaces for SMM PerformanceMeasurement Protocol.
//
-PERFORMANCE_PROTOCOL mPerformanceInterface = {
- StartGauge,
- EndGauge,
- GetGauge
-};
-
-//
-// Interfaces for SMM PerformanceEx Protocol.
-//
-PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = {
- StartGaugeEx,
- EndGaugeEx,
- GetGaugeEx
+EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL mPerformanceMeasurementInterface = {
+ CreatePerformanceMeasurement,
};
/**
Check whether the Token is a known one which is uesed by core.
@@ -641,239 +630,10 @@ InsertFpdtMeasurement (
mSmmBootPerformanceTable->Header.Length += FpdtRecordPtr.RecordHeader->Length;
return EFI_SUCCESS;
}
-/**
- Adds a record at the end of the performance measurement log
- that records the start time of a performance measurement.
-
- Adds a record to the end of the performance measurement log
- that contains the Handle, Token, Module and Identifier.
- The end time of the new record must be set to zero.
- If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
- If TimeStamp is zero, the start time in the record is filled in with the value
- read from the current time stamp.
-
- @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 StartGauge of PERFORMANCE_PROTOCOL.
-
- @retval EFI_SUCCESS The data was read correctly from the device.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
-
-**/
-EFI_STATUS
-EFIAPI
-StartGaugeEx (
- IN CONST VOID *Handle, OPTIONAL
- IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp,
- IN UINT32 Identifier
- )
-{
- EFI_STATUS Status;
-
- AcquireSpinLock (&mSmmFpdtLock);
-
- Status = InsertFpdtMeasurement (TRUE, Handle, Token, Module, TimeStamp, Identifier);
-
- ReleaseSpinLock (&mSmmFpdtLock);
-
- return Status;
-}
-
-/**
- Searches the performance measurement log from the beginning of the log
- for the first matching record that contains a zero end time and fills in a valid end time.
-
- Searches the performance measurement log from the beginning of the log
- for the first record that matches Handle, Token, Module and Identifier and has an end time value of zero.
- If the record can not be found then return EFI_NOT_FOUND.
- If the record is found and TimeStamp is not zero,
- then the end time in the record is filled in with the value specified by TimeStamp.
- If the record is found and TimeStamp is zero, then the end time in the matching record
- is filled in with the current time stamp value.
-
- @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 EndGauge of PERFORMANCE_PROTOCOL.
-
- @retval EFI_SUCCESS The end of the measurement was recorded.
- @retval EFI_NOT_FOUND The specified measurement record could not be found.
-
-**/
-EFI_STATUS
-EFIAPI
-EndGaugeEx (
- IN CONST VOID *Handle, OPTIONAL
- IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp,
- IN UINT32 Identifier
- )
-{
- EFI_STATUS Status;
-
- AcquireSpinLock (&mSmmFpdtLock);
-
- Status = InsertFpdtMeasurement (FALSE, Handle, Token, Module, TimeStamp, Identifier);
-
- ReleaseSpinLock (&mSmmFpdtLock);
-
- return Status;
-}
-
-/**
- Retrieves a previously logged performance measurement.
- It can also retrieve the log created by StartGauge and EndGauge of PERFORMANCE_PROTOCOL,
- and then assign the Identifier with 0.
-
- !!! Not Support!!!
-
- Retrieves the performance log entry from the performance log specified by LogEntryKey.
- If it stands for a valid entry, then EFI_SUCCESS is returned and
- GaugeDataEntryEx stores the pointer to that entry.
-
- @param LogEntryKey The key for the previous performance measurement log entry.
- If 0, then the first performance measurement log entry is retrieved.
- @param GaugeDataEntryEx The indirect pointer to the extended gauge data entry specified by LogEntryKey
- if the retrieval is successful.
-
- @retval EFI_SUCCESS The GuageDataEntryEx is successfully found based on LogEntryKey.
- @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).
- @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).
- @retval EFI_INVALIDE_PARAMETER GaugeDataEntryEx is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-GetGaugeEx (
- IN UINTN LogEntryKey,
- OUT GAUGE_DATA_ENTRY_EX **GaugeDataEntryEx
- )
-{
- return EFI_UNSUPPORTED;
-}
-
-/**
- Adds a record at the end of the performance measurement log
- that records the start time of a performance measurement.
-
- Adds a record to the end of the performance measurement log
- that contains the Handle, Token, and Module.
- The end time of the new record must be set to zero.
- If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
- If TimeStamp is zero, the start time in the record is filled in with the value
- read from the current time stamp.
-
- @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 EFI_SUCCESS The data was read correctly from the device.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
-
-**/
-EFI_STATUS
-EFIAPI
-StartGauge (
- IN CONST VOID *Handle, OPTIONAL
- IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
- )
-{
- return StartGaugeEx (Handle, Token, Module, TimeStamp, 0);
-}
-
-/**
- Searches the performance measurement log from the beginning of the log
- for the first matching record that contains a zero end time and fills in a valid end time.
-
- Searches the performance measurement log from the beginning of the log
- for the first record that matches Handle, Token, and Module and has an end time value of zero.
- If the record can not be found then return EFI_NOT_FOUND.
- If the record is found and TimeStamp is not zero,
- then the end time in the record is filled in with the value specified by TimeStamp.
- If the record is found and TimeStamp is zero, then the end time in the matching record
- is filled in with the current time stamp value.
-
- @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 EFI_SUCCESS The end of the measurement was recorded.
- @retval EFI_NOT_FOUND The specified measurement record could not be found.
-
-**/
-EFI_STATUS
-EFIAPI
-EndGauge (
- IN CONST VOID *Handle, OPTIONAL
- IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
- )
-{
- return EndGaugeEx (Handle, Token, Module, TimeStamp, 0);
-}
-
-/**
- Retrieves a previously logged performance measurement.
- It can also retrieve the log created by StartGaugeEx and EndGaugeEx of PERFORMANCE_EX_PROTOCOL,
- and then eliminate the Identifier.
-
- !!! Not Support!!!
-
- Retrieves the performance log entry from the performance log specified by LogEntryKey.
- If it stands for a valid entry, then EFI_SUCCESS is returned and
- GaugeDataEntry stores the pointer to that entry.
-
- @param LogEntryKey The key for the previous performance measurement log entry.
- If 0, then the first performance measurement log entry is retrieved.
- @param GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey
- if the retrieval is successful.
-
- @retval EFI_SUCCESS The GuageDataEntry is successfully found based on LogEntryKey.
- @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).
- @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).
- @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-GetGauge (
- IN UINTN LogEntryKey,
- OUT GAUGE_DATA_ENTRY **GaugeDataEntry
- )
-{
- return EFI_UNSUPPORTED;
-}
-
-
/**
SmmReadyToBoot protocol notification event handler.
@param Protocol Points to the protocol's unique identifier
@param Interface Points to the interface instance
@@ -940,20 +700,13 @@ InitializeSmmCorePerformanceLib (
// Install the protocol interfaces for SMM performance library instance.
//
Handle = NULL;
Status = gSmst->SmmInstallProtocolInterface (
&Handle,
- &gSmmPerformanceProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &mPerformanceInterface
- );
- ASSERT_EFI_ERROR (Status);
- Status = gSmst->SmmInstallProtocolInterface (
- &Handle,
- &gSmmPerformanceExProtocolGuid,
+ &gEdkiiSmmPerformanceMeasurementProtocolGuid,
EFI_NATIVE_INTERFACE,
- &mPerformanceExInterface
+ &mPerformanceMeasurementInterface
);
ASSERT_EFI_ERROR (Status);
Status = gSmst->SmmRegisterProtocolNotify (
&gEdkiiSmmReadyToBootProtocolGuid,
@@ -1029,10 +782,52 @@ SmmCorePerformanceLibConstructor (
ASSERT_EFI_ERROR (Status);
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
+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;
+
+ AcquireSpinLock (&mSmmFpdtLock);
+ if (Attribute == PerfStartEntry) {
+ Status = InsertFpdtMeasurement (TRUE, CallerIdentifier, String, String, TimeStamp, Identifier);
+ } else if (Attribute == PerfEndEntry) {
+ Status = InsertFpdtMeasurement (FALSE, CallerIdentifier, String, String, TimeStamp, Identifier);
+ }
+ ReleaseSpinLock (&mSmmFpdtLock);
+ return Status;
+}
+
/**
Adds a record at the end of the performance measurement log
that records the start time of a performance measurement.
Adds a record to the end of the performance measurement log
@@ -1064,11 +859,21 @@ StartPerformanceMeasurementEx (
IN CONST CHAR8 *Module, OPTIONAL
IN UINT64 TimeStamp,
IN UINT32 Identifier
)
{
- return (RETURN_STATUS) StartGaugeEx (Handle, Token, Module, TimeStamp, Identifier);
+ CONST CHAR8 *String;
+
+ if (Token != NULL) {
+ String = Token;
+ } else if (Module != NULL) {
+ String = Module;
+ } else {
+ String = NULL;
+ }
+
+ return (RETURN_STATUS)CreatePerformanceMeasurement (Handle, NULL, String, TimeStamp, 0, Identifier, PerfStartEntry);
}
/**
Searches the performance measurement log from the beginning of the log
for the first matching record that contains a zero end time and fills in a valid end time.
@@ -1103,11 +908,21 @@ EndPerformanceMeasurementEx (
IN CONST CHAR8 *Module, OPTIONAL
IN UINT64 TimeStamp,
IN UINT32 Identifier
)
{
- return (RETURN_STATUS) EndGaugeEx (Handle, Token, Module, TimeStamp, Identifier);
+ CONST CHAR8 *String;
+
+ if (Token != NULL) {
+ String = Token;
+ } else if (Module != NULL) {
+ String = Module;
+ } else {
+ String = NULL;
+ }
+
+ return (RETURN_STATUS)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,
@@ -1196,11 +1011,11 @@ StartPerformanceMeasurement (
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
IN UINT64 TimeStamp
)
{
- return StartGaugeEx (Handle, Token, Module, TimeStamp, 0);
+ return StartPerformanceMeasurementEx (Handle, Token, Module, TimeStamp, 0);
}
/**
Searches the performance measurement log from the beginning of the log
for the first matching record that contains a zero end time and fills in a valid end time.
@@ -1232,11 +1047,11 @@ EndPerformanceMeasurement (
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
IN UINT64 TimeStamp
)
{
- return EndGaugeEx (Handle, Token, Module, TimeStamp, 0);
+ 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,
diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf
index 01d8604eb61..61b92836657 100644
--- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf
+++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf
@@ -64,19 +64,14 @@
[Protocols]
gEfiSmmBase2ProtocolGuid ## CONSUMES
gEdkiiSmmReadyToBootProtocolGuid ## NOTIFY
[Guids]
- ## PRODUCES ## UNDEFINED # Install protocol
- ## CONSUMES ## UNDEFINED # SmiHandlerRegister
- gSmmPerformanceProtocolGuid
- ## PRODUCES ## UNDEFINED # Install protocol
- ## CONSUMES ## UNDEFINED # SmiHandlerRegister
- gSmmPerformanceExProtocolGuid
## PRODUCES ## SystemTable
gPerformanceProtocolGuid
gEdkiiFpdtExtendedFirmwarePerformanceGuid ## SOMETIMES_PRODUCES ## UNDEFINED # StatusCode Data
gZeroGuid ## SOMETIMES_CONSUMES ## GUID
+ gEdkiiSmmPerformanceMeasurementProtocolGuid ## PRODUCES ## UNDEFINED # Install protocol
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask ## CONSUMES
gEfiMdeModulePkgTokenSpaceGuid.PcdEdkiiFpdtStringRecordEnableOnly ## CONSUMES
diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLibInternal.h b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLibInternal.h
index 9d24d9ff7a0..76f24984735 100644
--- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLibInternal.h
+++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLibInternal.h
@@ -18,10 +18,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#ifndef _SMM_CORE_PERFORMANCE_LIB_INTERNAL_H_
#define _SMM_CORE_PERFORMANCE_LIB_INTERNAL_H_
#include <Guid/Performance.h>
+#include <Guid/PerformanceMeasurement.h>
#include <Guid/ExtendedFirmwarePerformance.h>
#include <Guid/FirmwarePerformance.h>
#include <Guid/ZeroGuid.h>
#include <Guid/EventGroup.h>
@@ -44,202 +45,38 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Protocol/SmmBase2.h>
#include <Protocol/LoadedImage.h>
#include <Protocol/DevicePathToText.h>
//
-// Interface declarations for SMM PerformanceEx Protocol.
+// Interface declarations for SMM PerformanceMeasurement Protocol.
//
/**
- Adds a record at the end of the performance measurement log
- that records the start time of a performance measurement.
-
- Adds a record to the end of the performance measurement log
- that contains the Handle, Token, Module and Identifier.
- The end time of the new record must be set to zero.
- If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
- If TimeStamp is zero, the start time in the record is filled in with the value
- read from the current time stamp.
-
- @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 StartGauge of PERFORMANCE_PROTOCOL.
-
- @retval EFI_SUCCESS The data was read correctly from the device.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
-
+ 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
-StartGaugeEx (
- IN CONST VOID *Handle, OPTIONAL
- IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp,
- IN UINT32 Identifier
+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
);
-/**
- Searches the performance measurement log from the beginning of the log
- for the first matching record that contains a zero end time and fills in a valid end time.
-
- Searches the performance measurement log from the beginning of the log
- for the first record that matches Handle, Token, Module and Identifier and has an end time value of zero.
- If the record can not be found then return EFI_NOT_FOUND.
- If the record is found and TimeStamp is not zero,
- then the end time in the record is filled in with the value specified by TimeStamp.
- If the record is found and TimeStamp is zero, then the end time in the matching record
- is filled in with the current time stamp value.
-
- @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 EndGauge of PERFORMANCE_PROTOCOL.
-
- @retval EFI_SUCCESS The end of the measurement was recorded.
- @retval EFI_NOT_FOUND The specified measurement record could not be found.
-
-**/
-EFI_STATUS
-EFIAPI
-EndGaugeEx (
- IN CONST VOID *Handle, OPTIONAL
- IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp,
- IN UINT32 Identifier
- );
-
-/**
- Retrieves a previously logged performance measurement.
- It can also retrieve the log created by StartGauge and EndGauge of PERFORMANCE_PROTOCOL,
- and then assign the Identifier with 0.
-
- Retrieves the performance log entry from the performance log specified by LogEntryKey.
- If it stands for a valid entry, then EFI_SUCCESS is returned and
- GaugeDataEntryEx stores the pointer to that entry.
-
- @param LogEntryKey The key for the previous performance measurement log entry.
- If 0, then the first performance measurement log entry is retrieved.
- @param GaugeDataEntryEx The indirect pointer to the extended gauge data entry specified by LogEntryKey
- if the retrieval is successful.
-
- @retval EFI_SUCCESS The GuageDataEntryEx is successfully found based on LogEntryKey.
- @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).
- @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).
- @retval EFI_INVALIDE_PARAMETER GaugeDataEntryEx is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-GetGaugeEx (
- IN UINTN LogEntryKey,
- OUT GAUGE_DATA_ENTRY_EX **GaugeDataEntryEx
- );
-
-//
-// Interface declarations for SMM Performance Protocol.
-//
-/**
- Adds a record at the end of the performance measurement log
- that records the start time of a performance measurement.
-
- Adds a record to the end of the performance measurement log
- that contains the Handle, Token, and Module.
- The end time of the new record must be set to zero.
- If TimeStamp is not zero, then TimeStamp is used to fill in the start time in the record.
- If TimeStamp is zero, the start time in the record is filled in with the value
- read from the current time stamp.
-
- @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 EFI_SUCCESS The data was read correctly from the device.
- @retval EFI_OUT_OF_RESOURCES There are not enough resources to record the measurement.
-
-**/
-EFI_STATUS
-EFIAPI
-StartGauge (
- IN CONST VOID *Handle, OPTIONAL
- IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
- );
-
-/**
- Searches the performance measurement log from the beginning of the log
- for the first matching record that contains a zero end time and fills in a valid end time.
-
- Searches the performance measurement log from the beginning of the log
- for the first record that matches Handle, Token, and Module and has an end time value of zero.
- If the record can not be found then return EFI_NOT_FOUND.
- If the record is found and TimeStamp is not zero,
- then the end time in the record is filled in with the value specified by TimeStamp.
- If the record is found and TimeStamp is zero, then the end time in the matching record
- is filled in with the current time stamp value.
-
- @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 EFI_SUCCESS The end of the measurement was recorded.
- @retval EFI_NOT_FOUND The specified measurement record could not be found.
-
-**/
-EFI_STATUS
-EFIAPI
-EndGauge (
- IN CONST VOID *Handle, OPTIONAL
- IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
- );
-
-/**
- Retrieves a previously logged performance measurement.
- It can also retrieve the log created by StartGaugeEx and EndGaugeEx of PERFORMANCE_EX_PROTOCOL,
- and then eliminate the Identifier.
-
- Retrieves the performance log entry from the performance log specified by LogEntryKey.
- If it stands for a valid entry, then EFI_SUCCESS is returned and
- GaugeDataEntry stores the pointer to that entry.
-
- @param LogEntryKey The key for the previous performance measurement log entry.
- If 0, then the first performance measurement log entry is retrieved.
- @param GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey
- if the retrieval is successful.
-
- @retval EFI_SUCCESS The GuageDataEntry is successfully found based on LogEntryKey.
- @retval EFI_NOT_FOUND The LogEntryKey is the last entry (equals to the total entry number).
- @retval EFI_INVALIDE_PARAMETER The LogEntryKey is not a valid entry (greater than the total entry number).
- @retval EFI_INVALIDE_PARAMETER GaugeDataEntry is NULL.
-
-**/
-EFI_STATUS
-EFIAPI
-GetGauge (
- IN UINTN LogEntryKey,
- OUT GAUGE_DATA_ENTRY **GaugeDataEntry
- );
-
-
#endif
diff --git a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c b/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c
index 4a08c24789c..fd820c0e49c 100644
--- a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c
+++ b/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c
@@ -16,24 +16,22 @@ 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 <Guid/Performance.h>
+#include <Guid/PerformanceMeasurement.h>
#include <Library/PerformanceLib.h>
#include <Library/DebugLib.h>
#include <Library/SmmServicesTableLib.h>
#include <Library/PcdLib.h>
#include <Library/BaseMemoryLib.h>
//
// The cached SMM Performance Protocol and SMM PerformanceEx Protocol interface.
-//
-PERFORMANCE_PROTOCOL *mPerformance = NULL;
-PERFORMANCE_EX_PROTOCOL *mPerformanceEx = NULL;
-BOOLEAN mPerformanceMeasurementEnabled;
+EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *mPerformanceMeasurement = NULL;
+BOOLEAN mPerformanceMeasurementEnabled;
/**
The constructor function initializes the Performance Measurement Enable flag
@param ImageHandle The firmware allocated handle for the EFI image.
@@ -63,42 +61,30 @@ SmmPerformanceLibConstructor (
@retval EFI_SUCCESS SMM PerformanceEx protocol or Performance Protocol is successfully located.
@retval EFI_NOT_FOUND Both SMM PerformanceEx protocol and Performance Protocol are not located to log performance.
**/
EFI_STATUS
-GetPerformanceProtocol (
+GetPerformanceMeasurementProtocol (
VOID
)
{
EFI_STATUS Status;
- PERFORMANCE_PROTOCOL *Performance;
- PERFORMANCE_EX_PROTOCOL *PerformanceEx;
+ EDKII_PERFORMANCE_MEASUREMENT_PROTOCOL *PerformanceMeasurement;
- if (mPerformanceEx != NULL || mPerformance != NULL) {
+ if (mPerformanceMeasurement != NULL) {
return EFI_SUCCESS;
}
- Status = gSmst->SmmLocateProtocol (&gSmmPerformanceExProtocolGuid, NULL, (VOID **) &PerformanceEx);
+ Status = gSmst->SmmLocateProtocol (&gEdkiiSmmPerformanceMeasurementProtocolGuid, NULL, (VOID **) &PerformanceMeasurement);
if (!EFI_ERROR (Status)) {
- ASSERT (PerformanceEx != NULL);
+ ASSERT (PerformanceMeasurement != NULL);
//
- // Cache PerformanceEx Protocol.
+ // Cache PerformanceMeasurement Protocol.
//
- mPerformanceEx = PerformanceEx;
+ mPerformanceMeasurement = PerformanceMeasurement;
return EFI_SUCCESS;
}
-
- Status = gSmst->SmmLocateProtocol (&gSmmPerformanceProtocolGuid, NULL, (VOID **) &Performance);
- if (!EFI_ERROR (Status)) {
- ASSERT (Performance != NULL);
- //
- // Cache performance protocol.
- //
- mPerformance = Performance;
- return EFI_SUCCESS;
- }
-
return EFI_NOT_FOUND;
}
/**
Creates a record for the beginning of a performance measurement.
@@ -130,21 +116,28 @@ StartPerformanceMeasurementEx (
IN CONST CHAR8 *Module, OPTIONAL
IN UINT64 TimeStamp,
IN UINT32 Identifier
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ CONST CHAR8* String;
- Status = GetPerformanceProtocol ();
+ Status = GetPerformanceMeasurementProtocol ();
if (EFI_ERROR (Status)) {
- return RETURN_OUT_OF_RESOURCES;
+ return RETURN_NOT_FOUND;
}
- if (mPerformanceEx != NULL) {
- Status = mPerformanceEx->StartGaugeEx (Handle, Token, Module, TimeStamp, Identifier);
- } else if (mPerformance != NULL) {
- Status = mPerformance->StartGauge (Handle, Token, Module, TimeStamp);
+ if (Token != NULL) {
+ String = Token;
+ } else if (Module != NULL) {
+ String = Module;
+ } else {
+ String = NULL;
+ }
+
+ if (mPerformanceMeasurement != NULL) {
+ Status = mPerformanceMeasurement->CreatePerformanceMeasurement (Handle, NULL, String, TimeStamp, 0, Identifier, PerfStartEntry);
} else {
ASSERT (FALSE);
}
return (RETURN_STATUS) Status;
@@ -182,21 +175,28 @@ EndPerformanceMeasurementEx (
IN CONST CHAR8 *Module, OPTIONAL
IN UINT64 TimeStamp,
IN UINT32 Identifier
)
{
- EFI_STATUS Status;
+ EFI_STATUS Status;
+ CONST CHAR8* String;
- Status = GetPerformanceProtocol ();
+ Status = GetPerformanceMeasurementProtocol ();
if (EFI_ERROR (Status)) {
return RETURN_NOT_FOUND;
}
- if (mPerformanceEx != NULL) {
- Status = mPerformanceEx->EndGaugeEx (Handle, Token, Module, TimeStamp, Identifier);
- } else if (mPerformance != NULL) {
- Status = mPerformance->EndGauge (Handle, Token, Module, TimeStamp);
+ if (Token != NULL) {
+ String = Token;
+ } else if (Module != NULL) {
+ String = Module;
+ } else {
+ String = NULL;
+ }
+
+ if (mPerformanceMeasurement != NULL) {
+ Status = mPerformanceMeasurement->CreatePerformanceMeasurement (Handle, NULL, String, TimeStamp, 0, Identifier, PerfEndEntry);
} else {
ASSERT (FALSE);
}
return (RETURN_STATUS) Status;
@@ -253,62 +253,11 @@ GetPerformanceMeasurementEx (
OUT UINT64 *StartTimeStamp,
OUT UINT64 *EndTimeStamp,
OUT UINT32 *Identifier
)
{
- EFI_STATUS Status;
- GAUGE_DATA_ENTRY_EX *GaugeData;
-
- GaugeData = NULL;
-
- ASSERT (Handle != NULL);
- ASSERT (Token != NULL);
- ASSERT (Module != NULL);
- ASSERT (StartTimeStamp != NULL);
- ASSERT (EndTimeStamp != NULL);
- ASSERT (Identifier != NULL);
-
- Status = GetPerformanceProtocol ();
- if (EFI_ERROR (Status)) {
- return 0;
- }
-
- if (mPerformanceEx != NULL) {
- Status = mPerformanceEx->GetGaugeEx (LogEntryKey++, &GaugeData);
- } else if (mPerformance != NULL) {
- Status = mPerformance->GetGauge (LogEntryKey++, (GAUGE_DATA_ENTRY **) &GaugeData);
- } else {
- ASSERT (FALSE);
- return 0;
- }
-
- //
- // Make sure that LogEntryKey is a valid log entry key,
- //
- ASSERT (Status != EFI_INVALID_PARAMETER);
-
- if (EFI_ERROR (Status)) {
- //
- // The LogEntryKey is the last entry (equals to the total entry number).
- //
- return 0;
- }
-
- ASSERT (GaugeData != NULL);
-
- *Handle = (VOID *) (UINTN) GaugeData->Handle;
- *Token = GaugeData->Token;
- *Module = GaugeData->Module;
- *StartTimeStamp = GaugeData->StartTimeStamp;
- *EndTimeStamp = GaugeData->EndTimeStamp;
- if (mPerformanceEx != NULL) {
- *Identifier = GaugeData->Identifier;
- } else {
- *Identifier = 0;
- }
-
- return LogEntryKey;
+ return 0;
}
/**
Creates a record for the beginning of a performance measurement.
@@ -423,12 +372,11 @@ GetPerformanceMeasurement (
OUT CONST CHAR8 **Module,
OUT UINT64 *StartTimeStamp,
OUT UINT64 *EndTimeStamp
)
{
- UINT32 Identifier;
- return GetPerformanceMeasurementEx (LogEntryKey, Handle, Token, Module, StartTimeStamp, EndTimeStamp, &Identifier);
+ return 0;
}
/**
Returns TRUE if the performance measurement macros are enabled.
diff --git a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.inf b/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.inf
index c3d01a1e51d..174ed3f1e59 100644
--- a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.inf
+++ b/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.inf
@@ -4,11 +4,11 @@
# This library instance provides infrastructure for SMM drivers to log performance
# data. It consumes SMM PerformanceEx or Performance Protocol published by SmmCorePerformanceLib
# to log performance data. If both SMM PerformanceEx and Performance Protocol are not available,
# it does not log any performance information.
#
-# Copyright (c) 2011 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2011 - 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
#
@@ -48,10 +48,9 @@
SmmServicesTableLib
DebugLib
BaseMemoryLib
[Guids]
- gSmmPerformanceProtocolGuid ## SOMETIMES_CONSUMES ## UNDEFINED # Locate protocol
- gSmmPerformanceExProtocolGuid ## SOMETIMES_CONSUMES ## UNDEFINED # Locate protocol
+ gEdkiiSmmPerformanceMeasurementProtocolGuid ## SOMETIMES_CONSUMES ## UNDEFINED # Locate protocol
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask ## CONSUMES
--
2.14.3.windows.1
next prev parent reply other threads:[~2018-06-22 8:56 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-22 8:56 [patch V2 0/9] Add new Perf macros Dandan Bi
2018-06-22 8:56 ` [patch V2 1/9] MdeModulePkg: Add PERFORMANCE_MEASUREMENT_PROTOCOL Dandan Bi
2018-06-22 8:56 ` Dandan Bi [this message]
2018-06-22 8:56 ` [patch V2 3/9] MdePkg/PerformanceLib.h: Add new Perf macros Dandan Bi
2018-06-22 8:56 ` [patch V2 4/9] MdeModulePkg/ExtendedFirmwarePerf: Remove PerfId definitions Dandan Bi
2018-06-22 8:56 ` [patch V2 5/9] MdeModulePkg: Update performance library instances Dandan Bi
2018-06-22 8:56 ` [patch V2 6/9] ShellPkg/dp: Update dp tool to parse new Perf record Dandan Bi
2018-06-22 8:56 ` [patch V2 7/9] MdeModulePkg: Use new added Perf macros Dandan Bi
2018-06-22 8:56 ` [patch V2 8/9] SecurityPkg: " Dandan Bi
2018-07-03 23:29 ` Zhang, Chao B
2018-06-22 8:56 ` [patch V2 9/9] UefiCpuPkg: " Dandan Bi
2018-06-25 8:02 ` [patch V2 0/9] Add new " Gao, Liming
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-list from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20180622085623.154924-3-dandan.bi@intel.com \
--to=devel@edk2.groups.io \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox