]> git.proxmox.com Git - mirror_edk2.git/commitdiff
ShellPkg/UefiDpLib: Support execution break
authorCinnamon Shia <cinnamon.shia@hpe.com>
Mon, 7 Mar 2016 03:23:08 +0000 (11:23 +0800)
committerStar Zeng <star.zeng@intel.com>
Tue, 8 Mar 2016 10:23:53 +0000 (18:23 +0800)
Support UEFI shell execution break.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Cinnamon Shia <cinnamon.shia@hpe.com>
Reviewed-by: Star Zeng <star.zeng@intel.com>
Reviewed-by: Samer EL-Haj-Mahmoud <elhaj@hpe.com>
Reviewed-by: Jaben Carsey <jaben.carsey@intel.com>
ShellPkg/Library/UefiDpLib/Dp.c
ShellPkg/Library/UefiDpLib/DpInternal.h
ShellPkg/Library/UefiDpLib/DpTrace.c
ShellPkg/Library/UefiDpLib/UefiDpLib.h

index 6b06d20749f29c3bc695abd99880fa294061456e..0176e31bc0d6624ad0371b3ecb01b181d69c9beb 100644 (file)
@@ -14,7 +14,7 @@
   timer information to calculate elapsed time for each measurement.\r
  \r
   Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.\r
-  (C) Copyright 2015 Hewlett Packard Enterprise Development LP<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
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -137,10 +137,10 @@ InitCumulativeData (
   @param[in]  ImageHandle     The image handle.\r
   @param[in]  SystemTable     The system table.\r
   \r
-  @retval EFI_SUCCESS            Command completed successfully.\r
-  @retval EFI_INVALID_PARAMETER  Command usage error.\r
-  @retval value                  Unknown error.\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
+  @retval value                    Unknown error.\r
 **/\r
 SHELL_STATUS\r
 EFIAPI\r
@@ -168,6 +168,7 @@ ShellCommandRunDp (
   BOOLEAN                   CumulativeMode;\r
   CONST CHAR16              *CustomCumulativeToken;\r
   PERF_CUM_DATA             *CustomCumulativeData;\r
+  SHELL_STATUS              ShellStatus;\r
 \r
   StringPtr   = NULL;\r
   SummaryMode = FALSE;\r
@@ -179,6 +180,7 @@ ShellCommandRunDp (
   ExcludeMode = FALSE;\r
   CumulativeMode = FALSE;\r
   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
@@ -329,14 +331,22 @@ ShellCommandRunDp (
     ProcessCumulative (CustomCumulativeData);\r
   } else if (AllMode) {\r
     if (TraceMode) {\r
-      DumpAllTrace( Number2Display, ExcludeMode);\r
+      Status = DumpAllTrace( Number2Display, 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
-      DumpRawTrace( Number2Display, ExcludeMode);\r
+      Status = DumpRawTrace( Number2Display, ExcludeMode);\r
+      if (Status == EFI_ABORTED) {\r
+        ShellStatus = SHELL_ABORTED;\r
+        goto Done;\r
+      }\r
     }\r
     if (ProfileMode) {\r
       DumpRawProfile( Number2Display, ExcludeMode);\r
@@ -347,11 +357,24 @@ ShellCommandRunDp (
       ProcessPhases ( Ticker );\r
       if ( ! SummaryMode) {\r
         Status = ProcessHandles ( ExcludeMode);\r
-        if ( ! EFI_ERROR( Status)) {\r
-          ProcessPeims ();\r
-          ProcessGlobal ();\r
-          ProcessCumulative (NULL);\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
       }\r
     }\r
     if (ProfileMode) {\r
@@ -362,11 +385,12 @@ ShellCommandRunDp (
     DumpStatistics();\r
   }\r
 \r
+Done:\r
   SHELL_FREE_NON_NULL (StringPtr);\r
   if (CustomCumulativeData != NULL) {\r
     SHELL_FREE_NON_NULL (CustomCumulativeData->Name);\r
   }\r
   SHELL_FREE_NON_NULL (CustomCumulativeData);\r
 \r
-  return SHELL_SUCCESS;\r
+  return ShellStatus;\r
 }\r
index aa07fea8c21d4512a5cb5236617aa1186a1d716e..b5ec5f0401c0b53006e3582c205511273b674452 100644 (file)
@@ -7,7 +7,7 @@
   DpUtilities.c, DpTrace.c, and DpProfile.c are included here.\r
 \r
   Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.\r
-  (C) Copyright 2015 Hewlett Packard Enterprise Development LP<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
   which accompanies this distribution.  The full text of the license may be found at\r
@@ -198,8 +198,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
@@ -221,9 +224,10 @@ 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
+  @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
@@ -246,7 +250,9 @@ ProcessPhases(
   \r
   @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items from display.\r
   \r
-  @return       Status from a call to gBS->LocateHandle().\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
@@ -259,8 +265,10 @@ ProcessHandles(
   \r
   Only prints complete PEIM records\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
@@ -273,8 +281,10 @@ ProcessPeims(
   Increment TIndex for every record, even skipped ones, so that we have an\r
   indication of every measurement record taken.\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
index 22b83d0917dfc2267a53dcff64f0a59ca2835b70..c1074d5b7a0465e39718196ca33095cf5e60067e 100644 (file)
@@ -136,8 +136,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
@@ -257,12 +260,18 @@ 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
   SHELL_FREE_NON_NULL (IncFlag);\r
+\r
+  return Status;\r
 }\r
 \r
 /** \r
@@ -281,9 +290,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 +309,9 @@ DumpRawTrace(
 \r
   EFI_STRING    StringPtr;\r
   EFI_STRING    StringPtrUnknown;\r
+  EFI_STATUS    Status;\r
+\r
+  Status = EFI_SUCCESS;\r
 \r
   StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);  \r
   StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);\r
@@ -361,7 +375,12 @@ DumpRawTrace(
         Measurement.Module\r
       );\r
     }\r
+    if (ShellGetExecutionBreakFlag ()) {\r
+      Status = EFI_ABORTED;\r
+      break;\r
+    }\r
   }\r
+  return Status;\r
 }\r
 \r
 /** \r
@@ -510,7 +529,9 @@ ProcessPhases(
   \r
   @param[in]    ExcludeFlag   TRUE to exclude individual Cumulative items from display.\r
   \r
-  @return       Status from a call to gBS->LocateHandle().\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
@@ -606,6 +627,10 @@ ProcessHandles(
           );\r
         }\r
       }\r
+      if (ShellGetExecutionBreakFlag ()) {\r
+        Status = EFI_ABORTED;\r
+        break;\r
+      }\r
     }\r
   }\r
   if (HandleBuffer != NULL) {\r
@@ -619,8 +644,10 @@ ProcessHandles(
   \r
   Only prints complete PEIM records\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
@@ -632,6 +659,9 @@ ProcessPeims(
   UINTN                     LogEntryKey;\r
   UINTN                     TIndex;\r
   EFI_STRING                StringPtrUnknown;\r
+  EFI_STATUS                Status;\r
+\r
+  Status = EFI_SUCCESS;\r
 \r
   StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);  \r
   StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);\r
@@ -685,7 +715,12 @@ ProcessPeims(
         );\r
       }\r
     }\r
+    if (ShellGetExecutionBreakFlag ()) {\r
+      Status = EFI_ABORTED;\r
+      break;\r
+    }\r
   }\r
+  return Status;\r
 }\r
 \r
 /** \r
@@ -696,8 +731,10 @@ ProcessPeims(
   Increment TIndex for every record, even skipped ones, so that we have an\r
   indication of every measurement record taken.\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
@@ -709,6 +746,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 (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);  \r
   StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);\r
@@ -766,8 +806,13 @@ ProcessGlobal(
         }\r
       }\r
     }\r
+    if (ShellGetExecutionBreakFlag ()) {\r
+      Status = EFI_ABORTED;\r
+      break;\r
+    }\r
     Index++;\r
   }\r
+  return Status;  //*HP_ISS_EDK2_CONTRIUTION\r
 }\r
 \r
 /** \r
index d16f55fe02ff9b55e4d65acffeeeea36dfb63d89..3dd9ddf9ffaf6cce748d4eca8b5ec612533452d9 100644 (file)
@@ -2,6 +2,7 @@
   Main file for NULL named library for dp command functions.\r
 \r
   Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 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
@@ -47,6 +48,11 @@ extern        EFI_HANDLE                        gDpHiiHandle;
 \r
   @param[in] ImageHandle  Handle to the Image (NULL if Internal).\r
   @param[in] SystemTable  Pointer to the System Table (NULL if Internal).\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
+  @retval value                    Unknown error.\r
 **/\r
 SHELL_STATUS\r
 EFIAPI\r