2013-03-04 23:02:59 +01:00
|
|
|
/** @file
|
|
|
|
Shell command for Displaying Performance Metrics.
|
|
|
|
|
|
|
|
The Dp command reads performance data and presents it in several
|
|
|
|
different formats depending upon the needs of the user. Both
|
|
|
|
Trace and Measured Profiling information is processed and presented.
|
|
|
|
|
|
|
|
Dp uses the "PerformanceLib" to read the measurement records.
|
|
|
|
The "TimerLib" provides information about the timer, such as frequency,
|
|
|
|
beginning, and ending counter values.
|
|
|
|
Measurement records contain identifying information (Handle, Token, Module)
|
|
|
|
and start and end time values.
|
|
|
|
Dp uses this information to group records in different ways. It also uses
|
|
|
|
timer information to calculate elapsed time for each measurement.
|
2018-06-27 15:13:38 +02:00
|
|
|
|
2018-01-22 09:39:03 +01:00
|
|
|
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
|
2016-03-07 04:23:08 +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 "Dp.h"
|
|
|
|
#include "Literals.h"
|
|
|
|
#include "DpInternal.h"
|
|
|
|
|
2018-01-22 09:39:03 +01:00
|
|
|
#pragma pack(1)
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
EFI_ACPI_DESCRIPTION_HEADER Header;
|
|
|
|
UINT32 Entry;
|
|
|
|
} RSDT_TABLE;
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
EFI_ACPI_DESCRIPTION_HEADER Header;
|
|
|
|
UINT64 Entry;
|
|
|
|
} XSDT_TABLE;
|
|
|
|
|
|
|
|
#pragma pack()
|
|
|
|
|
2017-11-24 10:26:24 +01:00
|
|
|
EFI_HANDLE mDpHiiHandle;
|
|
|
|
|
2018-01-22 09:39:03 +01:00
|
|
|
typedef struct {
|
|
|
|
EFI_HANDLE Handle;
|
|
|
|
EFI_GUID ModuleGuid;
|
|
|
|
} HANDLE_GUID_MAP;
|
|
|
|
|
|
|
|
HANDLE_GUID_MAP *mCacheHandleGuidTable;
|
|
|
|
UINTN mCachePairCount = 0;
|
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
//
|
|
|
|
/// Module-Global Variables
|
|
|
|
///@{
|
|
|
|
CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH + 1];
|
|
|
|
CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];
|
|
|
|
UINT64 mInterestThreshold;
|
|
|
|
BOOLEAN mShowId = FALSE;
|
2018-01-22 09:39:03 +01:00
|
|
|
UINT8 *mBootPerformanceTable;
|
|
|
|
UINTN mBootPerformanceTableSize;
|
|
|
|
BOOLEAN mPeiPhase = FALSE;
|
|
|
|
BOOLEAN mDxePhase = FALSE;
|
2013-03-04 23:02:59 +01:00
|
|
|
|
|
|
|
PERF_SUMMARY_DATA SummaryData = { 0 }; ///< Create the SummaryData structure and init. to ZERO.
|
2018-01-22 09:39:03 +01:00
|
|
|
MEASUREMENT_RECORD *mMeasurementList = NULL;
|
|
|
|
UINTN mMeasurementNum = 0;
|
2013-03-04 23:02:59 +01:00
|
|
|
|
|
|
|
/// Items for which to gather cumulative statistics.
|
|
|
|
PERF_CUM_DATA CumData[] = {
|
|
|
|
PERF_INIT_CUM_DATA (LOAD_IMAGE_TOK),
|
|
|
|
PERF_INIT_CUM_DATA (START_IMAGE_TOK),
|
|
|
|
PERF_INIT_CUM_DATA (DRIVERBINDING_START_TOK),
|
2018-07-19 05:26:21 +02:00
|
|
|
PERF_INIT_CUM_DATA (DRIVERBINDING_SUPPORT_TOK),
|
|
|
|
PERF_INIT_CUM_DATA (DRIVERBINDING_STOP_TOK)
|
2013-03-04 23:02:59 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
/// Number of items for which we are gathering cumulative statistics.
|
|
|
|
UINT32 const NumCum = sizeof(CumData) / sizeof(PERF_CUM_DATA);
|
|
|
|
|
|
|
|
STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
|
|
|
|
{L"-v", TypeFlag}, // -v Verbose Mode
|
|
|
|
{L"-A", TypeFlag}, // -A All, Cooked
|
|
|
|
{L"-R", TypeFlag}, // -R RAW All
|
|
|
|
{L"-s", TypeFlag}, // -s Summary
|
|
|
|
{L"-x", TypeFlag}, // -x eXclude Cumulative Items
|
|
|
|
{L"-i", TypeFlag}, // -i Display Identifier
|
2015-11-05 02:59:24 +01:00
|
|
|
{L"-c", TypeValue}, // -c Display cumulative data.
|
2013-03-04 23:02:59 +01:00
|
|
|
{L"-n", TypeValue}, // -n # Number of records to display for A and R
|
|
|
|
{L"-t", TypeValue}, // -t # Threshold of interest
|
|
|
|
{NULL, TypeMax}
|
|
|
|
};
|
|
|
|
|
|
|
|
///@}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Display the trailing Verbose information.
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
DumpStatistics( void )
|
|
|
|
{
|
|
|
|
EFI_STRING StringPtr;
|
|
|
|
EFI_STRING StringPtrUnknown;
|
2017-11-24 10:26:24 +01:00
|
|
|
StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_STATISTICS), NULL);
|
|
|
|
StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
(StringPtr == NULL) ? StringPtrUnknown : StringPtr);
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMTRACE), mDpHiiHandle, SummaryData.NumTrace);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMINCOMPLETE), mDpHiiHandle, SummaryData.NumIncomplete);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPHASES), mDpHiiHandle, SummaryData.NumSummary);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMHANDLES), mDpHiiHandle, SummaryData.NumHandles, SummaryData.NumTrace - SummaryData.NumHandles);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPEIMS), mDpHiiHandle, SummaryData.NumPEIMs);
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMGLOBALS), mDpHiiHandle, SummaryData.NumGlobal);
|
2013-03-04 23:02:59 +01:00
|
|
|
SHELL_FREE_NON_NULL (StringPtr);
|
|
|
|
SHELL_FREE_NON_NULL (StringPtrUnknown);
|
|
|
|
}
|
|
|
|
|
2018-01-22 09:39:03 +01:00
|
|
|
/**
|
|
|
|
Get Boot performance table form Acpi table.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
GetBootPerformanceTable (
|
|
|
|
)
|
|
|
|
{
|
|
|
|
FIRMWARE_PERFORMANCE_TABLE *FirmwarePerformanceTable;
|
|
|
|
|
2018-06-08 10:40:40 +02:00
|
|
|
FirmwarePerformanceTable = (FIRMWARE_PERFORMANCE_TABLE *) EfiLocateFirstAcpiTable (
|
|
|
|
EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE
|
|
|
|
);
|
2018-01-22 09:39:03 +01:00
|
|
|
if (FirmwarePerformanceTable == NULL) {
|
2018-02-09 04:10:12 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_ACPI_FPDT_FAIL), mDpHiiHandle);
|
2018-01-22 09:39:03 +01:00
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
mBootPerformanceTable = (UINT8*) (UINTN)FirmwarePerformanceTable->BootPointerRecord.BootPerformanceTablePointer;
|
|
|
|
mBootPerformanceTableSize = ((BOOT_PERFORMANCE_TABLE *) mBootPerformanceTable)->Header.Length;
|
|
|
|
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Get Handle form Module Guid.
|
|
|
|
|
|
|
|
@param ModuleGuid Module Guid.
|
|
|
|
@param Handle The handle to be returned.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
GetHandleFormModuleGuid (
|
|
|
|
IN EFI_GUID *ModuleGuid,
|
|
|
|
IN OUT EFI_HANDLE *Handle
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN Index;
|
|
|
|
|
|
|
|
if (IsZeroGuid (ModuleGuid)) {
|
|
|
|
*Handle = NULL;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Try to get the Handle form the caached array.
|
|
|
|
//
|
|
|
|
for (Index = 0; Index < mCachePairCount; Index++) {
|
|
|
|
if (CompareGuid (ModuleGuid, &mCacheHandleGuidTable[Index].ModuleGuid)) {
|
|
|
|
*Handle = mCacheHandleGuidTable[Index].Handle;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (Index >= mCachePairCount) {
|
|
|
|
*Handle = NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Cache the GUID and handle mapping pairs. In order to save time for searching.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
BuildCachedGuidHandleTable (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_HANDLE *HandleBuffer;
|
|
|
|
UINTN HandleCount;
|
|
|
|
UINTN Index;
|
|
|
|
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
|
|
|
|
EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
|
|
|
|
EFI_GUID *TempGuid;
|
|
|
|
MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *FvFilePath;
|
|
|
|
|
|
|
|
Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);
|
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
|
|
|
mCacheHandleGuidTable = AllocateZeroPool (HandleCount * sizeof (HANDLE_GUID_MAP));
|
|
|
|
if (mCacheHandleGuidTable == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (Index = 0; Index < HandleCount; Index++) {
|
|
|
|
//
|
|
|
|
// Try Handle as ImageHandle.
|
|
|
|
//
|
|
|
|
Status = gBS->HandleProtocol (
|
|
|
|
HandleBuffer[Index],
|
|
|
|
&gEfiLoadedImageProtocolGuid,
|
|
|
|
(VOID**) &LoadedImage
|
|
|
|
);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
//
|
|
|
|
// Try Handle as Controller Handle
|
|
|
|
//
|
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
HandleBuffer[Index],
|
|
|
|
&gEfiDriverBindingProtocolGuid,
|
|
|
|
(VOID **) &DriverBinding,
|
|
|
|
NULL,
|
|
|
|
NULL,
|
|
|
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
|
|
|
);
|
|
|
|
if (!EFI_ERROR (Status)) {
|
|
|
|
//
|
|
|
|
// Get Image protocol from ImageHandle
|
|
|
|
//
|
|
|
|
Status = gBS->HandleProtocol (
|
|
|
|
DriverBinding->ImageHandle,
|
|
|
|
&gEfiLoadedImageProtocolGuid,
|
|
|
|
(VOID**) &LoadedImage
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!EFI_ERROR (Status) && LoadedImage != NULL) {
|
|
|
|
//
|
|
|
|
// Get Module Guid from DevicePath.
|
|
|
|
//
|
|
|
|
if (LoadedImage->FilePath != NULL &&
|
|
|
|
LoadedImage->FilePath->Type == MEDIA_DEVICE_PATH &&
|
|
|
|
LoadedImage->FilePath->SubType == MEDIA_PIWG_FW_FILE_DP
|
|
|
|
) {
|
|
|
|
FvFilePath = (MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) LoadedImage->FilePath;
|
|
|
|
TempGuid = &FvFilePath->FvFileName;
|
|
|
|
|
|
|
|
mCacheHandleGuidTable[mCachePairCount].Handle = HandleBuffer[Index];
|
|
|
|
CopyGuid (&mCacheHandleGuidTable[mCachePairCount].ModuleGuid, TempGuid);
|
|
|
|
mCachePairCount ++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (HandleBuffer != NULL) {
|
|
|
|
FreePool (HandleBuffer);
|
|
|
|
HandleBuffer = NULL;
|
|
|
|
}
|
2018-05-11 08:02:08 +02:00
|
|
|
return EFI_SUCCESS;
|
2018-01-22 09:39:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Get Measurement form Fpdt records.
|
|
|
|
|
|
|
|
@param RecordHeader Pointer to the start record.
|
|
|
|
@param IsStart Is start record or End record.
|
|
|
|
@param Measurement Pointer to the measurement which need to be filled.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
GetMeasurementInfo (
|
|
|
|
IN EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *RecordHeader,
|
|
|
|
IN BOOLEAN IsStart,
|
|
|
|
IN OUT MEASUREMENT_RECORD *Measurement
|
|
|
|
)
|
|
|
|
{
|
|
|
|
VOID *ModuleGuid;
|
|
|
|
EFI_HANDLE StartHandle;
|
|
|
|
|
|
|
|
switch (RecordHeader->Type) {
|
|
|
|
case FPDT_GUID_EVENT_TYPE:
|
|
|
|
ModuleGuid = &(((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Guid);
|
|
|
|
Measurement->Identifier = ((UINT32)((FPDT_GUID_EVENT_RECORD *)RecordHeader)->ProgressID);
|
|
|
|
if (IsStart) {
|
|
|
|
Measurement->StartTimeStamp = ((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Timestamp;
|
|
|
|
} else {
|
|
|
|
Measurement->EndTimeStamp = ((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Timestamp;
|
|
|
|
}
|
|
|
|
switch (Measurement->Identifier) {
|
|
|
|
case MODULE_START_ID:
|
|
|
|
case MODULE_END_ID:
|
|
|
|
if (mPeiPhase) {
|
|
|
|
Measurement->Token = ALit_PEIM;
|
|
|
|
Measurement->Module = ALit_PEIM;
|
|
|
|
} else if (mDxePhase) {
|
|
|
|
Measurement->Token = ALit_START_IMAGE;
|
|
|
|
Measurement->Module = ALit_START_IMAGE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ASSERT(FALSE);
|
|
|
|
}
|
|
|
|
|
2018-06-22 10:56:20 +02:00
|
|
|
if (Measurement->Token != NULL && AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {
|
|
|
|
Measurement->Handle = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);
|
2018-01-22 09:39:03 +01:00
|
|
|
} else {
|
|
|
|
GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
|
2018-06-22 10:56:20 +02:00
|
|
|
Measurement->Handle = StartHandle;
|
|
|
|
//
|
|
|
|
// When no perf entry to record the PEI and DXE phase,
|
|
|
|
// For start image, we need detect the PEIM and non PEIM here.
|
|
|
|
//
|
|
|
|
if (Measurement->Token == NULL) {
|
|
|
|
if (StartHandle == NULL && !IsZeroGuid (ModuleGuid)) {
|
|
|
|
Measurement->Token = ALit_PEIM;
|
|
|
|
Measurement->Module = ALit_PEIM;
|
|
|
|
Measurement->Handle = ModuleGuid;
|
|
|
|
} else {
|
|
|
|
Measurement->Token = ALit_START_IMAGE;
|
|
|
|
Measurement->Module = ALit_START_IMAGE;
|
|
|
|
}
|
|
|
|
}
|
2018-01-22 09:39:03 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FPDT_DYNAMIC_STRING_EVENT_TYPE:
|
|
|
|
ModuleGuid = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);
|
|
|
|
Measurement->Identifier = ((UINT32)((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);
|
|
|
|
if (IsStart) {
|
|
|
|
Measurement->StartTimeStamp = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
|
|
|
|
} else {
|
|
|
|
Measurement->EndTimeStamp = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
|
|
|
|
}
|
|
|
|
switch (Measurement->Identifier) {
|
|
|
|
case MODULE_START_ID:
|
|
|
|
case MODULE_END_ID:
|
|
|
|
if (mPeiPhase) {
|
|
|
|
Measurement->Token = ALit_PEIM;
|
|
|
|
} else if (mDxePhase) {
|
|
|
|
Measurement->Token = ALit_START_IMAGE;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MODULE_LOADIMAGE_START_ID:
|
|
|
|
case MODULE_LOADIMAGE_END_ID:
|
|
|
|
Measurement->Token = ALit_LOAD_IMAGE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MODULE_DB_START_ID:
|
|
|
|
case MODULE_DB_END_ID:
|
|
|
|
Measurement->Token = ALit_DB_START;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MODULE_DB_SUPPORT_START_ID:
|
|
|
|
case MODULE_DB_SUPPORT_END_ID:
|
|
|
|
Measurement->Token = ALit_DB_SUPPORT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MODULE_DB_STOP_START_ID:
|
|
|
|
case MODULE_DB_STOP_END_ID:
|
|
|
|
Measurement->Token = ALit_DB_STOP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
Measurement->Token = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->String;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
Measurement->Module = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->String;
|
|
|
|
|
2018-06-22 10:56:20 +02:00
|
|
|
if (Measurement->Token != NULL && AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {
|
2018-01-22 09:39:03 +01:00
|
|
|
Measurement->Handle = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);
|
|
|
|
} else {
|
|
|
|
GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
|
|
|
|
Measurement->Handle = StartHandle;
|
2018-06-22 10:56:20 +02:00
|
|
|
//
|
|
|
|
// When no perf entry to record the PEI and DXE phase,
|
|
|
|
// For start image, we need detect the PEIM and non PEIM here.
|
|
|
|
//
|
|
|
|
if (Measurement->Token == NULL && (Measurement->Identifier == MODULE_START_ID || Measurement->Identifier == MODULE_END_ID)) {
|
|
|
|
if (StartHandle == NULL && !IsZeroGuid (ModuleGuid)) {
|
|
|
|
Measurement->Token = ALit_PEIM;
|
|
|
|
Measurement->Handle = ModuleGuid;
|
|
|
|
} else {
|
|
|
|
Measurement->Token = ALit_START_IMAGE;
|
|
|
|
}
|
|
|
|
}
|
2018-01-22 09:39:03 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FPDT_GUID_QWORD_EVENT_TYPE:
|
|
|
|
ModuleGuid = &(((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->Guid);
|
|
|
|
Measurement->Identifier = ((UINT32)((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->ProgressID);
|
|
|
|
if (IsStart) {
|
|
|
|
Measurement->StartTimeStamp = ((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->Timestamp;
|
|
|
|
} else {
|
|
|
|
Measurement->EndTimeStamp = ((FPDT_GUID_QWORD_EVENT_RECORD *)RecordHeader)->Timestamp;
|
|
|
|
}
|
|
|
|
switch (Measurement->Identifier) {
|
|
|
|
case MODULE_DB_START_ID:
|
|
|
|
Measurement->Token = ALit_DB_START;
|
|
|
|
Measurement->Module = ALit_DB_START;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MODULE_DB_SUPPORT_START_ID:
|
|
|
|
case MODULE_DB_SUPPORT_END_ID:
|
|
|
|
Measurement->Token = ALit_DB_SUPPORT;
|
|
|
|
Measurement->Module = ALit_DB_SUPPORT;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MODULE_DB_STOP_START_ID:
|
|
|
|
case MODULE_DB_STOP_END_ID:
|
|
|
|
Measurement->Token = ALit_DB_STOP;
|
|
|
|
Measurement->Module = ALit_DB_STOP;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case MODULE_LOADIMAGE_START_ID:
|
|
|
|
case MODULE_LOADIMAGE_END_ID:
|
|
|
|
Measurement->Token = ALit_LOAD_IMAGE;
|
|
|
|
Measurement->Module = ALit_LOAD_IMAGE;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
ASSERT(FALSE);
|
|
|
|
}
|
|
|
|
GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
|
|
|
|
Measurement->Handle = StartHandle;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case FPDT_GUID_QWORD_STRING_EVENT_TYPE:
|
|
|
|
ModuleGuid = &(((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->Guid);
|
|
|
|
Measurement->Identifier = ((UINT32)((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);
|
|
|
|
if (IsStart) {
|
|
|
|
Measurement->StartTimeStamp = ((FPDT_GUID_QWORD_STRING_EVENT_RECORD*)RecordHeader)->Timestamp;
|
|
|
|
} else {
|
|
|
|
Measurement->EndTimeStamp = ((FPDT_GUID_QWORD_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
|
|
|
|
}
|
|
|
|
//
|
|
|
|
// Currently only "DB:Start:" end record with FPDT_GUID_QWORD_STRING_EVENT_TYPE.
|
|
|
|
//
|
|
|
|
switch (Measurement->Identifier) {
|
|
|
|
case MODULE_DB_END_ID:
|
|
|
|
Measurement->Token = ALit_DB_START;
|
|
|
|
Measurement->Module = ALit_DB_START;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ASSERT(FALSE);
|
|
|
|
}
|
|
|
|
GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
|
|
|
|
Measurement->Handle = StartHandle;
|
|
|
|
break;
|
|
|
|
|
2018-06-22 10:56:20 +02:00
|
|
|
case FPDT_DUAL_GUID_STRING_EVENT_TYPE:
|
|
|
|
ModuleGuid = &(((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Guid1);
|
|
|
|
Measurement->Identifier = ((UINT32)((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);
|
|
|
|
if (IsStart) {
|
|
|
|
Measurement->StartTimeStamp = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
|
|
|
|
} else {
|
|
|
|
Measurement->EndTimeStamp = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;
|
|
|
|
}
|
|
|
|
Measurement->Token = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->String;
|
|
|
|
Measurement->Module = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->String;
|
|
|
|
GetHandleFormModuleGuid(ModuleGuid, &StartHandle);
|
|
|
|
Measurement->Handle = StartHandle;
|
|
|
|
break;
|
|
|
|
|
2018-01-22 09:39:03 +01:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Search the start measurement in the mMeasurementList for the end measurement.
|
|
|
|
|
|
|
|
@param EndMeasureMent Measurement for end record.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
SearchMeasurement (
|
|
|
|
IN MEASUREMENT_RECORD *EndMeasureMent
|
|
|
|
)
|
|
|
|
{
|
|
|
|
INTN Index;
|
|
|
|
|
|
|
|
for (Index = mMeasurementNum - 1; Index >= 0; Index--) {
|
|
|
|
if (AsciiStrCmp (EndMeasureMent->Token, ALit_PEIM) == 0) {
|
|
|
|
if (mMeasurementList[Index].EndTimeStamp == 0 && EndMeasureMent->Handle!= NULL && mMeasurementList[Index].Handle != NULL&&
|
|
|
|
CompareGuid(mMeasurementList[Index].Handle, EndMeasureMent->Handle) &&
|
|
|
|
(AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) &&
|
|
|
|
(AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0)) {
|
|
|
|
mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;
|
|
|
|
break;
|
|
|
|
}
|
2018-06-22 10:56:20 +02:00
|
|
|
} else if (EndMeasureMent->Identifier == PERF_CROSSMODULE_END_ID) {
|
|
|
|
if (mMeasurementList[Index].EndTimeStamp == 0 &&
|
|
|
|
(AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) &&
|
|
|
|
(AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0) &&
|
|
|
|
mMeasurementList[Index].Identifier == PERF_CROSSMODULE_START_ID) {
|
|
|
|
mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;
|
|
|
|
break;
|
|
|
|
}
|
2018-01-22 09:39:03 +01:00
|
|
|
} else {
|
|
|
|
if (mMeasurementList[Index].EndTimeStamp == 0 && mMeasurementList[Index].Handle == EndMeasureMent->Handle &&
|
|
|
|
(AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) &&
|
|
|
|
(AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0)) {
|
|
|
|
mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Generate the measure record array.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
BuildMeasurementList (
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *RecordHeader;
|
|
|
|
UINT8 *PerformanceTablePtr;
|
|
|
|
UINT16 StartProgressId;
|
|
|
|
UINTN TableLength;
|
|
|
|
UINT8 *StartRecordEvent;
|
|
|
|
MEASUREMENT_RECORD MeasureMent;
|
|
|
|
|
|
|
|
mMeasurementList = AllocateZeroPool (mBootPerformanceTableSize);
|
|
|
|
if (mMeasurementList == NULL) {
|
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
|
|
|
TableLength = sizeof (BOOT_PERFORMANCE_TABLE);
|
|
|
|
PerformanceTablePtr = (mBootPerformanceTable + TableLength);
|
|
|
|
|
|
|
|
while (TableLength < mBootPerformanceTableSize) {
|
|
|
|
RecordHeader = (EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER*) PerformanceTablePtr;
|
|
|
|
StartRecordEvent = (UINT8 *)RecordHeader;
|
|
|
|
StartProgressId = ((FPDT_GUID_EVENT_RECORD *)StartRecordEvent)->ProgressID;
|
|
|
|
|
|
|
|
//
|
2018-06-22 10:56:20 +02:00
|
|
|
// If the record with ProgressId 0, the record doesn't appear in pairs. The timestamp in the record is the EndTimeStamp, its StartTimeStamp is 0.
|
2018-01-22 09:39:03 +01:00
|
|
|
// If the record is the start record, fill the info to the measurement in the mMeasurementList.
|
|
|
|
// If the record is the end record, find the related start measurement in the mMeasurementList and fill the EndTimeStamp.
|
|
|
|
//
|
2018-06-22 10:56:20 +02:00
|
|
|
if (StartProgressId == 0) {
|
|
|
|
GetMeasurementInfo (RecordHeader, FALSE, &(mMeasurementList[mMeasurementNum]));
|
|
|
|
mMeasurementNum ++;
|
|
|
|
} else if (((StartProgressId >= PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 0x000F) == 0)) ||
|
2018-01-22 09:39:03 +01:00
|
|
|
(StartProgressId < PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 0x0001) != 0)))) {
|
|
|
|
//
|
|
|
|
// Since PEIM and StartImage has same Type and ID when PCD PcdEdkiiFpdtStringRecordEnableOnly = FALSE
|
|
|
|
// So we need to identify these two kinds of record through different phase.
|
|
|
|
//
|
2018-06-22 10:56:20 +02:00
|
|
|
if(StartProgressId == PERF_CROSSMODULE_START_ID ){
|
|
|
|
if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_PEI) == 0) {
|
|
|
|
mPeiPhase = TRUE;
|
|
|
|
} else if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_DXE) == 0) {
|
|
|
|
mDxePhase = TRUE;
|
|
|
|
mPeiPhase = FALSE;
|
|
|
|
}
|
2018-01-22 09:39:03 +01:00
|
|
|
}
|
|
|
|
// Get measurement info form the start record to the mMeasurementList.
|
|
|
|
GetMeasurementInfo (RecordHeader, TRUE, &(mMeasurementList[mMeasurementNum]));
|
|
|
|
mMeasurementNum ++;
|
|
|
|
} else {
|
2018-06-22 10:56:20 +02:00
|
|
|
ZeroMem(&MeasureMent, sizeof(MEASUREMENT_RECORD));
|
2018-01-22 09:39:03 +01:00
|
|
|
GetMeasurementInfo (RecordHeader, FALSE, &MeasureMent);
|
|
|
|
SearchMeasurement (&MeasureMent);
|
|
|
|
}
|
|
|
|
TableLength += RecordHeader->Length;
|
|
|
|
PerformanceTablePtr += RecordHeader->Length;
|
|
|
|
}
|
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2015-11-05 02:03:14 +01:00
|
|
|
/**
|
|
|
|
Initialize the cumulative data.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
InitCumulativeData (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN Index;
|
|
|
|
|
|
|
|
for (Index = 0; Index < NumCum; ++Index) {
|
|
|
|
CumData[Index].Count = 0;
|
|
|
|
CumData[Index].MinDur = PERF_MAXDUR;
|
|
|
|
CumData[Index].MaxDur = 0;
|
|
|
|
CumData[Index].Duration = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-05-12 14:57:36 +02:00
|
|
|
/**
|
|
|
|
Initialize the Summary data.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
InitSummaryData (
|
|
|
|
VOID
|
|
|
|
)
|
|
|
|
{
|
|
|
|
SummaryData.NumTrace = 0;
|
|
|
|
SummaryData.NumIncomplete = 0;
|
|
|
|
SummaryData.NumSummary = 0;
|
|
|
|
SummaryData.NumHandles = 0;
|
|
|
|
SummaryData.NumPEIMs = 0;
|
|
|
|
SummaryData.NumGlobal = 0;
|
|
|
|
}
|
|
|
|
|
2015-11-05 02:03:14 +01:00
|
|
|
/**
|
2013-03-04 23:02:59 +01:00
|
|
|
Dump performance data.
|
2018-06-27 15:13:38 +02:00
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
@param[in] ImageHandle The image handle.
|
|
|
|
@param[in] SystemTable The system table.
|
2018-06-27 15:13:38 +02:00
|
|
|
|
2016-03-07 04:23:08 +01:00
|
|
|
@retval SHELL_SUCCESS Command completed successfully.
|
|
|
|
@retval SHELL_INVALID_PARAMETER Command usage error.
|
|
|
|
@retval SHELL_ABORTED The user aborts the operation.
|
|
|
|
@retval value Unknown error.
|
2013-03-04 23:02:59 +01:00
|
|
|
**/
|
|
|
|
SHELL_STATUS
|
2017-11-24 10:26:24 +01:00
|
|
|
RunDp (
|
2013-03-04 23:02:59 +01:00
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
)
|
|
|
|
{
|
|
|
|
LIST_ENTRY *ParamPackage;
|
|
|
|
CONST CHAR16 *CmdLineArg;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
2016-06-08 09:23:24 +02:00
|
|
|
PERFORMANCE_PROPERTY *PerformanceProperty;
|
2013-03-04 23:02:59 +01:00
|
|
|
UINTN Number2Display;
|
|
|
|
|
2013-03-11 02:22:51 +01:00
|
|
|
EFI_STRING StringPtr;
|
|
|
|
BOOLEAN SummaryMode;
|
|
|
|
BOOLEAN VerboseMode;
|
|
|
|
BOOLEAN AllMode;
|
|
|
|
BOOLEAN RawMode;
|
|
|
|
BOOLEAN ExcludeMode;
|
2015-11-05 02:59:24 +01:00
|
|
|
BOOLEAN CumulativeMode;
|
|
|
|
CONST CHAR16 *CustomCumulativeToken;
|
|
|
|
PERF_CUM_DATA *CustomCumulativeData;
|
2016-06-15 07:39:13 +02:00
|
|
|
UINTN NameSize;
|
2016-03-07 04:23:08 +01:00
|
|
|
SHELL_STATUS ShellStatus;
|
2018-01-22 09:39:03 +01:00
|
|
|
TIMER_INFO TimerInfo;
|
2018-06-25 16:49:56 +02:00
|
|
|
UINT64 Intermediate;
|
2013-03-11 02:22:51 +01:00
|
|
|
|
|
|
|
StringPtr = NULL;
|
|
|
|
SummaryMode = FALSE;
|
|
|
|
VerboseMode = FALSE;
|
|
|
|
AllMode = FALSE;
|
|
|
|
RawMode = FALSE;
|
|
|
|
ExcludeMode = FALSE;
|
2015-11-05 02:59:24 +01:00
|
|
|
CumulativeMode = FALSE;
|
|
|
|
CustomCumulativeData = NULL;
|
2016-03-07 04:23:08 +01:00
|
|
|
ShellStatus = SHELL_SUCCESS;
|
2013-03-04 23:02:59 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// initialize the shell lib (we must be in non-auto-init...)
|
|
|
|
//
|
|
|
|
Status = ShellInitialize();
|
|
|
|
ASSERT_EFI_ERROR(Status);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Process Command Line arguments
|
|
|
|
//
|
|
|
|
Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE);
|
|
|
|
if (EFI_ERROR(Status)) {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_ARG), mDpHiiHandle);
|
2013-03-04 23:02:59 +01:00
|
|
|
return SHELL_INVALID_PARAMETER;
|
2018-06-25 16:49:56 +02:00
|
|
|
} else if (ShellCommandLineGetCount(ParamPackage) > 1){
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_MANY), mDpHiiHandle);
|
|
|
|
return SHELL_INVALID_PARAMETER;
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Boolean options
|
|
|
|
//
|
|
|
|
VerboseMode = ShellCommandLineGetFlag (ParamPackage, L"-v");
|
|
|
|
SummaryMode = (BOOLEAN) (ShellCommandLineGetFlag (ParamPackage, L"-S") || ShellCommandLineGetFlag (ParamPackage, L"-s"));
|
|
|
|
AllMode = ShellCommandLineGetFlag (ParamPackage, L"-A");
|
|
|
|
RawMode = ShellCommandLineGetFlag (ParamPackage, L"-R");
|
|
|
|
ExcludeMode = ShellCommandLineGetFlag (ParamPackage, L"-x");
|
|
|
|
mShowId = ShellCommandLineGetFlag (ParamPackage, L"-i");
|
2015-11-05 02:59:24 +01:00
|
|
|
CumulativeMode = ShellCommandLineGetFlag (ParamPackage, L"-c");
|
2013-03-04 23:02:59 +01:00
|
|
|
|
2018-06-25 16:49:56 +02:00
|
|
|
if (AllMode && RawMode) {
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CONFLICT_ARG), mDpHiiHandle, L"-A", L"-R");
|
|
|
|
return SHELL_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
// Options with Values
|
2018-06-25 16:49:56 +02:00
|
|
|
if (ShellCommandLineGetFlag (ParamPackage, L"-n")) {
|
|
|
|
CmdLineArg = ShellCommandLineGetValue (ParamPackage, L"-n");
|
|
|
|
if (CmdLineArg == NULL) {
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_FEW), mDpHiiHandle);
|
|
|
|
return SHELL_INVALID_PARAMETER;
|
|
|
|
} else {
|
|
|
|
if (!(RawMode || AllMode)) {
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_NO_RAW_ALL), mDpHiiHandle);
|
|
|
|
return SHELL_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
Status = ShellConvertStringToUint64(CmdLineArg, &Intermediate, FALSE, TRUE);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_NUM_ARG), mDpHiiHandle, L"-n");
|
|
|
|
return SHELL_INVALID_PARAMETER;
|
|
|
|
} else {
|
|
|
|
Number2Display = (UINTN)Intermediate;
|
|
|
|
if (Number2Display == 0 || Number2Display > MAXIMUM_DISPLAYCOUNT) {
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_RANGE), mDpHiiHandle, L"-n", 0, MAXIMUM_DISPLAYCOUNT);
|
|
|
|
return SHELL_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
}
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
2018-06-25 16:49:56 +02:00
|
|
|
} else {
|
|
|
|
Number2Display = DEFAULT_DISPLAYCOUNT;
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
|
2018-06-25 16:49:56 +02:00
|
|
|
if (ShellCommandLineGetFlag (ParamPackage, L"-t")) {
|
|
|
|
CmdLineArg = ShellCommandLineGetValue (ParamPackage, L"-t");
|
|
|
|
if (CmdLineArg == NULL) {
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_FEW), mDpHiiHandle);
|
|
|
|
return SHELL_INVALID_PARAMETER;
|
|
|
|
} else {
|
|
|
|
Status = ShellConvertStringToUint64(CmdLineArg, &Intermediate, FALSE, TRUE);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_NUM_ARG), mDpHiiHandle, L"-t");
|
|
|
|
return SHELL_INVALID_PARAMETER;
|
|
|
|
} else {
|
|
|
|
mInterestThreshold = Intermediate;
|
|
|
|
}
|
|
|
|
}
|
2013-03-04 23:02:59 +01:00
|
|
|
} else {
|
2018-06-25 16:49:56 +02:00
|
|
|
mInterestThreshold = DEFAULT_THRESHOLD; // 1ms := 1,000 us
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
|
2018-06-25 16:49:56 +02:00
|
|
|
if (ShellCommandLineGetFlag (ParamPackage, L"-c")) {
|
|
|
|
CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c");
|
|
|
|
if (CustomCumulativeToken == NULL) {
|
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_FEW), mDpHiiHandle);
|
|
|
|
return SHELL_INVALID_PARAMETER;
|
|
|
|
} else {
|
|
|
|
CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA));
|
|
|
|
if (CustomCumulativeData == NULL) {
|
|
|
|
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
CustomCumulativeData->MinDur = PERF_MAXDUR;
|
|
|
|
CustomCumulativeData->MaxDur = 0;
|
|
|
|
CustomCumulativeData->Count = 0;
|
|
|
|
CustomCumulativeData->Duration = 0;
|
|
|
|
NameSize = StrLen (CustomCumulativeToken) + 1;
|
|
|
|
CustomCumulativeData->Name = AllocateZeroPool (NameSize);
|
|
|
|
if (CustomCumulativeData->Name == NULL) {
|
|
|
|
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, NameSize);
|
|
|
|
}
|
|
|
|
}
|
2013-03-04 23:02:59 +01:00
|
|
|
|
2018-05-11 08:02:08 +02:00
|
|
|
//
|
|
|
|
// DP dump performance data by parsing FPDT table in ACPI table.
|
|
|
|
// Folloing 3 steps are to get the measurement form the FPDT table.
|
|
|
|
//
|
|
|
|
|
|
|
|
//
|
|
|
|
//1. Get FPDT from ACPI table.
|
|
|
|
//
|
|
|
|
Status = GetBootPerformanceTable ();
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
ShellStatus = Status;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
//2. Cache the ModuleGuid and hanlde mapping table.
|
|
|
|
//
|
|
|
|
Status = BuildCachedGuidHandleTable();
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
ShellStatus = Status;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
//3. Build the measurement array form the FPDT records.
|
|
|
|
//
|
|
|
|
Status = BuildMeasurementList ();
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
ShellStatus = SHELL_OUT_OF_RESOURCES;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
2015-11-05 02:03:14 +01:00
|
|
|
//
|
|
|
|
// Initialize the pre-defined cumulative data.
|
|
|
|
//
|
|
|
|
InitCumulativeData ();
|
|
|
|
|
2018-05-12 14:57:36 +02:00
|
|
|
//
|
|
|
|
// Initialize the Summary data.
|
|
|
|
//
|
|
|
|
InitSummaryData ();
|
|
|
|
|
2013-03-04 23:02:59 +01:00
|
|
|
//
|
|
|
|
// Timer specific processing
|
|
|
|
//
|
|
|
|
// Get the Performance counter characteristics:
|
|
|
|
// Freq = Frequency in Hz
|
|
|
|
// StartCount = Value loaded into the counter when it starts counting
|
|
|
|
// EndCount = Value counter counts to before it needs to be reset
|
|
|
|
//
|
2017-02-24 03:06:01 +01:00
|
|
|
Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **) &PerformanceProperty);
|
2017-02-27 02:33:00 +01:00
|
|
|
if (EFI_ERROR (Status) || (PerformanceProperty == NULL)) {
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PERF_PROPERTY_NOT_FOUND), mDpHiiHandle);
|
2016-06-08 09:23:24 +02:00
|
|
|
goto Done;
|
|
|
|
}
|
2013-03-04 23:02:59 +01:00
|
|
|
|
2016-06-08 09:23:24 +02:00
|
|
|
TimerInfo.Frequency = (UINT32)DivU64x32 (PerformanceProperty->Frequency, 1000);
|
2018-01-22 09:39:03 +01:00
|
|
|
TimerInfo.StartCount = 0;
|
|
|
|
TimerInfo.EndCount = 0xFFFF;
|
|
|
|
TimerInfo.CountUp = TRUE;
|
2013-03-04 23:02:59 +01:00
|
|
|
|
|
|
|
//
|
|
|
|
// Print header
|
|
|
|
//
|
|
|
|
// print DP's build version
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_BUILD_REVISION), mDpHiiHandle, DP_MAJOR_VERSION, DP_MINOR_VERSION);
|
2013-03-04 23:02:59 +01:00
|
|
|
|
|
|
|
// print performance timer characteristics
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_KHZ), mDpHiiHandle, TimerInfo.Frequency);
|
2013-03-04 23:02:59 +01:00
|
|
|
|
|
|
|
if (VerboseMode && !RawMode) {
|
2017-11-24 10:26:24 +01:00
|
|
|
StringPtr = HiiGetString (mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
(EFI_STRING_ID) (TimerInfo.CountUp ? STRING_TOKEN (STR_DP_UP) : STRING_TOKEN (STR_DP_DOWN)), NULL);
|
|
|
|
ASSERT (StringPtr != NULL);
|
|
|
|
// Print Timer count range and direction
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TIMER_PROPERTIES), mDpHiiHandle,
|
2013-03-04 23:02:59 +01:00
|
|
|
StringPtr,
|
|
|
|
TimerInfo.StartCount,
|
|
|
|
TimerInfo.EndCount
|
|
|
|
);
|
2017-11-24 10:26:24 +01:00
|
|
|
ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_VERBOSE_THRESHOLD), mDpHiiHandle, mInterestThreshold);
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
**** Print Sections based on command line options
|
|
|
|
****
|
|
|
|
**** Option modes have the following priority:
|
|
|
|
**** v Verbose -- Valid in combination with any other options
|
|
|
|
**** t Threshold -- Modifies All, Raw, and Cooked output
|
|
|
|
**** Default is 0 for All and Raw mode
|
|
|
|
**** Default is DEFAULT_THRESHOLD for "Cooked" mode
|
|
|
|
**** n Number2Display Used by All and Raw mode. Otherwise ignored.
|
|
|
|
**** A All -- R and S options are ignored
|
|
|
|
**** R Raw -- S option is ignored
|
|
|
|
**** s Summary -- Modifies "Cooked" output only
|
|
|
|
**** Cooked (Default)
|
|
|
|
****************************************************************************/
|
2015-11-05 02:59:24 +01:00
|
|
|
GatherStatistics (CustomCumulativeData);
|
2018-06-27 15:13:38 +02:00
|
|
|
if (CumulativeMode) {
|
2015-11-05 02:59:24 +01:00
|
|
|
ProcessCumulative (CustomCumulativeData);
|
|
|
|
} else if (AllMode) {
|
2018-05-12 15:00:23 +02:00
|
|
|
Status = DumpAllTrace( Number2Display, ExcludeMode);
|
|
|
|
if (Status == EFI_ABORTED) {
|
|
|
|
ShellStatus = SHELL_ABORTED;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
} else if (RawMode) {
|
|
|
|
Status = DumpRawTrace( Number2Display, ExcludeMode);
|
|
|
|
if (Status == EFI_ABORTED) {
|
|
|
|
ShellStatus = SHELL_ABORTED;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
//------------- Begin Cooked Mode Processing
|
|
|
|
ProcessPhases ();
|
|
|
|
if ( ! SummaryMode) {
|
|
|
|
Status = ProcessHandles ( ExcludeMode);
|
2016-03-07 04:23:08 +01:00
|
|
|
if (Status == EFI_ABORTED) {
|
|
|
|
ShellStatus = SHELL_ABORTED;
|
|
|
|
goto Done;
|
|
|
|
}
|
2018-05-12 15:00:23 +02:00
|
|
|
|
|
|
|
Status = ProcessPeims ();
|
2016-03-07 04:23:08 +01:00
|
|
|
if (Status == EFI_ABORTED) {
|
|
|
|
ShellStatus = SHELL_ABORTED;
|
|
|
|
goto Done;
|
|
|
|
}
|
2018-05-12 15:00:23 +02:00
|
|
|
|
|
|
|
Status = ProcessGlobal ();
|
|
|
|
if (Status == EFI_ABORTED) {
|
|
|
|
ShellStatus = SHELL_ABORTED;
|
|
|
|
goto Done;
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
2018-05-12 15:00:23 +02:00
|
|
|
|
|
|
|
ProcessCumulative (NULL);
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
|
|
|
} //------------- End of Cooked Mode Processing
|
|
|
|
if ( VerboseMode || SummaryMode) {
|
|
|
|
DumpStatistics();
|
|
|
|
}
|
|
|
|
|
2016-03-07 04:23:08 +01:00
|
|
|
Done:
|
2016-03-28 05:03:23 +02:00
|
|
|
if (ParamPackage != NULL) {
|
|
|
|
ShellCommandLineFreeVarList (ParamPackage);
|
|
|
|
}
|
2013-03-04 23:02:59 +01:00
|
|
|
SHELL_FREE_NON_NULL (StringPtr);
|
2015-11-05 02:59:24 +01:00
|
|
|
if (CustomCumulativeData != NULL) {
|
|
|
|
SHELL_FREE_NON_NULL (CustomCumulativeData->Name);
|
|
|
|
}
|
|
|
|
SHELL_FREE_NON_NULL (CustomCumulativeData);
|
2013-03-04 23:02:59 +01:00
|
|
|
|
2018-01-22 09:39:03 +01:00
|
|
|
SHELL_FREE_NON_NULL (mMeasurementList);
|
|
|
|
|
|
|
|
SHELL_FREE_NON_NULL (mCacheHandleGuidTable);
|
|
|
|
|
|
|
|
mMeasurementNum = 0;
|
|
|
|
mCachePairCount = 0;
|
2016-03-07 04:23:08 +01:00
|
|
|
return ShellStatus;
|
2013-03-04 23:02:59 +01:00
|
|
|
}
|
2017-11-24 10:26:24 +01:00
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
Retrive HII package list from ImageHandle and publish to HII database.
|
|
|
|
|
|
|
|
@param ImageHandle The image handle of the process.
|
|
|
|
|
|
|
|
@return HII handle.
|
|
|
|
**/
|
|
|
|
EFI_HANDLE
|
|
|
|
InitializeHiiPackage (
|
|
|
|
EFI_HANDLE ImageHandle
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
EFI_HII_PACKAGE_LIST_HEADER *PackageList;
|
|
|
|
EFI_HANDLE HiiHandle;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Retrieve HII package list from ImageHandle
|
|
|
|
//
|
|
|
|
Status = gBS->OpenProtocol (
|
|
|
|
ImageHandle,
|
|
|
|
&gEfiHiiPackageListProtocolGuid,
|
|
|
|
(VOID **)&PackageList,
|
|
|
|
ImageHandle,
|
|
|
|
NULL,
|
|
|
|
EFI_OPEN_PROTOCOL_GET_PROTOCOL
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Publish HII package list to HII Database.
|
|
|
|
//
|
|
|
|
Status = gHiiDatabase->NewPackageList (
|
|
|
|
gHiiDatabase,
|
|
|
|
PackageList,
|
|
|
|
NULL,
|
|
|
|
&HiiHandle
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return HiiHandle;
|
|
|
|
}
|