]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/dp: Convert from NULL class library to Dynamic Command
authorRuiyu Ni <ruiyu.ni@intel.com>
Fri, 24 Nov 2017 09:26:24 +0000 (17:26 +0800)
committerRuiyu Ni <ruiyu.ni@intel.com>
Tue, 28 Nov 2017 05:22:35 +0000 (13:22 +0800)
UEFI Shell spec defines Shell Dynamic Command protocol which is just
for the purpose to extend internal command.
So dp command is changed from NULL class library to be a driver
producing DynamicCommand protocol.

The guideline is:
1. Only use NULL class library for Shell spec defined commands.
2. New commands can be provided as not only a standalone application
   but also a dynamic command. So it can be used either as an
   internal command, but also as a standalone application.

DpApp.inf is to provide a standalone application.
DpDynamicCommand.inf is to provide a standalone driver producing
Dynamic Command protocol.

Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
29 files changed:
ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c [new file with mode: 0644]
ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h [new file with mode: 0644]
ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni [new file with mode: 0644]
ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c [new file with mode: 0644]
ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf [new file with mode: 0644]
ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.c [new file with mode: 0644]
ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf [new file with mode: 0644]
ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h [new file with mode: 0644]
ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c [new file with mode: 0644]
ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c [new file with mode: 0644]
ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c [new file with mode: 0644]
ShellPkg/DynamicCommand/DpDynamicCommand/Literals.c [new file with mode: 0644]
ShellPkg/DynamicCommand/DpDynamicCommand/Literals.h [new file with mode: 0644]
ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h [new file with mode: 0644]
ShellPkg/Library/UefiDpLib/Dp.c [deleted file]
ShellPkg/Library/UefiDpLib/Dp.h [deleted file]
ShellPkg/Library/UefiDpLib/DpInternal.h [deleted file]
ShellPkg/Library/UefiDpLib/DpProfile.c [deleted file]
ShellPkg/Library/UefiDpLib/DpTrace.c [deleted file]
ShellPkg/Library/UefiDpLib/DpUtilities.c [deleted file]
ShellPkg/Library/UefiDpLib/Literals.c [deleted file]
ShellPkg/Library/UefiDpLib/Literals.h [deleted file]
ShellPkg/Library/UefiDpLib/PerformanceTokens.h [deleted file]
ShellPkg/Library/UefiDpLib/Readme.txt [deleted file]
ShellPkg/Library/UefiDpLib/UefiDpLib.c [deleted file]
ShellPkg/Library/UefiDpLib/UefiDpLib.h [deleted file]
ShellPkg/Library/UefiDpLib/UefiDpLib.inf [deleted file]
ShellPkg/Library/UefiDpLib/UefiDpLib.uni [deleted file]
ShellPkg/ShellPkg.dsc

diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
new file mode 100644 (file)
index 0000000..3ecc753
--- /dev/null
@@ -0,0 +1,438 @@
+/** @file\r
+  Shell command for Displaying Performance Metrics.\r
+\r
+  The Dp command reads performance data and presents it in several\r
+  different formats depending upon the needs of the user.  Both\r
+  Trace and Measured Profiling information is processed and presented.\r
+\r
+  Dp uses the "PerformanceLib" to read the measurement records.\r
+  The "TimerLib" provides information about the timer, such as frequency,\r
+  beginning, and ending counter values.\r
+  Measurement records contain identifying information (Handle, Token, Module)\r
+  and start and end time values.\r
+  Dp uses this information to group records in different ways.  It also uses\r
+  timer information to calculate elapsed time for each measurement.\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 "PerformanceTokens.h"\r
+#include "Dp.h"\r
+#include "Literals.h"\r
+#include "DpInternal.h"\r
+\r
+EFI_HANDLE   mDpHiiHandle;\r
+\r
+//\r
+/// Module-Global Variables\r
+///@{\r
+CHAR16           mGaugeString[DP_GAUGE_STRING_LENGTH + 1];\r
+CHAR16           mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];\r
+UINT64           mInterestThreshold;\r
+BOOLEAN          mShowId = FALSE;\r
+\r
+PERF_SUMMARY_DATA SummaryData = { 0 };    ///< Create the SummaryData structure and init. to ZERO.\r
+\r
+/// Timer Specific Information.\r
+TIMER_INFO TimerInfo;\r
+\r
+/// Items for which to gather cumulative statistics.\r
+PERF_CUM_DATA CumData[] = {\r
+  PERF_INIT_CUM_DATA (LOAD_IMAGE_TOK),\r
+  PERF_INIT_CUM_DATA (START_IMAGE_TOK),\r
+  PERF_INIT_CUM_DATA (DRIVERBINDING_START_TOK),\r
+  PERF_INIT_CUM_DATA (DRIVERBINDING_SUPPORT_TOK)\r
+};\r
+\r
+/// Number of items for which we are gathering cumulative statistics.\r
+UINT32 const      NumCum = sizeof(CumData) / sizeof(PERF_CUM_DATA);\r
+\r
+STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r
+  {L"-v", TypeFlag},   // -v   Verbose Mode\r
+  {L"-A", TypeFlag},   // -A   All, Cooked\r
+  {L"-R", TypeFlag},   // -R   RAW All\r
+  {L"-s", TypeFlag},   // -s   Summary\r
+#if PROFILING_IMPLEMENTED\r
+  {L"-P", TypeFlag},   // -P   Dump Profile Data\r
+  {L"-T", TypeFlag},   // -T   Dump Trace Data\r
+#endif // PROFILING_IMPLEMENTED\r
+  {L"-x", TypeFlag},   // -x   eXclude Cumulative Items\r
+  {L"-i", TypeFlag},   // -i   Display Identifier\r
+  {L"-c", TypeValue},  // -c   Display cumulative data.\r
+  {L"-n", TypeValue},  // -n # Number of records to display for A and R\r
+  {L"-t", TypeValue},  // -t # Threshold of interest\r
+  {NULL, TypeMax}\r
+  };\r
+\r
+///@}\r
+\r
+/**\r
+   Display the trailing Verbose information.\r
+**/\r
+VOID\r
+DumpStatistics( void )\r
+{\r
+  EFI_STRING                StringPtr;\r
+  EFI_STRING                StringPtrUnknown;\r
+  StringPtr        = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_STATISTICS), NULL);\r
+  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,\r
+              (StringPtr == NULL) ? StringPtrUnknown : StringPtr);\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMTRACE), mDpHiiHandle,      SummaryData.NumTrace);\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMINCOMPLETE), mDpHiiHandle, SummaryData.NumIncomplete);\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPHASES), mDpHiiHandle,     SummaryData.NumSummary);\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMHANDLES), mDpHiiHandle,    SummaryData.NumHandles, SummaryData.NumTrace - SummaryData.NumHandles);\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPEIMS), mDpHiiHandle,      SummaryData.NumPEIMs);\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMGLOBALS), mDpHiiHandle,    SummaryData.NumGlobal);\r
+#if PROFILING_IMPLEMENTED\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPROFILE), mDpHiiHandle,    SummaryData.NumProfile);\r
+#endif // PROFILING_IMPLEMENTED\r
+  SHELL_FREE_NON_NULL (StringPtr);\r
+  SHELL_FREE_NON_NULL (StringPtrUnknown);\r
+}\r
+\r
+/**\r
+  Initialize the cumulative data.\r
+\r
+**/\r
+VOID\r
+InitCumulativeData (\r
+  VOID\r
+  )\r
+{\r
+  UINTN                             Index;\r
+\r
+  for (Index = 0; Index < NumCum; ++Index) {\r
+    CumData[Index].Count = 0;\r
+    CumData[Index].MinDur = PERF_MAXDUR;\r
+    CumData[Index].MaxDur = 0;\r
+    CumData[Index].Duration = 0;\r
+  }\r
+}\r
+\r
+/**\r
+  Dump performance data.\r
+  \r
+  @param[in]  ImageHandle     The image handle.\r
+  @param[in]  SystemTable     The system table.\r
+  \r
+  @retval SHELL_SUCCESS            Command completed successfully.\r
+  @retval SHELL_INVALID_PARAMETER  Command usage error.\r
+  @retval SHELL_ABORTED            The user aborts the operation.\r
+  @retval value                    Unknown error.\r
+**/\r
+SHELL_STATUS\r
+RunDp (\r
+  IN EFI_HANDLE               ImageHandle,\r
+  IN EFI_SYSTEM_TABLE         *SystemTable\r
+  )\r
+{\r
+  LIST_ENTRY                *ParamPackage;\r
+  CONST CHAR16              *CmdLineArg;\r
+  EFI_STATUS                Status;\r
+\r
+  PERFORMANCE_PROPERTY      *PerformanceProperty;\r
+  UINTN                     Number2Display;\r
+\r
+  EFI_STRING                StringPtr;\r
+  BOOLEAN                   SummaryMode;\r
+  BOOLEAN                   VerboseMode;\r
+  BOOLEAN                   AllMode;\r
+  BOOLEAN                   RawMode;\r
+  BOOLEAN                   TraceMode;\r
+  BOOLEAN                   ProfileMode;\r
+  BOOLEAN                   ExcludeMode;\r
+  BOOLEAN                   CumulativeMode;\r
+  CONST CHAR16              *CustomCumulativeToken;\r
+  PERF_CUM_DATA             *CustomCumulativeData;\r
+  UINTN                     NameSize;\r
+  SHELL_STATUS              ShellStatus;\r
+\r
+  StringPtr   = NULL;\r
+  SummaryMode = FALSE;\r
+  VerboseMode = FALSE;\r
+  AllMode     = FALSE;\r
+  RawMode     = FALSE;\r
+  TraceMode   = FALSE;\r
+  ProfileMode = FALSE;\r
+  ExcludeMode = FALSE;\r
+  CumulativeMode = FALSE;\r
+  CustomCumulativeData = NULL;\r
+  ShellStatus = SHELL_SUCCESS;\r
+\r
+  //\r
+  // initialize the shell lib (we must be in non-auto-init...)\r
+  //\r
+  Status = ShellInitialize();\r
+  ASSERT_EFI_ERROR(Status);\r
+\r
+  //\r
+  // Process Command Line arguments\r
+  //\r
+  Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE);\r
+  if (EFI_ERROR(Status)) {\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_ARG), mDpHiiHandle);\r
+    return SHELL_INVALID_PARAMETER;\r
+  }\r
+\r
+  //\r
+  // Boolean options\r
+  //\r
+  VerboseMode = ShellCommandLineGetFlag (ParamPackage, L"-v");\r
+  SummaryMode = (BOOLEAN) (ShellCommandLineGetFlag (ParamPackage, L"-S") || ShellCommandLineGetFlag (ParamPackage, L"-s"));\r
+  AllMode     = ShellCommandLineGetFlag (ParamPackage, L"-A");\r
+  RawMode     = ShellCommandLineGetFlag (ParamPackage, L"-R");\r
+#if PROFILING_IMPLEMENTED\r
+  TraceMode   = ShellCommandLineGetFlag (ParamPackage, L"-T");\r
+  ProfileMode = ShellCommandLineGetFlag (ParamPackage, L"-P");\r
+#endif  // PROFILING_IMPLEMENTED\r
+  ExcludeMode = ShellCommandLineGetFlag (ParamPackage, L"-x");\r
+  mShowId     = ShellCommandLineGetFlag (ParamPackage, L"-i");\r
+  CumulativeMode = ShellCommandLineGetFlag (ParamPackage, L"-c");\r
+\r
+  // Options with Values\r
+  CmdLineArg  = ShellCommandLineGetValue (ParamPackage, L"-n");\r
+  if (CmdLineArg == NULL) {\r
+    Number2Display = DEFAULT_DISPLAYCOUNT;\r
+  } else {\r
+    Number2Display = StrDecimalToUintn(CmdLineArg);\r
+    if (Number2Display == 0) {\r
+      Number2Display = MAXIMUM_DISPLAYCOUNT;\r
+    }\r
+  }\r
+\r
+  CmdLineArg  = ShellCommandLineGetValue (ParamPackage, L"-t");\r
+  if (CmdLineArg == NULL) {\r
+    mInterestThreshold = DEFAULT_THRESHOLD;  // 1ms := 1,000 us\r
+  } else {\r
+    mInterestThreshold = StrDecimalToUint64(CmdLineArg);\r
+  }\r
+\r
+  // Handle Flag combinations and default behaviors\r
+  // If both TraceMode and ProfileMode are FALSE, set them both to TRUE\r
+  if ((! TraceMode) && (! ProfileMode)) {\r
+    TraceMode   = TRUE;\r
+#if PROFILING_IMPLEMENTED\r
+    ProfileMode = TRUE;\r
+#endif  // PROFILING_IMPLEMENTED\r
+  }\r
+\r
+  //\r
+  // Initialize the pre-defined cumulative data.\r
+  //\r
+  InitCumulativeData ();\r
+\r
+  //\r
+  // Init the custom cumulative data.\r
+  //\r
+  CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c");\r
+  if (CustomCumulativeToken != NULL) {\r
+    CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA));\r
+    if (CustomCumulativeData == NULL) {\r
+      return SHELL_OUT_OF_RESOURCES;\r
+    }\r
+    CustomCumulativeData->MinDur = PERF_MAXDUR;\r
+    CustomCumulativeData->MaxDur = 0;\r
+    CustomCumulativeData->Count  = 0;\r
+    CustomCumulativeData->Duration = 0;\r
+    NameSize = StrLen (CustomCumulativeToken) + 1;\r
+    CustomCumulativeData->Name   = AllocateZeroPool (NameSize);\r
+    if (CustomCumulativeData->Name == NULL) {\r
+      FreePool (CustomCumulativeData);\r
+      return SHELL_OUT_OF_RESOURCES;\r
+    }\r
+    UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, NameSize);\r
+  }\r
+\r
+  //\r
+  // Timer specific processing\r
+  //\r
+  // Get the Performance counter characteristics:\r
+  //          Freq = Frequency in Hz\r
+  //    StartCount = Value loaded into the counter when it starts counting\r
+  //      EndCount = Value counter counts to before it needs to be reset\r
+  //\r
+  Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **) &PerformanceProperty);\r
+  if (EFI_ERROR (Status) || (PerformanceProperty == NULL)) {\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PERF_PROPERTY_NOT_FOUND), mDpHiiHandle);\r
+    goto Done;\r
+  }\r
+\r
+  TimerInfo.Frequency  = (UINT32)DivU64x32 (PerformanceProperty->Frequency, 1000);\r
+  TimerInfo.StartCount = PerformanceProperty->TimerStartValue;\r
+  TimerInfo.EndCount   = PerformanceProperty->TimerEndValue;\r
+\r
+  // Determine in which direction the performance counter counts.\r
+  TimerInfo.CountUp = (BOOLEAN) (TimerInfo.EndCount >= TimerInfo.StartCount);\r
+\r
+  //\r
+  // Print header\r
+  //\r
+  // print DP's build version\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_BUILD_REVISION), mDpHiiHandle, DP_MAJOR_VERSION, DP_MINOR_VERSION);\r
+\r
+  // print performance timer characteristics\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_KHZ), mDpHiiHandle, TimerInfo.Frequency);\r
+\r
+  if (VerboseMode && !RawMode) {\r
+    StringPtr = HiiGetString (mDpHiiHandle,\r
+                  (EFI_STRING_ID) (TimerInfo.CountUp ? STRING_TOKEN (STR_DP_UP) : STRING_TOKEN (STR_DP_DOWN)), NULL);\r
+    ASSERT (StringPtr != NULL);\r
+    // Print Timer count range and direction\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TIMER_PROPERTIES), mDpHiiHandle,\r
+                StringPtr,\r
+                TimerInfo.StartCount,\r
+                TimerInfo.EndCount\r
+                );\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_VERBOSE_THRESHOLD), mDpHiiHandle, mInterestThreshold);\r
+  }\r
+\r
+/****************************************************************************\r
+****            Print Sections based on command line options\r
+****\r
+****  Option modes have the following priority:\r
+****    v Verbose     --  Valid in combination with any other options\r
+****    t Threshold   --  Modifies All, Raw, and Cooked output\r
+****                      Default is 0 for All and Raw mode\r
+****                      Default is DEFAULT_THRESHOLD for "Cooked" mode\r
+****    n Number2Display  Used by All and Raw mode.  Otherwise ignored.\r
+****    A All         --  R and S options are ignored\r
+****    R Raw         --  S option is ignored\r
+****    s Summary     --  Modifies "Cooked" output only\r
+****    Cooked (Default)\r
+****\r
+****  The All, Raw, and Cooked modes are modified by the Trace and Profile\r
+****  options.\r
+****    !T && !P  := (0) Default, Both are displayed\r
+****     T && !P  := (1) Only Trace records are displayed\r
+****    !T &&  P  := (2) Only Profile records are displayed\r
+****     T &&  P  := (3) Same as Default, both are displayed\r
+****************************************************************************/\r
+  GatherStatistics (CustomCumulativeData);\r
+  if (CumulativeMode) {                       \r
+    ProcessCumulative (CustomCumulativeData);\r
+  } else if (AllMode) {\r
+    if (TraceMode) {\r
+      Status = DumpAllTrace( Number2Display, ExcludeMode);\r
+      if (Status == EFI_ABORTED) {\r
+        ShellStatus = SHELL_ABORTED;\r
+        goto Done;\r
+      }\r
+    }\r
+    if (ProfileMode) {\r
+      DumpAllProfile( Number2Display, ExcludeMode);\r
+    }\r
+  } else if (RawMode) {\r
+    if (TraceMode) {\r
+      Status = DumpRawTrace( Number2Display, ExcludeMode);\r
+      if (Status == EFI_ABORTED) {\r
+        ShellStatus = SHELL_ABORTED;\r
+        goto Done;\r
+      }\r
+    }\r
+    if (ProfileMode) {\r
+      DumpRawProfile( Number2Display, ExcludeMode);\r
+    }\r
+  } else {\r
+    //------------- Begin Cooked Mode Processing\r
+    if (TraceMode) {\r
+      ProcessPhases ();\r
+      if ( ! SummaryMode) {\r
+        Status = ProcessHandles ( ExcludeMode);\r
+        if (Status == EFI_ABORTED) {\r
+          ShellStatus = SHELL_ABORTED;\r
+          goto Done;\r
+        }\r
+\r
+        Status = ProcessPeims ();\r
+        if (Status == EFI_ABORTED) {\r
+          ShellStatus = SHELL_ABORTED;\r
+          goto Done;\r
+        }\r
+\r
+        Status = ProcessGlobal ();\r
+        if (Status == EFI_ABORTED) {\r
+          ShellStatus = SHELL_ABORTED;\r
+          goto Done;\r
+        }\r
+\r
+        ProcessCumulative (NULL);\r
+      }\r
+    }\r
+    if (ProfileMode) {\r
+      DumpAllProfile( Number2Display, ExcludeMode);\r
+    }\r
+  } //------------- End of Cooked Mode Processing\r
+  if ( VerboseMode || SummaryMode) {\r
+    DumpStatistics();\r
+  }\r
+\r
+Done:\r
+  if (ParamPackage != NULL) {\r
+    ShellCommandLineFreeVarList (ParamPackage);\r
+  }\r
+  SHELL_FREE_NON_NULL (StringPtr);\r
+  if (CustomCumulativeData != NULL) {\r
+    SHELL_FREE_NON_NULL (CustomCumulativeData->Name);\r
+  }\r
+  SHELL_FREE_NON_NULL (CustomCumulativeData);\r
+\r
+  return ShellStatus;\r
+}\r
+\r
+\r
+/**\r
+  Retrive HII package list from ImageHandle and publish to HII database.\r
+\r
+  @param ImageHandle            The image handle of the process.\r
+\r
+  @return HII handle.\r
+**/\r
+EFI_HANDLE\r
+InitializeHiiPackage (\r
+  EFI_HANDLE                  ImageHandle\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  EFI_HII_PACKAGE_LIST_HEADER *PackageList;\r
+  EFI_HANDLE                  HiiHandle;\r
+\r
+  //\r
+  // Retrieve HII package list from ImageHandle\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ImageHandle,\r
+                  &gEfiHiiPackageListProtocolGuid,\r
+                  (VOID **)&PackageList,\r
+                  ImageHandle,\r
+                  NULL,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+  if (EFI_ERROR (Status)) {\r
+    return NULL;\r
+  }\r
+\r
+  //\r
+  // Publish HII package list to HII Database.\r
+  //\r
+  Status = gHiiDatabase->NewPackageList (\r
+                           gHiiDatabase,\r
+                           PackageList,\r
+                           NULL,\r
+                           &HiiHandle\r
+                           );\r
+  ASSERT_EFI_ERROR (Status);\r
+  if (EFI_ERROR (Status)) {\r
+    return NULL;\r
+  }\r
+  return HiiHandle;\r
+}\r
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
new file mode 100644 (file)
index 0000000..4027b6b
--- /dev/null
@@ -0,0 +1,150 @@
+/** @file\r
+  Header file for 'dp' command functions.\r
+\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\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
+\r
+#ifndef _DP_H_\r
+#define _DP_H_\r
+\r
+\r
+#include <Uefi.h>\r
+\r
+#include <Guid/Performance.h>\r
+\r
+#include <Protocol/HiiPackageList.h>\r
+#include <Protocol/DevicePath.h>\r
+#include <Protocol/LoadedImage.h>\r
+#include <Protocol/UnicodeCollation.h>\r
+\r
+#include <Library/BaseLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/ShellLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/SortLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/FileHandleLib.h>\r
+#include <Library/UefiHiiServicesLib.h>\r
+\r
+extern EFI_HANDLE mDpHiiHandle;\r
+\r
+#define DP_MAJOR_VERSION        2\r
+#define DP_MINOR_VERSION        4\r
+\r
+/**\r
+  * The value assigned to DP_DEBUG controls which debug output\r
+  * is generated.  Set it to ZERO to disable.\r
+**/\r
+#define DP_DEBUG                0\r
+\r
+/**\r
+  * Set to 1 once Profiling has been implemented in order to enable\r
+  * profiling related options and report output.\r
+**/\r
+#define PROFILING_IMPLEMENTED   0\r
+\r
+#define DEFAULT_THRESHOLD       1000    ///< One millisecond.\r
+#define DEFAULT_DISPLAYCOUNT    50\r
+#define MAXIMUM_DISPLAYCOUNT    999999  ///< Arbitrary maximum reasonable number.\r
+\r
+#define PERF_MAXDUR             0xFFFFFFFFFFFFFFFFULL\r
+\r
+/// Determine whether  0 <= C < L.  If L == 0, return true regardless of C.\r
+#define WITHIN_LIMIT( C, L)   ( ((L) == 0) || ((C) < (L)) )\r
+\r
+/// Structure for storing Timer specific information.\r
+typedef struct {\r
+  UINT64    StartCount;   ///< Value timer is initialized with.\r
+  UINT64    EndCount;     ///< Value timer has just before it wraps.\r
+  UINT32    Frequency;    ///< Timer count frequency in KHz.\r
+  BOOLEAN   CountUp;      ///< TRUE if the counter counts up.\r
+} TIMER_INFO;\r
+\r
+/** Initialize one PERF_CUM_DATA structure instance for token t.\r
+  *\r
+  * This parameterized macro takes a single argument, t, which is expected\r
+  * to resolve to a pointer to an ASCII string literal.  This parameter may\r
+  * take any one of the following forms:\r
+  *   - PERF_INIT_CUM_DATA("Token")         A string literal\r
+  *   - PERF_INIT_CUM_DATA(pointer)         A pointer -- CHAR8 *pointer;\r
+  *   - PERF_INIT_CUM_DATA(array)           Address of an array -- CHAR8 array[N];\r
+**/\r
+#define PERF_INIT_CUM_DATA(t)   { 0ULL, PERF_MAXDUR, 0ULL, (t), 0U }\r
+\r
+typedef struct {\r
+  UINT64  Duration;     ///< Cumulative duration for this item.\r
+  UINT64  MinDur;       ///< Smallest duration encountered.\r
+  UINT64  MaxDur;       ///< Largest duration encountered.\r
+  CHAR8   *Name;        ///< ASCII name of this item.\r
+  UINT32  Count;        ///< Total number of measurements accumulated.\r
+} PERF_CUM_DATA;\r
+\r
+typedef struct {\r
+  UINT32                NumTrace;         ///< Number of recorded TRACE performance measurements.\r
+  UINT32                NumProfile;       ///< Number of recorded PROFILE performance measurements.\r
+  UINT32                NumIncomplete;    ///< Number of measurements with no END value.\r
+  UINT32                NumSummary;       ///< Number of summary section measurements.\r
+  UINT32                NumHandles;       ///< Number of measurements with handles.\r
+  UINT32                NumPEIMs;         ///< Number of measurements of PEIMs.\r
+  UINT32                NumGlobal;        ///< Number of measurements with END value and NULL handle.\r
+} PERF_SUMMARY_DATA;\r
+\r
+typedef struct {\r
+  CONST VOID            *Handle;\r
+  CONST CHAR8           *Token;           ///< Measured token string name.\r
+  CONST CHAR8           *Module;          ///< Module string name.\r
+  UINT64                StartTimeStamp;   ///< Start time point.\r
+  UINT64                EndTimeStamp;     ///< End time point.\r
+  UINT32                Identifier;       ///< Identifier.\r
+} MEASUREMENT_RECORD;\r
+\r
+typedef struct {\r
+  CHAR8                 *Name;            ///< Measured token string name.\r
+  UINT64                CumulativeTime;   ///< Accumulated Elapsed Time.\r
+  UINT64                MinTime;          ///< Minimum Elapsed Time.\r
+  UINT64                MaxTime;          ///< Maximum Elapsed Time.\r
+  UINT32                Count;            ///< Number of measurements accumulated.\r
+} PROFILE_RECORD;\r
+\r
+/**\r
+  Dump performance data.\r
+\r
+  @param[in]  ImageHandle     The image handle.\r
+  @param[in]  SystemTable     The system table.\r
+\r
+  @retval SHELL_SUCCESS            Command completed successfully.\r
+  @retval SHELL_INVALID_PARAMETER  Command usage error.\r
+  @retval SHELL_ABORTED            The user aborts the operation.\r
+  @retval value                    Unknown error.\r
+**/\r
+SHELL_STATUS\r
+RunDp (\r
+  IN EFI_HANDLE               ImageHandle,\r
+  IN EFI_SYSTEM_TABLE         *SystemTable\r
+  );\r
+\r
+/**\r
+  Retrive HII package list from ImageHandle and publish to HII database.\r
+\r
+  @param ImageHandle            The image handle of the process.\r
+\r
+  @return HII handle.\r
+**/\r
+EFI_HANDLE\r
+InitializeHiiPackage (\r
+  EFI_HANDLE                  ImageHandle\r
+  );\r
+#endif  // _DP_H_\r
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
new file mode 100644 (file)
index 0000000..b77c507
--- /dev/null
@@ -0,0 +1,131 @@
+// *++\r
+//\r
+// (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>\r
+// Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
+// (C) Copyright 2015 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
+// Module Name:\r
+//\r
+//   DpStrings.uni\r
+//\r
+// Abstract:\r
+//\r
+//   String definitions for the Shell dp command\r
+//\r
+// Revision History:\r
+//\r
+// --*/\r
+\r
+/=#\r
+\r
+#langdef   en-US "English"\r
+\r
+#string STR_DP_UP                      #language en-US  "UP"\r
+#string STR_DP_DOWN                    #language en-US  "DOWN"\r
+#string STR_DP_DASHES                  #language en-US  "-------------------------------------------------------------------------------\n"\r
+#string STR_DP_SECTION_HEADER          #language en-US  "\n==[ %s ]========\n"\r
+#string STR_DP_INVALID_ARG             #language en-US  "Invalid argument(s)\n"\r
+#string STR_DP_HANDLES_ERROR           #language en-US  "Locate all handles error - %r\n"\r
+#string STR_DP_ERROR_NAME              #language en-US  "Unknown driver name"\r
+#string STR_PERF_PROPERTY_NOT_FOUND    #language en-US  "Performance property not found\n"\r
+#string STR_DP_BUILD_REVISION          #language en-US  "\nDP Build Version:       %d.%d\n"\r
+#string STR_DP_KHZ                     #language en-US  "System Performance Timer Frequency:   %,8d (KHz)\n"\r
+#string STR_DP_TIMER_PROPERTIES        #language en-US  "System Performance Timer counts %s from 0x%Lx to 0x%Lx\n"\r
+#string STR_DP_VERBOSE_THRESHOLD       #language en-US  "Measurements less than %,Ld microseconds are not displayed.\n"\r
+#string STR_DP_SECTION_PHASES          #language en-US  "Major Phases"\r
+#string STR_DP_SEC_PHASE               #language en-US  "  SEC Phase Duration:      %L8d (us)\n"\r
+#string STR_DP_PHASE_BDSTO             #language en-US  "         BDS Timeout:   %L8d (ms) included in BDS Duration\n"\r
+#string STR_DP_PHASE_DURATION          #language en-US  "%5a Phase Duration:   %L8d (ms)\n"\r
+#string STR_DP_TOTAL_DURATION          #language en-US  "Total       Duration:   %L8d (ms)\n"\r
+#string STR_DP_SECTION_DRIVERS         #language en-US  "Drivers by Handle"\r
+#string STR_DP_HANDLE_SECTION          #language en-US  "Index:  Handle                Driver Name               Description    Time(us)\n"\r
+#string STR_DP_HANDLE_VARS             #language en-US  "%5d:  [%3x]   %36s    %11s    %L8d\n"\r
+#string STR_DP_HANDLE_SECTION2         #language en-US  "Index: Handle               Driver Name             Description  Time(us)    ID\n"\r
+#string STR_DP_HANDLE_VARS2            #language en-US  "%5d: [%3x]  %36s  %11s  %L8d %5d\n"\r
+#string STR_DP_SECTION_PEIMS           #language en-US  "PEIMs"\r
+#string STR_DP_PEIM_SECTION            #language en-US  "Index:  Pointer Value              Instance GUID              Token    Time(us)\n"\r
+#string STR_DP_PEIM_VARS               #language en-US  "%5d:  0x%11p   %g   PEIM    %L8d\n"\r
+#string STR_DP_PEIM_SECTION2           #language en-US  "Index: Pointer Value             Instance GUID            Token  Time(us)    ID\n"\r
+#string STR_DP_PEIM_VARS2              #language en-US  "%5d: 0x%11p  %g PEIM  %L8d %5d\n"\r
+#string STR_DP_SECTION_GENERAL         #language en-US  "General"\r
+#string STR_DP_GLOBAL_SECTION          #language en-US  "Index                      Name                         Description    Time(us)\n"\r
+#string STR_DP_GLOBAL_VARS             #language en-US  "%5d:%25s     %31s    %L8d\n"\r
+#string STR_DP_GLOBAL_SECTION2         #language en-US  "Index                      Name                     Description  Time(us)    ID\n"\r
+#string STR_DP_GLOBAL_VARS2            #language en-US  "%5d:%25s %31s  %L8d %5d\n"\r
+#string STR_DP_SECTION_CUMULATIVE      #language en-US  "Cumulative"\r
+#string STR_DP_CUMULATIVE_SECT_1       #language en-US  "(Times in microsec.)     Cumulative   Average     Shortest    Longest\n"\r
+#string STR_DP_CUMULATIVE_SECT_2       #language en-US  "   Name         Count     Duration    Duration    Duration    Duration\n"\r
+#string STR_DP_CUMULATIVE_STATS        #language en-US  "%11a   %8d  %L10d  %L10d  %L10d  %L10d\n"\r
+#string STR_DP_SECTION_STATISTICS      #language en-US  "Statistics"\r
+#string STR_DP_STATS_NUMTRACE          #language en-US  "There were %d measurements taken, of which:\n"\r
+#string STR_DP_STATS_NUMINCOMPLETE     #language en-US  "%,8d are incomplete.\n"\r
+#string STR_DP_STATS_NUMPHASES         #language en-US  "%,8d are major execution phases.\n"\r
+#string STR_DP_STATS_NUMHANDLES        #language en-US  "%,8d have non-NULL handles, %d are NULL.\n"\r
+#string STR_DP_STATS_NUMPEIMS          #language en-US  "%,8d are PEIMs.\n"\r
+#string STR_DP_STATS_NUMGLOBALS        #language en-US  "%,8d are general measurements.\n"\r
+#string STR_DP_STATS_NUMPROFILE        #language en-US  "%,8d are profiling records.\n"\r
+#string STR_DP_SECTION_PROFILE         #language en-US  "Sequential Profile Records"\r
+#string STR_DP_SECTION_ALL             #language en-US  "Sequential Trace Records"\r
+#string STR_DP_ALL_HEADR               #language en-US  "\nIndex      Handle                 Module                      Token    Time(us)\n"\r
+#string STR_DP_ALL_VARS                #language en-US  "%5d:%3s0x%08p %36s %13s %L8d\n"\r
+#string STR_DP_ALL_DASHES2             #language en-US  "-------------------------------------------------------------------------------------\n"\r
+#string STR_DP_ALL_HEADR2              #language en-US  "\nIndex      Handle                 Module                      Token    Time(us)    ID\n"\r
+#string STR_DP_ALL_VARS2               #language en-US  "%5d:%3s0x%08p %36s %13s %L8d %5d\n"\r
+#string STR_DP_SECTION_RAWTRACE        #language en-US  "RAW Trace"\r
+#string STR_DP_SECTION_RAWPROFILE      #language en-US  "RAW Profile"\r
+#string STR_DP_RAW_DASHES              #language en-US  "---------------------------------------------------------------------------------------------------------------------------\n"\r
+#string STR_DP_RAW_VARS                #language en-US  "%5d: %16LX %16LX %16LX  %31a  %31a\n"\r
+#string STR_DP_RAW_HEADR               #language en-US  "\nIndex       Handle        Start Count       End Count                  Token                          Module\n"\r
+#string STR_DP_RAW_DASHES2             #language en-US  "---------------------------------------------------------------------------------------------------------------------------------\n"\r
+#string STR_DP_RAW_VARS2               #language en-US  "%5d: %16LX %16LX %16LX  %31a  %31a %5d\n"\r
+#string STR_DP_RAW_HEADR2              #language en-US  "\nIndex       Handle        Start Count       End Count                  Token                          Module                   ID\n"\r
+#string STR_DP_INCOMPLETE              #language en-US  " I "\r
+#string STR_DP_COMPLETE                #language en-US  "   "\r
+#string STR_ALIT_UNKNOWN               #language en-US  "Unknown"\r
+\r
+#string STR_GET_HELP_DP         #language en-US ""\r
+".TH dp 0 "Display performance metrics"\r\n"\r
+".SH NAME\r\n"\r
+"Displays performance metrics that are stored in memory.\r\n"\r
+".SH SYNOPSIS\r\n"\r
+"DP [-b] [-v] [-x] [-s | -A | -R] [-T] [-P] [-t value] [-n count] [-c [token]][-i] [-h | -?]\r\n"\r
+".SH OPTIONS\r\n"\r
+" \r\n"\r
+"  -b       - Displays on multiple pages\r\n"\r
+"  -v       - Displays additional information\r\n"\r
+"  -x       - Prevents display of individual measurements for cumulative items\r\n"\r
+"  -s       - Displays summary information only\r\n"\r
+"  -A       - Displays all measurements in a list\r\n"\r
+"  -R       - Displays all measurements in raw format\r\n"\r
+"  -T       - Displays trace measurements only\r\n"\r
+"  -P       - Displays profile measurements only\r\n"\r
+"  -t VALUE - Sets display threshold to VALUE microseconds\r\n"\r
+"  -n COUNT - Limits display to COUNT lines in All and Raw modes\r\n"\r
+"  -i       - Displays identifier\r\n"\r
+"  -c TOKEN - Display pre-defined and custom cumulative data\r\n" \r
+"             Pre-defined cumulative token are:\r\n"\r
+"             1. LoadImage:\r\n"\r
+"             2. StartImage:\r\n"\r
+"             3. DB:Start:\r\n"\r
+"             4. DB:Support:\r\n"\r
+"  -?       - Displays DP help information\r\n"\r
+".SH DESCRIPTION\r\n"\r
+" \r\n"\r
+"NOTES:\r\n"\r
+"  1. Displays Performance metrics that are stored in memory.\r\n"\r
+".SH RETURNVALUES\r\n"\r
+" \r\n"\r
+"RETURN VALUES:\r\n"\r
+"  SHELL_SUCCESS            The action was completed as requested.\r\n"\r
+"  SHELL_NOT_FOUND          The requested option was not found.\r\n"\r
+"  SHELL_INVALID_PARAMETER  One of the passed in parameters was incorrectly formatted or its value was out of bounds.\r\n"\r
+"  SHELL_UNSUPPORTED        The action as requested was unsupported.\r\n"\r
+"  SHELL_OUT_OF_RESOURCES   There was insufficient free space for the request to be completed.\r\n"\r
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c
new file mode 100644 (file)
index 0000000..f96209b
--- /dev/null
@@ -0,0 +1,53 @@
+/** @file\r
+  Entrypoint of "dp" shell standalone application.\r
+\r
+  Copyright (c) 2017, Intel Corporation. All rights reserved. <BR>\r
+\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 "Dp.h"\r
+\r
+//\r
+// String token ID of help message text.\r
+// Shell supports to find help message in the resource section of an application image if\r
+// .MAN file is not found. This global variable is added to make build tool recognizes\r
+// that the help string is consumed by user and then build tool will add the string into\r
+// the resource section. Thus the application can use '-?' option to show help message in\r
+// Shell.\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_DP);\r
+\r
+/**\r
+  Entry point of Tftp standalone application.\r
+\r
+  @param ImageHandle            The image handle of the process.\r
+  @param SystemTable            The EFI System Table pointer.\r
+\r
+  @retval EFI_SUCCESS           Tftp command is executed sucessfully.\r
+  @retval EFI_ABORTED           HII package was failed to initialize.\r
+  @retval others                Other errors when executing tftp command.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DpAppInitialize (\r
+  IN EFI_HANDLE               ImageHandle,\r
+  IN EFI_SYSTEM_TABLE         *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  mDpHiiHandle = InitializeHiiPackage (ImageHandle);\r
+  if (mDpHiiHandle == NULL) {\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  Status = (EFI_STATUS)RunDp (ImageHandle, SystemTable);\r
+  HiiRemovePackages (mDpHiiHandle);\r
+  return Status;\r
+}\r
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
new file mode 100644 (file)
index 0000000..b0ed229
--- /dev/null
@@ -0,0 +1,73 @@
+##  @file\r
+# Provides Shell 'dp' standalone application.\r
+#\r
+# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\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
+#  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
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010006\r
+  BASE_NAME                      = dp\r
+  FILE_GUID                      = 1831A379-2D48-45BD-9744-D4059D93815D\r
+  MODULE_TYPE                    = UEFI_APPLICATION\r
+  VERSION_STRING                 = 1.0\r
+  ENTRY_POINT                    = DpAppInitialize\r
+#\r
+#  This flag specifies whether HII resource section is generated into PE image.\r
+#\r
+  UEFI_HII_RESOURCE_SECTION      = TRUE\r
+\r
+[Sources.common]\r
+  PerformanceTokens.h\r
+  Dp.uni\r
+  Dp.c\r
+  Dp.h\r
+  Literals.h\r
+  Literals.c\r
+  DpInternal.h\r
+  DpUtilities.c\r
+  DpTrace.c\r
+  DpProfile.c\r
+  DpApp.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  ShellPkg/ShellPkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  MemoryAllocationLib\r
+  BaseLib\r
+  BaseMemoryLib\r
+  DebugLib\r
+  ShellLib\r
+  UefiLib\r
+  UefiRuntimeServicesTableLib\r
+  UefiBootServicesTableLib\r
+  UefiApplicationEntryPoint\r
+  SortLib\r
+  PrintLib\r
+  DevicePathLib\r
+  PerformanceLib\r
+  DxeServicesLib\r
+  PeCoffGetEntryPointLib\r
+\r
+[Guids]\r
+  gPerformanceProtocolGuid                                ## CONSUMES ## SystemTable\r
+\r
+[Protocols]\r
+  gEfiLoadedImageProtocolGuid                             ## CONSUMES\r
+  gEfiDriverBindingProtocolGuid                           ## SOMETIMES_CONSUMES\r
+  gEfiComponentName2ProtocolGuid                          ## SOMETIMES_CONSUMES\r
+  gEfiLoadedImageDevicePathProtocolGuid                   ## SOMETIMES_CONSUMES\r
+  gEfiHiiPackageListProtocolGuid                          ## CONSUMES\r
+\r
+[Pcd]\r
+  gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize   ## CONSUMES\r
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.c b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.c
new file mode 100644 (file)
index 0000000..6f3997f
--- /dev/null
@@ -0,0 +1,130 @@
+/** @file\r
+  Produce "dp" shell dynamic command.\r
+\r
+  Copyright (c) 2017, Intel Corporation. All rights reserved. <BR>\r
+\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 "Dp.h"\r
+#include <Protocol/ShellDynamicCommand.h>\r
+\r
+/**\r
+  This is the shell command handler function pointer callback type.  This\r
+  function handles the command when it is invoked in the shell.\r
+\r
+  @param[in] This                   The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
+  @param[in] SystemTable            The pointer to the system table.\r
+  @param[in] ShellParameters        The parameters associated with the command.\r
+  @param[in] Shell                  The instance of the shell protocol used in the context\r
+                                    of processing this command.\r
+\r
+  @return EFI_SUCCESS               the operation was sucessful\r
+  @return other                     the operation failed.\r
+**/\r
+SHELL_STATUS\r
+EFIAPI\r
+DpCommandHandler (\r
+  IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL    *This,\r
+  IN EFI_SYSTEM_TABLE                      *SystemTable,\r
+  IN EFI_SHELL_PARAMETERS_PROTOCOL         *ShellParameters,\r
+  IN EFI_SHELL_PROTOCOL                    *Shell\r
+  )\r
+{\r
+  gEfiShellParametersProtocol = ShellParameters;\r
+  return RunDp (gImageHandle, SystemTable);\r
+}\r
+\r
+/**\r
+  This is the command help handler function pointer callback type.  This\r
+  function is responsible for displaying help information for the associated\r
+  command.\r
+\r
+  @param[in] This                   The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.\r
+  @param[in] Language               The pointer to the language string to use.\r
+\r
+  @return string                    Pool allocated help string, must be freed by caller\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+DpCommandGetHelp (\r
+  IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL    *This,\r
+  IN CONST CHAR8                           *Language\r
+  )\r
+{\r
+  return HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_GET_HELP_DP), Language);\r
+}\r
+\r
+EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mDpDynamicCommand = {\r
+  L"dp",\r
+  DpCommandHandler,\r
+  DpCommandGetHelp\r
+};\r
+\r
+/**\r
+  Entry point of Tftp Dynamic Command.\r
+\r
+  Produce the DynamicCommand protocol to handle "tftp" command.\r
+\r
+  @param ImageHandle            The image handle of the process.\r
+  @param SystemTable            The EFI System Table pointer.\r
+\r
+  @retval EFI_SUCCESS           Tftp command is executed sucessfully.\r
+  @retval EFI_ABORTED           HII package was failed to initialize.\r
+  @retval others                Other errors when executing tftp command.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DpCommandInitialize (\r
+  IN EFI_HANDLE               ImageHandle,\r
+  IN EFI_SYSTEM_TABLE         *SystemTable\r
+  )\r
+{\r
+  EFI_STATUS                  Status;\r
+  mDpHiiHandle = InitializeHiiPackage (ImageHandle);\r
+  if (mDpHiiHandle == NULL) {\r
+    return EFI_ABORTED;\r
+  }\r
+\r
+  Status = gBS->InstallProtocolInterface (\r
+                  &ImageHandle,\r
+                  &gEfiShellDynamicCommandProtocolGuid,\r
+                  EFI_NATIVE_INTERFACE,\r
+                  &mDpDynamicCommand\r
+                  );\r
+  ASSERT_EFI_ERROR (Status);\r
+  return Status;\r
+}\r
+\r
+/**\r
+  Tftp driver unload handler.\r
+\r
+  @param ImageHandle            The image handle of the process.\r
+\r
+  @retval EFI_SUCCESS           The image is unloaded.\r
+  @retval Others                Failed to unload the image.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+DpUnload (\r
+  IN EFI_HANDLE               ImageHandle\r
+)\r
+{\r
+  EFI_STATUS                  Status;\r
+  Status = gBS->UninstallProtocolInterface (\r
+                  ImageHandle,\r
+                  &gEfiShellDynamicCommandProtocolGuid,\r
+                  &mDpDynamicCommand\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+  HiiRemovePackages (mDpHiiHandle);\r
+  return EFI_SUCCESS;\r
+}\r
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
new file mode 100644 (file)
index 0000000..3164561
--- /dev/null
@@ -0,0 +1,78 @@
+##  @file\r
+# Provides Shell 'dp' dynamic command.\r
+#\r
+# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\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
+#  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
+##\r
+\r
+[Defines]\r
+  INF_VERSION                    = 0x00010006\r
+  BASE_NAME                      = dpDynamicCommand\r
+  FILE_GUID                      = 0253F9FA-129A-4A8D-B12E-7DC2B6376302\r
+  MODULE_TYPE                    = DXE_DRIVER\r
+  VERSION_STRING                 = 1.0\r
+  ENTRY_POINT                    = DpCommandInitialize\r
+  UNLOAD_IMAGE                   = DpUnload\r
+#\r
+#  This flag specifies whether HII resource section is generated into PE image.\r
+#\r
+  UEFI_HII_RESOURCE_SECTION      = TRUE\r
+\r
+[Sources.common]\r
+  PerformanceTokens.h\r
+  Dp.uni\r
+  Dp.c\r
+  Dp.h\r
+  Literals.h\r
+  Literals.c\r
+  DpInternal.h\r
+  DpUtilities.c\r
+  DpTrace.c\r
+  DpProfile.c\r
+  DpDynamicCommand.c\r
+\r
+[Packages]\r
+  MdePkg/MdePkg.dec\r
+  ShellPkg/ShellPkg.dec\r
+  MdeModulePkg/MdeModulePkg.dec\r
+\r
+[LibraryClasses]\r
+  MemoryAllocationLib\r
+  BaseLib\r
+  BaseMemoryLib\r
+  DebugLib\r
+  ShellLib\r
+  UefiLib\r
+  UefiRuntimeServicesTableLib\r
+  UefiBootServicesTableLib\r
+  UefiDriverEntryPoint\r
+  SortLib\r
+  PrintLib\r
+  DevicePathLib\r
+  PerformanceLib\r
+  DxeServicesLib\r
+  PeCoffGetEntryPointLib\r
+\r
+[Guids]\r
+  gPerformanceProtocolGuid                                ## CONSUMES ## SystemTable\r
+\r
+[Protocols]\r
+  gEfiLoadedImageProtocolGuid                             ## CONSUMES\r
+  gEfiDriverBindingProtocolGuid                           ## SOMETIMES_CONSUMES\r
+  gEfiComponentName2ProtocolGuid                          ## SOMETIMES_CONSUMES\r
+  gEfiLoadedImageDevicePathProtocolGuid                   ## SOMETIMES_CONSUMES\r
+  gEfiHiiPackageListProtocolGuid                          ## CONSUMES\r
+  gEfiShellDynamicCommandProtocolGuid                     ## PRODUCES\r
+\r
+[Pcd]\r
+  gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize   ## CONSUMES\r
+\r
+[DEPEX]\r
+  TRUE\r
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h b/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
new file mode 100644 (file)
index 0000000..ece1c23
--- /dev/null
@@ -0,0 +1,354 @@
+/** @file\r
+  Declarations of objects defined internally to the Dp Application.\r
+\r
+  Declarations of data and functions which are private to the Dp application.\r
+  This file should never be referenced by anything other than components of the\r
+  Dp application.  In addition to global data, function declarations for\r
+  DpUtilities.c, DpTrace.c, and DpProfile.c are included here.\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
+#ifndef _DP_INTELNAL_H_\r
+#define _DP_INTELNAL_H_\r
+\r
+#define DP_GAUGE_STRING_LENGTH   36\r
+\r
+//\r
+/// Module-Global Variables\r
+///@{\r
+extern EFI_HII_HANDLE     mDpHiiHandle;\r
+extern CHAR16             mGaugeString[DP_GAUGE_STRING_LENGTH + 1];\r
+extern CHAR16             mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];\r
+extern UINT64             mInterestThreshold;\r
+extern BOOLEAN            mShowId;\r
+\r
+extern PERF_SUMMARY_DATA  SummaryData;    ///< Create the SummaryData structure and init. to ZERO.\r
+\r
+/// Timer Specific Information.\r
+extern TIMER_INFO         TimerInfo;\r
+\r
+/// Items for which to gather cumulative statistics.\r
+extern PERF_CUM_DATA      CumData[];\r
+\r
+/// Number of items for which we are gathering cumulative statistics.\r
+extern UINT32 const       NumCum;\r
+\r
+///@}\r
+\r
+/** \r
+  Calculate an event's duration in timer ticks.\r
+  \r
+  Given the count direction and the event's start and end timer values,\r
+  calculate the duration of the event in timer ticks.  Information for\r
+  the current measurement is pointed to by the parameter.\r
+  \r
+  If the measurement's start time is 1, it indicates that the developer\r
+  is indicating that the measurement began at the release of reset.\r
+  The start time is adjusted to the timer's starting count before performing\r
+  the elapsed time calculation.\r
+  \r
+  The calculated duration, in ticks, is the absolute difference between\r
+  the measurement's ending and starting counts.\r
+  \r
+  @param Measurement   Pointer to a MEASUREMENT_RECORD structure containing\r
+                       data for the current measurement.\r
+  \r
+  @return              The 64-bit duration of the event.\r
+**/\r
+UINT64\r
+GetDuration (\r
+  IN OUT MEASUREMENT_RECORD *Measurement\r
+  );\r
+\r
+/** \r
+  Determine whether the Measurement record is for an EFI Phase.\r
+  \r
+  The Token and Module members of the measurement record are checked.\r
+  Module must be empty and Token must be one of SEC, PEI, DXE, BDS, or SHELL.\r
+  \r
+  @param[in]  Measurement A pointer to the Measurement record to test.\r
+  \r
+  @retval     TRUE        The measurement record is for an EFI Phase.\r
+  @retval     FALSE       The measurement record is NOT for an EFI Phase.\r
+**/\r
+BOOLEAN\r
+IsPhase(\r
+  IN MEASUREMENT_RECORD *Measurement\r
+  );\r
+\r
+/** \r
+  Get the file name portion of the Pdb File Name.\r
+  \r
+  The portion of the Pdb File Name between the last backslash and\r
+  either a following period or the end of the string is converted\r
+  to Unicode and copied into UnicodeBuffer.  The name is truncated,\r
+  if necessary, to ensure that UnicodeBuffer is not overrun.\r
+  \r
+  @param[in]  PdbFileName     Pdb file name.\r
+  @param[out] UnicodeBuffer   The resultant Unicode File Name.\r
+  \r
+**/\r
+VOID\r
+DpGetShortPdbFileName (\r
+  IN  CHAR8     *PdbFileName,\r
+  OUT CHAR16    *UnicodeBuffer\r
+  );\r
+\r
+/** \r
+  Get a human readable name for an image handle.\r
+  The following methods will be tried orderly:\r
+    1. Image PDB\r
+    2. ComponentName2 protocol\r
+    3. FFS UI section\r
+    4. Image GUID\r
+    5. Image DevicePath\r
+    6. Unknown Driver Name\r
+  \r
+  @param[in]    Handle\r
+  \r
+  @post   The resulting Unicode name string is stored in the\r
+          mGaugeString global array.\r
+  \r
+**/\r
+VOID\r
+DpGetNameFromHandle (\r
+  IN EFI_HANDLE Handle\r
+  );\r
+\r
+/** \r
+  Calculate the Duration in microseconds.\r
+  \r
+  Duration is multiplied by 1000, instead of Frequency being divided by 1000 or\r
+  multiplying the result by 1000, in order to maintain precision.  Since Duration is\r
+  a 64-bit value, multiplying it by 1000 is unlikely to produce an overflow.\r
+  \r
+  The time is calculated as (Duration * 1000) / Timer_Frequency.\r
+  \r
+  @param[in]  Duration   The event duration in timer ticks.\r
+  \r
+  @return     A 64-bit value which is the Elapsed time in microseconds.\r
+**/\r
+UINT64\r
+DurationInMicroSeconds (\r
+  IN UINT64 Duration\r
+  );\r
+\r
+/** \r
+  Get index of Measurement Record's match in the CumData array.\r
+  \r
+  If the Measurement's Token value matches a Token in one of the CumData\r
+  records, the index of the matching record is returned.  The returned\r
+  index is a signed value so that negative values can indicate that\r
+  the Measurement didn't match any entry in the CumData array.\r
+  \r
+  @param[in]  Measurement A pointer to a Measurement Record to match against the CumData array.\r
+  \r
+  @retval     <0    Token is not in the CumData array.\r
+  @retval     >=0   Return value is the index into CumData where Token is found.\r
+**/\r
+INTN\r
+GetCumulativeItem(\r
+  IN MEASUREMENT_RECORD *Measurement\r
+  );\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  The pointer to the custom cumulative data.\r
+\r
+**/\r
+VOID\r
+GatherStatistics(\r
+  IN OUT PERF_CUM_DATA              *CustomCumulativeData OPTIONAL\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
+/** \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
+  @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
+/** \r
+  Gather and print Major Phase metrics.\r
+  \r
+**/\r
+VOID\r
+ProcessPhases(\r
+  VOID\r
+  );\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
+\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
+/** \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
+/** \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  The pointer to the custom cumulative data.\r
+  \r
+**/\r
+VOID\r
+ProcessCumulative(\r
+  IN PERF_CUM_DATA                  *CustomCumulativeData OPTIONAL\r
+  );\r
+\r
+/** \r
+  Gather and print ALL Profiling Records.\r
+  \r
+  Displays all "interesting" Profile measurements in order.\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
+**/\r
+VOID\r
+DumpAllProfile(\r
+  IN UINTN          Limit,\r
+  IN BOOLEAN        ExcludeFlag\r
+  );\r
+\r
+/** \r
+  Gather and print Raw Profile Records.\r
+  \r
+  All Profile 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
+**/\r
+VOID\r
+DumpRawProfile(\r
+  IN UINTN          Limit,\r
+  IN BOOLEAN        ExcludeFlag\r
+  );\r
+\r
+#endif\r
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c b/ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c
new file mode 100644 (file)
index 0000000..af25217
--- /dev/null
@@ -0,0 +1,100 @@
+/** @file\r
+  Measured Profiling reporting for the Dp utility.\r
+\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\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
+  Gather and print ALL Profiling Records.\r
+\r
+  Displays all "interesting" Profile measurements in order.\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
+**/\r
+VOID\r
+DumpAllProfile(\r
+  IN UINTN      Limit,\r
+  IN BOOLEAN    ExcludeFlag\r
+  )\r
+{\r
+  EFI_STRING    StringPtr;\r
+  EFI_STRING    StringPtrUnknown;\r
+\r
+  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PROFILE), NULL);\r
+\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,\r
+              (StringPtr == NULL) ? StringPtrUnknown: StringPtr);\r
+  FreePool (StringPtr);\r
+  FreePool (StringPtrUnknown);\r
+}\r
+\r
+/**\r
+  Gather and print Raw Profile Records.\r
+\r
+  All Profile 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
+**/\r
+VOID\r
+DumpRawProfile(\r
+  IN UINTN      Limit,\r
+  IN BOOLEAN    ExcludeFlag\r
+  )\r
+{\r
+  EFI_STRING    StringPtr;\r
+  EFI_STRING    StringPtrUnknown;\r
+\r
+  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWPROFILE), NULL);\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,\r
+              (StringPtr == NULL) ? StringPtrUnknown: StringPtr);\r
+  FreePool (StringPtr);\r
+  FreePool (StringPtrUnknown);\r
+}\r
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c b/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
new file mode 100644 (file)
index 0000000..bc882be
--- /dev/null
@@ -0,0 +1,876 @@
+/** @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 (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
+  IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL);\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,\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), mDpHiiHandle, 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), mDpHiiHandle);\r
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_DASHES2), mDpHiiHandle);\r
+    } else {\r
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR), mDpHiiHandle);\r
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);\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 (mDpHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL);\r
+      }\r
+      else {\r
+        IncFlag = HiiGetString (mDpHiiHandle, 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), mDpHiiHandle,\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), mDpHiiHandle,\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 (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,\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), mDpHiiHandle);\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES2), mDpHiiHandle);\r
+  } else {\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR), mDpHiiHandle);\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES), mDpHiiHandle);\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), mDpHiiHandle,\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), mDpHiiHandle,\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 (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL);\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,\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), mDpHiiHandle, 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), mDpHiiHandle, 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), mDpHiiHandle, 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), mDpHiiHandle, 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), mDpHiiHandle, ALit_BdsTO, ElapsedTime);\r
+  }\r
+\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOTAL_DURATION), mDpHiiHandle, 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 (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL);\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,\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), mDpHiiHandle, 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), mDpHiiHandle);\r
+    } else {\r
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION), mDpHiiHandle);\r
+    }\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);\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), mDpHiiHandle,\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), mDpHiiHandle,\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 (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,\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), mDpHiiHandle);\r
+  } else {\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION), mDpHiiHandle);\r
+  }\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);\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), mDpHiiHandle,\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), mDpHiiHandle,\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 (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,\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), mDpHiiHandle);\r
+  } else {\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION), mDpHiiHandle);\r
+  }\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);\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), mDpHiiHandle,\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), mDpHiiHandle,\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 (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL);\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,\r
+              (StringPtr == NULL) ? StringPtrUnknown: StringPtr);\r
+  FreePool (StringPtr);\r
+  FreePool (StringPtrUnknown);\r
+\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1), mDpHiiHandle);\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2), mDpHiiHandle);\r
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);\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), mDpHiiHandle,\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), mDpHiiHandle,\r
+                CustomCumulativeData->Name,\r
+                CustomCumulativeData->Count,\r
+                Dur,\r
+                AvgDur,\r
+                MinDur,\r
+                MaxDur\r
+                );\r
+  }\r
+}\r
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c b/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c
new file mode 100644 (file)
index 0000000..b98ec4b
--- /dev/null
@@ -0,0 +1,414 @@
+/** @file\r
+  Utility functions used by the Dp application.\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/PrintLib.h>\r
+#include <Library/HiiLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/HandleParsingLib.h>\r
+\r
+#include <Pi/PiFirmwareFile.h>\r
+#include <Library/DxeServicesLib.h>\r
+\r
+#include <Protocol/LoadedImage.h>\r
+#include <Protocol/DriverBinding.h>\r
+#include <Protocol/ComponentName2.h>\r
+#include <Protocol/DevicePath.h>\r
+\r
+#include <Guid/Performance.h>\r
+\r
+#include "Dp.h"\r
+#include "Literals.h"\r
+#include "DpInternal.h"\r
+\r
+/** \r
+  Calculate an event's duration in timer ticks.\r
+  \r
+  Given the count direction and the event's start and end timer values,\r
+  calculate the duration of the event in timer ticks.  Information for\r
+  the current measurement is pointed to by the parameter.\r
+  \r
+  If the measurement's start time is 1, it indicates that the developer\r
+  is indicating that the measurement began at the release of reset.\r
+  The start time is adjusted to the timer's starting count before performing\r
+  the elapsed time calculation.\r
+  \r
+  The calculated duration, in ticks, is the absolute difference between\r
+  the measurement's ending and starting counts.\r
+  \r
+  @param Measurement   Pointer to a MEASUREMENT_RECORD structure containing\r
+                       data for the current measurement.\r
+  \r
+  @return              The 64-bit duration of the event.\r
+**/\r
+UINT64\r
+GetDuration (\r
+  IN OUT MEASUREMENT_RECORD   *Measurement\r
+  )\r
+{\r
+  UINT64    Duration;\r
+  BOOLEAN   Error;\r
+\r
+  if (Measurement->EndTimeStamp == 0) {\r
+    return 0;\r
+  }\r
+\r
+  // PERF_START macros are called with a value of 1 to indicate\r
+  // the beginning of time.  So, adjust the start ticker value\r
+  // to the real beginning of time.\r
+  // Assumes no wraparound.  Even then, there is a very low probability\r
+  // of having a valid StartTicker value of 1.\r
+  if (Measurement->StartTimeStamp == 1) {\r
+    Measurement->StartTimeStamp = TimerInfo.StartCount;\r
+  }\r
+  if (TimerInfo.CountUp) {\r
+    Duration = Measurement->EndTimeStamp - Measurement->StartTimeStamp;\r
+    Error = (BOOLEAN)(Duration > Measurement->EndTimeStamp);\r
+  }\r
+  else {\r
+    Duration = Measurement->StartTimeStamp - Measurement->EndTimeStamp;\r
+    Error = (BOOLEAN)(Duration > Measurement->StartTimeStamp);\r
+  }\r
+\r
+  if (Error) {\r
+    DEBUG ((EFI_D_ERROR, ALit_TimerLibError));\r
+    Duration = 0;\r
+  }\r
+  return Duration;\r
+}\r
+\r
+/** \r
+  Determine whether the Measurement record is for an EFI Phase.\r
+  \r
+  The Token and Module members of the measurement record are checked.\r
+  Module must be empty and Token must be one of SEC, PEI, DXE, BDS, or SHELL.\r
+  \r
+  @param[in]  Measurement A pointer to the Measurement record to test.\r
+  \r
+  @retval     TRUE        The measurement record is for an EFI Phase.\r
+  @retval     FALSE       The measurement record is NOT for an EFI Phase.\r
+**/\r
+BOOLEAN\r
+IsPhase(\r
+  IN MEASUREMENT_RECORD        *Measurement\r
+  )\r
+{\r
+  BOOLEAN   RetVal;\r
+\r
+  RetVal = (BOOLEAN)( ( *Measurement->Module == '\0')                               &&\r
+            ((AsciiStrnCmp (Measurement->Token, ALit_SEC, PERF_TOKEN_LENGTH) == 0)    ||\r
+             (AsciiStrnCmp (Measurement->Token, ALit_PEI, PERF_TOKEN_LENGTH) == 0)    ||\r
+             (AsciiStrnCmp (Measurement->Token, ALit_DXE, PERF_TOKEN_LENGTH) == 0)    ||\r
+             (AsciiStrnCmp (Measurement->Token, ALit_BDS, PERF_TOKEN_LENGTH) == 0))\r
+            );\r
+  return RetVal;\r
+}\r
+\r
+/** \r
+  Get the file name portion of the Pdb File Name.\r
+  \r
+  The portion of the Pdb File Name between the last backslash and\r
+  either a following period or the end of the string is converted\r
+  to Unicode and copied into UnicodeBuffer.  The name is truncated,\r
+  if necessary, to ensure that UnicodeBuffer is not overrun.\r
+  \r
+  @param[in]  PdbFileName     Pdb file name.\r
+  @param[out] UnicodeBuffer   The resultant Unicode File Name.\r
+  \r
+**/\r
+VOID\r
+DpGetShortPdbFileName (\r
+  IN  CHAR8     *PdbFileName,\r
+  OUT CHAR16    *UnicodeBuffer\r
+  )\r
+{\r
+  UINTN IndexA;     // Current work location within an ASCII string.\r
+  UINTN IndexU;     // Current work location within a Unicode string.\r
+  UINTN StartIndex;\r
+  UINTN EndIndex;\r
+\r
+  ZeroMem (UnicodeBuffer, (DP_GAUGE_STRING_LENGTH + 1) * sizeof (CHAR16));\r
+\r
+  if (PdbFileName == NULL) {\r
+    StrnCpyS (UnicodeBuffer, DP_GAUGE_STRING_LENGTH + 1, L" ", 1);\r
+  } else {\r
+    StartIndex = 0;\r
+    for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)\r
+      ;\r
+    for (IndexA = 0; PdbFileName[IndexA] != 0; IndexA++) {\r
+      if ((PdbFileName[IndexA] == '\\') || (PdbFileName[IndexA] == '/')) {\r
+        StartIndex = IndexA + 1;\r
+      }\r
+\r
+      if (PdbFileName[IndexA] == '.') {\r
+        EndIndex = IndexA;\r
+      }\r
+    }\r
+\r
+    IndexU = 0;\r
+    for (IndexA = StartIndex; IndexA < EndIndex; IndexA++) {\r
+      UnicodeBuffer[IndexU] = (CHAR16) PdbFileName[IndexA];\r
+      IndexU++;\r
+      if (IndexU >= DP_GAUGE_STRING_LENGTH) {\r
+        UnicodeBuffer[DP_GAUGE_STRING_LENGTH] = 0;\r
+        break;\r
+      }\r
+    }\r
+  }\r
+}\r
+\r
+/** \r
+  Get a human readable name for an image handle.\r
+  The following methods will be tried orderly:\r
+    1. Image PDB\r
+    2. ComponentName2 protocol\r
+    3. FFS UI section\r
+    4. Image GUID\r
+    5. Image DevicePath\r
+    6. Unknown Driver Name\r
+\r
+  @param[in]    Handle\r
+\r
+  @post   The resulting Unicode name string is stored in the\r
+          mGaugeString global array.\r
+\r
+**/\r
+VOID\r
+DpGetNameFromHandle (\r
+  IN EFI_HANDLE   Handle\r
+  )\r
+{\r
+  EFI_STATUS                   Status;\r
+  EFI_LOADED_IMAGE_PROTOCOL    *Image;\r
+  CHAR8                        *PdbFileName;\r
+  EFI_DRIVER_BINDING_PROTOCOL  *DriverBinding;\r
+  EFI_STRING                   StringPtr;\r
+  EFI_DEVICE_PATH_PROTOCOL     *LoadedImageDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL     *DevicePath;\r
+  EFI_GUID                     *NameGuid;\r
+  CHAR16                       *NameString;\r
+  UINTN                        StringSize;\r
+  CHAR8                        *PlatformLanguage;\r
+  CHAR8                        *BestLanguage;\r
+  EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;\r
+\r
+  Image = NULL;\r
+  LoadedImageDevicePath = NULL;\r
+  DevicePath = NULL;\r
+\r
+  //\r
+  // Method 1: Get the name string from image PDB\r
+  //\r
+  Status = gBS->HandleProtocol (\r
+                  Handle,\r
+                  &gEfiLoadedImageProtocolGuid,\r
+                  (VOID **) &Image\r
+                  );\r
+\r
+  if (EFI_ERROR (Status)) {\r
+    Status = gBS->OpenProtocol (\r
+                    Handle,\r
+                    &gEfiDriverBindingProtocolGuid,\r
+                    (VOID **) &DriverBinding,\r
+                    NULL,\r
+                    NULL,\r
+                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                    );\r
+    if (!EFI_ERROR (Status)) {\r
+      Status = gBS->HandleProtocol (\r
+                      DriverBinding->ImageHandle,\r
+                      &gEfiLoadedImageProtocolGuid,\r
+                      (VOID **) &Image\r
+                      );\r
+    }\r
+  }\r
+\r
+  if (!EFI_ERROR (Status)) {\r
+    PdbFileName = PeCoffLoaderGetPdbPointer (Image->ImageBase);\r
+\r
+    if (PdbFileName != NULL) {\r
+      DpGetShortPdbFileName (PdbFileName, mGaugeString);\r
+      return;\r
+    }\r
+  }\r
+\r
+  //\r
+  // Method 2: Get the name string from ComponentName2 protocol\r
+  //\r
+  Status = gBS->HandleProtocol (\r
+                  Handle,\r
+                  &gEfiComponentName2ProtocolGuid,\r
+                  (VOID **) &ComponentName2\r
+                  );\r
+  if (!EFI_ERROR (Status)) {\r
+    //\r
+    // Firstly use platform language setting, secondly use driver's first supported language.\r
+    //\r
+    GetVariable2 (L"PlatformLang", &gEfiGlobalVariableGuid, (VOID**)&PlatformLanguage, NULL);\r
+    BestLanguage = GetBestLanguage(\r
+                     ComponentName2->SupportedLanguages,\r
+                     FALSE,\r
+                     (PlatformLanguage != NULL) ? PlatformLanguage : "",\r
+                     ComponentName2->SupportedLanguages,\r
+                     NULL\r
+                     );\r
+    SHELL_FREE_NON_NULL (PlatformLanguage);\r
+\r
+    Status = ComponentName2->GetDriverName (\r
+                               ComponentName2,\r
+                               BestLanguage != NULL ? BestLanguage : "en-US",\r
+                               &StringPtr\r
+                               );\r
+    if (!EFI_ERROR (Status)) {\r
+      SHELL_FREE_NON_NULL (BestLanguage);\r
+      StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr, DP_GAUGE_STRING_LENGTH);\r
+      mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;\r
+      return;\r
+    }\r
+  }\r
+\r
+  Status = gBS->HandleProtocol (\r
+                  Handle,\r
+                  &gEfiLoadedImageDevicePathProtocolGuid,\r
+                  (VOID **) &LoadedImageDevicePath\r
+                  );\r
+  if (!EFI_ERROR (Status) && (LoadedImageDevicePath != NULL)) {\r
+    DevicePath = LoadedImageDevicePath;\r
+  } else if (Image != NULL) {\r
+    DevicePath = Image->FilePath;\r
+  }\r
+\r
+  if (DevicePath != NULL) {\r
+    //\r
+    // Try to get image GUID from image DevicePath\r
+    //\r
+    NameGuid = NULL;\r
+    while (!IsDevicePathEndType (DevicePath)) {\r
+      NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePath);\r
+      if (NameGuid != NULL) {\r
+        break;\r
+      }\r
+      DevicePath = NextDevicePathNode (DevicePath);\r
+    }\r
+\r
+    if (NameGuid != NULL) {\r
+      //\r
+      // Try to get the image's FFS UI section by image GUID\r
+      //\r
+      NameString = NULL;\r
+      StringSize = 0;\r
+      Status = GetSectionFromAnyFv (\r
+                NameGuid,\r
+                EFI_SECTION_USER_INTERFACE,\r
+                0,\r
+                (VOID **) &NameString,\r
+                &StringSize\r
+                );\r
+\r
+      if (!EFI_ERROR (Status)) {\r
+        //\r
+        // Method 3. Get the name string from FFS UI section\r
+        //\r
+        StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, NameString, DP_GAUGE_STRING_LENGTH);\r
+        mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;\r
+        FreePool (NameString);\r
+      } else {\r
+        //\r
+        // Method 4: Get the name string from image GUID\r
+        //\r
+        UnicodeSPrint (mGaugeString, sizeof (mGaugeString), L"%g", NameGuid);\r
+      }\r
+      return;\r
+    } else {\r
+      //\r
+      // Method 5: Get the name string from image DevicePath\r
+      //\r
+      NameString = ConvertDevicePathToText (DevicePath, TRUE, FALSE);\r
+      if (NameString != NULL) {\r
+        StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, NameString, DP_GAUGE_STRING_LENGTH);\r
+        mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;\r
+        FreePool (NameString);\r
+        return;\r
+      }\r
+    }\r
+  }\r
+\r
+  //\r
+  // Method 6: Unknown Driver Name\r
+  //\r
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_ERROR_NAME), NULL);\r
+  ASSERT (StringPtr != NULL);\r
+  StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr, DP_GAUGE_STRING_LENGTH);\r
+  FreePool (StringPtr);\r
+}\r
+\r
+/** \r
+  Calculate the Duration in microseconds.\r
+  \r
+  Duration is multiplied by 1000, instead of Frequency being divided by 1000 or\r
+  multiplying the result by 1000, in order to maintain precision.  Since Duration is\r
+  a 64-bit value, multiplying it by 1000 is unlikely to produce an overflow.\r
+  \r
+  The time is calculated as (Duration * 1000) / Timer_Frequency.\r
+  \r
+  @param[in]  Duration   The event duration in timer ticks.\r
+  \r
+  @return     A 64-bit value which is the Elapsed time in microseconds.\r
+**/\r
+UINT64\r
+DurationInMicroSeconds (\r
+  IN UINT64 Duration\r
+  )\r
+{\r
+  UINT64 Temp;\r
+\r
+  Temp = MultU64x32 (Duration, 1000);\r
+  return DivU64x32 (Temp, TimerInfo.Frequency);\r
+}\r
+\r
+/** \r
+  Get index of Measurement Record's match in the CumData array.\r
+  \r
+  If the Measurement's Token value matches a Token in one of the CumData\r
+  records, the index of the matching record is returned.  The returned\r
+  index is a signed value so that negative values can indicate that\r
+  the Measurement didn't match any entry in the CumData array.\r
+  \r
+  @param[in]  Measurement A pointer to a Measurement Record to match against the CumData array.\r
+  \r
+  @retval     <0    Token is not in the CumData array.\r
+  @retval     >=0   Return value is the index into CumData where Token is found.\r
+**/\r
+INTN\r
+GetCumulativeItem(\r
+  IN MEASUREMENT_RECORD   *Measurement\r
+  )\r
+{\r
+  INTN    Index;\r
+\r
+  for( Index = 0; Index < (INTN)NumCum; ++Index) {\r
+    if (AsciiStrnCmp (Measurement->Token, CumData[Index].Name, PERF_TOKEN_LENGTH) == 0) {\r
+      return Index;  // Exit, we found a match\r
+    }\r
+  }\r
+  // If the for loop exits, Token was not found.\r
+  return -1;   // Indicate failure\r
+}\r
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.c
new file mode 100644 (file)
index 0000000..c1cddfb
--- /dev/null
@@ -0,0 +1,22 @@
+/** @file\r
+  Definitions of ASCII string literals used by DP.\r
+\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<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
+#include <PerformanceTokens.h>\r
+\r
+// ASCII String literals which probably don't need translation\r
+CHAR8 const ALit_TimerLibError[] = "Timer library instance error!\n";\r
+CHAR8 const ALit_SEC[]    = SEC_TOK;\r
+CHAR8 const ALit_DXE[]    = DXE_TOK;\r
+CHAR8 const ALit_PEI[]    = PEI_TOK;\r
+CHAR8 const ALit_BDS[]    = BDS_TOK;\r
+CHAR8 const ALit_BdsTO[]  = "BdsTimeOut";\r
+CHAR8 const ALit_PEIM[]   = "PEIM";\r
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.h b/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.h
new file mode 100644 (file)
index 0000000..8aec09c
--- /dev/null
@@ -0,0 +1,26 @@
+/** @file\r
+  Declarations of ASCII string literals used by DP.\r
+\r
+  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<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
+#ifndef _LITERALS_H_\r
+#define _LITERALS_H_\r
+\r
+// ASCII String literals which probably don't need translation\r
+extern CHAR8 const ALit_TimerLibError[];\r
+extern CHAR8 const ALit_SEC[];\r
+extern CHAR8 const ALit_DXE[];\r
+extern CHAR8 const ALit_SHELL[];\r
+extern CHAR8 const ALit_PEI[];\r
+extern CHAR8 const ALit_BDS[];\r
+extern CHAR8 const ALit_BdsTO[];\r
+extern CHAR8 const ALit_PEIM[];\r
+\r
+#endif  // _LITERALS_H_\r
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h b/ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h
new file mode 100644 (file)
index 0000000..bbbc48d
--- /dev/null
@@ -0,0 +1,28 @@
+/** @file\r
+  ASCII String Literals with special meaning to Performance measurement and the Dp utility.\r
+\r
+Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<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
+\r
+#ifndef __PERFORMANCE_TOKENS_H__\r
+#define __PERFORMANCE_TOKENS_H__\r
+\r
+#define SEC_TOK                         "SEC"             ///< SEC Phase\r
+#define DXE_TOK                         "DXE"             ///< DEC Phase\r
+#define SHELL_TOK                       "SHELL"           ///< Shell Phase\r
+#define PEI_TOK                         "PEI"             ///< PEI Phase\r
+#define BDS_TOK                         "BDS"             ///< BDS Phase\r
+#define DRIVERBINDING_START_TOK         "DB:Start:"       ///< Driver Binding Start() function call\r
+#define DRIVERBINDING_SUPPORT_TOK       "DB:Support:"     ///< Driver Binding Support() function call\r
+#define LOAD_IMAGE_TOK                  "LoadImage:"      ///< Load a dispatched module\r
+#define START_IMAGE_TOK                 "StartImage:"     ///< Dispatched Modules Entry Point execution\r
+\r
+#endif  // __PERFORMANCE_TOKENS_H__\r
diff --git a/ShellPkg/Library/UefiDpLib/Dp.c b/ShellPkg/Library/UefiDpLib/Dp.c
deleted file mode 100644 (file)
index 94fa61c..0000000
+++ /dev/null
@@ -1,400 +0,0 @@
-/** @file\r
-  Shell command for Displaying Performance Metrics.\r
-\r
-  The Dp command reads performance data and presents it in several\r
-  different formats depending upon the needs of the user.  Both\r
-  Trace and Measured Profiling information is processed and presented.\r
-\r
-  Dp uses the "PerformanceLib" to read the measurement records.\r
-  The "TimerLib" provides information about the timer, such as frequency,\r
-  beginning, and ending counter values.\r
-  Measurement records contain identifying information (Handle, Token, Module)\r
-  and start and end time values.\r
-  Dp uses this information to group records in different ways.  It also uses\r
-  timer information to calculate elapsed time for each measurement.\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 "UefiDpLib.h"\r
-#include <Library/ShellLib.h>\r
-#include <Library/BaseLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/UefiLib.h>\r
-\r
-#include <Guid/Performance.h>\r
-\r
-#include "PerformanceTokens.h"\r
-#include "Dp.h"\r
-#include "Literals.h"\r
-#include "DpInternal.h"\r
-\r
-//\r
-/// Module-Global Variables\r
-///@{\r
-CHAR16           mGaugeString[DP_GAUGE_STRING_LENGTH + 1];\r
-CHAR16           mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];\r
-UINT64           mInterestThreshold;\r
-BOOLEAN          mShowId = FALSE;\r
-\r
-PERF_SUMMARY_DATA SummaryData = { 0 };    ///< Create the SummaryData structure and init. to ZERO.\r
-\r
-/// Timer Specific Information.\r
-TIMER_INFO TimerInfo;\r
-\r
-/// Items for which to gather cumulative statistics.\r
-PERF_CUM_DATA CumData[] = {\r
-  PERF_INIT_CUM_DATA (LOAD_IMAGE_TOK),\r
-  PERF_INIT_CUM_DATA (START_IMAGE_TOK),\r
-  PERF_INIT_CUM_DATA (DRIVERBINDING_START_TOK),\r
-  PERF_INIT_CUM_DATA (DRIVERBINDING_SUPPORT_TOK)\r
-};\r
-\r
-/// Number of items for which we are gathering cumulative statistics.\r
-UINT32 const      NumCum = sizeof(CumData) / sizeof(PERF_CUM_DATA);\r
-\r
-STATIC CONST SHELL_PARAM_ITEM ParamList[] = {\r
-  {L"-v", TypeFlag},   // -v   Verbose Mode\r
-  {L"-A", TypeFlag},   // -A   All, Cooked\r
-  {L"-R", TypeFlag},   // -R   RAW All\r
-  {L"-s", TypeFlag},   // -s   Summary\r
-#if PROFILING_IMPLEMENTED\r
-  {L"-P", TypeFlag},   // -P   Dump Profile Data\r
-  {L"-T", TypeFlag},   // -T   Dump Trace Data\r
-#endif // PROFILING_IMPLEMENTED\r
-  {L"-x", TypeFlag},   // -x   eXclude Cumulative Items\r
-  {L"-i", TypeFlag},   // -i   Display Identifier\r
-  {L"-c", TypeValue},  // -c   Display cumulative data.\r
-  {L"-n", TypeValue},  // -n # Number of records to display for A and R\r
-  {L"-t", TypeValue},  // -t # Threshold of interest\r
-  {NULL, TypeMax}\r
-  };\r
-\r
-///@}\r
-\r
-/**\r
-   Display the trailing Verbose information.\r
-**/\r
-VOID\r
-DumpStatistics( void )\r
-{\r
-  EFI_STRING                StringPtr;\r
-  EFI_STRING                StringPtrUnknown;\r
-  StringPtr        = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_STATISTICS), NULL);\r
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,\r
-              (StringPtr == NULL) ? StringPtrUnknown : StringPtr);\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMTRACE), gDpHiiHandle,      SummaryData.NumTrace);\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMINCOMPLETE), gDpHiiHandle, SummaryData.NumIncomplete);\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPHASES), gDpHiiHandle,     SummaryData.NumSummary);\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMHANDLES), gDpHiiHandle,    SummaryData.NumHandles, SummaryData.NumTrace - SummaryData.NumHandles);\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPEIMS), gDpHiiHandle,      SummaryData.NumPEIMs);\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMGLOBALS), gDpHiiHandle,    SummaryData.NumGlobal);\r
-#if PROFILING_IMPLEMENTED\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPROFILE), gDpHiiHandle,    SummaryData.NumProfile);\r
-#endif // PROFILING_IMPLEMENTED\r
-  SHELL_FREE_NON_NULL (StringPtr);\r
-  SHELL_FREE_NON_NULL (StringPtrUnknown);\r
-}\r
-\r
-/**\r
-  Initialize the cumulative data.\r
-\r
-**/\r
-VOID\r
-InitCumulativeData (\r
-  VOID\r
-  )\r
-{\r
-  UINTN                             Index;\r
-\r
-  for (Index = 0; Index < NumCum; ++Index) {\r
-    CumData[Index].Count = 0;\r
-    CumData[Index].MinDur = PERF_MAXDUR;\r
-    CumData[Index].MaxDur = 0;\r
-    CumData[Index].Duration = 0;\r
-  }\r
-}\r
-\r
-/**\r
-  Dump performance data.\r
-  \r
-  @param[in]  ImageHandle     The image handle.\r
-  @param[in]  SystemTable     The system table.\r
-  \r
-  @retval SHELL_SUCCESS            Command completed successfully.\r
-  @retval SHELL_INVALID_PARAMETER  Command usage error.\r
-  @retval SHELL_ABORTED            The user aborts the operation.\r
-  @retval value                    Unknown error.\r
-**/\r
-SHELL_STATUS\r
-EFIAPI\r
-ShellCommandRunDp (\r
-  IN EFI_HANDLE               ImageHandle,\r
-  IN EFI_SYSTEM_TABLE         *SystemTable\r
-  )\r
-{\r
-  LIST_ENTRY                *ParamPackage;\r
-  CONST CHAR16              *CmdLineArg;\r
-  EFI_STATUS                Status;\r
-\r
-  PERFORMANCE_PROPERTY      *PerformanceProperty;\r
-  UINTN                     Number2Display;\r
-\r
-  EFI_STRING                StringPtr;\r
-  BOOLEAN                   SummaryMode;\r
-  BOOLEAN                   VerboseMode;\r
-  BOOLEAN                   AllMode;\r
-  BOOLEAN                   RawMode;\r
-  BOOLEAN                   TraceMode;\r
-  BOOLEAN                   ProfileMode;\r
-  BOOLEAN                   ExcludeMode;\r
-  BOOLEAN                   CumulativeMode;\r
-  CONST CHAR16              *CustomCumulativeToken;\r
-  PERF_CUM_DATA             *CustomCumulativeData;\r
-  UINTN                     NameSize;\r
-  SHELL_STATUS              ShellStatus;\r
-\r
-  StringPtr   = NULL;\r
-  SummaryMode = FALSE;\r
-  VerboseMode = FALSE;\r
-  AllMode     = FALSE;\r
-  RawMode     = FALSE;\r
-  TraceMode   = FALSE;\r
-  ProfileMode = FALSE;\r
-  ExcludeMode = FALSE;\r
-  CumulativeMode = FALSE;\r
-  CustomCumulativeData = NULL;\r
-  ShellStatus = SHELL_SUCCESS;\r
-\r
-  //\r
-  // initialize the shell lib (we must be in non-auto-init...)\r
-  //\r
-  Status = ShellInitialize();\r
-  ASSERT_EFI_ERROR(Status);\r
-\r
-  Status = CommandInit();\r
-  ASSERT_EFI_ERROR(Status);\r
-\r
-  //\r
-  // Process Command Line arguments\r
-  //\r
-  Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE);\r
-  if (EFI_ERROR(Status)) {\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_ARG), gDpHiiHandle);\r
-    return SHELL_INVALID_PARAMETER;\r
-  }\r
-\r
-  //\r
-  // Boolean options\r
-  //\r
-  VerboseMode = ShellCommandLineGetFlag (ParamPackage, L"-v");\r
-  SummaryMode = (BOOLEAN) (ShellCommandLineGetFlag (ParamPackage, L"-S") || ShellCommandLineGetFlag (ParamPackage, L"-s"));\r
-  AllMode     = ShellCommandLineGetFlag (ParamPackage, L"-A");\r
-  RawMode     = ShellCommandLineGetFlag (ParamPackage, L"-R");\r
-#if PROFILING_IMPLEMENTED\r
-  TraceMode   = ShellCommandLineGetFlag (ParamPackage, L"-T");\r
-  ProfileMode = ShellCommandLineGetFlag (ParamPackage, L"-P");\r
-#endif  // PROFILING_IMPLEMENTED\r
-  ExcludeMode = ShellCommandLineGetFlag (ParamPackage, L"-x");\r
-  mShowId     = ShellCommandLineGetFlag (ParamPackage, L"-i");\r
-  CumulativeMode = ShellCommandLineGetFlag (ParamPackage, L"-c");\r
-\r
-  // Options with Values\r
-  CmdLineArg  = ShellCommandLineGetValue (ParamPackage, L"-n");\r
-  if (CmdLineArg == NULL) {\r
-    Number2Display = DEFAULT_DISPLAYCOUNT;\r
-  } else {\r
-    Number2Display = StrDecimalToUintn(CmdLineArg);\r
-    if (Number2Display == 0) {\r
-      Number2Display = MAXIMUM_DISPLAYCOUNT;\r
-    }\r
-  }\r
-\r
-  CmdLineArg  = ShellCommandLineGetValue (ParamPackage, L"-t");\r
-  if (CmdLineArg == NULL) {\r
-    mInterestThreshold = DEFAULT_THRESHOLD;  // 1ms := 1,000 us\r
-  } else {\r
-    mInterestThreshold = StrDecimalToUint64(CmdLineArg);\r
-  }\r
-\r
-  // Handle Flag combinations and default behaviors\r
-  // If both TraceMode and ProfileMode are FALSE, set them both to TRUE\r
-  if ((! TraceMode) && (! ProfileMode)) {\r
-    TraceMode   = TRUE;\r
-#if PROFILING_IMPLEMENTED\r
-    ProfileMode = TRUE;\r
-#endif  // PROFILING_IMPLEMENTED\r
-  }\r
-\r
-  //\r
-  // Initialize the pre-defined cumulative data.\r
-  //\r
-  InitCumulativeData ();\r
-\r
-  //\r
-  // Init the custom cumulative data.\r
-  //\r
-  CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c");\r
-  if (CustomCumulativeToken != NULL) {\r
-    CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA));\r
-    if (CustomCumulativeData == NULL) {\r
-      return SHELL_OUT_OF_RESOURCES;\r
-    }\r
-    CustomCumulativeData->MinDur = PERF_MAXDUR;\r
-    CustomCumulativeData->MaxDur = 0;\r
-    CustomCumulativeData->Count  = 0;\r
-    CustomCumulativeData->Duration = 0;\r
-    NameSize = StrLen (CustomCumulativeToken) + 1;\r
-    CustomCumulativeData->Name   = AllocateZeroPool (NameSize);\r
-    if (CustomCumulativeData->Name == NULL) {\r
-      FreePool (CustomCumulativeData);\r
-      return SHELL_OUT_OF_RESOURCES;\r
-    }\r
-    UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, NameSize);\r
-  }\r
-\r
-  //\r
-  // Timer specific processing\r
-  //\r
-  // Get the Performance counter characteristics:\r
-  //          Freq = Frequency in Hz\r
-  //    StartCount = Value loaded into the counter when it starts counting\r
-  //      EndCount = Value counter counts to before it needs to be reset\r
-  //\r
-  Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **) &PerformanceProperty);\r
-  if (EFI_ERROR (Status) || (PerformanceProperty == NULL)) {\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PERF_PROPERTY_NOT_FOUND), gDpHiiHandle);\r
-    goto Done;\r
-  }\r
-\r
-  TimerInfo.Frequency  = (UINT32)DivU64x32 (PerformanceProperty->Frequency, 1000);\r
-  TimerInfo.StartCount = PerformanceProperty->TimerStartValue;\r
-  TimerInfo.EndCount   = PerformanceProperty->TimerEndValue;\r
-\r
-  // Determine in which direction the performance counter counts.\r
-  TimerInfo.CountUp = (BOOLEAN) (TimerInfo.EndCount >= TimerInfo.StartCount);\r
-\r
-  //\r
-  // Print header\r
-  //\r
-  // print DP's build version\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_BUILD_REVISION), gDpHiiHandle, DP_MAJOR_VERSION, DP_MINOR_VERSION);\r
-\r
-  // print performance timer characteristics\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_KHZ), gDpHiiHandle, TimerInfo.Frequency);\r
-\r
-  if (VerboseMode && !RawMode) {\r
-    StringPtr = HiiGetString (gDpHiiHandle,\r
-                  (EFI_STRING_ID) (TimerInfo.CountUp ? STRING_TOKEN (STR_DP_UP) : STRING_TOKEN (STR_DP_DOWN)), NULL);\r
-    ASSERT (StringPtr != NULL);\r
-    // Print Timer count range and direction\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TIMER_PROPERTIES), gDpHiiHandle,\r
-                StringPtr,\r
-                TimerInfo.StartCount,\r
-                TimerInfo.EndCount\r
-                );\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_VERBOSE_THRESHOLD), gDpHiiHandle, mInterestThreshold);\r
-  }\r
-\r
-/****************************************************************************\r
-****            Print Sections based on command line options\r
-****\r
-****  Option modes have the following priority:\r
-****    v Verbose     --  Valid in combination with any other options\r
-****    t Threshold   --  Modifies All, Raw, and Cooked output\r
-****                      Default is 0 for All and Raw mode\r
-****                      Default is DEFAULT_THRESHOLD for "Cooked" mode\r
-****    n Number2Display  Used by All and Raw mode.  Otherwise ignored.\r
-****    A All         --  R and S options are ignored\r
-****    R Raw         --  S option is ignored\r
-****    s Summary     --  Modifies "Cooked" output only\r
-****    Cooked (Default)\r
-****\r
-****  The All, Raw, and Cooked modes are modified by the Trace and Profile\r
-****  options.\r
-****    !T && !P  := (0) Default, Both are displayed\r
-****     T && !P  := (1) Only Trace records are displayed\r
-****    !T &&  P  := (2) Only Profile records are displayed\r
-****     T &&  P  := (3) Same as Default, both are displayed\r
-****************************************************************************/\r
-  GatherStatistics (CustomCumulativeData);\r
-  if (CumulativeMode) {                       \r
-    ProcessCumulative (CustomCumulativeData);\r
-  } else if (AllMode) {\r
-    if (TraceMode) {\r
-      Status = DumpAllTrace( Number2Display, ExcludeMode);\r
-      if (Status == EFI_ABORTED) {\r
-        ShellStatus = SHELL_ABORTED;\r
-        goto Done;\r
-      }\r
-    }\r
-    if (ProfileMode) {\r
-      DumpAllProfile( Number2Display, ExcludeMode);\r
-    }\r
-  } else if (RawMode) {\r
-    if (TraceMode) {\r
-      Status = DumpRawTrace( Number2Display, ExcludeMode);\r
-      if (Status == EFI_ABORTED) {\r
-        ShellStatus = SHELL_ABORTED;\r
-        goto Done;\r
-      }\r
-    }\r
-    if (ProfileMode) {\r
-      DumpRawProfile( Number2Display, ExcludeMode);\r
-    }\r
-  } else {\r
-    //------------- Begin Cooked Mode Processing\r
-    if (TraceMode) {\r
-      ProcessPhases ();\r
-      if ( ! SummaryMode) {\r
-        Status = ProcessHandles ( ExcludeMode);\r
-        if (Status == EFI_ABORTED) {\r
-          ShellStatus = SHELL_ABORTED;\r
-          goto Done;\r
-        }\r
-\r
-        Status = ProcessPeims ();\r
-        if (Status == EFI_ABORTED) {\r
-          ShellStatus = SHELL_ABORTED;\r
-          goto Done;\r
-        }\r
-\r
-        Status = ProcessGlobal ();\r
-        if (Status == EFI_ABORTED) {\r
-          ShellStatus = SHELL_ABORTED;\r
-          goto Done;\r
-        }\r
-\r
-        ProcessCumulative (NULL);\r
-      }\r
-    }\r
-    if (ProfileMode) {\r
-      DumpAllProfile( Number2Display, ExcludeMode);\r
-    }\r
-  } //------------- End of Cooked Mode Processing\r
-  if ( VerboseMode || SummaryMode) {\r
-    DumpStatistics();\r
-  }\r
-\r
-Done:\r
-  if (ParamPackage != NULL) {\r
-    ShellCommandLineFreeVarList (ParamPackage);\r
-  }\r
-  SHELL_FREE_NON_NULL (StringPtr);\r
-  if (CustomCumulativeData != NULL) {\r
-    SHELL_FREE_NON_NULL (CustomCumulativeData->Name);\r
-  }\r
-  SHELL_FREE_NON_NULL (CustomCumulativeData);\r
-\r
-  return ShellStatus;\r
-}\r
diff --git a/ShellPkg/Library/UefiDpLib/Dp.h b/ShellPkg/Library/UefiDpLib/Dp.h
deleted file mode 100644 (file)
index 06fee3b..0000000
+++ /dev/null
@@ -1,97 +0,0 @@
-/** @file\r
-  Common declarations for the Dp Performance Reporting Utility.\r
-\r
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.\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
-#ifndef _EFI_APP_DP_H_\r
-#define _EFI_APP_DP_H_\r
-\r
-#include <Library/ShellLib.h>\r
-\r
-#define DP_MAJOR_VERSION        2\r
-#define DP_MINOR_VERSION        4\r
-\r
-/**\r
-  * The value assigned to DP_DEBUG controls which debug output\r
-  * is generated.  Set it to ZERO to disable.\r
-**/\r
-#define DP_DEBUG                0\r
-\r
-/**\r
-  * Set to 1 once Profiling has been implemented in order to enable\r
-  * profiling related options and report output.\r
-**/\r
-#define PROFILING_IMPLEMENTED   0\r
-\r
-#define DEFAULT_THRESHOLD       1000    ///< One millisecond.\r
-#define DEFAULT_DISPLAYCOUNT    50\r
-#define MAXIMUM_DISPLAYCOUNT    999999  ///< Arbitrary maximum reasonable number.\r
-\r
-#define PERF_MAXDUR             0xFFFFFFFFFFFFFFFFULL\r
-\r
-/// Determine whether  0 <= C < L.  If L == 0, return true regardless of C.\r
-#define WITHIN_LIMIT( C, L)   ( ((L) == 0) || ((C) < (L)) )\r
-\r
-/// Structure for storing Timer specific information.\r
-typedef struct {\r
-  UINT64    StartCount;   ///< Value timer is initialized with.\r
-  UINT64    EndCount;     ///< Value timer has just before it wraps.\r
-  UINT32    Frequency;    ///< Timer count frequency in KHz.\r
-  BOOLEAN   CountUp;      ///< TRUE if the counter counts up.\r
-} TIMER_INFO;\r
-\r
-/** Initialize one PERF_CUM_DATA structure instance for token t.\r
-  *\r
-  * This parameterized macro takes a single argument, t, which is expected\r
-  * to resolve to a pointer to an ASCII string literal.  This parameter may\r
-  * take any one of the following forms:\r
-  *   - PERF_INIT_CUM_DATA("Token")         A string literal\r
-  *   - PERF_INIT_CUM_DATA(pointer)         A pointer -- CHAR8 *pointer;\r
-  *   - PERF_INIT_CUM_DATA(array)           Address of an array -- CHAR8 array[N];\r
-**/\r
-#define PERF_INIT_CUM_DATA(t)   { 0ULL, PERF_MAXDUR, 0ULL, (t), 0U }\r
-\r
-typedef struct {\r
-  UINT64  Duration;     ///< Cumulative duration for this item.\r
-  UINT64  MinDur;       ///< Smallest duration encountered.\r
-  UINT64  MaxDur;       ///< Largest duration encountered.\r
-  CHAR8   *Name;        ///< ASCII name of this item.\r
-  UINT32  Count;        ///< Total number of measurements accumulated.\r
-} PERF_CUM_DATA;\r
-\r
-typedef struct {\r
-  UINT32                NumTrace;         ///< Number of recorded TRACE performance measurements.\r
-  UINT32                NumProfile;       ///< Number of recorded PROFILE performance measurements.\r
-  UINT32                NumIncomplete;    ///< Number of measurements with no END value.\r
-  UINT32                NumSummary;       ///< Number of summary section measurements.\r
-  UINT32                NumHandles;       ///< Number of measurements with handles.\r
-  UINT32                NumPEIMs;         ///< Number of measurements of PEIMs.\r
-  UINT32                NumGlobal;        ///< Number of measurements with END value and NULL handle.\r
-} PERF_SUMMARY_DATA;\r
-\r
-typedef struct {\r
-  CONST VOID            *Handle;\r
-  CONST CHAR8           *Token;           ///< Measured token string name.\r
-  CONST CHAR8           *Module;          ///< Module string name.\r
-  UINT64                StartTimeStamp;   ///< Start time point.\r
-  UINT64                EndTimeStamp;     ///< End time point.\r
-  UINT32                Identifier;       ///< Identifier.\r
-} MEASUREMENT_RECORD;\r
-\r
-typedef struct {\r
-  CHAR8                 *Name;            ///< Measured token string name.\r
-  UINT64                CumulativeTime;   ///< Accumulated Elapsed Time.\r
-  UINT64                MinTime;          ///< Minimum Elapsed Time.\r
-  UINT64                MaxTime;          ///< Maximum Elapsed Time.\r
-  UINT32                Count;            ///< Number of measurements accumulated.\r
-} PROFILE_RECORD;\r
-\r
-#endif  // _EFI_APP_DP_H_\r
diff --git a/ShellPkg/Library/UefiDpLib/DpInternal.h b/ShellPkg/Library/UefiDpLib/DpInternal.h
deleted file mode 100644 (file)
index 6de194a..0000000
+++ /dev/null
@@ -1,354 +0,0 @@
-/** @file\r
-  Declarations of objects defined internally to the Dp Application.\r
-\r
-  Declarations of data and functions which are private to the Dp application.\r
-  This file should never be referenced by anything other than components of the\r
-  Dp application.  In addition to global data, function declarations for\r
-  DpUtilities.c, DpTrace.c, and DpProfile.c are included here.\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
-#ifndef _DP_INTELNAL_H_\r
-#define _DP_INTELNAL_H_\r
-\r
-#define DP_GAUGE_STRING_LENGTH   36\r
-\r
-//\r
-/// Module-Global Variables\r
-///@{\r
-extern EFI_HII_HANDLE     gDpHiiHandle;\r
-extern CHAR16             mGaugeString[DP_GAUGE_STRING_LENGTH + 1];\r
-extern CHAR16             mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];\r
-extern UINT64             mInterestThreshold;\r
-extern BOOLEAN            mShowId;\r
-\r
-extern PERF_SUMMARY_DATA  SummaryData;    ///< Create the SummaryData structure and init. to ZERO.\r
-\r
-/// Timer Specific Information.\r
-extern TIMER_INFO         TimerInfo;\r
-\r
-/// Items for which to gather cumulative statistics.\r
-extern PERF_CUM_DATA      CumData[];\r
-\r
-/// Number of items for which we are gathering cumulative statistics.\r
-extern UINT32 const       NumCum;\r
-\r
-///@}\r
-\r
-/** \r
-  Calculate an event's duration in timer ticks.\r
-  \r
-  Given the count direction and the event's start and end timer values,\r
-  calculate the duration of the event in timer ticks.  Information for\r
-  the current measurement is pointed to by the parameter.\r
-  \r
-  If the measurement's start time is 1, it indicates that the developer\r
-  is indicating that the measurement began at the release of reset.\r
-  The start time is adjusted to the timer's starting count before performing\r
-  the elapsed time calculation.\r
-  \r
-  The calculated duration, in ticks, is the absolute difference between\r
-  the measurement's ending and starting counts.\r
-  \r
-  @param Measurement   Pointer to a MEASUREMENT_RECORD structure containing\r
-                       data for the current measurement.\r
-  \r
-  @return              The 64-bit duration of the event.\r
-**/\r
-UINT64\r
-GetDuration (\r
-  IN OUT MEASUREMENT_RECORD *Measurement\r
-  );\r
-\r
-/** \r
-  Determine whether the Measurement record is for an EFI Phase.\r
-  \r
-  The Token and Module members of the measurement record are checked.\r
-  Module must be empty and Token must be one of SEC, PEI, DXE, BDS, or SHELL.\r
-  \r
-  @param[in]  Measurement A pointer to the Measurement record to test.\r
-  \r
-  @retval     TRUE        The measurement record is for an EFI Phase.\r
-  @retval     FALSE       The measurement record is NOT for an EFI Phase.\r
-**/\r
-BOOLEAN\r
-IsPhase(\r
-  IN MEASUREMENT_RECORD *Measurement\r
-  );\r
-\r
-/** \r
-  Get the file name portion of the Pdb File Name.\r
-  \r
-  The portion of the Pdb File Name between the last backslash and\r
-  either a following period or the end of the string is converted\r
-  to Unicode and copied into UnicodeBuffer.  The name is truncated,\r
-  if necessary, to ensure that UnicodeBuffer is not overrun.\r
-  \r
-  @param[in]  PdbFileName     Pdb file name.\r
-  @param[out] UnicodeBuffer   The resultant Unicode File Name.\r
-  \r
-**/\r
-VOID\r
-DpGetShortPdbFileName (\r
-  IN  CHAR8     *PdbFileName,\r
-  OUT CHAR16    *UnicodeBuffer\r
-  );\r
-\r
-/** \r
-  Get a human readable name for an image handle.\r
-  The following methods will be tried orderly:\r
-    1. Image PDB\r
-    2. ComponentName2 protocol\r
-    3. FFS UI section\r
-    4. Image GUID\r
-    5. Image DevicePath\r
-    6. Unknown Driver Name\r
-  \r
-  @param[in]    Handle\r
-  \r
-  @post   The resulting Unicode name string is stored in the\r
-          mGaugeString global array.\r
-  \r
-**/\r
-VOID\r
-DpGetNameFromHandle (\r
-  IN EFI_HANDLE Handle\r
-  );\r
-\r
-/** \r
-  Calculate the Duration in microseconds.\r
-  \r
-  Duration is multiplied by 1000, instead of Frequency being divided by 1000 or\r
-  multiplying the result by 1000, in order to maintain precision.  Since Duration is\r
-  a 64-bit value, multiplying it by 1000 is unlikely to produce an overflow.\r
-  \r
-  The time is calculated as (Duration * 1000) / Timer_Frequency.\r
-  \r
-  @param[in]  Duration   The event duration in timer ticks.\r
-  \r
-  @return     A 64-bit value which is the Elapsed time in microseconds.\r
-**/\r
-UINT64\r
-DurationInMicroSeconds (\r
-  IN UINT64 Duration\r
-  );\r
-\r
-/** \r
-  Get index of Measurement Record's match in the CumData array.\r
-  \r
-  If the Measurement's Token value matches a Token in one of the CumData\r
-  records, the index of the matching record is returned.  The returned\r
-  index is a signed value so that negative values can indicate that\r
-  the Measurement didn't match any entry in the CumData array.\r
-  \r
-  @param[in]  Measurement A pointer to a Measurement Record to match against the CumData array.\r
-  \r
-  @retval     <0    Token is not in the CumData array.\r
-  @retval     >=0   Return value is the index into CumData where Token is found.\r
-**/\r
-INTN\r
-GetCumulativeItem(\r
-  IN MEASUREMENT_RECORD *Measurement\r
-  );\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  The pointer to the custom cumulative data.\r
-\r
-**/\r
-VOID\r
-GatherStatistics(\r
-  IN OUT PERF_CUM_DATA              *CustomCumulativeData OPTIONAL\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
-/** \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
-  @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
-/** \r
-  Gather and print Major Phase metrics.\r
-  \r
-**/\r
-VOID\r
-ProcessPhases(\r
-  VOID\r
-  );\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
-\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
-/** \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
-/** \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  The pointer to the custom cumulative data.\r
-  \r
-**/\r
-VOID\r
-ProcessCumulative(\r
-  IN PERF_CUM_DATA                  *CustomCumulativeData OPTIONAL\r
-  );\r
-\r
-/** \r
-  Gather and print ALL Profiling Records.\r
-  \r
-  Displays all "interesting" Profile measurements in order.\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
-**/\r
-VOID\r
-DumpAllProfile(\r
-  IN UINTN          Limit,\r
-  IN BOOLEAN        ExcludeFlag\r
-  );\r
-\r
-/** \r
-  Gather and print Raw Profile Records.\r
-  \r
-  All Profile 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
-**/\r
-VOID\r
-DumpRawProfile(\r
-  IN UINTN          Limit,\r
-  IN BOOLEAN        ExcludeFlag\r
-  );\r
-\r
-#endif\r
diff --git a/ShellPkg/Library/UefiDpLib/DpProfile.c b/ShellPkg/Library/UefiDpLib/DpProfile.c
deleted file mode 100644 (file)
index e443403..0000000
+++ /dev/null
@@ -1,100 +0,0 @@
-/** @file\r
-  Measured Profiling reporting for the Dp utility.\r
-\r
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\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
-  Gather and print ALL Profiling Records.\r
-  \r
-  Displays all "interesting" Profile measurements in order.\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
-**/\r
-VOID\r
-DumpAllProfile(\r
-  IN UINTN      Limit,\r
-  IN BOOLEAN    ExcludeFlag\r
-  )\r
-{\r
-  EFI_STRING    StringPtr;\r
-  EFI_STRING    StringPtrUnknown;\r
-\r
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);   \r
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PROFILE), NULL);\r
-\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
-\r
-/** \r
-  Gather and print Raw Profile Records.\r
-  \r
-  All Profile 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
-**/\r
-VOID\r
-DumpRawProfile(\r
-  IN UINTN      Limit,\r
-  IN BOOLEAN    ExcludeFlag\r
-  )\r
-{\r
-  EFI_STRING    StringPtr;\r
-  EFI_STRING    StringPtrUnknown;\r
-\r
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);\r
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWPROFILE), 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
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
diff --git a/ShellPkg/Library/UefiDpLib/DpUtilities.c b/ShellPkg/Library/UefiDpLib/DpUtilities.c
deleted file mode 100644 (file)
index c60d27d..0000000
+++ /dev/null
@@ -1,404 +0,0 @@
-/** @file\r
-  Utility functions used by the Dp application.\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/PrintLib.h>\r
-#include <Library/HiiLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/DevicePathLib.h>\r
-#include <Library/HandleParsingLib.h>\r
-\r
-#include <Pi/PiFirmwareFile.h>\r
-#include <Library/DxeServicesLib.h>\r
-\r
-#include <Protocol/LoadedImage.h>\r
-#include <Protocol/DriverBinding.h>\r
-#include <Protocol/ComponentName2.h>\r
-#include <Protocol/DevicePath.h>\r
-\r
-#include <Guid/Performance.h>\r
-\r
-#include "Dp.h"\r
-#include "Literals.h"\r
-#include "DpInternal.h"\r
-\r
-/** \r
-  Calculate an event's duration in timer ticks.\r
-  \r
-  Given the count direction and the event's start and end timer values,\r
-  calculate the duration of the event in timer ticks.  Information for\r
-  the current measurement is pointed to by the parameter.\r
-  \r
-  If the measurement's start time is 1, it indicates that the developer\r
-  is indicating that the measurement began at the release of reset.\r
-  The start time is adjusted to the timer's starting count before performing\r
-  the elapsed time calculation.\r
-  \r
-  The calculated duration, in ticks, is the absolute difference between\r
-  the measurement's ending and starting counts.\r
-  \r
-  @param Measurement   Pointer to a MEASUREMENT_RECORD structure containing\r
-                       data for the current measurement.\r
-  \r
-  @return              The 64-bit duration of the event.\r
-**/\r
-UINT64\r
-GetDuration (\r
-  IN OUT MEASUREMENT_RECORD   *Measurement\r
-  )\r
-{\r
-  UINT64    Duration;\r
-  BOOLEAN   Error;\r
-\r
-  if (Measurement->EndTimeStamp == 0) {\r
-    return 0;\r
-  }\r
-\r
-  // PERF_START macros are called with a value of 1 to indicate\r
-  // the beginning of time.  So, adjust the start ticker value\r
-  // to the real beginning of time.\r
-  // Assumes no wraparound.  Even then, there is a very low probability\r
-  // of having a valid StartTicker value of 1.\r
-  if (Measurement->StartTimeStamp == 1) {\r
-    Measurement->StartTimeStamp = TimerInfo.StartCount;\r
-  }\r
-  if (TimerInfo.CountUp) {\r
-    Duration = Measurement->EndTimeStamp - Measurement->StartTimeStamp;\r
-    Error = (BOOLEAN)(Duration > Measurement->EndTimeStamp);\r
-  }\r
-  else {\r
-    Duration = Measurement->StartTimeStamp - Measurement->EndTimeStamp;\r
-    Error = (BOOLEAN)(Duration > Measurement->StartTimeStamp);\r
-  }\r
-\r
-  if (Error) {\r
-    DEBUG ((EFI_D_ERROR, ALit_TimerLibError));\r
-    Duration = 0;\r
-  }\r
-  return Duration;\r
-}\r
-\r
-/** \r
-  Determine whether the Measurement record is for an EFI Phase.\r
-  \r
-  The Token and Module members of the measurement record are checked.\r
-  Module must be empty and Token must be one of SEC, PEI, DXE, BDS, or SHELL.\r
-  \r
-  @param[in]  Measurement A pointer to the Measurement record to test.\r
-  \r
-  @retval     TRUE        The measurement record is for an EFI Phase.\r
-  @retval     FALSE       The measurement record is NOT for an EFI Phase.\r
-**/\r
-BOOLEAN\r
-IsPhase(\r
-  IN MEASUREMENT_RECORD        *Measurement\r
-  )\r
-{\r
-  BOOLEAN   RetVal;\r
-\r
-  RetVal = (BOOLEAN)( ( *Measurement->Module == '\0')                               &&\r
-            ((AsciiStrnCmp (Measurement->Token, ALit_SEC, PERF_TOKEN_LENGTH) == 0)    ||\r
-             (AsciiStrnCmp (Measurement->Token, ALit_PEI, PERF_TOKEN_LENGTH) == 0)    ||\r
-             (AsciiStrnCmp (Measurement->Token, ALit_DXE, PERF_TOKEN_LENGTH) == 0)    ||\r
-             (AsciiStrnCmp (Measurement->Token, ALit_BDS, PERF_TOKEN_LENGTH) == 0))\r
-            );\r
-  return RetVal;\r
-}\r
-\r
-/** \r
-  Get the file name portion of the Pdb File Name.\r
-  \r
-  The portion of the Pdb File Name between the last backslash and\r
-  either a following period or the end of the string is converted\r
-  to Unicode and copied into UnicodeBuffer.  The name is truncated,\r
-  if necessary, to ensure that UnicodeBuffer is not overrun.\r
-  \r
-  @param[in]  PdbFileName     Pdb file name.\r
-  @param[out] UnicodeBuffer   The resultant Unicode File Name.\r
-  \r
-**/\r
-VOID\r
-DpGetShortPdbFileName (\r
-  IN  CHAR8     *PdbFileName,\r
-  OUT CHAR16    *UnicodeBuffer\r
-  )\r
-{\r
-  UINTN IndexA;     // Current work location within an ASCII string.\r
-  UINTN IndexU;     // Current work location within a Unicode string.\r
-  UINTN StartIndex;\r
-  UINTN EndIndex;\r
-\r
-  ZeroMem (UnicodeBuffer, (DP_GAUGE_STRING_LENGTH + 1) * sizeof (CHAR16));\r
-\r
-  if (PdbFileName == NULL) {\r
-    StrnCpyS (UnicodeBuffer, DP_GAUGE_STRING_LENGTH + 1, L" ", 1);\r
-  } else {\r
-    StartIndex = 0;\r
-    for (EndIndex = 0; PdbFileName[EndIndex] != 0; EndIndex++)\r
-      ;\r
-    for (IndexA = 0; PdbFileName[IndexA] != 0; IndexA++) {\r
-      if ((PdbFileName[IndexA] == '\\') || (PdbFileName[IndexA] == '/')) {\r
-        StartIndex = IndexA + 1;\r
-      }\r
-\r
-      if (PdbFileName[IndexA] == '.') {\r
-        EndIndex = IndexA;\r
-      }\r
-    }\r
-\r
-    IndexU = 0;\r
-    for (IndexA = StartIndex; IndexA < EndIndex; IndexA++) {\r
-      UnicodeBuffer[IndexU] = (CHAR16) PdbFileName[IndexA];\r
-      IndexU++;\r
-      if (IndexU >= DP_GAUGE_STRING_LENGTH) {\r
-        UnicodeBuffer[DP_GAUGE_STRING_LENGTH] = 0;\r
-        break;\r
-      }\r
-    }\r
-  }\r
-}\r
-\r
-/** \r
-  Get a human readable name for an image handle.\r
-  The following methods will be tried orderly:\r
-    1. Image PDB\r
-    2. ComponentName2 protocol\r
-    3. FFS UI section\r
-    4. Image GUID\r
-    5. Image DevicePath\r
-    6. Unknown Driver Name\r
-\r
-  @param[in]    Handle\r
-\r
-  @post   The resulting Unicode name string is stored in the\r
-          mGaugeString global array.\r
-\r
-**/\r
-VOID\r
-DpGetNameFromHandle (\r
-  IN EFI_HANDLE   Handle\r
-  )\r
-{\r
-  EFI_STATUS                  Status;\r
-  EFI_LOADED_IMAGE_PROTOCOL   *Image;\r
-  CHAR8                       *PdbFileName;\r
-  EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;\r
-  EFI_STRING                  StringPtr;\r
-  EFI_DEVICE_PATH_PROTOCOL    *LoadedImageDevicePath;\r
-  EFI_DEVICE_PATH_PROTOCOL    *DevicePath;\r
-  EFI_GUID                    *NameGuid;\r
-  CHAR16                      *NameString;\r
-  UINTN                       StringSize;\r
-  CHAR8                       *PlatformLanguage;\r
-  EFI_COMPONENT_NAME2_PROTOCOL      *ComponentName2;\r
-\r
-  Image = NULL;\r
-  LoadedImageDevicePath = NULL;\r
-  DevicePath = NULL;\r
-\r
-  //\r
-  // Method 1: Get the name string from image PDB\r
-  //\r
-  Status = gBS->HandleProtocol (\r
-                  Handle,\r
-                  &gEfiLoadedImageProtocolGuid,\r
-                  (VOID **) &Image\r
-                  );\r
-\r
-  if (EFI_ERROR (Status)) {\r
-    Status = gBS->OpenProtocol (\r
-                    Handle,\r
-                    &gEfiDriverBindingProtocolGuid,\r
-                    (VOID **) &DriverBinding,\r
-                    NULL,\r
-                    NULL,\r
-                    EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
-                    );\r
-    if (!EFI_ERROR (Status)) {\r
-      Status = gBS->HandleProtocol (\r
-                      DriverBinding->ImageHandle,\r
-                      &gEfiLoadedImageProtocolGuid,\r
-                      (VOID **) &Image\r
-                      );\r
-    }\r
-  }\r
-\r
-  if (!EFI_ERROR (Status)) {\r
-    PdbFileName = PeCoffLoaderGetPdbPointer (Image->ImageBase);\r
-\r
-    if (PdbFileName != NULL) {\r
-      DpGetShortPdbFileName (PdbFileName, mGaugeString);\r
-      return;\r
-    }\r
-  }\r
-\r
-  //\r
-  // Method 2: Get the name string from ComponentName2 protocol\r
-  //\r
-  Status = gBS->HandleProtocol (\r
-                  Handle,\r
-                  &gEfiComponentName2ProtocolGuid,\r
-                  (VOID **) &ComponentName2\r
-                  );\r
-  if (!EFI_ERROR (Status)) {\r
-    //\r
-    // Get the current platform language setting\r
-    //\r
-    PlatformLanguage = GetBestLanguageForDriver(ComponentName2->SupportedLanguages, NULL, FALSE);\r
-    Status = ComponentName2->GetDriverName (\r
-                               ComponentName2,\r
-                               PlatformLanguage != NULL ? PlatformLanguage : "en-US",\r
-                               &StringPtr\r
-                               );\r
-    if (!EFI_ERROR (Status)) {\r
-      SHELL_FREE_NON_NULL (PlatformLanguage);\r
-      StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr, DP_GAUGE_STRING_LENGTH);\r
-      mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;\r
-      return;\r
-    }\r
-  }\r
-\r
-  Status = gBS->HandleProtocol (\r
-                  Handle,\r
-                  &gEfiLoadedImageDevicePathProtocolGuid,\r
-                  (VOID **) &LoadedImageDevicePath\r
-                  );\r
-  if (!EFI_ERROR (Status) && (LoadedImageDevicePath != NULL)) {\r
-    DevicePath = LoadedImageDevicePath;\r
-  } else if (Image != NULL) {\r
-    DevicePath = Image->FilePath;\r
-  }\r
-\r
-  if (DevicePath != NULL) {\r
-    //\r
-    // Try to get image GUID from image DevicePath\r
-    //\r
-    NameGuid = NULL;\r
-    while (!IsDevicePathEndType (DevicePath)) {\r
-      NameGuid = EfiGetNameGuidFromFwVolDevicePathNode ((MEDIA_FW_VOL_FILEPATH_DEVICE_PATH *) DevicePath);\r
-      if (NameGuid != NULL) {\r
-        break;\r
-      }\r
-      DevicePath = NextDevicePathNode (DevicePath);\r
-    }\r
-\r
-    if (NameGuid != NULL) {\r
-      //\r
-      // Try to get the image's FFS UI section by image GUID\r
-      //\r
-      NameString = NULL;\r
-      StringSize = 0;\r
-      Status = GetSectionFromAnyFv (\r
-                NameGuid,\r
-                EFI_SECTION_USER_INTERFACE,\r
-                0,\r
-                (VOID **) &NameString,\r
-                &StringSize\r
-                );\r
-\r
-      if (!EFI_ERROR (Status)) {\r
-        //\r
-        // Method 3. Get the name string from FFS UI section\r
-        //\r
-        StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, NameString, DP_GAUGE_STRING_LENGTH);\r
-        mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;\r
-        FreePool (NameString);\r
-      } else {\r
-        //\r
-        // Method 4: Get the name string from image GUID\r
-        //\r
-        UnicodeSPrint (mGaugeString, sizeof (mGaugeString), L"%g", NameGuid);\r
-      }\r
-      return;\r
-    } else {\r
-      //\r
-      // Method 5: Get the name string from image DevicePath\r
-      //\r
-      NameString = ConvertDevicePathToText (DevicePath, TRUE, FALSE);\r
-      if (NameString != NULL) {\r
-        StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, NameString, DP_GAUGE_STRING_LENGTH);\r
-        mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;\r
-        FreePool (NameString);\r
-        return;\r
-      }\r
-    }\r
-  }\r
-\r
-  //\r
-  // Method 6: Unknown Driver Name\r
-  //\r
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_ERROR_NAME), NULL);\r
-  ASSERT (StringPtr != NULL);\r
-  StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr, DP_GAUGE_STRING_LENGTH);\r
-  FreePool (StringPtr);\r
-}\r
-\r
-/** \r
-  Calculate the Duration in microseconds.\r
-  \r
-  Duration is multiplied by 1000, instead of Frequency being divided by 1000 or\r
-  multiplying the result by 1000, in order to maintain precision.  Since Duration is\r
-  a 64-bit value, multiplying it by 1000 is unlikely to produce an overflow.\r
-  \r
-  The time is calculated as (Duration * 1000) / Timer_Frequency.\r
-  \r
-  @param[in]  Duration   The event duration in timer ticks.\r
-  \r
-  @return     A 64-bit value which is the Elapsed time in microseconds.\r
-**/\r
-UINT64\r
-DurationInMicroSeconds (\r
-  IN UINT64 Duration\r
-  )\r
-{\r
-  UINT64 Temp;\r
-\r
-  Temp = MultU64x32 (Duration, 1000);\r
-  return DivU64x32 (Temp, TimerInfo.Frequency);\r
-}\r
-\r
-/** \r
-  Get index of Measurement Record's match in the CumData array.\r
-  \r
-  If the Measurement's Token value matches a Token in one of the CumData\r
-  records, the index of the matching record is returned.  The returned\r
-  index is a signed value so that negative values can indicate that\r
-  the Measurement didn't match any entry in the CumData array.\r
-  \r
-  @param[in]  Measurement A pointer to a Measurement Record to match against the CumData array.\r
-  \r
-  @retval     <0    Token is not in the CumData array.\r
-  @retval     >=0   Return value is the index into CumData where Token is found.\r
-**/\r
-INTN\r
-GetCumulativeItem(\r
-  IN MEASUREMENT_RECORD   *Measurement\r
-  )\r
-{\r
-  INTN    Index;\r
-\r
-  for( Index = 0; Index < (INTN)NumCum; ++Index) {\r
-    if (AsciiStrnCmp (Measurement->Token, CumData[Index].Name, PERF_TOKEN_LENGTH) == 0) {\r
-      return Index;  // Exit, we found a match\r
-    }\r
-  }\r
-  // If the for loop exits, Token was not found.\r
-  return -1;   // Indicate failure\r
-}\r
diff --git a/ShellPkg/Library/UefiDpLib/Literals.c b/ShellPkg/Library/UefiDpLib/Literals.c
deleted file mode 100644 (file)
index c1cddfb..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-/** @file\r
-  Definitions of ASCII string literals used by DP.\r
-\r
-  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<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
-#include <PerformanceTokens.h>\r
-\r
-// ASCII String literals which probably don't need translation\r
-CHAR8 const ALit_TimerLibError[] = "Timer library instance error!\n";\r
-CHAR8 const ALit_SEC[]    = SEC_TOK;\r
-CHAR8 const ALit_DXE[]    = DXE_TOK;\r
-CHAR8 const ALit_PEI[]    = PEI_TOK;\r
-CHAR8 const ALit_BDS[]    = BDS_TOK;\r
-CHAR8 const ALit_BdsTO[]  = "BdsTimeOut";\r
-CHAR8 const ALit_PEIM[]   = "PEIM";\r
diff --git a/ShellPkg/Library/UefiDpLib/Literals.h b/ShellPkg/Library/UefiDpLib/Literals.h
deleted file mode 100644 (file)
index 8aec09c..0000000
+++ /dev/null
@@ -1,26 +0,0 @@
-/** @file\r
-  Declarations of ASCII string literals used by DP.\r
-\r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<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
-#ifndef _LITERALS_H_\r
-#define _LITERALS_H_\r
-\r
-// ASCII String literals which probably don't need translation\r
-extern CHAR8 const ALit_TimerLibError[];\r
-extern CHAR8 const ALit_SEC[];\r
-extern CHAR8 const ALit_DXE[];\r
-extern CHAR8 const ALit_SHELL[];\r
-extern CHAR8 const ALit_PEI[];\r
-extern CHAR8 const ALit_BDS[];\r
-extern CHAR8 const ALit_BdsTO[];\r
-extern CHAR8 const ALit_PEIM[];\r
-\r
-#endif  // _LITERALS_H_\r
diff --git a/ShellPkg/Library/UefiDpLib/PerformanceTokens.h b/ShellPkg/Library/UefiDpLib/PerformanceTokens.h
deleted file mode 100644 (file)
index bbbc48d..0000000
+++ /dev/null
@@ -1,28 +0,0 @@
-/** @file\r
-  ASCII String Literals with special meaning to Performance measurement and the Dp utility.\r
-\r
-Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<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
-\r
-#ifndef __PERFORMANCE_TOKENS_H__\r
-#define __PERFORMANCE_TOKENS_H__\r
-\r
-#define SEC_TOK                         "SEC"             ///< SEC Phase\r
-#define DXE_TOK                         "DXE"             ///< DEC Phase\r
-#define SHELL_TOK                       "SHELL"           ///< Shell Phase\r
-#define PEI_TOK                         "PEI"             ///< PEI Phase\r
-#define BDS_TOK                         "BDS"             ///< BDS Phase\r
-#define DRIVERBINDING_START_TOK         "DB:Start:"       ///< Driver Binding Start() function call\r
-#define DRIVERBINDING_SUPPORT_TOK       "DB:Support:"     ///< Driver Binding Support() function call\r
-#define LOAD_IMAGE_TOK                  "LoadImage:"      ///< Load a dispatched module\r
-#define START_IMAGE_TOK                 "StartImage:"     ///< Dispatched Modules Entry Point execution\r
-\r
-#endif  // __PERFORMANCE_TOKENS_H__\r
diff --git a/ShellPkg/Library/UefiDpLib/Readme.txt b/ShellPkg/Library/UefiDpLib/Readme.txt
deleted file mode 100644 (file)
index 849efa4..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-from PerformancePkg\Dp_App\r
-SVN 13406\r
diff --git a/ShellPkg/Library/UefiDpLib/UefiDpLib.c b/ShellPkg/Library/UefiDpLib/UefiDpLib.c
deleted file mode 100644 (file)
index f3ecfea..0000000
+++ /dev/null
@@ -1,101 +0,0 @@
-/** @file\r
-  Main file for NULL named library for install1 shell command functions.\r
-\r
-  Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.\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
-\r
-#include "UefiDpLib.h"\r
-\r
-STATIC CONST CHAR16 mFileName[] = L"ShellCommands";\r
-EFI_HANDLE gDpHiiHandle = NULL;\r
-\r
-#define DP_HII_GUID \\r
-  { \\r
-  0xeb832fd9, 0x9089, 0x4898, { 0x83, 0xc9, 0x41, 0x61, 0x8f, 0x5c, 0x48, 0xb9 } \\r
-  }\r
-\r
-EFI_GUID gDpHiiGuid = DP_HII_GUID;\r
-\r
-/**\r
-  Function to get the filename with help context if HII will not be used.\r
-\r
-  @return   The filename with help text in it.\r
-**/\r
-CONST CHAR16*\r
-EFIAPI\r
-UefiDpLibGetManFileName (\r
-  VOID\r
-  )\r
-{\r
-  return (mFileName);\r
-}\r
-\r
-/**\r
-  Constructor for the Shell Level 1 Commands library.\r
-\r
-  Install the handlers for level 1 UEFI Shell 2.0 commands.\r
-\r
-  @param ImageHandle    the image handle of the process\r
-  @param SystemTable    the EFI System Table pointer\r
-\r
-  @retval EFI_SUCCESS        the shell command handlers were installed sucessfully\r
-  @retval EFI_UNSUPPORTED    the shell level required was not found.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UefiDpLibConstructor (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-  //\r
-  // check our bit of the profiles mask\r
-  //\r
-  if ((PcdGet8(PcdShellProfileMask) & BIT2) == 0) {\r
-    return (EFI_SUCCESS);\r
-  }\r
-\r
-  //\r
-  // 3rd parameter 'HII strings array' must be name of .uni strings file followed by 'Strings', e.g. mycommands.uni must be\r
-  // specified as 'mycommandsStrings' because the build Autogen process defines this as a string array for the strings in your\r
-  // .uni file.  Examine your Build folder under your package's DEBUG folder and you will find it defined in a xxxStrDefs.h file.\r
-  //\r
-  gDpHiiHandle = HiiAddPackages (&gDpHiiGuid, gImageHandle, UefiDpLibStrings, NULL);\r
-  if (gDpHiiHandle == NULL) {\r
-    return (EFI_DEVICE_ERROR);\r
-  }\r
-\r
-  //\r
-  // install our shell command handlers that are always installed\r
-  //\r
-  ShellCommandRegisterCommandName(L"dp", ShellCommandRunDp , UefiDpLibGetManFileName, 0, L"", FALSE, gDpHiiHandle, STRING_TOKEN(STR_GET_HELP_DP));\r
-\r
-  return (EFI_SUCCESS);\r
-}\r
-\r
-/**\r
-  Destructor for the library.  free any resources.\r
-\r
-  @param ImageHandle            The image handle of the process.\r
-  @param SystemTable            The EFI System Table pointer.\r
-**/\r
-EFI_STATUS\r
-EFIAPI\r
-UefiDpLibDestructor (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  )\r
-{\r
-  if (gDpHiiHandle != NULL) {\r
-    HiiRemovePackages(gDpHiiHandle);\r
-  }\r
-  return (EFI_SUCCESS);\r
-}\r
diff --git a/ShellPkg/Library/UefiDpLib/UefiDpLib.h b/ShellPkg/Library/UefiDpLib/UefiDpLib.h
deleted file mode 100644 (file)
index 283f833..0000000
+++ /dev/null
@@ -1,64 +0,0 @@
-/** @file\r
-  Main file for NULL named library for dp command functions.\r
-\r
-  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>\r
-  (C) Copyright 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
-\r
-#ifndef _UEFI_DP_LIB_H_\r
-#define _UEFI_DP_LIB_H_\r
-\r
-#include <Uefi.h>\r
-\r
-extern EFI_GUID gDpHiiGuid;\r
-\r
-#include <Protocol/Shell.h>\r
-#include <Protocol/ShellParameters.h>\r
-#include <Protocol/DevicePath.h>\r
-#include <Protocol/LoadedImage.h>\r
-#include <Protocol/UnicodeCollation.h>\r
-\r
-#include <Library/BaseLib.h>\r
-#include <Library/BaseMemoryLib.h>\r
-#include <Library/DebugLib.h>\r
-#include <Library/MemoryAllocationLib.h>\r
-#include <Library/PcdLib.h>\r
-#include <Library/ShellCommandLib.h>\r
-#include <Library/ShellLib.h>\r
-#include <Library/SortLib.h>\r
-#include <Library/UefiLib.h>\r
-#include <Library/UefiRuntimeServicesTableLib.h>\r
-#include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/HiiLib.h>\r
-#include <Library/FileHandleLib.h>\r
-\r
-extern        EFI_HANDLE                        gDpHiiHandle;\r
-\r
-/**\r
-  Function for 'dp' command.\r
-\r
-  @param[in] ImageHandle  Handle to the Image (NULL if Internal).\r
-  @param[in] SystemTable  Pointer to the System Table (NULL if Internal).\r
-\r
-  @retval SHELL_SUCCESS            Command completed successfully.\r
-  @retval SHELL_INVALID_PARAMETER  Command usage error.\r
-  @retval SHELL_ABORTED            The user aborts the operation.\r
-  @retval value                    Unknown error.\r
-**/\r
-SHELL_STATUS\r
-EFIAPI\r
-ShellCommandRunDp (\r
-  IN EFI_HANDLE        ImageHandle,\r
-  IN EFI_SYSTEM_TABLE  *SystemTable\r
-  );\r
-\r
-#endif\r
-\r
diff --git a/ShellPkg/Library/UefiDpLib/UefiDpLib.inf b/ShellPkg/Library/UefiDpLib/UefiDpLib.inf
deleted file mode 100644 (file)
index 0bce0ce..0000000
+++ /dev/null
@@ -1,77 +0,0 @@
-##  @file\r
-#  Display Performance Application, Module information file.\r
-#\r
-# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\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
-\r
-[Defines]\r
-  INF_VERSION                    = 0x00010006\r
-  BASE_NAME                      = UefiDpLib\r
-  FILE_GUID                      = 9DF262F7-CF81-4294-B5A5-B2E3CAFE5618\r
-  MODULE_TYPE                    = UEFI_DRIVER\r
-  VERSION_STRING                 = 1.0\r
-  LIBRARY_CLASS                  = NULL|UEFI_APPLICATION UEFI_DRIVER\r
-  CONSTRUCTOR                    = UefiDpLibConstructor\r
-  DESTRUCTOR                     = UefiDpLibDestructor\r
-\r
-#\r
-# The following information is for reference only and not required by the build tools.\r
-#\r
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC\r
-#\r
-\r
-[Sources.common]\r
-  PerformanceTokens.h\r
-  UefiDpLib.c\r
-  UefiDpLib.h\r
-  UefiDpLib.uni\r
-  Dp.c\r
-  Dp.h\r
-  Literals.h\r
-  Literals.c\r
-  DpInternal.h\r
-  DpUtilities.c\r
-  DpTrace.c\r
-  DpProfile.c\r
-\r
-[Packages]\r
-  MdePkg/MdePkg.dec\r
-  ShellPkg/ShellPkg.dec\r
-  MdeModulePkg/MdeModulePkg.dec\r
-\r
-[LibraryClasses]\r
-  PerformanceLib\r
-  DxeServicesLib\r
-  MemoryAllocationLib\r
-  BaseLib\r
-  BaseMemoryLib\r
-  DebugLib\r
-  ShellCommandLib\r
-  ShellLib\r
-  UefiLib\r
-  UefiRuntimeServicesTableLib\r
-  UefiBootServicesTableLib\r
-  SortLib\r
-  PrintLib\r
-  DevicePathLib\r
-\r
-[Guids]\r
-  gPerformanceProtocolGuid                                ## CONSUMES ## SystemTable\r
-\r
-[Protocols]\r
-  gEfiLoadedImageProtocolGuid                             ## CONSUMES\r
-  gEfiDriverBindingProtocolGuid                           ## SOMETIMES_CONSUMES\r
-  gEfiComponentName2ProtocolGuid                          ## SOMETIMES_CONSUMES\r
-  gEfiLoadedImageDevicePathProtocolGuid                   ## SOMETIMES_CONSUMES\r
-\r
-[Pcd]\r
-  gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize   ## UNDEFINED\r
-  gEfiShellPkgTokenSpaceGuid.PcdShellProfileMask          ## CONSUMES\r
diff --git a/ShellPkg/Library/UefiDpLib/UefiDpLib.uni b/ShellPkg/Library/UefiDpLib/UefiDpLib.uni
deleted file mode 100644 (file)
index b77c507..0000000
+++ /dev/null
@@ -1,131 +0,0 @@
-// *++\r
-//\r
-// (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>\r
-// Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
-// (C) Copyright 2015 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
-// Module Name:\r
-//\r
-//   DpStrings.uni\r
-//\r
-// Abstract:\r
-//\r
-//   String definitions for the Shell dp command\r
-//\r
-// Revision History:\r
-//\r
-// --*/\r
-\r
-/=#\r
-\r
-#langdef   en-US "English"\r
-\r
-#string STR_DP_UP                      #language en-US  "UP"\r
-#string STR_DP_DOWN                    #language en-US  "DOWN"\r
-#string STR_DP_DASHES                  #language en-US  "-------------------------------------------------------------------------------\n"\r
-#string STR_DP_SECTION_HEADER          #language en-US  "\n==[ %s ]========\n"\r
-#string STR_DP_INVALID_ARG             #language en-US  "Invalid argument(s)\n"\r
-#string STR_DP_HANDLES_ERROR           #language en-US  "Locate all handles error - %r\n"\r
-#string STR_DP_ERROR_NAME              #language en-US  "Unknown driver name"\r
-#string STR_PERF_PROPERTY_NOT_FOUND    #language en-US  "Performance property not found\n"\r
-#string STR_DP_BUILD_REVISION          #language en-US  "\nDP Build Version:       %d.%d\n"\r
-#string STR_DP_KHZ                     #language en-US  "System Performance Timer Frequency:   %,8d (KHz)\n"\r
-#string STR_DP_TIMER_PROPERTIES        #language en-US  "System Performance Timer counts %s from 0x%Lx to 0x%Lx\n"\r
-#string STR_DP_VERBOSE_THRESHOLD       #language en-US  "Measurements less than %,Ld microseconds are not displayed.\n"\r
-#string STR_DP_SECTION_PHASES          #language en-US  "Major Phases"\r
-#string STR_DP_SEC_PHASE               #language en-US  "  SEC Phase Duration:      %L8d (us)\n"\r
-#string STR_DP_PHASE_BDSTO             #language en-US  "         BDS Timeout:   %L8d (ms) included in BDS Duration\n"\r
-#string STR_DP_PHASE_DURATION          #language en-US  "%5a Phase Duration:   %L8d (ms)\n"\r
-#string STR_DP_TOTAL_DURATION          #language en-US  "Total       Duration:   %L8d (ms)\n"\r
-#string STR_DP_SECTION_DRIVERS         #language en-US  "Drivers by Handle"\r
-#string STR_DP_HANDLE_SECTION          #language en-US  "Index:  Handle                Driver Name               Description    Time(us)\n"\r
-#string STR_DP_HANDLE_VARS             #language en-US  "%5d:  [%3x]   %36s    %11s    %L8d\n"\r
-#string STR_DP_HANDLE_SECTION2         #language en-US  "Index: Handle               Driver Name             Description  Time(us)    ID\n"\r
-#string STR_DP_HANDLE_VARS2            #language en-US  "%5d: [%3x]  %36s  %11s  %L8d %5d\n"\r
-#string STR_DP_SECTION_PEIMS           #language en-US  "PEIMs"\r
-#string STR_DP_PEIM_SECTION            #language en-US  "Index:  Pointer Value              Instance GUID              Token    Time(us)\n"\r
-#string STR_DP_PEIM_VARS               #language en-US  "%5d:  0x%11p   %g   PEIM    %L8d\n"\r
-#string STR_DP_PEIM_SECTION2           #language en-US  "Index: Pointer Value             Instance GUID            Token  Time(us)    ID\n"\r
-#string STR_DP_PEIM_VARS2              #language en-US  "%5d: 0x%11p  %g PEIM  %L8d %5d\n"\r
-#string STR_DP_SECTION_GENERAL         #language en-US  "General"\r
-#string STR_DP_GLOBAL_SECTION          #language en-US  "Index                      Name                         Description    Time(us)\n"\r
-#string STR_DP_GLOBAL_VARS             #language en-US  "%5d:%25s     %31s    %L8d\n"\r
-#string STR_DP_GLOBAL_SECTION2         #language en-US  "Index                      Name                     Description  Time(us)    ID\n"\r
-#string STR_DP_GLOBAL_VARS2            #language en-US  "%5d:%25s %31s  %L8d %5d\n"\r
-#string STR_DP_SECTION_CUMULATIVE      #language en-US  "Cumulative"\r
-#string STR_DP_CUMULATIVE_SECT_1       #language en-US  "(Times in microsec.)     Cumulative   Average     Shortest    Longest\n"\r
-#string STR_DP_CUMULATIVE_SECT_2       #language en-US  "   Name         Count     Duration    Duration    Duration    Duration\n"\r
-#string STR_DP_CUMULATIVE_STATS        #language en-US  "%11a   %8d  %L10d  %L10d  %L10d  %L10d\n"\r
-#string STR_DP_SECTION_STATISTICS      #language en-US  "Statistics"\r
-#string STR_DP_STATS_NUMTRACE          #language en-US  "There were %d measurements taken, of which:\n"\r
-#string STR_DP_STATS_NUMINCOMPLETE     #language en-US  "%,8d are incomplete.\n"\r
-#string STR_DP_STATS_NUMPHASES         #language en-US  "%,8d are major execution phases.\n"\r
-#string STR_DP_STATS_NUMHANDLES        #language en-US  "%,8d have non-NULL handles, %d are NULL.\n"\r
-#string STR_DP_STATS_NUMPEIMS          #language en-US  "%,8d are PEIMs.\n"\r
-#string STR_DP_STATS_NUMGLOBALS        #language en-US  "%,8d are general measurements.\n"\r
-#string STR_DP_STATS_NUMPROFILE        #language en-US  "%,8d are profiling records.\n"\r
-#string STR_DP_SECTION_PROFILE         #language en-US  "Sequential Profile Records"\r
-#string STR_DP_SECTION_ALL             #language en-US  "Sequential Trace Records"\r
-#string STR_DP_ALL_HEADR               #language en-US  "\nIndex      Handle                 Module                      Token    Time(us)\n"\r
-#string STR_DP_ALL_VARS                #language en-US  "%5d:%3s0x%08p %36s %13s %L8d\n"\r
-#string STR_DP_ALL_DASHES2             #language en-US  "-------------------------------------------------------------------------------------\n"\r
-#string STR_DP_ALL_HEADR2              #language en-US  "\nIndex      Handle                 Module                      Token    Time(us)    ID\n"\r
-#string STR_DP_ALL_VARS2               #language en-US  "%5d:%3s0x%08p %36s %13s %L8d %5d\n"\r
-#string STR_DP_SECTION_RAWTRACE        #language en-US  "RAW Trace"\r
-#string STR_DP_SECTION_RAWPROFILE      #language en-US  "RAW Profile"\r
-#string STR_DP_RAW_DASHES              #language en-US  "---------------------------------------------------------------------------------------------------------------------------\n"\r
-#string STR_DP_RAW_VARS                #language en-US  "%5d: %16LX %16LX %16LX  %31a  %31a\n"\r
-#string STR_DP_RAW_HEADR               #language en-US  "\nIndex       Handle        Start Count       End Count                  Token                          Module\n"\r
-#string STR_DP_RAW_DASHES2             #language en-US  "---------------------------------------------------------------------------------------------------------------------------------\n"\r
-#string STR_DP_RAW_VARS2               #language en-US  "%5d: %16LX %16LX %16LX  %31a  %31a %5d\n"\r
-#string STR_DP_RAW_HEADR2              #language en-US  "\nIndex       Handle        Start Count       End Count                  Token                          Module                   ID\n"\r
-#string STR_DP_INCOMPLETE              #language en-US  " I "\r
-#string STR_DP_COMPLETE                #language en-US  "   "\r
-#string STR_ALIT_UNKNOWN               #language en-US  "Unknown"\r
-\r
-#string STR_GET_HELP_DP         #language en-US ""\r
-".TH dp 0 "Display performance metrics"\r\n"\r
-".SH NAME\r\n"\r
-"Displays performance metrics that are stored in memory.\r\n"\r
-".SH SYNOPSIS\r\n"\r
-"DP [-b] [-v] [-x] [-s | -A | -R] [-T] [-P] [-t value] [-n count] [-c [token]][-i] [-h | -?]\r\n"\r
-".SH OPTIONS\r\n"\r
-" \r\n"\r
-"  -b       - Displays on multiple pages\r\n"\r
-"  -v       - Displays additional information\r\n"\r
-"  -x       - Prevents display of individual measurements for cumulative items\r\n"\r
-"  -s       - Displays summary information only\r\n"\r
-"  -A       - Displays all measurements in a list\r\n"\r
-"  -R       - Displays all measurements in raw format\r\n"\r
-"  -T       - Displays trace measurements only\r\n"\r
-"  -P       - Displays profile measurements only\r\n"\r
-"  -t VALUE - Sets display threshold to VALUE microseconds\r\n"\r
-"  -n COUNT - Limits display to COUNT lines in All and Raw modes\r\n"\r
-"  -i       - Displays identifier\r\n"\r
-"  -c TOKEN - Display pre-defined and custom cumulative data\r\n" \r
-"             Pre-defined cumulative token are:\r\n"\r
-"             1. LoadImage:\r\n"\r
-"             2. StartImage:\r\n"\r
-"             3. DB:Start:\r\n"\r
-"             4. DB:Support:\r\n"\r
-"  -?       - Displays DP help information\r\n"\r
-".SH DESCRIPTION\r\n"\r
-" \r\n"\r
-"NOTES:\r\n"\r
-"  1. Displays Performance metrics that are stored in memory.\r\n"\r
-".SH RETURNVALUES\r\n"\r
-" \r\n"\r
-"RETURN VALUES:\r\n"\r
-"  SHELL_SUCCESS            The action was completed as requested.\r\n"\r
-"  SHELL_NOT_FOUND          The requested option was not found.\r\n"\r
-"  SHELL_INVALID_PARAMETER  One of the passed in parameters was incorrectly formatted or its value was out of bounds.\r\n"\r
-"  SHELL_UNSUPPORTED        The action as requested was unsupported.\r\n"\r
-"  SHELL_OUT_OF_RESOURCES   There was insufficient free space for the request to be completed.\r\n"\r
index 8fc20709f4637e0ee7d34f53738cdf12c3714799..65e89594550e9cd3a8743edbbe673f0adc0748f7 100644 (file)
   ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf\r
   ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf\r
 \r
-  ShellPkg/Library/UefiDpLib/UefiDpLib.inf {\r
-    <LibraryClasses>\r
-      PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf\r
-      DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf\r
-  }\r
-\r
   ShellPkg/Application/Shell/Shell.inf {\r
     <PcdsFixedAtBuild>\r
       gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE\r
       NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf\r
       NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf\r
       NULL|ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf\r
-!ifdef $(INCLUDE_DP)\r
-      NULL|ShellPkg/Library/UefiDpLib/UefiDpLib.inf\r
-!endif #$(INCLUDE_DP)\r
 !endif #$(NO_SHELL_PROFILES)\r
   }\r
 \r
   ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf\r
   ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.inf\r
+  ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf {\r
+    <LibraryClasses>\r
+      PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf\r
+  }\r
+  ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf {\r
+    <LibraryClasses>\r
+      PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf\r
+  }\r
 \r
 [BuildOptions]\r
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES\r