]> git.proxmox.com Git - mirror_edk2.git/commitdiff
Add new extension PerformanceLib APIs to store ID info.
authorlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 24 Apr 2012 09:15:10 +0000 (09:15 +0000)
committerlzeng14 <lzeng14@6f19259b-4bc3-4df7-8a09-765794883524>
Tue, 24 Apr 2012 09:15:10 +0000 (09:15 +0000)
Signed-off-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@13216 6f19259b-4bc3-4df7-8a09-765794883524

PerformancePkg/Dp_App/Dp.c
PerformancePkg/Dp_App/Dp.h
PerformancePkg/Dp_App/DpInternal.h
PerformancePkg/Dp_App/DpStrings.uni
PerformancePkg/Dp_App/DpTrace.c

index 50598921922488070aca1969aeb99aa29ee5d3d4..57144a8fb87467315cf54756a2cab8ed5bdbaabe 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 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2012, 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
@@ -49,6 +49,7 @@ CHAR16           *mPrintTokenBuffer = NULL;
 CHAR16           mGaugeString[DP_GAUGE_STRING_LENGTH + 1];\r
 CHAR16           mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];\r
 UINT64           mInterestThreshold;\r
+BOOLEAN          mShowId = FALSE;\r
 \r
 PERF_SUMMARY_DATA SummaryData = { 0 };    ///< Create the SummaryData structure and init. to ZERO.\r
 \r
@@ -79,6 +80,7 @@ PARAM_ITEM_LIST  ParamList[] = {
   {STRING_TOKEN (STR_DP_OPTION_UT), TypeFlag},   // -T   Dump Trace Data\r
 #endif\r
   {STRING_TOKEN (STR_DP_OPTION_LX), TypeFlag},   // -x   eXclude Cumulative Items\r
+  {STRING_TOKEN (STR_DP_OPTION_LI), TypeFlag},   // -i   Display Identifier\r
   {STRING_TOKEN (STR_DP_OPTION_LN), TypeValue},  // -n # Number of records to display for A and R\r
   {STRING_TOKEN (STR_DP_OPTION_LT), TypeValue}   // -t # Threshold of interest\r
   };\r
@@ -135,6 +137,7 @@ ShowHelp( void )
 #endif // PROFILING_IMPLEMENTED\r
   PrintToken (STRING_TOKEN (STR_DP_HELP_THRESHOLD));\r
   PrintToken (STRING_TOKEN (STR_DP_HELP_COUNT));\r
+  PrintToken (STRING_TOKEN (STR_DP_HELP_ID));\r
   PrintToken (STRING_TOKEN (STR_DP_HELP_HELP));\r
   Print(L"\n");\r
 }\r
@@ -214,6 +217,7 @@ InitializeDp (
   EFI_STRING                StringDpOptionLx;\r
   EFI_STRING                StringDpOptionLn;\r
   EFI_STRING                StringDpOptionLt;\r
+  EFI_STRING                StringDpOptionLi;\r
   \r
   SummaryMode     = FALSE;\r
   VerboseMode     = FALSE;\r
@@ -236,6 +240,7 @@ InitializeDp (
   StringDpOptionLx = NULL;\r
   StringDpOptionLn = NULL;\r
   StringDpOptionLt = NULL;\r
+  StringDpOptionLi = NULL;\r
   StringPtr        = NULL;\r
 \r
   // Get DP's entry time as soon as possible.\r
@@ -283,6 +288,7 @@ InitializeDp (
       StringDpOptionLx = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LX), NULL);\r
       StringDpOptionLn = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LN), NULL);\r
       StringDpOptionLt = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LT), NULL);\r
+      StringDpOptionLi = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_OPTION_LI), NULL);\r
       \r
       // Boolean Options\r
       // \r
@@ -296,6 +302,7 @@ InitializeDp (
       ProfileMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionUp);\r
 #endif  // PROFILING_IMPLEMENTED\r
       ExcludeMode = ShellCommandLineGetFlag (ParamPackage, StringDpOptionLx);\r
+      mShowId     =  ShellCommandLineGetFlag (ParamPackage, StringDpOptionLi);\r
 \r
       // Options with Values\r
       CmdLineArg  = ShellCommandLineGetValue (ParamPackage, StringDpOptionLn);\r
@@ -447,6 +454,7 @@ InitializeDp (
   SafeFreePool (StringDpOptionLx);\r
   SafeFreePool (StringDpOptionLn);\r
   SafeFreePool (StringDpOptionLt);\r
+  SafeFreePool (StringDpOptionLi);\r
   SafeFreePool (StringPtr);\r
   SafeFreePool (mPrintTokenBuffer);\r
 \r
index 489c9684db76bb0d18759633ff93f9d86ec6a92d..5fc3335279e712ef5531927e5c16184a17ad35cd 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Common declarations for the Dp Performance Reporting Utility.\r
 \r
-  Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2012, 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
@@ -83,6 +83,7 @@ typedef struct {
   CONST CHAR8           *Module;          ///< Module string name.\r
   UINT64                StartTimeStamp;   ///< Start time point.\r
   UINT64                EndTimeStamp;     ///< End time point.\r
+  UINT32                Identifier;       ///< Identifier.\r
 } MEASUREMENT_RECORD;\r
 \r
 typedef struct {\r
index 223feef9b85f81bda86a22ab1da89e739f5515ef..eb4f2748921fb4f4957be07e29362cb7e1865694 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 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2012, 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
@@ -28,6 +28,7 @@ extern CHAR16             *mPrintTokenBuffer;
 extern CHAR16             mGaugeString[DP_GAUGE_STRING_LENGTH + 1];\r
 extern CHAR16             mUnicodeToken[DXE_PERFORMANCE_STRING_SIZE];\r
 extern UINT64             mInterestThreshold;\r
+extern BOOLEAN            mShowId;\r
 \r
 extern PERF_SUMMARY_DATA  SummaryData;    ///< Create the SummaryData structure and init. to ZERO.\r
 \r
index 22925ba348c18d9ed5ef1d76160bd3e863ab18c7..eddc02c2b8536c63718b82040f9c0238e21d23ce 100644 (file)
Binary files a/PerformancePkg/Dp_App/DpStrings.uni and b/PerformancePkg/Dp_App/DpStrings.uni differ
index a7c2049b8531f7a66ea1b45205615e22473c2363..1ba2b72ba4fcfc056bfd7b5335c16e7e11543a57 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Trace reporting for the Dp utility.\r
 \r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2012, 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
@@ -54,13 +54,14 @@ GatherStatistics(
   INTN                      TIndex;\r
 \r
   LogEntryKey = 0;\r
-  while ((LogEntryKey = GetPerformanceMeasurement (\r
+  while ((LogEntryKey = GetPerformanceMeasurementEx (\r
                         LogEntryKey,\r
                         &Measurement.Handle,\r
                         &Measurement.Token,\r
                         &Measurement.Module,\r
                         &Measurement.StartTimeStamp,\r
-                        &Measurement.EndTimeStamp)) != 0)\r
+                        &Measurement.EndTimeStamp,\r
+                        &Measurement.Identifier)) != 0)\r
   {\r
     ++SummaryData.NumTrace;           // Count the number of TRACE Measurement records\r
     if (Measurement.EndTimeStamp == 0) {\r
@@ -168,27 +169,31 @@ DumpAllTrace(
     //    Display only records with Elapsed times >= mInterestThreshold\r
     //    Display driver names in Module field for records with Handles.\r
     //\r
-    PrintToken (STRING_TOKEN (STR_DP_ALL_HEADR) );\r
-    PrintToken (STRING_TOKEN (STR_DP_DASHES) );\r
+    if (mShowId) {\r
+      PrintToken (STRING_TOKEN (STR_DP_ALL_HEADR2) );\r
+      PrintToken (STRING_TOKEN (STR_DP_ALL_DASHES2) );\r
+    } else {\r
+      PrintToken (STRING_TOKEN (STR_DP_ALL_HEADR) );\r
+      PrintToken (STRING_TOKEN (STR_DP_DASHES) );\r
+    }\r
 \r
     LogEntryKey = 0;\r
     Count = 0;\r
     Index = 0;\r
     while ( WITHIN_LIMIT(Count, Limit) &&\r
-            ((LogEntryKey = GetPerformanceMeasurement (\r
+            ((LogEntryKey = GetPerformanceMeasurementEx (\r
                             LogEntryKey,\r
                             &Measurement.Handle,\r
                             &Measurement.Token,\r
                             &Measurement.Module,\r
                             &Measurement.StartTimeStamp,\r
-                            &Measurement.EndTimeStamp)) != 0)\r
+                            &Measurement.EndTimeStamp,\r
+                            &Measurement.Identifier)) != 0)\r
           )\r
     {\r
       ++Index;    // Count every record.  First record is 1.\r
       ElapsedTime = 0;\r
-      if (IncFlag != NULL) {\r
-        FreePool ((void *)IncFlag);\r
-      }\r
+      SafeFreePool ((VOID *) IncFlag);\r
       if (Measurement.EndTimeStamp != 0) {\r
         Duration = GetDuration (&Measurement);\r
         ElapsedTime = DurationInMicroSeconds ( Duration );\r
@@ -225,20 +230,32 @@ DumpAllTrace(
       mGaugeString[DP_GAUGE_STRING_LENGTH] = 0;\r
       mUnicodeToken[13] = 0;\r
 \r
-      PrintToken( STRING_TOKEN (STR_DP_ALL_VARS),\r
-        Index,      // 1 based, Which measurement record is being printed\r
-        IncFlag,\r
-        Measurement.Handle,\r
-        mGaugeString,\r
-        mUnicodeToken,\r
-        ElapsedTime\r
-      );\r
+      if (mShowId) {\r
+        PrintToken( STRING_TOKEN (STR_DP_ALL_VARS2),\r
+          Index,      // 1 based, Which measurement record is being printed\r
+          IncFlag,\r
+          Measurement.Handle,\r
+          mGaugeString,\r
+          mUnicodeToken,\r
+          ElapsedTime,\r
+          Measurement.Identifier\r
+        );\r
+      } else {\r
+        PrintToken( STRING_TOKEN (STR_DP_ALL_VARS),\r
+          Index,      // 1 based, Which measurement record is being printed\r
+          IncFlag,\r
+          Measurement.Handle,\r
+          mGaugeString,\r
+          mUnicodeToken,\r
+          ElapsedTime\r
+        );\r
+      }\r
     }\r
   }\r
   if (HandleBuffer != &TempHandle) {\r
     FreePool (HandleBuffer);\r
   }\r
-  FreePool ((void *)IncFlag);\r
+  SafeFreePool ((VOID *) IncFlag);\r
 }\r
 \r
 /** \r
@@ -282,20 +299,26 @@ DumpRawTrace(
   FreePool (StringPtr);\r
   FreePool (StringPtrUnknown);\r
 \r
-  PrintToken (STRING_TOKEN (STR_DP_RAW_HEADR) );\r
-  PrintToken (STRING_TOKEN (STR_DP_RAW_DASHES) );\r
+  if (mShowId) {\r
+    PrintToken (STRING_TOKEN (STR_DP_RAW_HEADR2) );\r
+    PrintToken (STRING_TOKEN (STR_DP_RAW_DASHES2) );\r
+  } else {\r
+    PrintToken (STRING_TOKEN (STR_DP_RAW_HEADR) );\r
+    PrintToken (STRING_TOKEN (STR_DP_RAW_DASHES) );\r
+  }\r
 \r
   LogEntryKey = 0;\r
   Count = 0;\r
   Index = 0;\r
   while ( WITHIN_LIMIT(Count, Limit) &&\r
-          ((LogEntryKey = GetPerformanceMeasurement (\r
+          ((LogEntryKey = GetPerformanceMeasurementEx (\r
                           LogEntryKey,\r
                           &Measurement.Handle,\r
                           &Measurement.Token,\r
                           &Measurement.Module,\r
                           &Measurement.StartTimeStamp,\r
-                          &Measurement.EndTimeStamp)) != 0)\r
+                          &Measurement.EndTimeStamp,\r
+                          &Measurement.Identifier)) != 0)\r
         )\r
   {\r
     ++Index;    // Count every record.  First record is 1.\r
@@ -310,14 +333,27 @@ DumpRawTrace(
       continue;\r
     }\r
     ++Count;    // Count the number of records printed\r
-    PrintToken (STRING_TOKEN (STR_DP_RAW_VARS),\r
-      Index,      // 1 based, Which measurement record is being printed\r
-      Measurement.Handle,\r
-      Measurement.StartTimeStamp,\r
-      Measurement.EndTimeStamp,\r
-      Measurement.Token,\r
-      Measurement.Module\r
-    );\r
+\r
+    if (mShowId) {\r
+      PrintToken (STRING_TOKEN (STR_DP_RAW_VARS2),\r
+        Index,      // 1 based, Which measurement record is being printed\r
+        Measurement.Handle,\r
+        Measurement.StartTimeStamp,\r
+        Measurement.EndTimeStamp,\r
+        Measurement.Token,\r
+        Measurement.Module,\r
+        Measurement.Identifier\r
+      );\r
+    } else {\r
+      PrintToken (STRING_TOKEN (STR_DP_RAW_VARS),\r
+        Index,      // 1 based, Which measurement record is being printed\r
+        Measurement.Handle,\r
+        Measurement.StartTimeStamp,\r
+        Measurement.EndTimeStamp,\r
+        Measurement.Token,\r
+        Measurement.Module\r
+      );\r
+    }\r
   }\r
 }\r
 \r
@@ -363,13 +399,14 @@ ProcessPhases(
   FreePool (StringPtrUnknown);\r
 \r
   LogEntryKey = 0;\r
-  while ((LogEntryKey = GetPerformanceMeasurement (\r
+  while ((LogEntryKey = GetPerformanceMeasurementEx (\r
                           LogEntryKey,\r
                           &Measurement.Handle,\r
                           &Measurement.Token,\r
                           &Measurement.Module,\r
                           &Measurement.StartTimeStamp,\r
-                          &Measurement.EndTimeStamp)) != 0)\r
+                          &Measurement.EndTimeStamp,\r
+                          &Measurement.Identifier)) != 0)\r
   {\r
     if (AsciiStrnCmp (Measurement.Token, ALit_SHELL, PERF_TOKEN_LENGTH) == 0) {\r
       Measurement.EndTimeStamp = Ticker;\r
@@ -512,18 +549,23 @@ ProcessHandles(
     Print (L"There are %,d Handles defined.\n", (Size / sizeof(HandleBuffer[0])));\r
 #endif\r
 \r
-    PrintToken (STRING_TOKEN (STR_DP_HANDLE_SECTION) );\r
+    if (mShowId) {\r
+      PrintToken (STRING_TOKEN (STR_DP_HANDLE_SECTION2) );\r
+    } else {\r
+      PrintToken (STRING_TOKEN (STR_DP_HANDLE_SECTION) );\r
+    }\r
     PrintToken (STRING_TOKEN (STR_DP_DASHES) );\r
 \r
     LogEntryKey = 0;\r
     Count   = 0;\r
-    while ((LogEntryKey = GetPerformanceMeasurement (\r
+    while ((LogEntryKey = GetPerformanceMeasurementEx (\r
                             LogEntryKey,\r
                             &Measurement.Handle,\r
                             &Measurement.Token,\r
                             &Measurement.Module,\r
                             &Measurement.StartTimeStamp,\r
-                            &Measurement.EndTimeStamp)) != 0)\r
+                            &Measurement.EndTimeStamp,\r
+                            &Measurement.Identifier)) != 0)\r
     {\r
       Count++;\r
       Duration = GetDuration (&Measurement);\r
@@ -549,14 +591,26 @@ ProcessHandles(
       mUnicodeToken[11] = 0;\r
       if (mGaugeString[0] != 0) {\r
         // Display the record if it has a valid handle.\r
-        PrintToken (\r
-          STRING_TOKEN (STR_DP_HANDLE_VARS),\r
-          Count,      // 1 based, Which measurement record is being printed\r
-          Index + 1,  // 1 based, Which handle is being printed\r
-          mGaugeString,\r
-          mUnicodeToken,\r
-          ElapsedTime\r
-        );\r
+        if (mShowId) {\r
+          PrintToken (\r
+            STRING_TOKEN (STR_DP_HANDLE_VARS2),\r
+            Count,      // 1 based, Which measurement record is being printed\r
+            Index + 1,  // 1 based, Which handle is being printed\r
+            mGaugeString,\r
+            mUnicodeToken,\r
+            ElapsedTime,\r
+            Measurement.Identifier\r
+          );\r
+        } else {\r
+          PrintToken (\r
+            STRING_TOKEN (STR_DP_HANDLE_VARS),\r
+            Count,      // 1 based, Which measurement record is being printed\r
+            Index + 1,  // 1 based, Which handle is being printed\r
+            mGaugeString,\r
+            mUnicodeToken,\r
+            ElapsedTime\r
+          );\r
+        }\r
       }\r
     }\r
   }\r
@@ -592,17 +646,22 @@ ProcessPeims(
   FreePool (StringPtr);\r
   FreePool (StringPtrUnknown);\r
 \r
-  PrintToken (STRING_TOKEN (STR_DP_PEIM_SECTION));\r
+  if (mShowId) {\r
+    PrintToken (STRING_TOKEN (STR_DP_PEIM_SECTION2));\r
+  } else {\r
+    PrintToken (STRING_TOKEN (STR_DP_PEIM_SECTION));\r
+  }\r
   PrintToken (STRING_TOKEN (STR_DP_DASHES));\r
   TIndex  = 0;\r
   LogEntryKey = 0;\r
-  while ((LogEntryKey = GetPerformanceMeasurement (\r
+  while ((LogEntryKey = GetPerformanceMeasurementEx (\r
                           LogEntryKey,\r
                           &Measurement.Handle,\r
                           &Measurement.Token,\r
                           &Measurement.Module,\r
                           &Measurement.StartTimeStamp,\r
-                          &Measurement.EndTimeStamp)) != 0)\r
+                          &Measurement.EndTimeStamp,\r
+                          &Measurement.Identifier)) != 0)\r
   {\r
     TIndex++;\r
     if ((Measurement.EndTimeStamp == 0) ||\r
@@ -615,12 +674,22 @@ ProcessPeims(
     ElapsedTime = DurationInMicroSeconds ( Duration );  // Calculate elapsed time in microseconds\r
     if (ElapsedTime >= mInterestThreshold) {\r
       // PEIM FILE Handle is the start address of its FFS file that contains its file guid.\r
-      PrintToken (STRING_TOKEN (STR_DP_PEIM_VARS),\r
-            TIndex,   // 1 based, Which measurement record is being printed\r
-            Measurement.Handle,  // base address\r
-            Measurement.Handle,  // file guid\r
-            ElapsedTime\r
-      );\r
+      if (mShowId) {\r
+        PrintToken (STRING_TOKEN (STR_DP_PEIM_VARS2),\r
+              TIndex,   // 1 based, Which measurement record is being printed\r
+              Measurement.Handle,  // base address\r
+              Measurement.Handle,  // file guid\r
+              ElapsedTime,\r
+              Measurement.Identifier\r
+        );\r
+      } else {\r
+        PrintToken (STRING_TOKEN (STR_DP_PEIM_VARS),\r
+              TIndex,   // 1 based, Which measurement record is being printed\r
+              Measurement.Handle,  // base address\r
+              Measurement.Handle,  // file guid\r
+              ElapsedTime\r
+        );\r
+      }\r
     }\r
   }\r
 }\r
@@ -654,23 +723,28 @@ ProcessGlobal(
   FreePool (StringPtr);\r
   FreePool (StringPtrUnknown);\r
 \r
-  PrintToken (STRING_TOKEN (STR_DP_GLOBAL_SECTION));\r
+  if (mShowId) {\r
+    PrintToken (STRING_TOKEN (STR_DP_GLOBAL_SECTION2));\r
+  } else {\r
+    PrintToken (STRING_TOKEN (STR_DP_GLOBAL_SECTION));\r
+  }\r
   PrintToken (STRING_TOKEN (STR_DP_DASHES));\r
 \r
   Index = 1;\r
   LogEntryKey = 0;\r
 \r
-  while ((LogEntryKey = GetPerformanceMeasurement (\r
+  while ((LogEntryKey = GetPerformanceMeasurementEx (\r
                           LogEntryKey,\r
                           &Measurement.Handle,\r
                           &Measurement.Token,\r
                           &Measurement.Module,\r
                           &Measurement.StartTimeStamp,\r
-                          &Measurement.EndTimeStamp)) != 0)\r
+                          &Measurement.EndTimeStamp,\r
+                          &Measurement.Identifier)) != 0)\r
   {\r
     AsciiStrToUnicodeStr (Measurement.Module, mGaugeString);\r
     AsciiStrToUnicodeStr (Measurement.Token, mUnicodeToken);\r
-    mGaugeString[26] = 0;\r
+    mGaugeString[25] = 0;\r
     mUnicodeToken[31] = 0;\r
     if ( ! ( IsPhase( &Measurement)  ||\r
         (Measurement.Handle != NULL)      ||\r
@@ -680,13 +754,24 @@ ProcessGlobal(
       Duration = GetDuration (&Measurement);\r
       ElapsedTime = DurationInMicroSeconds ( Duration );\r
       if (ElapsedTime >= mInterestThreshold) {\r
-        PrintToken (\r
-          STRING_TOKEN (STR_DP_GLOBAL_VARS),\r
-          Index,\r
-          mGaugeString,\r
-          mUnicodeToken,\r
-          ElapsedTime\r
-          );\r
+        if (mShowId) {\r
+          PrintToken (\r
+            STRING_TOKEN (STR_DP_GLOBAL_VARS2),\r
+            Index,\r
+            mGaugeString,\r
+            mUnicodeToken,\r
+            ElapsedTime,\r
+            Measurement.Identifier\r
+            );\r
+        } else {\r
+           PrintToken (\r
+            STRING_TOKEN (STR_DP_GLOBAL_VARS),\r
+            Index,\r
+            mGaugeString,\r
+            mUnicodeToken,\r
+            ElapsedTime\r
+            );\r
+        }\r
       }\r
     }\r
     Index++;\r