/** @file\r
Trace reporting for the Dp utility.\r
\r
- Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\r
+ Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.\r
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
This program and the accompanying materials\r
are licensed and made available under the terms and conditions of the BSD License\r
#include <Library/HiiLib.h>\r
#include <Library/PcdLib.h>\r
\r
-#include <Guid/Performance.h>\r
-\r
#include "Dp.h"\r
#include "Literals.h"\r
#include "DpInternal.h"\r
\r
+/**\r
+ Attempts to retrieve a performance measurement log entry from the performance measurement log.\r
+\r
+\r
+ @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.\r
+ 0, then the first performance measurement log entry is retrieved.\r
+ On exit, the key of the next performance log entry.\r
+ @param Handle Pointer to environment specific context used to identify the component\r
+ being measured.\r
+ @param Token Pointer to a Null-terminated ASCII string that identifies the component\r
+ being measured.\r
+ @param Module Pointer to a Null-terminated ASCII string that identifies the module\r
+ being measured.\r
+ @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r
+ was started.\r
+ @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r
+ was ended.\r
+ @param Identifier Pointer to the 32-bit identifier that was recorded when the measurement\r
+ was ended.\r
+\r
+ @return The key for the next performance log entry (in general case).\r
+\r
+**/\r
+UINTN\r
+GetPerformanceMeasurementRecord (\r
+ IN UINTN LogEntryKey,\r
+ OUT CONST VOID **Handle,\r
+ OUT CONST CHAR8 **Token,\r
+ OUT CONST CHAR8 **Module,\r
+ OUT UINT64 *StartTimeStamp,\r
+ OUT UINT64 *EndTimeStamp,\r
+ OUT UINT32 *Identifier\r
+ )\r
+{\r
+ if (LogEntryKey == mMeasurementNum) {\r
+ return 0;\r
+ }\r
+\r
+ *Handle = (VOID *) (UINTN) mMeasurementList[LogEntryKey].Handle;\r
+ *Token = mMeasurementList[LogEntryKey].Token;\r
+ *Module = mMeasurementList[LogEntryKey].Module;\r
+ *StartTimeStamp = mMeasurementList[LogEntryKey].StartTimeStamp;\r
+ *EndTimeStamp = mMeasurementList[LogEntryKey].EndTimeStamp;\r
+ *Identifier = mMeasurementList[LogEntryKey].Identifier;\r
+\r
+ LogEntryKey ++;\r
+\r
+ return LogEntryKey;\r
+}\r
+\r
/**\r
Collect verbose statistics about the logged performance measurements.\r
\r
INTN TIndex;\r
\r
LogEntryKey = 0;\r
- while ((LogEntryKey = GetPerformanceMeasurementEx (\r
+ while ((LogEntryKey = GetPerformanceMeasurementRecord (\r
LogEntryKey,\r
&Measurement.Handle,\r
&Measurement.Token,\r
if (IsPhase( &Measurement)) {\r
++SummaryData.NumSummary; // Count the number of major phases\r
}\r
- else { // !IsPhase(...\r
+ else { // !IsPhase\r
if(Measurement.Handle == NULL) {\r
++SummaryData.NumGlobal;\r
}\r
}\r
\r
- if (AsciiStrnCmp (Measurement.Token, ALit_PEIM, PERF_TOKEN_LENGTH) == 0) {\r
+ if (AsciiStrCmp (Measurement.Token, ALit_PEIM) == 0) {\r
++SummaryData.NumPEIMs; // Count PEIM measurements\r
}\r
\r
Count = 0;\r
Index = 0;\r
while ( WITHIN_LIMIT(Count, Limit) &&\r
- ((LogEntryKey = GetPerformanceMeasurementEx (\r
+ ((LogEntryKey = GetPerformanceMeasurementRecord (\r
LogEntryKey,\r
&Measurement.Handle,\r
&Measurement.Token,\r
}\r
}\r
\r
- if (AsciiStrnCmp (Measurement.Token, ALit_PEIM, PERF_TOKEN_LENGTH) == 0) {\r
+ if (AsciiStrCmp (Measurement.Token, ALit_PEIM) == 0) {\r
UnicodeSPrint (mGaugeString, sizeof (mGaugeString), L"%g", Measurement.Handle);\r
}\r
\r
Count = 0;\r
Index = 0;\r
while ( WITHIN_LIMIT(Count, Limit) &&\r
- ((LogEntryKey = GetPerformanceMeasurementEx (\r
+ ((LogEntryKey = GetPerformanceMeasurementRecord (\r
LogEntryKey,\r
&Measurement.Handle,\r
&Measurement.Token,\r
FreePool (StringPtrUnknown);\r
\r
LogEntryKey = 0;\r
- while ((LogEntryKey = GetPerformanceMeasurementEx (\r
+ while ((LogEntryKey = GetPerformanceMeasurementRecord (\r
LogEntryKey,\r
&Measurement.Handle,\r
&Measurement.Token,\r
}\r
Duration = GetDuration (&Measurement);\r
if ( Measurement.Handle != NULL\r
- && (AsciiStrnCmp (Measurement.Token, ALit_BdsTO, PERF_TOKEN_LENGTH) == 0)\r
+ && (AsciiStrCmp (Measurement.Token, ALit_BdsTO) == 0)\r
)\r
{\r
BdsTimeoutValue = Duration;\r
- } else if (AsciiStrnCmp (Measurement.Token, ALit_SEC, PERF_TOKEN_LENGTH) == 0) {\r
+ } else if (AsciiStrCmp (Measurement.Token, ALit_SEC) == 0) {\r
SecTime = Duration;\r
- } else if (AsciiStrnCmp (Measurement.Token, ALit_PEI, PERF_TOKEN_LENGTH) == 0) {\r
+ } else if (AsciiStrCmp (Measurement.Token, ALit_PEI) == 0) {\r
PeiTime = Duration;\r
- } else if (AsciiStrnCmp (Measurement.Token, ALit_DXE, PERF_TOKEN_LENGTH) == 0) {\r
+ } else if (AsciiStrCmp (Measurement.Token, ALit_DXE) == 0) {\r
DxeTime = Duration;\r
- } else if (AsciiStrnCmp (Measurement.Token, ALit_BDS, PERF_TOKEN_LENGTH) == 0) {\r
+ } else if (AsciiStrCmp (Measurement.Token, ALit_BDS) == 0) {\r
BdsTime = Duration;\r
}\r
}\r
// print PEI phase duration time\r
//\r
if (PeiTime > 0) {\r
- ElapsedTime = DivU64x32 (\r
- PeiTime,\r
- (UINT32)TimerInfo.Frequency\r
- );\r
+ ElapsedTime = DivU64x32 (PeiTime, 1000000);\r
Total += ElapsedTime;\r
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_PEI, ElapsedTime);\r
}\r
// print DXE phase duration time\r
//\r
if (DxeTime > 0) {\r
- ElapsedTime = DivU64x32 (\r
- DxeTime,\r
- (UINT32)TimerInfo.Frequency\r
- );\r
+ ElapsedTime = DivU64x32 (DxeTime, 1000000);\r
Total += ElapsedTime;\r
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_DXE, ElapsedTime);\r
}\r
// print BDS phase duration time\r
//\r
if (BdsTime > 0) {\r
- ElapsedTime = DivU64x32 (\r
- BdsTime,\r
- (UINT32)TimerInfo.Frequency\r
- );\r
+ ElapsedTime = DivU64x32 (BdsTime, 1000000);\r
Total += ElapsedTime;\r
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_BDS, ElapsedTime);\r
}\r
\r
if (BdsTimeoutValue > 0) {\r
- ElapsedTime = DivU64x32 (\r
- BdsTimeoutValue,\r
- (UINT32)TimerInfo.Frequency\r
- );\r
+ ElapsedTime = DivU64x32 (BdsTimeoutValue, 1000000);\r
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_BDSTO), mDpHiiHandle, ALit_BdsTO, ElapsedTime);\r
}\r
\r
\r
LogEntryKey = 0;\r
Count = 0;\r
- while ((LogEntryKey = GetPerformanceMeasurementEx (\r
+ while ((LogEntryKey = GetPerformanceMeasurementRecord (\r
LogEntryKey,\r
&Measurement.Handle,\r
&Measurement.Token,\r
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);\r
TIndex = 0;\r
LogEntryKey = 0;\r
- while ((LogEntryKey = GetPerformanceMeasurementEx (\r
+ while ((LogEntryKey = GetPerformanceMeasurementRecord (\r
LogEntryKey,\r
&Measurement.Handle,\r
&Measurement.Token,\r
{\r
TIndex++;\r
if ((Measurement.EndTimeStamp == 0) ||\r
- (AsciiStrnCmp (Measurement.Token, ALit_PEIM, PERF_TOKEN_LENGTH) != 0)\r
+ (AsciiStrCmp (Measurement.Token, ALit_PEIM) != 0)\r
) {\r
continue;\r
}\r
if (mShowId) {\r
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS2), mDpHiiHandle,\r
TIndex, // 1 based, Which measurement record is being printed\r
- Measurement.Handle, // base address\r
Measurement.Handle, // file guid\r
ElapsedTime,\r
Measurement.Identifier\r
} else {\r
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS), mDpHiiHandle,\r
TIndex, // 1 based, Which measurement record is being printed\r
- Measurement.Handle, // base address\r
Measurement.Handle, // file guid\r
ElapsedTime\r
);\r
Index = 1;\r
LogEntryKey = 0;\r
\r
- while ((LogEntryKey = GetPerformanceMeasurementEx (\r
+ while ((LogEntryKey = GetPerformanceMeasurementRecord (\r
LogEntryKey,\r
&Measurement.Handle,\r
&Measurement.Token,\r