47UINTN mCachePairCount = 0;
53CHAR16 mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];
54UINT64 mInterestThreshold;
55BOOLEAN mShowId =
FALSE;
56UINT8 *mBootPerformanceTable;
57UINTN mBootPerformanceTableSize;
58BOOLEAN mPeiPhase =
FALSE;
59BOOLEAN mDxePhase =
FALSE;
64UINTN mMeasurementNum = 0;
101 EFI_STRING StringPtr;
102 EFI_STRING StringPtrUnknown;
112 (StringPtr ==
NULL) ? StringPtrUnknown : StringPtr
120 SHELL_FREE_NON_NULL (StringPtr);
121 SHELL_FREE_NON_NULL (StringPtrUnknown);
138 if (FirmwarePerformanceTable ==
NULL) {
140 if (EFI_ERROR (Status)) {
142 return EFI_NOT_FOUND;
175 for (Index = 0; Index < mCachePairCount; Index++) {
176 if (
CompareGuid (ModuleGuid, &mCacheHandleGuidTable[Index].ModuleGuid)) {
177 *Handle = mCacheHandleGuidTable[Index].Handle;
182 if (Index >= mCachePairCount) {
206 if (EFI_ERROR (Status)) {
212 if (mCacheHandleGuidTable ==
NULL) {
213 return EFI_OUT_OF_RESOURCES;
216 for (Index = 0; Index < HandleCount; Index++) {
220 Status =
gBS->HandleProtocol (
222 &gEfiLoadedImageProtocolGuid,
223 (VOID **)&LoadedImage
225 if (EFI_ERROR (Status)) {
229 Status =
gBS->OpenProtocol (
231 &gEfiDriverBindingProtocolGuid,
232 (VOID **)&DriverBinding,
235 EFI_OPEN_PROTOCOL_GET_PROTOCOL
237 if (!EFI_ERROR (Status)) {
241 Status =
gBS->HandleProtocol (
242 DriverBinding->ImageHandle,
243 &gEfiLoadedImageProtocolGuid,
244 (VOID **)&LoadedImage
249 if (!EFI_ERROR (Status) && (LoadedImage !=
NULL)) {
253 if ((LoadedImage->FilePath !=
NULL) &&
254 (LoadedImage->FilePath->Type == MEDIA_DEVICE_PATH) &&
259 TempGuid = &FvFilePath->FvFileName;
261 mCacheHandleGuidTable[mCachePairCount].Handle = HandleBuffer[Index];
262 CopyGuid (&mCacheHandleGuidTable[mCachePairCount].ModuleGuid, TempGuid);
268 if (HandleBuffer !=
NULL) {
294 switch (RecordHeader->Type) {
295 case FPDT_GUID_EVENT_TYPE:
304 switch (Measurement->Identifier) {
305 case MODULE_START_ID:
308 Measurement->Token = ALit_PEIM;
309 Measurement->Module = ALit_PEIM;
310 }
else if (mDxePhase) {
311 Measurement->Token = ALit_START_IMAGE;
312 Measurement->Module = ALit_START_IMAGE;
320 if ((Measurement->Token !=
NULL) && (
AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0)) {
324 Measurement->Handle = StartHandle;
329 if (Measurement->Token ==
NULL) {
331 Measurement->Token = ALit_PEIM;
332 Measurement->Module = ALit_PEIM;
333 Measurement->Handle = ModuleGuid;
335 Measurement->Token = ALit_START_IMAGE;
336 Measurement->Module = ALit_START_IMAGE;
343 case FPDT_DYNAMIC_STRING_EVENT_TYPE:
352 switch (Measurement->Identifier) {
353 case MODULE_START_ID:
356 Measurement->Token = ALit_PEIM;
357 }
else if (mDxePhase) {
358 Measurement->Token = ALit_START_IMAGE;
363 case MODULE_LOADIMAGE_START_ID:
364 case MODULE_LOADIMAGE_END_ID:
365 Measurement->Token = ALit_LOAD_IMAGE;
368 case MODULE_DB_START_ID:
369 case MODULE_DB_END_ID:
370 Measurement->Token = ALit_DB_START;
373 case MODULE_DB_SUPPORT_START_ID:
374 case MODULE_DB_SUPPORT_END_ID:
375 Measurement->Token = ALit_DB_SUPPORT;
378 case MODULE_DB_STOP_START_ID:
379 case MODULE_DB_STOP_END_ID:
380 Measurement->Token = ALit_DB_STOP;
390 if ((Measurement->Token !=
NULL) && (
AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0)) {
394 Measurement->Handle = StartHandle;
399 if ((Measurement->Token ==
NULL) && ((Measurement->Identifier == MODULE_START_ID) || (Measurement->Identifier == MODULE_END_ID))) {
401 Measurement->Token = ALit_PEIM;
402 Measurement->Handle = ModuleGuid;
404 Measurement->Token = ALit_START_IMAGE;
411 case FPDT_GUID_QWORD_EVENT_TYPE:
420 switch (Measurement->Identifier) {
421 case MODULE_DB_START_ID:
422 Measurement->Token = ALit_DB_START;
423 Measurement->Module = ALit_DB_START;
426 case MODULE_DB_SUPPORT_START_ID:
427 case MODULE_DB_SUPPORT_END_ID:
428 Measurement->Token = ALit_DB_SUPPORT;
429 Measurement->Module = ALit_DB_SUPPORT;
432 case MODULE_DB_STOP_START_ID:
433 case MODULE_DB_STOP_END_ID:
434 Measurement->Token = ALit_DB_STOP;
435 Measurement->Module = ALit_DB_STOP;
438 case MODULE_LOADIMAGE_START_ID:
439 case MODULE_LOADIMAGE_END_ID:
440 Measurement->Token = ALit_LOAD_IMAGE;
441 Measurement->Module = ALit_LOAD_IMAGE;
449 Measurement->Handle = StartHandle;
452 case FPDT_GUID_QWORD_STRING_EVENT_TYPE:
464 switch (Measurement->Identifier) {
465 case MODULE_DB_END_ID:
466 Measurement->Token = ALit_DB_START;
467 Measurement->Module = ALit_DB_START;
474 Measurement->Handle = StartHandle;
477 case FPDT_DUAL_GUID_STRING_EVENT_TYPE:
489 Measurement->Handle = StartHandle;
510 for (Index = mMeasurementNum - 1; Index >= 0; Index--) {
511 if (
AsciiStrCmp (EndMeasureMent->Token, ALit_PEIM) == 0) {
512 if ((mMeasurementList[Index].EndTimeStamp == 0) && (EndMeasureMent->Handle !=
NULL) && (mMeasurementList[Index].Handle !=
NULL) &&
513 CompareGuid (mMeasurementList[Index].Handle, EndMeasureMent->Handle) &&
514 (
AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->
Token) == 0) &&
517 mMeasurementList[Index].
EndTimeStamp = EndMeasureMent->EndTimeStamp;
520 }
else if (EndMeasureMent->Identifier == PERF_CROSSMODULE_END_ID) {
521 if ((mMeasurementList[Index].EndTimeStamp == 0) &&
522 (
AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->
Token) == 0) &&
524 (mMeasurementList[Index].
Identifier == PERF_CROSSMODULE_START_ID))
526 mMeasurementList[Index].
EndTimeStamp = EndMeasureMent->EndTimeStamp;
530 if ((mMeasurementList[Index].EndTimeStamp == 0) && (mMeasurementList[Index].Handle == EndMeasureMent->Handle) &&
531 (
AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->
Token) == 0) &&
534 mMeasurementList[Index].
EndTimeStamp = EndMeasureMent->EndTimeStamp;
550 UINT8 *PerformanceTablePtr;
551 UINT8 *BasicBootTablePtr;
553 UINT16 StartProgressId;
555 UINT8 *StartRecordEvent;
559 if (mMeasurementList ==
NULL) {
560 return EFI_OUT_OF_RESOURCES;
567 BasicBootTablePtr = (mBootPerformanceTable + TableLength);
571 mResetEnd = ResetEnd;
575 PerformanceTablePtr = (mBootPerformanceTable + TableLength);
577 while (TableLength < mBootPerformanceTableSize) {
579 StartRecordEvent = (UINT8 *)RecordHeader;
587 if (StartProgressId == 0) {
590 }
else if ((((StartProgressId >= PERF_EVENTSIGNAL_START_ID) && ((StartProgressId & 0x000F) == 0)) ||
591 ((StartProgressId < PERF_EVENTSIGNAL_START_ID) && ((StartProgressId & 0x0001) != 0))))
597 if (StartProgressId == PERF_CROSSMODULE_START_ID ) {
615 TableLength += RecordHeader->Length;
616 PerformanceTablePtr += RecordHeader->Length;
633 for (Index = 0; Index <
NumCum; ++Index) {
676 CONST CHAR16 *CmdLineArg;
680 UINTN Number2Display;
682 EFI_STRING StringPtr;
688 BOOLEAN CumulativeMode;
689 CONST CHAR16 *CustomCumulativeToken;
702 CumulativeMode =
FALSE;
703 CustomCumulativeData =
NULL;
716 if (EFI_ERROR (Status)) {
735 if (AllMode && RawMode) {
743 if (CmdLineArg ==
NULL) {
747 if (!(RawMode || AllMode)) {
753 if (EFI_ERROR (Status)) {
757 Number2Display = (
UINTN)Intermediate;
765 Number2Display = DEFAULT_DISPLAYCOUNT;
770 if (CmdLineArg ==
NULL) {
775 if (EFI_ERROR (Status)) {
779 mInterestThreshold = Intermediate;
788 if (CustomCumulativeToken ==
NULL) {
793 if (CustomCumulativeData ==
NULL) {
798 CustomCumulativeData->
MinDur = PERF_MAXDUR;
799 CustomCumulativeData->
MaxDur = 0;
800 CustomCumulativeData->
Count = 0;
802 NameSize =
StrLen (CustomCumulativeToken) + 1;
804 if (CustomCumulativeData->
Name ==
NULL) {
822 if (EFI_ERROR (Status)) {
823 ShellStatus = Status;
831 if (EFI_ERROR (Status)) {
832 ShellStatus = Status;
840 if (EFI_ERROR (Status)) {
864 if (EFI_ERROR (Status) || (PerformanceProperty ==
NULL)) {
883 if (VerboseMode && !RawMode) {
889 ASSERT (StringPtr !=
NULL);
919 if (CumulativeMode) {
921 }
else if (AllMode) {
923 if (Status == EFI_ABORTED) {
927 }
else if (RawMode) {
929 if (Status == EFI_ABORTED) {
938 if (Status == EFI_ABORTED) {
944 if (Status == EFI_ABORTED) {
950 if (Status == EFI_ABORTED) {
959 if ( VerboseMode || SummaryMode) {
964 if (ParamPackage !=
NULL) {
968 SHELL_FREE_NON_NULL (StringPtr);
969 if (CustomCumulativeData !=
NULL) {
970 SHELL_FREE_NON_NULL (CustomCumulativeData->
Name);
973 SHELL_FREE_NON_NULL (CustomCumulativeData);
975 SHELL_FREE_NON_NULL (mMeasurementList);
977 SHELL_FREE_NON_NULL (mCacheHandleGuidTable);
1003 Status =
gBS->OpenProtocol (
1005 &gEfiHiiPackageListProtocolGuid,
1006 (VOID **)&PackageList,
1009 EFI_OPEN_PROTOCOL_GET_PROTOCOL
1012 if (EFI_ERROR (Status)) {
1026 if (EFI_ERROR (Status)) {
#define EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE
UINT64 EFIAPI DivU64x32(IN UINT64 Dividend, IN UINT32 Divisor)
INTN EFIAPI AsciiStrCmp(IN CONST CHAR8 *FirstString, IN CONST CHAR8 *SecondString)
RETURN_STATUS EFIAPI UnicodeStrToAsciiStrS(IN CONST CHAR16 *Source, OUT CHAR8 *Destination, IN UINTN DestMax)
UINTN EFIAPI StrLen(IN CONST CHAR16 *String)
BOOLEAN EFIAPI CompareGuid(IN CONST GUID *Guid1, IN CONST GUID *Guid2)
GUID *EFIAPI CopyGuid(OUT GUID *DestinationGuid, IN CONST GUID *SourceGuid)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
BOOLEAN EFIAPI IsZeroGuid(IN CONST GUID *Guid)
#define MEDIA_PIWG_FW_FILE_DP
PERF_CUM_DATA CumData[]
Items for which to gather cumulative statistics.
VOID InitSummaryData(VOID)
EFI_HII_HANDLE InitializeHiiPackage(EFI_HANDLE ImageHandle)
VOID SearchMeasurement(IN MEASUREMENT_RECORD *EndMeasureMent)
PERF_SUMMARY_DATA SummaryData
Create the SummaryData structure and init. to ZERO.
EFI_STATUS BuildCachedGuidHandleTable(VOID)
CHAR16 mGaugeString[DP_GAUGE_STRING_LENGTH+1]
SHELL_STATUS RunDp(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID GetHandleFormModuleGuid(IN EFI_GUID *ModuleGuid, IN OUT EFI_HANDLE *Handle)
EFI_STATUS BuildMeasurementList()
EFI_STATUS GetBootPerformanceTable()
UINT32 const NumCum
Number of items for which we are gathering cumulative statistics.
VOID DumpStatistics(void)
VOID GetMeasurementInfo(IN EFI_ACPI_5_0_FPDT_PERFORMANCE_RECORD_HEADER *RecordHeader, IN BOOLEAN IsStart, IN OUT MEASUREMENT_RECORD *Measurement)
VOID InitCumulativeData(VOID)
EFI_HII_HANDLE mDpHiiHandle
#define DEFAULT_THRESHOLD
One millisecond.
#define MAXIMUM_DISPLAYCOUNT
Arbitrary maximum reasonable number.
#define PERF_INIT_CUM_DATA(t)
VOID GatherStatistics(IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL)
EFI_STATUS ProcessGlobal(VOID)
EFI_STATUS DumpRawTrace(IN UINTN Limit, IN BOOLEAN ExcludeFlag)
EFI_STATUS ProcessPeims(VOID)
EFI_STATUS DumpAllTrace(IN UINTN Limit, IN BOOLEAN ExcludeFlag)
EFI_STATUS ProcessHandles(IN BOOLEAN ExcludeFlag)
VOID ProcessCumulative(IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STRING EFIAPI HiiGetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language OPTIONAL)
#define ASSERT_EFI_ERROR(StatusParameter)
@ SHELL_INVALID_PARAMETER
CONST CHAR16 *EFIAPI ShellCommandLineGetValue(IN CONST LIST_ENTRY *CheckPackage, IN CHAR16 *KeyString)
#define ShellCommandLineParse(CheckList, CheckPackage, ProblemParam, AutoPageBreak)
Make it easy to upgrade from older versions of the shell library.
EFI_STATUS EFIAPI ShellPrintHiiEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR8 *Language OPTIONAL, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle,...)
BOOLEAN EFIAPI ShellCommandLineGetFlag(IN CONST LIST_ENTRY *CONST CheckPackage, IN CONST CHAR16 *CONST KeyString)
@ TypeValue
A flag that has some data following it with a space (IE "-a 1").
@ TypeFlag
A flag that is present or not present only (IE "-a").
VOID EFIAPI ShellCommandLineFreeVarList(IN LIST_ENTRY *CheckPackage)
EFI_STATUS EFIAPI ShellInitialize(VOID)
UINTN EFIAPI ShellCommandLineGetCount(IN CONST LIST_ENTRY *CheckPackage)
EFI_STATUS EFIAPI ShellConvertStringToUint64(IN CONST CHAR16 *String, OUT UINT64 *Value, IN CONST BOOLEAN ForceHex, IN CONST BOOLEAN StopAtSpace)
EFI_HII_DATABASE_PROTOCOL * gHiiDatabase
EFI_STATUS EFIAPI EfiGetSystemConfigurationTable(IN EFI_GUID *TableGuid, OUT VOID **Table)
EFI_ACPI_COMMON_HEADER *EFIAPI EfiLocateFirstAcpiTable(IN UINT32 Signature)
UINT64 BootPerformanceTablePointer
EFI_ACPI_5_0_FPDT_BOOT_PERFORMANCE_TABLE_POINTER_RECORD BootPointerRecord
Basic Boot Performance Table Pointer record.
UINT32 Identifier
Identifier.
CONST CHAR8 * Module
Module string name.
CONST CHAR8 * Token
Measured token string name.
UINT64 EndTimeStamp
End time point.
UINT64 MaxDur
Largest duration encountered.
UINT64 MinDur
Smallest duration encountered.
UINT64 Duration
Cumulative duration for this item.
UINT32 Count
Total number of measurements accumulated.
CHAR8 * Name
ASCII name of this item.
UINT32 NumSummary
Number of summary section measurements.
UINT32 NumHandles
Number of measurements with handles.
UINT32 NumPEIMs
Number of measurements of PEIMs.
UINT32 NumTrace
Number of recorded TRACE performance measurements.
UINT32 NumGlobal
Number of measurements with END value and NULL handle.
UINT32 NumIncomplete
Number of measurements with no END value.
Structure for storing Timer specific information.
UINT64 StartCount
Value timer is initialized with.
UINT32 Frequency
Timer count frequency in KHz.
UINT64 EndCount
Value timer has just before it wraps.
BOOLEAN CountUp
TRUE if the counter counts up.