[edk2] [PATCH v2 3/3] ShellPkg/dp: Convert from NULL class library to Dynamic Command

Ruiyu Ni posted 3 patches 7 years ago
[edk2] [PATCH v2 3/3] ShellPkg/dp: Convert from NULL class library to Dynamic Command
Posted by Ruiyu Ni 7 years ago
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>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Cc: Michael D Kinney <michael.d.kinney@intel.com>
---
 .../DpDynamicCommand}/Dp.c                         | 100 +++++++----
 .../DpDynamicCommand}/Dp.h                         |  63 ++++++-
 .../DpDynamicCommand/Dp.uni}                       |   0
 ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c   |  53 ++++++
 ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf |  73 +++++++++
 .../DpDynamicCommand/DpDynamicCommand.c            | 130 +++++++++++++++
 .../DpDynamicCommand/DpDynamicCommand.inf          |  78 +++++++++
 .../DpDynamicCommand}/DpInternal.h                 |   2 +-
 .../DpDynamicCommand}/DpProfile.c                  |  34 ++--
 .../DpDynamicCommand}/DpTrace.c                    | 182 ++++++++++-----------
 .../DpDynamicCommand}/DpUtilities.c                |  44 +++--
 .../DpDynamicCommand}/Literals.c                   |   0
 .../DpDynamicCommand}/Literals.h                   |   0
 .../DpDynamicCommand}/PerformanceTokens.h          |   0
 ShellPkg/Library/UefiDpLib/Readme.txt              |   2 -
 ShellPkg/Library/UefiDpLib/UefiDpLib.c             | 101 ------------
 ShellPkg/Library/UefiDpLib/UefiDpLib.h             |  64 --------
 ShellPkg/Library/UefiDpLib/UefiDpLib.inf           |  77 ---------
 ShellPkg/ShellPkg.dsc                              |  17 +-
 19 files changed, 605 insertions(+), 415 deletions(-)
 rename ShellPkg/{Library/UefiDpLib => DynamicCommand/DpDynamicCommand}/Dp.c (84%)
 rename ShellPkg/{Library/UefiDpLib => DynamicCommand/DpDynamicCommand}/Dp.h (70%)
 rename ShellPkg/{Library/UefiDpLib/UefiDpLib.uni => DynamicCommand/DpDynamicCommand/Dp.uni} (100%)
 create mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c
 create mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
 create mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.c
 create mode 100644 ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
 rename ShellPkg/{Library/UefiDpLib => DynamicCommand/DpDynamicCommand}/DpInternal.h (96%)
 rename ShellPkg/{Library/UefiDpLib => DynamicCommand/DpDynamicCommand}/DpProfile.c (87%)
 rename ShellPkg/{Library/UefiDpLib => DynamicCommand/DpDynamicCommand}/DpTrace.c (89%)
 rename ShellPkg/{Library/UefiDpLib => DynamicCommand/DpDynamicCommand}/DpUtilities.c (87%)
 rename ShellPkg/{Library/UefiDpLib => DynamicCommand/DpDynamicCommand}/Literals.c (100%)
 rename ShellPkg/{Library/UefiDpLib => DynamicCommand/DpDynamicCommand}/Literals.h (100%)
 rename ShellPkg/{Library/UefiDpLib => DynamicCommand/DpDynamicCommand}/PerformanceTokens.h (100%)
 delete mode 100644 ShellPkg/Library/UefiDpLib/Readme.txt
 delete mode 100644 ShellPkg/Library/UefiDpLib/UefiDpLib.c
 delete mode 100644 ShellPkg/Library/UefiDpLib/UefiDpLib.h
 delete mode 100644 ShellPkg/Library/UefiDpLib/UefiDpLib.inf

diff --git a/ShellPkg/Library/UefiDpLib/Dp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
similarity index 84%
rename from ShellPkg/Library/UefiDpLib/Dp.c
rename to ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
index 94fa61c710..3ecc753d0c 100644
--- a/ShellPkg/Library/UefiDpLib/Dp.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
@@ -24,20 +24,13 @@
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 **/
 
-#include "UefiDpLib.h"
-#include <Library/ShellLib.h>
-#include <Library/BaseLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/DebugLib.h>
-#include <Library/UefiLib.h>
-
-#include <Guid/Performance.h>
-
 #include "PerformanceTokens.h"
 #include "Dp.h"
 #include "Literals.h"
 #include "DpInternal.h"
 
+EFI_HANDLE   mDpHiiHandle;
+
 //
 /// Module-Global Variables
 ///@{
@@ -89,18 +82,18 @@ DumpStatistics( void )
 {
   EFI_STRING                StringPtr;
   EFI_STRING                StringPtrUnknown;
-  StringPtr        = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_STATISTICS), NULL);
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
+  StringPtr        = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_STATISTICS), NULL);
+  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
               (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMTRACE), gDpHiiHandle,      SummaryData.NumTrace);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMINCOMPLETE), gDpHiiHandle, SummaryData.NumIncomplete);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPHASES), gDpHiiHandle,     SummaryData.NumSummary);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMHANDLES), gDpHiiHandle,    SummaryData.NumHandles, SummaryData.NumTrace - SummaryData.NumHandles);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPEIMS), gDpHiiHandle,      SummaryData.NumPEIMs);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMGLOBALS), gDpHiiHandle,    SummaryData.NumGlobal);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMTRACE), mDpHiiHandle,      SummaryData.NumTrace);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMINCOMPLETE), mDpHiiHandle, SummaryData.NumIncomplete);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPHASES), mDpHiiHandle,     SummaryData.NumSummary);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMHANDLES), mDpHiiHandle,    SummaryData.NumHandles, SummaryData.NumTrace - SummaryData.NumHandles);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPEIMS), mDpHiiHandle,      SummaryData.NumPEIMs);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMGLOBALS), mDpHiiHandle,    SummaryData.NumGlobal);
 #if PROFILING_IMPLEMENTED
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPROFILE), gDpHiiHandle,    SummaryData.NumProfile);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPROFILE), mDpHiiHandle,    SummaryData.NumProfile);
 #endif // PROFILING_IMPLEMENTED
   SHELL_FREE_NON_NULL (StringPtr);
   SHELL_FREE_NON_NULL (StringPtrUnknown);
@@ -137,8 +130,7 @@ InitCumulativeData (
   @retval value                    Unknown error.
 **/
 SHELL_STATUS
-EFIAPI
-ShellCommandRunDp (
+RunDp (
   IN EFI_HANDLE               ImageHandle,
   IN EFI_SYSTEM_TABLE         *SystemTable
   )
@@ -182,15 +174,12 @@ ShellCommandRunDp (
   Status = ShellInitialize();
   ASSERT_EFI_ERROR(Status);
 
-  Status = CommandInit();
-  ASSERT_EFI_ERROR(Status);
-
   //
   // Process Command Line arguments
   //
   Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL, TRUE);
   if (EFI_ERROR(Status)) {
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_ARG), gDpHiiHandle);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_ARG), mDpHiiHandle);
     return SHELL_INVALID_PARAMETER;
   }
 
@@ -273,7 +262,7 @@ ShellCommandRunDp (
   //
   Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, (VOID **) &PerformanceProperty);
   if (EFI_ERROR (Status) || (PerformanceProperty == NULL)) {
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PERF_PROPERTY_NOT_FOUND), gDpHiiHandle);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PERF_PROPERTY_NOT_FOUND), mDpHiiHandle);
     goto Done;
   }
 
@@ -288,22 +277,22 @@ ShellCommandRunDp (
   // Print header
   //
   // print DP's build version
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_BUILD_REVISION), gDpHiiHandle, DP_MAJOR_VERSION, DP_MINOR_VERSION);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_BUILD_REVISION), mDpHiiHandle, DP_MAJOR_VERSION, DP_MINOR_VERSION);
 
   // print performance timer characteristics
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_KHZ), gDpHiiHandle, TimerInfo.Frequency);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_KHZ), mDpHiiHandle, TimerInfo.Frequency);
 
   if (VerboseMode && !RawMode) {
-    StringPtr = HiiGetString (gDpHiiHandle,
+    StringPtr = HiiGetString (mDpHiiHandle,
                   (EFI_STRING_ID) (TimerInfo.CountUp ? STRING_TOKEN (STR_DP_UP) : STRING_TOKEN (STR_DP_DOWN)), NULL);
     ASSERT (StringPtr != NULL);
     // Print Timer count range and direction
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TIMER_PROPERTIES), gDpHiiHandle,
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TIMER_PROPERTIES), mDpHiiHandle,
                 StringPtr,
                 TimerInfo.StartCount,
                 TimerInfo.EndCount
                 );
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_VERBOSE_THRESHOLD), gDpHiiHandle, mInterestThreshold);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_VERBOSE_THRESHOLD), mDpHiiHandle, mInterestThreshold);
   }
 
 /****************************************************************************
@@ -398,3 +387,52 @@ Done:
 
   return ShellStatus;
 }
+
+
+/**
+  Retrive HII package list from ImageHandle and publish to HII database.
+
+  @param ImageHandle            The image handle of the process.
+
+  @return HII handle.
+**/
+EFI_HANDLE
+InitializeHiiPackage (
+  EFI_HANDLE                  ImageHandle
+  )
+{
+  EFI_STATUS                  Status;
+  EFI_HII_PACKAGE_LIST_HEADER *PackageList;
+  EFI_HANDLE                  HiiHandle;
+
+  //
+  // Retrieve HII package list from ImageHandle
+  //
+  Status = gBS->OpenProtocol (
+                  ImageHandle,
+                  &gEfiHiiPackageListProtocolGuid,
+                  (VOID **)&PackageList,
+                  ImageHandle,
+                  NULL,
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
+                  );
+  ASSERT_EFI_ERROR (Status);
+  if (EFI_ERROR (Status)) {
+    return NULL;
+  }
+
+  //
+  // Publish HII package list to HII Database.
+  //
+  Status = gHiiDatabase->NewPackageList (
+                           gHiiDatabase,
+                           PackageList,
+                           NULL,
+                           &HiiHandle
+                           );
+  ASSERT_EFI_ERROR (Status);
+  if (EFI_ERROR (Status)) {
+    return NULL;
+  }
+  return HiiHandle;
+}
diff --git a/ShellPkg/Library/UefiDpLib/Dp.h b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
similarity index 70%
rename from ShellPkg/Library/UefiDpLib/Dp.h
rename to ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
index 06fee3bcf4..4027b6b84e 100644
--- a/ShellPkg/Library/UefiDpLib/Dp.h
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
@@ -1,7 +1,7 @@
 /** @file
-  Common declarations for the Dp Performance Reporting Utility.
+  Header file for 'dp' command functions.
 
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
   This program and the accompanying materials
   are licensed and made available under the terms and conditions of the BSD License
   which accompanies this distribution.  The full text of the license may be found at
@@ -9,12 +9,37 @@
 
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
 **/
 
-#ifndef _EFI_APP_DP_H_
-#define _EFI_APP_DP_H_
+#ifndef _DP_H_
+#define _DP_H_
+
+
+#include <Uefi.h>
+
+#include <Guid/Performance.h>
 
+#include <Protocol/HiiPackageList.h>
+#include <Protocol/DevicePath.h>
+#include <Protocol/LoadedImage.h>
+#include <Protocol/UnicodeCollation.h>
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/MemoryAllocationLib.h>
 #include <Library/ShellLib.h>
+#include <Library/UefiLib.h>
+#include <Library/UefiRuntimeServicesTableLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+#include <Library/PcdLib.h>
+#include <Library/SortLib.h>
+#include <Library/HiiLib.h>
+#include <Library/FileHandleLib.h>
+#include <Library/UefiHiiServicesLib.h>
+
+extern EFI_HANDLE mDpHiiHandle;
 
 #define DP_MAJOR_VERSION        2
 #define DP_MINOR_VERSION        4
@@ -94,4 +119,32 @@ typedef struct {
   UINT32                Count;            ///< Number of measurements accumulated.
 } PROFILE_RECORD;
 
-#endif  // _EFI_APP_DP_H_
+/**
+  Dump performance data.
+
+  @param[in]  ImageHandle     The image handle.
+  @param[in]  SystemTable     The system table.
+
+  @retval SHELL_SUCCESS            Command completed successfully.
+  @retval SHELL_INVALID_PARAMETER  Command usage error.
+  @retval SHELL_ABORTED            The user aborts the operation.
+  @retval value                    Unknown error.
+**/
+SHELL_STATUS
+RunDp (
+  IN EFI_HANDLE               ImageHandle,
+  IN EFI_SYSTEM_TABLE         *SystemTable
+  );
+
+/**
+  Retrive HII package list from ImageHandle and publish to HII database.
+
+  @param ImageHandle            The image handle of the process.
+
+  @return HII handle.
+**/
+EFI_HANDLE
+InitializeHiiPackage (
+  EFI_HANDLE                  ImageHandle
+  );
+#endif  // _DP_H_
diff --git a/ShellPkg/Library/UefiDpLib/UefiDpLib.uni b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
similarity index 100%
rename from ShellPkg/Library/UefiDpLib/UefiDpLib.uni
rename to ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c
new file mode 100644
index 0000000000..f96209b27a
--- /dev/null
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c
@@ -0,0 +1,53 @@
+/** @file
+  Entrypoint of "dp" shell standalone application.
+
+  Copyright (c) 2017, Intel Corporation. All rights reserved. <BR>
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which accompanies this distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#include "Dp.h"
+
+//
+// String token ID of help message text.
+// Shell supports to find help message in the resource section of an application image if
+// .MAN file is not found. This global variable is added to make build tool recognizes
+// that the help string is consumed by user and then build tool will add the string into
+// the resource section. Thus the application can use '-?' option to show help message in
+// Shell.
+//
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId = STRING_TOKEN (STR_GET_HELP_DP);
+
+/**
+  Entry point of Tftp standalone application.
+
+  @param ImageHandle            The image handle of the process.
+  @param SystemTable            The EFI System Table pointer.
+
+  @retval EFI_SUCCESS           Tftp command is executed sucessfully.
+  @retval EFI_ABORTED           HII package was failed to initialize.
+  @retval others                Other errors when executing tftp command.
+**/
+EFI_STATUS
+EFIAPI
+DpAppInitialize (
+  IN EFI_HANDLE               ImageHandle,
+  IN EFI_SYSTEM_TABLE         *SystemTable
+  )
+{
+  EFI_STATUS                  Status;
+  mDpHiiHandle = InitializeHiiPackage (ImageHandle);
+  if (mDpHiiHandle == NULL) {
+    return EFI_ABORTED;
+  }
+
+  Status = (EFI_STATUS)RunDp (ImageHandle, SystemTable);
+  HiiRemovePackages (mDpHiiHandle);
+  return Status;
+}
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
new file mode 100644
index 0000000000..b0ed229b49
--- /dev/null
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
@@ -0,0 +1,73 @@
+##  @file
+# Provides Shell 'dp' standalone application.
+#
+# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which accompanies this distribution. The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010006
+  BASE_NAME                      = dp
+  FILE_GUID                      = 1831A379-2D48-45BD-9744-D4059D93815D
+  MODULE_TYPE                    = UEFI_APPLICATION
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = DpAppInitialize
+#
+#  This flag specifies whether HII resource section is generated into PE image.
+#
+  UEFI_HII_RESOURCE_SECTION      = TRUE
+
+[Sources.common]
+  PerformanceTokens.h
+  Dp.uni
+  Dp.c
+  Dp.h
+  Literals.h
+  Literals.c
+  DpInternal.h
+  DpUtilities.c
+  DpTrace.c
+  DpProfile.c
+  DpApp.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  ShellPkg/ShellPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+  MemoryAllocationLib
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  ShellLib
+  UefiLib
+  UefiRuntimeServicesTableLib
+  UefiBootServicesTableLib
+  UefiApplicationEntryPoint
+  SortLib
+  PrintLib
+  DevicePathLib
+  PerformanceLib
+  DxeServicesLib
+  PeCoffGetEntryPointLib
+
+[Guids]
+  gPerformanceProtocolGuid                                ## CONSUMES ## SystemTable
+
+[Protocols]
+  gEfiLoadedImageProtocolGuid                             ## CONSUMES
+  gEfiDriverBindingProtocolGuid                           ## SOMETIMES_CONSUMES
+  gEfiComponentName2ProtocolGuid                          ## SOMETIMES_CONSUMES
+  gEfiLoadedImageDevicePathProtocolGuid                   ## SOMETIMES_CONSUMES
+  gEfiHiiPackageListProtocolGuid                          ## CONSUMES
+
+[Pcd]
+  gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize   ## CONSUMES
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.c b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.c
new file mode 100644
index 0000000000..6f3997fff4
--- /dev/null
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.c
@@ -0,0 +1,130 @@
+/** @file
+  Produce "dp" shell dynamic command.
+
+  Copyright (c) 2017, Intel Corporation. All rights reserved. <BR>
+
+  This program and the accompanying materials
+  are licensed and made available under the terms and conditions of the BSD License
+  which accompanies this distribution.  The full text of the license may be found at
+  http://opensource.org/licenses/bsd-license.php
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+#include "Dp.h"
+#include <Protocol/ShellDynamicCommand.h>
+
+/**
+  This is the shell command handler function pointer callback type.  This
+  function handles the command when it is invoked in the shell.
+
+  @param[in] This                   The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
+  @param[in] SystemTable            The pointer to the system table.
+  @param[in] ShellParameters        The parameters associated with the command.
+  @param[in] Shell                  The instance of the shell protocol used in the context
+                                    of processing this command.
+
+  @return EFI_SUCCESS               the operation was sucessful
+  @return other                     the operation failed.
+**/
+SHELL_STATUS
+EFIAPI
+DpCommandHandler (
+  IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL    *This,
+  IN EFI_SYSTEM_TABLE                      *SystemTable,
+  IN EFI_SHELL_PARAMETERS_PROTOCOL         *ShellParameters,
+  IN EFI_SHELL_PROTOCOL                    *Shell
+  )
+{
+  gEfiShellParametersProtocol = ShellParameters;
+  return RunDp (gImageHandle, SystemTable);
+}
+
+/**
+  This is the command help handler function pointer callback type.  This
+  function is responsible for displaying help information for the associated
+  command.
+
+  @param[in] This                   The instance of the EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
+  @param[in] Language               The pointer to the language string to use.
+
+  @return string                    Pool allocated help string, must be freed by caller
+**/
+CHAR16 *
+EFIAPI
+DpCommandGetHelp (
+  IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL    *This,
+  IN CONST CHAR8                           *Language
+  )
+{
+  return HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_GET_HELP_DP), Language);
+}
+
+EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mDpDynamicCommand = {
+  L"dp",
+  DpCommandHandler,
+  DpCommandGetHelp
+};
+
+/**
+  Entry point of Tftp Dynamic Command.
+
+  Produce the DynamicCommand protocol to handle "tftp" command.
+
+  @param ImageHandle            The image handle of the process.
+  @param SystemTable            The EFI System Table pointer.
+
+  @retval EFI_SUCCESS           Tftp command is executed sucessfully.
+  @retval EFI_ABORTED           HII package was failed to initialize.
+  @retval others                Other errors when executing tftp command.
+**/
+EFI_STATUS
+EFIAPI
+DpCommandInitialize (
+  IN EFI_HANDLE               ImageHandle,
+  IN EFI_SYSTEM_TABLE         *SystemTable
+  )
+{
+  EFI_STATUS                  Status;
+  mDpHiiHandle = InitializeHiiPackage (ImageHandle);
+  if (mDpHiiHandle == NULL) {
+    return EFI_ABORTED;
+  }
+
+  Status = gBS->InstallProtocolInterface (
+                  &ImageHandle,
+                  &gEfiShellDynamicCommandProtocolGuid,
+                  EFI_NATIVE_INTERFACE,
+                  &mDpDynamicCommand
+                  );
+  ASSERT_EFI_ERROR (Status);
+  return Status;
+}
+
+/**
+  Tftp driver unload handler.
+
+  @param ImageHandle            The image handle of the process.
+
+  @retval EFI_SUCCESS           The image is unloaded.
+  @retval Others                Failed to unload the image.
+**/
+EFI_STATUS
+EFIAPI
+DpUnload (
+  IN EFI_HANDLE               ImageHandle
+)
+{
+  EFI_STATUS                  Status;
+  Status = gBS->UninstallProtocolInterface (
+                  ImageHandle,
+                  &gEfiShellDynamicCommandProtocolGuid,
+                  &mDpDynamicCommand
+                  );
+  if (EFI_ERROR (Status)) {
+    return Status;
+  }
+  HiiRemovePackages (mDpHiiHandle);
+  return EFI_SUCCESS;
+}
diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
new file mode 100644
index 0000000000..3164561958
--- /dev/null
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
@@ -0,0 +1,78 @@
+##  @file
+# Provides Shell 'dp' dynamic command.
+#
+# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
+#  This program and the accompanying materials
+#  are licensed and made available under the terms and conditions of the BSD License
+#  which accompanies this distribution. The full text of the license may be found at
+#  http://opensource.org/licenses/bsd-license.php
+#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+#
+#
+##
+
+[Defines]
+  INF_VERSION                    = 0x00010006
+  BASE_NAME                      = dpDynamicCommand
+  FILE_GUID                      = 0253F9FA-129A-4A8D-B12E-7DC2B6376302
+  MODULE_TYPE                    = DXE_DRIVER
+  VERSION_STRING                 = 1.0
+  ENTRY_POINT                    = DpCommandInitialize
+  UNLOAD_IMAGE                   = DpUnload
+#
+#  This flag specifies whether HII resource section is generated into PE image.
+#
+  UEFI_HII_RESOURCE_SECTION      = TRUE
+
+[Sources.common]
+  PerformanceTokens.h
+  Dp.uni
+  Dp.c
+  Dp.h
+  Literals.h
+  Literals.c
+  DpInternal.h
+  DpUtilities.c
+  DpTrace.c
+  DpProfile.c
+  DpDynamicCommand.c
+
+[Packages]
+  MdePkg/MdePkg.dec
+  ShellPkg/ShellPkg.dec
+  MdeModulePkg/MdeModulePkg.dec
+
+[LibraryClasses]
+  MemoryAllocationLib
+  BaseLib
+  BaseMemoryLib
+  DebugLib
+  ShellLib
+  UefiLib
+  UefiRuntimeServicesTableLib
+  UefiBootServicesTableLib
+  UefiDriverEntryPoint
+  SortLib
+  PrintLib
+  DevicePathLib
+  PerformanceLib
+  DxeServicesLib
+  PeCoffGetEntryPointLib
+
+[Guids]
+  gPerformanceProtocolGuid                                ## CONSUMES ## SystemTable
+
+[Protocols]
+  gEfiLoadedImageProtocolGuid                             ## CONSUMES
+  gEfiDriverBindingProtocolGuid                           ## SOMETIMES_CONSUMES
+  gEfiComponentName2ProtocolGuid                          ## SOMETIMES_CONSUMES
+  gEfiLoadedImageDevicePathProtocolGuid                   ## SOMETIMES_CONSUMES
+  gEfiHiiPackageListProtocolGuid                          ## CONSUMES
+  gEfiShellDynamicCommandProtocolGuid                     ## PRODUCES
+
+[Pcd]
+  gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize   ## CONSUMES
+
+[DEPEX]
+  TRUE
diff --git a/ShellPkg/Library/UefiDpLib/DpInternal.h b/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
similarity index 96%
rename from ShellPkg/Library/UefiDpLib/DpInternal.h
rename to ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
index 6de194aaaa..ece1c23aaf 100644
--- a/ShellPkg/Library/UefiDpLib/DpInternal.h
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
@@ -24,7 +24,7 @@
 //
 /// Module-Global Variables
 ///@{
-extern EFI_HII_HANDLE     gDpHiiHandle;
+extern EFI_HII_HANDLE     mDpHiiHandle;
 extern CHAR16             mGaugeString[DP_GAUGE_STRING_LENGTH + 1];
 extern CHAR16             mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];
 extern UINT64             mInterestThreshold;
diff --git a/ShellPkg/Library/UefiDpLib/DpProfile.c b/ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c
similarity index 87%
rename from ShellPkg/Library/UefiDpLib/DpProfile.c
rename to ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c
index e4434034c6..af25217dae 100644
--- a/ShellPkg/Library/UefiDpLib/DpProfile.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c
@@ -28,23 +28,23 @@
 #include "Literals.h"
 #include "DpInternal.h"
 
-/** 
+/**
   Gather and print ALL Profiling Records.
-  
+
   Displays all "interesting" Profile measurements in order.
   The number of records displayed is controlled by:
      - records with a duration less than mInterestThreshold microseconds are not displayed.
      - No more than Limit records are displayed.  A Limit of zero will not limit the output.
      - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
        displayed.
-  
+
   @pre    The mInterestThreshold global variable is set to the shortest duration to be printed.
            The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
            They must not be in use by a calling function.
-  
+
   @param[in]    Limit         The number of records to print.  Zero is ALL.
   @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items from display.
-  
+
 **/
 VOID
 DumpAllProfile(
@@ -55,32 +55,32 @@ DumpAllProfile(
   EFI_STRING    StringPtr;
   EFI_STRING    StringPtrUnknown;
 
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);   
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PROFILE), NULL);
+  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PROFILE), NULL);
 
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle, 
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
               (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
   FreePool (StringPtr);
   FreePool (StringPtrUnknown);
 }
 
-/** 
+/**
   Gather and print Raw Profile Records.
-  
+
   All Profile measurements with a duration greater than or equal to
   mInterestThreshold are printed without interpretation.
-  
+
   The number of records displayed is controlled by:
      - records with a duration less than mInterestThreshold microseconds are not displayed.
      - No more than Limit records are displayed.  A Limit of zero will not limit the output.
      - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
        displayed.
-  
+
   @pre    The mInterestThreshold global variable is set to the shortest duration to be printed.
-  
+
   @param[in]    Limit         The number of records to print.  Zero is ALL.
   @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items from display.
-  
+
 **/
 VOID
 DumpRawProfile(
@@ -91,9 +91,9 @@ DumpRawProfile(
   EFI_STRING    StringPtr;
   EFI_STRING    StringPtrUnknown;
 
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWPROFILE), NULL);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle, 
+  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWPROFILE), NULL);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
               (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
   FreePool (StringPtr);
   FreePool (StringPtrUnknown);
diff --git a/ShellPkg/Library/UefiDpLib/DpTrace.c b/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
similarity index 89%
rename from ShellPkg/Library/UefiDpLib/DpTrace.c
rename to ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
index 90a71ad91b..bc882be622 100644
--- a/ShellPkg/Library/UefiDpLib/DpTrace.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
@@ -29,17 +29,17 @@
 #include "Literals.h"
 #include "DpInternal.h"
 
-/** 
+/**
   Collect verbose statistics about the logged performance measurements.
-  
+
   General Summary information for all Trace measurements is gathered and
   stored within the SummaryData structure.  This information is both
   used internally by subsequent reporting functions, and displayed
   at the end of verbose reports.
-  
+
   @pre  The SummaryData and CumData structures must be initialized
         prior to calling this function.
-  
+
   @post The SummaryData and CumData structures contain statistics for the
         current performance logs.
 
@@ -118,23 +118,23 @@ GatherStatistics(
   }
 }
 
-/** 
+/**
   Gather and print ALL Trace Records.
-  
+
   Displays all "interesting" Trace measurements in order.<BR>
   The number of records displayed is controlled by:
      - records with a duration less than mInterestThreshold microseconds are not displayed.
      - No more than Limit records are displayed.  A Limit of zero will not limit the output.
      - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
        displayed.
-  
+
   @pre    The mInterestThreshold global variable is set to the shortest duration to be printed.
            The mGaugeString and mUnicodeToken global arrays are used for temporary string storage.
            They must not be in use by a calling function.
-  
+
   @param[in]    Limit       The number of records to print.  Zero is ALL.
   @param[in]    ExcludeFlag TRUE to exclude individual Cumulative items from display.
-  
+
   @retval EFI_SUCCESS           The operation was successful.
   @retval EFI_ABORTED           The user aborts the operation.
   @return Others                from a call to gBS->LocateHandleBuffer().
@@ -159,9 +159,9 @@ DumpAllTrace(
   EFI_STATUS                Status;
   EFI_STRING                StringPtrUnknown;
 
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
-  IncFlag = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
+  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
+  IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_ALL), NULL);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
               (IncFlag == NULL) ? StringPtrUnknown : IncFlag);
   FreePool (StringPtrUnknown);
 
@@ -169,7 +169,7 @@ DumpAllTrace(
   //
   Status  = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);
   if (EFI_ERROR (Status)) {
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), gDpHiiHandle, Status);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);
   }
   else {
     // We have successfully populated the HandleBuffer
@@ -179,11 +179,11 @@ DumpAllTrace(
     //    Display driver names in Module field for records with Handles.
     //
     if (mShowId) {
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR2), gDpHiiHandle);
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_DASHES2), gDpHiiHandle);
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR2), mDpHiiHandle);
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_DASHES2), mDpHiiHandle);
     } else {
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR), gDpHiiHandle);
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle);
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR), mDpHiiHandle);
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
     }
 
     LogEntryKey = 0;
@@ -206,10 +206,10 @@ DumpAllTrace(
       if (Measurement.EndTimeStamp != 0) {
         Duration = GetDuration (&Measurement);
         ElapsedTime = DurationInMicroSeconds ( Duration );
-        IncFlag = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL);
+        IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_COMPLETE), NULL);
       }
       else {
-        IncFlag = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_INCOMPLETE), NULL);  // Mark incomplete records
+        IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_INCOMPLETE), NULL);  // Mark incomplete records
       }
       if (((Measurement.EndTimeStamp != 0) && (ElapsedTime < mInterestThreshold)) ||
           ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))
@@ -240,7 +240,7 @@ DumpAllTrace(
       mUnicodeToken[13] = 0;
 
       if (mShowId) {
-        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS2), gDpHiiHandle,
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS2), mDpHiiHandle,
           Index,      // 1 based, Which measurement record is being printed
           IncFlag,
           Measurement.Handle,
@@ -250,7 +250,7 @@ DumpAllTrace(
           Measurement.Identifier
         );
       } else {
-        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS), gDpHiiHandle,
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS), mDpHiiHandle,
           Index,      // 1 based, Which measurement record is being printed
           IncFlag,
           Measurement.Handle,
@@ -273,20 +273,20 @@ DumpAllTrace(
   return Status;
 }
 
-/** 
+/**
   Gather and print Raw Trace Records.
-  
+
   All Trace measurements with a duration greater than or equal to
   mInterestThreshold are printed without interpretation.
-  
+
   The number of records displayed is controlled by:
      - records with a duration less than mInterestThreshold microseconds are not displayed.
      - No more than Limit records are displayed.  A Limit of zero will not limit the output.
      - If the ExcludeFlag is TRUE, records matching entries in the CumData array are not
        displayed.
-  
+
   @pre    The mInterestThreshold global variable is set to the shortest duration to be printed.
-  
+
   @param[in]    Limit       The number of records to print.  Zero is ALL.
   @param[in]    ExcludeFlag TRUE to exclude individual Cumulative items from display.
 
@@ -312,19 +312,19 @@ DumpRawTrace(
 
   Status = EFI_SUCCESS;
 
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);  
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
+  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
               (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
   FreePool (StringPtr);
   FreePool (StringPtrUnknown);
 
   if (mShowId) {
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR2), gDpHiiHandle);
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES2), gDpHiiHandle);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR2), mDpHiiHandle);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES2), mDpHiiHandle);
   } else {
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR), gDpHiiHandle);
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES), gDpHiiHandle);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR), mDpHiiHandle);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES), mDpHiiHandle);
   }
 
   LogEntryKey = 0;
@@ -355,7 +355,7 @@ DumpRawTrace(
     ++Count;    // Count the number of records printed
 
     if (mShowId) {
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS2), gDpHiiHandle,
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS2), mDpHiiHandle,
         Index,      // 1 based, Which measurement record is being printed
         Measurement.Handle,
         Measurement.StartTimeStamp,
@@ -365,7 +365,7 @@ DumpRawTrace(
         Measurement.Identifier
       );
     } else {
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS), gDpHiiHandle,
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS), mDpHiiHandle,
         Index,      // 1 based, Which measurement record is being printed
         Measurement.Handle,
         Measurement.StartTimeStamp,
@@ -382,9 +382,9 @@ DumpRawTrace(
   return Status;
 }
 
-/** 
+/**
   Gather and print Major Phase metrics.
-  
+
 **/
 VOID
 ProcessPhases(
@@ -412,9 +412,9 @@ ProcessPhases(
   //
   // Get Execution Phase Statistics
   //
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);   
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
+  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PHASES), NULL);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
               (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
   FreePool (StringPtr);
   FreePool (StringPtrUnknown);
@@ -456,7 +456,7 @@ ProcessPhases(
   if (SecTime > 0) {
     ElapsedTime = DurationInMicroSeconds ( SecTime );     // Calculate elapsed time in microseconds
     Total += DivU64x32 (ElapsedTime, 1000);   // Accumulate time in milliseconds
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SEC_PHASE), gDpHiiHandle, ElapsedTime);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SEC_PHASE), mDpHiiHandle, ElapsedTime);
   }
 
   // print PEI phase duration time
@@ -467,7 +467,7 @@ ProcessPhases(
                     (UINT32)TimerInfo.Frequency
                     );
     Total += ElapsedTime;
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), gDpHiiHandle, ALit_PEI, ElapsedTime);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_PEI, ElapsedTime);
   }
 
   // print DXE phase duration time
@@ -478,7 +478,7 @@ ProcessPhases(
                     (UINT32)TimerInfo.Frequency
                     );
     Total += ElapsedTime;
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), gDpHiiHandle, ALit_DXE, ElapsedTime);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_DXE, ElapsedTime);
   }
 
   // print BDS phase duration time
@@ -489,7 +489,7 @@ ProcessPhases(
                     (UINT32)TimerInfo.Frequency
                     );
     Total += ElapsedTime;
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), gDpHiiHandle, ALit_BDS, ElapsedTime);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_BDS, ElapsedTime);
   }
 
   if (BdsTimeoutValue > 0) {
@@ -497,17 +497,17 @@ ProcessPhases(
                     BdsTimeoutValue,
                     (UINT32)TimerInfo.Frequency
                     );
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_BDSTO), gDpHiiHandle, ALit_BdsTO, ElapsedTime);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_BDSTO), mDpHiiHandle, ALit_BdsTO, ElapsedTime);
   }
 
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOTAL_DURATION), gDpHiiHandle, Total);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOTAL_DURATION), mDpHiiHandle, Total);
 }
 
-/** 
+/**
   Gather and print Handle data.
-  
+
   @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items from display.
-  
+
   @retval EFI_SUCCESS             The operation was successful.
   @retval EFI_ABORTED             The user aborts the operation.
   @return Others                  from a call to gBS->LocateHandleBuffer().
@@ -529,16 +529,16 @@ ProcessHandles(
   EFI_STATUS                Status;
   EFI_STRING                StringPtrUnknown;
 
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);  
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
+  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_DRIVERS), NULL);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
               (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
   FreePool (StringPtr);
   FreePool (StringPtrUnknown);
 
   Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount, &HandleBuffer);
   if (EFI_ERROR (Status)) {
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), gDpHiiHandle, Status);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR), mDpHiiHandle, Status);
   }
   else {
 #if DP_DEBUG == 2
@@ -546,11 +546,11 @@ ProcessHandles(
 #endif
 
     if (mShowId) {
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION2), gDpHiiHandle);
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION2), mDpHiiHandle);
     } else {
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION), gDpHiiHandle);
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_SECTION), mDpHiiHandle);
     }
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
 
     LogEntryKey = 0;
     Count   = 0;
@@ -588,7 +588,7 @@ ProcessHandles(
       if (mGaugeString[0] != 0) {
         // Display the record if it has a valid handle.
         if (mShowId) {
-          ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS2), gDpHiiHandle,
+          ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS2), mDpHiiHandle,
             Count,      // 1 based, Which measurement record is being printed
             Index + 1,  // 1 based, Which handle is being printed
             mGaugeString,
@@ -597,7 +597,7 @@ ProcessHandles(
             Measurement.Identifier
           );
         } else {
-          ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS), gDpHiiHandle,
+          ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS), mDpHiiHandle,
             Count,      // 1 based, Which measurement record is being printed
             Index + 1,  // 1 based, Which handle is being printed
             mGaugeString,
@@ -618,11 +618,11 @@ ProcessHandles(
   return Status;
 }
 
-/** 
+/**
   Gather and print PEIM data.
-  
+
   Only prints complete PEIM records
-  
+
   @retval EFI_SUCCESS           The operation was successful.
   @retval EFI_ABORTED           The user aborts the operation.
 **/
@@ -642,19 +642,19 @@ ProcessPeims(
 
   Status = EFI_SUCCESS;
 
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);  
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
+  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
               (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
   FreePool (StringPtr);
   FreePool (StringPtrUnknown);
 
   if (mShowId) {
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION2), gDpHiiHandle);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION2), mDpHiiHandle);
   } else {
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION), gDpHiiHandle);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION), mDpHiiHandle);
   }
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
   TIndex  = 0;
   LogEntryKey = 0;
   while ((LogEntryKey = GetPerformanceMeasurementEx (
@@ -678,7 +678,7 @@ ProcessPeims(
     if (ElapsedTime >= mInterestThreshold) {
       // PEIM FILE Handle is the start address of its FFS file that contains its file guid.
       if (mShowId) {
-        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS2), gDpHiiHandle,
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS2), mDpHiiHandle,
               TIndex,   // 1 based, Which measurement record is being printed
               Measurement.Handle,  // base address
               Measurement.Handle,  // file guid
@@ -686,7 +686,7 @@ ProcessPeims(
               Measurement.Identifier
         );
       } else {
-        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS), gDpHiiHandle,
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS), mDpHiiHandle,
               TIndex,   // 1 based, Which measurement record is being printed
               Measurement.Handle,  // base address
               Measurement.Handle,  // file guid
@@ -702,14 +702,14 @@ ProcessPeims(
   return Status;
 }
 
-/** 
+/**
   Gather and print global data.
-  
+
   Strips out incomplete or "Execution Phase" records
   Only prints records where Handle is NULL
   Increment TIndex for every record, even skipped ones, so that we have an
   indication of every measurement record taken.
-  
+
   @retval EFI_SUCCESS           The operation was successful.
   @retval EFI_ABORTED           The user aborts the operation.
 **/
@@ -729,19 +729,19 @@ ProcessGlobal(
 
   Status = EFI_SUCCESS;
 
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);  
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
+  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
               (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
   FreePool (StringPtr);
   FreePool (StringPtrUnknown);
 
   if (mShowId) {
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION2), gDpHiiHandle);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION2), mDpHiiHandle);
   } else {
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION), gDpHiiHandle);
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION), mDpHiiHandle);
   }
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
 
   Index = 1;
   LogEntryKey = 0;
@@ -768,7 +768,7 @@ ProcessGlobal(
       ElapsedTime = DurationInMicroSeconds ( Duration );
       if (ElapsedTime >= mInterestThreshold) {
         if (mShowId) {
-          ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS2), gDpHiiHandle,
+          ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS2), mDpHiiHandle,
             Index,
             mGaugeString,
             mUnicodeToken,
@@ -776,7 +776,7 @@ ProcessGlobal(
             Measurement.Identifier
             );
         } else {
-           ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS), gDpHiiHandle,
+           ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS), mDpHiiHandle,
             Index,
             mGaugeString,
             mUnicodeToken,
@@ -794,9 +794,9 @@ ProcessGlobal(
   return Status;
 }
 
-/** 
+/**
   Gather and print cumulative data.
-  
+
   Traverse the measurement records and:<BR>
   For each record with a Token listed in the CumData array:<BR>
      - Update the instance count and the total, minimum, and maximum durations.
@@ -818,16 +818,16 @@ ProcessCumulative(
   UINTN                     TIndex;
   EFI_STRING                StringPtrUnknown;
 
-  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);  
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), gDpHiiHandle,
+  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_CUMULATIVE), NULL);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER), mDpHiiHandle,
               (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
   FreePool (StringPtr);
   FreePool (StringPtrUnknown);
 
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1), gDpHiiHandle);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2), gDpHiiHandle);
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), gDpHiiHandle);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_1), mDpHiiHandle);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_SECT_2), mDpHiiHandle);
+  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES), mDpHiiHandle);
 
   for ( TIndex = 0; TIndex < NumCum; ++TIndex) {
     if (CumData[TIndex].Count != 0) {
@@ -836,8 +836,8 @@ ProcessCumulative(
       Dur    = DurationInMicroSeconds(CumData[TIndex].Duration);
       MaxDur = DurationInMicroSeconds(CumData[TIndex].MaxDur);
       MinDur = DurationInMicroSeconds(CumData[TIndex].MinDur);
-    
-      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), gDpHiiHandle,
+
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), mDpHiiHandle,
                   CumData[TIndex].Name,
                   CumData[TIndex].Count,
                   Dur,
@@ -864,7 +864,7 @@ ProcessCumulative(
       MaxDur = 0;
       MinDur = 0;
     }
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), gDpHiiHandle,
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CUMULATIVE_STATS), mDpHiiHandle,
                 CustomCumulativeData->Name,
                 CustomCumulativeData->Count,
                 Dur,
diff --git a/ShellPkg/Library/UefiDpLib/DpUtilities.c b/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c
similarity index 87%
rename from ShellPkg/Library/UefiDpLib/DpUtilities.c
rename to ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c
index c60d27d861..b98ec4b5bd 100644
--- a/ShellPkg/Library/UefiDpLib/DpUtilities.c
+++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c
@@ -196,18 +196,19 @@ DpGetNameFromHandle (
   IN EFI_HANDLE   Handle
   )
 {
-  EFI_STATUS                  Status;
-  EFI_LOADED_IMAGE_PROTOCOL   *Image;
-  CHAR8                       *PdbFileName;
-  EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
-  EFI_STRING                  StringPtr;
-  EFI_DEVICE_PATH_PROTOCOL    *LoadedImageDevicePath;
-  EFI_DEVICE_PATH_PROTOCOL    *DevicePath;
-  EFI_GUID                    *NameGuid;
-  CHAR16                      *NameString;
-  UINTN                       StringSize;
-  CHAR8                       *PlatformLanguage;
-  EFI_COMPONENT_NAME2_PROTOCOL      *ComponentName2;
+  EFI_STATUS                   Status;
+  EFI_LOADED_IMAGE_PROTOCOL    *Image;
+  CHAR8                        *PdbFileName;
+  EFI_DRIVER_BINDING_PROTOCOL  *DriverBinding;
+  EFI_STRING                   StringPtr;
+  EFI_DEVICE_PATH_PROTOCOL     *LoadedImageDevicePath;
+  EFI_DEVICE_PATH_PROTOCOL     *DevicePath;
+  EFI_GUID                     *NameGuid;
+  CHAR16                       *NameString;
+  UINTN                        StringSize;
+  CHAR8                        *PlatformLanguage;
+  CHAR8                        *BestLanguage;
+  EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
 
   Image = NULL;
   LoadedImageDevicePath = NULL;
@@ -259,16 +260,25 @@ DpGetNameFromHandle (
                   );
   if (!EFI_ERROR (Status)) {
     //
-    // Get the current platform language setting
+    // Firstly use platform language setting, secondly use driver's first supported language.
     //
-    PlatformLanguage = GetBestLanguageForDriver(ComponentName2->SupportedLanguages, NULL, FALSE);
+    GetVariable2 (L"PlatformLang", &gEfiGlobalVariableGuid, (VOID**)&PlatformLanguage, NULL);
+    BestLanguage = GetBestLanguage(
+                     ComponentName2->SupportedLanguages,
+                     FALSE,
+                     (PlatformLanguage != NULL) ? PlatformLanguage : "",
+                     ComponentName2->SupportedLanguages,
+                     NULL
+                     );
+    SHELL_FREE_NON_NULL (PlatformLanguage);
+
     Status = ComponentName2->GetDriverName (
                                ComponentName2,
-                               PlatformLanguage != NULL ? PlatformLanguage : "en-US",
+                               BestLanguage != NULL ? BestLanguage : "en-US",
                                &StringPtr
                                );
     if (!EFI_ERROR (Status)) {
-      SHELL_FREE_NON_NULL (PlatformLanguage);
+      SHELL_FREE_NON_NULL (BestLanguage);
       StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr, DP_GAUGE_STRING_LENGTH);
       mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
       return;
@@ -344,7 +354,7 @@ DpGetNameFromHandle (
   //
   // Method 6: Unknown Driver Name
   //
-  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_ERROR_NAME), NULL);
+  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_DP_ERROR_NAME), NULL);
   ASSERT (StringPtr != NULL);
   StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr, DP_GAUGE_STRING_LENGTH);
   FreePool (StringPtr);
diff --git a/ShellPkg/Library/UefiDpLib/Literals.c b/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.c
similarity index 100%
rename from ShellPkg/Library/UefiDpLib/Literals.c
rename to ShellPkg/DynamicCommand/DpDynamicCommand/Literals.c
diff --git a/ShellPkg/Library/UefiDpLib/Literals.h b/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.h
similarity index 100%
rename from ShellPkg/Library/UefiDpLib/Literals.h
rename to ShellPkg/DynamicCommand/DpDynamicCommand/Literals.h
diff --git a/ShellPkg/Library/UefiDpLib/PerformanceTokens.h b/ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h
similarity index 100%
rename from ShellPkg/Library/UefiDpLib/PerformanceTokens.h
rename to ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h
diff --git a/ShellPkg/Library/UefiDpLib/Readme.txt b/ShellPkg/Library/UefiDpLib/Readme.txt
deleted file mode 100644
index 849efa4360..0000000000
--- a/ShellPkg/Library/UefiDpLib/Readme.txt
+++ /dev/null
@@ -1,2 +0,0 @@
-from PerformancePkg\Dp_App
-SVN 13406
diff --git a/ShellPkg/Library/UefiDpLib/UefiDpLib.c b/ShellPkg/Library/UefiDpLib/UefiDpLib.c
deleted file mode 100644
index f3ecfeac7f..0000000000
--- a/ShellPkg/Library/UefiDpLib/UefiDpLib.c
+++ /dev/null
@@ -1,101 +0,0 @@
-/** @file
-  Main file for NULL named library for install1 shell command functions.
-
-  Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.
-  This program and the accompanying materials
-  are licensed and made available under the terms and conditions of the BSD License
-  which accompanies this distribution.  The full text of the license may be found at
-  http://opensource.org/licenses/bsd-license.php
-
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#include "UefiDpLib.h"
-
-STATIC CONST CHAR16 mFileName[] = L"ShellCommands";
-EFI_HANDLE gDpHiiHandle = NULL;
-
-#define DP_HII_GUID \
-  { \
-  0xeb832fd9, 0x9089, 0x4898, { 0x83, 0xc9, 0x41, 0x61, 0x8f, 0x5c, 0x48, 0xb9 } \
-  }
-
-EFI_GUID gDpHiiGuid = DP_HII_GUID;
-
-/**
-  Function to get the filename with help context if HII will not be used.
-
-  @return   The filename with help text in it.
-**/
-CONST CHAR16*
-EFIAPI
-UefiDpLibGetManFileName (
-  VOID
-  )
-{
-  return (mFileName);
-}
-
-/**
-  Constructor for the Shell Level 1 Commands library.
-
-  Install the handlers for level 1 UEFI Shell 2.0 commands.
-
-  @param ImageHandle    the image handle of the process
-  @param SystemTable    the EFI System Table pointer
-
-  @retval EFI_SUCCESS        the shell command handlers were installed sucessfully
-  @retval EFI_UNSUPPORTED    the shell level required was not found.
-**/
-EFI_STATUS
-EFIAPI
-UefiDpLibConstructor (
-  IN EFI_HANDLE        ImageHandle,
-  IN EFI_SYSTEM_TABLE  *SystemTable
-  )
-{
-  //
-  // check our bit of the profiles mask
-  //
-  if ((PcdGet8(PcdShellProfileMask) & BIT2) == 0) {
-    return (EFI_SUCCESS);
-  }
-
-  //
-  // 3rd parameter 'HII strings array' must be name of .uni strings file followed by 'Strings', e.g. mycommands.uni must be
-  // specified as 'mycommandsStrings' because the build Autogen process defines this as a string array for the strings in your
-  // .uni file.  Examine your Build folder under your package's DEBUG folder and you will find it defined in a xxxStrDefs.h file.
-  //
-  gDpHiiHandle = HiiAddPackages (&gDpHiiGuid, gImageHandle, UefiDpLibStrings, NULL);
-  if (gDpHiiHandle == NULL) {
-    return (EFI_DEVICE_ERROR);
-  }
-
-  //
-  // install our shell command handlers that are always installed
-  //
-  ShellCommandRegisterCommandName(L"dp", ShellCommandRunDp , UefiDpLibGetManFileName, 0, L"", FALSE, gDpHiiHandle, STRING_TOKEN(STR_GET_HELP_DP));
-
-  return (EFI_SUCCESS);
-}
-
-/**
-  Destructor for the library.  free any resources.
-
-  @param ImageHandle            The image handle of the process.
-  @param SystemTable            The EFI System Table pointer.
-**/
-EFI_STATUS
-EFIAPI
-UefiDpLibDestructor (
-  IN EFI_HANDLE        ImageHandle,
-  IN EFI_SYSTEM_TABLE  *SystemTable
-  )
-{
-  if (gDpHiiHandle != NULL) {
-    HiiRemovePackages(gDpHiiHandle);
-  }
-  return (EFI_SUCCESS);
-}
diff --git a/ShellPkg/Library/UefiDpLib/UefiDpLib.h b/ShellPkg/Library/UefiDpLib/UefiDpLib.h
deleted file mode 100644
index 283f8337ff..0000000000
--- a/ShellPkg/Library/UefiDpLib/UefiDpLib.h
+++ /dev/null
@@ -1,64 +0,0 @@
-/** @file
-  Main file for NULL named library for dp command functions.
-
-  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
-  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
-  This program and the accompanying materials
-  are licensed and made available under the terms and conditions of the BSD License
-  which accompanies this distribution.  The full text of the license may be found at
-  http://opensource.org/licenses/bsd-license.php
-
-  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-
-**/
-
-#ifndef _UEFI_DP_LIB_H_
-#define _UEFI_DP_LIB_H_
-
-#include <Uefi.h>
-
-extern EFI_GUID gDpHiiGuid;
-
-#include <Protocol/Shell.h>
-#include <Protocol/ShellParameters.h>
-#include <Protocol/DevicePath.h>
-#include <Protocol/LoadedImage.h>
-#include <Protocol/UnicodeCollation.h>
-
-#include <Library/BaseLib.h>
-#include <Library/BaseMemoryLib.h>
-#include <Library/DebugLib.h>
-#include <Library/MemoryAllocationLib.h>
-#include <Library/PcdLib.h>
-#include <Library/ShellCommandLib.h>
-#include <Library/ShellLib.h>
-#include <Library/SortLib.h>
-#include <Library/UefiLib.h>
-#include <Library/UefiRuntimeServicesTableLib.h>
-#include <Library/UefiBootServicesTableLib.h>
-#include <Library/HiiLib.h>
-#include <Library/FileHandleLib.h>
-
-extern        EFI_HANDLE                        gDpHiiHandle;
-
-/**
-  Function for 'dp' command.
-
-  @param[in] ImageHandle  Handle to the Image (NULL if Internal).
-  @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
-
-  @retval SHELL_SUCCESS            Command completed successfully.
-  @retval SHELL_INVALID_PARAMETER  Command usage error.
-  @retval SHELL_ABORTED            The user aborts the operation.
-  @retval value                    Unknown error.
-**/
-SHELL_STATUS
-EFIAPI
-ShellCommandRunDp (
-  IN EFI_HANDLE        ImageHandle,
-  IN EFI_SYSTEM_TABLE  *SystemTable
-  );
-
-#endif
-
diff --git a/ShellPkg/Library/UefiDpLib/UefiDpLib.inf b/ShellPkg/Library/UefiDpLib/UefiDpLib.inf
deleted file mode 100644
index 0bce0ce6c9..0000000000
--- a/ShellPkg/Library/UefiDpLib/UefiDpLib.inf
+++ /dev/null
@@ -1,77 +0,0 @@
-##  @file
-#  Display Performance Application, Module information file.
-#
-# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
-# This program and the accompanying materials
-# are licensed and made available under the terms and conditions of the BSD License
-# which accompanies this distribution.  The full text of the license may be found at
-# http://opensource.org/licenses/bsd-license.php
-#
-# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
-# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
-#
-##
-
-[Defines]
-  INF_VERSION                    = 0x00010006
-  BASE_NAME                      = UefiDpLib
-  FILE_GUID                      = 9DF262F7-CF81-4294-B5A5-B2E3CAFE5618
-  MODULE_TYPE                    = UEFI_DRIVER
-  VERSION_STRING                 = 1.0
-  LIBRARY_CLASS                  = NULL|UEFI_APPLICATION UEFI_DRIVER
-  CONSTRUCTOR                    = UefiDpLibConstructor
-  DESTRUCTOR                     = UefiDpLibDestructor
-
-#
-# The following information is for reference only and not required by the build tools.
-#
-#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC
-#
-
-[Sources.common]
-  PerformanceTokens.h
-  UefiDpLib.c
-  UefiDpLib.h
-  UefiDpLib.uni
-  Dp.c
-  Dp.h
-  Literals.h
-  Literals.c
-  DpInternal.h
-  DpUtilities.c
-  DpTrace.c
-  DpProfile.c
-
-[Packages]
-  MdePkg/MdePkg.dec
-  ShellPkg/ShellPkg.dec
-  MdeModulePkg/MdeModulePkg.dec
-
-[LibraryClasses]
-  PerformanceLib
-  DxeServicesLib
-  MemoryAllocationLib
-  BaseLib
-  BaseMemoryLib
-  DebugLib
-  ShellCommandLib
-  ShellLib
-  UefiLib
-  UefiRuntimeServicesTableLib
-  UefiBootServicesTableLib
-  SortLib
-  PrintLib
-  DevicePathLib
-
-[Guids]
-  gPerformanceProtocolGuid                                ## CONSUMES ## SystemTable
-
-[Protocols]
-  gEfiLoadedImageProtocolGuid                             ## CONSUMES
-  gEfiDriverBindingProtocolGuid                           ## SOMETIMES_CONSUMES
-  gEfiComponentName2ProtocolGuid                          ## SOMETIMES_CONSUMES
-  gEfiLoadedImageDevicePathProtocolGuid                   ## SOMETIMES_CONSUMES
-
-[Pcd]
-  gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize   ## UNDEFINED
-  gEfiShellPkgTokenSpaceGuid.PcdShellProfileMask          ## CONSUMES
diff --git a/ShellPkg/ShellPkg.dsc b/ShellPkg/ShellPkg.dsc
index 8fc20709f4..65e8959455 100644
--- a/ShellPkg/ShellPkg.dsc
+++ b/ShellPkg/ShellPkg.dsc
@@ -104,12 +104,6 @@ [Components]
   ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
   ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf
 
-  ShellPkg/Library/UefiDpLib/UefiDpLib.inf {
-    <LibraryClasses>
-      PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
-      DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
-  }
-
   ShellPkg/Application/Shell/Shell.inf {
     <PcdsFixedAtBuild>
       gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
@@ -123,14 +117,19 @@ [Components]
       NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1CommandsLib.inf
       NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1CommandsLib.inf
       NULL|ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2CommandsLib.inf
-!ifdef $(INCLUDE_DP)
-      NULL|ShellPkg/Library/UefiDpLib/UefiDpLib.inf
-!endif #$(INCLUDE_DP)
 !endif #$(NO_SHELL_PROFILES)
   }
 
   ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.inf
   ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.inf
+  ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf {
+    <LibraryClasses>
+      PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
+  }
+  ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf {
+    <LibraryClasses>
+      PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmmPerformanceLib.inf
+  }
 
 [BuildOptions]
   *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
-- 
2.15.0.gvfs.1.preview.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel
Re: [edk2] [PATCH v2 3/3] ShellPkg/dp: Convert from NULL class library to Dynamic Command
Posted by Carsey, Jaben 7 years ago
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>

> -----Original Message-----
> From: Ni, Ruiyu
> Sent: Sunday, November 26, 2017 9:56 PM
> To: edk2-devel@lists.01.org
> Cc: Carsey, Jaben <jaben.carsey@intel.com>; Kinney, Michael D
> <michael.d.kinney@intel.com>
> Subject: [PATCH v2 3/3] ShellPkg/dp: Convert from NULL class library to
> Dynamic Command
> Importance: High
> 
> 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>
> Cc: Jaben Carsey <jaben.carsey@intel.com>
> Cc: Michael D Kinney <michael.d.kinney@intel.com>
> ---
>  .../DpDynamicCommand}/Dp.c                         | 100 +++++++----
>  .../DpDynamicCommand}/Dp.h                         |  63 ++++++-
>  .../DpDynamicCommand/Dp.uni}                       |   0
>  ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c   |  53 ++++++
>  ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf |  73
> +++++++++
>  .../DpDynamicCommand/DpDynamicCommand.c            | 130
> +++++++++++++++
>  .../DpDynamicCommand/DpDynamicCommand.inf          |  78 +++++++++
>  .../DpDynamicCommand}/DpInternal.h                 |   2 +-
>  .../DpDynamicCommand}/DpProfile.c                  |  34 ++--
>  .../DpDynamicCommand}/DpTrace.c                    | 182 ++++++++++-----------
>  .../DpDynamicCommand}/DpUtilities.c                |  44 +++--
>  .../DpDynamicCommand}/Literals.c                   |   0
>  .../DpDynamicCommand}/Literals.h                   |   0
>  .../DpDynamicCommand}/PerformanceTokens.h          |   0
>  ShellPkg/Library/UefiDpLib/Readme.txt              |   2 -
>  ShellPkg/Library/UefiDpLib/UefiDpLib.c             | 101 ------------
>  ShellPkg/Library/UefiDpLib/UefiDpLib.h             |  64 --------
>  ShellPkg/Library/UefiDpLib/UefiDpLib.inf           |  77 ---------
>  ShellPkg/ShellPkg.dsc                              |  17 +-
>  19 files changed, 605 insertions(+), 415 deletions(-)
>  rename ShellPkg/{Library/UefiDpLib =>
> DynamicCommand/DpDynamicCommand}/Dp.c (84%)
>  rename ShellPkg/{Library/UefiDpLib =>
> DynamicCommand/DpDynamicCommand}/Dp.h (70%)
>  rename ShellPkg/{Library/UefiDpLib/UefiDpLib.uni =>
> DynamicCommand/DpDynamicCommand/Dp.uni} (100%)
>  create mode 100644
> ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c
>  create mode 100644
> ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
>  create mode 100644
> ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.c
>  create mode 100644
> ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
>  rename ShellPkg/{Library/UefiDpLib =>
> DynamicCommand/DpDynamicCommand}/DpInternal.h (96%)
>  rename ShellPkg/{Library/UefiDpLib =>
> DynamicCommand/DpDynamicCommand}/DpProfile.c (87%)
>  rename ShellPkg/{Library/UefiDpLib =>
> DynamicCommand/DpDynamicCommand}/DpTrace.c (89%)
>  rename ShellPkg/{Library/UefiDpLib =>
> DynamicCommand/DpDynamicCommand}/DpUtilities.c (87%)
>  rename ShellPkg/{Library/UefiDpLib =>
> DynamicCommand/DpDynamicCommand}/Literals.c (100%)
>  rename ShellPkg/{Library/UefiDpLib =>
> DynamicCommand/DpDynamicCommand}/Literals.h (100%)
>  rename ShellPkg/{Library/UefiDpLib =>
> DynamicCommand/DpDynamicCommand}/PerformanceTokens.h (100%)
>  delete mode 100644 ShellPkg/Library/UefiDpLib/Readme.txt
>  delete mode 100644 ShellPkg/Library/UefiDpLib/UefiDpLib.c
>  delete mode 100644 ShellPkg/Library/UefiDpLib/UefiDpLib.h
>  delete mode 100644 ShellPkg/Library/UefiDpLib/UefiDpLib.inf
> 
> diff --git a/ShellPkg/Library/UefiDpLib/Dp.c
> b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> similarity index 84%
> rename from ShellPkg/Library/UefiDpLib/Dp.c
> rename to ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> index 94fa61c710..3ecc753d0c 100644
> --- a/ShellPkg/Library/UefiDpLib/Dp.c
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
> @@ -24,20 +24,13 @@
>    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
>  **/
> 
> -#include "UefiDpLib.h"
> -#include <Library/ShellLib.h>
> -#include <Library/BaseLib.h>
> -#include <Library/MemoryAllocationLib.h>
> -#include <Library/DebugLib.h>
> -#include <Library/UefiLib.h>
> -
> -#include <Guid/Performance.h>
> -
>  #include "PerformanceTokens.h"
>  #include "Dp.h"
>  #include "Literals.h"
>  #include "DpInternal.h"
> 
> +EFI_HANDLE   mDpHiiHandle;
> +
>  //
>  /// Module-Global Variables
>  ///@{
> @@ -89,18 +82,18 @@ DumpStatistics( void )
>  {
>    EFI_STRING                StringPtr;
>    EFI_STRING                StringPtrUnknown;
> -  StringPtr        = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_STATISTICS), NULL);
> -  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> gDpHiiHandle,
> +  StringPtr        = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_STATISTICS), NULL);
> +  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> mDpHiiHandle,
>                (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMTRACE),
> gDpHiiHandle,      SummaryData.NumTrace);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_STATS_NUMINCOMPLETE), gDpHiiHandle,
> SummaryData.NumIncomplete);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_STATS_NUMPHASES), gDpHiiHandle,
> SummaryData.NumSummary);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_STATS_NUMHANDLES), gDpHiiHandle,
> SummaryData.NumHandles, SummaryData.NumTrace -
> SummaryData.NumHandles);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPEIMS),
> gDpHiiHandle,      SummaryData.NumPEIMs);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_STATS_NUMGLOBALS), gDpHiiHandle,
> SummaryData.NumGlobal);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_STATS_NUMTRACE), mDpHiiHandle,      SummaryData.NumTrace);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_STATS_NUMINCOMPLETE), mDpHiiHandle,
> SummaryData.NumIncomplete);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_STATS_NUMPHASES), mDpHiiHandle,
> SummaryData.NumSummary);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_STATS_NUMHANDLES), mDpHiiHandle,
> SummaryData.NumHandles, SummaryData.NumTrace -
> SummaryData.NumHandles);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_STATS_NUMPEIMS), mDpHiiHandle,      SummaryData.NumPEIMs);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_STATS_NUMGLOBALS), mDpHiiHandle,
> SummaryData.NumGlobal);
>  #if PROFILING_IMPLEMENTED
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_STATS_NUMPROFILE), gDpHiiHandle,    SummaryData.NumProfile);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_STATS_NUMPROFILE), mDpHiiHandle,
> SummaryData.NumProfile);
>  #endif // PROFILING_IMPLEMENTED
>    SHELL_FREE_NON_NULL (StringPtr);
>    SHELL_FREE_NON_NULL (StringPtrUnknown);
> @@ -137,8 +130,7 @@ InitCumulativeData (
>    @retval value                    Unknown error.
>  **/
>  SHELL_STATUS
> -EFIAPI
> -ShellCommandRunDp (
> +RunDp (
>    IN EFI_HANDLE               ImageHandle,
>    IN EFI_SYSTEM_TABLE         *SystemTable
>    )
> @@ -182,15 +174,12 @@ ShellCommandRunDp (
>    Status = ShellInitialize();
>    ASSERT_EFI_ERROR(Status);
> 
> -  Status = CommandInit();
> -  ASSERT_EFI_ERROR(Status);
> -
>    //
>    // Process Command Line arguments
>    //
>    Status = ShellCommandLineParse (ParamList, &ParamPackage, NULL,
> TRUE);
>    if (EFI_ERROR(Status)) {
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_ARG),
> gDpHiiHandle);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_ARG),
> mDpHiiHandle);
>      return SHELL_INVALID_PARAMETER;
>    }
> 
> @@ -273,7 +262,7 @@ ShellCommandRunDp (
>    //
>    Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid,
> (VOID **) &PerformanceProperty);
>    if (EFI_ERROR (Status) || (PerformanceProperty == NULL)) {
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_PERF_PROPERTY_NOT_FOUND), gDpHiiHandle);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_PERF_PROPERTY_NOT_FOUND), mDpHiiHandle);
>      goto Done;
>    }
> 
> @@ -288,22 +277,22 @@ ShellCommandRunDp (
>    // Print header
>    //
>    // print DP's build version
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_BUILD_REVISION),
> gDpHiiHandle, DP_MAJOR_VERSION, DP_MINOR_VERSION);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_BUILD_REVISION),
> mDpHiiHandle, DP_MAJOR_VERSION, DP_MINOR_VERSION);
> 
>    // print performance timer characteristics
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_KHZ), gDpHiiHandle,
> TimerInfo.Frequency);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_KHZ),
> mDpHiiHandle, TimerInfo.Frequency);
> 
>    if (VerboseMode && !RawMode) {
> -    StringPtr = HiiGetString (gDpHiiHandle,
> +    StringPtr = HiiGetString (mDpHiiHandle,
>                    (EFI_STRING_ID) (TimerInfo.CountUp ? STRING_TOKEN
> (STR_DP_UP) : STRING_TOKEN (STR_DP_DOWN)), NULL);
>      ASSERT (StringPtr != NULL);
>      // Print Timer count range and direction
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_TIMER_PROPERTIES), gDpHiiHandle,
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_TIMER_PROPERTIES), mDpHiiHandle,
>                  StringPtr,
>                  TimerInfo.StartCount,
>                  TimerInfo.EndCount
>                  );
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_VERBOSE_THRESHOLD), gDpHiiHandle, mInterestThreshold);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_VERBOSE_THRESHOLD), mDpHiiHandle, mInterestThreshold);
>    }
> 
> 
> /**********************************************************
> ******************
> @@ -398,3 +387,52 @@ Done:
> 
>    return ShellStatus;
>  }
> +
> +
> +/**
> +  Retrive HII package list from ImageHandle and publish to HII database.
> +
> +  @param ImageHandle            The image handle of the process.
> +
> +  @return HII handle.
> +**/
> +EFI_HANDLE
> +InitializeHiiPackage (
> +  EFI_HANDLE                  ImageHandle
> +  )
> +{
> +  EFI_STATUS                  Status;
> +  EFI_HII_PACKAGE_LIST_HEADER *PackageList;
> +  EFI_HANDLE                  HiiHandle;
> +
> +  //
> +  // Retrieve HII package list from ImageHandle
> +  //
> +  Status = gBS->OpenProtocol (
> +                  ImageHandle,
> +                  &gEfiHiiPackageListProtocolGuid,
> +                  (VOID **)&PackageList,
> +                  ImageHandle,
> +                  NULL,
> +                  EFI_OPEN_PROTOCOL_GET_PROTOCOL
> +                  );
> +  ASSERT_EFI_ERROR (Status);
> +  if (EFI_ERROR (Status)) {
> +    return NULL;
> +  }
> +
> +  //
> +  // Publish HII package list to HII Database.
> +  //
> +  Status = gHiiDatabase->NewPackageList (
> +                           gHiiDatabase,
> +                           PackageList,
> +                           NULL,
> +                           &HiiHandle
> +                           );
> +  ASSERT_EFI_ERROR (Status);
> +  if (EFI_ERROR (Status)) {
> +    return NULL;
> +  }
> +  return HiiHandle;
> +}
> diff --git a/ShellPkg/Library/UefiDpLib/Dp.h
> b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
> similarity index 70%
> rename from ShellPkg/Library/UefiDpLib/Dp.h
> rename to ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
> index 06fee3bcf4..4027b6b84e 100644
> --- a/ShellPkg/Library/UefiDpLib/Dp.h
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.h
> @@ -1,7 +1,7 @@
>  /** @file
> -  Common declarations for the Dp Performance Reporting Utility.
> +  Header file for 'dp' command functions.
> 
> -  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
> +  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
>    This program and the accompanying materials
>    are licensed and made available under the terms and conditions of the BSD
> License
>    which accompanies this distribution.  The full text of the license may be
> found at
> @@ -9,12 +9,37 @@
> 
>    THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
>    WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
>  **/
> 
> -#ifndef _EFI_APP_DP_H_
> -#define _EFI_APP_DP_H_
> +#ifndef _DP_H_
> +#define _DP_H_
> +
> +
> +#include <Uefi.h>
> +
> +#include <Guid/Performance.h>
> 
> +#include <Protocol/HiiPackageList.h>
> +#include <Protocol/DevicePath.h>
> +#include <Protocol/LoadedImage.h>
> +#include <Protocol/UnicodeCollation.h>
> +
> +#include <Library/BaseLib.h>
> +#include <Library/BaseMemoryLib.h>
> +#include <Library/DebugLib.h>
> +#include <Library/MemoryAllocationLib.h>
>  #include <Library/ShellLib.h>
> +#include <Library/UefiLib.h>
> +#include <Library/UefiRuntimeServicesTableLib.h>
> +#include <Library/UefiBootServicesTableLib.h>
> +#include <Library/PcdLib.h>
> +#include <Library/SortLib.h>
> +#include <Library/HiiLib.h>
> +#include <Library/FileHandleLib.h>
> +#include <Library/UefiHiiServicesLib.h>
> +
> +extern EFI_HANDLE mDpHiiHandle;
> 
>  #define DP_MAJOR_VERSION        2
>  #define DP_MINOR_VERSION        4
> @@ -94,4 +119,32 @@ typedef struct {
>    UINT32                Count;            ///< Number of measurements accumulated.
>  } PROFILE_RECORD;
> 
> -#endif  // _EFI_APP_DP_H_
> +/**
> +  Dump performance data.
> +
> +  @param[in]  ImageHandle     The image handle.
> +  @param[in]  SystemTable     The system table.
> +
> +  @retval SHELL_SUCCESS            Command completed successfully.
> +  @retval SHELL_INVALID_PARAMETER  Command usage error.
> +  @retval SHELL_ABORTED            The user aborts the operation.
> +  @retval value                    Unknown error.
> +**/
> +SHELL_STATUS
> +RunDp (
> +  IN EFI_HANDLE               ImageHandle,
> +  IN EFI_SYSTEM_TABLE         *SystemTable
> +  );
> +
> +/**
> +  Retrive HII package list from ImageHandle and publish to HII database.
> +
> +  @param ImageHandle            The image handle of the process.
> +
> +  @return HII handle.
> +**/
> +EFI_HANDLE
> +InitializeHiiPackage (
> +  EFI_HANDLE                  ImageHandle
> +  );
> +#endif  // _DP_H_
> diff --git a/ShellPkg/Library/UefiDpLib/UefiDpLib.uni
> b/ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
> similarity index 100%
> rename from ShellPkg/Library/UefiDpLib/UefiDpLib.uni
> rename to ShellPkg/DynamicCommand/DpDynamicCommand/Dp.uni
> diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c
> b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c
> new file mode 100644
> index 0000000000..f96209b27a
> --- /dev/null
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.c
> @@ -0,0 +1,53 @@
> +/** @file
> +  Entrypoint of "dp" shell standalone application.
> +
> +  Copyright (c) 2017, Intel Corporation. All rights reserved. <BR>
> +
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD
> License
> +  which accompanies this distribution.  The full text of the license may be
> found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +**/
> +#include "Dp.h"
> +
> +//
> +// String token ID of help message text.
> +// Shell supports to find help message in the resource section of an
> application image if
> +// .MAN file is not found. This global variable is added to make build tool
> recognizes
> +// that the help string is consumed by user and then build tool will add the
> string into
> +// the resource section. Thus the application can use '-?' option to show
> help message in
> +// Shell.
> +//
> +GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mStringHelpTokenId
> = STRING_TOKEN (STR_GET_HELP_DP);
> +
> +/**
> +  Entry point of Tftp standalone application.
> +
> +  @param ImageHandle            The image handle of the process.
> +  @param SystemTable            The EFI System Table pointer.
> +
> +  @retval EFI_SUCCESS           Tftp command is executed sucessfully.
> +  @retval EFI_ABORTED           HII package was failed to initialize.
> +  @retval others                Other errors when executing tftp command.
> +**/
> +EFI_STATUS
> +EFIAPI
> +DpAppInitialize (
> +  IN EFI_HANDLE               ImageHandle,
> +  IN EFI_SYSTEM_TABLE         *SystemTable
> +  )
> +{
> +  EFI_STATUS                  Status;
> +  mDpHiiHandle = InitializeHiiPackage (ImageHandle);
> +  if (mDpHiiHandle == NULL) {
> +    return EFI_ABORTED;
> +  }
> +
> +  Status = (EFI_STATUS)RunDp (ImageHandle, SystemTable);
> +  HiiRemovePackages (mDpHiiHandle);
> +  return Status;
> +}
> diff --git a/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
> b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
> new file mode 100644
> index 0000000000..b0ed229b49
> --- /dev/null
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf
> @@ -0,0 +1,73 @@
> +##  @file
> +# Provides Shell 'dp' standalone application.
> +#
> +# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
> +#  This program and the accompanying materials
> +#  are licensed and made available under the terms and conditions of the
> BSD License
> +#  which accompanies this distribution. The full text of the license may be
> found at
> +#  http://opensource.org/licenses/bsd-license.php
> +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +#
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION                    = 0x00010006
> +  BASE_NAME                      = dp
> +  FILE_GUID                      = 1831A379-2D48-45BD-9744-D4059D93815D
> +  MODULE_TYPE                    = UEFI_APPLICATION
> +  VERSION_STRING                 = 1.0
> +  ENTRY_POINT                    = DpAppInitialize
> +#
> +#  This flag specifies whether HII resource section is generated into PE
> image.
> +#
> +  UEFI_HII_RESOURCE_SECTION      = TRUE
> +
> +[Sources.common]
> +  PerformanceTokens.h
> +  Dp.uni
> +  Dp.c
> +  Dp.h
> +  Literals.h
> +  Literals.c
> +  DpInternal.h
> +  DpUtilities.c
> +  DpTrace.c
> +  DpProfile.c
> +  DpApp.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  ShellPkg/ShellPkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +
> +[LibraryClasses]
> +  MemoryAllocationLib
> +  BaseLib
> +  BaseMemoryLib
> +  DebugLib
> +  ShellLib
> +  UefiLib
> +  UefiRuntimeServicesTableLib
> +  UefiBootServicesTableLib
> +  UefiApplicationEntryPoint
> +  SortLib
> +  PrintLib
> +  DevicePathLib
> +  PerformanceLib
> +  DxeServicesLib
> +  PeCoffGetEntryPointLib
> +
> +[Guids]
> +  gPerformanceProtocolGuid                                ## CONSUMES ## SystemTable
> +
> +[Protocols]
> +  gEfiLoadedImageProtocolGuid                             ## CONSUMES
> +  gEfiDriverBindingProtocolGuid                           ## SOMETIMES_CONSUMES
> +  gEfiComponentName2ProtocolGuid                          ##
> SOMETIMES_CONSUMES
> +  gEfiLoadedImageDevicePathProtocolGuid                   ##
> SOMETIMES_CONSUMES
> +  gEfiHiiPackageListProtocolGuid                          ## CONSUMES
> +
> +[Pcd]
> +  gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize   ##
> CONSUMES
> diff --git
> a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.
> c
> b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.
> c
> new file mode 100644
> index 0000000000..6f3997fff4
> --- /dev/null
> +++
> b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.
> c
> @@ -0,0 +1,130 @@
> +/** @file
> +  Produce "dp" shell dynamic command.
> +
> +  Copyright (c) 2017, Intel Corporation. All rights reserved. <BR>
> +
> +  This program and the accompanying materials
> +  are licensed and made available under the terms and conditions of the BSD
> License
> +  which accompanies this distribution.  The full text of the license may be
> found at
> +  http://opensource.org/licenses/bsd-license.php
> +
> +  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +
> +**/
> +#include "Dp.h"
> +#include <Protocol/ShellDynamicCommand.h>
> +
> +/**
> +  This is the shell command handler function pointer callback type.  This
> +  function handles the command when it is invoked in the shell.
> +
> +  @param[in] This                   The instance of the
> EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
> +  @param[in] SystemTable            The pointer to the system table.
> +  @param[in] ShellParameters        The parameters associated with the
> command.
> +  @param[in] Shell                  The instance of the shell protocol used in the
> context
> +                                    of processing this command.
> +
> +  @return EFI_SUCCESS               the operation was sucessful
> +  @return other                     the operation failed.
> +**/
> +SHELL_STATUS
> +EFIAPI
> +DpCommandHandler (
> +  IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL    *This,
> +  IN EFI_SYSTEM_TABLE                      *SystemTable,
> +  IN EFI_SHELL_PARAMETERS_PROTOCOL         *ShellParameters,
> +  IN EFI_SHELL_PROTOCOL                    *Shell
> +  )
> +{
> +  gEfiShellParametersProtocol = ShellParameters;
> +  return RunDp (gImageHandle, SystemTable);
> +}
> +
> +/**
> +  This is the command help handler function pointer callback type.  This
> +  function is responsible for displaying help information for the associated
> +  command.
> +
> +  @param[in] This                   The instance of the
> EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL.
> +  @param[in] Language               The pointer to the language string to use.
> +
> +  @return string                    Pool allocated help string, must be freed by caller
> +**/
> +CHAR16 *
> +EFIAPI
> +DpCommandGetHelp (
> +  IN EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL    *This,
> +  IN CONST CHAR8                           *Language
> +  )
> +{
> +  return HiiGetString (mDpHiiHandle, STRING_TOKEN (STR_GET_HELP_DP),
> Language);
> +}
> +
> +EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL mDpDynamicCommand = {
> +  L"dp",
> +  DpCommandHandler,
> +  DpCommandGetHelp
> +};
> +
> +/**
> +  Entry point of Tftp Dynamic Command.
> +
> +  Produce the DynamicCommand protocol to handle "tftp" command.
> +
> +  @param ImageHandle            The image handle of the process.
> +  @param SystemTable            The EFI System Table pointer.
> +
> +  @retval EFI_SUCCESS           Tftp command is executed sucessfully.
> +  @retval EFI_ABORTED           HII package was failed to initialize.
> +  @retval others                Other errors when executing tftp command.
> +**/
> +EFI_STATUS
> +EFIAPI
> +DpCommandInitialize (
> +  IN EFI_HANDLE               ImageHandle,
> +  IN EFI_SYSTEM_TABLE         *SystemTable
> +  )
> +{
> +  EFI_STATUS                  Status;
> +  mDpHiiHandle = InitializeHiiPackage (ImageHandle);
> +  if (mDpHiiHandle == NULL) {
> +    return EFI_ABORTED;
> +  }
> +
> +  Status = gBS->InstallProtocolInterface (
> +                  &ImageHandle,
> +                  &gEfiShellDynamicCommandProtocolGuid,
> +                  EFI_NATIVE_INTERFACE,
> +                  &mDpDynamicCommand
> +                  );
> +  ASSERT_EFI_ERROR (Status);
> +  return Status;
> +}
> +
> +/**
> +  Tftp driver unload handler.
> +
> +  @param ImageHandle            The image handle of the process.
> +
> +  @retval EFI_SUCCESS           The image is unloaded.
> +  @retval Others                Failed to unload the image.
> +**/
> +EFI_STATUS
> +EFIAPI
> +DpUnload (
> +  IN EFI_HANDLE               ImageHandle
> +)
> +{
> +  EFI_STATUS                  Status;
> +  Status = gBS->UninstallProtocolInterface (
> +                  ImageHandle,
> +                  &gEfiShellDynamicCommandProtocolGuid,
> +                  &mDpDynamicCommand
> +                  );
> +  if (EFI_ERROR (Status)) {
> +    return Status;
> +  }
> +  HiiRemovePackages (mDpHiiHandle);
> +  return EFI_SUCCESS;
> +}
> diff --git
> a/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.i
> nf
> b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.i
> nf
> new file mode 100644
> index 0000000000..3164561958
> --- /dev/null
> +++
> b/ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.i
> nf
> @@ -0,0 +1,78 @@
> +##  @file
> +# Provides Shell 'dp' dynamic command.
> +#
> +# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
> +#  This program and the accompanying materials
> +#  are licensed and made available under the terms and conditions of the
> BSD License
> +#  which accompanies this distribution. The full text of the license may be
> found at
> +#  http://opensource.org/licenses/bsd-license.php
> +#  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> +#  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> +#
> +#
> +##
> +
> +[Defines]
> +  INF_VERSION                    = 0x00010006
> +  BASE_NAME                      = dpDynamicCommand
> +  FILE_GUID                      = 0253F9FA-129A-4A8D-B12E-7DC2B6376302
> +  MODULE_TYPE                    = DXE_DRIVER
> +  VERSION_STRING                 = 1.0
> +  ENTRY_POINT                    = DpCommandInitialize
> +  UNLOAD_IMAGE                   = DpUnload
> +#
> +#  This flag specifies whether HII resource section is generated into PE
> image.
> +#
> +  UEFI_HII_RESOURCE_SECTION      = TRUE
> +
> +[Sources.common]
> +  PerformanceTokens.h
> +  Dp.uni
> +  Dp.c
> +  Dp.h
> +  Literals.h
> +  Literals.c
> +  DpInternal.h
> +  DpUtilities.c
> +  DpTrace.c
> +  DpProfile.c
> +  DpDynamicCommand.c
> +
> +[Packages]
> +  MdePkg/MdePkg.dec
> +  ShellPkg/ShellPkg.dec
> +  MdeModulePkg/MdeModulePkg.dec
> +
> +[LibraryClasses]
> +  MemoryAllocationLib
> +  BaseLib
> +  BaseMemoryLib
> +  DebugLib
> +  ShellLib
> +  UefiLib
> +  UefiRuntimeServicesTableLib
> +  UefiBootServicesTableLib
> +  UefiDriverEntryPoint
> +  SortLib
> +  PrintLib
> +  DevicePathLib
> +  PerformanceLib
> +  DxeServicesLib
> +  PeCoffGetEntryPointLib
> +
> +[Guids]
> +  gPerformanceProtocolGuid                                ## CONSUMES ## SystemTable
> +
> +[Protocols]
> +  gEfiLoadedImageProtocolGuid                             ## CONSUMES
> +  gEfiDriverBindingProtocolGuid                           ## SOMETIMES_CONSUMES
> +  gEfiComponentName2ProtocolGuid                          ##
> SOMETIMES_CONSUMES
> +  gEfiLoadedImageDevicePathProtocolGuid                   ##
> SOMETIMES_CONSUMES
> +  gEfiHiiPackageListProtocolGuid                          ## CONSUMES
> +  gEfiShellDynamicCommandProtocolGuid                     ## PRODUCES
> +
> +[Pcd]
> +  gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize   ##
> CONSUMES
> +
> +[DEPEX]
> +  TRUE
> diff --git a/ShellPkg/Library/UefiDpLib/DpInternal.h
> b/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
> similarity index 96%
> rename from ShellPkg/Library/UefiDpLib/DpInternal.h
> rename to ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
> index 6de194aaaa..ece1c23aaf 100644
> --- a/ShellPkg/Library/UefiDpLib/DpInternal.h
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpInternal.h
> @@ -24,7 +24,7 @@
>  //
>  /// Module-Global Variables
>  ///@{
> -extern EFI_HII_HANDLE     gDpHiiHandle;
> +extern EFI_HII_HANDLE     mDpHiiHandle;
>  extern CHAR16             mGaugeString[DP_GAUGE_STRING_LENGTH + 1];
>  extern CHAR16             mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];
>  extern UINT64             mInterestThreshold;
> diff --git a/ShellPkg/Library/UefiDpLib/DpProfile.c
> b/ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c
> similarity index 87%
> rename from ShellPkg/Library/UefiDpLib/DpProfile.c
> rename to ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c
> index e4434034c6..af25217dae 100644
> --- a/ShellPkg/Library/UefiDpLib/DpProfile.c
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpProfile.c
> @@ -28,23 +28,23 @@
>  #include "Literals.h"
>  #include "DpInternal.h"
> 
> -/**
> +/**
>    Gather and print ALL Profiling Records.
> -
> +
>    Displays all "interesting" Profile measurements in order.
>    The number of records displayed is controlled by:
>       - records with a duration less than mInterestThreshold microseconds are
> not displayed.
>       - No more than Limit records are displayed.  A Limit of zero will not limit
> the output.
>       - If the ExcludeFlag is TRUE, records matching entries in the CumData array
> are not
>         displayed.
> -
> +
>    @pre    The mInterestThreshold global variable is set to the shortest
> duration to be printed.
>             The mGaugeString and mUnicodeToken global arrays are used for
> temporary string storage.
>             They must not be in use by a calling function.
> -
> +
>    @param[in]    Limit         The number of records to print.  Zero is ALL.
>    @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items
> from display.
> -
> +
>  **/
>  VOID
>  DumpAllProfile(
> @@ -55,32 +55,32 @@ DumpAllProfile(
>    EFI_STRING    StringPtr;
>    EFI_STRING    StringPtrUnknown;
> 
> -  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> -  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_PROFILE), NULL);
> +  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> +  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_PROFILE), NULL);
> 
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> gDpHiiHandle,
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> mDpHiiHandle,
>                (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
>    FreePool (StringPtr);
>    FreePool (StringPtrUnknown);
>  }
> 
> -/**
> +/**
>    Gather and print Raw Profile Records.
> -
> +
>    All Profile measurements with a duration greater than or equal to
>    mInterestThreshold are printed without interpretation.
> -
> +
>    The number of records displayed is controlled by:
>       - records with a duration less than mInterestThreshold microseconds are
> not displayed.
>       - No more than Limit records are displayed.  A Limit of zero will not limit
> the output.
>       - If the ExcludeFlag is TRUE, records matching entries in the CumData array
> are not
>         displayed.
> -
> +
>    @pre    The mInterestThreshold global variable is set to the shortest
> duration to be printed.
> -
> +
>    @param[in]    Limit         The number of records to print.  Zero is ALL.
>    @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items
> from display.
> -
> +
>  **/
>  VOID
>  DumpRawProfile(
> @@ -91,9 +91,9 @@ DumpRawProfile(
>    EFI_STRING    StringPtr;
>    EFI_STRING    StringPtrUnknown;
> 
> -  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> -  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_RAWPROFILE), NULL);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> gDpHiiHandle,
> +  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> +  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_RAWPROFILE), NULL);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> mDpHiiHandle,
>                (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
>    FreePool (StringPtr);
>    FreePool (StringPtrUnknown);
> diff --git a/ShellPkg/Library/UefiDpLib/DpTrace.c
> b/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
> similarity index 89%
> rename from ShellPkg/Library/UefiDpLib/DpTrace.c
> rename to ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
> index 90a71ad91b..bc882be622 100644
> --- a/ShellPkg/Library/UefiDpLib/DpTrace.c
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpTrace.c
> @@ -29,17 +29,17 @@
>  #include "Literals.h"
>  #include "DpInternal.h"
> 
> -/**
> +/**
>    Collect verbose statistics about the logged performance measurements.
> -
> +
>    General Summary information for all Trace measurements is gathered and
>    stored within the SummaryData structure.  This information is both
>    used internally by subsequent reporting functions, and displayed
>    at the end of verbose reports.
> -
> +
>    @pre  The SummaryData and CumData structures must be initialized
>          prior to calling this function.
> -
> +
>    @post The SummaryData and CumData structures contain statistics for the
>          current performance logs.
> 
> @@ -118,23 +118,23 @@ GatherStatistics(
>    }
>  }
> 
> -/**
> +/**
>    Gather and print ALL Trace Records.
> -
> +
>    Displays all "interesting" Trace measurements in order.<BR>
>    The number of records displayed is controlled by:
>       - records with a duration less than mInterestThreshold microseconds are
> not displayed.
>       - No more than Limit records are displayed.  A Limit of zero will not limit
> the output.
>       - If the ExcludeFlag is TRUE, records matching entries in the CumData array
> are not
>         displayed.
> -
> +
>    @pre    The mInterestThreshold global variable is set to the shortest
> duration to be printed.
>             The mGaugeString and mUnicodeToken global arrays are used for
> temporary string storage.
>             They must not be in use by a calling function.
> -
> +
>    @param[in]    Limit       The number of records to print.  Zero is ALL.
>    @param[in]    ExcludeFlag TRUE to exclude individual Cumulative items from
> display.
> -
> +
>    @retval EFI_SUCCESS           The operation was successful.
>    @retval EFI_ABORTED           The user aborts the operation.
>    @return Others                from a call to gBS->LocateHandleBuffer().
> @@ -159,9 +159,9 @@ DumpAllTrace(
>    EFI_STATUS                Status;
>    EFI_STRING                StringPtrUnknown;
> 
> -  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> -  IncFlag = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_ALL), NULL);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> gDpHiiHandle,
> +  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> +  IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_ALL), NULL);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> mDpHiiHandle,
>                (IncFlag == NULL) ? StringPtrUnknown : IncFlag);
>    FreePool (StringPtrUnknown);
> 
> @@ -169,7 +169,7 @@ DumpAllTrace(
>    //
>    Status  = gBS->LocateHandleBuffer (AllHandles, NULL, NULL,
> &HandleCount, &HandleBuffer);
>    if (EFI_ERROR (Status)) {
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR),
> gDpHiiHandle, Status);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR),
> mDpHiiHandle, Status);
>    }
>    else {
>      // We have successfully populated the HandleBuffer
> @@ -179,11 +179,11 @@ DumpAllTrace(
>      //    Display driver names in Module field for records with Handles.
>      //
>      if (mShowId) {
> -      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR2),
> gDpHiiHandle);
> -      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_DASHES2),
> gDpHiiHandle);
> +      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR2),
> mDpHiiHandle);
> +      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_DASHES2),
> mDpHiiHandle);
>      } else {
> -      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR),
> gDpHiiHandle);
> -      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES),
> gDpHiiHandle);
> +      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_HEADR),
> mDpHiiHandle);
> +      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES),
> mDpHiiHandle);
>      }
> 
>      LogEntryKey = 0;
> @@ -206,10 +206,10 @@ DumpAllTrace(
>        if (Measurement.EndTimeStamp != 0) {
>          Duration = GetDuration (&Measurement);
>          ElapsedTime = DurationInMicroSeconds ( Duration );
> -        IncFlag = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_DP_COMPLETE), NULL);
> +        IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_DP_COMPLETE), NULL);
>        }
>        else {
> -        IncFlag = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_DP_INCOMPLETE), NULL);  // Mark incomplete records
> +        IncFlag = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_DP_INCOMPLETE), NULL);  // Mark incomplete records
>        }
>        if (((Measurement.EndTimeStamp != 0) && (ElapsedTime <
> mInterestThreshold)) ||
>            ((ExcludeFlag) && (GetCumulativeItem(&Measurement) >= 0))
> @@ -240,7 +240,7 @@ DumpAllTrace(
>        mUnicodeToken[13] = 0;
> 
>        if (mShowId) {
> -        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS2),
> gDpHiiHandle,
> +        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS2),
> mDpHiiHandle,
>            Index,      // 1 based, Which measurement record is being printed
>            IncFlag,
>            Measurement.Handle,
> @@ -250,7 +250,7 @@ DumpAllTrace(
>            Measurement.Identifier
>          );
>        } else {
> -        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS),
> gDpHiiHandle,
> +        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_ALL_VARS),
> mDpHiiHandle,
>            Index,      // 1 based, Which measurement record is being printed
>            IncFlag,
>            Measurement.Handle,
> @@ -273,20 +273,20 @@ DumpAllTrace(
>    return Status;
>  }
> 
> -/**
> +/**
>    Gather and print Raw Trace Records.
> -
> +
>    All Trace measurements with a duration greater than or equal to
>    mInterestThreshold are printed without interpretation.
> -
> +
>    The number of records displayed is controlled by:
>       - records with a duration less than mInterestThreshold microseconds are
> not displayed.
>       - No more than Limit records are displayed.  A Limit of zero will not limit
> the output.
>       - If the ExcludeFlag is TRUE, records matching entries in the CumData array
> are not
>         displayed.
> -
> +
>    @pre    The mInterestThreshold global variable is set to the shortest
> duration to be printed.
> -
> +
>    @param[in]    Limit       The number of records to print.  Zero is ALL.
>    @param[in]    ExcludeFlag TRUE to exclude individual Cumulative items from
> display.
> 
> @@ -312,19 +312,19 @@ DumpRawTrace(
> 
>    Status = EFI_SUCCESS;
> 
> -  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> -  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_RAWTRACE), NULL);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> gDpHiiHandle,
> +  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> +  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_RAWTRACE), NULL);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> mDpHiiHandle,
>                (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
>    FreePool (StringPtr);
>    FreePool (StringPtrUnknown);
> 
>    if (mShowId) {
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR2),
> gDpHiiHandle);
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES2),
> gDpHiiHandle);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR2),
> mDpHiiHandle);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES2),
> mDpHiiHandle);
>    } else {
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR),
> gDpHiiHandle);
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES),
> gDpHiiHandle);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_HEADR),
> mDpHiiHandle);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_DASHES),
> mDpHiiHandle);
>    }
> 
>    LogEntryKey = 0;
> @@ -355,7 +355,7 @@ DumpRawTrace(
>      ++Count;    // Count the number of records printed
> 
>      if (mShowId) {
> -      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS2),
> gDpHiiHandle,
> +      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS2),
> mDpHiiHandle,
>          Index,      // 1 based, Which measurement record is being printed
>          Measurement.Handle,
>          Measurement.StartTimeStamp,
> @@ -365,7 +365,7 @@ DumpRawTrace(
>          Measurement.Identifier
>        );
>      } else {
> -      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS),
> gDpHiiHandle,
> +      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_RAW_VARS),
> mDpHiiHandle,
>          Index,      // 1 based, Which measurement record is being printed
>          Measurement.Handle,
>          Measurement.StartTimeStamp,
> @@ -382,9 +382,9 @@ DumpRawTrace(
>    return Status;
>  }
> 
> -/**
> +/**
>    Gather and print Major Phase metrics.
> -
> +
>  **/
>  VOID
>  ProcessPhases(
> @@ -412,9 +412,9 @@ ProcessPhases(
>    //
>    // Get Execution Phase Statistics
>    //
> -  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> -  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_PHASES), NULL);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> gDpHiiHandle,
> +  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> +  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_PHASES), NULL);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> mDpHiiHandle,
>                (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
>    FreePool (StringPtr);
>    FreePool (StringPtrUnknown);
> @@ -456,7 +456,7 @@ ProcessPhases(
>    if (SecTime > 0) {
>      ElapsedTime = DurationInMicroSeconds ( SecTime );     // Calculate elapsed
> time in microseconds
>      Total += DivU64x32 (ElapsedTime, 1000);   // Accumulate time in
> milliseconds
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SEC_PHASE),
> gDpHiiHandle, ElapsedTime);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SEC_PHASE),
> mDpHiiHandle, ElapsedTime);
>    }
> 
>    // print PEI phase duration time
> @@ -467,7 +467,7 @@ ProcessPhases(
>                      (UINT32)TimerInfo.Frequency
>                      );
>      Total += ElapsedTime;
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_PHASE_DURATION), gDpHiiHandle, ALit_PEI, ElapsedTime);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_PEI, ElapsedTime);
>    }
> 
>    // print DXE phase duration time
> @@ -478,7 +478,7 @@ ProcessPhases(
>                      (UINT32)TimerInfo.Frequency
>                      );
>      Total += ElapsedTime;
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_PHASE_DURATION), gDpHiiHandle, ALit_DXE, ElapsedTime);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_DXE, ElapsedTime);
>    }
> 
>    // print BDS phase duration time
> @@ -489,7 +489,7 @@ ProcessPhases(
>                      (UINT32)TimerInfo.Frequency
>                      );
>      Total += ElapsedTime;
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_PHASE_DURATION), gDpHiiHandle, ALit_BDS, ElapsedTime);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_PHASE_DURATION), mDpHiiHandle, ALit_BDS, ElapsedTime);
>    }
> 
>    if (BdsTimeoutValue > 0) {
> @@ -497,17 +497,17 @@ ProcessPhases(
>                      BdsTimeoutValue,
>                      (UINT32)TimerInfo.Frequency
>                      );
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_BDSTO),
> gDpHiiHandle, ALit_BdsTO, ElapsedTime);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_BDSTO),
> mDpHiiHandle, ALit_BdsTO, ElapsedTime);
>    }
> 
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOTAL_DURATION),
> gDpHiiHandle, Total);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOTAL_DURATION),
> mDpHiiHandle, Total);
>  }
> 
> -/**
> +/**
>    Gather and print Handle data.
> -
> +
>    @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items
> from display.
> -
> +
>    @retval EFI_SUCCESS             The operation was successful.
>    @retval EFI_ABORTED             The user aborts the operation.
>    @return Others                  from a call to gBS->LocateHandleBuffer().
> @@ -529,16 +529,16 @@ ProcessHandles(
>    EFI_STATUS                Status;
>    EFI_STRING                StringPtrUnknown;
> 
> -  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> -  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_DRIVERS), NULL);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> gDpHiiHandle,
> +  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> +  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_DRIVERS), NULL);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> mDpHiiHandle,
>                (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
>    FreePool (StringPtr);
>    FreePool (StringPtrUnknown);
> 
>    Status = gBS->LocateHandleBuffer (AllHandles, NULL, NULL, &HandleCount,
> &HandleBuffer);
>    if (EFI_ERROR (Status)) {
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR),
> gDpHiiHandle, Status);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLES_ERROR),
> mDpHiiHandle, Status);
>    }
>    else {
>  #if DP_DEBUG == 2
> @@ -546,11 +546,11 @@ ProcessHandles(
>  #endif
> 
>      if (mShowId) {
> -      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_HANDLE_SECTION2), gDpHiiHandle);
> +      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_HANDLE_SECTION2), mDpHiiHandle);
>      } else {
> -      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_HANDLE_SECTION), gDpHiiHandle);
> +      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_HANDLE_SECTION), mDpHiiHandle);
>      }
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES),
> gDpHiiHandle);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES),
> mDpHiiHandle);
> 
>      LogEntryKey = 0;
>      Count   = 0;
> @@ -588,7 +588,7 @@ ProcessHandles(
>        if (mGaugeString[0] != 0) {
>          // Display the record if it has a valid handle.
>          if (mShowId) {
> -          ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_HANDLE_VARS2), gDpHiiHandle,
> +          ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_HANDLE_VARS2), mDpHiiHandle,
>              Count,      // 1 based, Which measurement record is being printed
>              Index + 1,  // 1 based, Which handle is being printed
>              mGaugeString,
> @@ -597,7 +597,7 @@ ProcessHandles(
>              Measurement.Identifier
>            );
>          } else {
> -          ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS),
> gDpHiiHandle,
> +          ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_HANDLE_VARS),
> mDpHiiHandle,
>              Count,      // 1 based, Which measurement record is being printed
>              Index + 1,  // 1 based, Which handle is being printed
>              mGaugeString,
> @@ -618,11 +618,11 @@ ProcessHandles(
>    return Status;
>  }
> 
> -/**
> +/**
>    Gather and print PEIM data.
> -
> +
>    Only prints complete PEIM records
> -
> +
>    @retval EFI_SUCCESS           The operation was successful.
>    @retval EFI_ABORTED           The user aborts the operation.
>  **/
> @@ -642,19 +642,19 @@ ProcessPeims(
> 
>    Status = EFI_SUCCESS;
> 
> -  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> -  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_PEIMS), NULL);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> gDpHiiHandle,
> +  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> +  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_PEIMS), NULL);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> mDpHiiHandle,
>                (StringPtr == NULL) ? StringPtrUnknown : StringPtr);
>    FreePool (StringPtr);
>    FreePool (StringPtrUnknown);
> 
>    if (mShowId) {
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION2),
> gDpHiiHandle);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION2),
> mDpHiiHandle);
>    } else {
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION),
> gDpHiiHandle);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_SECTION),
> mDpHiiHandle);
>    }
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES),
> gDpHiiHandle);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES),
> mDpHiiHandle);
>    TIndex  = 0;
>    LogEntryKey = 0;
>    while ((LogEntryKey = GetPerformanceMeasurementEx (
> @@ -678,7 +678,7 @@ ProcessPeims(
>      if (ElapsedTime >= mInterestThreshold) {
>        // PEIM FILE Handle is the start address of its FFS file that contains its file
> guid.
>        if (mShowId) {
> -        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS2),
> gDpHiiHandle,
> +        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS2),
> mDpHiiHandle,
>                TIndex,   // 1 based, Which measurement record is being printed
>                Measurement.Handle,  // base address
>                Measurement.Handle,  // file guid
> @@ -686,7 +686,7 @@ ProcessPeims(
>                Measurement.Identifier
>          );
>        } else {
> -        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS),
> gDpHiiHandle,
> +        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PEIM_VARS),
> mDpHiiHandle,
>                TIndex,   // 1 based, Which measurement record is being printed
>                Measurement.Handle,  // base address
>                Measurement.Handle,  // file guid
> @@ -702,14 +702,14 @@ ProcessPeims(
>    return Status;
>  }
> 
> -/**
> +/**
>    Gather and print global data.
> -
> +
>    Strips out incomplete or "Execution Phase" records
>    Only prints records where Handle is NULL
>    Increment TIndex for every record, even skipped ones, so that we have an
>    indication of every measurement record taken.
> -
> +
>    @retval EFI_SUCCESS           The operation was successful.
>    @retval EFI_ABORTED           The user aborts the operation.
>  **/
> @@ -729,19 +729,19 @@ ProcessGlobal(
> 
>    Status = EFI_SUCCESS;
> 
> -  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> -  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_GENERAL), NULL);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> gDpHiiHandle,
> +  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> +  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_GENERAL), NULL);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> mDpHiiHandle,
>                (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
>    FreePool (StringPtr);
>    FreePool (StringPtrUnknown);
> 
>    if (mShowId) {
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_GLOBAL_SECTION2), gDpHiiHandle);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_GLOBAL_SECTION2), mDpHiiHandle);
>    } else {
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION),
> gDpHiiHandle);
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_SECTION),
> mDpHiiHandle);
>    }
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES),
> gDpHiiHandle);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES),
> mDpHiiHandle);
> 
>    Index = 1;
>    LogEntryKey = 0;
> @@ -768,7 +768,7 @@ ProcessGlobal(
>        ElapsedTime = DurationInMicroSeconds ( Duration );
>        if (ElapsedTime >= mInterestThreshold) {
>          if (mShowId) {
> -          ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_GLOBAL_VARS2), gDpHiiHandle,
> +          ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_GLOBAL_VARS2), mDpHiiHandle,
>              Index,
>              mGaugeString,
>              mUnicodeToken,
> @@ -776,7 +776,7 @@ ProcessGlobal(
>              Measurement.Identifier
>              );
>          } else {
> -           ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GLOBAL_VARS),
> gDpHiiHandle,
> +           ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_GLOBAL_VARS), mDpHiiHandle,
>              Index,
>              mGaugeString,
>              mUnicodeToken,
> @@ -794,9 +794,9 @@ ProcessGlobal(
>    return Status;
>  }
> 
> -/**
> +/**
>    Gather and print cumulative data.
> -
> +
>    Traverse the measurement records and:<BR>
>    For each record with a Token listed in the CumData array:<BR>
>       - Update the instance count and the total, minimum, and maximum
> durations.
> @@ -818,16 +818,16 @@ ProcessCumulative(
>    UINTN                     TIndex;
>    EFI_STRING                StringPtrUnknown;
> 
> -  StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> -  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_CUMULATIVE), NULL);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> gDpHiiHandle,
> +  StringPtrUnknown = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_ALIT_UNKNOWN), NULL);
> +  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_DP_SECTION_CUMULATIVE), NULL);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_SECTION_HEADER),
> mDpHiiHandle,
>                (StringPtr == NULL) ? StringPtrUnknown: StringPtr);
>    FreePool (StringPtr);
>    FreePool (StringPtrUnknown);
> 
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_CUMULATIVE_SECT_1), gDpHiiHandle);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_CUMULATIVE_SECT_2), gDpHiiHandle);
> -  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES),
> gDpHiiHandle);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_CUMULATIVE_SECT_1), mDpHiiHandle);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_CUMULATIVE_SECT_2), mDpHiiHandle);
> +  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_DASHES),
> mDpHiiHandle);
> 
>    for ( TIndex = 0; TIndex < NumCum; ++TIndex) {
>      if (CumData[TIndex].Count != 0) {
> @@ -836,8 +836,8 @@ ProcessCumulative(
>        Dur    = DurationInMicroSeconds(CumData[TIndex].Duration);
>        MaxDur = DurationInMicroSeconds(CumData[TIndex].MaxDur);
>        MinDur = DurationInMicroSeconds(CumData[TIndex].MinDur);
> -
> -      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_CUMULATIVE_STATS), gDpHiiHandle,
> +
> +      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_CUMULATIVE_STATS), mDpHiiHandle,
>                    CumData[TIndex].Name,
>                    CumData[TIndex].Count,
>                    Dur,
> @@ -864,7 +864,7 @@ ProcessCumulative(
>        MaxDur = 0;
>        MinDur = 0;
>      }
> -    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_CUMULATIVE_STATS), gDpHiiHandle,
> +    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN
> (STR_DP_CUMULATIVE_STATS), mDpHiiHandle,
>                  CustomCumulativeData->Name,
>                  CustomCumulativeData->Count,
>                  Dur,
> diff --git a/ShellPkg/Library/UefiDpLib/DpUtilities.c
> b/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c
> similarity index 87%
> rename from ShellPkg/Library/UefiDpLib/DpUtilities.c
> rename to ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c
> index c60d27d861..b98ec4b5bd 100644
> --- a/ShellPkg/Library/UefiDpLib/DpUtilities.c
> +++ b/ShellPkg/DynamicCommand/DpDynamicCommand/DpUtilities.c
> @@ -196,18 +196,19 @@ DpGetNameFromHandle (
>    IN EFI_HANDLE   Handle
>    )
>  {
> -  EFI_STATUS                  Status;
> -  EFI_LOADED_IMAGE_PROTOCOL   *Image;
> -  CHAR8                       *PdbFileName;
> -  EFI_DRIVER_BINDING_PROTOCOL *DriverBinding;
> -  EFI_STRING                  StringPtr;
> -  EFI_DEVICE_PATH_PROTOCOL    *LoadedImageDevicePath;
> -  EFI_DEVICE_PATH_PROTOCOL    *DevicePath;
> -  EFI_GUID                    *NameGuid;
> -  CHAR16                      *NameString;
> -  UINTN                       StringSize;
> -  CHAR8                       *PlatformLanguage;
> -  EFI_COMPONENT_NAME2_PROTOCOL      *ComponentName2;
> +  EFI_STATUS                   Status;
> +  EFI_LOADED_IMAGE_PROTOCOL    *Image;
> +  CHAR8                        *PdbFileName;
> +  EFI_DRIVER_BINDING_PROTOCOL  *DriverBinding;
> +  EFI_STRING                   StringPtr;
> +  EFI_DEVICE_PATH_PROTOCOL     *LoadedImageDevicePath;
> +  EFI_DEVICE_PATH_PROTOCOL     *DevicePath;
> +  EFI_GUID                     *NameGuid;
> +  CHAR16                       *NameString;
> +  UINTN                        StringSize;
> +  CHAR8                        *PlatformLanguage;
> +  CHAR8                        *BestLanguage;
> +  EFI_COMPONENT_NAME2_PROTOCOL *ComponentName2;
> 
>    Image = NULL;
>    LoadedImageDevicePath = NULL;
> @@ -259,16 +260,25 @@ DpGetNameFromHandle (
>                    );
>    if (!EFI_ERROR (Status)) {
>      //
> -    // Get the current platform language setting
> +    // Firstly use platform language setting, secondly use driver's first
> supported language.
>      //
> -    PlatformLanguage = GetBestLanguageForDriver(ComponentName2-
> >SupportedLanguages, NULL, FALSE);
> +    GetVariable2 (L"PlatformLang", &gEfiGlobalVariableGuid,
> (VOID**)&PlatformLanguage, NULL);
> +    BestLanguage = GetBestLanguage(
> +                     ComponentName2->SupportedLanguages,
> +                     FALSE,
> +                     (PlatformLanguage != NULL) ? PlatformLanguage : "",
> +                     ComponentName2->SupportedLanguages,
> +                     NULL
> +                     );
> +    SHELL_FREE_NON_NULL (PlatformLanguage);
> +
>      Status = ComponentName2->GetDriverName (
>                                 ComponentName2,
> -                               PlatformLanguage != NULL ? PlatformLanguage : "en-US",
> +                               BestLanguage != NULL ? BestLanguage : "en-US",
>                                 &StringPtr
>                                 );
>      if (!EFI_ERROR (Status)) {
> -      SHELL_FREE_NON_NULL (PlatformLanguage);
> +      SHELL_FREE_NON_NULL (BestLanguage);
>        StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr,
> DP_GAUGE_STRING_LENGTH);
>        mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;
>        return;
> @@ -344,7 +354,7 @@ DpGetNameFromHandle (
>    //
>    // Method 6: Unknown Driver Name
>    //
> -  StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN
> (STR_DP_ERROR_NAME), NULL);
> +  StringPtr = HiiGetString (mDpHiiHandle, STRING_TOKEN
> (STR_DP_ERROR_NAME), NULL);
>    ASSERT (StringPtr != NULL);
>    StrnCpyS (mGaugeString, DP_GAUGE_STRING_LENGTH + 1, StringPtr,
> DP_GAUGE_STRING_LENGTH);
>    FreePool (StringPtr);
> diff --git a/ShellPkg/Library/UefiDpLib/Literals.c
> b/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.c
> similarity index 100%
> rename from ShellPkg/Library/UefiDpLib/Literals.c
> rename to ShellPkg/DynamicCommand/DpDynamicCommand/Literals.c
> diff --git a/ShellPkg/Library/UefiDpLib/Literals.h
> b/ShellPkg/DynamicCommand/DpDynamicCommand/Literals.h
> similarity index 100%
> rename from ShellPkg/Library/UefiDpLib/Literals.h
> rename to ShellPkg/DynamicCommand/DpDynamicCommand/Literals.h
> diff --git a/ShellPkg/Library/UefiDpLib/PerformanceTokens.h
> b/ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h
> similarity index 100%
> rename from ShellPkg/Library/UefiDpLib/PerformanceTokens.h
> rename to
> ShellPkg/DynamicCommand/DpDynamicCommand/PerformanceTokens.h
> diff --git a/ShellPkg/Library/UefiDpLib/Readme.txt
> b/ShellPkg/Library/UefiDpLib/Readme.txt
> deleted file mode 100644
> index 849efa4360..0000000000
> --- a/ShellPkg/Library/UefiDpLib/Readme.txt
> +++ /dev/null
> @@ -1,2 +0,0 @@
> -from PerformancePkg\Dp_App
> -SVN 13406
> diff --git a/ShellPkg/Library/UefiDpLib/UefiDpLib.c
> b/ShellPkg/Library/UefiDpLib/UefiDpLib.c
> deleted file mode 100644
> index f3ecfeac7f..0000000000
> --- a/ShellPkg/Library/UefiDpLib/UefiDpLib.c
> +++ /dev/null
> @@ -1,101 +0,0 @@
> -/** @file
> -  Main file for NULL named library for install1 shell command functions.
> -
> -  Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.
> -  This program and the accompanying materials
> -  are licensed and made available under the terms and conditions of the BSD
> License
> -  which accompanies this distribution.  The full text of the license may be
> found at
> -  http://opensource.org/licenses/bsd-license.php
> -
> -  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> -  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> -
> -**/
> -
> -#include "UefiDpLib.h"
> -
> -STATIC CONST CHAR16 mFileName[] = L"ShellCommands";
> -EFI_HANDLE gDpHiiHandle = NULL;
> -
> -#define DP_HII_GUID \
> -  { \
> -  0xeb832fd9, 0x9089, 0x4898, { 0x83, 0xc9, 0x41, 0x61, 0x8f, 0x5c, 0x48, 0xb9
> } \
> -  }
> -
> -EFI_GUID gDpHiiGuid = DP_HII_GUID;
> -
> -/**
> -  Function to get the filename with help context if HII will not be used.
> -
> -  @return   The filename with help text in it.
> -**/
> -CONST CHAR16*
> -EFIAPI
> -UefiDpLibGetManFileName (
> -  VOID
> -  )
> -{
> -  return (mFileName);
> -}
> -
> -/**
> -  Constructor for the Shell Level 1 Commands library.
> -
> -  Install the handlers for level 1 UEFI Shell 2.0 commands.
> -
> -  @param ImageHandle    the image handle of the process
> -  @param SystemTable    the EFI System Table pointer
> -
> -  @retval EFI_SUCCESS        the shell command handlers were installed
> sucessfully
> -  @retval EFI_UNSUPPORTED    the shell level required was not found.
> -**/
> -EFI_STATUS
> -EFIAPI
> -UefiDpLibConstructor (
> -  IN EFI_HANDLE        ImageHandle,
> -  IN EFI_SYSTEM_TABLE  *SystemTable
> -  )
> -{
> -  //
> -  // check our bit of the profiles mask
> -  //
> -  if ((PcdGet8(PcdShellProfileMask) & BIT2) == 0) {
> -    return (EFI_SUCCESS);
> -  }
> -
> -  //
> -  // 3rd parameter 'HII strings array' must be name of .uni strings file
> followed by 'Strings', e.g. mycommands.uni must be
> -  // specified as 'mycommandsStrings' because the build Autogen process
> defines this as a string array for the strings in your
> -  // .uni file.  Examine your Build folder under your package's DEBUG folder
> and you will find it defined in a xxxStrDefs.h file.
> -  //
> -  gDpHiiHandle = HiiAddPackages (&gDpHiiGuid, gImageHandle,
> UefiDpLibStrings, NULL);
> -  if (gDpHiiHandle == NULL) {
> -    return (EFI_DEVICE_ERROR);
> -  }
> -
> -  //
> -  // install our shell command handlers that are always installed
> -  //
> -  ShellCommandRegisterCommandName(L"dp", ShellCommandRunDp ,
> UefiDpLibGetManFileName, 0, L"", FALSE, gDpHiiHandle,
> STRING_TOKEN(STR_GET_HELP_DP));
> -
> -  return (EFI_SUCCESS);
> -}
> -
> -/**
> -  Destructor for the library.  free any resources.
> -
> -  @param ImageHandle            The image handle of the process.
> -  @param SystemTable            The EFI System Table pointer.
> -**/
> -EFI_STATUS
> -EFIAPI
> -UefiDpLibDestructor (
> -  IN EFI_HANDLE        ImageHandle,
> -  IN EFI_SYSTEM_TABLE  *SystemTable
> -  )
> -{
> -  if (gDpHiiHandle != NULL) {
> -    HiiRemovePackages(gDpHiiHandle);
> -  }
> -  return (EFI_SUCCESS);
> -}
> diff --git a/ShellPkg/Library/UefiDpLib/UefiDpLib.h
> b/ShellPkg/Library/UefiDpLib/UefiDpLib.h
> deleted file mode 100644
> index 283f8337ff..0000000000
> --- a/ShellPkg/Library/UefiDpLib/UefiDpLib.h
> +++ /dev/null
> @@ -1,64 +0,0 @@
> -/** @file
> -  Main file for NULL named library for dp command functions.
> -
> -  Copyright (c) 2010 - 2016, Intel Corporation. All rights reserved.<BR>
> -  (C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
> -  This program and the accompanying materials
> -  are licensed and made available under the terms and conditions of the BSD
> License
> -  which accompanies this distribution.  The full text of the license may be
> found at
> -  http://opensource.org/licenses/bsd-license.php
> -
> -  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> -  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> -
> -**/
> -
> -#ifndef _UEFI_DP_LIB_H_
> -#define _UEFI_DP_LIB_H_
> -
> -#include <Uefi.h>
> -
> -extern EFI_GUID gDpHiiGuid;
> -
> -#include <Protocol/Shell.h>
> -#include <Protocol/ShellParameters.h>
> -#include <Protocol/DevicePath.h>
> -#include <Protocol/LoadedImage.h>
> -#include <Protocol/UnicodeCollation.h>
> -
> -#include <Library/BaseLib.h>
> -#include <Library/BaseMemoryLib.h>
> -#include <Library/DebugLib.h>
> -#include <Library/MemoryAllocationLib.h>
> -#include <Library/PcdLib.h>
> -#include <Library/ShellCommandLib.h>
> -#include <Library/ShellLib.h>
> -#include <Library/SortLib.h>
> -#include <Library/UefiLib.h>
> -#include <Library/UefiRuntimeServicesTableLib.h>
> -#include <Library/UefiBootServicesTableLib.h>
> -#include <Library/HiiLib.h>
> -#include <Library/FileHandleLib.h>
> -
> -extern        EFI_HANDLE                        gDpHiiHandle;
> -
> -/**
> -  Function for 'dp' command.
> -
> -  @param[in] ImageHandle  Handle to the Image (NULL if Internal).
> -  @param[in] SystemTable  Pointer to the System Table (NULL if Internal).
> -
> -  @retval SHELL_SUCCESS            Command completed successfully.
> -  @retval SHELL_INVALID_PARAMETER  Command usage error.
> -  @retval SHELL_ABORTED            The user aborts the operation.
> -  @retval value                    Unknown error.
> -**/
> -SHELL_STATUS
> -EFIAPI
> -ShellCommandRunDp (
> -  IN EFI_HANDLE        ImageHandle,
> -  IN EFI_SYSTEM_TABLE  *SystemTable
> -  );
> -
> -#endif
> -
> diff --git a/ShellPkg/Library/UefiDpLib/UefiDpLib.inf
> b/ShellPkg/Library/UefiDpLib/UefiDpLib.inf
> deleted file mode 100644
> index 0bce0ce6c9..0000000000
> --- a/ShellPkg/Library/UefiDpLib/UefiDpLib.inf
> +++ /dev/null
> @@ -1,77 +0,0 @@
> -##  @file
> -#  Display Performance Application, Module information file.
> -#
> -# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.
> -# This program and the accompanying materials
> -# are licensed and made available under the terms and conditions of the
> BSD License
> -# which accompanies this distribution.  The full text of the license may be
> found at
> -# http://opensource.org/licenses/bsd-license.php
> -#
> -# THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS"
> BASIS,
> -# WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER
> EXPRESS OR IMPLIED.
> -#
> -##
> -
> -[Defines]
> -  INF_VERSION                    = 0x00010006
> -  BASE_NAME                      = UefiDpLib
> -  FILE_GUID                      = 9DF262F7-CF81-4294-B5A5-B2E3CAFE5618
> -  MODULE_TYPE                    = UEFI_DRIVER
> -  VERSION_STRING                 = 1.0
> -  LIBRARY_CLASS                  = NULL|UEFI_APPLICATION UEFI_DRIVER
> -  CONSTRUCTOR                    = UefiDpLibConstructor
> -  DESTRUCTOR                     = UefiDpLibDestructor
> -
> -#
> -# The following information is for reference only and not required by the
> build tools.
> -#
> -#  VALID_ARCHITECTURES           = IA32 X64 IPF EBC
> -#
> -
> -[Sources.common]
> -  PerformanceTokens.h
> -  UefiDpLib.c
> -  UefiDpLib.h
> -  UefiDpLib.uni
> -  Dp.c
> -  Dp.h
> -  Literals.h
> -  Literals.c
> -  DpInternal.h
> -  DpUtilities.c
> -  DpTrace.c
> -  DpProfile.c
> -
> -[Packages]
> -  MdePkg/MdePkg.dec
> -  ShellPkg/ShellPkg.dec
> -  MdeModulePkg/MdeModulePkg.dec
> -
> -[LibraryClasses]
> -  PerformanceLib
> -  DxeServicesLib
> -  MemoryAllocationLib
> -  BaseLib
> -  BaseMemoryLib
> -  DebugLib
> -  ShellCommandLib
> -  ShellLib
> -  UefiLib
> -  UefiRuntimeServicesTableLib
> -  UefiBootServicesTableLib
> -  SortLib
> -  PrintLib
> -  DevicePathLib
> -
> -[Guids]
> -  gPerformanceProtocolGuid                                ## CONSUMES ## SystemTable
> -
> -[Protocols]
> -  gEfiLoadedImageProtocolGuid                             ## CONSUMES
> -  gEfiDriverBindingProtocolGuid                           ## SOMETIMES_CONSUMES
> -  gEfiComponentName2ProtocolGuid                          ##
> SOMETIMES_CONSUMES
> -  gEfiLoadedImageDevicePathProtocolGuid                   ##
> SOMETIMES_CONSUMES
> -
> -[Pcd]
> -  gEfiMdePkgTokenSpaceGuid.PcdUefiLibMaxPrintBufferSize   ##
> UNDEFINED
> -  gEfiShellPkgTokenSpaceGuid.PcdShellProfileMask          ## CONSUMES
> diff --git a/ShellPkg/ShellPkg.dsc b/ShellPkg/ShellPkg.dsc
> index 8fc20709f4..65e8959455 100644
> --- a/ShellPkg/ShellPkg.dsc
> +++ b/ShellPkg/ShellPkg.dsc
> @@ -104,12 +104,6 @@ [Components]
> 
> ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1Comm
> andsLib.inf
> 
> ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2Comm
> andsLib.inf
> 
> -  ShellPkg/Library/UefiDpLib/UefiDpLib.inf {
> -    <LibraryClasses>
> -
> PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmm
> PerformanceLib.inf
> -      DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf
> -  }
> -
>    ShellPkg/Application/Shell/Shell.inf {
>      <PcdsFixedAtBuild>
>        gEfiShellPkgTokenSpaceGuid.PcdShellLibAutoInitialize|FALSE
> @@ -123,14 +117,19 @@ [Components]
> 
> NULL|ShellPkg/Library/UefiShellDebug1CommandsLib/UefiShellDebug1Com
> mandsLib.inf
> 
> NULL|ShellPkg/Library/UefiShellNetwork1CommandsLib/UefiShellNetwork1
> CommandsLib.inf
> 
> NULL|ShellPkg/Library/UefiShellNetwork2CommandsLib/UefiShellNetwork2
> CommandsLib.inf
> -!ifdef $(INCLUDE_DP)
> -      NULL|ShellPkg/Library/UefiDpLib/UefiDpLib.inf
> -!endif #$(INCLUDE_DP)
>  !endif #$(NO_SHELL_PROFILES)
>    }
> 
> 
> ShellPkg/DynamicCommand/TftpDynamicCommand/TftpDynamicCommand.
> inf
>    ShellPkg/DynamicCommand/TftpDynamicCommand/TftpApp.inf
> +
> ShellPkg/DynamicCommand/DpDynamicCommand/DpDynamicCommand.inf
> {
> +    <LibraryClasses>
> +
> PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmm
> PerformanceLib.inf
> +  }
> +  ShellPkg/DynamicCommand/DpDynamicCommand/DpApp.inf {
> +    <LibraryClasses>
> +
> PerformanceLib|MdeModulePkg/Library/DxeSmmPerformanceLib/DxeSmm
> PerformanceLib.inf
> +  }
> 
>  [BuildOptions]
>    *_*_*_CC_FLAGS = -D DISABLE_NEW_DEPRECATED_INTERFACES
> --
> 2.15.0.gvfs.1.preview.4

_______________________________________________
edk2-devel mailing list
edk2-devel@lists.01.org
https://lists.01.org/mailman/listinfo/edk2-devel