]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg UefiDpLib: Remove TimerLib dependency
authorStar Zeng <star.zeng@intel.com>
Wed, 8 Jun 2016 07:23:24 +0000 (00:23 -0700)
committerMichael Kinney <michael.d.kinney@intel.com>
Thu, 23 Feb 2017 17:01:30 +0000 (09:01 -0800)
Current UefiDpLib implementation depends on TimerLib,
as different platforms may implement and use their
own TimerLib, it makes the dp command needs to be built
by platform. The TimerLib dependency can be removed by
using performance property configuration table to make
UefiDpLib to be generic.

Cc: Andrew Fish <afish@apple.com>
Cc: Michael Kinney <michael.d.kinney@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Cinnamon Shia <cinnamon.shia@hpe.com>
Cc: Jaben Carsey <jaben.carsey@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Andrew Fish <afish@apple.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
Reviewed-by: Jiewen Yao <jiewen.yao@intel.com>
ShellPkg/Library/UefiDpLib/Dp.c
ShellPkg/Library/UefiDpLib/DpInternal.h
ShellPkg/Library/UefiDpLib/DpProfile.c
ShellPkg/Library/UefiDpLib/DpTrace.c
ShellPkg/Library/UefiDpLib/DpUtilities.c
ShellPkg/Library/UefiDpLib/Literals.c
ShellPkg/Library/UefiDpLib/UefiDpLib.inf
ShellPkg/Library/UefiDpLib/UefiDpLib.uni
ShellPkg/ShellPkg.dsc

index 75c7d11dc3df5e427e6b4e8ac98f3d77649ecde2..444c136ab1889ab9a0454ab29f3f171c5458dc63 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 - 2016, Intel Corporation. All rights reserved.\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\r
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
 **/\r
 \r
 #include "UefiDpLib.h"\r
-#include <Guid/GlobalVariable.h>\r
-#include <Library/PrintLib.h>\r
-#include <Library/HandleParsingLib.h>\r
-#include <Library/DevicePathLib.h>\r
-\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
 \r
 #include <Guid/Performance.h>\r
@@ -153,8 +147,7 @@ ShellCommandRunDp (
   CONST CHAR16              *CmdLineArg;\r
   EFI_STATUS                Status;\r
 \r
-  UINT64                    Freq;\r
-  UINT64                    Ticker;\r
+  PERFORMANCE_PROPERTY      *PerformanceProperty;\r
   UINTN                     Number2Display;\r
 \r
   EFI_STRING                StringPtr;\r
@@ -183,11 +176,6 @@ ShellCommandRunDp (
   CustomCumulativeData = NULL;\r
   ShellStatus = SHELL_SUCCESS;\r
 \r
-  // Get DP's entry time as soon as possible.\r
-  // This is used as the Shell-Phase end time.\r
-  //\r
-  Ticker  = GetPerformanceCounter ();\r
-\r
   //\r
   // initialize the shell lib (we must be in non-auto-init...)\r
   //\r
@@ -283,10 +271,15 @@ ShellCommandRunDp (
   //    StartCount = Value loaded into the counter when it starts counting\r
   //      EndCount = Value counter counts to before it needs to be reset\r
   //\r
-  Freq = GetPerformanceCounterProperties (&TimerInfo.StartCount, &TimerInfo.EndCount);\r
+  Status = EfiGetSystemConfigurationTable (&gPerformanceProtocolGuid, &PerformanceProperty);\r
+  if (EFI_ERROR (Status)) {\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_PERF_PROPERTY_NOT_FOUND), gDpHiiHandle);\r
+    goto Done;\r
+  }\r
 \r
-  // Convert the Frequency from Hz to KHz\r
-  TimerInfo.Frequency = (UINT32)DivU64x32 (Freq, 1000);\r
+  TimerInfo.Frequency  = (UINT32)DivU64x32 (PerformanceProperty->Frequency, 1000);\r
+  TimerInfo.StartCount = PerformanceProperty->TimerStartValue;\r
+  TimerInfo.EndCount   = PerformanceProperty->TimerEndValue;\r
 \r
   // Determine in which direction the performance counter counts.\r
   TimerInfo.CountUp = (BOOLEAN) (TimerInfo.EndCount >= TimerInfo.StartCount);\r
@@ -362,7 +355,7 @@ ShellCommandRunDp (
   } else {\r
     //------------- Begin Cooked Mode Processing\r
     if (TraceMode) {\r
-      ProcessPhases ( Ticker );\r
+      ProcessPhases ();\r
       if ( ! SummaryMode) {\r
         Status = ProcessHandles ( ExcludeMode);\r
         if (Status == EFI_ABORTED) {\r
index b5ec5f0401c0b53006e3582c205511273b674452..6de194aaaadfceca531edc3031c6a033063ff709 100644 (file)
@@ -6,7 +6,7 @@
   Dp application.  In addition to global data, function declarations for\r
   DpUtilities.c, DpTrace.c, and DpProfile.c are included here.\r
 \r
-  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\r
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -236,12 +236,10 @@ DumpRawTrace(
 /** \r
   Gather and print Major Phase metrics.\r
   \r
-  @param[in]    Ticker      The timer value for the END of Shell phase\r
-  \r
 **/\r
 VOID\r
 ProcessPhases(\r
-  IN UINT64 Ticker\r
+  VOID\r
   );\r
 \r
 \r
index 64583988c183cfcebddc31800d9bc276c3025897..e4434034c6c120acad836c37769986f9b9759c74 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Measured Profiling reporting for the Dp utility.\r
 \r
-  Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -16,7 +16,6 @@
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/TimerLib.h>\r
 #include <Library/PeCoffGetEntryPointLib.h>\r
 #include <Library/PerformanceLib.h>\r
 #include <Library/PrintLib.h>\r
index eca2ef309bbc6bb959b1a577ab8f57dd4d1e8d09..90a71ad91b571da267dcbeb33f750d3bec19bb15 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Trace reporting for the Dp utility.\r
 \r
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\r
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -17,7 +17,6 @@
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/TimerLib.h>\r
 #include <Library/PeCoffGetEntryPointLib.h>\r
 #include <Library/PerformanceLib.h>\r
 #include <Library/PrintLib.h>\r
@@ -386,12 +385,10 @@ DumpRawTrace(
 /** \r
   Gather and print Major Phase metrics.\r
   \r
-  @param[in]    Ticker      The timer value for the END of Shell phase\r
-  \r
 **/\r
 VOID\r
 ProcessPhases(\r
-  IN UINT64            Ticker\r
+  VOID\r
   )\r
 {\r
   MEASUREMENT_RECORD        Measurement;\r
@@ -400,7 +397,6 @@ ProcessPhases(
   UINT64                    PeiTime;\r
   UINT64                    DxeTime;\r
   UINT64                    BdsTime;\r
-  UINT64                    ShellTime;\r
   UINT64                    ElapsedTime;\r
   UINT64                    Duration;\r
   UINT64                    Total;\r
@@ -413,7 +409,6 @@ ProcessPhases(
   PeiTime         = 0;\r
   DxeTime         = 0;\r
   BdsTime         = 0;\r
-  ShellTime       = 0;   \r
   //\r
   // Get Execution Phase Statistics\r
   //\r
@@ -434,9 +429,6 @@ ProcessPhases(
                           &Measurement.EndTimeStamp,\r
                           &Measurement.Identifier)) != 0)\r
   {\r
-    if (AsciiStrnCmp (Measurement.Token, ALit_SHELL, PERF_TOKEN_LENGTH) == 0) {\r
-      Measurement.EndTimeStamp = Ticker;\r
-    }\r
     if (Measurement.EndTimeStamp == 0) { // Skip "incomplete" records\r
       continue;\r
     }\r
@@ -454,8 +446,6 @@ ProcessPhases(
       DxeTime      = Duration;\r
     } else if (AsciiStrnCmp (Measurement.Token, ALit_BDS, PERF_TOKEN_LENGTH) == 0) {\r
       BdsTime      = Duration;\r
-    } else if (AsciiStrnCmp (Measurement.Token, ALit_SHELL, PERF_TOKEN_LENGTH) == 0) {\r
-      ShellTime    = Duration;\r
     }\r
   }\r
 \r
@@ -510,17 +500,6 @@ ProcessPhases(
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_BDSTO), gDpHiiHandle, ALit_BdsTO, ElapsedTime);\r
   }\r
 \r
-  // print SHELL phase duration time\r
-  //\r
-  if (ShellTime > 0) {\r
-    ElapsedTime = DivU64x32 (\r
-                    ShellTime,\r
-                    (UINT32)TimerInfo.Frequency\r
-                    );\r
-    Total += ElapsedTime;\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_PHASE_DURATION), gDpHiiHandle, ALit_SHELL, ElapsedTime);\r
-  }\r
-\r
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOTAL_DURATION), gDpHiiHandle, Total);\r
 }\r
 \r
index fbdd938bc3bfbd1388515f909c7d4645000817a8..64f1830fcc92457d8436922c9de42705b16b996d 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Utility functions used by the Dp application.\r
 \r
-  Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\r
   (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
@@ -17,7 +17,6 @@
 #include <Library/MemoryAllocationLib.h>\r
 #include <Library/DebugLib.h>\r
 #include <Library/UefiBootServicesTableLib.h>\r
-#include <Library/TimerLib.h>\r
 #include <Library/PeCoffGetEntryPointLib.h>\r
 #include <Library/PrintLib.h>\r
 #include <Library/HiiLib.h>\r
index 68de0fbc9ece3910f47d0d53ef1ff2c49d519567..c1cddfb9ffb25f7cdbe6f68e24ffc6b6512fe1a9 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Definitions of ASCII string literals used by DP.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
   This program and the accompanying materials\r
   are licensed and made available under the terms and conditions of the BSD License\r
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -16,7 +16,6 @@
 CHAR8 const ALit_TimerLibError[] = "Timer library instance error!\n";\r
 CHAR8 const ALit_SEC[]    = SEC_TOK;\r
 CHAR8 const ALit_DXE[]    = DXE_TOK;\r
-CHAR8 const ALit_SHELL[]  = SHELL_TOK;\r
 CHAR8 const ALit_PEI[]    = PEI_TOK;\r
 CHAR8 const ALit_BDS[]    = BDS_TOK;\r
 CHAR8 const ALit_BdsTO[]  = "BdsTimeOut";\r
index 70d2163d2bd24f5f61ab0c62fe1145f383560606..0bce0ce6c9e3c15534c5d1970f9679c91318fcc5 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.\r
+# Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.\r
 # This program and the accompanying materials\r
 # are licensed and made available under the terms and conditions of the BSD License\r
 # which accompanies this distribution.  The full text of the license may be found at\r
@@ -48,7 +48,6 @@
   MdeModulePkg/MdeModulePkg.dec\r
 \r
 [LibraryClasses]\r
-  TimerLib\r
   PerformanceLib\r
   DxeServicesLib\r
   MemoryAllocationLib\r
@@ -64,6 +63,9 @@
   PrintLib\r
   DevicePathLib\r
 \r
+[Guids]\r
+  gPerformanceProtocolGuid                                ## CONSUMES ## SystemTable\r
+\r
 [Protocols]\r
   gEfiLoadedImageProtocolGuid                             ## CONSUMES\r
   gEfiDriverBindingProtocolGuid                           ## SOMETIMES_CONSUMES\r
index b09227451078e8f596cd457fe99fd047037f077d..b77c50771b64b2560d9baade371606874786d115 100644 (file)
@@ -1,7 +1,7 @@
 // *++\r
 //\r
 // (C) Copyright 2014-2015 Hewlett-Packard Development Company, L.P.<BR>\r
-// Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.<BR>\r
+// Copyright (c) 2009 - 2017, Intel Corporation. All rights reserved.<BR>\r
 // (C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR>\r
 // This program and the accompanying materials\r
 // are licensed and made available under the terms and conditions of the BSD License\r
@@ -35,6 +35,7 @@
 #string STR_DP_INVALID_ARG             #language en-US  "Invalid argument(s)\n"\r
 #string STR_DP_HANDLES_ERROR           #language en-US  "Locate all handles error - %r\n"\r
 #string STR_DP_ERROR_NAME              #language en-US  "Unknown driver name"\r
+#string STR_PERF_PROPERTY_NOT_FOUND    #language en-US  "Performance property not found\n"\r
 #string STR_DP_BUILD_REVISION          #language en-US  "\nDP Build Version:       %d.%d\n"\r
 #string STR_DP_KHZ                     #language en-US  "System Performance Timer Frequency:   %,8d (KHz)\n"\r
 #string STR_DP_TIMER_PROPERTIES        #language en-US  "System Performance Timer counts %s from 0x%Lx to 0x%Lx\n"\r
index 6b7864bac395acae3a06941dfc7c7015130ac745..5c01933c5265d6210c8b28f96e51bf8f4efd3f83 100644 (file)
@@ -1,7 +1,7 @@
 ##  @file\r
 # Shell Package\r
 #\r
-# Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>\r
+# Copyright (c) 2007 - 2017, Intel Corporation. All rights reserved.<BR>\r
 #\r
 #    This program and the accompanying materials\r
 #    are licensed and made available under the terms and conditions of the BSD License\r
@@ -99,7 +99,6 @@
 \r
   ShellPkg/Library/UefiDpLib/UefiDpLib.inf {\r
     <LibraryClasses>\r
-      TimerLib|MdePkg/Library/BaseTimerLibNullTemplate/BaseTimerLibNullTemplate.inf\r
       PerformanceLib|MdePkg/Library/BasePerformanceLibNull/BasePerformanceLibNull.inf\r
       DxeServicesLib|MdePkg/Library/DxeServicesLib/DxeServicesLib.inf\r
   }\r