2 Trace reporting for the Dp utility.
4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
5 (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
6 SPDX-License-Identifier: BSD-2-Clause-Patent
9 #include <Library/BaseLib.h>
10 #include <Library/BaseMemoryLib.h>
11 #include <Library/MemoryAllocationLib.h>
12 #include <Library/DebugLib.h>
13 #include <Library/UefiBootServicesTableLib.h>
14 #include <Library/PeCoffGetEntryPointLib.h>
15 #include <Library/PerformanceLib.h>
16 #include <Library/PrintLib.h>
17 #include <Library/HiiLib.h>
18 #include <Library/PcdLib.h>
22 #include "DpInternal.h"
25 Attempts to retrieve a performance measurement log entry from the performance measurement log.
28 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
29 0, then the first performance measurement log entry is retrieved.
30 On exit, the key of the next performance log entry.
31 @param Handle Pointer to environment specific context used to identify the component
33 @param Token Pointer to a Null-terminated ASCII string that identifies the component
35 @param Module Pointer to a Null-terminated ASCII string that identifies the module
37 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
39 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
41 @param Identifier Pointer to the 32-bit identifier that was recorded when the measurement
44 @return The key for the next performance log entry (in general case).
48 GetPerformanceMeasurementRecord (
50 OUT CONST VOID
**Handle
,
51 OUT CONST CHAR8
**Token
,
52 OUT CONST CHAR8
**Module
,
53 OUT UINT64
*StartTimeStamp
,
54 OUT UINT64
*EndTimeStamp
,
55 OUT UINT32
*Identifier
58 if (LogEntryKey
== mMeasurementNum
) {
62 *Handle
= (VOID
*)(UINTN
)mMeasurementList
[LogEntryKey
].Handle
;
63 *Token
= mMeasurementList
[LogEntryKey
].Token
;
64 *Module
= mMeasurementList
[LogEntryKey
].Module
;
65 *StartTimeStamp
= mMeasurementList
[LogEntryKey
].StartTimeStamp
;
66 *EndTimeStamp
= mMeasurementList
[LogEntryKey
].EndTimeStamp
;
67 *Identifier
= mMeasurementList
[LogEntryKey
].Identifier
;
75 Collect verbose statistics about the logged performance measurements.
77 General Summary information for all Trace measurements is gathered and
78 stored within the SummaryData structure. This information is both
79 used internally by subsequent reporting functions, and displayed
80 at the end of verbose reports.
82 @pre The SummaryData and CumData structures must be initialized
83 prior to calling this function.
85 @post The SummaryData and CumData structures contain statistics for the
86 current performance logs.
88 @param[in, out] CustomCumulativeData A pointer to the custom cumulative data.
93 IN OUT PERF_CUM_DATA
*CustomCumulativeData OPTIONAL
96 MEASUREMENT_RECORD Measurement
;
102 while ((LogEntryKey
= GetPerformanceMeasurementRecord (
107 &Measurement
.StartTimeStamp
,
108 &Measurement
.EndTimeStamp
,
109 &Measurement
.Identifier
112 ++SummaryData
.NumTrace
; // Count the number of TRACE Measurement records
113 if (Measurement
.EndTimeStamp
== 0) {
114 ++SummaryData
.NumIncomplete
; // Count the incomplete records
118 if (Measurement
.Handle
!= NULL
) {
119 ++SummaryData
.NumHandles
; // Count the number of measurements with non-NULL handles
122 if (IsPhase (&Measurement
)) {
123 ++SummaryData
.NumSummary
; // Count the number of major phases
126 if (Measurement
.Handle
== NULL
) {
127 ++SummaryData
.NumGlobal
;
131 if (AsciiStrCmp (Measurement
.Token
, ALit_PEIM
) == 0) {
132 ++SummaryData
.NumPEIMs
; // Count PEIM measurements
135 Duration
= GetDuration (&Measurement
);
136 TIndex
= GetCumulativeItem (&Measurement
);
138 CumData
[TIndex
].Duration
+= Duration
;
139 CumData
[TIndex
].Count
++;
140 if ( Duration
< CumData
[TIndex
].MinDur
) {
141 CumData
[TIndex
].MinDur
= Duration
;
144 if ( Duration
> CumData
[TIndex
].MaxDur
) {
145 CumData
[TIndex
].MaxDur
= Duration
;
150 // Collect the data for custom cumulative data.
152 if ((CustomCumulativeData
!= NULL
) && (AsciiStrCmp (Measurement
.Token
, CustomCumulativeData
->Name
) == 0)) {
153 CustomCumulativeData
->Duration
+= Duration
;
154 CustomCumulativeData
->Count
++;
155 if (Duration
< CustomCumulativeData
->MinDur
) {
156 CustomCumulativeData
->MinDur
= Duration
;
159 if (Duration
> CustomCumulativeData
->MaxDur
) {
160 CustomCumulativeData
->MaxDur
= Duration
;
167 Gather and print ALL Trace Records.
169 Displays all "interesting" Trace measurements in order.<BR>
170 The number of records displayed is controlled by:
171 - records with a duration less than mInterestThreshold microseconds are not displayed.
172 - No more than Limit records are displayed. A Limit of zero will not limit the output.
173 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
176 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
177 The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
178 They must not be in use by a calling function.
180 @param[in] Limit The number of records to print. Zero is ALL.
181 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
183 @retval EFI_SUCCESS The operation was successful.
184 @retval EFI_ABORTED The user aborts the operation.
185 @return Others from a call to gBS->LocateHandleBuffer().
190 IN BOOLEAN ExcludeFlag
193 MEASUREMENT_RECORD Measurement
;
202 EFI_HANDLE
*HandleBuffer
;
205 EFI_STRING StringPtrUnknown
;
207 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
208 IncFlag
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_ALL
), NULL
);
213 STRING_TOKEN (STR_DP_SECTION_HEADER
),
215 (IncFlag
== NULL
) ? StringPtrUnknown
: IncFlag
217 FreePool (StringPtrUnknown
);
219 // Get Handle information
221 Status
= gBS
->LocateHandleBuffer (AllHandles
, NULL
, NULL
, &HandleCount
, &HandleBuffer
);
222 if (EFI_ERROR (Status
)) {
223 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLES_ERROR
), mDpHiiHandle
, Status
);
225 // We have successfully populated the HandleBuffer
226 // Display ALL Measurement Records
227 // Up to Limit lines displayed
228 // Display only records with Elapsed times >= mInterestThreshold
229 // Display driver names in Module field for records with Handles.
232 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_HEADR2
), mDpHiiHandle
);
233 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_DASHES2
), mDpHiiHandle
);
235 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_HEADR
), mDpHiiHandle
);
236 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), mDpHiiHandle
);
242 while ( WITHIN_LIMIT (Count
, Limit
) &&
243 ((LogEntryKey
= GetPerformanceMeasurementRecord (
248 &Measurement
.StartTimeStamp
,
249 &Measurement
.EndTimeStamp
,
250 &Measurement
.Identifier
254 ++Index
; // Count every record. First record is 1.
256 SHELL_FREE_NON_NULL (IncFlag
);
257 if (Measurement
.EndTimeStamp
!= 0) {
258 Duration
= GetDuration (&Measurement
);
259 ElapsedTime
= DurationInMicroSeconds (Duration
);
260 IncFlag
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_COMPLETE
), NULL
);
262 IncFlag
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_INCOMPLETE
), NULL
); // Mark incomplete records
265 if (((Measurement
.EndTimeStamp
!= 0) && (ElapsedTime
< mInterestThreshold
)) ||
266 ((ExcludeFlag
) && (GetCumulativeItem (&Measurement
) >= 0))
267 ) // Ignore "uninteresting" or excluded records
272 ++Count
; // Count the number of records printed
274 // If Handle is non-zero, see if we can determine a name for the driver
275 AsciiStrToUnicodeStrS (Measurement
.Module
, mGaugeString
, ARRAY_SIZE (mGaugeString
)); // Use Module by default
276 AsciiStrToUnicodeStrS (Measurement
.Token
, mUnicodeToken
, ARRAY_SIZE (mUnicodeToken
));
277 if (Measurement
.Handle
!= NULL
) {
278 // See if the Handle is in the HandleBuffer
279 for (TIndex
= 0; TIndex
< HandleCount
; TIndex
++) {
280 if (Measurement
.Handle
== HandleBuffer
[TIndex
]) {
281 DpGetNameFromHandle (HandleBuffer
[TIndex
]);
287 if (AsciiStrCmp (Measurement
.Token
, ALit_PEIM
) == 0) {
288 UnicodeSPrint (mGaugeString
, sizeof (mGaugeString
), L
"%g", Measurement
.Handle
);
291 // Ensure that the argument strings are not too long.
292 mGaugeString
[DP_GAUGE_STRING_LENGTH
] = 0;
293 mUnicodeToken
[13] = 0;
300 STRING_TOKEN (STR_DP_ALL_VARS2
),
302 Index
, // 1 based, Which measurement record is being printed
308 Measurement
.Identifier
315 STRING_TOKEN (STR_DP_ALL_VARS
),
317 Index
, // 1 based, Which measurement record is being printed
326 if (ShellGetExecutionBreakFlag ()) {
327 Status
= EFI_ABORTED
;
333 if (HandleBuffer
!= NULL
) {
334 FreePool (HandleBuffer
);
337 SHELL_FREE_NON_NULL (IncFlag
);
343 Gather and print Raw Trace Records.
345 All Trace measurements with a duration greater than or equal to
346 mInterestThreshold are printed without interpretation.
348 The number of records displayed is controlled by:
349 - records with a duration less than mInterestThreshold microseconds are not displayed.
350 - No more than Limit records are displayed. A Limit of zero will not limit the output.
351 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
354 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
356 @param[in] Limit The number of records to print. Zero is ALL.
357 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
359 @retval EFI_SUCCESS The operation was successful.
360 @retval EFI_ABORTED The user aborts the operation.
365 IN BOOLEAN ExcludeFlag
368 MEASUREMENT_RECORD Measurement
;
375 EFI_STRING StringPtr
;
376 EFI_STRING StringPtrUnknown
;
379 Status
= EFI_SUCCESS
;
381 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
382 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_RAWTRACE
), NULL
);
387 STRING_TOKEN (STR_DP_SECTION_HEADER
),
389 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
391 FreePool (StringPtr
);
392 FreePool (StringPtrUnknown
);
395 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_HEADR2
), mDpHiiHandle
);
396 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_DASHES2
), mDpHiiHandle
);
398 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_HEADR
), mDpHiiHandle
);
399 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_DASHES
), mDpHiiHandle
);
405 while ( WITHIN_LIMIT (Count
, Limit
) &&
406 ((LogEntryKey
= GetPerformanceMeasurementRecord (
411 &Measurement
.StartTimeStamp
,
412 &Measurement
.EndTimeStamp
,
413 &Measurement
.Identifier
417 ++Index
; // Count every record. First record is 1.
419 if (Measurement
.EndTimeStamp
!= 0) {
420 Duration
= GetDuration (&Measurement
);
421 ElapsedTime
= DurationInMicroSeconds (Duration
);
424 if ((ElapsedTime
< mInterestThreshold
) ||
425 ((ExcludeFlag
) && (GetCumulativeItem (&Measurement
) >= 0))
426 ) // Ignore "uninteresting" or Excluded records
431 ++Count
; // Count the number of records printed
438 STRING_TOKEN (STR_DP_RAW_VARS2
),
440 Index
, // 1 based, Which measurement record is being printed
442 Measurement
.StartTimeStamp
,
443 Measurement
.EndTimeStamp
,
446 Measurement
.Identifier
453 STRING_TOKEN (STR_DP_RAW_VARS
),
455 Index
, // 1 based, Which measurement record is being printed
457 Measurement
.StartTimeStamp
,
458 Measurement
.EndTimeStamp
,
464 if (ShellGetExecutionBreakFlag ()) {
465 Status
= EFI_ABORTED
;
474 Gather and print Major Phase metrics.
482 MEASUREMENT_RECORD Measurement
;
483 UINT64 BdsTimeoutValue
;
491 EFI_STRING StringPtr
;
493 EFI_STRING StringPtrUnknown
;
501 // Get Execution Phase Statistics
503 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
504 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PHASES
), NULL
);
509 STRING_TOKEN (STR_DP_SECTION_HEADER
),
511 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
513 FreePool (StringPtr
);
514 FreePool (StringPtrUnknown
);
517 while ((LogEntryKey
= GetPerformanceMeasurementRecord (
522 &Measurement
.StartTimeStamp
,
523 &Measurement
.EndTimeStamp
,
524 &Measurement
.Identifier
527 if (Measurement
.EndTimeStamp
== 0) {
528 // Skip "incomplete" records
532 Duration
= GetDuration (&Measurement
);
533 if ( (Measurement
.Handle
!= NULL
)
534 && (AsciiStrCmp (Measurement
.Token
, ALit_BdsTO
) == 0)
537 BdsTimeoutValue
= Duration
;
538 } else if (AsciiStrCmp (Measurement
.Token
, ALit_SEC
) == 0) {
540 } else if (AsciiStrCmp (Measurement
.Token
, ALit_PEI
) == 0) {
542 } else if (AsciiStrCmp (Measurement
.Token
, ALit_DXE
) == 0) {
544 } else if (AsciiStrCmp (Measurement
.Token
, ALit_BDS
) == 0) {
551 // print Reset End if it's valid
553 if (SecTime
> mResetEnd
) {
554 SecTime
= SecTime
- mResetEnd
; // Calculate sec time duration start from the beginning of firmware image execution
555 ElapsedTime
= DurationInMicroSeconds (mResetEnd
); // Calculate elapsed time in microseconds
556 Total
+= DivU64x32 (ElapsedTime
, 1000); // Accumulate time in milliseconds
557 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RESET_END
), mDpHiiHandle
, ElapsedTime
);
560 // print SEC phase duration time
563 ElapsedTime
= DurationInMicroSeconds (SecTime
); // Calculate elapsed time in microseconds
564 Total
+= DivU64x32 (ElapsedTime
, 1000); // Accumulate time in milliseconds
565 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SEC_PHASE
), mDpHiiHandle
, ElapsedTime
);
568 // print PEI phase duration time
571 ElapsedTime
= DivU64x32 (PeiTime
, 1000000);
572 Total
+= ElapsedTime
;
573 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), mDpHiiHandle
, ALit_PEI
, ElapsedTime
);
576 // print DXE phase duration time
579 ElapsedTime
= DivU64x32 (DxeTime
, 1000000);
580 Total
+= ElapsedTime
;
581 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), mDpHiiHandle
, ALit_DXE
, ElapsedTime
);
584 // print BDS phase duration time
587 ElapsedTime
= DivU64x32 (BdsTime
, 1000000);
588 Total
+= ElapsedTime
;
589 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), mDpHiiHandle
, ALit_BDS
, ElapsedTime
);
592 if (BdsTimeoutValue
> 0) {
593 ElapsedTime
= DivU64x32 (BdsTimeoutValue
, 1000000);
594 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_BDSTO
), mDpHiiHandle
, ALit_BdsTO
, ElapsedTime
);
597 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_TOTAL_DURATION
), mDpHiiHandle
, Total
);
601 Gather and print Handle data.
603 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
605 @retval EFI_SUCCESS The operation was successful.
606 @retval EFI_ABORTED The user aborts the operation.
607 @return Others from a call to gBS->LocateHandleBuffer().
611 IN BOOLEAN ExcludeFlag
614 MEASUREMENT_RECORD Measurement
;
617 EFI_HANDLE
*HandleBuffer
;
618 EFI_STRING StringPtr
;
624 EFI_STRING StringPtrUnknown
;
626 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
627 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_DRIVERS
), NULL
);
632 STRING_TOKEN (STR_DP_SECTION_HEADER
),
634 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
636 FreePool (StringPtr
);
637 FreePool (StringPtrUnknown
);
639 Status
= gBS
->LocateHandleBuffer (AllHandles
, NULL
, NULL
, &HandleCount
, &HandleBuffer
);
640 if (EFI_ERROR (Status
)) {
641 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLES_ERROR
), mDpHiiHandle
, Status
);
644 Print (L
"There are %,d Handles defined.\n", (Size
/ sizeof (HandleBuffer
[0])));
648 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_SECTION2
), mDpHiiHandle
);
650 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_SECTION
), mDpHiiHandle
);
653 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), mDpHiiHandle
);
657 while ((LogEntryKey
= GetPerformanceMeasurementRecord (
662 &Measurement
.StartTimeStamp
,
663 &Measurement
.EndTimeStamp
,
664 &Measurement
.Identifier
668 Duration
= GetDuration (&Measurement
);
669 ElapsedTime
= DurationInMicroSeconds (Duration
);
670 if ((ElapsedTime
< mInterestThreshold
) ||
671 (Measurement
.EndTimeStamp
== 0) ||
672 (!IsCorePerf (&Measurement
)) ||
673 ((ExcludeFlag
) && (GetCumulativeItem (&Measurement
) >= 0))
674 ) // Ignore "uninteresting" or excluded records
679 mGaugeString
[0] = 0; // Empty driver name by default
680 AsciiStrToUnicodeStrS (Measurement
.Token
, mUnicodeToken
, ARRAY_SIZE (mUnicodeToken
));
681 // See if the Handle is in the HandleBuffer
682 for (Index
= 0; Index
< HandleCount
; Index
++) {
683 if (Measurement
.Handle
== HandleBuffer
[Index
]) {
684 DpGetNameFromHandle (HandleBuffer
[Index
]); // Name is put into mGaugeString
689 // Ensure that the argument strings are not too long.
690 mGaugeString
[DP_GAUGE_STRING_LENGTH
] = 0;
691 mUnicodeToken
[11] = 0;
692 if (mGaugeString
[0] != 0) {
693 // Display the record if it has a valid handle.
699 STRING_TOKEN (STR_DP_HANDLE_VARS2
),
701 Count
, // 1 based, Which measurement record is being printed
702 Index
+ 1, // 1 based, Which handle is being printed
706 Measurement
.Identifier
713 STRING_TOKEN (STR_DP_HANDLE_VARS
),
715 Count
, // 1 based, Which measurement record is being printed
716 Index
+ 1, // 1 based, Which handle is being printed
724 if (ShellGetExecutionBreakFlag ()) {
725 Status
= EFI_ABORTED
;
731 if (HandleBuffer
!= NULL
) {
732 FreePool (HandleBuffer
);
739 Gather and print PEIM data.
741 Only prints complete PEIM records
743 @retval EFI_SUCCESS The operation was successful.
744 @retval EFI_ABORTED The user aborts the operation.
751 MEASUREMENT_RECORD Measurement
;
754 EFI_STRING StringPtr
;
757 EFI_STRING StringPtrUnknown
;
760 Status
= EFI_SUCCESS
;
762 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
763 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PEIMS
), NULL
);
768 STRING_TOKEN (STR_DP_SECTION_HEADER
),
770 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
772 FreePool (StringPtr
);
773 FreePool (StringPtrUnknown
);
776 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_SECTION2
), mDpHiiHandle
);
778 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_SECTION
), mDpHiiHandle
);
781 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), mDpHiiHandle
);
784 while ((LogEntryKey
= GetPerformanceMeasurementRecord (
789 &Measurement
.StartTimeStamp
,
790 &Measurement
.EndTimeStamp
,
791 &Measurement
.Identifier
795 if ((Measurement
.EndTimeStamp
== 0) ||
796 (AsciiStrCmp (Measurement
.Token
, ALit_PEIM
) != 0)
802 Duration
= GetDuration (&Measurement
);
803 ElapsedTime
= DurationInMicroSeconds (Duration
); // Calculate elapsed time in microseconds
804 if (ElapsedTime
>= mInterestThreshold
) {
805 // PEIM FILE Handle is the start address of its FFS file that contains its file guid.
811 STRING_TOKEN (STR_DP_PEIM_VARS2
),
813 TIndex
, // 1 based, Which measurement record is being printed
814 Measurement
.Handle
, // file guid
816 Measurement
.Identifier
823 STRING_TOKEN (STR_DP_PEIM_VARS
),
825 TIndex
, // 1 based, Which measurement record is being printed
826 Measurement
.Handle
, // file guid
832 if (ShellGetExecutionBreakFlag ()) {
833 Status
= EFI_ABORTED
;
842 Gather and print global data.
844 Strips out incomplete or "Execution Phase" records
845 Only prints records where Handle is NULL
846 Increment TIndex for every record, even skipped ones, so that we have an
847 indication of every measurement record taken.
849 @retval EFI_SUCCESS The operation was successful.
850 @retval EFI_ABORTED The user aborts the operation.
857 MEASUREMENT_RECORD Measurement
;
860 EFI_STRING StringPtr
;
862 UINTN Index
; // Index, or number, of the measurement record being processed
863 EFI_STRING StringPtrUnknown
;
866 Status
= EFI_SUCCESS
;
868 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
869 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_GENERAL
), NULL
);
874 STRING_TOKEN (STR_DP_SECTION_HEADER
),
876 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
878 FreePool (StringPtr
);
879 FreePool (StringPtrUnknown
);
882 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_SECTION2
), mDpHiiHandle
);
884 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_SECTION
), mDpHiiHandle
);
887 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), mDpHiiHandle
);
892 while ((LogEntryKey
= GetPerformanceMeasurementRecord (
897 &Measurement
.StartTimeStamp
,
898 &Measurement
.EndTimeStamp
,
899 &Measurement
.Identifier
902 AsciiStrToUnicodeStrS (Measurement
.Module
, mGaugeString
, ARRAY_SIZE (mGaugeString
));
903 AsciiStrToUnicodeStrS (Measurement
.Token
, mUnicodeToken
, ARRAY_SIZE (mUnicodeToken
));
904 mGaugeString
[25] = 0;
905 mUnicodeToken
[31] = 0;
906 if ( !(IsPhase (&Measurement
) ||
907 IsCorePerf (&Measurement
) ||
908 (Measurement
.EndTimeStamp
== 0)
911 Duration
= GetDuration (&Measurement
);
912 ElapsedTime
= DurationInMicroSeconds (Duration
);
913 if (ElapsedTime
>= mInterestThreshold
) {
919 STRING_TOKEN (STR_DP_GLOBAL_VARS2
),
925 Measurement
.Identifier
932 STRING_TOKEN (STR_DP_GLOBAL_VARS
),
943 if (ShellGetExecutionBreakFlag ()) {
944 Status
= EFI_ABORTED
;
955 Gather and print cumulative data.
957 Traverse the measurement records and:<BR>
958 For each record with a Token listed in the CumData array:<BR>
959 - Update the instance count and the total, minimum, and maximum durations.
960 Finally, print the gathered cumulative statistics.
962 @param[in] CustomCumulativeData A pointer to the custom cumulative data.
967 IN PERF_CUM_DATA
*CustomCumulativeData OPTIONAL
970 UINT64 AvgDur
; // the computed average duration
974 EFI_STRING StringPtr
;
976 EFI_STRING StringPtrUnknown
;
978 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
979 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE
), NULL
);
984 STRING_TOKEN (STR_DP_SECTION_HEADER
),
986 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
988 FreePool (StringPtr
);
989 FreePool (StringPtrUnknown
);
991 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1
), mDpHiiHandle
);
992 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2
), mDpHiiHandle
);
993 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), mDpHiiHandle
);
995 for ( TIndex
= 0; TIndex
< NumCum
; ++TIndex
) {
996 if (CumData
[TIndex
].Count
!= 0) {
997 AvgDur
= DivU64x32 (CumData
[TIndex
].Duration
, CumData
[TIndex
].Count
);
998 AvgDur
= DurationInMicroSeconds (AvgDur
);
999 Dur
= DurationInMicroSeconds (CumData
[TIndex
].Duration
);
1000 MaxDur
= DurationInMicroSeconds (CumData
[TIndex
].MaxDur
);
1001 MinDur
= DurationInMicroSeconds (CumData
[TIndex
].MinDur
);
1007 STRING_TOKEN (STR_DP_CUMULATIVE_STATS
),
1009 CumData
[TIndex
].Name
,
1010 CumData
[TIndex
].Count
,
1020 // Print the custom cumulative data.
1022 if (CustomCumulativeData
!= NULL
) {
1023 if (CustomCumulativeData
->Count
!= 0) {
1024 AvgDur
= DivU64x32 (CustomCumulativeData
->Duration
, CustomCumulativeData
->Count
);
1025 AvgDur
= DurationInMicroSeconds (AvgDur
);
1026 Dur
= DurationInMicroSeconds (CustomCumulativeData
->Duration
);
1027 MaxDur
= DurationInMicroSeconds (CustomCumulativeData
->MaxDur
);
1028 MinDur
= DurationInMicroSeconds (CustomCumulativeData
->MinDur
);
1040 STRING_TOKEN (STR_DP_CUMULATIVE_STATS
),
1042 CustomCumulativeData
->Name
,
1043 CustomCumulativeData
->Count
,