2 Trace reporting for the Dp utility.
4 Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
5 (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #include <Library/BaseLib.h>
16 #include <Library/BaseMemoryLib.h>
17 #include <Library/MemoryAllocationLib.h>
18 #include <Library/DebugLib.h>
19 #include <Library/UefiBootServicesTableLib.h>
20 #include <Library/TimerLib.h>
21 #include <Library/PeCoffGetEntryPointLib.h>
22 #include <Library/PerformanceLib.h>
23 #include <Library/PrintLib.h>
24 #include <Library/HiiLib.h>
25 #include <Library/PcdLib.h>
27 #include <Guid/Performance.h>
31 #include "DpInternal.h"
34 Collect verbose statistics about the logged performance measurements.
36 General Summary information for all Trace measurements is gathered and
37 stored within the SummaryData structure. This information is both
38 used internally by subsequent reporting functions, and displayed
39 at the end of verbose reports.
41 @pre The SummaryData and CumData structures must be initialized
42 prior to calling this function.
44 @post The SummaryData and CumData structures contain statistics for the
45 current performance logs.
47 @param[in, out] CustomCumulativeData A pointer to the cumtom cumulative data.
52 IN OUT PERF_CUM_DATA
*CustomCumulativeData OPTIONAL
55 MEASUREMENT_RECORD Measurement
;
61 while ((LogEntryKey
= GetPerformanceMeasurementEx (
66 &Measurement
.StartTimeStamp
,
67 &Measurement
.EndTimeStamp
,
68 &Measurement
.Identifier
)) != 0)
70 ++SummaryData
.NumTrace
; // Count the number of TRACE Measurement records
71 if (Measurement
.EndTimeStamp
== 0) {
72 ++SummaryData
.NumIncomplete
; // Count the incomplete records
76 if (Measurement
.Handle
!= NULL
) {
77 ++SummaryData
.NumHandles
; // Count the number of measurements with non-NULL handles
80 if (IsPhase( &Measurement
)) {
81 ++SummaryData
.NumSummary
; // Count the number of major phases
83 else { // !IsPhase(...
84 if(Measurement
.Handle
== NULL
) {
85 ++SummaryData
.NumGlobal
;
89 if (AsciiStrnCmp (Measurement
.Token
, ALit_PEIM
, PERF_TOKEN_LENGTH
) == 0) {
90 ++SummaryData
.NumPEIMs
; // Count PEIM measurements
93 Duration
= GetDuration (&Measurement
);
94 TIndex
= GetCumulativeItem (&Measurement
);
96 CumData
[TIndex
].Duration
+= Duration
;
97 CumData
[TIndex
].Count
++;
98 if ( Duration
< CumData
[TIndex
].MinDur
) {
99 CumData
[TIndex
].MinDur
= Duration
;
101 if ( Duration
> CumData
[TIndex
].MaxDur
) {
102 CumData
[TIndex
].MaxDur
= Duration
;
107 // Collect the data for custom cumulative data.
109 if ((CustomCumulativeData
!= NULL
) && (AsciiStrCmp (Measurement
.Token
, CustomCumulativeData
->Name
) == 0)) {
110 CustomCumulativeData
->Duration
+= Duration
;
111 CustomCumulativeData
->Count
++;
112 if (Duration
< CustomCumulativeData
->MinDur
) {
113 CustomCumulativeData
->MinDur
= Duration
;
115 if (Duration
> CustomCumulativeData
->MaxDur
) {
116 CustomCumulativeData
->MaxDur
= Duration
;
123 Gather and print ALL Trace Records.
125 Displays all "interesting" Trace measurements in order.<BR>
126 The number of records displayed is controlled by:
127 - records with a duration less than mInterestThreshold microseconds are not displayed.
128 - No more than Limit records are displayed. A Limit of zero will not limit the output.
129 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
132 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
133 The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
134 They must not be in use by a calling function.
136 @param[in] Limit The number of records to print. Zero is ALL.
137 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
143 IN BOOLEAN ExcludeFlag
146 MEASUREMENT_RECORD Measurement
;
155 EFI_HANDLE
*HandleBuffer
;
157 EFI_HANDLE TempHandle
;
159 EFI_STRING StringPtrUnknown
;
161 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
162 IncFlag
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_ALL
), NULL
);
163 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
164 (IncFlag
== NULL
) ? StringPtrUnknown
: IncFlag
);
165 FreePool (StringPtrUnknown
);
167 // Get Handle information
170 HandleBuffer
= &TempHandle
;
171 Status
= gBS
->LocateHandle (AllHandles
, NULL
, NULL
, &Size
, &TempHandle
);
172 if (Status
== EFI_BUFFER_TOO_SMALL
) {
173 HandleBuffer
= AllocatePool (Size
);
174 ASSERT (HandleBuffer
!= NULL
);
175 if (HandleBuffer
== NULL
) {
178 Status
= gBS
->LocateHandle (AllHandles
, NULL
, NULL
, &Size
, HandleBuffer
);
180 if (EFI_ERROR (Status
)) {
181 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLES_ERROR
), gDpHiiHandle
, Status
);
184 // We have successfully populated the HandleBuffer
185 // Display ALL Measurement Records
186 // Up to Limit lines displayed
187 // Display only records with Elapsed times >= mInterestThreshold
188 // Display driver names in Module field for records with Handles.
191 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_HEADR2
), gDpHiiHandle
);
192 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_DASHES2
), gDpHiiHandle
);
194 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_HEADR
), gDpHiiHandle
);
195 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
201 while ( WITHIN_LIMIT(Count
, Limit
) &&
202 ((LogEntryKey
= GetPerformanceMeasurementEx (
207 &Measurement
.StartTimeStamp
,
208 &Measurement
.EndTimeStamp
,
209 &Measurement
.Identifier
)) != 0)
212 ++Index
; // Count every record. First record is 1.
214 SHELL_FREE_NON_NULL (IncFlag
);
215 if (Measurement
.EndTimeStamp
!= 0) {
216 Duration
= GetDuration (&Measurement
);
217 ElapsedTime
= DurationInMicroSeconds ( Duration
);
218 IncFlag
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_COMPLETE
), NULL
);
221 IncFlag
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_INCOMPLETE
), NULL
); // Mark incomplete records
223 if (((Measurement
.EndTimeStamp
!= 0) && (ElapsedTime
< mInterestThreshold
)) ||
224 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
225 ) { // Ignore "uninteresting" or excluded records
228 ++Count
; // Count the number of records printed
230 // If Handle is non-zero, see if we can determine a name for the driver
231 AsciiStrToUnicodeStr (Measurement
.Module
, mGaugeString
); // Use Module by default
232 AsciiStrToUnicodeStr (Measurement
.Token
, mUnicodeToken
);
233 if (Measurement
.Handle
!= NULL
) {
234 // See if the Handle is in the HandleBuffer
235 for (TIndex
= 0; TIndex
< (Size
/ sizeof(HandleBuffer
[0])); TIndex
++) {
236 if (Measurement
.Handle
== HandleBuffer
[TIndex
]) {
237 DpGetNameFromHandle (HandleBuffer
[TIndex
]);
243 if (AsciiStrnCmp (Measurement
.Token
, ALit_PEIM
, PERF_TOKEN_LENGTH
) == 0) {
244 UnicodeSPrint (mGaugeString
, sizeof (mGaugeString
), L
"%g", Measurement
.Handle
);
247 // Ensure that the argument strings are not too long.
248 mGaugeString
[DP_GAUGE_STRING_LENGTH
] = 0;
249 mUnicodeToken
[13] = 0;
252 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_VARS2
), gDpHiiHandle
,
253 Index
, // 1 based, Which measurement record is being printed
259 Measurement
.Identifier
262 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_VARS
), gDpHiiHandle
,
263 Index
, // 1 based, Which measurement record is being printed
273 if (HandleBuffer
!= &TempHandle
) {
274 FreePool (HandleBuffer
);
276 SHELL_FREE_NON_NULL (IncFlag
);
280 Gather and print Raw Trace Records.
282 All Trace measurements with a duration greater than or equal to
283 mInterestThreshold are printed without interpretation.
285 The number of records displayed is controlled by:
286 - records with a duration less than mInterestThreshold microseconds are not displayed.
287 - No more than Limit records are displayed. A Limit of zero will not limit the output.
288 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
291 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
293 @param[in] Limit The number of records to print. Zero is ALL.
294 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
300 IN BOOLEAN ExcludeFlag
303 MEASUREMENT_RECORD Measurement
;
310 EFI_STRING StringPtr
;
311 EFI_STRING StringPtrUnknown
;
313 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
314 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_RAWTRACE
), NULL
);
315 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
316 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
317 FreePool (StringPtr
);
318 FreePool (StringPtrUnknown
);
321 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_HEADR2
), gDpHiiHandle
);
322 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_DASHES2
), gDpHiiHandle
);
324 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_HEADR
), gDpHiiHandle
);
325 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_DASHES
), gDpHiiHandle
);
331 while ( WITHIN_LIMIT(Count
, Limit
) &&
332 ((LogEntryKey
= GetPerformanceMeasurementEx (
337 &Measurement
.StartTimeStamp
,
338 &Measurement
.EndTimeStamp
,
339 &Measurement
.Identifier
)) != 0)
342 ++Index
; // Count every record. First record is 1.
344 if (Measurement
.EndTimeStamp
!= 0) {
345 Duration
= GetDuration (&Measurement
);
346 ElapsedTime
= DurationInMicroSeconds ( Duration
);
348 if ((ElapsedTime
< mInterestThreshold
) ||
349 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
350 ) { // Ignore "uninteresting" or Excluded records
353 ++Count
; // Count the number of records printed
356 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_VARS2
), gDpHiiHandle
,
357 Index
, // 1 based, Which measurement record is being printed
359 Measurement
.StartTimeStamp
,
360 Measurement
.EndTimeStamp
,
363 Measurement
.Identifier
366 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_VARS
), gDpHiiHandle
,
367 Index
, // 1 based, Which measurement record is being printed
369 Measurement
.StartTimeStamp
,
370 Measurement
.EndTimeStamp
,
379 Gather and print Major Phase metrics.
381 @param[in] Ticker The timer value for the END of Shell phase
389 MEASUREMENT_RECORD Measurement
;
390 UINT64 BdsTimeoutValue
;
399 EFI_STRING StringPtr
;
401 EFI_STRING StringPtrUnknown
;
410 // Get Execution Phase Statistics
412 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
413 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PHASES
), NULL
);
414 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
415 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
416 FreePool (StringPtr
);
417 FreePool (StringPtrUnknown
);
420 while ((LogEntryKey
= GetPerformanceMeasurementEx (
425 &Measurement
.StartTimeStamp
,
426 &Measurement
.EndTimeStamp
,
427 &Measurement
.Identifier
)) != 0)
429 if (AsciiStrnCmp (Measurement
.Token
, ALit_SHELL
, PERF_TOKEN_LENGTH
) == 0) {
430 Measurement
.EndTimeStamp
= Ticker
;
432 if (Measurement
.EndTimeStamp
== 0) { // Skip "incomplete" records
435 Duration
= GetDuration (&Measurement
);
436 if ( Measurement
.Handle
!= NULL
437 && (AsciiStrnCmp (Measurement
.Token
, ALit_BdsTO
, PERF_TOKEN_LENGTH
) == 0)
440 BdsTimeoutValue
= Duration
;
441 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_SEC
, PERF_TOKEN_LENGTH
) == 0) {
443 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_PEI
, PERF_TOKEN_LENGTH
) == 0) {
445 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_DXE
, PERF_TOKEN_LENGTH
) == 0) {
447 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_BDS
, PERF_TOKEN_LENGTH
) == 0) {
449 } else if (AsciiStrnCmp (Measurement
.Token
, ALit_SHELL
, PERF_TOKEN_LENGTH
) == 0) {
450 ShellTime
= Duration
;
456 // print SEC phase duration time
459 ElapsedTime
= DurationInMicroSeconds ( SecTime
); // Calculate elapsed time in microseconds
460 Total
+= DivU64x32 (ElapsedTime
, 1000); // Accumulate time in milliseconds
461 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SEC_PHASE
), gDpHiiHandle
, ElapsedTime
);
464 // print PEI phase duration time
467 ElapsedTime
= DivU64x32 (
469 (UINT32
)TimerInfo
.Frequency
471 Total
+= ElapsedTime
;
472 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_PEI
, ElapsedTime
);
475 // print DXE phase duration time
478 ElapsedTime
= DivU64x32 (
480 (UINT32
)TimerInfo
.Frequency
482 Total
+= ElapsedTime
;
483 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_DXE
, ElapsedTime
);
486 // print BDS phase duration time
489 ElapsedTime
= DivU64x32 (
491 (UINT32
)TimerInfo
.Frequency
493 Total
+= ElapsedTime
;
494 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_BDS
, ElapsedTime
);
497 if (BdsTimeoutValue
> 0) {
498 ElapsedTime
= DivU64x32 (
500 (UINT32
)TimerInfo
.Frequency
502 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_BDSTO
), gDpHiiHandle
, ALit_BdsTO
, ElapsedTime
);
505 // print SHELL phase duration time
508 ElapsedTime
= DivU64x32 (
510 (UINT32
)TimerInfo
.Frequency
512 Total
+= ElapsedTime
;
513 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), gDpHiiHandle
, ALit_SHELL
, ElapsedTime
);
516 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_TOTAL_DURATION
), gDpHiiHandle
, Total
);
520 Gather and print Handle data.
522 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
524 @return Status from a call to gBS->LocateHandle().
528 IN BOOLEAN ExcludeFlag
531 MEASUREMENT_RECORD Measurement
;
534 EFI_HANDLE
*HandleBuffer
;
535 EFI_STRING StringPtr
;
540 EFI_HANDLE TempHandle
;
542 EFI_STRING StringPtrUnknown
;
544 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
545 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_DRIVERS
), NULL
);
546 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
547 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
548 FreePool (StringPtr
);
549 FreePool (StringPtrUnknown
);
552 HandleBuffer
= &TempHandle
;
553 Status
= gBS
->LocateHandle (AllHandles
, NULL
, NULL
, &Size
, &TempHandle
);
554 if (Status
== EFI_BUFFER_TOO_SMALL
) {
555 HandleBuffer
= AllocatePool (Size
);
556 ASSERT (HandleBuffer
!= NULL
);
557 if (HandleBuffer
== NULL
) {
560 Status
= gBS
->LocateHandle (AllHandles
, NULL
, NULL
, &Size
, HandleBuffer
);
562 if (EFI_ERROR (Status
)) {
563 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLES_ERROR
), gDpHiiHandle
, Status
);
567 Print (L
"There are %,d Handles defined.\n", (Size
/ sizeof(HandleBuffer
[0])));
571 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_SECTION2
), gDpHiiHandle
);
573 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_SECTION
), gDpHiiHandle
);
575 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
579 while ((LogEntryKey
= GetPerformanceMeasurementEx (
584 &Measurement
.StartTimeStamp
,
585 &Measurement
.EndTimeStamp
,
586 &Measurement
.Identifier
)) != 0)
589 Duration
= GetDuration (&Measurement
);
590 ElapsedTime
= DurationInMicroSeconds ( Duration
);
591 if ((ElapsedTime
< mInterestThreshold
) ||
592 (Measurement
.EndTimeStamp
== 0) ||
593 (Measurement
.Handle
== NULL
) ||
594 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
595 ) { // Ignore "uninteresting" or excluded records
598 mGaugeString
[0] = 0; // Empty driver name by default
599 AsciiStrToUnicodeStr (Measurement
.Token
, mUnicodeToken
);
600 // See if the Handle is in the HandleBuffer
601 for (Index
= 0; Index
< (Size
/ sizeof(HandleBuffer
[0])); Index
++) {
602 if (Measurement
.Handle
== HandleBuffer
[Index
]) {
603 DpGetNameFromHandle (HandleBuffer
[Index
]); // Name is put into mGaugeString
607 // Ensure that the argument strings are not too long.
608 mGaugeString
[DP_GAUGE_STRING_LENGTH
] = 0;
609 mUnicodeToken
[11] = 0;
610 if (mGaugeString
[0] != 0) {
611 // Display the record if it has a valid handle.
613 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_VARS2
), gDpHiiHandle
,
614 Count
, // 1 based, Which measurement record is being printed
615 Index
+ 1, // 1 based, Which handle is being printed
619 Measurement
.Identifier
622 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_VARS
), gDpHiiHandle
,
623 Count
, // 1 based, Which measurement record is being printed
624 Index
+ 1, // 1 based, Which handle is being printed
633 if (HandleBuffer
!= &TempHandle
) {
634 FreePool (HandleBuffer
);
640 Gather and print PEIM data.
642 Only prints complete PEIM records
650 MEASUREMENT_RECORD Measurement
;
653 EFI_STRING StringPtr
;
656 EFI_STRING StringPtrUnknown
;
658 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
659 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PEIMS
), NULL
);
660 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
661 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
662 FreePool (StringPtr
);
663 FreePool (StringPtrUnknown
);
666 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_SECTION2
), gDpHiiHandle
);
668 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_SECTION
), gDpHiiHandle
);
670 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
673 while ((LogEntryKey
= GetPerformanceMeasurementEx (
678 &Measurement
.StartTimeStamp
,
679 &Measurement
.EndTimeStamp
,
680 &Measurement
.Identifier
)) != 0)
683 if ((Measurement
.EndTimeStamp
== 0) ||
684 (AsciiStrnCmp (Measurement
.Token
, ALit_PEIM
, PERF_TOKEN_LENGTH
) != 0)
689 Duration
= GetDuration (&Measurement
);
690 ElapsedTime
= DurationInMicroSeconds ( Duration
); // Calculate elapsed time in microseconds
691 if (ElapsedTime
>= mInterestThreshold
) {
692 // PEIM FILE Handle is the start address of its FFS file that contains its file guid.
694 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_VARS2
), gDpHiiHandle
,
695 TIndex
, // 1 based, Which measurement record is being printed
696 Measurement
.Handle
, // base address
697 Measurement
.Handle
, // file guid
699 Measurement
.Identifier
702 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_VARS
), gDpHiiHandle
,
703 TIndex
, // 1 based, Which measurement record is being printed
704 Measurement
.Handle
, // base address
705 Measurement
.Handle
, // file guid
714 Gather and print global data.
716 Strips out incomplete or "Execution Phase" records
717 Only prints records where Handle is NULL
718 Increment TIndex for every record, even skipped ones, so that we have an
719 indication of every measurement record taken.
727 MEASUREMENT_RECORD Measurement
;
730 EFI_STRING StringPtr
;
732 UINTN Index
; // Index, or number, of the measurement record being processed
733 EFI_STRING StringPtrUnknown
;
735 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
736 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_GENERAL
), NULL
);
737 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
738 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
739 FreePool (StringPtr
);
740 FreePool (StringPtrUnknown
);
743 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_SECTION2
), gDpHiiHandle
);
745 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_SECTION
), gDpHiiHandle
);
747 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
752 while ((LogEntryKey
= GetPerformanceMeasurementEx (
757 &Measurement
.StartTimeStamp
,
758 &Measurement
.EndTimeStamp
,
759 &Measurement
.Identifier
)) != 0)
761 AsciiStrToUnicodeStr (Measurement
.Module
, mGaugeString
);
762 AsciiStrToUnicodeStr (Measurement
.Token
, mUnicodeToken
);
763 mGaugeString
[25] = 0;
764 mUnicodeToken
[31] = 0;
765 if ( ! ( IsPhase( &Measurement
) ||
766 (Measurement
.Handle
!= NULL
) ||
767 (Measurement
.EndTimeStamp
== 0)
770 Duration
= GetDuration (&Measurement
);
771 ElapsedTime
= DurationInMicroSeconds ( Duration
);
772 if (ElapsedTime
>= mInterestThreshold
) {
774 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_VARS2
), gDpHiiHandle
,
779 Measurement
.Identifier
782 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_VARS
), gDpHiiHandle
,
796 Gather and print cumulative data.
798 Traverse the measurement records and:<BR>
799 For each record with a Token listed in the CumData array:<BR>
800 - Update the instance count and the total, minimum, and maximum durations.
801 Finally, print the gathered cumulative statistics.
803 @param[in] CustomCumulativeData A pointer to the cumtom cumulative data.
808 IN PERF_CUM_DATA
*CustomCumulativeData OPTIONAL
811 UINT64 AvgDur
; // the computed average duration
815 EFI_STRING StringPtr
;
817 EFI_STRING StringPtrUnknown
;
819 StringPtrUnknown
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
820 StringPtr
= HiiGetString (gDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE
), NULL
);
821 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), gDpHiiHandle
,
822 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
823 FreePool (StringPtr
);
824 FreePool (StringPtrUnknown
);
826 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1
), gDpHiiHandle
);
827 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2
), gDpHiiHandle
);
828 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), gDpHiiHandle
);
830 for ( TIndex
= 0; TIndex
< NumCum
; ++TIndex
) {
831 if (CumData
[TIndex
].Count
!= 0) {
832 AvgDur
= DivU64x32 (CumData
[TIndex
].Duration
, CumData
[TIndex
].Count
);
833 AvgDur
= DurationInMicroSeconds(AvgDur
);
834 Dur
= DurationInMicroSeconds(CumData
[TIndex
].Duration
);
835 MaxDur
= DurationInMicroSeconds(CumData
[TIndex
].MaxDur
);
836 MinDur
= DurationInMicroSeconds(CumData
[TIndex
].MinDur
);
838 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_STATS
), gDpHiiHandle
,
839 CumData
[TIndex
].Name
,
840 CumData
[TIndex
].Count
,
850 // Print the custom cumulative data.
852 if (CustomCumulativeData
!= NULL
) {
853 if (CustomCumulativeData
->Count
!= 0) {
854 AvgDur
= DivU64x32 (CustomCumulativeData
->Duration
, CustomCumulativeData
->Count
);
855 AvgDur
= DurationInMicroSeconds (AvgDur
);
856 Dur
= DurationInMicroSeconds (CustomCumulativeData
->Duration
);
857 MaxDur
= DurationInMicroSeconds (CustomCumulativeData
->MaxDur
);
858 MinDur
= DurationInMicroSeconds (CustomCumulativeData
->MinDur
);
865 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_STATS
), gDpHiiHandle
,
866 CustomCumulativeData
->Name
,
867 CustomCumulativeData
->Count
,