/** @file
Trace reporting for the Dp utility.
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
which accompanies this distribution. The full text of the license may be found at
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include <Library/BaseMemoryLib.h>
#include <Library/MemoryAllocationLib.h>
#include <Library/DebugLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/TimerLib.h>
#include <Library/PeCoffGetEntryPointLib.h>
#include <Library/PerformanceLib.h>
#include <Library/PrintLib.h>
#include <Guid/Performance.h>
#include "Dp.h"
#include "Literals.h"
#include "DpInternal.h"
/**
Collect verbose statistics about the logged performance measurements.
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.
@pre The SummaryData and CumData structures must be initialized
prior to calling this function.
@post The SummaryData and CumData structures contain statistics for the
current performance logs.
**/
)
{
LogEntryKey = 0;
while ((LogEntryKey = GetPerformanceMeasurementEx (
&Measurement.Identifier)) != 0)
{
if (Measurement.EndTimeStamp == 0) {
continue;
}
}
if (IsPhase( &Measurement)) {
}
else { // !IsPhase(...
}
}
}
if (TIndex >= 0) {
}
}
}
}
}
/**
Gather and print ALL Trace Records.
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.
@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.
@param[in] Limit The number of records to print. Zero is ALL.
@param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
**/
)
{
// Get Handle information
//
Size = 0;
if (Status == EFI_BUFFER_TOO_SMALL) {
if (HandleBuffer == NULL) {
return;
}
}
}
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) {
} else {
}
LogEntryKey = 0;
Count = 0;
Index = 0;
&Measurement.Identifier)) != 0)
)
{
++Index; // Count every record. First record is 1.
ElapsedTime = 0;
if (Measurement.EndTimeStamp != 0) {
}
else {
IncFlag = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_INCOMPLETE), NULL); // Mark incomplete records
}
) { // 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
// See if the Handle is in the HandleBuffer
break;
}
}
}
}
// Ensure that the argument strings are not too long.
mUnicodeToken[13] = 0;
if (mShowId) {
);
} else {
);
}
}
}
if (HandleBuffer != &TempHandle) {
}
}
/**
Gather and print Raw Trace Records.
All Trace measurements with a duration greater than or equal to
mInterestThreshold are printed without interpretation.
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.
@pre The mInterestThreshold global variable is set to the shortest duration to be printed.
@param[in] Limit The number of records to print. Zero is ALL.
@param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
**/
)
{
if (mShowId) {
} else {
}
LogEntryKey = 0;
Count = 0;
Index = 0;
&Measurement.Identifier)) != 0)
)
{
++Index; // Count every record. First record is 1.
ElapsedTime = 0;
if (Measurement.EndTimeStamp != 0) {
}
if ((ElapsedTime < mInterestThreshold) ||
) { // Ignore "uninteresting" or Excluded records
continue;
}
++Count; // Count the number of records printed
if (mShowId) {
);
} else {
);
}
}
}
/**
Gather and print Major Phase metrics.
@param[in] Ticker The timer value for the END of Shell phase
**/
)
{
BdsTimeoutValue = 0;
SecTime = 0;
PeiTime = 0;
DxeTime = 0;
BdsTime = 0;
ShellTime = 0;
//
// Get Execution Phase Statistics
//
LogEntryKey = 0;
while ((LogEntryKey = GetPerformanceMeasurementEx (
&Measurement.Identifier)) != 0)
{
}
continue;
}
)
{
}
}
Total = 0;
// print SEC phase duration time
//
if (SecTime > 0) {
}
// print PEI phase duration time
//
if (PeiTime > 0) {
ElapsedTime = DivU64x32 (
);
Total += ElapsedTime;
}
// print DXE phase duration time
//
if (DxeTime > 0) {
ElapsedTime = DivU64x32 (
);
Total += ElapsedTime;
}
// print BDS phase duration time
//
if (BdsTime > 0) {
ElapsedTime = DivU64x32 (
);
Total += ElapsedTime;
}
if (BdsTimeoutValue > 0) {
ElapsedTime = DivU64x32 (
);
}
// print SHELL phase duration time
//
if (ShellTime > 0) {
ElapsedTime = DivU64x32 (
);
Total += ElapsedTime;
}
}
/**
Gather and print Handle data.
@param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
@return Status from a call to gBS->LocateHandle().
**/
)
{
Size = 0;
if (Status == EFI_BUFFER_TOO_SMALL) {
if (HandleBuffer == NULL) {
return Status;
}
}
}
else {
#if DP_DEBUG == 2
#endif
if (mShowId) {
} else {
}
LogEntryKey = 0;
Count = 0;
while ((LogEntryKey = GetPerformanceMeasurementEx (
&Measurement.Identifier)) != 0)
{
Count++;
if ((ElapsedTime < mInterestThreshold) ||
(Measurement.EndTimeStamp == 0) ||
) { // Ignore "uninteresting" or excluded records
continue;
}
mGaugeString[0] = 0; // Empty driver name by default
// See if the Handle is in the HandleBuffer
break;
}
}
// Ensure that the argument strings are not too long.
mUnicodeToken[11] = 0;
if (mGaugeString[0] != 0) {
// Display the record if it has a valid handle.
if (mShowId) {
);
} else {
);
}
}
}
}
if (HandleBuffer != &TempHandle) {
}
return Status;
}
/**
Gather and print PEIM data.
Only prints complete PEIM records
**/
)
{
if (mShowId) {
} else {
}
TIndex = 0;
LogEntryKey = 0;
while ((LogEntryKey = GetPerformanceMeasurementEx (
&Measurement.Identifier)) != 0)
{
TIndex++;
if ((Measurement.EndTimeStamp == 0) ||
) {
continue;
}
if (ElapsedTime >= mInterestThreshold) {
// PEIM FILE Handle is the start address of its FFS file that contains its file guid.
if (mShowId) {
);
} else {
);
}
}
}
}
/**
Gather and print global data.
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.
**/
)
{
if (mShowId) {
} else {
}
Index = 1;
LogEntryKey = 0;
while ((LogEntryKey = GetPerformanceMeasurementEx (
&Measurement.Identifier)) != 0)
{
mGaugeString[25] = 0;
mUnicodeToken[31] = 0;
if ( ! ( IsPhase( &Measurement) ||
(Measurement.EndTimeStamp == 0)
))
{
if (ElapsedTime >= mInterestThreshold) {
if (mShowId) {
);
} else {
);
}
}
}
Index++;
}
}
/**
Gather and print cumulative data.
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.
**/
)
{
Dur,
);
}
}
}