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 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/PeCoffGetEntryPointLib.h>
21 #include <Library/PerformanceLib.h>
22 #include <Library/PrintLib.h>
23 #include <Library/HiiLib.h>
24 #include <Library/PcdLib.h>
28 #include "DpInternal.h"
31 Attempts to retrieve a performance measurement log entry from the performance measurement log.
34 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.
35 0, then the first performance measurement log entry is retrieved.
36 On exit, the key of the next performance log entry.
37 @param Handle Pointer to environment specific context used to identify the component
39 @param Token Pointer to a Null-terminated ASCII string that identifies the component
41 @param Module Pointer to a Null-terminated ASCII string that identifies the module
43 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
45 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement
47 @param Identifier Pointer to the 32-bit identifier that was recorded when the measurement
50 @return The key for the next performance log entry (in general case).
54 GetPerformanceMeasurementRecord (
56 OUT CONST VOID
**Handle
,
57 OUT CONST CHAR8
**Token
,
58 OUT CONST CHAR8
**Module
,
59 OUT UINT64
*StartTimeStamp
,
60 OUT UINT64
*EndTimeStamp
,
61 OUT UINT32
*Identifier
64 if (LogEntryKey
== mMeasurementNum
) {
68 *Handle
= (VOID
*) (UINTN
) mMeasurementList
[LogEntryKey
].Handle
;
69 *Token
= mMeasurementList
[LogEntryKey
].Token
;
70 *Module
= mMeasurementList
[LogEntryKey
].Module
;
71 *StartTimeStamp
= mMeasurementList
[LogEntryKey
].StartTimeStamp
;
72 *EndTimeStamp
= mMeasurementList
[LogEntryKey
].EndTimeStamp
;
73 *Identifier
= mMeasurementList
[LogEntryKey
].Identifier
;
81 Collect verbose statistics about the logged performance measurements.
83 General Summary information for all Trace measurements is gathered and
84 stored within the SummaryData structure. This information is both
85 used internally by subsequent reporting functions, and displayed
86 at the end of verbose reports.
88 @pre The SummaryData and CumData structures must be initialized
89 prior to calling this function.
91 @post The SummaryData and CumData structures contain statistics for the
92 current performance logs.
94 @param[in, out] CustomCumulativeData A pointer to the cumtom cumulative data.
99 IN OUT PERF_CUM_DATA
*CustomCumulativeData OPTIONAL
102 MEASUREMENT_RECORD Measurement
;
108 while ((LogEntryKey
= GetPerformanceMeasurementRecord (
113 &Measurement
.StartTimeStamp
,
114 &Measurement
.EndTimeStamp
,
115 &Measurement
.Identifier
)) != 0)
117 ++SummaryData
.NumTrace
; // Count the number of TRACE Measurement records
118 if (Measurement
.EndTimeStamp
== 0) {
119 ++SummaryData
.NumIncomplete
; // Count the incomplete records
123 if (Measurement
.Handle
!= NULL
) {
124 ++SummaryData
.NumHandles
; // Count the number of measurements with non-NULL handles
127 if (IsPhase( &Measurement
)) {
128 ++SummaryData
.NumSummary
; // Count the number of major phases
131 if(Measurement
.Handle
== NULL
) {
132 ++SummaryData
.NumGlobal
;
136 if (AsciiStrCmp (Measurement
.Token
, ALit_PEIM
) == 0) {
137 ++SummaryData
.NumPEIMs
; // Count PEIM measurements
140 Duration
= GetDuration (&Measurement
);
141 TIndex
= GetCumulativeItem (&Measurement
);
143 CumData
[TIndex
].Duration
+= Duration
;
144 CumData
[TIndex
].Count
++;
145 if ( Duration
< CumData
[TIndex
].MinDur
) {
146 CumData
[TIndex
].MinDur
= Duration
;
148 if ( Duration
> CumData
[TIndex
].MaxDur
) {
149 CumData
[TIndex
].MaxDur
= Duration
;
154 // Collect the data for custom cumulative data.
156 if ((CustomCumulativeData
!= NULL
) && (AsciiStrCmp (Measurement
.Token
, CustomCumulativeData
->Name
) == 0)) {
157 CustomCumulativeData
->Duration
+= Duration
;
158 CustomCumulativeData
->Count
++;
159 if (Duration
< CustomCumulativeData
->MinDur
) {
160 CustomCumulativeData
->MinDur
= Duration
;
162 if (Duration
> CustomCumulativeData
->MaxDur
) {
163 CustomCumulativeData
->MaxDur
= Duration
;
170 Gather and print ALL Trace Records.
172 Displays all "interesting" Trace measurements in order.<BR>
173 The number of records displayed is controlled by:
174 - records with a duration less than mInterestThreshold microseconds are not displayed.
175 - No more than Limit records are displayed. A Limit of zero will not limit the output.
176 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
179 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
180 The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
181 They must not be in use by a calling function.
183 @param[in] Limit The number of records to print. Zero is ALL.
184 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
186 @retval EFI_SUCCESS The operation was successful.
187 @retval EFI_ABORTED The user aborts the operation.
188 @return Others from a call to gBS->LocateHandleBuffer().
193 IN BOOLEAN ExcludeFlag
196 MEASUREMENT_RECORD Measurement
;
205 EFI_HANDLE
*HandleBuffer
;
208 EFI_STRING StringPtrUnknown
;
210 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
211 IncFlag
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_ALL
), NULL
);
212 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), mDpHiiHandle
,
213 (IncFlag
== NULL
) ? StringPtrUnknown
: IncFlag
);
214 FreePool (StringPtrUnknown
);
216 // Get Handle information
218 Status
= gBS
->LocateHandleBuffer (AllHandles
, NULL
, NULL
, &HandleCount
, &HandleBuffer
);
219 if (EFI_ERROR (Status
)) {
220 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLES_ERROR
), mDpHiiHandle
, Status
);
223 // We have successfully populated the HandleBuffer
224 // Display ALL Measurement Records
225 // Up to Limit lines displayed
226 // Display only records with Elapsed times >= mInterestThreshold
227 // Display driver names in Module field for records with Handles.
230 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_HEADR2
), mDpHiiHandle
);
231 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_DASHES2
), mDpHiiHandle
);
233 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_HEADR
), mDpHiiHandle
);
234 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), mDpHiiHandle
);
240 while ( WITHIN_LIMIT(Count
, Limit
) &&
241 ((LogEntryKey
= GetPerformanceMeasurementRecord (
246 &Measurement
.StartTimeStamp
,
247 &Measurement
.EndTimeStamp
,
248 &Measurement
.Identifier
)) != 0)
251 ++Index
; // Count every record. First record is 1.
253 SHELL_FREE_NON_NULL (IncFlag
);
254 if (Measurement
.EndTimeStamp
!= 0) {
255 Duration
= GetDuration (&Measurement
);
256 ElapsedTime
= DurationInMicroSeconds ( Duration
);
257 IncFlag
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_COMPLETE
), NULL
);
260 IncFlag
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_INCOMPLETE
), NULL
); // Mark incomplete records
262 if (((Measurement
.EndTimeStamp
!= 0) && (ElapsedTime
< mInterestThreshold
)) ||
263 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
264 ) { // Ignore "uninteresting" or excluded records
267 ++Count
; // Count the number of records printed
269 // If Handle is non-zero, see if we can determine a name for the driver
270 AsciiStrToUnicodeStrS (Measurement
.Module
, mGaugeString
, ARRAY_SIZE (mGaugeString
)); // Use Module by default
271 AsciiStrToUnicodeStrS (Measurement
.Token
, mUnicodeToken
, ARRAY_SIZE (mUnicodeToken
));
272 if (Measurement
.Handle
!= NULL
) {
273 // See if the Handle is in the HandleBuffer
274 for (TIndex
= 0; TIndex
< HandleCount
; TIndex
++) {
275 if (Measurement
.Handle
== HandleBuffer
[TIndex
]) {
276 DpGetNameFromHandle (HandleBuffer
[TIndex
]);
282 if (AsciiStrCmp (Measurement
.Token
, ALit_PEIM
) == 0) {
283 UnicodeSPrint (mGaugeString
, sizeof (mGaugeString
), L
"%g", Measurement
.Handle
);
286 // Ensure that the argument strings are not too long.
287 mGaugeString
[DP_GAUGE_STRING_LENGTH
] = 0;
288 mUnicodeToken
[13] = 0;
291 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_VARS2
), mDpHiiHandle
,
292 Index
, // 1 based, Which measurement record is being printed
298 Measurement
.Identifier
301 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_ALL_VARS
), mDpHiiHandle
,
302 Index
, // 1 based, Which measurement record is being printed
310 if (ShellGetExecutionBreakFlag ()) {
311 Status
= EFI_ABORTED
;
316 if (HandleBuffer
!= NULL
) {
317 FreePool (HandleBuffer
);
319 SHELL_FREE_NON_NULL (IncFlag
);
325 Gather and print Raw Trace Records.
327 All Trace measurements with a duration greater than or equal to
328 mInterestThreshold are printed without interpretation.
330 The number of records displayed is controlled by:
331 - records with a duration less than mInterestThreshold microseconds are not displayed.
332 - No more than Limit records are displayed. A Limit of zero will not limit the output.
333 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
336 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.
338 @param[in] Limit The number of records to print. Zero is ALL.
339 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
341 @retval EFI_SUCCESS The operation was successful.
342 @retval EFI_ABORTED The user aborts the operation.
347 IN BOOLEAN ExcludeFlag
350 MEASUREMENT_RECORD Measurement
;
357 EFI_STRING StringPtr
;
358 EFI_STRING StringPtrUnknown
;
361 Status
= EFI_SUCCESS
;
363 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
364 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_RAWTRACE
), NULL
);
365 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), mDpHiiHandle
,
366 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
367 FreePool (StringPtr
);
368 FreePool (StringPtrUnknown
);
371 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_HEADR2
), mDpHiiHandle
);
372 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_DASHES2
), mDpHiiHandle
);
374 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_HEADR
), mDpHiiHandle
);
375 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_DASHES
), mDpHiiHandle
);
381 while ( WITHIN_LIMIT(Count
, Limit
) &&
382 ((LogEntryKey
= GetPerformanceMeasurementRecord (
387 &Measurement
.StartTimeStamp
,
388 &Measurement
.EndTimeStamp
,
389 &Measurement
.Identifier
)) != 0)
392 ++Index
; // Count every record. First record is 1.
394 if (Measurement
.EndTimeStamp
!= 0) {
395 Duration
= GetDuration (&Measurement
);
396 ElapsedTime
= DurationInMicroSeconds ( Duration
);
398 if ((ElapsedTime
< mInterestThreshold
) ||
399 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
400 ) { // Ignore "uninteresting" or Excluded records
403 ++Count
; // Count the number of records printed
406 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_VARS2
), mDpHiiHandle
,
407 Index
, // 1 based, Which measurement record is being printed
409 Measurement
.StartTimeStamp
,
410 Measurement
.EndTimeStamp
,
413 Measurement
.Identifier
416 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_RAW_VARS
), mDpHiiHandle
,
417 Index
, // 1 based, Which measurement record is being printed
419 Measurement
.StartTimeStamp
,
420 Measurement
.EndTimeStamp
,
425 if (ShellGetExecutionBreakFlag ()) {
426 Status
= EFI_ABORTED
;
434 Gather and print Major Phase metrics.
442 MEASUREMENT_RECORD Measurement
;
443 UINT64 BdsTimeoutValue
;
451 EFI_STRING StringPtr
;
453 EFI_STRING StringPtrUnknown
;
461 // Get Execution Phase Statistics
463 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
464 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PHASES
), NULL
);
465 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), mDpHiiHandle
,
466 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
467 FreePool (StringPtr
);
468 FreePool (StringPtrUnknown
);
471 while ((LogEntryKey
= GetPerformanceMeasurementRecord (
476 &Measurement
.StartTimeStamp
,
477 &Measurement
.EndTimeStamp
,
478 &Measurement
.Identifier
)) != 0)
480 if (Measurement
.EndTimeStamp
== 0) { // Skip "incomplete" records
483 Duration
= GetDuration (&Measurement
);
484 if ( Measurement
.Handle
!= NULL
485 && (AsciiStrCmp (Measurement
.Token
, ALit_BdsTO
) == 0)
488 BdsTimeoutValue
= Duration
;
489 } else if (AsciiStrCmp (Measurement
.Token
, ALit_SEC
) == 0) {
491 } else if (AsciiStrCmp (Measurement
.Token
, ALit_PEI
) == 0) {
493 } else if (AsciiStrCmp (Measurement
.Token
, ALit_DXE
) == 0) {
495 } else if (AsciiStrCmp (Measurement
.Token
, ALit_BDS
) == 0) {
502 // print SEC phase duration time
505 ElapsedTime
= DurationInMicroSeconds ( SecTime
); // Calculate elapsed time in microseconds
506 Total
+= DivU64x32 (ElapsedTime
, 1000); // Accumulate time in milliseconds
507 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SEC_PHASE
), mDpHiiHandle
, ElapsedTime
);
510 // print PEI phase duration time
513 ElapsedTime
= DivU64x32 (PeiTime
, 1000000);
514 Total
+= ElapsedTime
;
515 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), mDpHiiHandle
, ALit_PEI
, ElapsedTime
);
518 // print DXE phase duration time
521 ElapsedTime
= DivU64x32 (DxeTime
, 1000000);
522 Total
+= ElapsedTime
;
523 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), mDpHiiHandle
, ALit_DXE
, ElapsedTime
);
526 // print BDS phase duration time
529 ElapsedTime
= DivU64x32 (BdsTime
, 1000000);
530 Total
+= ElapsedTime
;
531 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_DURATION
), mDpHiiHandle
, ALit_BDS
, ElapsedTime
);
534 if (BdsTimeoutValue
> 0) {
535 ElapsedTime
= DivU64x32 (BdsTimeoutValue
, 1000000);
536 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PHASE_BDSTO
), mDpHiiHandle
, ALit_BdsTO
, ElapsedTime
);
539 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_TOTAL_DURATION
), mDpHiiHandle
, Total
);
543 Gather and print Handle data.
545 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.
547 @retval EFI_SUCCESS The operation was successful.
548 @retval EFI_ABORTED The user aborts the operation.
549 @return Others from a call to gBS->LocateHandleBuffer().
553 IN BOOLEAN ExcludeFlag
556 MEASUREMENT_RECORD Measurement
;
559 EFI_HANDLE
*HandleBuffer
;
560 EFI_STRING StringPtr
;
566 EFI_STRING StringPtrUnknown
;
568 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
569 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_DRIVERS
), NULL
);
570 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), mDpHiiHandle
,
571 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
572 FreePool (StringPtr
);
573 FreePool (StringPtrUnknown
);
575 Status
= gBS
->LocateHandleBuffer (AllHandles
, NULL
, NULL
, &HandleCount
, &HandleBuffer
);
576 if (EFI_ERROR (Status
)) {
577 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLES_ERROR
), mDpHiiHandle
, Status
);
581 Print (L
"There are %,d Handles defined.\n", (Size
/ sizeof(HandleBuffer
[0])));
585 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_SECTION2
), mDpHiiHandle
);
587 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_SECTION
), mDpHiiHandle
);
589 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), mDpHiiHandle
);
593 while ((LogEntryKey
= GetPerformanceMeasurementRecord (
598 &Measurement
.StartTimeStamp
,
599 &Measurement
.EndTimeStamp
,
600 &Measurement
.Identifier
)) != 0)
603 Duration
= GetDuration (&Measurement
);
604 ElapsedTime
= DurationInMicroSeconds ( Duration
);
605 if ((ElapsedTime
< mInterestThreshold
) ||
606 (Measurement
.EndTimeStamp
== 0) ||
607 (Measurement
.Handle
== NULL
) ||
608 ((ExcludeFlag
) && (GetCumulativeItem(&Measurement
) >= 0))
609 ) { // Ignore "uninteresting" or excluded records
612 mGaugeString
[0] = 0; // Empty driver name by default
613 AsciiStrToUnicodeStrS (Measurement
.Token
, mUnicodeToken
, ARRAY_SIZE (mUnicodeToken
));
614 // See if the Handle is in the HandleBuffer
615 for (Index
= 0; Index
< HandleCount
; Index
++) {
616 if (Measurement
.Handle
== HandleBuffer
[Index
]) {
617 DpGetNameFromHandle (HandleBuffer
[Index
]); // Name is put into mGaugeString
621 // Ensure that the argument strings are not too long.
622 mGaugeString
[DP_GAUGE_STRING_LENGTH
] = 0;
623 mUnicodeToken
[11] = 0;
624 if (mGaugeString
[0] != 0) {
625 // Display the record if it has a valid handle.
627 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_VARS2
), mDpHiiHandle
,
628 Count
, // 1 based, Which measurement record is being printed
629 Index
+ 1, // 1 based, Which handle is being printed
633 Measurement
.Identifier
636 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_HANDLE_VARS
), mDpHiiHandle
,
637 Count
, // 1 based, Which measurement record is being printed
638 Index
+ 1, // 1 based, Which handle is being printed
645 if (ShellGetExecutionBreakFlag ()) {
646 Status
= EFI_ABORTED
;
651 if (HandleBuffer
!= NULL
) {
652 FreePool (HandleBuffer
);
658 Gather and print PEIM data.
660 Only prints complete PEIM records
662 @retval EFI_SUCCESS The operation was successful.
663 @retval EFI_ABORTED The user aborts the operation.
670 MEASUREMENT_RECORD Measurement
;
673 EFI_STRING StringPtr
;
676 EFI_STRING StringPtrUnknown
;
679 Status
= EFI_SUCCESS
;
681 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
682 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_PEIMS
), NULL
);
683 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), mDpHiiHandle
,
684 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
685 FreePool (StringPtr
);
686 FreePool (StringPtrUnknown
);
689 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_SECTION2
), mDpHiiHandle
);
691 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_SECTION
), mDpHiiHandle
);
693 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), mDpHiiHandle
);
696 while ((LogEntryKey
= GetPerformanceMeasurementRecord (
701 &Measurement
.StartTimeStamp
,
702 &Measurement
.EndTimeStamp
,
703 &Measurement
.Identifier
)) != 0)
706 if ((Measurement
.EndTimeStamp
== 0) ||
707 (AsciiStrCmp (Measurement
.Token
, ALit_PEIM
) != 0)
712 Duration
= GetDuration (&Measurement
);
713 ElapsedTime
= DurationInMicroSeconds ( Duration
); // Calculate elapsed time in microseconds
714 if (ElapsedTime
>= mInterestThreshold
) {
715 // PEIM FILE Handle is the start address of its FFS file that contains its file guid.
717 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_VARS2
), mDpHiiHandle
,
718 TIndex
, // 1 based, Which measurement record is being printed
719 Measurement
.Handle
, // file guid
721 Measurement
.Identifier
724 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_PEIM_VARS
), mDpHiiHandle
,
725 TIndex
, // 1 based, Which measurement record is being printed
726 Measurement
.Handle
, // file guid
731 if (ShellGetExecutionBreakFlag ()) {
732 Status
= EFI_ABORTED
;
740 Gather and print global data.
742 Strips out incomplete or "Execution Phase" records
743 Only prints records where Handle is NULL
744 Increment TIndex for every record, even skipped ones, so that we have an
745 indication of every measurement record taken.
747 @retval EFI_SUCCESS The operation was successful.
748 @retval EFI_ABORTED The user aborts the operation.
755 MEASUREMENT_RECORD Measurement
;
758 EFI_STRING StringPtr
;
760 UINTN Index
; // Index, or number, of the measurement record being processed
761 EFI_STRING StringPtrUnknown
;
764 Status
= EFI_SUCCESS
;
766 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
767 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_GENERAL
), NULL
);
768 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), mDpHiiHandle
,
769 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
770 FreePool (StringPtr
);
771 FreePool (StringPtrUnknown
);
774 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_SECTION2
), mDpHiiHandle
);
776 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_SECTION
), mDpHiiHandle
);
778 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), mDpHiiHandle
);
783 while ((LogEntryKey
= GetPerformanceMeasurementRecord (
788 &Measurement
.StartTimeStamp
,
789 &Measurement
.EndTimeStamp
,
790 &Measurement
.Identifier
)) != 0)
792 AsciiStrToUnicodeStrS (Measurement
.Module
, mGaugeString
, ARRAY_SIZE (mGaugeString
));
793 AsciiStrToUnicodeStrS (Measurement
.Token
, mUnicodeToken
, ARRAY_SIZE (mUnicodeToken
));
794 mGaugeString
[25] = 0;
795 mUnicodeToken
[31] = 0;
796 if ( ! ( IsPhase( &Measurement
) ||
797 (Measurement
.Handle
!= NULL
) ||
798 (Measurement
.EndTimeStamp
== 0)
801 Duration
= GetDuration (&Measurement
);
802 ElapsedTime
= DurationInMicroSeconds ( Duration
);
803 if (ElapsedTime
>= mInterestThreshold
) {
805 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_VARS2
), mDpHiiHandle
,
810 Measurement
.Identifier
813 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_GLOBAL_VARS
), mDpHiiHandle
,
822 if (ShellGetExecutionBreakFlag ()) {
823 Status
= EFI_ABORTED
;
832 Gather and print cumulative data.
834 Traverse the measurement records and:<BR>
835 For each record with a Token listed in the CumData array:<BR>
836 - Update the instance count and the total, minimum, and maximum durations.
837 Finally, print the gathered cumulative statistics.
839 @param[in] CustomCumulativeData A pointer to the cumtom cumulative data.
844 IN PERF_CUM_DATA
*CustomCumulativeData OPTIONAL
847 UINT64 AvgDur
; // the computed average duration
851 EFI_STRING StringPtr
;
853 EFI_STRING StringPtrUnknown
;
855 StringPtrUnknown
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_ALIT_UNKNOWN
), NULL
);
856 StringPtr
= HiiGetString (mDpHiiHandle
, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE
), NULL
);
857 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_SECTION_HEADER
), mDpHiiHandle
,
858 (StringPtr
== NULL
) ? StringPtrUnknown
: StringPtr
);
859 FreePool (StringPtr
);
860 FreePool (StringPtrUnknown
);
862 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1
), mDpHiiHandle
);
863 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2
), mDpHiiHandle
);
864 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_DASHES
), mDpHiiHandle
);
866 for ( TIndex
= 0; TIndex
< NumCum
; ++TIndex
) {
867 if (CumData
[TIndex
].Count
!= 0) {
868 AvgDur
= DivU64x32 (CumData
[TIndex
].Duration
, CumData
[TIndex
].Count
);
869 AvgDur
= DurationInMicroSeconds(AvgDur
);
870 Dur
= DurationInMicroSeconds(CumData
[TIndex
].Duration
);
871 MaxDur
= DurationInMicroSeconds(CumData
[TIndex
].MaxDur
);
872 MinDur
= DurationInMicroSeconds(CumData
[TIndex
].MinDur
);
874 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_STATS
), mDpHiiHandle
,
875 CumData
[TIndex
].Name
,
876 CumData
[TIndex
].Count
,
886 // Print the custom cumulative data.
888 if (CustomCumulativeData
!= NULL
) {
889 if (CustomCumulativeData
->Count
!= 0) {
890 AvgDur
= DivU64x32 (CustomCumulativeData
->Duration
, CustomCumulativeData
->Count
);
891 AvgDur
= DurationInMicroSeconds (AvgDur
);
892 Dur
= DurationInMicroSeconds (CustomCumulativeData
->Duration
);
893 MaxDur
= DurationInMicroSeconds (CustomCumulativeData
->MaxDur
);
894 MinDur
= DurationInMicroSeconds (CustomCumulativeData
->MinDur
);
901 ShellPrintHiiEx (-1, -1, NULL
, STRING_TOKEN (STR_DP_CUMULATIVE_STATS
), mDpHiiHandle
,
902 CustomCumulativeData
->Name
,
903 CustomCumulativeData
->Count
,