diff options
author | lzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-04-24 09:12:36 +0000 |
---|---|---|
committer | lzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524> | 2012-04-24 09:12:36 +0000 |
commit | f0da4d7d9addb4cbb097286095b146547a8e5122 (patch) | |
tree | 09b97c21eff0a559279fc15a0979713689a9bc3a /MdeModulePkg | |
parent | ba14539c9045b18da3a9e0f06c619e5e13590e23 (diff) | |
download | edk2-platforms-f0da4d7d9addb4cbb097286095b146547a8e5122.tar.xz |
Add new extension PerformanceLib APIs to store ID info.
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13215 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'MdeModulePkg')
16 files changed, 2033 insertions, 392 deletions
diff --git a/MdeModulePkg/Include/Guid/Performance.h b/MdeModulePkg/Include/Guid/Performance.h index 3659ccc328..d7768e1fc1 100644 --- a/MdeModulePkg/Include/Guid/Performance.h +++ b/MdeModulePkg/Include/Guid/Performance.h @@ -4,7 +4,7 @@ * performance protocol interfaces.
* performance variables.
-Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2009 - 2012, 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 that accompanies this distribution.
The full text of the license may be found at
@@ -66,12 +66,16 @@ typedef struct { } PERF_HEADER;
#define PERFORMANCE_PROTOCOL_GUID \
- { 0x76b6bdfa, 0x2acd, 0x4462, {0x9E, 0x3F, 0xcb, 0x58, 0xC9, 0x69, 0xd9, 0x37 } }
+ { 0x76b6bdfa, 0x2acd, 0x4462, { 0x9E, 0x3F, 0xcb, 0x58, 0xC9, 0x69, 0xd9, 0x37 } }
+
+#define PERFORMANCE_EX_PROTOCOL_GUID \
+ { 0x1ea81bec, 0xf01a, 0x4d98, { 0xa2, 0x1, 0x4a, 0x61, 0xce, 0x2f, 0xc0, 0x22 } }
//
// Forward reference for pure ANSI compatibility
//
typedef struct _PERFORMANCE_PROTOCOL PERFORMANCE_PROTOCOL;
+typedef struct _PERFORMANCE_EX_PROTOCOL PERFORMANCE_EX_PROTOCOL;
//
// DXE_PERFORMANCE_STRING_SIZE must be a multiple of 8.
@@ -92,6 +96,15 @@ typedef struct { UINT64 EndTimeStamp; ///< End time point.
} GAUGE_DATA_ENTRY;
+typedef struct {
+ EFI_PHYSICAL_ADDRESS Handle;
+ CHAR8 Token[DXE_PERFORMANCE_STRING_SIZE]; ///< Measured token string name.
+ CHAR8 Module[DXE_PERFORMANCE_STRING_SIZE]; ///< Module string name.
+ UINT64 StartTimeStamp; ///< Start time point.
+ UINT64 EndTimeStamp; ///< End time point.
+ UINT32 Identifier; ///< Identifier.
+} GAUGE_DATA_ENTRY_EX;
+
//
// The header must be aligned at 8 bytes
//
@@ -105,7 +118,10 @@ typedef struct { //
#define SMM_PERFORMANCE_PROTOCOL_GUID \
- { 0xf866226a, 0xeaa5, 0x4f5a, { 0xa9, 0xa, 0x6c, 0xfb, 0xa5, 0x7c, 0x58, 0x8e } }
+ { 0xf866226a, 0xeaa5, 0x4f5a, { 0xa9, 0xa, 0x6c, 0xfb, 0xa5, 0x7c, 0x58, 0x8e } }
+
+#define SMM_PERFORMANCE_EX_PROTOCOL_GUID \
+ { 0x931fc048, 0xc71d, 0x4455, { 0x89, 0x30, 0x47, 0x6, 0x30, 0xe3, 0xe, 0xe5 } }
//
// SMM_PERFORMANCE_STRING_SIZE.
@@ -126,6 +142,14 @@ typedef struct { GAUGE_DATA_ENTRY *GaugeData;
} SMM_PERF_COMMUNICATE;
+typedef struct {
+ UINTN Function;
+ EFI_STATUS ReturnStatus;
+ UINTN NumberOfEntries;
+ UINTN LogEntryKey;
+ GAUGE_DATA_ENTRY_EX *GaugeDataEx;
+} SMM_PERF_COMMUNICATE_EX;
+
#define SMM_PERF_FUNCTION_GET_GAUGE_ENTRY_NUMBER 1
#define SMM_PERF_FUNCTION_GET_GAUGE_DATA 2
@@ -195,6 +219,8 @@ EFI_STATUS /**
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
@@ -216,13 +242,116 @@ EFI_STATUS OUT GAUGE_DATA_ENTRY **GaugeDataEntry
);
+/**
+ Adds a record at the end of the performance measurement log
+ that records the start time of a performance measurement.
+
+ The added record contains the Handle, Token, Module and Identifier.
+ The end time of the new record is not recorded, so it is 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 The pointer to environment specific context used
+ to identify the component being measured.
+ @param Token The pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module The pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+ @param TimeStamp The 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.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI * PERFORMANCE_START_GAUGE_EX)(
+ 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 The pointer to environment specific context used
+ to identify the component being measured.
+ @param Token The pointer to a Null-terminated ASCII string
+ that identifies the component being measured.
+ @param Module The pointer to a Null-terminated ASCII string
+ that identifies the module being measured.
+ @param TimeStamp The 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.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI * PERFORMANCE_END_GAUGE_EX)(
+ 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 Out parameter for the indirect pointer to the extented gauge data entry specified by LogEntryKey.
+
+ @retval EFI_SUCCESS The GuageDataEntryEx is successfully found based on LogEntryKey.
+ @retval EFI_NOT_FOUND There is no entry after the measurement referred to by LogEntryKey.
+ @retval EFI_INVALID_PARAMETER The LogEntryKey is not a valid entry, or GaugeDataEntryEx is NULL.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI * PERFORMANCE_GET_GAUGE_EX)(
+ IN UINTN LogEntryKey,
+ OUT GAUGE_DATA_ENTRY_EX **GaugeDataEntryEx
+ );
+
struct _PERFORMANCE_PROTOCOL {
PERFORMANCE_START_GAUGE StartGauge;
PERFORMANCE_END_GAUGE EndGauge;
PERFORMANCE_GET_GAUGE GetGauge;
};
+struct _PERFORMANCE_EX_PROTOCOL {
+ PERFORMANCE_START_GAUGE_EX StartGaugeEx;
+ PERFORMANCE_END_GAUGE_EX EndGaugeEx;
+ PERFORMANCE_GET_GAUGE_EX GetGaugeEx;
+};
+
extern EFI_GUID gPerformanceProtocolGuid;
extern EFI_GUID gSmmPerformanceProtocolGuid;
+extern EFI_GUID gPerformanceExProtocolGuid;
+extern EFI_GUID gSmmPerformanceExProtocolGuid;
#endif
diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c index e459513e15..08d295ca5a 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.c @@ -4,13 +4,13 @@ This library provides the performance measurement interfaces and initializes performance
logging for DXE phase. It first initializes its private global data structure for
performance logging and saves the performance GUIDed HOB passed from PEI phase.
- It initializes DXE phase performance logging by publishing the Performance Protocol,
- which is consumed by DxePerformanceLib to logging performance data in DXE phase.
+ It initializes DXE phase performance logging by publishing the Performance and PerformanceEx Protocol,
+ which are consumed by DxePerformanceLib to logging performance data in DXE phase.
This library is mainly used by DxeCore to start performance logging to ensure that
Performance Protocol is installed at the very beginning of DXE phase.
-Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, 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
@@ -43,7 +43,7 @@ UINT32 mMaxGaugeRecords; EFI_HANDLE mHandle = NULL;
//
-// Interfaces for performance protocol.
+// Interfaces for Performance Protocol.
//
PERFORMANCE_PROTOCOL mPerformanceInterface = {
StartGauge,
@@ -51,11 +51,20 @@ PERFORMANCE_PROTOCOL mPerformanceInterface = { GetGauge
};
+//
+// Interfaces for PerformanceEx Protocol.
+//
+PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = {
+ StartGaugeEx,
+ EndGaugeEx,
+ GetGaugeEx
+ };
+
/**
- Searches in the gauge array with keyword Handle, Token and Module.
+ Searches in the gauge array with keyword Handle, Token, Module and Identifier.
This internal function searches for the gauge entry in the gauge array.
- If there is an entry that exactly matches the given key word triple
+ If there is an entry that exactly matches the given keywords
and its end time stamp is zero, then the index of that gauge entry is returned;
otherwise, the the number of gauge entries in the array is returned.
@@ -65,6 +74,7 @@ PERFORMANCE_PROTOCOL mPerformanceInterface = { that identifies the component being measured.
@param Module Pointer to a Null-terminated ASCII string
that identifies the module being measured.
+ @param Identifier 32-bit identifier.
@retval The index of gauge entry in the array.
@@ -73,12 +83,13 @@ UINT32 InternalSearchForGaugeEntry (
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module OPTIONAL
+ IN CONST CHAR8 *Module, OPTIONAL
+ IN UINT32 Identifier
)
{
UINT32 Index;
UINT32 NumberOfEntries;
- GAUGE_DATA_ENTRY *GaugeEntryArray;
+ GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;
if (Token == NULL) {
Token = "";
@@ -88,13 +99,14 @@ InternalSearchForGaugeEntry ( }
NumberOfEntries = mGaugeData->NumberOfEntries;
- GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
+ GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
for (Index = 0; Index < NumberOfEntries; Index++) {
- if ((GaugeEntryArray[Index].Handle == (EFI_PHYSICAL_ADDRESS) (UINTN) Handle) &&
- AsciiStrnCmp (GaugeEntryArray[Index].Token, Token, DXE_PERFORMANCE_STRING_LENGTH) == 0 &&
- AsciiStrnCmp (GaugeEntryArray[Index].Module, Module, DXE_PERFORMANCE_STRING_LENGTH) == 0 &&
- GaugeEntryArray[Index].EndTimeStamp == 0
+ if ((GaugeEntryExArray[Index].Handle == (EFI_PHYSICAL_ADDRESS) (UINTN) Handle) &&
+ AsciiStrnCmp (GaugeEntryExArray[Index].Token, Token, DXE_PERFORMANCE_STRING_LENGTH) == 0 &&
+ AsciiStrnCmp (GaugeEntryExArray[Index].Module, Module, DXE_PERFORMANCE_STRING_LENGTH) == 0 &&
+ (GaugeEntryExArray[Index].Identifier == Identifier) &&
+ GaugeEntryExArray[Index].EndTimeStamp == 0
) {
break;
}
@@ -108,7 +120,7 @@ InternalSearchForGaugeEntry ( 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.
+ 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
@@ -121,6 +133,8 @@ InternalSearchForGaugeEntry ( @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.
@@ -128,15 +142,17 @@ InternalSearchForGaugeEntry ( **/
EFI_STATUS
EFIAPI
-StartGauge (
+StartGaugeEx (
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
+ IN UINT64 TimeStamp,
+ IN UINT32 Identifier
)
{
- GAUGE_DATA_ENTRY *GaugeEntryArray;
+ GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;
UINTN GaugeDataSize;
+ GAUGE_DATA_HEADER *NewGaugeData;
UINTN OldGaugeDataSize;
GAUGE_DATA_HEADER *OldGaugeData;
UINT32 Index;
@@ -147,15 +163,18 @@ StartGauge ( // Try to enlarge the scale of gauge array.
//
OldGaugeData = mGaugeData;
- OldGaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords;
+ OldGaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY_EX) * mMaxGaugeRecords;
- mMaxGaugeRecords *= 2;
- GaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords;
+ GaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY_EX) * mMaxGaugeRecords * 2;
- mGaugeData = AllocateZeroPool (GaugeDataSize);
- if (mGaugeData == NULL) {
+ NewGaugeData = AllocateZeroPool (GaugeDataSize);
+ if (NewGaugeData == NULL) {
return EFI_OUT_OF_RESOURCES;
}
+
+ mGaugeData = NewGaugeData;
+ mMaxGaugeRecords *= 2;
+
//
// Initialize new data array and migrate old data one.
//
@@ -164,20 +183,23 @@ StartGauge ( FreePool (OldGaugeData);
}
- GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
- GaugeEntryArray[Index].Handle = (EFI_PHYSICAL_ADDRESS) (UINTN) Handle;
+ GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
+ GaugeEntryExArray[Index].Handle = (EFI_PHYSICAL_ADDRESS) (UINTN) Handle;
if (Token != NULL) {
- AsciiStrnCpy (GaugeEntryArray[Index].Token, Token, DXE_PERFORMANCE_STRING_LENGTH);
+ AsciiStrnCpy (GaugeEntryExArray[Index].Token, Token, DXE_PERFORMANCE_STRING_LENGTH);
}
if (Module != NULL) {
- AsciiStrnCpy (GaugeEntryArray[Index].Module, Module, DXE_PERFORMANCE_STRING_LENGTH);
+ AsciiStrnCpy (GaugeEntryExArray[Index].Module, Module, DXE_PERFORMANCE_STRING_LENGTH);
}
+ GaugeEntryExArray[Index].EndTimeStamp = 0;
+ GaugeEntryExArray[Index].Identifier = Identifier;
+
if (TimeStamp == 0) {
TimeStamp = GetPerformanceCounter ();
}
- GaugeEntryArray[Index].StartTimeStamp = TimeStamp;
+ GaugeEntryExArray[Index].StartTimeStamp = TimeStamp;
mGaugeData->NumberOfEntries++;
@@ -189,7 +211,7 @@ StartGauge ( 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.
+ 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.
@@ -203,6 +225,8 @@ StartGauge ( @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.
@@ -210,57 +234,60 @@ StartGauge ( **/
EFI_STATUS
EFIAPI
-EndGauge (
+EndGaugeEx (
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
+ IN UINT64 TimeStamp,
+ IN UINT32 Identifier
)
{
- GAUGE_DATA_ENTRY *GaugeEntryArray;
- UINT32 Index;
+ GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;
+ UINT32 Index;
if (TimeStamp == 0) {
TimeStamp = GetPerformanceCounter ();
}
- Index = InternalSearchForGaugeEntry (Handle, Token, Module);
+ Index = InternalSearchForGaugeEntry (Handle, Token, Module, Identifier);
if (Index >= mGaugeData->NumberOfEntries) {
return EFI_NOT_FOUND;
}
- GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
- GaugeEntryArray[Index].EndTimeStamp = TimeStamp;
+ GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
+ GaugeEntryExArray[Index].EndTimeStamp = TimeStamp;
return EFI_SUCCESS;
}
/**
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
- GaugeDataEntry stores the pointer to that entry.
+ 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 GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey
+ @param GaugeDataEntryEx The indirect pointer to the extended gauge data entry specified by LogEntryKey
if the retrieval is successful.
- @retval EFI_SUCCESS The GuageDataEntry is successfully found based on LogEntryKey.
+ @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 GaugeDataEntry is NULL.
+ @retval EFI_INVALIDE_PARAMETER GaugeDataEntryEx is NULL.
**/
EFI_STATUS
EFIAPI
-GetGauge (
- IN UINTN LogEntryKey,
- OUT GAUGE_DATA_ENTRY **GaugeDataEntry
+GetGaugeEx (
+ IN UINTN LogEntryKey,
+ OUT GAUGE_DATA_ENTRY_EX **GaugeDataEntryEx
)
{
UINTN NumberOfEntries;
- GAUGE_DATA_ENTRY *LogEntryArray;
+ GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;
NumberOfEntries = (UINTN) (mGaugeData->NumberOfEntries);
if (LogEntryKey > NumberOfEntries) {
@@ -270,12 +297,127 @@ GetGauge ( return EFI_NOT_FOUND;
}
- LogEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
+ GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
+
+ if (GaugeDataEntryEx == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+ *GaugeDataEntryEx = &GaugeEntryExArray[LogEntryKey];
+
+ 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, 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.
+
+ 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
+ )
+{
+ EFI_STATUS Status;
+ GAUGE_DATA_ENTRY_EX *GaugeEntryEx;
+
+ Status = GetGaugeEx (LogEntryKey, &GaugeEntryEx);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
if (GaugeDataEntry == NULL) {
return EFI_INVALID_PARAMETER;
}
- *GaugeDataEntry = &LogEntryArray[LogEntryKey];
+
+ *GaugeDataEntry = (GAUGE_DATA_ENTRY *) GaugeEntryEx;
return EFI_SUCCESS;
}
@@ -296,12 +438,13 @@ InternalGetPeiPerformance ( EFI_HOB_GUID_TYPE *GuidHob;
PEI_PERFORMANCE_LOG_HEADER *LogHob;
PEI_PERFORMANCE_LOG_ENTRY *LogEntryArray;
- GAUGE_DATA_ENTRY *GaugeEntryArray;
+ UINT32 *LogIdArray;
+ GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;
UINT32 Index;
UINT32 NumberOfEntries;
NumberOfEntries = 0;
- GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
+ GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
//
// Dump PEI Log Entries to DXE Guage Data structure.
@@ -310,15 +453,23 @@ InternalGetPeiPerformance ( if (GuidHob != NULL) {
LogHob = GET_GUID_HOB_DATA (GuidHob);
LogEntryArray = (PEI_PERFORMANCE_LOG_ENTRY *) (LogHob + 1);
- GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
NumberOfEntries = LogHob->NumberOfEntries;
for (Index = 0; Index < NumberOfEntries; Index++) {
- GaugeEntryArray[Index].Handle = LogEntryArray[Index].Handle;
- AsciiStrnCpy (GaugeEntryArray[Index].Token, LogEntryArray[Index].Token, DXE_PERFORMANCE_STRING_LENGTH);
- AsciiStrnCpy (GaugeEntryArray[Index].Module, LogEntryArray[Index].Module, DXE_PERFORMANCE_STRING_LENGTH);
- GaugeEntryArray[Index].StartTimeStamp = LogEntryArray[Index].StartTimeStamp;
- GaugeEntryArray[Index].EndTimeStamp = LogEntryArray[Index].EndTimeStamp;
+ GaugeEntryExArray[Index].Handle = LogEntryArray[Index].Handle;
+ AsciiStrnCpy (GaugeEntryExArray[Index].Token, LogEntryArray[Index].Token, DXE_PERFORMANCE_STRING_LENGTH);
+ AsciiStrnCpy (GaugeEntryExArray[Index].Module, LogEntryArray[Index].Module, DXE_PERFORMANCE_STRING_LENGTH);
+ GaugeEntryExArray[Index].StartTimeStamp = LogEntryArray[Index].StartTimeStamp;
+ GaugeEntryExArray[Index].EndTimeStamp = LogEntryArray[Index].EndTimeStamp;
+ GaugeEntryExArray[Index].Identifier = 0;
+ }
+
+ GuidHob = GetFirstGuidHob (&gPerformanceExProtocolGuid);
+ if (GuidHob != NULL) {
+ LogIdArray = GET_GUID_HOB_DATA (GuidHob);
+ for (Index = 0; Index < NumberOfEntries; Index++) {
+ GaugeEntryExArray[Index].Identifier = LogIdArray[Index];
+ }
}
}
mGaugeData->NumberOfEntries = NumberOfEntries;
@@ -327,7 +478,7 @@ InternalGetPeiPerformance ( /**
The constructor function initializes Performance infrastructure for DXE phase.
- The constructor function publishes Performance protocol, allocates memory to log DXE performance
+ The constructor function publishes Performance and PerformanceEx protocol, allocates memory to log DXE performance
and merges PEI performance data to DXE performance log.
It will ASSERT() if one of these operations fails and it will always return EFI_SUCCESS.
@@ -355,17 +506,19 @@ DxeCorePerformanceLibConstructor ( //
// Install the protocol interfaces.
//
- Status = gBS->InstallProtocolInterface (
+ Status = gBS->InstallMultipleProtocolInterfaces (
&mHandle,
&gPerformanceProtocolGuid,
- EFI_NATIVE_INTERFACE,
- &mPerformanceInterface
+ &mPerformanceInterface,
+ &gPerformanceExProtocolGuid,
+ &mPerformanceExInterface,
+ NULL
);
ASSERT_EFI_ERROR (Status);
mMaxGaugeRecords = INIT_DXE_GAUGE_DATA_ENTRIES + PcdGet8 (PcdMaxPeiPerformanceLogEntries);
- mGaugeData = AllocateZeroPool (sizeof (GAUGE_DATA_HEADER) + (sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords));
+ mGaugeData = AllocateZeroPool (sizeof (GAUGE_DATA_HEADER) + (sizeof (GAUGE_DATA_ENTRY_EX) * mMaxGaugeRecords));
ASSERT (mGaugeData != NULL);
InternalGetPeiPerformance ();
@@ -378,7 +531,7 @@ DxeCorePerformanceLibConstructor ( 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.
+ 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
@@ -391,6 +544,8 @@ DxeCorePerformanceLibConstructor ( @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.
@@ -398,17 +553,15 @@ DxeCorePerformanceLibConstructor ( **/
RETURN_STATUS
EFIAPI
-StartPerformanceMeasurement (
+StartPerformanceMeasurementEx (
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
+ IN UINT64 TimeStamp,
+ IN UINT32 Identifier
)
{
- EFI_STATUS Status;
-
- Status = StartGauge (Handle, Token, Module, TimeStamp);
- return (RETURN_STATUS) Status;
+ return (RETURN_STATUS) StartGaugeEx (Handle, Token, Module, TimeStamp, Identifier);
}
/**
@@ -416,7 +569,7 @@ StartPerformanceMeasurement ( 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.
+ 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 RETURN_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.
@@ -430,6 +583,8 @@ StartPerformanceMeasurement ( @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.
@@ -437,21 +592,21 @@ StartPerformanceMeasurement ( **/
RETURN_STATUS
EFIAPI
-EndPerformanceMeasurement (
+EndPerformanceMeasurementEx (
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
+ IN UINT64 TimeStamp,
+ IN UINT32 Identifier
)
{
- EFI_STATUS Status;
-
- Status = EndGauge (Handle, Token, Module, TimeStamp);
- return (RETURN_STATUS) Status;
+ return (RETURN_STATUS) EndGaugeEx (Handle, Token, Module, TimeStamp, Identifier);
}
/**
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,
@@ -462,13 +617,14 @@ EndPerformanceMeasurement ( 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.
+ 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().
@param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
0, then the first performance measurement log entry is retrieved.
@@ -483,23 +639,25 @@ EndPerformanceMeasurement ( 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
-GetPerformanceMeasurement (
- IN UINTN LogEntryKey,
+GetPerformanceMeasurementEx (
+ IN UINTN LogEntryKey,
OUT CONST VOID **Handle,
OUT CONST CHAR8 **Token,
OUT CONST CHAR8 **Module,
OUT UINT64 *StartTimeStamp,
- OUT UINT64 *EndTimeStamp
+ OUT UINT64 *EndTimeStamp,
+ OUT UINT32 *Identifier
)
{
- EFI_STATUS Status;
- GAUGE_DATA_ENTRY *GaugeData;
+ EFI_STATUS Status;
+ GAUGE_DATA_ENTRY_EX *GaugeData;
GaugeData = NULL;
@@ -508,8 +666,9 @@ GetPerformanceMeasurement ( ASSERT (Module != NULL);
ASSERT (StartTimeStamp != NULL);
ASSERT (EndTimeStamp != NULL);
+ ASSERT (Identifier != NULL);
- Status = GetGauge (LogEntryKey++, &GaugeData);
+ Status = GetGaugeEx (LogEntryKey++, &GaugeData);
//
// Make sure that LogEntryKey is a valid log entry key,
@@ -530,11 +689,137 @@ GetPerformanceMeasurement ( *Module = GaugeData->Module;
*StartTimeStamp = GaugeData->StartTimeStamp;
*EndTimeStamp = GaugeData->EndTimeStamp;
+ *Identifier = GaugeData->Identifier;
return LogEntryKey;
}
/**
+ 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 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);
+}
+
+/**
+ 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 RETURN_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 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().
+
+ @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 log 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
+ )
+{
+ UINT32 Identifier;
+ return GetPerformanceMeasurementEx (LogEntryKey, Handle, Token, Module, StartTimeStamp, EndTimeStamp, &Identifier);
+}
+
+/**
Returns TRUE if the performance measurement macros are enabled.
This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf index 6ab725309c..64d7e3db4a 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLib.inf @@ -4,12 +4,12 @@ # This library provides the performance measurement interfaces and initializes performance
# logging for DXE phase. It first initializes its private global data structure for
# performance logging and saves the performance GUIDed HOB passed from PEI phase.
-# It initializes DXE phase performance logging by publishing the Performance Protocol,
+# It initializes DXE phase performance logging by publishing the Performance and PerformanceEx Protocol,
# which is consumed by DxePerformanceLib to logging performance data in DXE phase.
# This library is mainly used by DxeCore to start performance logging to ensure that
-# Performance Protocol is installed at the very beginning of DXE phase.
+# Performance and PerformanceEx Protocol are installed at the very beginning of DXE phase.
#
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2012, 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
@@ -59,6 +59,8 @@ [Guids]
gPerformanceProtocolGuid ## CONSUMES ## HOB
gPerformanceProtocolGuid ## PRODUCES ## PROTOCOL
+ gPerformanceExProtocolGuid ## CONSUMES ## HOB
+ gPerformanceExProtocolGuid ## PRODUCES ## PROTOCOL
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries
diff --git a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h index 2005e174e8..2b9ccd2fee 100644 --- a/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h +++ b/MdeModulePkg/Library/DxeCorePerformanceLib/DxeCorePerformanceLibInternal.h @@ -1,10 +1,10 @@ /** @file
Master header files for DxeCorePerformanceLib instance.
- This header file holds the prototypes of the Performance Protocol published by this
+ This header file holds the prototypes of the Performance and PerformanceEx Protocol published by this
library instance at its constructor.
-Copyright (c) 2006 - 2008, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2006 - 2012, 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
@@ -34,6 +34,107 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Library/MemoryAllocationLib.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.
+
+**/
+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 Performance Protocol.
//
/**
@@ -103,6 +204,8 @@ EndGauge ( /**
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
diff --git a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c index 5fb3ff2264..2ddd983126 100644 --- a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c +++ b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.c @@ -2,8 +2,8 @@ Performance Library
This library instance provides infrastructure for DXE phase drivers to log performance
- data. It consumes Performance Protocol published by DxeCorePerformanceLib
- to log performance data. If Performance Protocol is not available, it does not log any
+ data. It consumes PerformanceEx or Performance Protocol published by DxeCorePerformanceLib
+ to log performance data. If both PerformanceEx and Performance Protocol is not available, it does not log any
performance information.
Copyright (c) 2006 - 2012, Intel Corporation. All rights reserved.<BR>
@@ -28,18 +28,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Library/PcdLib.h>
//
-// The cached performance protocol interface.
+// The cached Performance Protocol and PerformanceEx Protocol interface.
//
-PERFORMANCE_PROTOCOL *mPerformance = NULL;
+PERFORMANCE_PROTOCOL *mPerformance = NULL;
+PERFORMANCE_EX_PROTOCOL *mPerformanceEx = NULL;
/**
- The constructor function caches the pointer to Performance protocol.
+ The function caches the pointers to PerformanceEx protocol and Performance Protocol.
- The constructor function locates Performance protocol from protocol database.
- It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
+ The function locates PerformanceEx protocol and Performance Protocol from protocol database.
- @retval EFI_SUCCESS Performance protocol is successfully located.
- @retval Other Performance protocol is not located to log performance.
+ @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
@@ -47,10 +47,21 @@ GetPerformanceProtocol ( VOID
)
{
- EFI_STATUS Status;
- PERFORMANCE_PROTOCOL *Performance;
+ EFI_STATUS Status;
+ PERFORMANCE_PROTOCOL *Performance;
+ PERFORMANCE_EX_PROTOCOL *PerformanceEx;
- if (mPerformance != NULL) {
+ if (mPerformanceEx != NULL || mPerformance != NULL) {
+ return EFI_SUCCESS;
+ }
+
+ Status = gBS->LocateProtocol (&gPerformanceExProtocolGuid, NULL, (VOID **) &PerformanceEx);
+ if (!EFI_ERROR (Status)) {
+ ASSERT (PerformanceEx != NULL);
+ //
+ // Cache PerformanceEx Protocol.
+ //
+ mPerformanceEx = PerformanceEx;
return EFI_SUCCESS;
}
@@ -61,15 +72,16 @@ GetPerformanceProtocol ( // Cache performance protocol.
//
mPerformance = Performance;
+ return EFI_SUCCESS;
}
- return Status;
+ return EFI_NOT_FOUND;
}
/**
Creates a record for the beginning of a performance measurement.
- Creates a record that contains the Handle, Token, and Module.
+ Creates a record that contains the Handle, Token, Module and Identifier.
If TimeStamp is not zero, then TimeStamp is added to the record as the start time.
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.
@@ -81,6 +93,8 @@ GetPerformanceProtocol ( @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.
@@ -88,11 +102,12 @@ GetPerformanceProtocol ( **/
RETURN_STATUS
EFIAPI
-StartPerformanceMeasurement (
+StartPerformanceMeasurementEx (
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
+ IN UINT64 TimeStamp,
+ IN UINT32 Identifier
)
{
EFI_STATUS Status;
@@ -102,7 +117,13 @@ StartPerformanceMeasurement ( return RETURN_OUT_OF_RESOURCES;
}
- Status = mPerformance->StartGauge (Handle, Token, Module, TimeStamp);
+ if (mPerformanceEx != NULL) {
+ Status = mPerformanceEx->StartGaugeEx (Handle, Token, Module, TimeStamp, Identifier);
+ } else if (mPerformance != NULL) {
+ Status = mPerformance->StartGauge (Handle, Token, Module, TimeStamp);
+ } else {
+ ASSERT (FALSE);
+ }
return (RETURN_STATUS) Status;
}
@@ -110,7 +131,7 @@ StartPerformanceMeasurement ( /**
Fills in the end time of a performance measurement.
- Looks up the record that matches Handle, Token, and Module.
+ Looks up the record that matches Handle, Token, Module and Identifier.
If the record can not be found then return RETURN_NOT_FOUND.
If the record is found and TimeStamp is not zero,
then TimeStamp is added to the record as the end time.
@@ -124,6 +145,8 @@ StartPerformanceMeasurement ( @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.
@@ -131,11 +154,12 @@ StartPerformanceMeasurement ( **/
RETURN_STATUS
EFIAPI
-EndPerformanceMeasurement (
+EndPerformanceMeasurementEx (
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
+ IN UINT64 TimeStamp,
+ IN UINT32 Identifier
)
{
EFI_STATUS Status;
@@ -145,13 +169,21 @@ EndPerformanceMeasurement ( return RETURN_NOT_FOUND;
}
- Status = mPerformance->EndGauge (Handle, Token, Module, TimeStamp);
+ if (mPerformanceEx != NULL) {
+ Status = mPerformanceEx->EndGaugeEx (Handle, Token, Module, TimeStamp, Identifier);
+ } else if (mPerformance != NULL) {
+ Status = mPerformance->EndGauge (Handle, Token, Module, TimeStamp);
+ } else {
+ ASSERT (FALSE);
+ }
return (RETURN_STATUS) Status;
}
/**
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,
@@ -162,13 +194,14 @@ EndPerformanceMeasurement ( 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.
+ 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().
@param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
0, then the first performance measurement log entry is retrieved.
@@ -183,36 +216,48 @@ EndPerformanceMeasurement ( 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
-GetPerformanceMeasurement (
- IN UINTN LogEntryKey,
+GetPerformanceMeasurementEx (
+ IN UINTN LogEntryKey,
OUT CONST VOID **Handle,
OUT CONST CHAR8 **Token,
OUT CONST CHAR8 **Module,
OUT UINT64 *StartTimeStamp,
- OUT UINT64 *EndTimeStamp
+ OUT UINT64 *EndTimeStamp,
+ OUT UINT32 *Identifier
)
{
- EFI_STATUS Status;
- GAUGE_DATA_ENTRY *GaugeData;
+ 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;
}
- Status = mPerformance->GetGauge (LogEntryKey++, &GaugeData);
+ 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,
@@ -233,11 +278,136 @@ GetPerformanceMeasurement ( *Module = GaugeData->Module;
*StartTimeStamp = GaugeData->StartTimeStamp;
*EndTimeStamp = GaugeData->EndTimeStamp;
+ if (mPerformanceEx != NULL) {
+ *Identifier = GaugeData->Identifier;
+ } else {
+ *Identifier = 0;
+ }
return LogEntryKey;
}
/**
+ Creates a record for the beginning of a performance measurement.
+
+ Creates a record that contains the Handle, Token, and Module.
+ If TimeStamp is not zero, then TimeStamp is added to the record as the start time.
+ 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.
+
+ @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);
+}
+
+/**
+ Fills in the end time of a performance measurement.
+
+ Looks up the record that matches Handle, Token, and Module.
+ If the record can not be found then return RETURN_NOT_FOUND.
+ If the record is found and TimeStamp is not zero,
+ then TimeStamp is added to the record as the end time.
+ If the record is found and TimeStamp is zero, then this function reads
+ the current time stamp and adds that time stamp value to the record 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().
+
+ @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 log 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
+ )
+{
+ UINT32 Identifier;
+ return GetPerformanceMeasurementEx (LogEntryKey, Handle, Token, Module, StartTimeStamp, EndTimeStamp, &Identifier);
+}
+
+/**
Returns TRUE if the performance measurement macros are enabled.
This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
diff --git a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf index 886fa462e4..c043848a2f 100644 --- a/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf +++ b/MdeModulePkg/Library/DxePerformanceLib/DxePerformanceLib.inf @@ -2,11 +2,11 @@ # Performance library instance used in DXE phase.
#
# This library instance provides infrastructure for DXE phase drivers to log performance
-# data. It consumes Performance Protocol published by DxeCorePerformanceLib
-# to log performance data. If Performance Protocol is not available, it does not log any
+# 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 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2012, 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
@@ -47,7 +47,8 @@ [Guids]
- gPerformanceProtocolGuid ## CONSUMES ## PROTOCOL
+ gPerformanceProtocolGuid ## SOMETIMES_CONSUMES ## PROTOCOL
+ gPerformanceExProtocolGuid ## SOMETIMES_CONSUMES ## PROTOCOL
[Pcd]
diff --git a/MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.c b/MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.c index 19e9877cbf..3ceda5ef6e 100644 --- a/MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.c +++ b/MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.c @@ -2,7 +2,8 @@ Performance library instance used in DXE phase to dump SMM performance data.
This library instance allows a DXE driver or UEFI application to dump the SMM performance data.
- StartPerformanceMeasurement() and EndPerformanceMeasurement() are not implemented.
+ StartPerformanceMeasurement(), EndPerformanceMeasurement(), StartPerformanceMeasurementEx()
+ and EndPerformanceMeasurementEx() are not implemented.
Copyright (c) 2011 - 2012, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
@@ -39,16 +40,16 @@ EFI_SMM_COMMUNICATION_PROTOCOL *mSmmCommunication = NULL; UINT8 mSmmPerformanceBuffer[SMM_PERFORMANCE_COMMUNICATION_BUFFER_SIZE];
GAUGE_DATA_ENTRY *mGaugeData = NULL;
UINTN mGaugeNumberOfEntries = 0;
-
+GAUGE_DATA_ENTRY_EX *mGaugeDataEx = NULL;
+UINTN mGaugeNumberOfEntriesEx = 0;
/**
- The constructor function caches the pointer to SMM Communication protocol.
+ The function caches the pointer to SMM Communication protocol.
- The constructor function locates Performance protocol from protocol database.
- It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
+ The function locates SMM Communication protocol from protocol database.
- @retval EFI_SUCCESS Performance protocol is successfully located.
- @retval Other Performance protocol is not located to log performance.
+ @retval EFI_SUCCESS SMM Communication protocol is successfully located.
+ @retval Other SMM Communication protocol is not located to log performance.
**/
EFI_STATUS
@@ -78,6 +79,78 @@ GetCommunicationProtocol ( /**
Creates a record for the beginning of a performance measurement.
+ Creates a record that contains the Handle, Token, Module and Identifier.
+ If TimeStamp is not zero, then TimeStamp is added to the record as the start time.
+ 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.
+
+ @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
+ )
+{
+ return RETURN_SUCCESS;
+}
+
+/**
+ Fills in the end time of a performance measurement.
+
+ Looks up the record that matches Handle, Token, Module and Identifier.
+ If the record can not be found then return RETURN_NOT_FOUND.
+ If the record is found and TimeStamp is not zero,
+ then TimeStamp is added to the record as the end time.
+ If the record is found and TimeStamp is zero, then this function reads
+ the current time stamp and adds that time stamp value to the record 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
+ )
+{
+ return RETURN_SUCCESS;
+}
+
+/**
+ Creates a record for the beginning of a performance measurement.
+
Creates a record that contains the Handle, Token, and Module.
If TimeStamp is not zero, then TimeStamp is added to the record as the start time.
If TimeStamp is zero, then this function reads the current time stamp
@@ -104,7 +177,7 @@ StartPerformanceMeasurement ( IN UINT64 TimeStamp
)
{
- return EFI_UNSUPPORTED;
+ return RETURN_SUCCESS;
}
/**
@@ -138,7 +211,7 @@ EndPerformanceMeasurement ( IN UINT64 TimeStamp
)
{
- return EFI_UNSUPPORTED;
+ return RETURN_SUCCESS;
}
/**
@@ -149,7 +222,7 @@ EndPerformanceMeasurement ( @retval !NULL Get all gauge data success.
@retval NULL Get all guage data failed.
**/
-GAUGE_DATA_ENTRY*
+GAUGE_DATA_ENTRY *
EFIAPI
GetAllSmmGaugeData (VOID)
{
@@ -171,22 +244,20 @@ GetAllSmmGaugeData (VOID) //
// Initialize communicate buffer
//
- SmmCommBufferHeader = (EFI_SMM_COMMUNICATE_HEADER*)mSmmPerformanceBuffer;
- SmmPerfCommData = (SMM_PERF_COMMUNICATE*)SmmCommBufferHeader->Data;
+ SmmCommBufferHeader = (EFI_SMM_COMMUNICATE_HEADER *)mSmmPerformanceBuffer;
+ SmmPerfCommData = (SMM_PERF_COMMUNICATE *)SmmCommBufferHeader->Data;
ZeroMem((UINT8*)SmmPerfCommData, sizeof(SMM_PERF_COMMUNICATE));
CopyGuid (&SmmCommBufferHeader->HeaderGuid, &gSmmPerformanceProtocolGuid);
SmmCommBufferHeader->MessageLength = sizeof(SMM_PERF_COMMUNICATE);
- CommSize = OFFSET_OF (EFI_SMM_COMMUNICATE_HEADER, Data) + sizeof(SMM_PERF_COMMUNICATE);
+ CommSize = SMM_PERFORMANCE_COMMUNICATION_BUFFER_SIZE;
//
// Get totol number of SMM gauge entries
//
SmmPerfCommData->Function = SMM_PERF_FUNCTION_GET_GAUGE_ENTRY_NUMBER;
Status = mSmmCommunication->Communicate (mSmmCommunication, mSmmPerformanceBuffer, &CommSize);
- ASSERT_EFI_ERROR (Status);
-
- if (EFI_ERROR (SmmPerfCommData->ReturnStatus) || SmmPerfCommData->NumberOfEntries == 0) {
+ if (EFI_ERROR (Status) || EFI_ERROR (SmmPerfCommData->ReturnStatus) || SmmPerfCommData->NumberOfEntries == 0) {
return NULL;
}
@@ -194,7 +265,7 @@ GetAllSmmGaugeData (VOID) DataSize = mGaugeNumberOfEntries * sizeof(GAUGE_DATA_ENTRY);
mGaugeData = AllocateZeroPool(DataSize);
- ASSERT_EFI_ERROR (Status);
+ ASSERT (mGaugeData != NULL);
//
// Get all SMM gauge data
@@ -204,54 +275,89 @@ GetAllSmmGaugeData (VOID) SmmPerfCommData->NumberOfEntries = mGaugeNumberOfEntries;
SmmPerfCommData->GaugeData = mGaugeData;
Status = mSmmCommunication->Communicate (mSmmCommunication, mSmmPerformanceBuffer, &CommSize);
- ASSERT_EFI_ERROR (Status);
- ASSERT_EFI_ERROR(SmmPerfCommData->ReturnStatus);
+ if (EFI_ERROR (Status) || EFI_ERROR (SmmPerfCommData->ReturnStatus)) {
+ FreePool (mGaugeData);
+ mGaugeData = NULL;
+ mGaugeNumberOfEntries = 0;
+ }
- return mGaugeData;
+ return mGaugeData;
}
/**
- Retrieves a previously logged performance measurement.
-
- 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.
+ Retrieves all previous logged performance measurement.
+ Function will use SMM communicate protocol to get all previous SMM performance measurement data.
+ If success, data buffer will be returned. If fail function will return NULL.
+ @retval !NULL Get all gauge data success.
+ @retval NULL Get all guage data failed.
**/
-EFI_STATUS
+GAUGE_DATA_ENTRY_EX *
EFIAPI
-GetGauge (
- IN UINTN LogEntryKey,
- OUT GAUGE_DATA_ENTRY **GaugeDataEntry
- )
+GetAllSmmGaugeDataEx (VOID)
{
- if (LogEntryKey > mGaugeNumberOfEntries) {
- return EFI_INVALID_PARAMETER;
+ EFI_STATUS Status;
+ EFI_SMM_COMMUNICATE_HEADER *SmmCommBufferHeader;
+ SMM_PERF_COMMUNICATE_EX *SmmPerfCommData;
+ UINTN CommSize;
+ UINTN DataSize;
+
+ if (mGaugeDataEx != NULL) {
+ return mGaugeDataEx;
}
- if (LogEntryKey == mGaugeNumberOfEntries) {
- return EFI_NOT_FOUND;
+
+ Status = GetCommunicationProtocol ();
+ if (EFI_ERROR (Status)) {
+ return NULL;
}
- if (GaugeDataEntry == NULL) {
- return EFI_INVALID_PARAMETER;
+ //
+ // Initialize communicate buffer
+ //
+ SmmCommBufferHeader = (EFI_SMM_COMMUNICATE_HEADER *)mSmmPerformanceBuffer;
+ SmmPerfCommData = (SMM_PERF_COMMUNICATE_EX *)SmmCommBufferHeader->Data;
+ ZeroMem((UINT8*)SmmPerfCommData, sizeof(SMM_PERF_COMMUNICATE_EX));
+
+ CopyGuid (&SmmCommBufferHeader->HeaderGuid, &gSmmPerformanceExProtocolGuid);
+ SmmCommBufferHeader->MessageLength = sizeof(SMM_PERF_COMMUNICATE_EX);
+ CommSize = SMM_PERFORMANCE_COMMUNICATION_BUFFER_SIZE;
+
+ //
+ // Get totol number of SMM gauge entries
+ //
+ SmmPerfCommData->Function = SMM_PERF_FUNCTION_GET_GAUGE_ENTRY_NUMBER;
+ Status = mSmmCommunication->Communicate (mSmmCommunication, mSmmPerformanceBuffer, &CommSize);
+ if (EFI_ERROR (Status) || EFI_ERROR (SmmPerfCommData->ReturnStatus) || SmmPerfCommData->NumberOfEntries == 0) {
+ return NULL;
}
- *GaugeDataEntry = &mGaugeData[LogEntryKey];
- return EFI_SUCCESS;
+ mGaugeNumberOfEntriesEx = SmmPerfCommData->NumberOfEntries;
+
+ DataSize = mGaugeNumberOfEntriesEx * sizeof(GAUGE_DATA_ENTRY_EX);
+ mGaugeDataEx = AllocateZeroPool(DataSize);
+ ASSERT (mGaugeDataEx != NULL);
+
+ //
+ // Get all SMM gauge data
+ //
+ SmmPerfCommData->Function = SMM_PERF_FUNCTION_GET_GAUGE_DATA;
+ SmmPerfCommData->LogEntryKey = 0;
+ SmmPerfCommData->NumberOfEntries = mGaugeNumberOfEntriesEx;
+ SmmPerfCommData->GaugeDataEx = mGaugeDataEx;
+ Status = mSmmCommunication->Communicate (mSmmCommunication, mSmmPerformanceBuffer, &CommSize);
+ if (EFI_ERROR (Status) || EFI_ERROR (SmmPerfCommData->ReturnStatus)) {
+ FreePool (mGaugeDataEx);
+ mGaugeDataEx = NULL;
+ mGaugeNumberOfEntriesEx = 0;
+ }
+
+ return mGaugeDataEx;
}
/**
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,
@@ -262,13 +368,14 @@ GetGauge ( 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.
+ 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().
@param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
0, then the first performance measurement log entry is retrieved.
@@ -283,23 +390,24 @@ GetGauge ( 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
-GetPerformanceMeasurement (
- IN UINTN LogEntryKey,
+GetPerformanceMeasurementEx (
+ IN UINTN LogEntryKey,
OUT CONST VOID **Handle,
OUT CONST CHAR8 **Token,
OUT CONST CHAR8 **Module,
OUT UINT64 *StartTimeStamp,
- OUT UINT64 *EndTimeStamp
+ OUT UINT64 *EndTimeStamp,
+ OUT UINT32 *Identifier
)
{
- EFI_STATUS Status;
- GAUGE_DATA_ENTRY *GaugeData;
+ GAUGE_DATA_ENTRY_EX *GaugeData;
GaugeData = NULL;
@@ -308,29 +416,40 @@ GetPerformanceMeasurement ( ASSERT (Module != NULL);
ASSERT (StartTimeStamp != NULL);
ASSERT (EndTimeStamp != NULL);
+ ASSERT (Identifier != NULL);
- mGaugeData = GetAllSmmGaugeData();
- if (mGaugeData == NULL) {
- return 0;
- }
-
- Status = GetGauge (LogEntryKey++, &GaugeData);
-
- //
- // Make sure that LogEntryKey is a valid log entry key,
- //
- ASSERT (Status != EFI_INVALID_PARAMETER);
-
- if (EFI_ERROR (Status)) {
+ mGaugeDataEx = GetAllSmmGaugeDataEx();
+ if (mGaugeDataEx != NULL) {
//
- // The LogEntryKey is the last entry (equals to the total entry number).
+ // Make sure that LogEntryKey is a valid log entry key.
//
- return 0;
-
+ ASSERT (LogEntryKey <= mGaugeNumberOfEntriesEx);
+
+ if (LogEntryKey == mGaugeNumberOfEntriesEx) {
+ return 0;
+ }
+
+ GaugeData = &mGaugeDataEx[LogEntryKey++];
+ *Identifier = GaugeData->Identifier;
+ } else {
+ mGaugeData = GetAllSmmGaugeData();
+ if (mGaugeData != NULL) {
+ //
+ // Make sure that LogEntryKey is a valid log entry key.
+ //
+ ASSERT (LogEntryKey <= mGaugeNumberOfEntries);
+
+ if (LogEntryKey == mGaugeNumberOfEntries) {
+ return 0;
+ }
+
+ GaugeData = (GAUGE_DATA_ENTRY_EX *) &mGaugeData[LogEntryKey++];
+ *Identifier = 0;
+ } else {
+ return 0;
+ }
}
- ASSERT (GaugeData != NULL);
-
*Handle = (VOID *) (UINTN) GaugeData->Handle;
*Token = GaugeData->Token;
*Module = GaugeData->Module;
@@ -341,6 +460,60 @@ GetPerformanceMeasurement ( }
/**
+ 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().
+
+ @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 log 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
+ )
+{
+ UINT32 Identifier;
+ return GetPerformanceMeasurementEx (LogEntryKey, Handle, Token, Module, StartTimeStamp, EndTimeStamp, &Identifier);
+}
+
+/**
Returns TRUE if the performance measurement macros are enabled.
This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
diff --git a/MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf b/MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf index 997187c38f..5fdaf051af 100644 --- a/MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf +++ b/MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf @@ -2,9 +2,10 @@ # Performance library instance used in DXE phase to dump SMM performance data.
#
# This library instance allows a DXE driver or UEFI application to dump the SMM performance data.
-# StartPerformanceMeasurement() and EndPerformanceMeasurement() are not implemented.
+# StartPerformanceMeasurement(), EndPerformanceMeasurement(), StartPerformanceMeasurementEx()
+# and EndPerformanceMeasurementEx() are not implemented.
#
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2011 - 2012, 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
@@ -48,7 +49,8 @@ MemoryAllocationLib
[Guids]
- gSmmPerformanceProtocolGuid ## CONSUMES
+ gSmmPerformanceProtocolGuid ## SOMETIMES_CONSUMES
+ gSmmPerformanceExProtocolGuid ## SOMETIMES_CONSUMES
[Protocols]
gEfiSmmCommunicationProtocolGuid ## CONSUMES
diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c index 3b6a44c9b2..49011b701c 100644 --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.c @@ -32,30 +32,27 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. /**
- Gets PEI the GUID HOB for PEI performance.
+ Gets the GUID HOB for PEI performance.
This internal function searches for the GUID HOB for PEI performance.
If that GUID HOB is not found, it will build a new one.
- It returns the data area of that GUID HOB to record performance log.
+ It outputs the data area of that GUID HOB to record performance log.
- @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.
-
- @retval The index of log entry in the array.
+ @param PeiPerformanceLog Pointer to Pointer to PEI performance log header.
+ @param PeiPerformanceIdArray Pointer to Pointer to PEI performance identifier array.
**/
-PEI_PERFORMANCE_LOG_HEADER *
+VOID
InternalGetPerformanceHobLog (
- VOID
+ OUT PEI_PERFORMANCE_LOG_HEADER **PeiPerformanceLog,
+ OUT UINT32 **PeiPerformanceIdArray
)
{
EFI_HOB_GUID_TYPE *GuidHob;
- PEI_PERFORMANCE_LOG_HEADER *PeiPerformanceLog;
- UINTN PeiPerformanceLogSize;
+ UINTN PeiPerformanceSize;
+
+ ASSERT (PeiPerformanceLog != NULL);
+ ASSERT (PeiPerformanceIdArray != NULL);
GuidHob = GetFirstGuidHob (&gPerformanceProtocolGuid);
@@ -63,25 +60,31 @@ InternalGetPerformanceHobLog ( //
// PEI Performance HOB was found, then return the existing one.
//
- PeiPerformanceLog = GET_GUID_HOB_DATA (GuidHob);
+ *PeiPerformanceLog = GET_GUID_HOB_DATA (GuidHob);
+
+ GuidHob = GetFirstGuidHob (&gPerformanceExProtocolGuid);
+ ASSERT (GuidHob != NULL);
+ *PeiPerformanceIdArray = GET_GUID_HOB_DATA (GuidHob);
} else {
//
// PEI Performance HOB was not found, then build one.
//
- PeiPerformanceLogSize = sizeof (PEI_PERFORMANCE_LOG_HEADER) +
- sizeof (PEI_PERFORMANCE_LOG_ENTRY) * PcdGet8 (PcdMaxPeiPerformanceLogEntries);
- PeiPerformanceLog = BuildGuidHob (&gPerformanceProtocolGuid, PeiPerformanceLogSize);
- PeiPerformanceLog = ZeroMem (PeiPerformanceLog, PeiPerformanceLogSize);
+ PeiPerformanceSize = sizeof (PEI_PERFORMANCE_LOG_HEADER) +
+ sizeof (PEI_PERFORMANCE_LOG_ENTRY) * PcdGet8 (PcdMaxPeiPerformanceLogEntries);
+ *PeiPerformanceLog = BuildGuidHob (&gPerformanceProtocolGuid, PeiPerformanceSize);
+ *PeiPerformanceLog = ZeroMem (*PeiPerformanceLog, PeiPerformanceSize);
+
+ PeiPerformanceSize = sizeof (UINT32) * PcdGet8 (PcdMaxPeiPerformanceLogEntries);
+ *PeiPerformanceIdArray = BuildGuidHob (&gPerformanceExProtocolGuid, PeiPerformanceSize);
+ *PeiPerformanceIdArray = ZeroMem (*PeiPerformanceIdArray, PeiPerformanceSize);
}
-
- return PeiPerformanceLog;
}
/**
- Searches in the log array with keyword Handle, Token and Module.
+ Searches in the log array with keyword Handle, Token, Module and Identifier.
This internal function searches for the log entry in the log array.
- If there is an entry that exactly matches the given key word triple
+ If there is an entry that exactly matches the given keywords
and its end time stamp is zero, then the index of that log entry is returned;
otherwise, the the number of log entries in the array is returned.
@@ -93,6 +96,7 @@ InternalGetPerformanceHobLog ( that identifies the component being measured.
@param Module Pointer to a Null-terminated ASCII string
that identifies the module being measured.
+ @param Identifier 32-bit identifier.
@retval The index of log entry in the array.
@@ -100,9 +104,11 @@ InternalGetPerformanceHobLog ( UINT32
InternalSearchForLogEntry (
IN PEI_PERFORMANCE_LOG_HEADER *PeiPerformanceLog,
+ IN UINT32 *PeiPerformanceIdArray,
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module OPTIONAL
+ IN CONST CHAR8 *Module, OPTIONAL
+ IN UINT32 Identifier
)
{
UINT32 Index;
@@ -123,6 +129,7 @@ InternalSearchForLogEntry ( if ((LogEntryArray[Index].Handle == (EFI_PHYSICAL_ADDRESS) (UINTN) Handle) &&
AsciiStrnCmp (LogEntryArray[Index].Token, Token, PEI_PERFORMANCE_STRING_LENGTH) == 0 &&
AsciiStrnCmp (LogEntryArray[Index].Module, Module, PEI_PERFORMANCE_STRING_LENGTH) == 0 &&
+ (PeiPerformanceIdArray[Index] == Identifier) &&
LogEntryArray[Index].EndTimeStamp == 0
) {
break;
@@ -134,7 +141,7 @@ InternalSearchForLogEntry ( /**
Creates a record for the beginning of a performance measurement.
- Creates a record that contains the Handle, Token, and Module.
+ Creates a record that contains the Handle, Token, Module and Identifier.
If TimeStamp is not zero, then TimeStamp is added to the record as the start time.
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.
@@ -146,6 +153,8 @@ InternalSearchForLogEntry ( @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.
@@ -153,18 +162,20 @@ InternalSearchForLogEntry ( **/
RETURN_STATUS
EFIAPI
-StartPerformanceMeasurement (
+StartPerformanceMeasurementEx (
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
+ IN UINT64 TimeStamp,
+ IN UINT32 Identifier
)
{
PEI_PERFORMANCE_LOG_HEADER *PeiPerformanceLog;
+ UINT32 *PeiPerformanceIdArray;
PEI_PERFORMANCE_LOG_ENTRY *LogEntryArray;
UINT32 Index;
- PeiPerformanceLog = InternalGetPerformanceHobLog ();
+ InternalGetPerformanceHobLog (&PeiPerformanceLog, &PeiPerformanceIdArray);
if (PeiPerformanceLog->NumberOfEntries >= PcdGet8 (PcdMaxPeiPerformanceLogEntries)) {
return RETURN_OUT_OF_RESOURCES;
@@ -180,6 +191,9 @@ StartPerformanceMeasurement ( AsciiStrnCpy (LogEntryArray[Index].Module, Module, PEI_PERFORMANCE_STRING_LENGTH);
}
+ LogEntryArray[Index].EndTimeStamp = 0;
+ PeiPerformanceIdArray[Index] = Identifier;
+
if (TimeStamp == 0) {
TimeStamp = GetPerformanceCounter ();
}
@@ -191,7 +205,7 @@ StartPerformanceMeasurement ( /**
Fills in the end time of a performance measurement.
- Looks up the record that matches Handle, Token, and Module.
+ Looks up the record that matches Handle, Token, Module and Identifier.
If the record can not be found then return RETURN_NOT_FOUND.
If the record is found and TimeStamp is not zero,
then TimeStamp is added to the record as the end time.
@@ -205,6 +219,8 @@ StartPerformanceMeasurement ( @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.
@@ -212,14 +228,16 @@ StartPerformanceMeasurement ( **/
RETURN_STATUS
EFIAPI
-EndPerformanceMeasurement (
+EndPerformanceMeasurementEx (
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
+ IN UINT64 TimeStamp,
+ IN UINT32 Identifier
)
{
PEI_PERFORMANCE_LOG_HEADER *PeiPerformanceLog;
+ UINT32 *PeiPerformanceIdArray;
PEI_PERFORMANCE_LOG_ENTRY *LogEntryArray;
UINT32 Index;
@@ -227,8 +245,8 @@ EndPerformanceMeasurement ( TimeStamp = GetPerformanceCounter ();
}
- PeiPerformanceLog = InternalGetPerformanceHobLog ();
- Index = InternalSearchForLogEntry (PeiPerformanceLog, Handle, Token, Module);
+ InternalGetPerformanceHobLog (&PeiPerformanceLog, &PeiPerformanceIdArray);
+ Index = InternalSearchForLogEntry (PeiPerformanceLog, PeiPerformanceIdArray, Handle, Token, Module, Identifier);
if (Index >= PeiPerformanceLog->NumberOfEntries) {
return RETURN_NOT_FOUND;
}
@@ -240,6 +258,8 @@ EndPerformanceMeasurement ( /**
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,
@@ -250,17 +270,18 @@ EndPerformanceMeasurement ( 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.
+ 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().
@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 lof entry entry.
+ 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
@@ -271,22 +292,25 @@ EndPerformanceMeasurement ( 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
-GetPerformanceMeasurement (
+GetPerformanceMeasurementEx (
IN UINTN LogEntryKey,
OUT CONST VOID **Handle,
OUT CONST CHAR8 **Token,
OUT CONST CHAR8 **Module,
OUT UINT64 *StartTimeStamp,
- OUT UINT64 *EndTimeStamp
+ OUT UINT64 *EndTimeStamp,
+ OUT UINT32 *Identifier
)
{
PEI_PERFORMANCE_LOG_HEADER *PeiPerformanceLog;
+ UINT32 *PeiPerformanceIdArray;
PEI_PERFORMANCE_LOG_ENTRY *CurrentLogEntry;
PEI_PERFORMANCE_LOG_ENTRY *LogEntryArray;
UINTN NumberOfEntries;
@@ -296,8 +320,9 @@ GetPerformanceMeasurement ( ASSERT (Module != NULL);
ASSERT (StartTimeStamp != NULL);
ASSERT (EndTimeStamp != NULL);
+ ASSERT (Identifier != NULL);
- PeiPerformanceLog = InternalGetPerformanceHobLog ();
+ InternalGetPerformanceHobLog (&PeiPerformanceLog, &PeiPerformanceIdArray);
NumberOfEntries = (UINTN) (PeiPerformanceLog->NumberOfEntries);
LogEntryArray = (PEI_PERFORMANCE_LOG_ENTRY *) (PeiPerformanceLog + 1);
@@ -310,18 +335,139 @@ GetPerformanceMeasurement ( return 0;
}
- CurrentLogEntry = &(LogEntryArray[LogEntryKey++]);
+ CurrentLogEntry = &(LogEntryArray[LogEntryKey]);
*Handle = (VOID *) (UINTN) (CurrentLogEntry->Handle);
*Token = CurrentLogEntry->Token;
*Module = CurrentLogEntry->Module;
*StartTimeStamp = CurrentLogEntry->StartTimeStamp;
*EndTimeStamp = CurrentLogEntry->EndTimeStamp;
+ *Identifier = PeiPerformanceIdArray[LogEntryKey++];
return LogEntryKey;
}
/**
+ Creates a record for the beginning of a performance measurement.
+
+ Creates a record that contains the Handle, Token, and Module.
+ If TimeStamp is not zero, then TimeStamp is added to the record as the start time.
+ 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.
+
+ @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);
+}
+
+/**
+ Fills in the end time of a performance measurement.
+
+ Looks up the record that matches Handle, Token, and Module.
+ If the record can not be found then return RETURN_NOT_FOUND.
+ If the record is found and TimeStamp is not zero,
+ then TimeStamp is added to the record as the end time.
+ If the record is found and TimeStamp is zero, then this function reads
+ the current time stamp and adds that time stamp value to the record 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().
+
+ @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
+ )
+{
+ UINT32 Identifier;
+ return GetPerformanceMeasurementEx (LogEntryKey, Handle, Token, Module, StartTimeStamp, EndTimeStamp, &Identifier);
+}
+
+/**
Returns TRUE if the performance measurement macros are enabled.
This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
diff --git a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf index cee14196a0..572ec5422b 100644 --- a/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf +++ b/MdeModulePkg/Library/PeiPerformanceLib/PeiPerformanceLib.inf @@ -6,7 +6,7 @@ # and consumes GUIDed HOB for performance logging. The GUIDed HOB is passed to DXE phase
# so that it can be taken over by DxeCorePerformanceLib.
#
-# Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2006 - 2012, 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
@@ -50,7 +50,8 @@ [Guids]
- gPerformanceProtocolGuid ## HOB
+ gPerformanceProtocolGuid ## PRODUCES ## HOB
+ gPerformanceExProtocolGuid ## PRODUCES ## HOB
[Pcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries
diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c index 98426c302c..5ee1f603d1 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.c @@ -3,13 +3,13 @@ This library provides the performance measurement interfaces and initializes performance
logging for the SMM phase.
- It initializes SMM phase performance logging by publishing the Performance Protocol,
+ It initializes SMM phase performance logging by publishing the SMM Performance and PerformanceEx Protocol,
which is consumed by SmmPerformanceLib to logging performance data in SMM phase.
This library is mainly used by SMM Core to start performance logging to ensure that
- SMM Performance Protocol is installed at the very beginning of SMM phase.
+ SMM Performance and PerformanceEx Protocol are installed at the very beginning of SMM phase.
-Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2012, 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
@@ -48,7 +48,7 @@ EFI_SMRAM_DESCRIPTOR *mSmramRanges; UINTN mSmramRangeCount;
//
-// Interfaces for performance protocol.
+// Interfaces for SMM Performance Protocol.
//
PERFORMANCE_PROTOCOL mPerformanceInterface = {
StartGauge,
@@ -56,11 +56,20 @@ PERFORMANCE_PROTOCOL mPerformanceInterface = { GetGauge
};
+//
+// Interfaces for SMM PerformanceEx Protocol.
+//
+PERFORMANCE_EX_PROTOCOL mPerformanceExInterface = {
+ StartGaugeEx,
+ EndGaugeEx,
+ GetGaugeEx
+};
+
/**
- Searches in the gauge array with keyword Handle, Token and Module.
+ Searches in the gauge array with keyword Handle, Token, Module and Identfier.
This internal function searches for the gauge entry in the gauge array.
- If there is an entry that exactly matches the given key word triple
+ If there is an entry that exactly matches the given keywords
and its end time stamp is zero, then the index of that gauge entry is returned;
otherwise, the the number of gauge entries in the array is returned.
@@ -70,6 +79,7 @@ PERFORMANCE_PROTOCOL mPerformanceInterface = { that identifies the component being measured.
@param Module Pointer to a Null-terminated ASCII string
that identifies the module being measured.
+ @param Identifier 32-bit identifier.
@retval The index of gauge entry in the array.
@@ -78,12 +88,13 @@ UINT32 SmmSearchForGaugeEntry (
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
- IN CONST CHAR8 *Module OPTIONAL
+ IN CONST CHAR8 *Module, OPTIONAL
+ IN CONST UINT32 Identifier
)
{
UINT32 Index;
UINT32 NumberOfEntries;
- GAUGE_DATA_ENTRY *GaugeEntryArray;
+ GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;
if (Token == NULL) {
Token = "";
@@ -93,13 +104,14 @@ SmmSearchForGaugeEntry ( }
NumberOfEntries = mGaugeData->NumberOfEntries;
- GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
+ GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
for (Index = 0; Index < NumberOfEntries; Index++) {
- if ((GaugeEntryArray[Index].Handle == (EFI_PHYSICAL_ADDRESS) (UINTN) Handle) &&
- AsciiStrnCmp (GaugeEntryArray[Index].Token, Token, SMM_PERFORMANCE_STRING_LENGTH) == 0 &&
- AsciiStrnCmp (GaugeEntryArray[Index].Module, Module, SMM_PERFORMANCE_STRING_LENGTH) == 0 &&
- GaugeEntryArray[Index].EndTimeStamp == 0) {
+ if ((GaugeEntryExArray[Index].Handle == (EFI_PHYSICAL_ADDRESS) (UINTN) Handle) &&
+ AsciiStrnCmp (GaugeEntryExArray[Index].Token, Token, SMM_PERFORMANCE_STRING_LENGTH) == 0 &&
+ AsciiStrnCmp (GaugeEntryExArray[Index].Module, Module, SMM_PERFORMANCE_STRING_LENGTH) == 0 &&
+ (GaugeEntryExArray[Index].Identifier == Identifier) &&
+ GaugeEntryExArray[Index].EndTimeStamp == 0) {
break;
}
}
@@ -112,7 +124,7 @@ SmmSearchForGaugeEntry ( 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.
+ 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
@@ -125,6 +137,8 @@ SmmSearchForGaugeEntry ( @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.
@@ -132,15 +146,17 @@ SmmSearchForGaugeEntry ( **/
EFI_STATUS
EFIAPI
-StartGauge (
+StartGaugeEx (
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
+ IN UINT64 TimeStamp,
+ IN UINT32 Identifier
)
{
- GAUGE_DATA_ENTRY *GaugeEntryArray;
+ GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;
UINTN GaugeDataSize;
+ GAUGE_DATA_HEADER *NewGaugeData;
UINTN OldGaugeDataSize;
GAUGE_DATA_HEADER *OldGaugeData;
UINT32 Index;
@@ -153,15 +169,19 @@ StartGauge ( // Try to enlarge the scale of gauge array.
//
OldGaugeData = mGaugeData;
- OldGaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords;
+ OldGaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY_EX) * mMaxGaugeRecords;
- mMaxGaugeRecords *= 2;
- GaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords;
+ GaugeDataSize = sizeof (GAUGE_DATA_HEADER) + sizeof (GAUGE_DATA_ENTRY_EX) * mMaxGaugeRecords * 2;
- mGaugeData = AllocateZeroPool (GaugeDataSize);
- if (mGaugeData == NULL) {
+ NewGaugeData = AllocateZeroPool (GaugeDataSize);
+ if (NewGaugeData == NULL) {
+ ReleaseSpinLock (&mSmmPerfLock);
return EFI_OUT_OF_RESOURCES;
}
+
+ mGaugeData = NewGaugeData;
+ mMaxGaugeRecords *= 2;
+
//
// Initialize new data array and migrate old data one.
//
@@ -170,20 +190,23 @@ StartGauge ( FreePool (OldGaugeData);
}
- GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
- GaugeEntryArray[Index].Handle = (EFI_PHYSICAL_ADDRESS) (UINTN) Handle;
+ GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
+ GaugeEntryExArray[Index].Handle = (EFI_PHYSICAL_ADDRESS) (UINTN) Handle;
if (Token != NULL) {
- AsciiStrnCpy (GaugeEntryArray[Index].Token, Token, SMM_PERFORMANCE_STRING_LENGTH);
+ AsciiStrnCpy (GaugeEntryExArray[Index].Token, Token, SMM_PERFORMANCE_STRING_LENGTH);
}
if (Module != NULL) {
- AsciiStrnCpy (GaugeEntryArray[Index].Module, Module, SMM_PERFORMANCE_STRING_LENGTH);
+ AsciiStrnCpy (GaugeEntryExArray[Index].Module, Module, SMM_PERFORMANCE_STRING_LENGTH);
}
+ GaugeEntryExArray[Index].EndTimeStamp = 0;
+ GaugeEntryExArray[Index].Identifier = Identifier;
+
if (TimeStamp == 0) {
TimeStamp = GetPerformanceCounter ();
}
- GaugeEntryArray[Index].StartTimeStamp = TimeStamp;
+ GaugeEntryExArray[Index].StartTimeStamp = TimeStamp;
mGaugeData->NumberOfEntries++;
@@ -197,7 +220,7 @@ StartGauge ( 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.
+ 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.
@@ -211,6 +234,8 @@ StartGauge ( @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.
@@ -218,57 +243,65 @@ StartGauge ( **/
EFI_STATUS
EFIAPI
-EndGauge (
+EndGaugeEx (
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
+ IN UINT64 TimeStamp,
+ IN UINT32 Identifier
)
{
- GAUGE_DATA_ENTRY *GaugeEntryArray;
- UINT32 Index;
+ GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;
+ UINT32 Index;
+
+ AcquireSpinLock (&mSmmPerfLock);
if (TimeStamp == 0) {
TimeStamp = GetPerformanceCounter ();
}
- Index = SmmSearchForGaugeEntry (Handle, Token, Module);
+ Index = SmmSearchForGaugeEntry (Handle, Token, Module, Identifier);
if (Index >= mGaugeData->NumberOfEntries) {
+ ReleaseSpinLock (&mSmmPerfLock);
return EFI_NOT_FOUND;
}
- GaugeEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
- GaugeEntryArray[Index].EndTimeStamp = TimeStamp;
+ GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
+ GaugeEntryExArray[Index].EndTimeStamp = TimeStamp;
+
+ ReleaseSpinLock (&mSmmPerfLock);
return EFI_SUCCESS;
}
/**
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
- GaugeDataEntry stores the pointer to that entry.
+ 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 GaugeDataEntry The indirect pointer to the gauge data entry specified by LogEntryKey
+ @param GaugeDataEntryEx The indirect pointer to the extended gauge data entry specified by LogEntryKey
if the retrieval is successful.
- @retval EFI_SUCCESS The GuageDataEntry is successfully found based on LogEntryKey.
+ @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 GaugeDataEntry is NULL.
+ @retval EFI_INVALIDE_PARAMETER GaugeDataEntryEx is NULL.
**/
EFI_STATUS
EFIAPI
-GetGauge (
- IN UINTN LogEntryKey,
- OUT GAUGE_DATA_ENTRY **GaugeDataEntry
+GetGaugeEx (
+ IN UINTN LogEntryKey,
+ OUT GAUGE_DATA_ENTRY_EX **GaugeDataEntryEx
)
{
UINTN NumberOfEntries;
- GAUGE_DATA_ENTRY *LogEntryArray;
+ GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;
NumberOfEntries = (UINTN) (mGaugeData->NumberOfEntries);
if (LogEntryKey > NumberOfEntries) {
@@ -278,16 +311,130 @@ GetGauge ( return EFI_NOT_FOUND;
}
- LogEntryArray = (GAUGE_DATA_ENTRY *) (mGaugeData + 1);
+ GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
- if (GaugeDataEntry == NULL) {
+ if (GaugeDataEntryEx == NULL) {
return EFI_INVALID_PARAMETER;
}
- *GaugeDataEntry = &LogEntryArray[LogEntryKey];
+ *GaugeDataEntryEx = &GaugeEntryExArray[LogEntryKey];
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, 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.
+
+ 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
+ )
+{
+ EFI_STATUS Status;
+ GAUGE_DATA_ENTRY_EX *GaugeEntryEx;
+
+ Status = GetGaugeEx (LogEntryKey, &GaugeEntryEx);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+
+ if (GaugeDataEntry == NULL) {
+ return EFI_INVALID_PARAMETER;
+ }
+
+ *GaugeDataEntry = (GAUGE_DATA_ENTRY *) GaugeEntryEx;
+
+ return EFI_SUCCESS;
+}
/**
This function check if the address is in SMRAM.
@@ -319,7 +466,88 @@ IsAddressInSmram ( /**
Communication service SMI Handler entry.
- This SMI handler provides services for the variable wrapper driver.
+ This SMI handler provides services for the performance wrapper driver.
+
+ @param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
+ @param[in] RegisterContext Points to an optional handler context which was specified when the
+ handler was registered.
+ @param[in, out] CommBuffer A pointer to a collection of data in memory that will
+ be conveyed from a non-SMM environment into an SMM environment.
+ @param[in, out] CommBufferSize The size of the CommBuffer.
+
+ @retval EFI_SUCCESS The interrupt was handled and quiesced. No other handlers
+ should still be called.
+ @retval EFI_WARN_INTERRUPT_SOURCE_QUIESCED The interrupt has been quiesced but other handlers should
+ still be called.
+ @retval EFI_WARN_INTERRUPT_SOURCE_PENDING The interrupt is still pending and other handlers should still
+ be called.
+ @retval EFI_INTERRUPT_PENDING The interrupt could not be quiesced.
+**/
+EFI_STATUS
+EFIAPI
+SmmPerformanceHandlerEx (
+ IN EFI_HANDLE DispatchHandle,
+ IN CONST VOID *RegisterContext,
+ IN OUT VOID *CommBuffer,
+ IN OUT UINTN *CommBufferSize
+ )
+{
+ EFI_STATUS Status;
+ SMM_PERF_COMMUNICATE_EX *SmmPerfCommData;
+ GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;
+ UINTN DataSize;
+
+ GaugeEntryExArray = NULL;
+
+ ASSERT (CommBuffer != NULL);
+
+ SmmPerfCommData = (SMM_PERF_COMMUNICATE_EX *)CommBuffer;
+
+ switch (SmmPerfCommData->Function) {
+ case SMM_PERF_FUNCTION_GET_GAUGE_ENTRY_NUMBER :
+ SmmPerfCommData->NumberOfEntries = mGaugeData->NumberOfEntries;
+ Status = EFI_SUCCESS;
+ break;
+
+ case SMM_PERF_FUNCTION_GET_GAUGE_DATA :
+ if ( SmmPerfCommData->GaugeDataEx == NULL || SmmPerfCommData->NumberOfEntries == 0 ||
+ (SmmPerfCommData->LogEntryKey + SmmPerfCommData->NumberOfEntries) > mGaugeData->NumberOfEntries) {
+ Status = EFI_INVALID_PARAMETER;
+ break;
+ }
+
+ //
+ // Sanity check
+ //
+ DataSize = SmmPerfCommData->NumberOfEntries * sizeof(GAUGE_DATA_ENTRY_EX);
+ if (IsAddressInSmram ((EFI_PHYSICAL_ADDRESS)(UINTN)SmmPerfCommData->GaugeDataEx, DataSize)) {
+ DEBUG ((EFI_D_ERROR, "Smm Performance Data buffer is in SMRAM!\n"));
+ Status = EFI_ACCESS_DENIED;
+ break ;
+ }
+
+ GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
+ CopyMem(
+ (UINT8 *) (SmmPerfCommData->GaugeDataEx),
+ (UINT8 *) &GaugeEntryExArray[SmmPerfCommData->LogEntryKey],
+ DataSize
+ );
+ Status = EFI_SUCCESS;
+ break;
+
+ default:
+ ASSERT (FALSE);
+ Status = EFI_UNSUPPORTED;
+ }
+
+ SmmPerfCommData->ReturnStatus = Status;
+ return EFI_SUCCESS;
+}
+
+/**
+ Communication service SMI Handler entry.
+
+ This SMI handler provides services for the performance wrapper driver.
@param[in] DispatchHandle The unique handle assigned to this handler by SmiHandlerRegister().
@param[in] RegisterContext Points to an optional handler context which was specified when the
@@ -341,39 +569,36 @@ EFIAPI SmmPerformanceHandler (
IN EFI_HANDLE DispatchHandle,
IN CONST VOID *RegisterContext,
- IN OUT VOID *CommBuffer,
- IN OUT UINTN *CommBufferSize
+ IN OUT VOID *CommBuffer,
+ IN OUT UINTN *CommBufferSize
)
{
EFI_STATUS Status;
SMM_PERF_COMMUNICATE *SmmPerfCommData;
- GAUGE_DATA_ENTRY *GaugeData;
+ GAUGE_DATA_ENTRY_EX *GaugeEntryExArray;
UINTN DataSize;
+ UINTN Index;
+ UINTN LogEntryKey;
+
+ GaugeEntryExArray = NULL;
- GaugeData = NULL;
-
ASSERT (CommBuffer != NULL);
- SmmPerfCommData = (SMM_PERF_COMMUNICATE*)CommBuffer;
+ SmmPerfCommData = (SMM_PERF_COMMUNICATE *)CommBuffer;
switch (SmmPerfCommData->Function) {
case SMM_PERF_FUNCTION_GET_GAUGE_ENTRY_NUMBER :
SmmPerfCommData->NumberOfEntries = mGaugeData->NumberOfEntries;
- return Status = EFI_SUCCESS;
+ Status = EFI_SUCCESS;
break;
case SMM_PERF_FUNCTION_GET_GAUGE_DATA :
- if ( SmmPerfCommData->GaugeData == NULL || SmmPerfCommData->NumberOfEntries <= 0 ||
- (SmmPerfCommData->LogEntryKey + SmmPerfCommData->NumberOfEntries) > mGaugeData->NumberOfEntries) {
+ if ( SmmPerfCommData->GaugeData == NULL || SmmPerfCommData->NumberOfEntries == 0 ||
+ (SmmPerfCommData->LogEntryKey + SmmPerfCommData->NumberOfEntries) > mGaugeData->NumberOfEntries) {
Status = EFI_INVALID_PARAMETER;
break;
- }
-
- Status = GetGauge(SmmPerfCommData->LogEntryKey, &GaugeData);
- if (EFI_ERROR(Status)) {
- break;
}
-
+
//
// Sanity check
//
@@ -384,17 +609,23 @@ SmmPerformanceHandler ( break ;
}
- CopyMem(
- (UINT8*)SmmPerfCommData->GaugeData,
- (UINT8*)GaugeData,
- DataSize
- );
+ GaugeEntryExArray = (GAUGE_DATA_ENTRY_EX *) (mGaugeData + 1);
+
+ LogEntryKey = SmmPerfCommData->LogEntryKey;
+ for (Index = 0; Index < SmmPerfCommData->NumberOfEntries; Index++) {
+ CopyMem(
+ (UINT8 *) &(SmmPerfCommData->GaugeData[Index]),
+ (UINT8 *) &GaugeEntryExArray[LogEntryKey++],
+ sizeof (GAUGE_DATA_ENTRY)
+ );
+ }
+ Status = EFI_SUCCESS;
break;
default:
ASSERT (FALSE);
Status = EFI_UNSUPPORTED;
- }
+ }
SmmPerfCommData->ReturnStatus = Status;
return EFI_SUCCESS;
@@ -402,7 +633,7 @@ SmmPerformanceHandler ( /**
SmmBase2 protocol notify callback function, when SMST and SMM memory service get initialized
- this function is callbacked to to initialize the Smm Performance Lib
+ this function is callbacked to initialize the Smm Performance Lib
@param Event The event of notify protocol.
@param Context Notify event context.
@@ -426,9 +657,9 @@ InitializeSmmCorePerformanceLib ( //
InitializeSpinLock (&mSmmPerfLock);
- mMaxGaugeRecords = INIT_SMM_GAUGE_DATA_ENTRIES + PcdGet8 (PcdMaxPeiPerformanceLogEntries);
+ mMaxGaugeRecords = INIT_SMM_GAUGE_DATA_ENTRIES;
- mGaugeData = AllocateZeroPool (sizeof (GAUGE_DATA_HEADER) + (sizeof (GAUGE_DATA_ENTRY) * mMaxGaugeRecords));
+ mGaugeData = AllocateZeroPool (sizeof (GAUGE_DATA_HEADER) + (sizeof (GAUGE_DATA_ENTRY_EX) * mMaxGaugeRecords));
ASSERT (mGaugeData != NULL);
//
@@ -464,19 +695,27 @@ InitializeSmmCorePerformanceLib ( );
ASSERT_EFI_ERROR (Status);
+ Status = gSmst->SmmInstallProtocolInterface (
+ &mHandle,
+ &gSmmPerformanceExProtocolGuid,
+ EFI_NATIVE_INTERFACE,
+ &mPerformanceExInterface
+ );
+ ASSERT_EFI_ERROR (Status);
+
///
/// Register SMM Performance SMI handler
///
Handle = NULL;
Status = gSmst->SmiHandlerRegister (SmmPerformanceHandler, &gSmmPerformanceProtocolGuid, &Handle);
ASSERT_EFI_ERROR (Status);
+ Status = gSmst->SmiHandlerRegister (SmmPerformanceHandlerEx, &gSmmPerformanceExProtocolGuid, &Handle);
+ ASSERT_EFI_ERROR (Status);
}
/**
- The constructor function initializes Performance infrastructure for DXE phase.
-
- The constructor function publishes Performance protocol, allocates memory to log DXE performance
- and merges PEI performance data to DXE performance log.
+ The constructor function initializes the Performance Measurement Enable flag and
+ registers SmmBase2 protocol notify callback.
It will ASSERT() if one of these operations fails and it will always return EFI_SUCCESS.
@param ImageHandle The firmware allocated handle for the EFI image.
@@ -535,7 +774,7 @@ SmmCorePerformanceLibConstructor ( 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.
+ 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
@@ -548,6 +787,8 @@ SmmCorePerformanceLibConstructor ( @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.
@@ -555,17 +796,15 @@ SmmCorePerformanceLibConstructor ( **/
RETURN_STATUS
EFIAPI
-StartPerformanceMeasurement (
+StartPerformanceMeasurementEx (
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
+ IN UINT64 TimeStamp,
+ IN UINT32 Identifier
)
{
- EFI_STATUS Status;
-
- Status = StartGauge (Handle, Token, Module, TimeStamp);
- return (RETURN_STATUS) Status;
+ return (RETURN_STATUS) StartGaugeEx (Handle, Token, Module, TimeStamp, Identifier);
}
/**
@@ -573,7 +812,7 @@ StartPerformanceMeasurement ( 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.
+ 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 RETURN_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.
@@ -587,6 +826,8 @@ StartPerformanceMeasurement ( @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.
@@ -594,21 +835,21 @@ StartPerformanceMeasurement ( **/
RETURN_STATUS
EFIAPI
-EndPerformanceMeasurement (
+EndPerformanceMeasurementEx (
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
+ IN UINT64 TimeStamp,
+ IN UINT32 Identifier
)
{
- EFI_STATUS Status;
-
- Status = EndGauge (Handle, Token, Module, TimeStamp);
- return (RETURN_STATUS) Status;
+ return (RETURN_STATUS) EndGaugeEx (Handle, Token, Module, TimeStamp, Identifier);
}
/**
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,
@@ -619,13 +860,14 @@ EndPerformanceMeasurement ( 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.
+ 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().
@param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
0, then the first performance measurement log entry is retrieved.
@@ -640,23 +882,25 @@ EndPerformanceMeasurement ( 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
-GetPerformanceMeasurement (
- IN UINTN LogEntryKey,
+GetPerformanceMeasurementEx (
+ IN UINTN LogEntryKey,
OUT CONST VOID **Handle,
OUT CONST CHAR8 **Token,
OUT CONST CHAR8 **Module,
OUT UINT64 *StartTimeStamp,
- OUT UINT64 *EndTimeStamp
+ OUT UINT64 *EndTimeStamp,
+ OUT UINT32 *Identifier
)
{
- EFI_STATUS Status;
- GAUGE_DATA_ENTRY *GaugeData;
+ EFI_STATUS Status;
+ GAUGE_DATA_ENTRY_EX *GaugeData;
GaugeData = NULL;
@@ -665,8 +909,9 @@ GetPerformanceMeasurement ( ASSERT (Module != NULL);
ASSERT (StartTimeStamp != NULL);
ASSERT (EndTimeStamp != NULL);
+ ASSERT (Identifier != NULL);
- Status = GetGauge (LogEntryKey++, &GaugeData);
+ Status = GetGaugeEx (LogEntryKey++, &GaugeData);
//
// Make sure that LogEntryKey is a valid log entry key,
@@ -687,11 +932,137 @@ GetPerformanceMeasurement ( *Module = GaugeData->Module;
*StartTimeStamp = GaugeData->StartTimeStamp;
*EndTimeStamp = GaugeData->EndTimeStamp;
+ *Identifier = GaugeData->Identifier;
return LogEntryKey;
}
/**
+ 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 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);
+}
+
+/**
+ 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 RETURN_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 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().
+
+ @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 log 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
+ )
+{
+ UINT32 Identifier;
+ return GetPerformanceMeasurementEx (LogEntryKey, Handle, Token, Module, StartTimeStamp, EndTimeStamp, &Identifier);
+}
+
+/**
Returns TRUE if the performance measurement macros are enabled.
This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
@@ -711,5 +1082,3 @@ PerformanceMeasurementEnabled ( {
return mPerformanceMeasurementEnabled;
}
-
-
diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf index cbf2c545f6..0cc367f971 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLib.inf @@ -3,12 +3,12 @@ #
# This library provides the performance measurement interfaces and initializes performance
# logging for the SMM phase.
-# It initializes SMM phase performance logging by publishing the Performance Protocol,
+# It initializes SMM phase performance logging by publishing the SMM Performance and PerformanceEx Protocol,
# which is consumed by SmmPerformanceLib to logging performance data in SMM phase.
# This library is mainly used by SMM Core to start performance logging to ensure that
-# SMM Performance Protocol is installed at the very beginning of SMM phase.
+# SMM Performance and PerformanceEx Protocol are installed at the very beginning of SMM phase.
#
-# Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2011 - 2012, 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
@@ -54,6 +54,7 @@ BaseLib
DebugLib
SynchronizationLib
+ SmmServicesTableLib
[Protocols]
gEfiSmmBase2ProtocolGuid ## CONSUMES
@@ -61,7 +62,7 @@ [Guids]
gSmmPerformanceProtocolGuid ## PRODUCES
+ gSmmPerformanceExProtocolGuid ## PRODUCES
[Pcd]
- gEfiMdeModulePkgTokenSpaceGuid.PcdMaxPeiPerformanceLogEntries
gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask
diff --git a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLibInternal.h b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLibInternal.h index 159d92b4a2..a023688278 100644 --- a/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLibInternal.h +++ b/MdeModulePkg/Library/SmmCorePerformanceLib/SmmCorePerformanceLibInternal.h @@ -1,10 +1,10 @@ /** @file
Master header files for SmmCorePerformanceLib instance.
- This header file holds the prototypes of the Performance Protocol published by this
+ This header file holds the prototypes of the SMM Performance and PerformanceEx Protocol published by this
library instance at its constructor.
-Copyright (c) 2011, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2011 - 2012, 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
@@ -37,7 +37,108 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Protocol/SmmAccess2.h>
//
-// Interface declarations for Performance Protocol.
+// Interface declarations for SMM 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.
+
+**/
+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
@@ -106,6 +207,8 @@ EndGauge ( /**
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
diff --git a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c b/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c index 3644824e7b..c01d16d1eb 100644 --- a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c +++ b/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.c @@ -2,8 +2,8 @@ Performance Library used in SMM phase.
This library instance provides infrastructure for SMM drivers to log performance
- data. It consumes SMM Performance Protocol published by SmmCorePerformanceLib
- to log performance data. If Performance Protocol is not available, it does not log any
+ 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 - 2012, Intel Corporation. All rights reserved.<BR>
@@ -26,21 +26,15 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include <Library/PcdLib.h>
#include <Library/BaseMemoryLib.h>
-#include <Protocol/SmmCommunication.h>
-
//
-// The cached performance protocol interface.
+// The cached SMM Performance Protocol and SMM PerformanceEx Protocol interface.
//
-PERFORMANCE_PROTOCOL *mPerformance = NULL;
-BOOLEAN mPerformanceMeasurementEnabled;
-
+PERFORMANCE_PROTOCOL *mPerformance = NULL;
+PERFORMANCE_EX_PROTOCOL *mPerformanceEx = NULL;
+BOOLEAN mPerformanceMeasurementEnabled;
/**
- The constructor function initializes Performance infrastructure for DXE phase.
-
- The constructor function publishes Performance protocol, allocates memory to log DXE performance
- and merges PEI performance data to DXE performance log.
- It will ASSERT() if one of these operations fails and it will always return EFI_SUCCESS.
+ The constructor function initializes the Performance Measurement Enable flag
@param ImageHandle The firmware allocated handle for the EFI image.
@param SystemTable A pointer to the EFI System Table.
@@ -62,13 +56,12 @@ SmmPerformanceLibConstructor ( }
/**
- The constructor function caches the pointer to Performance protocol.
+ The function caches the pointers to SMM PerformanceEx protocol and Performance Protocol.
- The constructor function locates SMM erformance protocol from the SMM protocol database.
- It will ASSERT() if that operation fails and it will always return EFI_SUCCESS.
+ The function locates SMM PerformanceEx protocol and Performance Protocol from protocol database.
- @retval EFI_SUCCESS Performance protocol is successfully located.
- @retval Other Performance protocol is not located to log performance.
+ @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
@@ -76,10 +69,21 @@ GetPerformanceProtocol ( VOID
)
{
- EFI_STATUS Status;
- PERFORMANCE_PROTOCOL *Performance;
+ EFI_STATUS Status;
+ PERFORMANCE_PROTOCOL *Performance;
+ PERFORMANCE_EX_PROTOCOL *PerformanceEx;
- if (mPerformance != NULL) {
+ if (mPerformanceEx != NULL || mPerformance != NULL) {
+ return EFI_SUCCESS;
+ }
+
+ Status = gSmst->SmmLocateProtocol (&gSmmPerformanceExProtocolGuid, NULL, (VOID **) &PerformanceEx);
+ if (!EFI_ERROR (Status)) {
+ ASSERT (PerformanceEx != NULL);
+ //
+ // Cache PerformanceEx Protocol.
+ //
+ mPerformanceEx = PerformanceEx;
return EFI_SUCCESS;
}
@@ -90,15 +94,16 @@ GetPerformanceProtocol ( // Cache performance protocol.
//
mPerformance = Performance;
+ return EFI_SUCCESS;
}
- return Status;
+ return EFI_NOT_FOUND;
}
/**
Creates a record for the beginning of a performance measurement.
- Creates a record that contains the Handle, Token, and Module.
+ Creates a record that contains the Handle, Token, Module and Identifier.
If TimeStamp is not zero, then TimeStamp is added to the record as the start time.
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.
@@ -110,6 +115,8 @@ GetPerformanceProtocol ( @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.
@@ -117,11 +124,12 @@ GetPerformanceProtocol ( **/
RETURN_STATUS
EFIAPI
-StartPerformanceMeasurement (
+StartPerformanceMeasurementEx (
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
+ IN UINT64 TimeStamp,
+ IN UINT32 Identifier
)
{
EFI_STATUS Status;
@@ -131,7 +139,13 @@ StartPerformanceMeasurement ( return RETURN_OUT_OF_RESOURCES;
}
- Status = mPerformance->StartGauge (Handle, Token, Module, TimeStamp);
+ if (mPerformanceEx != NULL) {
+ Status = mPerformanceEx->StartGaugeEx (Handle, Token, Module, TimeStamp, Identifier);
+ } else if (mPerformance != NULL) {
+ Status = mPerformance->StartGauge (Handle, Token, Module, TimeStamp);
+ } else {
+ ASSERT (FALSE);
+ }
return (RETURN_STATUS) Status;
}
@@ -139,7 +153,7 @@ StartPerformanceMeasurement ( /**
Fills in the end time of a performance measurement.
- Looks up the record that matches Handle, Token, and Module.
+ Looks up the record that matches Handle, Token, Module and Identifier.
If the record can not be found then return RETURN_NOT_FOUND.
If the record is found and TimeStamp is not zero,
then TimeStamp is added to the record as the end time.
@@ -153,6 +167,8 @@ StartPerformanceMeasurement ( @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.
@@ -160,11 +176,12 @@ StartPerformanceMeasurement ( **/
RETURN_STATUS
EFIAPI
-EndPerformanceMeasurement (
+EndPerformanceMeasurementEx (
IN CONST VOID *Handle, OPTIONAL
IN CONST CHAR8 *Token, OPTIONAL
IN CONST CHAR8 *Module, OPTIONAL
- IN UINT64 TimeStamp
+ IN UINT64 TimeStamp,
+ IN UINT32 Identifier
)
{
EFI_STATUS Status;
@@ -174,13 +191,21 @@ EndPerformanceMeasurement ( return RETURN_NOT_FOUND;
}
- Status = mPerformance->EndGauge (Handle, Token, Module, TimeStamp);
+ if (mPerformanceEx != NULL) {
+ Status = mPerformanceEx->EndGaugeEx (Handle, Token, Module, TimeStamp, Identifier);
+ } else if (mPerformance != NULL) {
+ Status = mPerformance->EndGauge (Handle, Token, Module, TimeStamp);
+ } else {
+ ASSERT (FALSE);
+ }
return (RETURN_STATUS) Status;
}
/**
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,
@@ -191,13 +216,14 @@ EndPerformanceMeasurement ( 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.
+ 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().
@param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
0, then the first performance measurement log entry is retrieved.
@@ -212,24 +238,26 @@ EndPerformanceMeasurement ( 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
-GetPerformanceMeasurement (
- IN UINTN LogEntryKey,
+GetPerformanceMeasurementEx (
+ IN UINTN LogEntryKey,
OUT CONST VOID **Handle,
OUT CONST CHAR8 **Token,
OUT CONST CHAR8 **Module,
OUT UINT64 *StartTimeStamp,
- OUT UINT64 *EndTimeStamp
+ OUT UINT64 *EndTimeStamp,
+ OUT UINT32 *Identifier
)
{
- EFI_STATUS Status;
- GAUGE_DATA_ENTRY *GaugeData;
-
+ EFI_STATUS Status;
+ GAUGE_DATA_ENTRY_EX *GaugeData;
+
GaugeData = NULL;
ASSERT (Handle != NULL);
@@ -237,13 +265,21 @@ GetPerformanceMeasurement ( ASSERT (Module != NULL);
ASSERT (StartTimeStamp != NULL);
ASSERT (EndTimeStamp != NULL);
+ ASSERT (Identifier != NULL);
Status = GetPerformanceProtocol ();
if (EFI_ERROR (Status)) {
return 0;
}
- Status = mPerformance->GetGauge (LogEntryKey++, &GaugeData);
+ 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,
@@ -264,11 +300,136 @@ GetPerformanceMeasurement ( *Module = GaugeData->Module;
*StartTimeStamp = GaugeData->StartTimeStamp;
*EndTimeStamp = GaugeData->EndTimeStamp;
+ if (mPerformanceEx != NULL) {
+ *Identifier = GaugeData->Identifier;
+ } else {
+ *Identifier = 0;
+ }
return LogEntryKey;
}
/**
+ Creates a record for the beginning of a performance measurement.
+
+ Creates a record that contains the Handle, Token, and Module.
+ If TimeStamp is not zero, then TimeStamp is added to the record as the start time.
+ 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.
+
+ @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);
+}
+
+/**
+ Fills in the end time of a performance measurement.
+
+ Looks up the record that matches Handle, Token, and Module.
+ If the record can not be found then return RETURN_NOT_FOUND.
+ If the record is found and TimeStamp is not zero,
+ then TimeStamp is added to the record as the end time.
+ If the record is found and TimeStamp is zero, then this function reads
+ the current time stamp and adds that time stamp value to the record 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().
+
+ @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 log 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
+ )
+{
+ UINT32 Identifier;
+ return GetPerformanceMeasurementEx (LogEntryKey, Handle, Token, Module, StartTimeStamp, EndTimeStamp, &Identifier);
+}
+
+/**
Returns TRUE if the performance measurement macros are enabled.
This function returns TRUE if the PERFORMANCE_LIBRARY_PROPERTY_MEASUREMENT_ENABLED bit of
diff --git a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.inf b/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.inf index 9397fec368..ac25a434d2 100644 --- a/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.inf +++ b/MdeModulePkg/Library/SmmPerformanceLib/SmmPerformanceLib.inf @@ -2,11 +2,11 @@ # Performance library instance used in SMM phase.
#
# This library instance provides infrastructure for SMM drivers to log performance
-# data. It consumes SMM Performance Protocol published by SmmCorePerformanceLib
-# to log performance data. If Performance Protocol is not available, it does not log any
+# 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, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2011 - 2012, 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
@@ -48,16 +48,9 @@ DebugLib
BaseMemoryLib
-[Protocols]
- gEfiSmmCommunicationProtocolGuid ## CONSUMES
-
-
[Guids]
- gSmmPerformanceProtocolGuid ## CONSUMES
-
+ gSmmPerformanceProtocolGuid ## SOMETIMES_CONSUMES
+ gSmmPerformanceExProtocolGuid ## SOMETIMES_CONSUMES
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdPerformanceLibraryPropertyMask
-
-[Depex]
- gEfiSmmCommunicationProtocolGuid
diff --git a/MdeModulePkg/MdeModulePkg.dec b/MdeModulePkg/MdeModulePkg.dec index 7facc06379..775dfa614d 100644 --- a/MdeModulePkg/MdeModulePkg.dec +++ b/MdeModulePkg/MdeModulePkg.dec @@ -152,8 +152,10 @@ ## Performance protocol guid that also acts as the performance HOB guid and performance variable GUID
# Include/Guid/Performance.h
- gPerformanceProtocolGuid = { 0x76B6BDFA, 0x2ACD, 0x4462, { 0x9E, 0x3F, 0xCB, 0x58, 0xC9, 0x69, 0xD9, 0x37 }}
- gSmmPerformanceProtocolGuid = { 0xf866226a, 0xeaa5, 0x4f5a, { 0xa9, 0xa, 0x6c, 0xfb, 0xa5, 0x7c, 0x58, 0x8e } }
+ gPerformanceProtocolGuid = { 0x76B6BDFA, 0x2ACD, 0x4462, { 0x9E, 0x3F, 0xCB, 0x58, 0xC9, 0x69, 0xD9, 0x37 } }
+ gSmmPerformanceProtocolGuid = { 0xf866226a, 0xeaa5, 0x4f5a, { 0xa9, 0xa, 0x6c, 0xfb, 0xa5, 0x7c, 0x58, 0x8e } }
+ gPerformanceExProtocolGuid = { 0x1ea81bec, 0xf01a, 0x4d98, { 0xa2, 0x1, 0x4a, 0x61, 0xce, 0x2f, 0xc0, 0x22 } }
+ gSmmPerformanceExProtocolGuid = { 0x931fc048, 0xc71d, 0x4455, { 0x89, 0x30, 0x47, 0x6, 0x30, 0xe3, 0xe, 0xe5 } }
## Guid is defined for CRC32 encapsulation scheme.
# Include/Guid/Crc32GuidedSectionExtraction.h
|