]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/DynamicCommand/DpDynamicCommand/Dp.c
ShellPkg/Dp: Initialize summary date when run DP
[mirror_edk2.git] / ShellPkg / DynamicCommand / DpDynamicCommand / Dp.c
index fafc64fe2d950902936f91e396798e8ece8e9922..d8451dbf59fa9f78160ca9ee540f60b112b37093 100644 (file)
@@ -257,7 +257,8 @@ GetBootPerformanceTable (
                &AcpiTable\r
                  );\r
   }\r
-  if (EFI_ERROR(Status)) {\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 +267,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 +392,7 @@ BuildCachedGuidHandleTable (
     FreePool (HandleBuffer);\r
     HandleBuffer = NULL;\r
   }\r
-  return Status;\r
+  return EFI_SUCCESS;\r
 }\r
 \r
 /**\r
@@ -672,6 +674,24 @@ 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.NumProfile    = 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
@@ -729,36 +749,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
@@ -810,11 +800,48 @@ RunDp (
 #endif  // PROFILING_IMPLEMENTED\r
   }\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
+    ShellStatus = Status;\r
+    goto Done;\r
+  }\r
+\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
   // Initialize the pre-defined cumulative data.\r
   //\r
   InitCumulativeData ();\r
 \r
+  //\r
+  // Initialize the Summary data.\r
+  //\r
+  InitSummaryData ();\r
+\r
   //\r
   // Init the custom cumulative data.\r
   //\r
@@ -822,7 +849,8 @@ RunDp (
   if (CustomCumulativeToken != NULL) {\r
     CustomCumulativeData = AllocateZeroPool (sizeof (PERF_CUM_DATA));\r
     if (CustomCumulativeData == NULL) {\r
-      return SHELL_OUT_OF_RESOURCES;\r
+      ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+      goto Done;\r
     }\r
     CustomCumulativeData->MinDur = PERF_MAXDUR;\r
     CustomCumulativeData->MaxDur = 0;\r
@@ -831,8 +859,8 @@ RunDp (
     NameSize = StrLen (CustomCumulativeToken) + 1;\r
     CustomCumulativeData->Name   = AllocateZeroPool (NameSize);\r
     if (CustomCumulativeData->Name == NULL) {\r
-      FreePool (CustomCumulativeData);\r
-      return SHELL_OUT_OF_RESOURCES;\r
+      ShellStatus = SHELL_OUT_OF_RESOURCES;\r
+      goto Done;\r
     }\r
     UnicodeStrToAsciiStrS (CustomCumulativeToken, CustomCumulativeData->Name, NameSize);\r
   }\r