]> git.proxmox.com Git - mirror_edk2.git/blobdiff - PerformancePkg/Dp_App/Dp.c
PerformancePkg: Make Dp print help information with -? flag in Shell.
[mirror_edk2.git] / PerformancePkg / Dp_App / Dp.c
index b24a0de72d74c952b285f3f9150273535de87301..283b61ccd4e07c52f44275bfc1c06234849af1ab 100644 (file)
@@ -13,7 +13,7 @@
   Dp uses this information to group records in different ways.  It also uses\r
   timer information to calculate elapsed time for each measurement.\r
  \r
   Dp uses this information to group records in different ways.  It also uses\r
   timer information to calculate elapsed time for each measurement.\r
  \r
-  Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
 **/\r
 \r
 #include <Library/UefiApplicationEntryPoint.h>\r
 **/\r
 \r
 #include <Library/UefiApplicationEntryPoint.h>\r
+#include <Library/UefiBootServicesTableLib.h>\r
 #include <Library/ShellLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/TimerLib.h>\r
 #include <Library/UefiLib.h>\r
 #include <Library/ShellLib.h>\r
 #include <Library/BaseLib.h>\r
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/TimerLib.h>\r
 #include <Library/UefiLib.h>\r
+#include <Library/UefiHiiServicesLib.h>\r
 #include <Library/HiiLib.h>\r
 #include <Library/PcdLib.h>\r
 \r
 #include <Library/HiiLib.h>\r
 #include <Library/PcdLib.h>\r
 \r
 #include "Literals.h"\r
 #include "DpInternal.h"\r
 \r
 #include "Literals.h"\r
 #include "DpInternal.h"\r
 \r
+//\r
+// String token ID of help message text.\r
+// Shell supports to find help message in the resource section of an application image if\r
+// .MAN file is not found. This global variable is added to make build tool recognizes\r
+// that the help string is consumed by user and then build tool will add the string into\r
+// the resource section. Thus the application can use '-?' option to show help message in\r
+// Shell.\r
+//\r
+GLOBAL_REMOVE_IF_UNREFERENCED EFI_STRING_ID mDpStrEngHelpTokenId = STRING_TOKEN (STR_DP_HELP_INFORMATION);\r
+\r
 //\r
 /// Module-Global Variables\r
 ///@{\r
 //\r
 /// Module-Global Variables\r
 ///@{\r
@@ -217,17 +229,18 @@ InitializeDp (
   EFI_STRING                StringPtr;\r
   UINTN                     Number2Display;\r
 \r
   EFI_STRING                StringPtr;\r
   UINTN                     Number2Display;\r
 \r
-  EFI_STATUS                Status;\r
-  BOOLEAN                   SummaryMode;\r
-  BOOLEAN                   VerboseMode;\r
-  BOOLEAN                   AllMode;\r
-  BOOLEAN                   RawMode;\r
-  BOOLEAN                   TraceMode;\r
-  BOOLEAN                   ProfileMode;\r
-  BOOLEAN                   ExcludeMode;\r
-  BOOLEAN                   CumulativeMode;\r
-  CONST CHAR16              *CustomCumulativeToken;\r
-  PERF_CUM_DATA             *CustomCumulativeData;\r
+  EFI_STATUS                    Status;\r
+  BOOLEAN                       SummaryMode;\r
+  BOOLEAN                       VerboseMode;\r
+  BOOLEAN                       AllMode;\r
+  BOOLEAN                       RawMode;\r
+  BOOLEAN                       TraceMode;\r
+  BOOLEAN                       ProfileMode;\r
+  BOOLEAN                       ExcludeMode;\r
+  BOOLEAN                       CumulativeMode;\r
+  CONST CHAR16                  *CustomCumulativeToken;\r
+  PERF_CUM_DATA                 *CustomCumulativeData;\r
+  EFI_HII_PACKAGE_LIST_HEADER   *PackageList;\r
 \r
   EFI_STRING                StringDpOptionQh;\r
   EFI_STRING                StringDpOptionLh;\r
 \r
   EFI_STRING                StringDpOptionQh;\r
   EFI_STRING                StringDpOptionLh;\r
@@ -277,10 +290,35 @@ InitializeDp (
   //\r
   Ticker  = GetPerformanceCounter ();\r
 \r
   //\r
   Ticker  = GetPerformanceCounter ();\r
 \r
-  // Register our string package with HII and return the handle to it.\r
   //\r
   //\r
-  gHiiHandle = HiiAddPackages (&gEfiCallerIdGuid, ImageHandle, DPStrings, NULL);\r
+  // Retrieve HII package list from ImageHandle\r
+  //\r
+  Status = gBS->OpenProtocol (\r
+                  ImageHandle,\r
+                  &gEfiHiiPackageListProtocolGuid,\r
+                  (VOID **) &PackageList,\r
+                  ImageHandle,\r
+                  NULL,\r
+                  EFI_OPEN_PROTOCOL_GET_PROTOCOL\r
+                  );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
+\r
+  //\r
+  // Publish HII package list to HII Database.\r
+  //\r
+  Status = gHiiDatabase->NewPackageList (\r
+                          gHiiDatabase,\r
+                          PackageList,\r
+                          NULL,\r
+                          &gHiiHandle\r
+                          );\r
+  if (EFI_ERROR (Status)) {\r
+    return Status;\r
+  }\r
   ASSERT (gHiiHandle != NULL);\r
   ASSERT (gHiiHandle != NULL);\r
+  \r
 \r
   // Initial the command list\r
   //\r
 \r
   // Initial the command list\r
   //\r