2013-03-04 23:02:59 +01:00
|
|
|
/** @file
|
|
|
|
Trace reporting for the Dp utility.
|
|
|
|
|
2018-01-22 09:39:03 +01:00
|
|
|
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
|
2016-02-15 10:07:13 +01:00
|
|
|
(C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
|
2019-04-04 01:07:06 +02:00
|
|
|
SPDX-License-Identifier: BSD-2-Clause-Patent
|
2013-03-04 23:02:59 +01:00
|
|
|
**/
|
|
|
|
|
|
|
|
#include <Library/BaseLib.h>
|
|
|
|
#include <Library/BaseMemoryLib.h>
|
|
|
|
#include <Library/MemoryAllocationLib.h>
|
|
|
|
#include <Library/DebugLib.h>
|
|
|
|
#include <Library/UefiBootServicesTableLib.h>
|
|
|
|
#include <Library/PeCoffGetEntryPointLib.h>
|
|
|
|
#include <Library/PerformanceLib.h>
|
|
|
|
#include <Library/PrintLib.h>
|
|
|
|
#include <Library/HiiLib.h>
|
|
|
|
#include <Library/PcdLib.h>
|
|
|
|
|
|
|
|
#include "Dp.h"
|
|
|
|
#include "Literals.h"
|
|
|
|
#include "DpInternal.h"
|
|
|
|
|
2018-01-22 09:39:03 +01:00
|
|
|
/**
|
|
|
|
Attempts to retrieve a performance measurement log entry from the performance measurement log.
|
|
|
|
|
|
|
|
|
|
|
|
@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.
|
|
|
|
@param Identifier Pointer to the 32-bit identifier that was recorded when the measurement
|
|
|
|
was ended.
|
|
|
|
|
|
|
|
@return The key for the next performance log entry (in general case).
|
|
|
|
|
|
|
|
**/
|
|
|
|
UINTN
|
|
|
|
GetPerformanceMeasurementRecord (
|
|
|
|
IN UINTN LogEntryKey,
|
|
|
|
OUT CONST VOID **Handle,
|
|
|
|
OUT CONST CHAR8 **Token,
|
|
|
|
OUT CONST CHAR8 **Module,
|
|
|
|
OUT UINT64 *StartTimeStamp,
|
|
|
|
OUT UINT64 *EndTimeStamp,
|
|
|
|
OUT UINT32 *Identifier
|
|
|
|
)
|
|
|
|
{
|
|
|
|
if (LogEntryKey == mMeasurementNum) {
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
*Handle = (VOID *) (UINTN) mMeasurementList[LogEntryKey].Handle;
|
|
|
|
*Token = mMeasurementList[LogEntryKey].Token;
|
|
|
|
*Module = mMeasurementList[LogEntryKey].Module;
|
|
|
|
*StartTimeStamp = mMeasurementList[LogEntryKey].StartTimeStamp;
|
|
|
|
*EndTimeStamp = mMeasurementList[LogEntryKey].EndTimeStamp;
|
|
|
|
*Identifier = mMeasurementList[LogEntryKey].Identifier;
|
|
|
|
|
|
|
|
LogEntryKey ++;
|
|
|
|
|
|
|
|
return LogEntryKey;
|
|
|
|
}
|
|
|
|
|
2017-11-24 10:26:24 +01:00
|
|
|
/**
|
2013-03-04 23:02:59 +01:00
|
|
|
Collect verbose statistics about the logged performance measurements.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
General Summary information for all Trace measurements is gathered and
|
|
|
|
stored within the SummaryData structure. This information is both
|
|
|
|
used internally by subsequent reporting functions, and displayed
|
|
|
|
at the end of verbose reports.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
@pre The SummaryData and CumData structures must be initialized
|
|
|
|
prior to calling this function.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
@post The SummaryData and CumData structures contain statistics for the
|
|
|
|
current performance logs.
|
2015-11-05 02:59:24 +01:00
|
|
|
|
|
|
|
@param[in, out] CustomCumulativeData A pointer to the cumtom cumulative data.
|
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
GatherStatistics(
|
2015-11-05 02:59:24 +01:00
|
|
|
IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL
|
|
|
|
)
|
2013-03-04 23:02:59 +01:00
|
|
|
{
|
|
|
|
MEASUREMENT_RECORD Measurement;
|
|
|
|
UINT64 Duration;
|
|
|
|
UINTN LogEntryKey;
|
|
|
|
INTN TIndex;
|
|
|
|
|
|
|
|
LogEntryKey = 0;
|
2018-01-22 09:39:03 +01:00
|
|
|
while ((LogEntryKey = GetPerformanceMeasurementRecord (
|
2013-03-04 23:02:59 +01:00
|
|
|
LogEntryKey,
|
|
|
|
&Measurement.Handle,
|
|
|
|
&Measurement.Token,
|
|
|
|
&Measurement.Module,
|
|
|
|
&Measurement.StartTimeStamp,
|
|
|
|
&Measurement.EndTimeStamp,
|
|
|
|
&Measurement.Identifier)) != 0)
|
|
|
|
{
|
|
|
|
++SummaryData.NumTrace; // Count the number of TRACE Measurement records
|
|
|
|
if (Measurement.EndTimeStamp == 0) {
|
|
|
|
++SummaryData.NumIncomplete; // Count the incomplete records
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (Measurement.Handle != NULL) {
|
|
|
|
++SummaryData.NumHandles; // Count the number of measurements with non-NULL handles
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsPhase( &Measurement)) {
|
|
|
|
++SummaryData.NumSummary; // Count the number of major phases
|
|
|
|
}
|
2018-01-22 09:39:03 +01:00
|
|
|
else { // !IsPhase
|
2013-03-04 23:02:59 +01:00
|
|
|
if(Measurement.Handle == NULL) {
|
|
|
|
++SummaryData.NumGlobal;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-22 09:39:03 +01:00
|
|
|
if (AsciiStrCmp (Measurement.Token, ALit_PEIM) == 0) {
|
2013-03-04 23:02:59 +01:00
|
|
|
++SummaryData.NumPEIMs; // Count PEIM measurements
|
|
|
|
}
|
|
|
|
|
|
|
|
Duration = GetDuration (&Measurement);
|
|
|
|
TIndex = GetCumulativeItem (&Measurement);
|
|
|
|
if (TIndex >= 0) {
|
|
|
|
CumData[TIndex].Duration += Duration;
|
|
|
|
CumData[TIndex].Count++;
|
|
|
|
if ( Duration < CumData[TIndex].MinDur ) {
|
|
|
|
CumData[TIndex].MinDur = Duration;
|
|
|
|
}
|
|
|
|
if ( Duration > CumData[TIndex].MaxDur ) {
|
|
|
|
CumData[TIndex].MaxDur = Duration;
|
|
|
|
}
|
|
|
|
}
|
2015-11-05 02:59:24 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Collect the data for custom cumulative data.
|
|
|
|
//
|
|
|
|
if ((CustomCumulativeData != NULL) && (AsciiStrCmp (Measurement.Token, CustomCumulativeData->Name) == 0)) {
|
|
|
|
CustomCumulativeData->Duration += Duration;
|
|
|
|
CustomCumulativeData->Count++;
|
|
|
|
if (Duration < CustomCumulativeData->MinDur) {
|
|
|
|
CustomCumulativeData->MinDur = Duration;
|
|
|
|
}
|
|
|
|
if (Duration > CustomCumulativeData->MaxDur) {
|
|
|
|
CustomCumulativeData->MaxDur = Duration;
|
|
|
|
}
|
|
|
|
}
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2017-11-24 10:26:24 +01:00
|
|
|
/**
|
2013-03-04 23:02:59 +01:00
|
|
|
Gather and print ALL Trace Records.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
Displays all "interesting" Trace measurements in order.<BR>
|
|
|
|
The number of records displayed is controlled by:
|
|
|
|
- records with a duration less than mInterestThreshold microseconds are not displayed.
|
|
|
|
- No more than Limit records are displayed. A Limit of zero will not limit the output.
|
|
|
|
- If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
|
|
|
|
displayed.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
@pre The mInterestThreshold global variable is set to the shortest duration to be printed.
|
|
|
|
The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
|
|
|
|
They must not be in use by a calling function.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
@param[in] Limit The number of records to print. Zero is ALL.
|
|
|
|
@param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2016-03-07 04:23:08 +01:00
|
|
|
@retval EFI_SUCCESS The operation was successful.
|
|
|
|
@retval EFI_ABORTED The user aborts the operation.
|
|
|
|
@return Others from a call to gBS->LocateHandleBuffer().
|
2013-03-04 23:02:59 +01:00
|
|
|
**/
|
2016-03-07 04:23:08 +01:00
|
|
|
EFI_STATUS
|
2013-03-04 23:02:59 +01:00
|
|
|
DumpAllTrace(
|
|
|
|
IN UINTN Limit,
|
|
|
|
IN BOOLEAN ExcludeFlag
|
|
|
|
)
|
|
|
|
{
|
|
|
|
MEASUREMENT_RECORD Measurement;
|
|
|
|
UINT64 ElapsedTime;
|
|
|
|
UINT64 Duration;
|
|
|
|
CHAR16 *IncFlag;
|
|
|
|
UINTN LogEntryKey;
|
|
|
|
UINTN Count;
|
|
|
|
UINTN Index;
|
|
|
|
UINTN TIndex;
|
|
|
|
|
|
|
|
EFI_HANDLE *HandleBuffer;
|
2016-02-15 10:07:13 +01:00
|
|
|
UINTN HandleCount;
|
2013-03-04 23:02:59 +01:00
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_STRING StringPtrUnknown;
|
|
|
|
|
2017-11-24 10:26:24 +01:00
|
|
|
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
|
|
|
|
IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
(IncFlag == NULL) ? StringPtrUnknown : IncFlag);
|
|
|
|
FreePool (StringPtrUnknown);
|
|
|
|
|
|
|
|
// Get Handle information
|
|
|
|
//
|
2016-02-15 10:07:13 +01:00
|
|
|
Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);
|
2013-03-04 23:02:59 +01:00
|
|
|
if (EFI_ERROR (Status)) {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
// We have successfully populated the HandleBuffer
|
|
|
|
// Display ALL Measurement Records
|
|
|
|
// Up to Limit lines displayed
|
|
|
|
// Display only records with Elapsed times >= mInterestThreshold
|
|
|
|
// Display driver names in Module field for records with Handles.
|
|
|
|
//
|
|
|
|
if (mShowId) {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR2), mDpHiiHandle);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_DASHES2), mDpHiiHandle);
|
2013-03-04 23:02:59 +01:00
|
|
|
} else {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR), mDpHiiHandle);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
LogEntryKey = 0;
|
|
|
|
Count = 0;
|
|
|
|
Index = 0;
|
|
|
|
while ( WITHIN_LIMIT(Count, Limit) &&
|
2018-01-22 09:39:03 +01:00
|
|
|
((LogEntryKey = GetPerformanceMeasurementRecord (
|
2013-03-04 23:02:59 +01:00
|
|
|
LogEntryKey,
|
|
|
|
&Measurement.Handle,
|
|
|
|
&Measurement.Token,
|
|
|
|
&Measurement.Module,
|
|
|
|
&Measurement.StartTimeStamp,
|
|
|
|
&Measurement.EndTimeStamp,
|
|
|
|
&Measurement.Identifier)) != 0)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
++Index; // Count every record. First record is 1.
|
|
|
|
ElapsedTime = 0;
|
|
|
|
SHELL_FREE_NON_NULL (IncFlag);
|
|
|
|
if (Measurement.EndTimeStamp != 0) {
|
|
|
|
Duration = GetDuration (&Measurement);
|
|
|
|
ElapsedTime = DurationInMicroSeconds ( Duration );
|
2017-11-24 10:26:24 +01:00
|
|
|
IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL);
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
else {
|
2017-11-24 10:26:24 +01:00
|
|
|
IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_INCOMPLETE), NULL); // Mark incomplete records
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
if (((Measurement.EndTimeStamp != 0) && (ElapsedTime < mInterestThreshold)) ||
|
|
|
|
((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))
|
|
|
|
) { // Ignore "uninteresting" or excluded records
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
++Count; // Count the number of records printed
|
|
|
|
|
|
|
|
// If Handle is non-zero, see if we can determine a name for the driver
|
2016-10-26 19:27:30 +02:00
|
|
|
AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString)); // Use Module by default
|
|
|
|
AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
|
2013-03-04 23:02:59 +01:00
|
|
|
if (Measurement.Handle != NULL) {
|
|
|
|
// See if the Handle is in the HandleBuffer
|
2016-02-15 10:07:13 +01:00
|
|
|
for (TIndex = 0; TIndex < HandleCount; TIndex++) {
|
2013-03-04 23:02:59 +01:00
|
|
|
if (Measurement.Handle == HandleBuffer[TIndex]) {
|
2015-09-15 06:54:06 +02:00
|
|
|
DpGetNameFromHandle (HandleBuffer[TIndex]);
|
2013-03-04 23:02:59 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-01-22 09:39:03 +01:00
|
|
|
if (AsciiStrCmp (Measurement.Token, ALit_PEIM) == 0) {
|
2013-03-04 23:02:59 +01:00
|
|
|
UnicodeSPrint (mGaugeString, sizeof (mGaugeString), L"%g", Measurement.Handle);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Ensure that the argument strings are not too long.
|
|
|
|
mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
|
|
|
|
mUnicodeToken[13] = 0;
|
|
|
|
|
|
|
|
if (mShowId) {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS2), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
Index, // 1 based, Which measurement record is being printed
|
|
|
|
IncFlag,
|
|
|
|
Measurement.Handle,
|
|
|
|
mGaugeString,
|
|
|
|
mUnicodeToken,
|
|
|
|
ElapsedTime,
|
|
|
|
Measurement.Identifier
|
|
|
|
);
|
|
|
|
} else {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
Index, // 1 based, Which measurement record is being printed
|
|
|
|
IncFlag,
|
|
|
|
Measurement.Handle,
|
|
|
|
mGaugeString,
|
|
|
|
mUnicodeToken,
|
|
|
|
ElapsedTime
|
|
|
|
);
|
|
|
|
}
|
2016-03-07 04:23:08 +01:00
|
|
|
if (ShellGetExecutionBreakFlag ()) {
|
|
|
|
Status = EFI_ABORTED;
|
|
|
|
break;
|
|
|
|
}
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
}
|
2016-02-15 10:07:13 +01:00
|
|
|
if (HandleBuffer != NULL) {
|
2013-03-04 23:02:59 +01:00
|
|
|
FreePool (HandleBuffer);
|
|
|
|
}
|
|
|
|
SHELL_FREE_NON_NULL (IncFlag);
|
2016-03-07 04:23:08 +01:00
|
|
|
|
|
|
|
return Status;
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
|
2017-11-24 10:26:24 +01:00
|
|
|
/**
|
2013-03-04 23:02:59 +01:00
|
|
|
Gather and print Raw Trace Records.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
All Trace measurements with a duration greater than or equal to
|
|
|
|
mInterestThreshold are printed without interpretation.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
The number of records displayed is controlled by:
|
|
|
|
- records with a duration less than mInterestThreshold microseconds are not displayed.
|
|
|
|
- No more than Limit records are displayed. A Limit of zero will not limit the output.
|
|
|
|
- If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
|
|
|
|
displayed.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
@pre The mInterestThreshold global variable is set to the shortest duration to be printed.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
@param[in] Limit The number of records to print. Zero is ALL.
|
|
|
|
@param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
|
2016-03-07 04:23:08 +01:00
|
|
|
|
|
|
|
@retval EFI_SUCCESS The operation was successful.
|
|
|
|
@retval EFI_ABORTED The user aborts the operation.
|
2013-03-04 23:02:59 +01:00
|
|
|
**/
|
2016-03-07 04:23:08 +01:00
|
|
|
EFI_STATUS
|
2013-03-04 23:02:59 +01:00
|
|
|
DumpRawTrace(
|
|
|
|
IN UINTN Limit,
|
|
|
|
IN BOOLEAN ExcludeFlag
|
|
|
|
)
|
|
|
|
{
|
|
|
|
MEASUREMENT_RECORD Measurement;
|
|
|
|
UINT64 ElapsedTime;
|
|
|
|
UINT64 Duration;
|
|
|
|
UINTN LogEntryKey;
|
|
|
|
UINTN Count;
|
|
|
|
UINTN Index;
|
|
|
|
|
|
|
|
EFI_STRING StringPtr;
|
|
|
|
EFI_STRING StringPtrUnknown;
|
2016-03-07 04:23:08 +01:00
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
Status = EFI_SUCCESS;
|
2013-03-04 23:02:59 +01:00
|
|
|
|
2017-11-24 10:26:24 +01:00
|
|
|
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
|
|
|
|
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
(StringPtr == NULL) ? StringPtrUnknown : StringPtr);
|
|
|
|
FreePool (StringPtr);
|
|
|
|
FreePool (StringPtrUnknown);
|
|
|
|
|
|
|
|
if (mShowId) {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR2), mDpHiiHandle);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES2), mDpHiiHandle);
|
2013-03-04 23:02:59 +01:00
|
|
|
} else {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR), mDpHiiHandle);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES), mDpHiiHandle);
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
LogEntryKey = 0;
|
|
|
|
Count = 0;
|
|
|
|
Index = 0;
|
|
|
|
while ( WITHIN_LIMIT(Count, Limit) &&
|
2018-01-22 09:39:03 +01:00
|
|
|
((LogEntryKey = GetPerformanceMeasurementRecord (
|
2013-03-04 23:02:59 +01:00
|
|
|
LogEntryKey,
|
|
|
|
&Measurement.Handle,
|
|
|
|
&Measurement.Token,
|
|
|
|
&Measurement.Module,
|
|
|
|
&Measurement.StartTimeStamp,
|
|
|
|
&Measurement.EndTimeStamp,
|
|
|
|
&Measurement.Identifier)) != 0)
|
|
|
|
)
|
|
|
|
{
|
|
|
|
++Index; // Count every record. First record is 1.
|
|
|
|
ElapsedTime = 0;
|
|
|
|
if (Measurement.EndTimeStamp != 0) {
|
|
|
|
Duration = GetDuration (&Measurement);
|
|
|
|
ElapsedTime = DurationInMicroSeconds ( Duration );
|
|
|
|
}
|
|
|
|
if ((ElapsedTime < mInterestThreshold) ||
|
|
|
|
((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))
|
|
|
|
) { // Ignore "uninteresting" or Excluded records
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
++Count; // Count the number of records printed
|
|
|
|
|
|
|
|
if (mShowId) {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS2), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
Index, // 1 based, Which measurement record is being printed
|
|
|
|
Measurement.Handle,
|
|
|
|
Measurement.StartTimeStamp,
|
|
|
|
Measurement.EndTimeStamp,
|
|
|
|
Measurement.Token,
|
|
|
|
Measurement.Module,
|
|
|
|
Measurement.Identifier
|
|
|
|
);
|
|
|
|
} else {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
Index, // 1 based, Which measurement record is being printed
|
|
|
|
Measurement.Handle,
|
|
|
|
Measurement.StartTimeStamp,
|
|
|
|
Measurement.EndTimeStamp,
|
|
|
|
Measurement.Token,
|
|
|
|
Measurement.Module
|
|
|
|
);
|
|
|
|
}
|
2016-03-07 04:23:08 +01:00
|
|
|
if (ShellGetExecutionBreakFlag ()) {
|
|
|
|
Status = EFI_ABORTED;
|
|
|
|
break;
|
|
|
|
}
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
2016-03-07 04:23:08 +01:00
|
|
|
return Status;
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
|
2017-11-24 10:26:24 +01:00
|
|
|
/**
|
2013-03-04 23:02:59 +01:00
|
|
|
Gather and print Major Phase metrics.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
ProcessPhases(
|
2016-06-08 09:23:24 +02:00
|
|
|
VOID
|
2013-03-04 23:02:59 +01:00
|
|
|
)
|
|
|
|
{
|
|
|
|
MEASUREMENT_RECORD Measurement;
|
|
|
|
UINT64 BdsTimeoutValue;
|
|
|
|
UINT64 SecTime;
|
|
|
|
UINT64 PeiTime;
|
|
|
|
UINT64 DxeTime;
|
|
|
|
UINT64 BdsTime;
|
|
|
|
UINT64 ElapsedTime;
|
|
|
|
UINT64 Duration;
|
|
|
|
UINT64 Total;
|
|
|
|
EFI_STRING StringPtr;
|
|
|
|
UINTN LogEntryKey;
|
|
|
|
EFI_STRING StringPtrUnknown;
|
|
|
|
|
|
|
|
BdsTimeoutValue = 0;
|
|
|
|
SecTime = 0;
|
|
|
|
PeiTime = 0;
|
|
|
|
DxeTime = 0;
|
|
|
|
BdsTime = 0;
|
|
|
|
//
|
|
|
|
// Get Execution Phase Statistics
|
|
|
|
//
|
2017-11-24 10:26:24 +01:00
|
|
|
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
|
|
|
|
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
(StringPtr == NULL) ? StringPtrUnknown : StringPtr);
|
|
|
|
FreePool (StringPtr);
|
|
|
|
FreePool (StringPtrUnknown);
|
|
|
|
|
|
|
|
LogEntryKey = 0;
|
2018-01-22 09:39:03 +01:00
|
|
|
while ((LogEntryKey = GetPerformanceMeasurementRecord (
|
2013-03-04 23:02:59 +01:00
|
|
|
LogEntryKey,
|
|
|
|
&Measurement.Handle,
|
|
|
|
&Measurement.Token,
|
|
|
|
&Measurement.Module,
|
|
|
|
&Measurement.StartTimeStamp,
|
|
|
|
&Measurement.EndTimeStamp,
|
|
|
|
&Measurement.Identifier)) != 0)
|
|
|
|
{
|
|
|
|
if (Measurement.EndTimeStamp == 0) { // Skip "incomplete" records
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
Duration = GetDuration (&Measurement);
|
|
|
|
if ( Measurement.Handle != NULL
|
2018-01-22 09:39:03 +01:00
|
|
|
&& (AsciiStrCmp (Measurement.Token, ALit_BdsTO) == 0)
|
2013-03-04 23:02:59 +01:00
|
|
|
)
|
|
|
|
{
|
|
|
|
BdsTimeoutValue = Duration;
|
2018-01-22 09:39:03 +01:00
|
|
|
} else if (AsciiStrCmp (Measurement.Token, ALit_SEC) == 0) {
|
2013-03-04 23:02:59 +01:00
|
|
|
SecTime = Duration;
|
2018-01-22 09:39:03 +01:00
|
|
|
} else if (AsciiStrCmp (Measurement.Token, ALit_PEI) == 0) {
|
2013-03-04 23:02:59 +01:00
|
|
|
PeiTime = Duration;
|
2018-01-22 09:39:03 +01:00
|
|
|
} else if (AsciiStrCmp (Measurement.Token, ALit_DXE) == 0) {
|
2013-03-04 23:02:59 +01:00
|
|
|
DxeTime = Duration;
|
2018-01-22 09:39:03 +01:00
|
|
|
} else if (AsciiStrCmp (Measurement.Token, ALit_BDS) == 0) {
|
2013-03-04 23:02:59 +01:00
|
|
|
BdsTime = Duration;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
Total = 0;
|
|
|
|
|
|
|
|
// print SEC phase duration time
|
|
|
|
//
|
|
|
|
if (SecTime > 0) {
|
|
|
|
ElapsedTime = DurationInMicroSeconds ( SecTime ); // Calculate elapsed time in microseconds
|
|
|
|
Total += DivU64x32 (ElapsedTime, 1000); // Accumulate time in milliseconds
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SEC_PHASE), mDpHiiHandle, ElapsedTime);
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// print PEI phase duration time
|
|
|
|
//
|
|
|
|
if (PeiTime > 0) {
|
2018-01-22 09:39:03 +01:00
|
|
|
ElapsedTime = DivU64x32 (PeiTime, 1000000);
|
2013-03-04 23:02:59 +01:00
|
|
|
Total += ElapsedTime;
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_PEI, ElapsedTime);
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// print DXE phase duration time
|
|
|
|
//
|
|
|
|
if (DxeTime > 0) {
|
2018-01-22 09:39:03 +01:00
|
|
|
ElapsedTime = DivU64x32 (DxeTime, 1000000);
|
2013-03-04 23:02:59 +01:00
|
|
|
Total += ElapsedTime;
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_DXE, ElapsedTime);
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
// print BDS phase duration time
|
|
|
|
//
|
|
|
|
if (BdsTime > 0) {
|
2018-01-22 09:39:03 +01:00
|
|
|
ElapsedTime = DivU64x32 (BdsTime, 1000000);
|
2013-03-04 23:02:59 +01:00
|
|
|
Total += ElapsedTime;
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_BDS, ElapsedTime);
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
if (BdsTimeoutValue > 0) {
|
2018-01-22 09:39:03 +01:00
|
|
|
ElapsedTime = DivU64x32 (BdsTimeoutValue, 1000000);
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_BDSTO), mDpHiiHandle, ALit_BdsTO, ElapsedTime);
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOTAL_DURATION), mDpHiiHandle, Total);
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
|
2017-11-24 10:26:24 +01:00
|
|
|
/**
|
2013-03-04 23:02:59 +01:00
|
|
|
Gather and print Handle data.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
@param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2016-03-07 04:23:08 +01:00
|
|
|
@retval EFI_SUCCESS The operation was successful.
|
|
|
|
@retval EFI_ABORTED The user aborts the operation.
|
|
|
|
@return Others from a call to gBS->LocateHandleBuffer().
|
2013-03-04 23:02:59 +01:00
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
ProcessHandles(
|
|
|
|
IN BOOLEAN ExcludeFlag
|
|
|
|
)
|
|
|
|
{
|
|
|
|
MEASUREMENT_RECORD Measurement;
|
|
|
|
UINT64 ElapsedTime;
|
|
|
|
UINT64 Duration;
|
|
|
|
EFI_HANDLE *HandleBuffer;
|
|
|
|
EFI_STRING StringPtr;
|
|
|
|
UINTN Index;
|
|
|
|
UINTN LogEntryKey;
|
|
|
|
UINTN Count;
|
2016-02-15 10:07:13 +01:00
|
|
|
UINTN HandleCount;
|
2013-03-04 23:02:59 +01:00
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_STRING StringPtrUnknown;
|
|
|
|
|
2017-11-24 10:26:24 +01:00
|
|
|
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
|
|
|
|
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
(StringPtr == NULL) ? StringPtrUnknown : StringPtr);
|
|
|
|
FreePool (StringPtr);
|
|
|
|
FreePool (StringPtrUnknown);
|
|
|
|
|
2016-02-15 10:07:13 +01:00
|
|
|
Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);
|
2013-03-04 23:02:59 +01:00
|
|
|
if (EFI_ERROR (Status)) {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
else {
|
|
|
|
#if DP_DEBUG == 2
|
|
|
|
Print (L"There are %,d Handles defined.\n", (Size / sizeof(HandleBuffer[0])));
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (mShowId) {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION2), mDpHiiHandle);
|
2013-03-04 23:02:59 +01:00
|
|
|
} else {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION), mDpHiiHandle);
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
|
2013-03-04 23:02:59 +01:00
|
|
|
|
|
|
|
LogEntryKey = 0;
|
|
|
|
Count = 0;
|
2018-01-22 09:39:03 +01:00
|
|
|
while ((LogEntryKey = GetPerformanceMeasurementRecord (
|
2013-03-04 23:02:59 +01:00
|
|
|
LogEntryKey,
|
|
|
|
&Measurement.Handle,
|
|
|
|
&Measurement.Token,
|
|
|
|
&Measurement.Module,
|
|
|
|
&Measurement.StartTimeStamp,
|
|
|
|
&Measurement.EndTimeStamp,
|
|
|
|
&Measurement.Identifier)) != 0)
|
|
|
|
{
|
|
|
|
Count++;
|
|
|
|
Duration = GetDuration (&Measurement);
|
|
|
|
ElapsedTime = DurationInMicroSeconds ( Duration );
|
|
|
|
if ((ElapsedTime < mInterestThreshold) ||
|
|
|
|
(Measurement.EndTimeStamp == 0) ||
|
2018-06-22 10:56:20 +02:00
|
|
|
(!IsCorePerf (&Measurement)) ||
|
2013-03-04 23:02:59 +01:00
|
|
|
((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))
|
|
|
|
) { // Ignore "uninteresting" or excluded records
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
mGaugeString[0] = 0; // Empty driver name by default
|
2016-10-26 19:27:30 +02:00
|
|
|
AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
|
2013-03-04 23:02:59 +01:00
|
|
|
// See if the Handle is in the HandleBuffer
|
2016-02-15 10:07:13 +01:00
|
|
|
for (Index = 0; Index < HandleCount; Index++) {
|
2013-03-04 23:02:59 +01:00
|
|
|
if (Measurement.Handle == HandleBuffer[Index]) {
|
2015-09-15 06:54:06 +02:00
|
|
|
DpGetNameFromHandle (HandleBuffer[Index]); // Name is put into mGaugeString
|
2013-03-04 23:02:59 +01:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
// Ensure that the argument strings are not too long.
|
|
|
|
mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
|
|
|
|
mUnicodeToken[11] = 0;
|
|
|
|
if (mGaugeString[0] != 0) {
|
|
|
|
// Display the record if it has a valid handle.
|
|
|
|
if (mShowId) {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS2), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
Count, // 1 based, Which measurement record is being printed
|
|
|
|
Index + 1, // 1 based, Which handle is being printed
|
|
|
|
mGaugeString,
|
|
|
|
mUnicodeToken,
|
|
|
|
ElapsedTime,
|
|
|
|
Measurement.Identifier
|
|
|
|
);
|
|
|
|
} else {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
Count, // 1 based, Which measurement record is being printed
|
|
|
|
Index + 1, // 1 based, Which handle is being printed
|
|
|
|
mGaugeString,
|
|
|
|
mUnicodeToken,
|
|
|
|
ElapsedTime
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2016-03-07 04:23:08 +01:00
|
|
|
if (ShellGetExecutionBreakFlag ()) {
|
|
|
|
Status = EFI_ABORTED;
|
|
|
|
break;
|
|
|
|
}
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
}
|
2016-02-15 10:07:13 +01:00
|
|
|
if (HandleBuffer != NULL) {
|
2013-03-04 23:02:59 +01:00
|
|
|
FreePool (HandleBuffer);
|
|
|
|
}
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2017-11-24 10:26:24 +01:00
|
|
|
/**
|
2013-03-04 23:02:59 +01:00
|
|
|
Gather and print PEIM data.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
Only prints complete PEIM records
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2016-03-07 04:23:08 +01:00
|
|
|
@retval EFI_SUCCESS The operation was successful.
|
|
|
|
@retval EFI_ABORTED The user aborts the operation.
|
2013-03-04 23:02:59 +01:00
|
|
|
**/
|
2016-03-07 04:23:08 +01:00
|
|
|
EFI_STATUS
|
2013-03-04 23:02:59 +01:00
|
|
|
ProcessPeims(
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
MEASUREMENT_RECORD Measurement;
|
|
|
|
UINT64 Duration;
|
|
|
|
UINT64 ElapsedTime;
|
|
|
|
EFI_STRING StringPtr;
|
|
|
|
UINTN LogEntryKey;
|
|
|
|
UINTN TIndex;
|
|
|
|
EFI_STRING StringPtrUnknown;
|
2016-03-07 04:23:08 +01:00
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
Status = EFI_SUCCESS;
|
2013-03-04 23:02:59 +01:00
|
|
|
|
2017-11-24 10:26:24 +01:00
|
|
|
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
|
|
|
|
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
(StringPtr == NULL) ? StringPtrUnknown : StringPtr);
|
|
|
|
FreePool (StringPtr);
|
|
|
|
FreePool (StringPtrUnknown);
|
|
|
|
|
|
|
|
if (mShowId) {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION2), mDpHiiHandle);
|
2013-03-04 23:02:59 +01:00
|
|
|
} else {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION), mDpHiiHandle);
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
|
2013-03-04 23:02:59 +01:00
|
|
|
TIndex = 0;
|
|
|
|
LogEntryKey = 0;
|
2018-01-22 09:39:03 +01:00
|
|
|
while ((LogEntryKey = GetPerformanceMeasurementRecord (
|
2013-03-04 23:02:59 +01:00
|
|
|
LogEntryKey,
|
|
|
|
&Measurement.Handle,
|
|
|
|
&Measurement.Token,
|
|
|
|
&Measurement.Module,
|
|
|
|
&Measurement.StartTimeStamp,
|
|
|
|
&Measurement.EndTimeStamp,
|
|
|
|
&Measurement.Identifier)) != 0)
|
|
|
|
{
|
|
|
|
TIndex++;
|
|
|
|
if ((Measurement.EndTimeStamp == 0) ||
|
2018-01-22 09:39:03 +01:00
|
|
|
(AsciiStrCmp (Measurement.Token, ALit_PEIM) != 0)
|
2013-03-04 23:02:59 +01:00
|
|
|
) {
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
|
|
|
Duration = GetDuration (&Measurement);
|
|
|
|
ElapsedTime = DurationInMicroSeconds ( Duration ); // Calculate elapsed time in microseconds
|
|
|
|
if (ElapsedTime >= mInterestThreshold) {
|
|
|
|
// PEIM FILE Handle is the start address of its FFS file that contains its file guid.
|
|
|
|
if (mShowId) {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS2), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
TIndex, // 1 based, Which measurement record is being printed
|
|
|
|
Measurement.Handle, // file guid
|
|
|
|
ElapsedTime,
|
|
|
|
Measurement.Identifier
|
|
|
|
);
|
|
|
|
} else {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
TIndex, // 1 based, Which measurement record is being printed
|
|
|
|
Measurement.Handle, // file guid
|
|
|
|
ElapsedTime
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2016-03-07 04:23:08 +01:00
|
|
|
if (ShellGetExecutionBreakFlag ()) {
|
|
|
|
Status = EFI_ABORTED;
|
|
|
|
break;
|
|
|
|
}
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
2016-03-07 04:23:08 +01:00
|
|
|
return Status;
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
|
2017-11-24 10:26:24 +01:00
|
|
|
/**
|
2013-03-04 23:02:59 +01:00
|
|
|
Gather and print global data.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
Strips out incomplete or "Execution Phase" records
|
|
|
|
Only prints records where Handle is NULL
|
|
|
|
Increment TIndex for every record, even skipped ones, so that we have an
|
|
|
|
indication of every measurement record taken.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2016-03-07 04:23:08 +01:00
|
|
|
@retval EFI_SUCCESS The operation was successful.
|
|
|
|
@retval EFI_ABORTED The user aborts the operation.
|
2013-03-04 23:02:59 +01:00
|
|
|
**/
|
2016-03-07 04:23:08 +01:00
|
|
|
EFI_STATUS
|
2013-03-04 23:02:59 +01:00
|
|
|
ProcessGlobal(
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
MEASUREMENT_RECORD Measurement;
|
|
|
|
UINT64 Duration;
|
|
|
|
UINT64 ElapsedTime;
|
|
|
|
EFI_STRING StringPtr;
|
|
|
|
UINTN LogEntryKey;
|
|
|
|
UINTN Index; // Index, or number, of the measurement record being processed
|
|
|
|
EFI_STRING StringPtrUnknown;
|
2016-03-07 04:23:08 +01:00
|
|
|
EFI_STATUS Status;
|
|
|
|
|
|
|
|
Status = EFI_SUCCESS;
|
2013-03-04 23:02:59 +01:00
|
|
|
|
2017-11-24 10:26:24 +01:00
|
|
|
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
|
|
|
|
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
(StringPtr == NULL) ? StringPtrUnknown: StringPtr);
|
|
|
|
FreePool (StringPtr);
|
|
|
|
FreePool (StringPtrUnknown);
|
|
|
|
|
|
|
|
if (mShowId) {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION2), mDpHiiHandle);
|
2013-03-04 23:02:59 +01:00
|
|
|
} else {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION), mDpHiiHandle);
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
|
2013-03-04 23:02:59 +01:00
|
|
|
|
|
|
|
Index = 1;
|
|
|
|
LogEntryKey = 0;
|
|
|
|
|
2018-01-22 09:39:03 +01:00
|
|
|
while ((LogEntryKey = GetPerformanceMeasurementRecord (
|
2013-03-04 23:02:59 +01:00
|
|
|
LogEntryKey,
|
|
|
|
&Measurement.Handle,
|
|
|
|
&Measurement.Token,
|
|
|
|
&Measurement.Module,
|
|
|
|
&Measurement.StartTimeStamp,
|
|
|
|
&Measurement.EndTimeStamp,
|
|
|
|
&Measurement.Identifier)) != 0)
|
|
|
|
{
|
2016-10-26 19:27:30 +02:00
|
|
|
AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString));
|
|
|
|
AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));
|
2013-03-04 23:02:59 +01:00
|
|
|
mGaugeString[25] = 0;
|
|
|
|
mUnicodeToken[31] = 0;
|
|
|
|
if ( ! ( IsPhase( &Measurement) ||
|
2018-06-22 10:56:20 +02:00
|
|
|
IsCorePerf (&Measurement) ||
|
2013-03-04 23:02:59 +01:00
|
|
|
(Measurement.EndTimeStamp == 0)
|
|
|
|
))
|
|
|
|
{
|
|
|
|
Duration = GetDuration (&Measurement);
|
|
|
|
ElapsedTime = DurationInMicroSeconds ( Duration );
|
|
|
|
if (ElapsedTime >= mInterestThreshold) {
|
|
|
|
if (mShowId) {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS2), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
Index,
|
|
|
|
mGaugeString,
|
|
|
|
mUnicodeToken,
|
|
|
|
ElapsedTime,
|
|
|
|
Measurement.Identifier
|
|
|
|
);
|
|
|
|
} else {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
Index,
|
|
|
|
mGaugeString,
|
|
|
|
mUnicodeToken,
|
|
|
|
ElapsedTime
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2016-03-07 04:23:08 +01:00
|
|
|
if (ShellGetExecutionBreakFlag ()) {
|
|
|
|
Status = EFI_ABORTED;
|
|
|
|
break;
|
|
|
|
}
|
2013-03-04 23:02:59 +01:00
|
|
|
Index++;
|
|
|
|
}
|
2016-05-02 10:45:33 +02:00
|
|
|
return Status;
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
|
2017-11-24 10:26:24 +01:00
|
|
|
/**
|
2013-03-04 23:02:59 +01:00
|
|
|
Gather and print cumulative data.
|
2017-11-24 10:26:24 +01:00
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
Traverse the measurement records and:<BR>
|
|
|
|
For each record with a Token listed in the CumData array:<BR>
|
|
|
|
- Update the instance count and the total, minimum, and maximum durations.
|
|
|
|
Finally, print the gathered cumulative statistics.
|
2015-11-05 02:59:24 +01:00
|
|
|
|
|
|
|
@param[in] CustomCumulativeData A pointer to the cumtom cumulative data.
|
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
ProcessCumulative(
|
2015-11-05 02:59:24 +01:00
|
|
|
IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL
|
|
|
|
)
|
2013-03-04 23:02:59 +01:00
|
|
|
{
|
|
|
|
UINT64 AvgDur; // the computed average duration
|
|
|
|
UINT64 Dur;
|
|
|
|
UINT64 MinDur;
|
|
|
|
UINT64 MaxDur;
|
|
|
|
EFI_STRING StringPtr;
|
|
|
|
UINTN TIndex;
|
|
|
|
EFI_STRING StringPtrUnknown;
|
|
|
|
|
2017-11-24 10:26:24 +01:00
|
|
|
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
|
|
|
|
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
(StringPtr == NULL) ? StringPtrUnknown: StringPtr);
|
|
|
|
FreePool (StringPtr);
|
|
|
|
FreePool (StringPtrUnknown);
|
|
|
|
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1), mDpHiiHandle);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2), mDpHiiHandle);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
|
2013-03-04 23:02:59 +01:00
|
|
|
|
|
|
|
for ( TIndex = 0; TIndex < NumCum; ++TIndex) {
|
|
|
|
if (CumData[TIndex].Count != 0) {
|
|
|
|
AvgDur = DivU64x32 (CumData[TIndex].Duration, CumData[TIndex].Count);
|
|
|
|
AvgDur = DurationInMicroSeconds(AvgDur);
|
|
|
|
Dur = DurationInMicroSeconds(CumData[TIndex].Duration);
|
|
|
|
MaxDur = DurationInMicroSeconds(CumData[TIndex].MaxDur);
|
|
|
|
MinDur = DurationInMicroSeconds(CumData[TIndex].MinDur);
|
2017-11-24 10:26:24 +01:00
|
|
|
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
CumData[TIndex].Name,
|
|
|
|
CumData[TIndex].Count,
|
|
|
|
Dur,
|
|
|
|
AvgDur,
|
|
|
|
MinDur,
|
|
|
|
MaxDur
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
2015-11-05 02:59:24 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Print the custom cumulative data.
|
|
|
|
//
|
|
|
|
if (CustomCumulativeData != NULL) {
|
|
|
|
if (CustomCumulativeData->Count != 0) {
|
|
|
|
AvgDur = DivU64x32 (CustomCumulativeData->Duration, CustomCumulativeData->Count);
|
|
|
|
AvgDur = DurationInMicroSeconds (AvgDur);
|
|
|
|
Dur = DurationInMicroSeconds (CustomCumulativeData->Duration);
|
|
|
|
MaxDur = DurationInMicroSeconds (CustomCumulativeData->MaxDur);
|
|
|
|
MinDur = DurationInMicroSeconds (CustomCumulativeData->MinDur);
|
|
|
|
} else {
|
|
|
|
AvgDur = 0;
|
|
|
|
Dur = 0;
|
|
|
|
MaxDur = 0;
|
|
|
|
MinDur = 0;
|
|
|
|
}
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), mDpHiiHandle,
|
2015-11-05 02:59:24 +01:00
|
|
|
CustomCumulativeData->Name,
|
|
|
|
CustomCumulativeData->Count,
|
|
|
|
Dur,
|
|
|
|
AvgDur,
|
|
|
|
MinDur,
|
|
|
|
MaxDur
|
|
|
|
);
|
|
|
|
}
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|