]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
ShellPkg/DP: Add more check for input parameters
[mirror_edk2.git] / ShellPkg / DynamicCommand / DpDynamicCommand / Dp.c
index 4dd7dd9ed11e360d0758761abbe319c7f04f3f62..213f6057c919f083dce1700988d14327cb202908 100644 (file)
   and start and end time values.\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
+\r
   Copyright (c) 2009 - 2018, 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
   which accompanies this distribution.  The full text of the license may be found at\r
   http://opensource.org/licenses/bsd-license.php\r
\r
+\r
   THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
   WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
 **/\r
@@ -84,10 +84,6 @@ STATIC CONST SHELL_PARAM_ITEM ParamList[] = {
   {L"-A", TypeFlag},   // -A   All, Cooked\r
   {L"-R", TypeFlag},   // -R   RAW All\r
   {L"-s", TypeFlag},   // -s   Summary\r
-#if PROFILING_IMPLEMENTED\r
-  {L"-P", TypeFlag},   // -P   Dump Profile Data\r
-  {L"-T", TypeFlag},   // -T   Dump Trace Data\r
-#endif // PROFILING_IMPLEMENTED\r
   {L"-x", TypeFlag},   // -x   eXclude Cumulative Items\r
   {L"-i", TypeFlag},   // -i   Display Identifier\r
   {L"-c", TypeValue},  // -c   Display cumulative data.\r
@@ -116,9 +112,6 @@ DumpStatistics( void )
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMHANDLES), mDpHiiHandle,    SummaryData.NumHandles, SummaryData.NumTrace - SummaryData.NumHandles);\r
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPEIMS), mDpHiiHandle,      SummaryData.NumPEIMs);\r
   ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMGLOBALS), mDpHiiHandle,    SummaryData.NumGlobal);\r
-#if PROFILING_IMPLEMENTED\r
-  ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_STATS_NUMPROFILE), mDpHiiHandle,    SummaryData.NumProfile);\r
-#endif // PROFILING_IMPLEMENTED\r
   SHELL_FREE_NON_NULL (StringPtr);\r
   SHELL_FREE_NON_NULL (StringPtrUnknown);\r
 }\r
@@ -258,6 +251,7 @@ GetBootPerformanceTable (
                  );\r
   }\r
   if (EFI_ERROR(Status) || AcpiTable == NULL) {\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_ACPI_TABLE_FAIL), mDpHiiHandle);\r
     return Status;\r
   }\r
 \r
@@ -266,6 +260,7 @@ GetBootPerformanceTable (
                       EFI_ACPI_5_0_FIRMWARE_PERFORMANCE_DATA_TABLE_SIGNATURE\r
                       );\r
   if (FirmwarePerformanceTable == NULL) {\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_ACPI_FPDT_FAIL), mDpHiiHandle);\r
     return EFI_NOT_FOUND;\r
   }\r
 \r
@@ -390,7 +385,7 @@ BuildCachedGuidHandleTable (
     FreePool (HandleBuffer);\r
     HandleBuffer = NULL;\r
   }\r
-  return Status;\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
@@ -435,11 +430,25 @@ GetMeasurementInfo (
       ASSERT(FALSE);\r
     }\r
 \r
-    if (AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {\r
-      Measurement->Handle         = &(((FPDT_GUID_EVENT_RECORD *)RecordHeader)->Guid);\r
+    if (Measurement->Token != NULL && AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {\r
+      Measurement->Handle         = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);\r
     } else {\r
       GetHandleFormModuleGuid(ModuleGuid, &StartHandle);\r
-      Measurement->Handle         = StartHandle;\r
+      Measurement->Handle = StartHandle;\r
+      //\r
+      // When no perf entry to record the PEI and DXE phase,\r
+      // For start image, we need detect the PEIM and non PEIM here.\r
+      //\r
+      if (Measurement->Token == NULL) {\r
+        if (StartHandle == NULL && !IsZeroGuid (ModuleGuid)) {\r
+          Measurement->Token      = ALit_PEIM;\r
+          Measurement->Module     = ALit_PEIM;\r
+          Measurement->Handle     = ModuleGuid;\r
+        } else {\r
+          Measurement->Token      = ALit_START_IMAGE;\r
+          Measurement->Module     = ALit_START_IMAGE;\r
+        }\r
+      }\r
     }\r
     break;\r
 \r
@@ -488,11 +497,23 @@ GetMeasurementInfo (
 \r
     Measurement->Module           = ((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->String;\r
 \r
-    if (AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {\r
+    if (Measurement->Token != NULL && AsciiStrCmp (Measurement->Token, ALit_PEIM) == 0) {\r
       Measurement->Handle         = &(((FPDT_DYNAMIC_STRING_EVENT_RECORD *)RecordHeader)->Guid);\r
     } else {\r
       GetHandleFormModuleGuid(ModuleGuid, &StartHandle);\r
       Measurement->Handle = StartHandle;\r
+      //\r
+      // When no perf entry to record the PEI and DXE phase,\r
+      // For start image, we need detect the PEIM and non PEIM here.\r
+      //\r
+      if (Measurement->Token == NULL  && (Measurement->Identifier == MODULE_START_ID || Measurement->Identifier == MODULE_END_ID)) {\r
+        if (StartHandle == NULL && !IsZeroGuid (ModuleGuid)) {\r
+          Measurement->Token      = ALit_PEIM;\r
+          Measurement->Handle     = ModuleGuid;\r
+        } else {\r
+          Measurement->Token      = ALit_START_IMAGE;\r
+        }\r
+      }\r
     }\r
     break;\r
 \r
@@ -558,6 +579,20 @@ GetMeasurementInfo (
     Measurement->Handle = StartHandle;\r
     break;\r
 \r
+  case FPDT_DUAL_GUID_STRING_EVENT_TYPE:\r
+    ModuleGuid                    = &(((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Guid1);\r
+    Measurement->Identifier       = ((UINT32)((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->ProgressID);\r
+    if (IsStart) {\r
+      Measurement->StartTimeStamp = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;\r
+    } else {\r
+      Measurement->EndTimeStamp   = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->Timestamp;\r
+    }\r
+    Measurement->Token            = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->String;\r
+    Measurement->Module           = ((FPDT_DUAL_GUID_STRING_EVENT_RECORD *)RecordHeader)->String;\r
+    GetHandleFormModuleGuid(ModuleGuid, &StartHandle);\r
+    Measurement->Handle = StartHandle;\r
+    break;\r
+\r
   default:\r
     break;\r
   }\r
@@ -585,6 +620,14 @@ SearchMeasurement (
         mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;\r
         break;\r
       }\r
+    } else if (EndMeasureMent->Identifier == PERF_CROSSMODULE_END_ID) {\r
+      if (mMeasurementList[Index].EndTimeStamp == 0 &&\r
+         (AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) &&\r
+         (AsciiStrCmp (mMeasurementList[Index].Module, EndMeasureMent->Module) == 0) &&\r
+         mMeasurementList[Index].Identifier == PERF_CROSSMODULE_START_ID) {\r
+        mMeasurementList[Index].EndTimeStamp = EndMeasureMent->EndTimeStamp;\r
+        break;\r
+      }\r
     } else {\r
       if (mMeasurementList[Index].EndTimeStamp == 0 && mMeasurementList[Index].Handle == EndMeasureMent->Handle &&\r
          (AsciiStrCmp (mMeasurementList[Index].Token, EndMeasureMent->Token) == 0) &&\r
@@ -625,25 +668,32 @@ BuildMeasurementList (
     StartProgressId   = ((FPDT_GUID_EVENT_RECORD *)StartRecordEvent)->ProgressID;\r
 \r
     //\r
+    // If the record with ProgressId 0, the record doesn't appear in pairs. The timestamp in the record is the EndTimeStamp, its StartTimeStamp is 0.\r
     // If the record is the start record, fill the info to the measurement in the mMeasurementList.\r
     // If the record is the end record, find the related start measurement in the mMeasurementList and fill the EndTimeStamp.\r
     //\r
-    if (((StartProgressId >= PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 0x000F) == 0)) ||\r
+    if (StartProgressId == 0) {\r
+      GetMeasurementInfo (RecordHeader, FALSE, &(mMeasurementList[mMeasurementNum]));\r
+      mMeasurementNum ++;\r
+    } else if (((StartProgressId >= PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 0x000F) == 0)) ||\r
         (StartProgressId < PERF_EVENTSIGNAL_START_ID && ((StartProgressId & 0x0001) != 0)))) {\r
       //\r
       // Since PEIM and StartImage has same Type and ID when PCD PcdEdkiiFpdtStringRecordEnableOnly = FALSE\r
       // So we need to identify these two kinds of record through different phase.\r
       //\r
-      if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_PEI) == 0) {\r
-        mPeiPhase = TRUE;\r
-      } else if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_DXE) == 0) {\r
-        mDxePhase = TRUE;\r
-        mPeiPhase = FALSE;\r
+      if(StartProgressId == PERF_CROSSMODULE_START_ID ){\r
+        if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_PEI) == 0) {\r
+          mPeiPhase = TRUE;\r
+        } else if (AsciiStrCmp (((FPDT_DYNAMIC_STRING_EVENT_RECORD *)StartRecordEvent)->String, ALit_DXE) == 0) {\r
+          mDxePhase = TRUE;\r
+          mPeiPhase = FALSE;\r
+        }\r
       }\r
       // Get measurement info form the start record to the mMeasurementList.\r
       GetMeasurementInfo (RecordHeader, TRUE, &(mMeasurementList[mMeasurementNum]));\r
       mMeasurementNum ++;\r
     } else {\r
+      ZeroMem(&MeasureMent, sizeof(MEASUREMENT_RECORD));\r
       GetMeasurementInfo (RecordHeader, FALSE, &MeasureMent);\r
       SearchMeasurement (&MeasureMent);\r
     }\r
@@ -672,12 +722,29 @@ InitCumulativeData (
   }\r
 }\r
 \r
+/**\r
+  Initialize the Summary data.\r
+\r
+**/\r
+VOID\r
+InitSummaryData (\r
+  VOID\r
+  )\r
+{\r
+  SummaryData.NumTrace      = 0;\r
+  SummaryData.NumIncomplete = 0;\r
+  SummaryData.NumSummary    = 0;\r
+  SummaryData.NumHandles    = 0;\r
+  SummaryData.NumPEIMs      = 0;\r
+  SummaryData.NumGlobal     = 0;\r
+}\r
+\r
 /**\r
   Dump performance data.\r
-  \r
+\r
   @param[in]  ImageHandle     The image handle.\r
   @param[in]  SystemTable     The system table.\r
-  \r
+\r
   @retval SHELL_SUCCESS            Command completed successfully.\r
   @retval SHELL_INVALID_PARAMETER  Command usage error.\r
   @retval SHELL_ABORTED            The user aborts the operation.\r
@@ -701,8 +768,6 @@ RunDp (
   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
@@ -710,14 +775,13 @@ RunDp (
   UINTN                     NameSize;\r
   SHELL_STATUS              ShellStatus;\r
   TIMER_INFO                TimerInfo;\r
+  UINT64                    Intermediate;\r
 \r
   StringPtr   = NULL;\r
   SummaryMode = FALSE;\r
   VerboseMode = FALSE;\r
   AllMode     = FALSE;\r
   RawMode     = FALSE;\r
-  TraceMode   = FALSE;\r
-  ProfileMode = FALSE;\r
   ExcludeMode = FALSE;\r
   CumulativeMode = FALSE;\r
   CustomCumulativeData = NULL;\r
@@ -729,36 +793,6 @@ RunDp (
   Status = ShellInitialize();\r
   ASSERT_EFI_ERROR(Status);\r
 \r
-  //\r
-  // DP dump performance data by parsing FPDT table in ACPI table.\r
-  // Folloing 3 steps are to get the measurement form the FPDT table.\r
-  //\r
-\r
-  //\r
-  //1. Get FPDT from ACPI table.\r
-  //\r
-  Status = GetBootPerformanceTable ();\r
-  if (EFI_ERROR(Status)) {\r
-    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_GET_BOOT_PERFORMANCE_TABLE_FAIL), mDpHiiHandle);\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  //2. Cache the ModuleGuid and hanlde mapping table.\r
-  //\r
-  Status = BuildCachedGuidHandleTable();\r
-  if (EFI_ERROR (Status)) {\r
-    return Status;\r
-  }\r
-\r
-  //\r
-  //3. Build the measurement array form the FPDT records.\r
-  //\r
-  Status = BuildMeasurementList ();\r
-  if (EFI_ERROR(Status)) {\r
-    return Status;\r
-  }\r
-\r
   //\r
   // Process Command Line arguments\r
   //\r
@@ -766,6 +800,9 @@ RunDp (
   if (EFI_ERROR(Status)) {\r
     ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_ARG), mDpHiiHandle);\r
     return SHELL_INVALID_PARAMETER;\r
+  } else if (ShellCommandLineGetCount(ParamPackage) > 1){\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_MANY), mDpHiiHandle);\r
+    return SHELL_INVALID_PARAMETER;\r
   }\r
 \r
   //\r
@@ -775,39 +812,115 @@ RunDp (
   SummaryMode = (BOOLEAN) (ShellCommandLineGetFlag (ParamPackage, L"-S") || ShellCommandLineGetFlag (ParamPackage, L"-s"));\r
   AllMode     = ShellCommandLineGetFlag (ParamPackage, L"-A");\r
   RawMode     = ShellCommandLineGetFlag (ParamPackage, L"-R");\r
-#if PROFILING_IMPLEMENTED\r
-  TraceMode   = ShellCommandLineGetFlag (ParamPackage, L"-T");\r
-  ProfileMode = ShellCommandLineGetFlag (ParamPackage, L"-P");\r
-#endif  // PROFILING_IMPLEMENTED\r
   ExcludeMode = ShellCommandLineGetFlag (ParamPackage, L"-x");\r
   mShowId     = ShellCommandLineGetFlag (ParamPackage, L"-i");\r
   CumulativeMode = ShellCommandLineGetFlag (ParamPackage, L"-c");\r
 \r
+  if (AllMode && RawMode) {\r
+    ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_CONFLICT_ARG), mDpHiiHandle, L"-A", L"-R");\r
+    return SHELL_INVALID_PARAMETER;\r
+  }\r
+\r
   // Options with Values\r
-  CmdLineArg  = ShellCommandLineGetValue (ParamPackage, L"-n");\r
-  if (CmdLineArg == NULL) {\r
+  if (ShellCommandLineGetFlag (ParamPackage, L"-n")) {\r
+    CmdLineArg  = ShellCommandLineGetValue (ParamPackage, L"-n");\r
+    if (CmdLineArg == NULL) {\r
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_FEW), mDpHiiHandle);\r
+      return SHELL_INVALID_PARAMETER;\r
+    } else {\r
+      if (!(RawMode || AllMode)) {\r
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_NO_RAW_ALL), mDpHiiHandle);\r
+        return SHELL_INVALID_PARAMETER;\r
+      }\r
+      Status = ShellConvertStringToUint64(CmdLineArg, &Intermediate, FALSE, TRUE);\r
+      if (EFI_ERROR (Status)) {\r
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_NUM_ARG), mDpHiiHandle, L"-n");\r
+        return SHELL_INVALID_PARAMETER;\r
+      } else {\r
+        Number2Display = (UINTN)Intermediate;\r
+        if (Number2Display == 0 || Number2Display > MAXIMUM_DISPLAYCOUNT) {\r
+          ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_RANGE), mDpHiiHandle, L"-n", 0, MAXIMUM_DISPLAYCOUNT);\r
+          return SHELL_INVALID_PARAMETER;\r
+        }\r
+      }\r
+    }\r
+  } else {\r
     Number2Display = DEFAULT_DISPLAYCOUNT;\r
+  }\r
+\r
+  if (ShellCommandLineGetFlag (ParamPackage, L"-t")) {\r
+    CmdLineArg  = ShellCommandLineGetValue (ParamPackage, L"-t");\r
+    if (CmdLineArg == NULL) {\r
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_FEW), mDpHiiHandle);\r
+      return SHELL_INVALID_PARAMETER;\r
+    } else {\r
+      Status = ShellConvertStringToUint64(CmdLineArg, &Intermediate, FALSE, TRUE);\r
+      if (EFI_ERROR (Status)) {\r
+        ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_INVALID_NUM_ARG), mDpHiiHandle, L"-t");\r
+        return SHELL_INVALID_PARAMETER;\r
+      } else {\r
+        mInterestThreshold = Intermediate;\r
+      }\r
+    }\r
   } else {\r
-    Number2Display = StrDecimalToUintn(CmdLineArg);\r
-    if (Number2Display == 0) {\r
-      Number2Display = MAXIMUM_DISPLAYCOUNT;\r
+    mInterestThreshold = DEFAULT_THRESHOLD;  // 1ms := 1,000 us\r
+  }\r
+\r
+  if (ShellCommandLineGetFlag (ParamPackage, L"-c")) {\r
+    CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c");\r
+    if (CustomCumulativeToken == NULL) {\r
+      ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DP_TOO_FEW), mDpHiiHandle);\r
+      return SHELL_INVALID_PARAMETER;\r
+    } else {\r
+      CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA));\r
+      if (CustomCumulativeData == NULL) {\r
+        ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+        goto Done;\r
+      }\r
+      CustomCumulativeData->MinDur = PERF_MAXDUR;\r
+      CustomCumulativeData->MaxDur = 0;\r
+      CustomCumulativeData->Count  = 0;\r
+      CustomCumulativeData->Duration = 0;\r
+      NameSize = StrLen (CustomCumulativeToken) + 1;\r
+      CustomCumulativeData->Name   = AllocateZeroPool (NameSize);\r
+      if (CustomCumulativeData->Name == NULL) {\r
+        ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+        goto Done;\r
+      }\r
+      UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, NameSize);\r
     }\r
   }\r
 \r
-  CmdLineArg  = ShellCommandLineGetValue (ParamPackage, L"-t");\r
-  if (CmdLineArg == NULL) {\r
-    mInterestThreshold = DEFAULT_THRESHOLD;  // 1ms := 1,000 us\r
-  } else {\r
-    mInterestThreshold = StrDecimalToUint64(CmdLineArg);\r
+  //\r
+  // DP dump performance data by parsing FPDT table in ACPI table.\r
+  // Folloing 3 steps are to get the measurement form the FPDT table.\r
+  //\r
+\r
+  //\r
+  //1. Get FPDT from ACPI table.\r
+  //\r
+  Status = GetBootPerformanceTable ();\r
+  if (EFI_ERROR (Status)) {\r
+    ShellStatus = Status;\r
+    goto Done;\r
   }\r
 \r
-  // Handle Flag combinations and default behaviors\r
-  // If both TraceMode and ProfileMode are FALSE, set them both to TRUE\r
-  if ((! TraceMode) && (! ProfileMode)) {\r
-    TraceMode   = TRUE;\r
-#if PROFILING_IMPLEMENTED\r
-    ProfileMode = TRUE;\r
-#endif  // PROFILING_IMPLEMENTED\r
+  //\r
+  //2. Cache the ModuleGuid and hanlde mapping table.\r
+  //\r
+  Status = BuildCachedGuidHandleTable();\r
+  if (EFI_ERROR (Status)) {\r
+    ShellStatus = Status;\r
+    goto Done;\r
+  }\r
+\r
+  //\r
+  //3. Build the measurement array form the FPDT records.\r
+  //\r
+  Status = BuildMeasurementList ();\r
+  if (EFI_ERROR (Status)) {\r
+    ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+    goto Done;\r
   }\r
 \r
   //\r
@@ -816,26 +929,9 @@ RunDp (
   InitCumulativeData ();\r
 \r
   //\r
-  // Init the custom cumulative data.\r
+  // Initialize the Summary data.\r
   //\r
-  CustomCumulativeToken = ShellCommandLineGetValue (ParamPackage, L"-c");\r
-  if (CustomCumulativeToken != NULL) {\r
-    CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA));\r
-    if (CustomCumulativeData == NULL) {\r
-      return SHELL_OUT_OF_RESOURCES;\r
-    }\r
-    CustomCumulativeData->MinDur = PERF_MAXDUR;\r
-    CustomCumulativeData->MaxDur = 0;\r
-    CustomCumulativeData->Count  = 0;\r
-    CustomCumulativeData->Duration = 0;\r
-    NameSize = StrLen (CustomCumulativeToken) + 1;\r
-    CustomCumulativeData->Name   = AllocateZeroPool (NameSize);\r
-    if (CustomCumulativeData->Name == NULL) {\r
-      FreePool (CustomCumulativeData);\r
-      return SHELL_OUT_OF_RESOURCES;\r
-    }\r
-    UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, NameSize);\r
-  }\r
+  InitSummaryData ();\r
 \r
   //\r
   // Timer specific processing\r
@@ -891,67 +987,45 @@ RunDp (
 ****    R Raw         --  S option is ignored\r
 ****    s Summary     --  Modifies "Cooked" output only\r
 ****    Cooked (Default)\r
-****\r
-****  The All, Raw, and Cooked modes are modified by the Trace and Profile\r
-****  options.\r
-****    !T && !P  := (0) Default, Both are displayed\r
-****     T && !P  := (1) Only Trace records are displayed\r
-****    !T &&  P  := (2) Only Profile records are displayed\r
-****     T &&  P  := (3) Same as Default, both are displayed\r
 ****************************************************************************/\r
   GatherStatistics (CustomCumulativeData);\r
-  if (CumulativeMode) {                       \r
+  if (CumulativeMode) {\r
     ProcessCumulative (CustomCumulativeData);\r
   } else if (AllMode) {\r
-    if (TraceMode) {\r
-      Status = DumpAllTrace( Number2Display, ExcludeMode);\r
+    Status = DumpAllTrace( Number2Display, ExcludeMode);\r
+    if (Status == EFI_ABORTED) {\r
+      ShellStatus = SHELL_ABORTED;\r
+      goto Done;\r
+    }\r
+  } else if (RawMode) {\r
+    Status = DumpRawTrace( Number2Display, ExcludeMode);\r
+    if (Status == EFI_ABORTED) {\r
+      ShellStatus = SHELL_ABORTED;\r
+      goto Done;\r
+    }\r
+  } else {\r
+    //------------- Begin Cooked Mode Processing\r
+    ProcessPhases ();\r
+    if ( ! SummaryMode) {\r
+      Status = ProcessHandles ( ExcludeMode);\r
       if (Status == EFI_ABORTED) {\r
         ShellStatus = SHELL_ABORTED;\r
         goto Done;\r
       }\r
-    }\r
-    if (ProfileMode) {\r
-      DumpAllProfile( Number2Display, ExcludeMode);\r
-    }\r
-  } else if (RawMode) {\r
-    if (TraceMode) {\r
-      Status = DumpRawTrace( Number2Display, ExcludeMode);\r
+\r
+      Status = ProcessPeims ();\r
       if (Status == EFI_ABORTED) {\r
         ShellStatus = SHELL_ABORTED;\r
         goto Done;\r
       }\r
-    }\r
-    if (ProfileMode) {\r
-      DumpRawProfile( Number2Display, ExcludeMode);\r
-    }\r
-  } else {\r
-    //------------- Begin Cooked Mode Processing\r
-    if (TraceMode) {\r
-      ProcessPhases ();\r
-      if ( ! SummaryMode) {\r
-        Status = ProcessHandles ( ExcludeMode);\r
-        if (Status == EFI_ABORTED) {\r
-          ShellStatus = SHELL_ABORTED;\r
-          goto Done;\r
-        }\r
 \r
-        Status = ProcessPeims ();\r
-        if (Status == EFI_ABORTED) {\r
-          ShellStatus = SHELL_ABORTED;\r
-          goto Done;\r
-        }\r
-\r
-        Status = ProcessGlobal ();\r
-        if (Status == EFI_ABORTED) {\r
-          ShellStatus = SHELL_ABORTED;\r
-          goto Done;\r
-        }\r
-\r
-        ProcessCumulative (NULL);\r
+      Status = ProcessGlobal ();\r
+      if (Status == EFI_ABORTED) {\r
+        ShellStatus = SHELL_ABORTED;\r
+        goto Done;\r
       }\r
-    }\r
-    if (ProfileMode) {\r
-      DumpAllProfile( Number2Display, ExcludeMode);\r
+\r
+       ProcessCumulative (NULL);\r
     }\r
   } //------------- End of Cooked Mode Processing\r
   if ( VerboseMode || SummaryMode) {\r