]> git.proxmox.com Git - mirror_edk2.git/blobdiff - PerformancePkg/Dp_App/DpTrace.c
BaseTools: Update Python Makefile to include the new added python files
[mirror_edk2.git] / PerformancePkg / Dp_App / DpTrace.c
index 632904f339408145aa2ac8a91610864ef4cb97aa..9b4e0ed289ad19d9938eb07ad25e9c92ed672f36 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   Trace reporting for the Dp utility.\r
 \r
-  Copyright (c) 2009 - 2012, Intel Corporation. All rights reserved.<BR>\r
+  Copyright (c) 2009 - 2017, 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
@@ -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
@@ -136,8 +135,11 @@ GatherStatistics(
   @param[in]    Limit       The number of records to print.  Zero is ALL.\r
   @param[in]    ExcludeFlag TRUE to exclude individual Cumulative items from display.\r
   \r
+  @retval EFI_SUCCESS           The operation was successful.\r
+  @retval EFI_ABORTED           The user aborts the operation.\r
+  @return Others                from a call to gBS->LocateHandleBuffer().\r
 **/\r
-VOID\r
+EFI_STATUS\r
 DumpAllTrace(\r
   IN UINTN             Limit,\r
   IN BOOLEAN           ExcludeFlag\r
@@ -217,8 +219,8 @@ DumpAllTrace(
       ++Count;    // Count the number of records printed\r
 \r
       // If Handle is non-zero, see if we can determine a name for the driver\r
-      AsciiStrToUnicodeStr (Measurement.Module, mGaugeString); // Use Module by default\r
-      AsciiStrToUnicodeStr (Measurement.Token, mUnicodeToken);\r
+      AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString)); // Use Module by default\r
+      AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));\r
       if (Measurement.Handle != NULL) {\r
         // See if the Handle is in the HandleBuffer\r
         for (TIndex = 0; TIndex < HandleCount; TIndex++) {\r
@@ -257,12 +259,17 @@ DumpAllTrace(
           ElapsedTime\r
         );\r
       }\r
+      if (ShellGetExecutionBreakFlag ()) {\r
+        Status = EFI_ABORTED;\r
+        break;\r
+      }\r
     }\r
   }\r
   if (HandleBuffer != NULL) {\r
     FreePool (HandleBuffer);\r
   }\r
   SafeFreePool ((VOID *) IncFlag);\r
+  return Status;\r
 }\r
 \r
 /** \r
@@ -281,9 +288,11 @@ DumpAllTrace(
   \r
   @param[in]    Limit       The number of records to print.  Zero is ALL.\r
   @param[in]    ExcludeFlag TRUE to exclude individual Cumulative items from display.\r
-  \r
+\r
+  @retval EFI_SUCCESS           The operation was successful.\r
+  @retval EFI_ABORTED           The user aborts the operation.\r
 **/\r
-VOID\r
+EFI_STATUS\r
 DumpRawTrace(\r
   IN UINTN          Limit,\r
   IN BOOLEAN        ExcludeFlag\r
@@ -298,6 +307,9 @@ DumpRawTrace(
 \r
   EFI_STRING    StringPtr;\r
   EFI_STRING    StringPtrUnknown;\r
+  EFI_STATUS    Status;\r
+\r
+  Status = EFI_SUCCESS;\r
 \r
   StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);  \r
   StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);\r
@@ -361,18 +373,21 @@ DumpRawTrace(
         Measurement.Module\r
       );\r
     }\r
+    if (ShellGetExecutionBreakFlag ()) {\r
+      Status = EFI_ABORTED;\r
+      break;\r
+    }\r
   }\r
+  return Status;\r
 }\r
 \r
 /** \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
@@ -381,7 +396,6 @@ ProcessPhases(
   UINT64                    PeiTime;\r
   UINT64                    DxeTime;\r
   UINT64                    BdsTime;\r
-  UINT64                    ShellTime;\r
   UINT64                    ElapsedTime;\r
   UINT64                    Duration;\r
   UINT64                    Total;\r
@@ -394,7 +408,6 @@ ProcessPhases(
   PeiTime         = 0;\r
   DxeTime         = 0;\r
   BdsTime         = 0;\r
-  ShellTime       = 0;   \r
   //\r
   // Get Execution Phase Statistics\r
   //\r
@@ -415,9 +428,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
@@ -435,8 +445,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
@@ -491,17 +499,6 @@ ProcessPhases(
     PrintToken (STRING_TOKEN (STR_DP_PHASE_BDSTO), 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
-    PrintToken (STRING_TOKEN (STR_DP_PHASE_DURATION), ALit_SHELL, ElapsedTime);\r
-  }\r
-\r
   PrintToken (STRING_TOKEN (STR_DP_TOTAL_DURATION), Total);\r
 }\r
 \r
@@ -509,8 +506,10 @@ ProcessPhases(
   Gather and print Handle data.\r
   \r
   @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items from display.\r
-  \r
-  @return       Status from a call to gBS->LocateHandle().\r
+\r
+  @retval EFI_SUCCESS             The operation was successful.\r
+  @retval EFI_ABORTED             The user aborts the operation.\r
+  @return Others                  from a call to gBS->LocateHandleBuffer().\r
 **/\r
 EFI_STATUS\r
 ProcessHandles(\r
@@ -574,7 +573,7 @@ ProcessHandles(
         continue;\r
       }\r
       mGaugeString[0] = 0;    // Empty driver name by default\r
-      AsciiStrToUnicodeStr (Measurement.Token, mUnicodeToken);\r
+      AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));\r
       // See if the Handle is in the HandleBuffer\r
       for (Index = 0; Index < HandleCount; Index++) {\r
         if (Measurement.Handle == HandleBuffer[Index]) {\r
@@ -608,6 +607,10 @@ ProcessHandles(
           );\r
         }\r
       }\r
+      if (ShellGetExecutionBreakFlag ()) {\r
+        Status = EFI_ABORTED;\r
+        break;\r
+      }\r
     }\r
   }\r
   if (HandleBuffer != NULL) {\r
@@ -620,9 +623,11 @@ ProcessHandles(
   Gather and print PEIM data.\r
   \r
   Only prints complete PEIM records\r
-  \r
+\r
+  @retval EFI_SUCCESS           The operation was successful.\r
+  @retval EFI_ABORTED           The user aborts the operation.\r
 **/\r
-VOID\r
+EFI_STATUS\r
 ProcessPeims(\r
   VOID\r
 )\r
@@ -634,6 +639,9 @@ ProcessPeims(
   UINTN                     LogEntryKey;\r
   UINTN                     TIndex;\r
   EFI_STRING                StringPtrUnknown;\r
+  EFI_STATUS                Status;\r
+\r
+  Status = EFI_SUCCESS;\r
 \r
   StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);  \r
   StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);\r
@@ -687,7 +695,12 @@ ProcessPeims(
         );\r
       }\r
     }\r
+    if (ShellGetExecutionBreakFlag ()) {\r
+      Status = EFI_ABORTED;\r
+      break;\r
+    }\r
   }\r
+  return Status;\r
 }\r
 \r
 /** \r
@@ -697,9 +710,11 @@ ProcessPeims(
   Only prints records where Handle is NULL\r
   Increment TIndex for every record, even skipped ones, so that we have an\r
   indication of every measurement record taken.\r
-  \r
+\r
+  @retval EFI_SUCCESS           The operation was successful.\r
+  @retval EFI_ABORTED           The user aborts the operation.\r
 **/\r
-VOID\r
+EFI_STATUS\r
 ProcessGlobal(\r
   VOID\r
 )\r
@@ -711,6 +726,9 @@ ProcessGlobal(
   UINTN                     LogEntryKey;\r
   UINTN                     Index;        // Index, or number, of the measurement record being processed\r
   EFI_STRING                StringPtrUnknown;\r
+  EFI_STATUS                Status;\r
+\r
+  Status = EFI_SUCCESS;\r
 \r
   StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);  \r
   StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);\r
@@ -738,8 +756,8 @@ ProcessGlobal(
                           &Measurement.EndTimeStamp,\r
                           &Measurement.Identifier)) != 0)\r
   {\r
-    AsciiStrToUnicodeStr (Measurement.Module, mGaugeString);\r
-    AsciiStrToUnicodeStr (Measurement.Token, mUnicodeToken);\r
+    AsciiStrToUnicodeStrS (Measurement.Module, mGaugeString, ARRAY_SIZE (mGaugeString));\r
+    AsciiStrToUnicodeStrS (Measurement.Token, mUnicodeToken, ARRAY_SIZE (mUnicodeToken));\r
     mGaugeString[25] = 0;\r
     mUnicodeToken[31] = 0;\r
     if ( ! ( IsPhase( &Measurement)  ||\r
@@ -770,8 +788,13 @@ ProcessGlobal(
         }\r
       }\r
     }\r
+    if (ShellGetExecutionBreakFlag ()) {\r
+      Status = EFI_ABORTED;\r
+      break;\r
+    }\r
     Index++;\r
   }\r
+  return Status;\r
 }\r
 \r
 /** \r