]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Library/UefiDpLib/DpTrace.c
ShellPkg/dp: Convert from NULL class library to Dynamic Command
[mirror_edk2.git] / ShellPkg / Library / UefiDpLib / DpTrace.c
diff --git a/ShellPkg/Library/UefiDpLib/DpTrace.c b/ShellPkg/Library/UefiDpLib/DpTrace.c
deleted file mode 100644 (file)
index 90a71ad..0000000
+++ /dev/null
@@ -1,876 +0,0 @@
-/** @file\r
-  Trace reporting for the Dp utility.\r
-\r
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\r
-  (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
-  This program and the accompanying materials\r
-  are licensed and made available under the terms and conditions of the BSD License\r
-  which accompanies this distribution.  The full text of the license may be found at\r
-  http://opensource.org/licenses/bsd-license.php\r
-\r
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
-**/\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/PeCoffGetEntryPointLib.h>\r
-#include <Library/PerformanceLib.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/HiiLib.h>\r
-#include <Library/PcdLib.h>\r
-\r
-#include <Guid/Performance.h>\r
-\r
-#include "Dp.h"\r
-#include "Literals.h"\r
-#include "DpInternal.h"\r
-\r
-/** \r
-  Collect verbose statistics about the logged performance measurements.\r
-  \r
-  General Summary information for all Trace measurements is gathered and\r
-  stored within the SummaryData structure.  This information is both\r
-  used internally by subsequent reporting functions, and displayed\r
-  at the end of verbose reports.\r
-  \r
-  @pre  The SummaryData and CumData structures must be initialized\r
-        prior to calling this function.\r
-  \r
-  @post The SummaryData and CumData structures contain statistics for the\r
-        current performance logs.\r
-\r
-  @param[in, out] CustomCumulativeData  A pointer to the cumtom cumulative data.\r
-\r
-**/\r
-VOID\r
-GatherStatistics(\r
-  IN OUT PERF_CUM_DATA              *CustomCumulativeData OPTIONAL\r
-  )\r
-{\r
-  MEASUREMENT_RECORD        Measurement;\r
-  UINT64                    Duration;\r
-  UINTN                     LogEntryKey;\r
-  INTN                      TIndex;\r
-\r
-  LogEntryKey = 0;\r
-  while ((LogEntryKey = GetPerformanceMeasurementEx (\r
-                        LogEntryKey,\r
-                        &Measurement.Handle,\r
-                        &Measurement.Token,\r
-                        &Measurement.Module,\r
-                        &Measurement.StartTimeStamp,\r
-                        &Measurement.EndTimeStamp,\r
-                        &Measurement.Identifier)) != 0)\r
-  {\r
-    ++SummaryData.NumTrace;           // Count the number of TRACE Measurement records\r
-    if (Measurement.EndTimeStamp == 0) {\r
-      ++SummaryData.NumIncomplete;    // Count the incomplete records\r
-      continue;\r
-    }\r
-\r
-    if (Measurement.Handle != NULL) {\r
-      ++SummaryData.NumHandles;       // Count the number of measurements with non-NULL handles\r
-    }\r
-\r
-    if (IsPhase( &Measurement)) {\r
-      ++SummaryData.NumSummary;       // Count the number of major phases\r
-    }\r
-    else {  // !IsPhase(...\r
-      if(Measurement.Handle == NULL) {\r
-        ++SummaryData.NumGlobal;\r
-      }\r
-    }\r
-\r
-    if (AsciiStrnCmp (Measurement.Token, ALit_PEIM, PERF_TOKEN_LENGTH) == 0) {\r
-      ++SummaryData.NumPEIMs;         // Count PEIM measurements\r
-    }\r
-\r
-    Duration = GetDuration (&Measurement);\r
-    TIndex = GetCumulativeItem (&Measurement);\r
-    if (TIndex >= 0) {\r
-      CumData[TIndex].Duration += Duration;\r
-      CumData[TIndex].Count++;\r
-      if ( Duration < CumData[TIndex].MinDur ) {\r
-        CumData[TIndex].MinDur = Duration;\r
-      }\r
-      if ( Duration > CumData[TIndex].MaxDur ) {\r
-        CumData[TIndex].MaxDur = Duration;\r
-      }\r
-    }\r
-\r
-    //\r
-    // Collect the data for custom cumulative data.\r
-    //\r
-    if ((CustomCumulativeData != NULL) && (AsciiStrCmp (Measurement.Token, CustomCumulativeData->Name) == 0)) {\r
-      CustomCumulativeData->Duration += Duration;\r
-      CustomCumulativeData->Count++;\r
-      if (Duration < CustomCumulativeData->MinDur) {\r
-        CustomCumulativeData->MinDur = Duration;\r
-      }\r
-      if (Duration > CustomCumulativeData->MaxDur) {\r
-        CustomCumulativeData->MaxDur = Duration;\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-/** \r
-  Gather and print ALL Trace Records.\r
-  \r
-  Displays all "interesting" Trace measurements in order.<BR>\r
-  The number of records displayed is controlled by:\r
-     - records with a duration less than mInterestThreshold microseconds are not displayed.\r
-     - No more than Limit records are displayed.  A Limit of zero will not limit the output.\r
-     - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not\r
-       displayed.\r
-  \r
-  @pre    The mInterestThreshold global variable is set to the shortest duration to be printed.\r
-           The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.\r
-           They must not be in use by a calling function.\r
-  \r
-  @param[in]    Limit       The number of records to print.  Zero is ALL.\r
-  @param[in]    ExcludeFlag TRUE to exclude individual Cumulative items from display.\r
-  \r
-  @retval EFI_SUCCESS           The operation was successful.\r
-  @retval EFI_ABORTED           The user aborts the operation.\r
-  @return Others                from a call to gBS->LocateHandleBuffer().\r
-**/\r
-EFI_STATUS\r
-DumpAllTrace(\r
-  IN UINTN             Limit,\r
-  IN BOOLEAN           ExcludeFlag\r
-  )\r
-{\r
-  MEASUREMENT_RECORD        Measurement;\r
-  UINT64                    ElapsedTime;\r
-  UINT64                    Duration;\r
-  CHAR16                    *IncFlag;\r
-  UINTN                     LogEntryKey;\r
-  UINTN                     Count;\r
-  UINTN                     Index;\r
-  UINTN                     TIndex;\r
-\r
-  EFI_HANDLE                *HandleBuffer;\r
-  UINTN                     HandleCount;\r
-  EFI_STATUS                Status;\r
-  EFI_STRING                StringPtrUnknown;\r
-\r
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
-  IncFlag = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL);\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,\r
-              (IncFlag == NULL) ? StringPtrUnknown : IncFlag);\r
-  FreePool (StringPtrUnknown);\r
-\r
-  // Get Handle information\r
-  //\r
-  Status  = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);\r
-  if (EFI_ERROR (Status)) {\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), gDpHiiHandle, Status);\r
-  }\r
-  else {\r
-    // We have successfully populated the HandleBuffer\r
-    // Display ALL Measurement Records\r
-    //    Up to Limit lines displayed\r
-    //    Display only records with Elapsed times >= mInterestThreshold\r
-    //    Display driver names in Module field for records with Handles.\r
-    //\r
-    if (mShowId) {\r
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR2), gDpHiiHandle);\r
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_DASHES2), gDpHiiHandle);\r
-    } else {\r
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR), gDpHiiHandle);\r
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle);\r
-    }\r
-\r
-    LogEntryKey = 0;\r
-    Count = 0;\r
-    Index = 0;\r
-    while ( WITHIN_LIMIT(Count, Limit) &&\r
-            ((LogEntryKey = GetPerformanceMeasurementEx (\r
-                            LogEntryKey,\r
-                            &Measurement.Handle,\r
-                            &Measurement.Token,\r
-                            &Measurement.Module,\r
-                            &Measurement.StartTimeStamp,\r
-                            &Measurement.EndTimeStamp,\r
-                            &Measurement.Identifier)) != 0)\r
-          )\r
-    {\r
-      ++Index;    // Count every record.  First record is 1.\r
-      ElapsedTime = 0;\r
-      SHELL_FREE_NON_NULL (IncFlag);\r
-      if (Measurement.EndTimeStamp != 0) {\r
-        Duration = GetDuration (&Measurement);\r
-        ElapsedTime = DurationInMicroSeconds ( Duration );\r
-        IncFlag = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL);\r
-      }\r
-      else {\r
-        IncFlag = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_INCOMPLETE), NULL);  // Mark incomplete records\r
-      }\r
-      if (((Measurement.EndTimeStamp != 0) && (ElapsedTime < mInterestThreshold)) ||\r
-          ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))\r
-         ) {      // Ignore "uninteresting" or excluded records\r
-        continue;\r
-      }\r
-      ++Count;    // Count the number of records printed\r
-\r
-      // If Handle is non-zero, see if we can determine a name for the driver\r
-      AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString)); // Use Module by default\r
-      AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));\r
-      if (Measurement.Handle != NULL) {\r
-        // See if the Handle is in the HandleBuffer\r
-        for (TIndex = 0; TIndex < HandleCount; TIndex++) {\r
-          if (Measurement.Handle == HandleBuffer[TIndex]) {\r
-            DpGetNameFromHandle (HandleBuffer[TIndex]);\r
-            break;\r
-          }\r
-        }\r
-      }\r
-\r
-      if (AsciiStrnCmp (Measurement.Token, ALit_PEIM, PERF_TOKEN_LENGTH) == 0) {\r
-        UnicodeSPrint (mGaugeString, sizeof (mGaugeString), L"%g", Measurement.Handle);\r
-      }\r
-\r
-      // Ensure that the argument strings are not too long.\r
-      mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;\r
-      mUnicodeToken[13] = 0;\r
-\r
-      if (mShowId) {\r
-        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS2), gDpHiiHandle,\r
-          Index,      // 1 based, Which measurement record is being printed\r
-          IncFlag,\r
-          Measurement.Handle,\r
-          mGaugeString,\r
-          mUnicodeToken,\r
-          ElapsedTime,\r
-          Measurement.Identifier\r
-        );\r
-      } else {\r
-        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS), gDpHiiHandle,\r
-          Index,      // 1 based, Which measurement record is being printed\r
-          IncFlag,\r
-          Measurement.Handle,\r
-          mGaugeString,\r
-          mUnicodeToken,\r
-          ElapsedTime\r
-        );\r
-      }\r
-      if (ShellGetExecutionBreakFlag ()) {\r
-        Status = EFI_ABORTED;\r
-        break;\r
-      }\r
-    }\r
-  }\r
-  if (HandleBuffer != NULL) {\r
-    FreePool (HandleBuffer);\r
-  }\r
-  SHELL_FREE_NON_NULL (IncFlag);\r
-\r
-  return Status;\r
-}\r
-\r
-/** \r
-  Gather and print Raw Trace Records.\r
-  \r
-  All Trace measurements with a duration greater than or equal to\r
-  mInterestThreshold are printed without interpretation.\r
-  \r
-  The number of records displayed is controlled by:\r
-     - records with a duration less than mInterestThreshold microseconds are not displayed.\r
-     - No more than Limit records are displayed.  A Limit of zero will not limit the output.\r
-     - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not\r
-       displayed.\r
-  \r
-  @pre    The mInterestThreshold global variable is set to the shortest duration to be printed.\r
-  \r
-  @param[in]    Limit       The number of records to print.  Zero is ALL.\r
-  @param[in]    ExcludeFlag TRUE to exclude individual Cumulative items from display.\r
-\r
-  @retval EFI_SUCCESS           The operation was successful.\r
-  @retval EFI_ABORTED           The user aborts the operation.\r
-**/\r
-EFI_STATUS\r
-DumpRawTrace(\r
-  IN UINTN          Limit,\r
-  IN BOOLEAN        ExcludeFlag\r
-  )\r
-{\r
-  MEASUREMENT_RECORD        Measurement;\r
-  UINT64                    ElapsedTime;\r
-  UINT64                    Duration;\r
-  UINTN                     LogEntryKey;\r
-  UINTN                     Count;\r
-  UINTN                     Index;\r
-\r
-  EFI_STRING    StringPtr;\r
-  EFI_STRING    StringPtrUnknown;\r
-  EFI_STATUS    Status;\r
-\r
-  Status = EFI_SUCCESS;\r
-\r
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);  \r
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,\r
-              (StringPtr == NULL) ? StringPtrUnknown : StringPtr);\r
-  FreePool (StringPtr);\r
-  FreePool (StringPtrUnknown);\r
-\r
-  if (mShowId) {\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR2), gDpHiiHandle);\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES2), gDpHiiHandle);\r
-  } else {\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR), gDpHiiHandle);\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES), gDpHiiHandle);\r
-  }\r
-\r
-  LogEntryKey = 0;\r
-  Count = 0;\r
-  Index = 0;\r
-  while ( WITHIN_LIMIT(Count, Limit) &&\r
-          ((LogEntryKey = GetPerformanceMeasurementEx (\r
-                          LogEntryKey,\r
-                          &Measurement.Handle,\r
-                          &Measurement.Token,\r
-                          &Measurement.Module,\r
-                          &Measurement.StartTimeStamp,\r
-                          &Measurement.EndTimeStamp,\r
-                          &Measurement.Identifier)) != 0)\r
-        )\r
-  {\r
-    ++Index;    // Count every record.  First record is 1.\r
-    ElapsedTime = 0;\r
-    if (Measurement.EndTimeStamp != 0) {\r
-      Duration = GetDuration (&Measurement);\r
-      ElapsedTime = DurationInMicroSeconds ( Duration );\r
-    }\r
-    if ((ElapsedTime < mInterestThreshold)                 ||\r
-        ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))\r
-        ) { // Ignore "uninteresting" or Excluded records\r
-      continue;\r
-    }\r
-    ++Count;    // Count the number of records printed\r
-\r
-    if (mShowId) {\r
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS2), gDpHiiHandle,\r
-        Index,      // 1 based, Which measurement record is being printed\r
-        Measurement.Handle,\r
-        Measurement.StartTimeStamp,\r
-        Measurement.EndTimeStamp,\r
-        Measurement.Token,\r
-        Measurement.Module,\r
-        Measurement.Identifier\r
-      );\r
-    } else {\r
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS), gDpHiiHandle,\r
-        Index,      // 1 based, Which measurement record is being printed\r
-        Measurement.Handle,\r
-        Measurement.StartTimeStamp,\r
-        Measurement.EndTimeStamp,\r
-        Measurement.Token,\r
-        Measurement.Module\r
-      );\r
-    }\r
-    if (ShellGetExecutionBreakFlag ()) {\r
-      Status = EFI_ABORTED;\r
-      break;\r
-    }\r
-  }\r
-  return Status;\r
-}\r
-\r
-/** \r
-  Gather and print Major Phase metrics.\r
-  \r
-**/\r
-VOID\r
-ProcessPhases(\r
-  VOID\r
-  )\r
-{\r
-  MEASUREMENT_RECORD        Measurement;\r
-  UINT64                    BdsTimeoutValue;\r
-  UINT64                    SecTime;\r
-  UINT64                    PeiTime;\r
-  UINT64                    DxeTime;\r
-  UINT64                    BdsTime;\r
-  UINT64                    ElapsedTime;\r
-  UINT64                    Duration;\r
-  UINT64                    Total;\r
-  EFI_STRING                StringPtr;\r
-  UINTN                     LogEntryKey;\r
-  EFI_STRING                StringPtrUnknown;\r
-\r
-  BdsTimeoutValue = 0;\r
-  SecTime         = 0;\r
-  PeiTime         = 0;\r
-  DxeTime         = 0;\r
-  BdsTime         = 0;\r
-  //\r
-  // Get Execution Phase Statistics\r
-  //\r
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);   \r
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL);\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,\r
-              (StringPtr == NULL) ? StringPtrUnknown : StringPtr);\r
-  FreePool (StringPtr);\r
-  FreePool (StringPtrUnknown);\r
-\r
-  LogEntryKey = 0;\r
-  while ((LogEntryKey = GetPerformanceMeasurementEx (\r
-                          LogEntryKey,\r
-                          &Measurement.Handle,\r
-                          &Measurement.Token,\r
-                          &Measurement.Module,\r
-                          &Measurement.StartTimeStamp,\r
-                          &Measurement.EndTimeStamp,\r
-                          &Measurement.Identifier)) != 0)\r
-  {\r
-    if (Measurement.EndTimeStamp == 0) { // Skip "incomplete" records\r
-      continue;\r
-    }\r
-    Duration = GetDuration (&Measurement);\r
-    if (   Measurement.Handle != NULL\r
-        && (AsciiStrnCmp (Measurement.Token, ALit_BdsTO, PERF_TOKEN_LENGTH) == 0)\r
-       )\r
-    {\r
-      BdsTimeoutValue = Duration;\r
-    } else if (AsciiStrnCmp (Measurement.Token, ALit_SEC, PERF_TOKEN_LENGTH) == 0) {\r
-      SecTime     = Duration;\r
-    } else if (AsciiStrnCmp (Measurement.Token, ALit_PEI, PERF_TOKEN_LENGTH) == 0) {\r
-      PeiTime     = Duration;\r
-    } else if (AsciiStrnCmp (Measurement.Token, ALit_DXE, PERF_TOKEN_LENGTH) == 0) {\r
-      DxeTime      = Duration;\r
-    } else if (AsciiStrnCmp (Measurement.Token, ALit_BDS, PERF_TOKEN_LENGTH) == 0) {\r
-      BdsTime      = Duration;\r
-    }\r
-  }\r
-\r
-  Total = 0;\r
-\r
-  // print SEC phase duration time\r
-  //\r
-  if (SecTime > 0) {\r
-    ElapsedTime = DurationInMicroSeconds ( SecTime );     // Calculate elapsed time in microseconds\r
-    Total += DivU64x32 (ElapsedTime, 1000);   // Accumulate time in milliseconds\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SEC_PHASE), gDpHiiHandle, ElapsedTime);\r
-  }\r
-\r
-  // print PEI phase duration time\r
-  //\r
-  if (PeiTime > 0) {\r
-    ElapsedTime = DivU64x32 (\r
-                    PeiTime,\r
-                    (UINT32)TimerInfo.Frequency\r
-                    );\r
-    Total += ElapsedTime;\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), gDpHiiHandle, ALit_PEI, ElapsedTime);\r
-  }\r
-\r
-  // print DXE phase duration time\r
-  //\r
-  if (DxeTime > 0) {\r
-    ElapsedTime = DivU64x32 (\r
-                    DxeTime,\r
-                    (UINT32)TimerInfo.Frequency\r
-                    );\r
-    Total += ElapsedTime;\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), gDpHiiHandle, ALit_DXE, ElapsedTime);\r
-  }\r
-\r
-  // print BDS phase duration time\r
-  //\r
-  if (BdsTime > 0) {\r
-    ElapsedTime = DivU64x32 (\r
-                    BdsTime,\r
-                    (UINT32)TimerInfo.Frequency\r
-                    );\r
-    Total += ElapsedTime;\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), gDpHiiHandle, ALit_BDS, ElapsedTime);\r
-  }\r
-\r
-  if (BdsTimeoutValue > 0) {\r
-    ElapsedTime = DivU64x32 (\r
-                    BdsTimeoutValue,\r
-                    (UINT32)TimerInfo.Frequency\r
-                    );\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_BDSTO), gDpHiiHandle, ALit_BdsTO, ElapsedTime);\r
-  }\r
-\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOTAL_DURATION), gDpHiiHandle, Total);\r
-}\r
-\r
-/** \r
-  Gather and print Handle data.\r
-  \r
-  @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items from display.\r
-  \r
-  @retval EFI_SUCCESS             The operation was successful.\r
-  @retval EFI_ABORTED             The user aborts the operation.\r
-  @return Others                  from a call to gBS->LocateHandleBuffer().\r
-**/\r
-EFI_STATUS\r
-ProcessHandles(\r
-  IN BOOLEAN      ExcludeFlag\r
-  )\r
-{\r
-  MEASUREMENT_RECORD        Measurement;\r
-  UINT64                    ElapsedTime;\r
-  UINT64                    Duration;\r
-  EFI_HANDLE                *HandleBuffer;\r
-  EFI_STRING                StringPtr;\r
-  UINTN                     Index;\r
-  UINTN                     LogEntryKey;\r
-  UINTN                     Count;\r
-  UINTN                     HandleCount;\r
-  EFI_STATUS                Status;\r
-  EFI_STRING                StringPtrUnknown;\r
-\r
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);  \r
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL);\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,\r
-              (StringPtr == NULL) ? StringPtrUnknown : StringPtr);\r
-  FreePool (StringPtr);\r
-  FreePool (StringPtrUnknown);\r
-\r
-  Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);\r
-  if (EFI_ERROR (Status)) {\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), gDpHiiHandle, Status);\r
-  }\r
-  else {\r
-#if DP_DEBUG == 2\r
-    Print (L"There are %,d Handles defined.\n", (Size / sizeof(HandleBuffer[0])));\r
-#endif\r
-\r
-    if (mShowId) {\r
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION2), gDpHiiHandle);\r
-    } else {\r
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION), gDpHiiHandle);\r
-    }\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle);\r
-\r
-    LogEntryKey = 0;\r
-    Count   = 0;\r
-    while ((LogEntryKey = GetPerformanceMeasurementEx (\r
-                            LogEntryKey,\r
-                            &Measurement.Handle,\r
-                            &Measurement.Token,\r
-                            &Measurement.Module,\r
-                            &Measurement.StartTimeStamp,\r
-                            &Measurement.EndTimeStamp,\r
-                            &Measurement.Identifier)) != 0)\r
-    {\r
-      Count++;\r
-      Duration = GetDuration (&Measurement);\r
-      ElapsedTime = DurationInMicroSeconds ( Duration );\r
-      if ((ElapsedTime < mInterestThreshold)                 ||\r
-          (Measurement.EndTimeStamp == 0)                    ||\r
-          (Measurement.Handle == NULL)                       ||\r
-          ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))\r
-         ) { // Ignore "uninteresting" or excluded records\r
-        continue;\r
-      }\r
-      mGaugeString[0] = 0;    // Empty driver name by default\r
-      AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));\r
-      // See if the Handle is in the HandleBuffer\r
-      for (Index = 0; Index < HandleCount; Index++) {\r
-        if (Measurement.Handle == HandleBuffer[Index]) {\r
-          DpGetNameFromHandle (HandleBuffer[Index]); // Name is put into mGaugeString\r
-          break;\r
-        }\r
-      }\r
-      // Ensure that the argument strings are not too long.\r
-      mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;\r
-      mUnicodeToken[11] = 0;\r
-      if (mGaugeString[0] != 0) {\r
-        // Display the record if it has a valid handle.\r
-        if (mShowId) {\r
-          ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS2), gDpHiiHandle,\r
-            Count,      // 1 based, Which measurement record is being printed\r
-            Index + 1,  // 1 based, Which handle is being printed\r
-            mGaugeString,\r
-            mUnicodeToken,\r
-            ElapsedTime,\r
-            Measurement.Identifier\r
-          );\r
-        } else {\r
-          ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS), gDpHiiHandle,\r
-            Count,      // 1 based, Which measurement record is being printed\r
-            Index + 1,  // 1 based, Which handle is being printed\r
-            mGaugeString,\r
-            mUnicodeToken,\r
-            ElapsedTime\r
-          );\r
-        }\r
-      }\r
-      if (ShellGetExecutionBreakFlag ()) {\r
-        Status = EFI_ABORTED;\r
-        break;\r
-      }\r
-    }\r
-  }\r
-  if (HandleBuffer != NULL) {\r
-    FreePool (HandleBuffer);\r
-  }\r
-  return Status;\r
-}\r
-\r
-/** \r
-  Gather and print PEIM data.\r
-  \r
-  Only prints complete PEIM records\r
-  \r
-  @retval EFI_SUCCESS           The operation was successful.\r
-  @retval EFI_ABORTED           The user aborts the operation.\r
-**/\r
-EFI_STATUS\r
-ProcessPeims(\r
-  VOID\r
-)\r
-{\r
-  MEASUREMENT_RECORD        Measurement;\r
-  UINT64                    Duration;\r
-  UINT64                    ElapsedTime;\r
-  EFI_STRING                StringPtr;\r
-  UINTN                     LogEntryKey;\r
-  UINTN                     TIndex;\r
-  EFI_STRING                StringPtrUnknown;\r
-  EFI_STATUS                Status;\r
-\r
-  Status = EFI_SUCCESS;\r
-\r
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);  \r
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,\r
-              (StringPtr == NULL) ? StringPtrUnknown : StringPtr);\r
-  FreePool (StringPtr);\r
-  FreePool (StringPtrUnknown);\r
-\r
-  if (mShowId) {\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION2), gDpHiiHandle);\r
-  } else {\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION), gDpHiiHandle);\r
-  }\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle);\r
-  TIndex  = 0;\r
-  LogEntryKey = 0;\r
-  while ((LogEntryKey = GetPerformanceMeasurementEx (\r
-                          LogEntryKey,\r
-                          &Measurement.Handle,\r
-                          &Measurement.Token,\r
-                          &Measurement.Module,\r
-                          &Measurement.StartTimeStamp,\r
-                          &Measurement.EndTimeStamp,\r
-                          &Measurement.Identifier)) != 0)\r
-  {\r
-    TIndex++;\r
-    if ((Measurement.EndTimeStamp == 0) ||\r
-        (AsciiStrnCmp (Measurement.Token, ALit_PEIM, PERF_TOKEN_LENGTH) != 0)\r
-       ) {\r
-      continue;\r
-    }\r
-\r
-    Duration = GetDuration (&Measurement);\r
-    ElapsedTime = DurationInMicroSeconds ( Duration );  // Calculate elapsed time in microseconds\r
-    if (ElapsedTime >= mInterestThreshold) {\r
-      // PEIM FILE Handle is the start address of its FFS file that contains its file guid.\r
-      if (mShowId) {\r
-        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS2), gDpHiiHandle,\r
-              TIndex,   // 1 based, Which measurement record is being printed\r
-              Measurement.Handle,  // base address\r
-              Measurement.Handle,  // file guid\r
-              ElapsedTime,\r
-              Measurement.Identifier\r
-        );\r
-      } else {\r
-        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS), gDpHiiHandle,\r
-              TIndex,   // 1 based, Which measurement record is being printed\r
-              Measurement.Handle,  // base address\r
-              Measurement.Handle,  // file guid\r
-              ElapsedTime\r
-        );\r
-      }\r
-    }\r
-    if (ShellGetExecutionBreakFlag ()) {\r
-      Status = EFI_ABORTED;\r
-      break;\r
-    }\r
-  }\r
-  return Status;\r
-}\r
-\r
-/** \r
-  Gather and print global data.\r
-  \r
-  Strips out incomplete or "Execution Phase" records\r
-  Only prints records where Handle is NULL\r
-  Increment TIndex for every record, even skipped ones, so that we have an\r
-  indication of every measurement record taken.\r
-  \r
-  @retval EFI_SUCCESS           The operation was successful.\r
-  @retval EFI_ABORTED           The user aborts the operation.\r
-**/\r
-EFI_STATUS\r
-ProcessGlobal(\r
-  VOID\r
-)\r
-{\r
-  MEASUREMENT_RECORD        Measurement;\r
-  UINT64                    Duration;\r
-  UINT64                    ElapsedTime;\r
-  EFI_STRING                StringPtr;\r
-  UINTN                     LogEntryKey;\r
-  UINTN                     Index;        // Index, or number, of the measurement record being processed\r
-  EFI_STRING                StringPtrUnknown;\r
-  EFI_STATUS                Status;\r
-\r
-  Status = EFI_SUCCESS;\r
-\r
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);  \r
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,\r
-              (StringPtr == NULL) ? StringPtrUnknown: StringPtr);\r
-  FreePool (StringPtr);\r
-  FreePool (StringPtrUnknown);\r
-\r
-  if (mShowId) {\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION2), gDpHiiHandle);\r
-  } else {\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION), gDpHiiHandle);\r
-  }\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle);\r
-\r
-  Index = 1;\r
-  LogEntryKey = 0;\r
-\r
-  while ((LogEntryKey = GetPerformanceMeasurementEx (\r
-                          LogEntryKey,\r
-                          &Measurement.Handle,\r
-                          &Measurement.Token,\r
-                          &Measurement.Module,\r
-                          &Measurement.StartTimeStamp,\r
-                          &Measurement.EndTimeStamp,\r
-                          &Measurement.Identifier)) != 0)\r
-  {\r
-    AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString));\r
-    AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));\r
-    mGaugeString[25] = 0;\r
-    mUnicodeToken[31] = 0;\r
-    if ( ! ( IsPhase( &Measurement)  ||\r
-        (Measurement.Handle != NULL)      ||\r
-        (Measurement.EndTimeStamp == 0)\r
-        ))\r
-    {\r
-      Duration = GetDuration (&Measurement);\r
-      ElapsedTime = DurationInMicroSeconds ( Duration );\r
-      if (ElapsedTime >= mInterestThreshold) {\r
-        if (mShowId) {\r
-          ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS2), gDpHiiHandle,\r
-            Index,\r
-            mGaugeString,\r
-            mUnicodeToken,\r
-            ElapsedTime,\r
-            Measurement.Identifier\r
-            );\r
-        } else {\r
-           ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS), gDpHiiHandle,\r
-            Index,\r
-            mGaugeString,\r
-            mUnicodeToken,\r
-            ElapsedTime\r
-            );\r
-        }\r
-      }\r
-    }\r
-    if (ShellGetExecutionBreakFlag ()) {\r
-      Status = EFI_ABORTED;\r
-      break;\r
-    }\r
-    Index++;\r
-  }\r
-  return Status;\r
-}\r
-\r
-/** \r
-  Gather and print cumulative data.\r
-  \r
-  Traverse the measurement records and:<BR>\r
-  For each record with a Token listed in the CumData array:<BR>\r
-     - Update the instance count and the total, minimum, and maximum durations.\r
-  Finally, print the gathered cumulative statistics.\r
-\r
-  @param[in]    CustomCumulativeData  A pointer to the cumtom cumulative data.\r
-\r
-**/\r
-VOID\r
-ProcessCumulative(\r
-  IN PERF_CUM_DATA                  *CustomCumulativeData OPTIONAL\r
-  )\r
-{\r
-  UINT64                    AvgDur;         // the computed average duration\r
-  UINT64                    Dur;\r
-  UINT64                    MinDur;\r
-  UINT64                    MaxDur;\r
-  EFI_STRING                StringPtr;\r
-  UINTN                     TIndex;\r
-  EFI_STRING                StringPtrUnknown;\r
-\r
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);  \r
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL);\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,\r
-              (StringPtr == NULL) ? StringPtrUnknown: StringPtr);\r
-  FreePool (StringPtr);\r
-  FreePool (StringPtrUnknown);\r
-\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1), gDpHiiHandle);\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2), gDpHiiHandle);\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle);\r
-\r
-  for ( TIndex = 0; TIndex < NumCum; ++TIndex) {\r
-    if (CumData[TIndex].Count != 0) {\r
-      AvgDur = DivU64x32 (CumData[TIndex].Duration, CumData[TIndex].Count);\r
-      AvgDur = DurationInMicroSeconds(AvgDur);\r
-      Dur    = DurationInMicroSeconds(CumData[TIndex].Duration);\r
-      MaxDur = DurationInMicroSeconds(CumData[TIndex].MaxDur);\r
-      MinDur = DurationInMicroSeconds(CumData[TIndex].MinDur);\r
-    \r
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), gDpHiiHandle,\r
-                  CumData[TIndex].Name,\r
-                  CumData[TIndex].Count,\r
-                  Dur,\r
-                  AvgDur,\r
-                  MinDur,\r
-                  MaxDur\r
-                 );\r
-    }\r
-  }\r
-\r
-  //\r
-  // Print the custom cumulative data.\r
-  //\r
-  if (CustomCumulativeData != NULL) {\r
-    if (CustomCumulativeData->Count != 0) {\r
-      AvgDur = DivU64x32 (CustomCumulativeData->Duration, CustomCumulativeData->Count);\r
-      AvgDur = DurationInMicroSeconds (AvgDur);\r
-      Dur    = DurationInMicroSeconds (CustomCumulativeData->Duration);\r
-      MaxDur = DurationInMicroSeconds (CustomCumulativeData->MaxDur);\r
-      MinDur = DurationInMicroSeconds (CustomCumulativeData->MinDur);\r
-    } else {\r
-      AvgDur = 0;\r
-      Dur    = 0;\r
-      MaxDur = 0;\r
-      MinDur = 0;\r
-    }\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), gDpHiiHandle,\r
-                CustomCumulativeData->Name,\r
-                CustomCumulativeData->Count,\r
-                Dur,\r
-                AvgDur,\r
-                MinDur,\r
-                MaxDur\r
-                );\r
-  }\r
-}\r