]> git.proxmox.com Git - mirror_edk2.git/commitdiff
PerformancePkg: Make Dp print help information with -? flag in Shell.
authorQiu Shumin <shumin.qiu@intel.com>
Tue, 12 Apr 2016 07:06:07 +0000 (15:06 +0800)
committerQiu Shumin <shumin.qiu@intel.com>
Fri, 15 Apr 2016 03:24:25 +0000 (11:24 +0800)
Since Shell supports finding help information from resource section
of application image. We enhance the Dp to add help information
string. After the Dp are loaded in system the help string will
be stored in resource section of the application image.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Qiu Shumin <shumin.qiu@intel.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
PerformancePkg/Dp_App/Dp.c
PerformancePkg/Dp_App/Dp.inf
PerformancePkg/Dp_App/DpStrings.uni

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
-  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
 **/\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/UefiHiiServicesLib.h>\r
 #include <Library/HiiLib.h>\r
 #include <Library/PcdLib.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
@@ -217,17 +229,18 @@ InitializeDp (
   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
@@ -277,10 +290,35 @@ InitializeDp (
   //\r
   Ticker  = GetPerformanceCounter ();\r
 \r
-  // Register our string package with HII and return the handle to it.\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
+  \r
 \r
   // Initial the command list\r
   //\r
index 1c62fb1dd6d2f171495bf3eb0fb41fd40bfd1a76..8abc20f1683087478369683a31503405c861e624 100644 (file)
@@ -1,7 +1,7 @@
 ##  @file\r
 #  Display Performance Application, Module information file.\r
 #\r
-# Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
   MODULE_TYPE                    = UEFI_APPLICATION\r
   VERSION_STRING                 = 1.0\r
   ENTRY_POINT                    = InitializeDp\r
+  \r
+#\r
+#  This flag specifies whether HII resource section is generated into PE image.\r
+#\r
+  UEFI_HII_RESOURCE_SECTION      = TRUE\r
 \r
 #\r
 # The following information is for reference only and not required by the build tools.\r
   PrintLib\r
   UefiLib\r
   HiiLib\r
+  UefiHiiServicesLib\r
   PcdLib\r
   DevicePathLib\r
   DxeServicesLib\r
 \r
 [Protocols]\r
   gEfiLoadedImageProtocolGuid                             ## CONSUMES\r
+  gEfiHiiPackageListProtocolGuid                          ## CONSUMES\r
   gEfiDriverBindingProtocolGuid                           ## SOMETIMES_CONSUMES\r
   gEfiComponentName2ProtocolGuid                          ## SOMETIMES_CONSUMES\r
   gEfiLoadedImageDevicePathProtocolGuid                   ## SOMETIMES_CONSUMES\r
index f368f3463f785b2128ee2fcd09fd37e66759fdc2..daaa242e3d3b425ffc09100718ae209c8d8a904a 100644 (file)
@@ -1,6 +1,6 @@
 // *++\r
 //\r
-// Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+// Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.<BR>\r
 // (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 // This program and the accompanying materials\r
 // are licensed and made available under the terms and conditions of the BSD License\r
 #langdef   en-US "English"\r
 #langdef   fr-FR "Français"\r
 \r
+#string STR_DP_HELP_INFORMATION        #language en-US  ""\r
+                                                        ".TH DP 0 "Display Performance metrics."\r\n"\r
+                                                        ".SH NAME\r\n"\r
+                                                        "Display Performance metrics.\r\n"\r
+                                                        ".SH SYNOPSIS\r\n"\r
+                                                        " \r\n"\r
+                                                        "If Profiling is implemented:\r\n"\r
+                                                        "dp [-b] [-v] [-x] [-s | -A | -R] [-T] [-P] [-t value] [-n count] [-c [token]] [-i] [-?]\r\n"\r
+                                                        "If Profiling is not implemented:\r\n"\r
+                                                        "dp [-b] [-v] [-x] [-s | -A | -R] [-t value] [-n count] [-c [token]] [-i] [-?]\r\n"\r
+                                                        ".SH OPTIONS\r\n"\r
+                                                        " \r\n"\r
+                                                        "   -b  display on multiple pages\n\r\n"\r
+                                                        "   -v  display additional information\r\n"\r
+                                                        "   -x  prevent display of individual measurements for cumulative items\r\n"\r
+                                                        "   -s  display summary information only\r\n"\r
+                                                        "   -A  display all measurements in a list\r\n"\r
+                                                        "   -R  display all measurements in raw format\r\n"\r
+                                                        "   -T  display Trace measurements only(This option is available when Profiling is implemented)\r\n"\r
+                                                        "   -P  display Profile measurements only(This option is available when Profiling is implemented)\r\n"\r
+                                                        "   -t VALUE  Set display threshold to VALUE microseconds\r\n"\r
+                                                        "   -n COUNT  Limit display to COUNT lines in All and Raw modes\r\n"\r
+                                                        "   -i  display identifier\r\n"\r
+                                                        "   -c TOKEN - Display pre-defined and custom cumulative data\r\n"\r
+                                                        "              Pre-defined cumulative token are:\r\n"\r
+                                                        "              1. LoadImage:\r\n"\r
+                                                        "              2. StartImage:\r\n"\r
+                                                        "              3. DB:Start:\r\n"\r
+                                                        "              4. DB:Support:\r\n"\r
+                                                        "   -?  display dp help information\r\n"\r
+                                                        "\r\n"\r
+                                       #language fr-FR  ""\r
+                                                        ".TH DP 0 "Montrer les données d'exécution"\r\n"\r
+                                                        ".SH NAME\r\n"\r
+                                                        "Montrer les données d'exécution\r\n"\r
+                                                        ".SH SYNOPSIS\r\n"\r
+                                                        " \r\n"\r
+                                                        "If Profiling is implemented:\r\n"\r
+                                                        "dp [-b] [-v] [-x] [-s | -A | -R] [-T] [-P] [-t value] [-n count] [-c [token]] [-i] [-?]\r\n"\r
+                                                        "If Profiling is not implemented:\r\n"\r
+                                                        "dp [-b] [-v] [-x] [-s | -A | -R] [-t value] [-n count] [-c [token]] [-i] [-?]\r\n"\r
+                                                        ".SH OPTIONS\r\n"\r
+                                                        " \r\n"\r
+                                                        "   -b  montrer sur les pages multiples\r\n"\r
+                                                        "   -v  display additional information\r\n"\r
+                                                        "   -x  prevent display of individual measurements for cumulative items\r\n"\r
+                                                        "   -s  montrer les données de statistique seulement\r\n"\r
+                                                        "   -A\r\n"\r
+                                                        "   -R\r\n"\r
+                                                        "   -T\r\n"\r
+                                                        "   -P\r\n"\r
+                                                        "   -t VALUE\r\n"\r
+                                                        "   -n COUNT\r\n"\r
+                                                        "   -i\r\n"\r
+                                                        "   -c\r\n"\r
+                                                        "   -?  montrer dp aider l'information\r\n"\r
+                                                        "\r\n"\r
+\r
 #string STR_DP_HELP_HEAD               #language en-US  "\nDisplay Performance metrics\n"\r
                                        #language fr-FR  "\nMontrer les données d'exécution\n"\r
-#string STR_DP_HELP_FLAGS              #language en-US  "dp [-b] [-v] [-x] [-s | -A | -R] [-T] [-P] [-t value] [-n count] [-c [token]] [-i] [-h | -?]\n"\r
-                                       #language fr-FR  "dp [-b] [-v] [-x] [-s | -A | -R] [-T] [-P] [-t value] [-n count] [-c [token]] [-i] [-h | -?]\n"\r
-#string STR_DP_HELP_FLAGS_2            #language en-US  "dp [-b] [-v] [-x] [-s | -A | -R] [-t value] [-n count] [-c [token]] [-i] [-h | -?]\n"\r
-                                       #language fr-FR  "dp [-b] [-v] [-x] [-s | -A | -R] [-t value] [-n count] [-c [token]] [-i] [-h | -?]\n"\r
+#string STR_DP_HELP_FLAGS              #language en-US  "dp [-b] [-v] [-x] [-s | -A | -R] [-T] [-P] [-t value] [-n count] [-c [token]] [-i] [-?]\n"\r
+                                       #language fr-FR  "dp [-b] [-v] [-x] [-s | -A | -R] [-T] [-P] [-t value] [-n count] [-c [token]] [-i] [-?]\n"\r
+#string STR_DP_HELP_FLAGS_2            #language en-US  "dp [-b] [-v] [-x] [-s | -A | -R] [-t value] [-n count] [-c [token]] [-i] [-?]\n"\r
+                                       #language fr-FR  "dp [-b] [-v] [-x] [-s | -A | -R] [-t value] [-n count] [-c [token]] [-i] [-?]\n"\r
 #string STR_DP_HELP_PAGINATE           #language en-US  "   -b  display on multiple pages\n"\r
                                        #language fr-FR  "   -b  montrer sur les pages multiples\n"\r
 #string STR_DP_HELP_VERBOSE            #language en-US  "   -v  display additional information\n"\r