X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=PerformancePkg%2FDp_App%2FDpTrace.c;h=fc21cdc7078a2214d4fc3a3a427becf18e22ba5f;hb=01951d1b7c9de94e1ea3fcdd43b3baf816e9da26;hp=3799af482ec199d07dbe89f3790c4488b296f774;hpb=224beee0fa29b9b10cda6c1d25307371368a1040;p=mirror_edk2.git diff --git a/PerformancePkg/Dp_App/DpTrace.c b/PerformancePkg/Dp_App/DpTrace.c index 3799af482e..fc21cdc707 100644 --- a/PerformancePkg/Dp_App/DpTrace.c +++ b/PerformancePkg/Dp_App/DpTrace.c @@ -1,14 +1,15 @@ /** @file - * Trace reporting for the Dp utility. - * - * Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.
- * 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 - * http://opensource.org/licenses/bsd-license.php - * - * THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, - * WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. + Trace reporting for the Dp utility. + + Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.
+ (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
+ 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 + http://opensource.org/licenses/bsd-license.php + + 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 @@ -42,11 +43,14 @@ @post The SummaryData and CumData structures contain statistics for the current performance logs. + + @param[in, out] CustomCumulativeData A pointer to the cumtom cumulative data. + **/ VOID GatherStatistics( - VOID -) + IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL + ) { MEASUREMENT_RECORD Measurement; UINT64 Duration; @@ -54,13 +58,14 @@ GatherStatistics( INTN TIndex; LogEntryKey = 0; - while ((LogEntryKey = GetPerformanceMeasurement ( + while ((LogEntryKey = GetPerformanceMeasurementEx ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, - &Measurement.EndTimeStamp)) != 0) + &Measurement.EndTimeStamp, + &Measurement.Identifier)) != 0) { ++SummaryData.NumTrace; // Count the number of TRACE Measurement records if (Measurement.EndTimeStamp == 0) { @@ -97,6 +102,20 @@ GatherStatistics( CumData[TIndex].MaxDur = Duration; } } + + // + // 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; + } + } } } @@ -117,8 +136,11 @@ GatherStatistics( @param[in] Limit The number of records to print. Zero is ALL. @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display. + @retval EFI_SUCCESS The operation was successful. + @retval EFI_ABORTED The user aborts the operation. + @return Others from a call to gBS->LocateHandleBuffer(). **/ -VOID +EFI_STATUS DumpAllTrace( IN UINTN Limit, IN BOOLEAN ExcludeFlag @@ -134,27 +156,19 @@ DumpAllTrace( UINTN TIndex; EFI_HANDLE *HandleBuffer; - UINTN Size; - EFI_HANDLE TempHandle; + UINTN HandleCount; EFI_STATUS Status; + EFI_STRING StringPtrUnknown; + StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); IncFlag = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL); PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER), - (IncFlag == NULL) ? ALit_UNKNOWN: IncFlag); + (IncFlag == NULL) ? StringPtrUnknown : IncFlag); + FreePool (StringPtrUnknown); // Get Handle information // - Size = 0; - HandleBuffer = &TempHandle; - Status = gBS->LocateHandle (AllHandles, NULL, NULL, &Size, &TempHandle); - if (Status == EFI_BUFFER_TOO_SMALL) { - HandleBuffer = AllocatePool (Size); - ASSERT (HandleBuffer != NULL); - if (HandleBuffer == NULL) { - return; - } - Status = gBS->LocateHandle (AllHandles, NULL, NULL, &Size, HandleBuffer); - } + Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer); if (EFI_ERROR (Status)) { PrintToken (STRING_TOKEN (STR_DP_HANDLES_ERROR), Status); } @@ -165,40 +179,44 @@ DumpAllTrace( // Display only records with Elapsed times >= mInterestThreshold // Display driver names in Module field for records with Handles. // - PrintToken (STRING_TOKEN (STR_DP_ALL_HEADR) ); - PrintToken (STRING_TOKEN (STR_DP_DASHES) ); + if (mShowId) { + PrintToken (STRING_TOKEN (STR_DP_ALL_HEADR2) ); + PrintToken (STRING_TOKEN (STR_DP_ALL_DASHES2) ); + } else { + PrintToken (STRING_TOKEN (STR_DP_ALL_HEADR) ); + PrintToken (STRING_TOKEN (STR_DP_DASHES) ); + } LogEntryKey = 0; Count = 0; Index = 0; while ( WITHIN_LIMIT(Count, Limit) && - ((LogEntryKey = GetPerformanceMeasurement ( + ((LogEntryKey = GetPerformanceMeasurementEx ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, - &Measurement.EndTimeStamp)) != 0) + &Measurement.EndTimeStamp, + &Measurement.Identifier)) != 0) ) { ++Index; // Count every record. First record is 1. ElapsedTime = 0; + SafeFreePool ((VOID *) IncFlag); if (Measurement.EndTimeStamp != 0) { Duration = GetDuration (&Measurement); ElapsedTime = DurationInMicroSeconds ( Duration ); - IncFlag = STR_DP_COMPLETE; + IncFlag = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL); } else { - IncFlag = STR_DP_INCOMPLETE; // Mark incomplete records + IncFlag = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_INCOMPLETE), NULL); // Mark incomplete records } - if ((ElapsedTime < mInterestThreshold) || + if (((Measurement.EndTimeStamp != 0) && (ElapsedTime < mInterestThreshold)) || ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0)) ) { // Ignore "uninteresting" or excluded records continue; } - if (Measurement.EndTimeStamp == 0) { - ElapsedTime = Measurement.StartTimeStamp; - } ++Count; // Count the number of records printed // If Handle is non-zero, see if we can determine a name for the driver @@ -206,30 +224,53 @@ DumpAllTrace( AsciiStrToUnicodeStr (Measurement.Token, mUnicodeToken); if (Measurement.Handle != NULL) { // See if the Handle is in the HandleBuffer - for (TIndex = 0; TIndex < (Size / sizeof(HandleBuffer[0])); TIndex++) { + for (TIndex = 0; TIndex < HandleCount; TIndex++) { if (Measurement.Handle == HandleBuffer[TIndex]) { GetNameFromHandle (HandleBuffer[TIndex]); break; } } } - // Ensure that the argument strings are not too long. - mGaugeString[31] = 0; - mUnicodeToken[18] = 0; - PrintToken( STRING_TOKEN (STR_DP_ALL_STATS), - Index, // 1 based, Which measurement record is being printed - IncFlag, - Measurement.Handle, - mGaugeString, - mUnicodeToken, - ElapsedTime - ); + if (AsciiStrnCmp (Measurement.Token, ALit_PEIM, PERF_TOKEN_LENGTH) == 0) { + 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) { + PrintToken( STRING_TOKEN (STR_DP_ALL_VARS2), + Index, // 1 based, Which measurement record is being printed + IncFlag, + Measurement.Handle, + mGaugeString, + mUnicodeToken, + ElapsedTime, + Measurement.Identifier + ); + } else { + PrintToken( STRING_TOKEN (STR_DP_ALL_VARS), + Index, // 1 based, Which measurement record is being printed + IncFlag, + Measurement.Handle, + mGaugeString, + mUnicodeToken, + ElapsedTime + ); + } + if (ShellGetExecutionBreakFlag ()) { + Status = EFI_ABORTED; + break; + } } } - if (HandleBuffer != &TempHandle) { + if (HandleBuffer != NULL) { FreePool (HandleBuffer); } + SafeFreePool ((VOID *) IncFlag); + return Status; } /** @@ -248,9 +289,11 @@ DumpAllTrace( @param[in] Limit The number of records to print. Zero is ALL. @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display. - + + @retval EFI_SUCCESS The operation was successful. + @retval EFI_ABORTED The user aborts the operation. **/ -VOID +EFI_STATUS DumpRawTrace( IN UINTN Limit, IN BOOLEAN ExcludeFlag @@ -264,25 +307,38 @@ DumpRawTrace( UINTN Index; EFI_STRING StringPtr; + EFI_STRING StringPtrUnknown; + EFI_STATUS Status; + Status = EFI_SUCCESS; + + StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL); PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER), - (StringPtr == NULL) ? ALit_UNKNOWN: StringPtr); - - PrintToken (STRING_TOKEN (STR_DP_RAW_HEADR) ); - PrintToken (STRING_TOKEN (STR_DP_RAW_DASHES) ); + (StringPtr == NULL) ? StringPtrUnknown : StringPtr); + FreePool (StringPtr); + FreePool (StringPtrUnknown); + + if (mShowId) { + PrintToken (STRING_TOKEN (STR_DP_RAW_HEADR2) ); + PrintToken (STRING_TOKEN (STR_DP_RAW_DASHES2) ); + } else { + PrintToken (STRING_TOKEN (STR_DP_RAW_HEADR) ); + PrintToken (STRING_TOKEN (STR_DP_RAW_DASHES) ); + } LogEntryKey = 0; Count = 0; Index = 0; while ( WITHIN_LIMIT(Count, Limit) && - ((LogEntryKey = GetPerformanceMeasurement ( + ((LogEntryKey = GetPerformanceMeasurementEx ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, - &Measurement.EndTimeStamp)) != 0) + &Measurement.EndTimeStamp, + &Measurement.Identifier)) != 0) ) { ++Index; // Count every record. First record is 1. @@ -297,15 +353,33 @@ DumpRawTrace( continue; } ++Count; // Count the number of records printed - PrintToken (STRING_TOKEN (STR_DP_RAW_VARS), - Index, // 1 based, Which measurement record is being printed - Measurement.Handle, - Measurement.StartTimeStamp, - Measurement.EndTimeStamp, - Measurement.Token, - Measurement.Module - ); + + if (mShowId) { + PrintToken (STRING_TOKEN (STR_DP_RAW_VARS2), + Index, // 1 based, Which measurement record is being printed + Measurement.Handle, + Measurement.StartTimeStamp, + Measurement.EndTimeStamp, + Measurement.Token, + Measurement.Module, + Measurement.Identifier + ); + } else { + PrintToken (STRING_TOKEN (STR_DP_RAW_VARS), + Index, // 1 based, Which measurement record is being printed + Measurement.Handle, + Measurement.StartTimeStamp, + Measurement.EndTimeStamp, + Measurement.Token, + Measurement.Module + ); + } + if (ShellGetExecutionBreakFlag ()) { + Status = EFI_ABORTED; + break; + } } + return Status; } /** @@ -316,7 +390,7 @@ DumpRawTrace( **/ VOID ProcessPhases( - UINT64 Ticker + IN UINT64 Ticker ) { MEASUREMENT_RECORD Measurement; @@ -331,6 +405,7 @@ ProcessPhases( UINT64 Total; EFI_STRING StringPtr; UINTN LogEntryKey; + EFI_STRING StringPtrUnknown; BdsTimeoutValue = 0; SecTime = 0; @@ -341,18 +416,22 @@ ProcessPhases( // // Get Execution Phase Statistics // + StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL); PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER), - (StringPtr == NULL) ? ALit_UNKNOWN: StringPtr); + (StringPtr == NULL) ? StringPtrUnknown : StringPtr); + FreePool (StringPtr); + FreePool (StringPtrUnknown); LogEntryKey = 0; - while ((LogEntryKey = GetPerformanceMeasurement ( + while ((LogEntryKey = GetPerformanceMeasurementEx ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, - &Measurement.EndTimeStamp)) != 0) + &Measurement.EndTimeStamp, + &Measurement.Identifier)) != 0) { if (AsciiStrnCmp (Measurement.Token, ALit_SHELL, PERF_TOKEN_LENGTH) == 0) { Measurement.EndTimeStamp = Ticker; @@ -448,8 +527,10 @@ ProcessPhases( Gather and print Handle data. @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display. - - @return Status from a call to gBS->LocateHandle(). + + @retval EFI_SUCCESS The operation was successful. + @retval EFI_ABORTED The user aborts the operation. + @return Others from a call to gBS->LocateHandleBuffer(). **/ EFI_STATUS ProcessHandles( @@ -464,25 +545,18 @@ ProcessHandles( UINTN Index; UINTN LogEntryKey; UINTN Count; - UINTN Size; - EFI_HANDLE TempHandle; + UINTN HandleCount; EFI_STATUS Status; + EFI_STRING StringPtrUnknown; + StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL); PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER), - (StringPtr == NULL) ? ALit_UNKNOWN: StringPtr); - - Size = 0; - HandleBuffer = &TempHandle; - Status = gBS->LocateHandle (AllHandles, NULL, NULL, &Size, &TempHandle); - if (Status == EFI_BUFFER_TOO_SMALL) { - HandleBuffer = AllocatePool (Size); - ASSERT (HandleBuffer != NULL); - if (HandleBuffer == NULL) { - return Status; - } - Status = gBS->LocateHandle (AllHandles, NULL, NULL, &Size, HandleBuffer); - } + (StringPtr == NULL) ? StringPtrUnknown : StringPtr); + FreePool (StringPtr); + FreePool (StringPtrUnknown); + + Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer); if (EFI_ERROR (Status)) { PrintToken (STRING_TOKEN (STR_DP_HANDLES_ERROR), Status); } @@ -491,18 +565,23 @@ ProcessHandles( Print (L"There are %,d Handles defined.\n", (Size / sizeof(HandleBuffer[0]))); #endif - PrintToken (STRING_TOKEN (STR_DP_HANDLE_GUID) ); + if (mShowId) { + PrintToken (STRING_TOKEN (STR_DP_HANDLE_SECTION2) ); + } else { + PrintToken (STRING_TOKEN (STR_DP_HANDLE_SECTION) ); + } PrintToken (STRING_TOKEN (STR_DP_DASHES) ); LogEntryKey = 0; Count = 0; - while ((LogEntryKey = GetPerformanceMeasurement ( + while ((LogEntryKey = GetPerformanceMeasurementEx ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, - &Measurement.EndTimeStamp)) != 0) + &Measurement.EndTimeStamp, + &Measurement.Identifier)) != 0) { Count++; Duration = GetDuration (&Measurement); @@ -517,29 +596,45 @@ ProcessHandles( mGaugeString[0] = 0; // Empty driver name by default AsciiStrToUnicodeStr (Measurement.Token, mUnicodeToken); // See if the Handle is in the HandleBuffer - for (Index = 0; Index < (Size / sizeof(HandleBuffer[0])); Index++) { + for (Index = 0; Index < HandleCount; Index++) { if (Measurement.Handle == HandleBuffer[Index]) { GetNameFromHandle (HandleBuffer[Index]); // Name is put into mGaugeString break; } } // Ensure that the argument strings are not too long. - mGaugeString[31] = 0; - mUnicodeToken[18] = 0; + mGaugeString[DP_GAUGE_STRING_LENGTH] = 0; + mUnicodeToken[11] = 0; if (mGaugeString[0] != 0) { // Display the record if it has a valid handle. - PrintToken ( - STRING_TOKEN (STR_DP_HANDLE_VARS), - Count, // 1 based, Which measurement record is being printed - Index + 1, // 1 based, Which handle is being printed - mGaugeString, - mUnicodeToken, - ElapsedTime - ); + if (mShowId) { + PrintToken ( + STRING_TOKEN (STR_DP_HANDLE_VARS2), + Count, // 1 based, Which measurement record is being printed + Index + 1, // 1 based, Which handle is being printed + mGaugeString, + mUnicodeToken, + ElapsedTime, + Measurement.Identifier + ); + } else { + PrintToken ( + STRING_TOKEN (STR_DP_HANDLE_VARS), + Count, // 1 based, Which measurement record is being printed + Index + 1, // 1 based, Which handle is being printed + mGaugeString, + mUnicodeToken, + ElapsedTime + ); + } + } + if (ShellGetExecutionBreakFlag ()) { + Status = EFI_ABORTED; + break; } } } - if (HandleBuffer != &TempHandle) { + if (HandleBuffer != NULL) { FreePool (HandleBuffer); } return Status; @@ -549,9 +644,11 @@ ProcessHandles( Gather and print PEIM data. Only prints complete PEIM records - + + @retval EFI_SUCCESS The operation was successful. + @retval EFI_ABORTED The user aborts the operation. **/ -VOID +EFI_STATUS ProcessPeims( VOID ) @@ -562,23 +659,34 @@ ProcessPeims( EFI_STRING StringPtr; UINTN LogEntryKey; UINTN TIndex; + EFI_STRING StringPtrUnknown; + EFI_STATUS Status; + Status = EFI_SUCCESS; + StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL); PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER), - (StringPtr == NULL) ? ALit_UNKNOWN: StringPtr); - - PrintToken (STRING_TOKEN (STR_DP_PEIM_SECTION)); + (StringPtr == NULL) ? StringPtrUnknown : StringPtr); + FreePool (StringPtr); + FreePool (StringPtrUnknown); + + if (mShowId) { + PrintToken (STRING_TOKEN (STR_DP_PEIM_SECTION2)); + } else { + PrintToken (STRING_TOKEN (STR_DP_PEIM_SECTION)); + } PrintToken (STRING_TOKEN (STR_DP_DASHES)); TIndex = 0; LogEntryKey = 0; - while ((LogEntryKey = GetPerformanceMeasurement ( + while ((LogEntryKey = GetPerformanceMeasurementEx ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, - &Measurement.EndTimeStamp)) != 0) + &Measurement.EndTimeStamp, + &Measurement.Identifier)) != 0) { TIndex++; if ((Measurement.EndTimeStamp == 0) || @@ -590,15 +698,30 @@ ProcessPeims( Duration = GetDuration (&Measurement); ElapsedTime = DurationInMicroSeconds ( Duration ); // Calculate elapsed time in microseconds if (ElapsedTime >= mInterestThreshold) { - GetNameFromHandle ((EFI_HANDLE) Measurement.Handle); // Name placed in mGaugeString - PrintToken (STRING_TOKEN (STR_DP_PEIM_STAT2), - TIndex, // 1 based, Which measurement record is being printed - Measurement.Handle, - mGaugeString, - ElapsedTime - ); + // PEIM FILE Handle is the start address of its FFS file that contains its file guid. + if (mShowId) { + PrintToken (STRING_TOKEN (STR_DP_PEIM_VARS2), + TIndex, // 1 based, Which measurement record is being printed + Measurement.Handle, // base address + Measurement.Handle, // file guid + ElapsedTime, + Measurement.Identifier + ); + } else { + PrintToken (STRING_TOKEN (STR_DP_PEIM_VARS), + TIndex, // 1 based, Which measurement record is being printed + Measurement.Handle, // base address + Measurement.Handle, // file guid + ElapsedTime + ); + } + } + if (ShellGetExecutionBreakFlag ()) { + Status = EFI_ABORTED; + break; } } + return Status; } /** @@ -608,9 +731,11 @@ ProcessPeims( 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. - + + @retval EFI_SUCCESS The operation was successful. + @retval EFI_ABORTED The user aborts the operation. **/ -VOID +EFI_STATUS ProcessGlobal( VOID ) @@ -621,27 +746,41 @@ ProcessGlobal( EFI_STRING StringPtr; UINTN LogEntryKey; UINTN Index; // Index, or number, of the measurement record being processed + EFI_STRING StringPtrUnknown; + EFI_STATUS Status; + + Status = EFI_SUCCESS; + StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL); PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER), - (StringPtr == NULL) ? ALit_UNKNOWN: StringPtr); - - PrintToken (STRING_TOKEN (STR_DP_GLOBAL_SECTION)); + (StringPtr == NULL) ? StringPtrUnknown: StringPtr); + FreePool (StringPtr); + FreePool (StringPtrUnknown); + + if (mShowId) { + PrintToken (STRING_TOKEN (STR_DP_GLOBAL_SECTION2)); + } else { + PrintToken (STRING_TOKEN (STR_DP_GLOBAL_SECTION)); + } PrintToken (STRING_TOKEN (STR_DP_DASHES)); Index = 1; LogEntryKey = 0; - while ((LogEntryKey = GetPerformanceMeasurement ( + while ((LogEntryKey = GetPerformanceMeasurementEx ( LogEntryKey, &Measurement.Handle, &Measurement.Token, &Measurement.Module, &Measurement.StartTimeStamp, - &Measurement.EndTimeStamp)) != 0) + &Measurement.EndTimeStamp, + &Measurement.Identifier)) != 0) { AsciiStrToUnicodeStr (Measurement.Module, mGaugeString); AsciiStrToUnicodeStr (Measurement.Token, mUnicodeToken); + mGaugeString[25] = 0; + mUnicodeToken[31] = 0; if ( ! ( IsPhase( &Measurement) || (Measurement.Handle != NULL) || (Measurement.EndTimeStamp == 0) @@ -650,17 +789,33 @@ ProcessGlobal( Duration = GetDuration (&Measurement); ElapsedTime = DurationInMicroSeconds ( Duration ); if (ElapsedTime >= mInterestThreshold) { - PrintToken ( - STRING_TOKEN (STR_DP_FOUR_VARS_2), - Index, - mGaugeString, - mUnicodeToken, - ElapsedTime - ); + if (mShowId) { + PrintToken ( + STRING_TOKEN (STR_DP_GLOBAL_VARS2), + Index, + mGaugeString, + mUnicodeToken, + ElapsedTime, + Measurement.Identifier + ); + } else { + PrintToken ( + STRING_TOKEN (STR_DP_GLOBAL_VARS), + Index, + mGaugeString, + mUnicodeToken, + ElapsedTime + ); + } } } + if (ShellGetExecutionBreakFlag ()) { + Status = EFI_ABORTED; + break; + } Index++; } + return Status; } /** @@ -670,35 +825,76 @@ ProcessGlobal( For each record with a Token listed in the CumData array:
- Update the instance count and the total, minimum, and maximum durations. Finally, print the gathered cumulative statistics. - + + @param[in] CustomCumulativeData A pointer to the cumtom cumulative data. + **/ VOID ProcessCumulative( - VOID -) + IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL + ) { - UINT64 Avgval; // the computed average duration + UINT64 AvgDur; // the computed average duration + UINT64 Dur; + UINT64 MinDur; + UINT64 MaxDur; EFI_STRING StringPtr; UINTN TIndex; + EFI_STRING StringPtrUnknown; - + StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL); PrintToken( STRING_TOKEN (STR_DP_SECTION_HEADER), - (StringPtr == NULL) ? ALit_UNKNOWN: StringPtr); + (StringPtr == NULL) ? StringPtrUnknown: StringPtr); + FreePool (StringPtr); + FreePool (StringPtrUnknown); PrintToken (STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1)); PrintToken (STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2)); PrintToken (STRING_TOKEN (STR_DP_DASHES)); for ( TIndex = 0; TIndex < NumCum; ++TIndex) { - Avgval = DivU64x32 (CumData[TIndex].Duration, CumData[TIndex].Count); + 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); + + PrintToken (STRING_TOKEN (STR_DP_CUMULATIVE_STATS), + CumData[TIndex].Name, + CumData[TIndex].Count, + Dur, + AvgDur, + MinDur, + MaxDur + ); + } + } + + // + // 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; + } PrintToken (STRING_TOKEN (STR_DP_CUMULATIVE_STATS), - CumData[TIndex].Name, - CumData[TIndex].Count, - DurationInMicroSeconds(CumData[TIndex].Duration), - DurationInMicroSeconds(Avgval), - DurationInMicroSeconds(CumData[TIndex].MinDur), - DurationInMicroSeconds(CumData[TIndex].MaxDur) - ); + CustomCumulativeData->Name, + CustomCumulativeData->Count, + Dur, + AvgDur, + MinDur, + MaxDur + ); } }