]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
ShellPkg/DpDynamicCommand: Add ResetEnd support in DP command
[mirror_edk2.git] / ShellPkg / DynamicCommand / DpDynamicCommand / DpTrace.c
CommitLineData
d41bc92c 1/** @file\r
2 Trace reporting for the Dp utility.\r
3\r
115eae65 4 Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.\r
64c51ed1 5 (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
56ba3746 6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
d41bc92c 7**/\r
8\r
9#include <Library/BaseLib.h>\r
10#include <Library/BaseMemoryLib.h>\r
11#include <Library/MemoryAllocationLib.h>\r
12#include <Library/DebugLib.h>\r
13#include <Library/UefiBootServicesTableLib.h>\r
d41bc92c 14#include <Library/PeCoffGetEntryPointLib.h>\r
15#include <Library/PerformanceLib.h>\r
16#include <Library/PrintLib.h>\r
17#include <Library/HiiLib.h>\r
18#include <Library/PcdLib.h>\r
19\r
d41bc92c 20#include "Dp.h"\r
21#include "Literals.h"\r
22#include "DpInternal.h"\r
23\r
115eae65
DB
24/**\r
25 Attempts to retrieve a performance measurement log entry from the performance measurement log.\r
26\r
27\r
28 @param LogEntryKey On entry, the key of the performance measurement log entry to retrieve.\r
29 0, then the first performance measurement log entry is retrieved.\r
30 On exit, the key of the next performance log entry.\r
31 @param Handle Pointer to environment specific context used to identify the component\r
32 being measured.\r
33 @param Token Pointer to a Null-terminated ASCII string that identifies the component\r
34 being measured.\r
35 @param Module Pointer to a Null-terminated ASCII string that identifies the module\r
36 being measured.\r
37 @param StartTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r
38 was started.\r
39 @param EndTimeStamp Pointer to the 64-bit time stamp that was recorded when the measurement\r
40 was ended.\r
41 @param Identifier Pointer to the 32-bit identifier that was recorded when the measurement\r
42 was ended.\r
43\r
44 @return The key for the next performance log entry (in general case).\r
45\r
46**/\r
47UINTN\r
48GetPerformanceMeasurementRecord (\r
47d20b54
MK
49 IN UINTN LogEntryKey,\r
50 OUT CONST VOID **Handle,\r
51 OUT CONST CHAR8 **Token,\r
52 OUT CONST CHAR8 **Module,\r
53 OUT UINT64 *StartTimeStamp,\r
54 OUT UINT64 *EndTimeStamp,\r
55 OUT UINT32 *Identifier\r
115eae65
DB
56 )\r
57{\r
58 if (LogEntryKey == mMeasurementNum) {\r
59 return 0;\r
60 }\r
61\r
47d20b54 62 *Handle = (VOID *)(UINTN)mMeasurementList[LogEntryKey].Handle;\r
115eae65
DB
63 *Token = mMeasurementList[LogEntryKey].Token;\r
64 *Module = mMeasurementList[LogEntryKey].Module;\r
65 *StartTimeStamp = mMeasurementList[LogEntryKey].StartTimeStamp;\r
66 *EndTimeStamp = mMeasurementList[LogEntryKey].EndTimeStamp;\r
67 *Identifier = mMeasurementList[LogEntryKey].Identifier;\r
68\r
47d20b54 69 LogEntryKey++;\r
115eae65
DB
70\r
71 return LogEntryKey;\r
72}\r
73\r
92034c4c 74/**\r
d41bc92c 75 Collect verbose statistics about the logged performance measurements.\r
92034c4c 76\r
d41bc92c 77 General Summary information for all Trace measurements is gathered and\r
78 stored within the SummaryData structure. This information is both\r
79 used internally by subsequent reporting functions, and displayed\r
80 at the end of verbose reports.\r
92034c4c 81\r
d41bc92c 82 @pre The SummaryData and CumData structures must be initialized\r
83 prior to calling this function.\r
92034c4c 84\r
d41bc92c 85 @post The SummaryData and CumData structures contain statistics for the\r
86 current performance logs.\r
a06795c6 87\r
f16bd394 88 @param[in, out] CustomCumulativeData A pointer to the custom cumulative data.\r
a06795c6 89\r
d41bc92c 90**/\r
91VOID\r
47d20b54
MK
92GatherStatistics (\r
93 IN OUT PERF_CUM_DATA *CustomCumulativeData OPTIONAL\r
a06795c6 94 )\r
d41bc92c 95{\r
47d20b54
MK
96 MEASUREMENT_RECORD Measurement;\r
97 UINT64 Duration;\r
98 UINTN LogEntryKey;\r
99 INTN TIndex;\r
d41bc92c 100\r
101 LogEntryKey = 0;\r
115eae65 102 while ((LogEntryKey = GetPerformanceMeasurementRecord (\r
47d20b54
MK
103 LogEntryKey,\r
104 &Measurement.Handle,\r
105 &Measurement.Token,\r
106 &Measurement.Module,\r
107 &Measurement.StartTimeStamp,\r
108 &Measurement.EndTimeStamp,\r
109 &Measurement.Identifier\r
110 )) != 0)\r
d41bc92c 111 {\r
112 ++SummaryData.NumTrace; // Count the number of TRACE Measurement records\r
113 if (Measurement.EndTimeStamp == 0) {\r
114 ++SummaryData.NumIncomplete; // Count the incomplete records\r
115 continue;\r
116 }\r
117\r
118 if (Measurement.Handle != NULL) {\r
119 ++SummaryData.NumHandles; // Count the number of measurements with non-NULL handles\r
120 }\r
121\r
47d20b54 122 if (IsPhase (&Measurement)) {\r
d41bc92c 123 ++SummaryData.NumSummary; // Count the number of major phases\r
47d20b54
MK
124 } else {\r
125 // !IsPhase\r
126 if (Measurement.Handle == NULL) {\r
d41bc92c 127 ++SummaryData.NumGlobal;\r
128 }\r
129 }\r
130\r
115eae65 131 if (AsciiStrCmp (Measurement.Token, ALit_PEIM) == 0) {\r
d41bc92c 132 ++SummaryData.NumPEIMs; // Count PEIM measurements\r
133 }\r
134\r
135 Duration = GetDuration (&Measurement);\r
47d20b54 136 TIndex = GetCumulativeItem (&Measurement);\r
d41bc92c 137 if (TIndex >= 0) {\r
138 CumData[TIndex].Duration += Duration;\r
139 CumData[TIndex].Count++;\r
140 if ( Duration < CumData[TIndex].MinDur ) {\r
141 CumData[TIndex].MinDur = Duration;\r
142 }\r
47d20b54 143\r
d41bc92c 144 if ( Duration > CumData[TIndex].MaxDur ) {\r
145 CumData[TIndex].MaxDur = Duration;\r
146 }\r
147 }\r
a06795c6
CS
148\r
149 //\r
150 // Collect the data for custom cumulative data.\r
151 //\r
152 if ((CustomCumulativeData != NULL) && (AsciiStrCmp (Measurement.Token, CustomCumulativeData->Name) == 0)) {\r
153 CustomCumulativeData->Duration += Duration;\r
154 CustomCumulativeData->Count++;\r
155 if (Duration < CustomCumulativeData->MinDur) {\r
156 CustomCumulativeData->MinDur = Duration;\r
157 }\r
47d20b54 158\r
a06795c6
CS
159 if (Duration > CustomCumulativeData->MaxDur) {\r
160 CustomCumulativeData->MaxDur = Duration;\r
161 }\r
162 }\r
d41bc92c 163 }\r
164}\r
165\r
92034c4c 166/**\r
d41bc92c 167 Gather and print ALL Trace Records.\r
92034c4c 168\r
d41bc92c 169 Displays all "interesting" Trace measurements in order.<BR>\r
170 The number of records displayed is controlled by:\r
171 - records with a duration less than mInterestThreshold microseconds are not displayed.\r
172 - No more than Limit records are displayed. A Limit of zero will not limit the output.\r
173 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not\r
174 displayed.\r
92034c4c 175\r
d41bc92c 176 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.\r
177 The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.\r
178 They must not be in use by a calling function.\r
92034c4c 179\r
d41bc92c 180 @param[in] Limit The number of records to print. Zero is ALL.\r
181 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.\r
92034c4c 182\r
196ccda0
CS
183 @retval EFI_SUCCESS The operation was successful.\r
184 @retval EFI_ABORTED The user aborts the operation.\r
185 @return Others from a call to gBS->LocateHandleBuffer().\r
d41bc92c 186**/\r
196ccda0 187EFI_STATUS\r
47d20b54
MK
188DumpAllTrace (\r
189 IN UINTN Limit,\r
190 IN BOOLEAN ExcludeFlag\r
d41bc92c 191 )\r
192{\r
47d20b54
MK
193 MEASUREMENT_RECORD Measurement;\r
194 UINT64 ElapsedTime;\r
195 UINT64 Duration;\r
196 CHAR16 *IncFlag;\r
197 UINTN LogEntryKey;\r
198 UINTN Count;\r
199 UINTN Index;\r
200 UINTN TIndex;\r
201\r
202 EFI_HANDLE *HandleBuffer;\r
203 UINTN HandleCount;\r
204 EFI_STATUS Status;\r
205 EFI_STRING StringPtrUnknown;\r
d41bc92c 206\r
92034c4c 207 StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
47d20b54
MK
208 IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL);\r
209 ShellPrintHiiEx (\r
210 -1,\r
211 -1,\r
212 NULL,\r
213 STRING_TOKEN (STR_DP_SECTION_HEADER),\r
214 mDpHiiHandle,\r
215 (IncFlag == NULL) ? StringPtrUnknown : IncFlag\r
216 );\r
d41bc92c 217 FreePool (StringPtrUnknown);\r
218\r
219 // Get Handle information\r
220 //\r
47d20b54 221 Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);\r
d41bc92c 222 if (EFI_ERROR (Status)) {\r
92034c4c 223 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);\r
47d20b54 224 } else {\r
d41bc92c 225 // We have successfully populated the HandleBuffer\r
226 // Display ALL Measurement Records\r
227 // Up to Limit lines displayed\r
228 // Display only records with Elapsed times >= mInterestThreshold\r
229 // Display driver names in Module field for records with Handles.\r
230 //\r
231 if (mShowId) {\r
92034c4c
RN
232 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR2), mDpHiiHandle);\r
233 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_DASHES2), mDpHiiHandle);\r
d41bc92c 234 } else {\r
92034c4c
RN
235 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR), mDpHiiHandle);\r
236 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);\r
d41bc92c 237 }\r
238\r
239 LogEntryKey = 0;\r
47d20b54
MK
240 Count = 0;\r
241 Index = 0;\r
242 while ( WITHIN_LIMIT (Count, Limit) &&\r
115eae65 243 ((LogEntryKey = GetPerformanceMeasurementRecord (\r
47d20b54
MK
244 LogEntryKey,\r
245 &Measurement.Handle,\r
246 &Measurement.Token,\r
247 &Measurement.Module,\r
248 &Measurement.StartTimeStamp,\r
249 &Measurement.EndTimeStamp,\r
250 &Measurement.Identifier\r
251 )) != 0)\r
252 )\r
d41bc92c 253 {\r
254 ++Index; // Count every record. First record is 1.\r
255 ElapsedTime = 0;\r
256 SHELL_FREE_NON_NULL (IncFlag);\r
257 if (Measurement.EndTimeStamp != 0) {\r
47d20b54
MK
258 Duration = GetDuration (&Measurement);\r
259 ElapsedTime = DurationInMicroSeconds (Duration);\r
260 IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL);\r
261 } else {\r
92034c4c 262 IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_INCOMPLETE), NULL); // Mark incomplete records\r
d41bc92c 263 }\r
47d20b54 264\r
d41bc92c 265 if (((Measurement.EndTimeStamp != 0) && (ElapsedTime < mInterestThreshold)) ||\r
47d20b54
MK
266 ((ExcludeFlag) && (GetCumulativeItem (&Measurement) >= 0))\r
267 ) // Ignore "uninteresting" or excluded records\r
268 {\r
d41bc92c 269 continue;\r
270 }\r
47d20b54 271\r
d41bc92c 272 ++Count; // Count the number of records printed\r
273\r
274 // If Handle is non-zero, see if we can determine a name for the driver\r
cb4669e0
LE
275 AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString)); // Use Module by default\r
276 AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));\r
d41bc92c 277 if (Measurement.Handle != NULL) {\r
278 // See if the Handle is in the HandleBuffer\r
64c51ed1 279 for (TIndex = 0; TIndex < HandleCount; TIndex++) {\r
d41bc92c 280 if (Measurement.Handle == HandleBuffer[TIndex]) {\r
2c55a81a 281 DpGetNameFromHandle (HandleBuffer[TIndex]);\r
d41bc92c 282 break;\r
283 }\r
284 }\r
285 }\r
286\r
115eae65 287 if (AsciiStrCmp (Measurement.Token, ALit_PEIM) == 0) {\r
d41bc92c 288 UnicodeSPrint (mGaugeString, sizeof (mGaugeString), L"%g", Measurement.Handle);\r
289 }\r
290\r
291 // Ensure that the argument strings are not too long.\r
292 mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;\r
47d20b54 293 mUnicodeToken[13] = 0;\r
d41bc92c 294\r
295 if (mShowId) {\r
47d20b54
MK
296 ShellPrintHiiEx (\r
297 -1,\r
298 -1,\r
299 NULL,\r
300 STRING_TOKEN (STR_DP_ALL_VARS2),\r
301 mDpHiiHandle,\r
d41bc92c 302 Index, // 1 based, Which measurement record is being printed\r
303 IncFlag,\r
304 Measurement.Handle,\r
305 mGaugeString,\r
306 mUnicodeToken,\r
307 ElapsedTime,\r
308 Measurement.Identifier\r
47d20b54 309 );\r
d41bc92c 310 } else {\r
47d20b54
MK
311 ShellPrintHiiEx (\r
312 -1,\r
313 -1,\r
314 NULL,\r
315 STRING_TOKEN (STR_DP_ALL_VARS),\r
316 mDpHiiHandle,\r
d41bc92c 317 Index, // 1 based, Which measurement record is being printed\r
318 IncFlag,\r
319 Measurement.Handle,\r
320 mGaugeString,\r
321 mUnicodeToken,\r
322 ElapsedTime\r
47d20b54 323 );\r
d41bc92c 324 }\r
47d20b54 325\r
196ccda0
CS
326 if (ShellGetExecutionBreakFlag ()) {\r
327 Status = EFI_ABORTED;\r
328 break;\r
329 }\r
d41bc92c 330 }\r
331 }\r
47d20b54 332\r
64c51ed1 333 if (HandleBuffer != NULL) {\r
d41bc92c 334 FreePool (HandleBuffer);\r
335 }\r
47d20b54 336\r
d41bc92c 337 SHELL_FREE_NON_NULL (IncFlag);\r
196ccda0
CS
338\r
339 return Status;\r
d41bc92c 340}\r
341\r
92034c4c 342/**\r
d41bc92c 343 Gather and print Raw Trace Records.\r
92034c4c 344\r
d41bc92c 345 All Trace measurements with a duration greater than or equal to\r
346 mInterestThreshold are printed without interpretation.\r
92034c4c 347\r
d41bc92c 348 The number of records displayed is controlled by:\r
349 - records with a duration less than mInterestThreshold microseconds are not displayed.\r
350 - No more than Limit records are displayed. A Limit of zero will not limit the output.\r
351 - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not\r
352 displayed.\r
92034c4c 353\r
d41bc92c 354 @pre The mInterestThreshold global variable is set to the shortest duration to be printed.\r
92034c4c 355\r
d41bc92c 356 @param[in] Limit The number of records to print. Zero is ALL.\r
357 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.\r
196ccda0
CS
358\r
359 @retval EFI_SUCCESS The operation was successful.\r
360 @retval EFI_ABORTED The user aborts the operation.\r
d41bc92c 361**/\r
196ccda0 362EFI_STATUS\r
47d20b54
MK
363DumpRawTrace (\r
364 IN UINTN Limit,\r
365 IN BOOLEAN ExcludeFlag\r
d41bc92c 366 )\r
367{\r
47d20b54
MK
368 MEASUREMENT_RECORD Measurement;\r
369 UINT64 ElapsedTime;\r
370 UINT64 Duration;\r
371 UINTN LogEntryKey;\r
372 UINTN Count;\r
373 UINTN Index;\r
d41bc92c 374\r
47d20b54
MK
375 EFI_STRING StringPtr;\r
376 EFI_STRING StringPtrUnknown;\r
377 EFI_STATUS Status;\r
196ccda0
CS
378\r
379 Status = EFI_SUCCESS;\r
d41bc92c 380\r
92034c4c 381 StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
47d20b54
MK
382 StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);\r
383 ShellPrintHiiEx (\r
384 -1,\r
385 -1,\r
386 NULL,\r
387 STRING_TOKEN (STR_DP_SECTION_HEADER),\r
388 mDpHiiHandle,\r
389 (StringPtr == NULL) ? StringPtrUnknown : StringPtr\r
390 );\r
d41bc92c 391 FreePool (StringPtr);\r
392 FreePool (StringPtrUnknown);\r
393\r
394 if (mShowId) {\r
92034c4c
RN
395 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR2), mDpHiiHandle);\r
396 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES2), mDpHiiHandle);\r
d41bc92c 397 } else {\r
92034c4c
RN
398 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR), mDpHiiHandle);\r
399 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES), mDpHiiHandle);\r
d41bc92c 400 }\r
401\r
402 LogEntryKey = 0;\r
47d20b54
MK
403 Count = 0;\r
404 Index = 0;\r
405 while ( WITHIN_LIMIT (Count, Limit) &&\r
115eae65 406 ((LogEntryKey = GetPerformanceMeasurementRecord (\r
47d20b54
MK
407 LogEntryKey,\r
408 &Measurement.Handle,\r
409 &Measurement.Token,\r
410 &Measurement.Module,\r
411 &Measurement.StartTimeStamp,\r
412 &Measurement.EndTimeStamp,\r
413 &Measurement.Identifier\r
414 )) != 0)\r
415 )\r
d41bc92c 416 {\r
417 ++Index; // Count every record. First record is 1.\r
418 ElapsedTime = 0;\r
419 if (Measurement.EndTimeStamp != 0) {\r
47d20b54
MK
420 Duration = GetDuration (&Measurement);\r
421 ElapsedTime = DurationInMicroSeconds (Duration);\r
d41bc92c 422 }\r
47d20b54 423\r
d41bc92c 424 if ((ElapsedTime < mInterestThreshold) ||\r
47d20b54
MK
425 ((ExcludeFlag) && (GetCumulativeItem (&Measurement) >= 0))\r
426 ) // Ignore "uninteresting" or Excluded records\r
427 {\r
d41bc92c 428 continue;\r
429 }\r
47d20b54 430\r
d41bc92c 431 ++Count; // Count the number of records printed\r
432\r
433 if (mShowId) {\r
47d20b54
MK
434 ShellPrintHiiEx (\r
435 -1,\r
436 -1,\r
437 NULL,\r
438 STRING_TOKEN (STR_DP_RAW_VARS2),\r
439 mDpHiiHandle,\r
d41bc92c 440 Index, // 1 based, Which measurement record is being printed\r
441 Measurement.Handle,\r
442 Measurement.StartTimeStamp,\r
443 Measurement.EndTimeStamp,\r
444 Measurement.Token,\r
445 Measurement.Module,\r
446 Measurement.Identifier\r
47d20b54 447 );\r
d41bc92c 448 } else {\r
47d20b54
MK
449 ShellPrintHiiEx (\r
450 -1,\r
451 -1,\r
452 NULL,\r
453 STRING_TOKEN (STR_DP_RAW_VARS),\r
454 mDpHiiHandle,\r
d41bc92c 455 Index, // 1 based, Which measurement record is being printed\r
456 Measurement.Handle,\r
457 Measurement.StartTimeStamp,\r
458 Measurement.EndTimeStamp,\r
459 Measurement.Token,\r
460 Measurement.Module\r
47d20b54 461 );\r
d41bc92c 462 }\r
47d20b54 463\r
196ccda0
CS
464 if (ShellGetExecutionBreakFlag ()) {\r
465 Status = EFI_ABORTED;\r
466 break;\r
467 }\r
d41bc92c 468 }\r
47d20b54 469\r
196ccda0 470 return Status;\r
d41bc92c 471}\r
472\r
92034c4c 473/**\r
d41bc92c 474 Gather and print Major Phase metrics.\r
92034c4c 475\r
d41bc92c 476**/\r
477VOID\r
47d20b54 478ProcessPhases (\r
ef224032 479 VOID\r
d41bc92c 480 )\r
481{\r
47d20b54
MK
482 MEASUREMENT_RECORD Measurement;\r
483 UINT64 BdsTimeoutValue;\r
484 UINT64 SecTime;\r
485 UINT64 PeiTime;\r
486 UINT64 DxeTime;\r
487 UINT64 BdsTime;\r
488 UINT64 ElapsedTime;\r
489 UINT64 Duration;\r
490 UINT64 Total;\r
491 EFI_STRING StringPtr;\r
492 UINTN LogEntryKey;\r
493 EFI_STRING StringPtrUnknown;\r
d41bc92c 494\r
495 BdsTimeoutValue = 0;\r
496 SecTime = 0;\r
497 PeiTime = 0;\r
498 DxeTime = 0;\r
499 BdsTime = 0;\r
d41bc92c 500 //\r
501 // Get Execution Phase Statistics\r
502 //\r
92034c4c 503 StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
47d20b54
MK
504 StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL);\r
505 ShellPrintHiiEx (\r
506 -1,\r
507 -1,\r
508 NULL,\r
509 STRING_TOKEN (STR_DP_SECTION_HEADER),\r
510 mDpHiiHandle,\r
511 (StringPtr == NULL) ? StringPtrUnknown : StringPtr\r
512 );\r
d41bc92c 513 FreePool (StringPtr);\r
514 FreePool (StringPtrUnknown);\r
515\r
516 LogEntryKey = 0;\r
115eae65 517 while ((LogEntryKey = GetPerformanceMeasurementRecord (\r
d41bc92c 518 LogEntryKey,\r
519 &Measurement.Handle,\r
520 &Measurement.Token,\r
521 &Measurement.Module,\r
522 &Measurement.StartTimeStamp,\r
523 &Measurement.EndTimeStamp,\r
47d20b54
MK
524 &Measurement.Identifier\r
525 )) != 0)\r
d41bc92c 526 {\r
47d20b54
MK
527 if (Measurement.EndTimeStamp == 0) {\r
528 // Skip "incomplete" records\r
d41bc92c 529 continue;\r
530 }\r
47d20b54 531\r
d41bc92c 532 Duration = GetDuration (&Measurement);\r
47d20b54
MK
533 if ( (Measurement.Handle != NULL)\r
534 && (AsciiStrCmp (Measurement.Token, ALit_BdsTO) == 0)\r
535 )\r
d41bc92c 536 {\r
537 BdsTimeoutValue = Duration;\r
115eae65 538 } else if (AsciiStrCmp (Measurement.Token, ALit_SEC) == 0) {\r
47d20b54 539 SecTime = Duration;\r
115eae65 540 } else if (AsciiStrCmp (Measurement.Token, ALit_PEI) == 0) {\r
47d20b54 541 PeiTime = Duration;\r
115eae65 542 } else if (AsciiStrCmp (Measurement.Token, ALit_DXE) == 0) {\r
47d20b54 543 DxeTime = Duration;\r
115eae65 544 } else if (AsciiStrCmp (Measurement.Token, ALit_BDS) == 0) {\r
47d20b54 545 BdsTime = Duration;\r
d41bc92c 546 }\r
547 }\r
548\r
549 Total = 0;\r
550\r
c8c978d3 551 // print Reset End if it's valid\r
552 //\r
553 if (SecTime > mResetEnd) {\r
554 SecTime = SecTime - mResetEnd; // Calculate sec time duration start from the beginning of firmware image execution\r
555 ElapsedTime = DurationInMicroSeconds (mResetEnd); // Calculate elapsed time in microseconds\r
556 Total += DivU64x32 (ElapsedTime, 1000); // Accumulate time in milliseconds\r
557 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RESET_END), mDpHiiHandle, ElapsedTime);\r
558 }\r
559\r
d41bc92c 560 // print SEC phase duration time\r
561 //\r
562 if (SecTime > 0) {\r
47d20b54
MK
563 ElapsedTime = DurationInMicroSeconds (SecTime); // Calculate elapsed time in microseconds\r
564 Total += DivU64x32 (ElapsedTime, 1000); // Accumulate time in milliseconds\r
92034c4c 565 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SEC_PHASE), mDpHiiHandle, ElapsedTime);\r
d41bc92c 566 }\r
567\r
568 // print PEI phase duration time\r
569 //\r
570 if (PeiTime > 0) {\r
115eae65 571 ElapsedTime = DivU64x32 (PeiTime, 1000000);\r
47d20b54 572 Total += ElapsedTime;\r
92034c4c 573 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_PEI, ElapsedTime);\r
d41bc92c 574 }\r
575\r
576 // print DXE phase duration time\r
577 //\r
578 if (DxeTime > 0) {\r
115eae65 579 ElapsedTime = DivU64x32 (DxeTime, 1000000);\r
47d20b54 580 Total += ElapsedTime;\r
92034c4c 581 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_DXE, ElapsedTime);\r
d41bc92c 582 }\r
583\r
584 // print BDS phase duration time\r
585 //\r
586 if (BdsTime > 0) {\r
115eae65 587 ElapsedTime = DivU64x32 (BdsTime, 1000000);\r
47d20b54 588 Total += ElapsedTime;\r
92034c4c 589 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_BDS, ElapsedTime);\r
d41bc92c 590 }\r
591\r
592 if (BdsTimeoutValue > 0) {\r
115eae65 593 ElapsedTime = DivU64x32 (BdsTimeoutValue, 1000000);\r
92034c4c 594 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_BDSTO), mDpHiiHandle, ALit_BdsTO, ElapsedTime);\r
d41bc92c 595 }\r
596\r
92034c4c 597 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOTAL_DURATION), mDpHiiHandle, Total);\r
d41bc92c 598}\r
599\r
92034c4c 600/**\r
d41bc92c 601 Gather and print Handle data.\r
92034c4c 602\r
d41bc92c 603 @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display.\r
92034c4c 604\r
196ccda0
CS
605 @retval EFI_SUCCESS The operation was successful.\r
606 @retval EFI_ABORTED The user aborts the operation.\r
607 @return Others from a call to gBS->LocateHandleBuffer().\r
d41bc92c 608**/\r
609EFI_STATUS\r
47d20b54
MK
610ProcessHandles (\r
611 IN BOOLEAN ExcludeFlag\r
d41bc92c 612 )\r
613{\r
47d20b54
MK
614 MEASUREMENT_RECORD Measurement;\r
615 UINT64 ElapsedTime;\r
616 UINT64 Duration;\r
617 EFI_HANDLE *HandleBuffer;\r
618 EFI_STRING StringPtr;\r
619 UINTN Index;\r
620 UINTN LogEntryKey;\r
621 UINTN Count;\r
622 UINTN HandleCount;\r
623 EFI_STATUS Status;\r
624 EFI_STRING StringPtrUnknown;\r
d41bc92c 625\r
92034c4c 626 StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
47d20b54
MK
627 StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL);\r
628 ShellPrintHiiEx (\r
629 -1,\r
630 -1,\r
631 NULL,\r
632 STRING_TOKEN (STR_DP_SECTION_HEADER),\r
633 mDpHiiHandle,\r
634 (StringPtr == NULL) ? StringPtrUnknown : StringPtr\r
635 );\r
d41bc92c 636 FreePool (StringPtr);\r
637 FreePool (StringPtrUnknown);\r
638\r
64c51ed1 639 Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);\r
d41bc92c 640 if (EFI_ERROR (Status)) {\r
92034c4c 641 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);\r
47d20b54
MK
642 } else {\r
643 #if DP_DEBUG == 2\r
644 Print (L"There are %,d Handles defined.\n", (Size / sizeof (HandleBuffer[0])));\r
645 #endif\r
d41bc92c 646\r
647 if (mShowId) {\r
92034c4c 648 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION2), mDpHiiHandle);\r
d41bc92c 649 } else {\r
92034c4c 650 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION), mDpHiiHandle);\r
d41bc92c 651 }\r
47d20b54 652\r
92034c4c 653 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);\r
d41bc92c 654\r
655 LogEntryKey = 0;\r
47d20b54 656 Count = 0;\r
115eae65 657 while ((LogEntryKey = GetPerformanceMeasurementRecord (\r
d41bc92c 658 LogEntryKey,\r
659 &Measurement.Handle,\r
660 &Measurement.Token,\r
661 &Measurement.Module,\r
662 &Measurement.StartTimeStamp,\r
663 &Measurement.EndTimeStamp,\r
47d20b54
MK
664 &Measurement.Identifier\r
665 )) != 0)\r
d41bc92c 666 {\r
667 Count++;\r
47d20b54
MK
668 Duration = GetDuration (&Measurement);\r
669 ElapsedTime = DurationInMicroSeconds (Duration);\r
d41bc92c 670 if ((ElapsedTime < mInterestThreshold) ||\r
671 (Measurement.EndTimeStamp == 0) ||\r
f45dd2dd 672 (!IsCorePerf (&Measurement)) ||\r
47d20b54
MK
673 ((ExcludeFlag) && (GetCumulativeItem (&Measurement) >= 0))\r
674 ) // Ignore "uninteresting" or excluded records\r
675 {\r
d41bc92c 676 continue;\r
677 }\r
47d20b54 678\r
d41bc92c 679 mGaugeString[0] = 0; // Empty driver name by default\r
cb4669e0 680 AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));\r
d41bc92c 681 // See if the Handle is in the HandleBuffer\r
64c51ed1 682 for (Index = 0; Index < HandleCount; Index++) {\r
d41bc92c 683 if (Measurement.Handle == HandleBuffer[Index]) {\r
2c55a81a 684 DpGetNameFromHandle (HandleBuffer[Index]); // Name is put into mGaugeString\r
d41bc92c 685 break;\r
686 }\r
687 }\r
47d20b54 688\r
d41bc92c 689 // Ensure that the argument strings are not too long.\r
690 mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;\r
47d20b54 691 mUnicodeToken[11] = 0;\r
d41bc92c 692 if (mGaugeString[0] != 0) {\r
693 // Display the record if it has a valid handle.\r
694 if (mShowId) {\r
47d20b54
MK
695 ShellPrintHiiEx (\r
696 -1,\r
697 -1,\r
698 NULL,\r
699 STRING_TOKEN (STR_DP_HANDLE_VARS2),\r
700 mDpHiiHandle,\r
d41bc92c 701 Count, // 1 based, Which measurement record is being printed\r
702 Index + 1, // 1 based, Which handle is being printed\r
703 mGaugeString,\r
704 mUnicodeToken,\r
705 ElapsedTime,\r
706 Measurement.Identifier\r
47d20b54 707 );\r
d41bc92c 708 } else {\r
47d20b54
MK
709 ShellPrintHiiEx (\r
710 -1,\r
711 -1,\r
712 NULL,\r
713 STRING_TOKEN (STR_DP_HANDLE_VARS),\r
714 mDpHiiHandle,\r
d41bc92c 715 Count, // 1 based, Which measurement record is being printed\r
716 Index + 1, // 1 based, Which handle is being printed\r
717 mGaugeString,\r
718 mUnicodeToken,\r
719 ElapsedTime\r
47d20b54 720 );\r
d41bc92c 721 }\r
722 }\r
47d20b54 723\r
196ccda0
CS
724 if (ShellGetExecutionBreakFlag ()) {\r
725 Status = EFI_ABORTED;\r
726 break;\r
727 }\r
d41bc92c 728 }\r
729 }\r
47d20b54 730\r
64c51ed1 731 if (HandleBuffer != NULL) {\r
d41bc92c 732 FreePool (HandleBuffer);\r
733 }\r
47d20b54 734\r
d41bc92c 735 return Status;\r
736}\r
737\r
92034c4c 738/**\r
d41bc92c 739 Gather and print PEIM data.\r
92034c4c 740\r
d41bc92c 741 Only prints complete PEIM records\r
92034c4c 742\r
196ccda0
CS
743 @retval EFI_SUCCESS The operation was successful.\r
744 @retval EFI_ABORTED The user aborts the operation.\r
d41bc92c 745**/\r
196ccda0 746EFI_STATUS\r
47d20b54 747ProcessPeims (\r
d41bc92c 748 VOID\r
47d20b54 749 )\r
d41bc92c 750{\r
47d20b54
MK
751 MEASUREMENT_RECORD Measurement;\r
752 UINT64 Duration;\r
753 UINT64 ElapsedTime;\r
754 EFI_STRING StringPtr;\r
755 UINTN LogEntryKey;\r
756 UINTN TIndex;\r
757 EFI_STRING StringPtrUnknown;\r
758 EFI_STATUS Status;\r
196ccda0
CS
759\r
760 Status = EFI_SUCCESS;\r
d41bc92c 761\r
92034c4c 762 StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
47d20b54
MK
763 StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);\r
764 ShellPrintHiiEx (\r
765 -1,\r
766 -1,\r
767 NULL,\r
768 STRING_TOKEN (STR_DP_SECTION_HEADER),\r
769 mDpHiiHandle,\r
770 (StringPtr == NULL) ? StringPtrUnknown : StringPtr\r
771 );\r
d41bc92c 772 FreePool (StringPtr);\r
773 FreePool (StringPtrUnknown);\r
774\r
775 if (mShowId) {\r
92034c4c 776 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION2), mDpHiiHandle);\r
d41bc92c 777 } else {\r
92034c4c 778 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION), mDpHiiHandle);\r
d41bc92c 779 }\r
47d20b54 780\r
92034c4c 781 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);\r
47d20b54 782 TIndex = 0;\r
d41bc92c 783 LogEntryKey = 0;\r
115eae65 784 while ((LogEntryKey = GetPerformanceMeasurementRecord (\r
d41bc92c 785 LogEntryKey,\r
786 &Measurement.Handle,\r
787 &Measurement.Token,\r
788 &Measurement.Module,\r
789 &Measurement.StartTimeStamp,\r
790 &Measurement.EndTimeStamp,\r
47d20b54
MK
791 &Measurement.Identifier\r
792 )) != 0)\r
d41bc92c 793 {\r
794 TIndex++;\r
795 if ((Measurement.EndTimeStamp == 0) ||\r
115eae65 796 (AsciiStrCmp (Measurement.Token, ALit_PEIM) != 0)\r
47d20b54
MK
797 )\r
798 {\r
d41bc92c 799 continue;\r
800 }\r
801\r
47d20b54
MK
802 Duration = GetDuration (&Measurement);\r
803 ElapsedTime = DurationInMicroSeconds (Duration); // Calculate elapsed time in microseconds\r
d41bc92c 804 if (ElapsedTime >= mInterestThreshold) {\r
805 // PEIM FILE Handle is the start address of its FFS file that contains its file guid.\r
806 if (mShowId) {\r
47d20b54
MK
807 ShellPrintHiiEx (\r
808 -1,\r
809 -1,\r
810 NULL,\r
811 STRING_TOKEN (STR_DP_PEIM_VARS2),\r
812 mDpHiiHandle,\r
813 TIndex, // 1 based, Which measurement record is being printed\r
814 Measurement.Handle, // file guid\r
815 ElapsedTime,\r
816 Measurement.Identifier\r
817 );\r
d41bc92c 818 } else {\r
47d20b54
MK
819 ShellPrintHiiEx (\r
820 -1,\r
821 -1,\r
822 NULL,\r
823 STRING_TOKEN (STR_DP_PEIM_VARS),\r
824 mDpHiiHandle,\r
825 TIndex, // 1 based, Which measurement record is being printed\r
826 Measurement.Handle, // file guid\r
827 ElapsedTime\r
828 );\r
d41bc92c 829 }\r
830 }\r
47d20b54 831\r
196ccda0
CS
832 if (ShellGetExecutionBreakFlag ()) {\r
833 Status = EFI_ABORTED;\r
834 break;\r
835 }\r
d41bc92c 836 }\r
47d20b54 837\r
196ccda0 838 return Status;\r
d41bc92c 839}\r
840\r
92034c4c 841/**\r
d41bc92c 842 Gather and print global data.\r
92034c4c 843\r
d41bc92c 844 Strips out incomplete or "Execution Phase" records\r
845 Only prints records where Handle is NULL\r
846 Increment TIndex for every record, even skipped ones, so that we have an\r
847 indication of every measurement record taken.\r
92034c4c 848\r
196ccda0
CS
849 @retval EFI_SUCCESS The operation was successful.\r
850 @retval EFI_ABORTED The user aborts the operation.\r
d41bc92c 851**/\r
196ccda0 852EFI_STATUS\r
47d20b54 853ProcessGlobal (\r
d41bc92c 854 VOID\r
47d20b54 855 )\r
d41bc92c 856{\r
47d20b54
MK
857 MEASUREMENT_RECORD Measurement;\r
858 UINT64 Duration;\r
859 UINT64 ElapsedTime;\r
860 EFI_STRING StringPtr;\r
861 UINTN LogEntryKey;\r
862 UINTN Index; // Index, or number, of the measurement record being processed\r
863 EFI_STRING StringPtrUnknown;\r
864 EFI_STATUS Status;\r
196ccda0
CS
865\r
866 Status = EFI_SUCCESS;\r
d41bc92c 867\r
92034c4c 868 StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
47d20b54
MK
869 StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);\r
870 ShellPrintHiiEx (\r
871 -1,\r
872 -1,\r
873 NULL,\r
874 STRING_TOKEN (STR_DP_SECTION_HEADER),\r
875 mDpHiiHandle,\r
876 (StringPtr == NULL) ? StringPtrUnknown : StringPtr\r
877 );\r
d41bc92c 878 FreePool (StringPtr);\r
879 FreePool (StringPtrUnknown);\r
880\r
881 if (mShowId) {\r
92034c4c 882 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION2), mDpHiiHandle);\r
d41bc92c 883 } else {\r
92034c4c 884 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION), mDpHiiHandle);\r
d41bc92c 885 }\r
47d20b54 886\r
92034c4c 887 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);\r
d41bc92c 888\r
47d20b54 889 Index = 1;\r
d41bc92c 890 LogEntryKey = 0;\r
891\r
115eae65 892 while ((LogEntryKey = GetPerformanceMeasurementRecord (\r
d41bc92c 893 LogEntryKey,\r
894 &Measurement.Handle,\r
895 &Measurement.Token,\r
896 &Measurement.Module,\r
897 &Measurement.StartTimeStamp,\r
898 &Measurement.EndTimeStamp,\r
47d20b54
MK
899 &Measurement.Identifier\r
900 )) != 0)\r
d41bc92c 901 {\r
cb4669e0
LE
902 AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString));\r
903 AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));\r
47d20b54 904 mGaugeString[25] = 0;\r
d41bc92c 905 mUnicodeToken[31] = 0;\r
47d20b54
MK
906 if ( !(IsPhase (&Measurement) ||\r
907 IsCorePerf (&Measurement) ||\r
908 (Measurement.EndTimeStamp == 0)\r
909 ))\r
d41bc92c 910 {\r
47d20b54
MK
911 Duration = GetDuration (&Measurement);\r
912 ElapsedTime = DurationInMicroSeconds (Duration);\r
d41bc92c 913 if (ElapsedTime >= mInterestThreshold) {\r
914 if (mShowId) {\r
47d20b54
MK
915 ShellPrintHiiEx (\r
916 -1,\r
917 -1,\r
918 NULL,\r
919 STRING_TOKEN (STR_DP_GLOBAL_VARS2),\r
920 mDpHiiHandle,\r
d41bc92c 921 Index,\r
922 mGaugeString,\r
923 mUnicodeToken,\r
924 ElapsedTime,\r
925 Measurement.Identifier\r
926 );\r
927 } else {\r
47d20b54
MK
928 ShellPrintHiiEx (\r
929 -1,\r
930 -1,\r
931 NULL,\r
932 STRING_TOKEN (STR_DP_GLOBAL_VARS),\r
933 mDpHiiHandle,\r
d41bc92c 934 Index,\r
935 mGaugeString,\r
936 mUnicodeToken,\r
937 ElapsedTime\r
938 );\r
939 }\r
940 }\r
941 }\r
47d20b54 942\r
196ccda0
CS
943 if (ShellGetExecutionBreakFlag ()) {\r
944 Status = EFI_ABORTED;\r
945 break;\r
946 }\r
47d20b54 947\r
d41bc92c 948 Index++;\r
949 }\r
47d20b54 950\r
d0a23f9f 951 return Status;\r
d41bc92c 952}\r
953\r
92034c4c 954/**\r
d41bc92c 955 Gather and print cumulative data.\r
92034c4c 956\r
d41bc92c 957 Traverse the measurement records and:<BR>\r
958 For each record with a Token listed in the CumData array:<BR>\r
959 - Update the instance count and the total, minimum, and maximum durations.\r
960 Finally, print the gathered cumulative statistics.\r
a06795c6 961\r
f16bd394 962 @param[in] CustomCumulativeData A pointer to the custom cumulative data.\r
a06795c6 963\r
d41bc92c 964**/\r
965VOID\r
47d20b54
MK
966ProcessCumulative (\r
967 IN PERF_CUM_DATA *CustomCumulativeData OPTIONAL\r
a06795c6 968 )\r
d41bc92c 969{\r
47d20b54
MK
970 UINT64 AvgDur; // the computed average duration\r
971 UINT64 Dur;\r
972 UINT64 MinDur;\r
973 UINT64 MaxDur;\r
974 EFI_STRING StringPtr;\r
975 UINTN TIndex;\r
976 EFI_STRING StringPtrUnknown;\r
d41bc92c 977\r
92034c4c 978 StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
47d20b54
MK
979 StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL);\r
980 ShellPrintHiiEx (\r
981 -1,\r
982 -1,\r
983 NULL,\r
984 STRING_TOKEN (STR_DP_SECTION_HEADER),\r
985 mDpHiiHandle,\r
986 (StringPtr == NULL) ? StringPtrUnknown : StringPtr\r
987 );\r
d41bc92c 988 FreePool (StringPtr);\r
989 FreePool (StringPtrUnknown);\r
990\r
92034c4c
RN
991 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1), mDpHiiHandle);\r
992 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2), mDpHiiHandle);\r
993 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);\r
d41bc92c 994\r
995 for ( TIndex = 0; TIndex < NumCum; ++TIndex) {\r
996 if (CumData[TIndex].Count != 0) {\r
997 AvgDur = DivU64x32 (CumData[TIndex].Duration, CumData[TIndex].Count);\r
47d20b54
MK
998 AvgDur = DurationInMicroSeconds (AvgDur);\r
999 Dur = DurationInMicroSeconds (CumData[TIndex].Duration);\r
1000 MaxDur = DurationInMicroSeconds (CumData[TIndex].MaxDur);\r
1001 MinDur = DurationInMicroSeconds (CumData[TIndex].MinDur);\r
1002\r
1003 ShellPrintHiiEx (\r
1004 -1,\r
1005 -1,\r
1006 NULL,\r
1007 STRING_TOKEN (STR_DP_CUMULATIVE_STATS),\r
1008 mDpHiiHandle,\r
1009 CumData[TIndex].Name,\r
1010 CumData[TIndex].Count,\r
1011 Dur,\r
1012 AvgDur,\r
1013 MinDur,\r
1014 MaxDur\r
1015 );\r
d41bc92c 1016 }\r
1017 }\r
a06795c6
CS
1018\r
1019 //\r
1020 // Print the custom cumulative data.\r
1021 //\r
1022 if (CustomCumulativeData != NULL) {\r
1023 if (CustomCumulativeData->Count != 0) {\r
1024 AvgDur = DivU64x32 (CustomCumulativeData->Duration, CustomCumulativeData->Count);\r
1025 AvgDur = DurationInMicroSeconds (AvgDur);\r
1026 Dur = DurationInMicroSeconds (CustomCumulativeData->Duration);\r
1027 MaxDur = DurationInMicroSeconds (CustomCumulativeData->MaxDur);\r
1028 MinDur = DurationInMicroSeconds (CustomCumulativeData->MinDur);\r
1029 } else {\r
1030 AvgDur = 0;\r
1031 Dur = 0;\r
1032 MaxDur = 0;\r
1033 MinDur = 0;\r
1034 }\r
47d20b54
MK
1035\r
1036 ShellPrintHiiEx (\r
1037 -1,\r
1038 -1,\r
1039 NULL,\r
1040 STRING_TOKEN (STR_DP_CUMULATIVE_STATS),\r
1041 mDpHiiHandle,\r
1042 CustomCumulativeData->Name,\r
1043 CustomCumulativeData->Count,\r
1044 Dur,\r
1045 AvgDur,\r
1046 MinDur,\r
1047 MaxDur\r
1048 );\r
a06795c6 1049 }\r
d41bc92c 1050}\r