From 3e9de670ec3f18d0211a72d28fedb5dfce93442a Mon Sep 17 00:00:00 2001 From: Cinnamon Shia Date: Mon, 7 Mar 2016 11:23:07 +0800 Subject: [PATCH] PerformancePkg/Dp_App: Support execution break Support UEFI shell execution break. Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Cinnamon Shia Reviewed-by: Star Zeng Reviewed-by: Samer EL-Haj-Mahmoud Reviewed-by: Jaben Carsey --- PerformancePkg/Dp_App/Dp.c | 36 ++++++++++++----- PerformancePkg/Dp_App/DpInternal.h | 27 +++++++++---- PerformancePkg/Dp_App/DpTrace.c | 62 +++++++++++++++++++++++++----- 3 files changed, 99 insertions(+), 26 deletions(-) diff --git a/PerformancePkg/Dp_App/Dp.c b/PerformancePkg/Dp_App/Dp.c index e05221699c..e36a032091 100644 --- a/PerformancePkg/Dp_App/Dp.c +++ b/PerformancePkg/Dp_App/Dp.c @@ -14,7 +14,7 @@ timer information to calculate elapsed time for each measurement. Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -195,11 +195,11 @@ InitCumulativeData ( @param[in] ImageHandle The image handle. @param[in] SystemTable The system table. - + @retval EFI_SUCCESS Command completed successfully. @retval EFI_INVALID_PARAMETER Command usage error. + @retval EFI_ABORTED The user aborts the operation. @retval value Unknown error. - **/ EFI_STATUS EFIAPI @@ -443,7 +443,10 @@ InitializeDp ( ProcessCumulative (CustomCumulativeData); } else if (AllMode) { if (TraceMode) { - DumpAllTrace( Number2Display, ExcludeMode); + Status = DumpAllTrace( Number2Display, ExcludeMode); + if (Status == EFI_ABORTED) { + goto Done; + } } if (ProfileMode) { DumpAllProfile( Number2Display, ExcludeMode); @@ -451,7 +454,10 @@ InitializeDp ( } else if (RawMode) { if (TraceMode) { - DumpRawTrace( Number2Display, ExcludeMode); + Status = DumpRawTrace( Number2Display, ExcludeMode); + if (Status == EFI_ABORTED) { + goto Done; + } } if (ProfileMode) { DumpRawProfile( Number2Display, ExcludeMode); @@ -463,11 +469,21 @@ InitializeDp ( ProcessPhases ( Ticker ); if ( ! SummaryMode) { Status = ProcessHandles ( ExcludeMode); - if ( ! EFI_ERROR( Status)) { - ProcessPeims ( ); - ProcessGlobal ( ); - ProcessCumulative (NULL); + if (Status == EFI_ABORTED) { + goto Done; } + + Status = ProcessPeims (); + if (Status == EFI_ABORTED) { + goto Done; + } + + Status = ProcessGlobal (); + if (Status == EFI_ABORTED) { + goto Done; + } + + ProcessCumulative (NULL); } } if (ProfileMode) { @@ -480,6 +496,8 @@ InitializeDp ( } } +Done: + // // Free the memory allocate from HiiGetString // diff --git a/PerformancePkg/Dp_App/DpInternal.h b/PerformancePkg/Dp_App/DpInternal.h index 0e97e1e17d..53c5fb201a 100644 --- a/PerformancePkg/Dp_App/DpInternal.h +++ b/PerformancePkg/Dp_App/DpInternal.h @@ -7,7 +7,7 @@ DpUtilities.c, DpTrace.c, and DpProfile.c are included here. Copyright (c) 2009 - 2014, Intel Corporation. All rights reserved.
- (C) Copyright 2015 Hewlett Packard Enterprise Development LP
+ (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -215,8 +215,11 @@ GatherStatistics( @param[in] Limit The number of records to print. Zero is ALL. @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display. + @retval EFI_SUCCESS The operation was successful. + @retval EFI_ABORTED The user aborts the operation. + @return Others from a call to gBS->LocateHandleBuffer(). **/ -VOID +EFI_STATUS DumpAllTrace( IN UINTN Limit, IN BOOLEAN ExcludeFlag @@ -238,9 +241,11 @@ DumpAllTrace( @param[in] Limit The number of records to print. Zero is ALL. @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display. - + + @retval EFI_SUCCESS The operation was successful. + @retval EFI_ABORTED The user aborts the operation. **/ -VOID +EFI_STATUS DumpRawTrace( IN UINTN Limit, IN BOOLEAN ExcludeFlag @@ -262,8 +267,10 @@ ProcessPhases( Gather and print Handle data. @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display. - - @return Status from a call to gBS->LocateHandle(). + + @retval EFI_SUCCESS The operation was successful. + @retval EFI_ABORTED The user aborts the operation. + @return Others from a call to gBS->LocateHandleBuffer(). **/ EFI_STATUS ProcessHandles( @@ -276,8 +283,10 @@ ProcessHandles( Only prints complete PEIM records + @retval EFI_SUCCESS The operation was successful. + @retval EFI_ABORTED The user aborts the operation. **/ -VOID +EFI_STATUS ProcessPeims( VOID ); @@ -290,8 +299,10 @@ ProcessPeims( Increment TIndex for every record, even skipped ones, so that we have an indication of every measurement record taken. + @retval EFI_SUCCESS The operation was successful. + @retval EFI_ABORTED The user aborts the operation. **/ -VOID +EFI_STATUS ProcessGlobal( VOID ); diff --git a/PerformancePkg/Dp_App/DpTrace.c b/PerformancePkg/Dp_App/DpTrace.c index 632904f339..fc21cdc707 100644 --- a/PerformancePkg/Dp_App/DpTrace.c +++ b/PerformancePkg/Dp_App/DpTrace.c @@ -136,8 +136,11 @@ GatherStatistics( @param[in] Limit The number of records to print. Zero is ALL. @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display. + @retval EFI_SUCCESS The operation was successful. + @retval EFI_ABORTED The user aborts the operation. + @return Others from a call to gBS->LocateHandleBuffer(). **/ -VOID +EFI_STATUS DumpAllTrace( IN UINTN Limit, IN BOOLEAN ExcludeFlag @@ -257,12 +260,17 @@ DumpAllTrace( ElapsedTime ); } + if (ShellGetExecutionBreakFlag ()) { + Status = EFI_ABORTED; + break; + } } } if (HandleBuffer != NULL) { FreePool (HandleBuffer); } SafeFreePool ((VOID *) IncFlag); + return Status; } /** @@ -281,9 +289,11 @@ DumpAllTrace( @param[in] Limit The number of records to print. Zero is ALL. @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display. - + + @retval EFI_SUCCESS The operation was successful. + @retval EFI_ABORTED The user aborts the operation. **/ -VOID +EFI_STATUS DumpRawTrace( IN UINTN Limit, IN BOOLEAN ExcludeFlag @@ -298,6 +308,9 @@ DumpRawTrace( EFI_STRING StringPtr; EFI_STRING StringPtrUnknown; + EFI_STATUS Status; + + Status = EFI_SUCCESS; StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL); @@ -361,7 +374,12 @@ DumpRawTrace( Measurement.Module ); } + if (ShellGetExecutionBreakFlag ()) { + Status = EFI_ABORTED; + break; + } } + return Status; } /** @@ -509,8 +527,10 @@ ProcessPhases( Gather and print Handle data. @param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display. - - @return Status from a call to gBS->LocateHandle(). + + @retval EFI_SUCCESS The operation was successful. + @retval EFI_ABORTED The user aborts the operation. + @return Others from a call to gBS->LocateHandleBuffer(). **/ EFI_STATUS ProcessHandles( @@ -608,6 +628,10 @@ ProcessHandles( ); } } + if (ShellGetExecutionBreakFlag ()) { + Status = EFI_ABORTED; + break; + } } } if (HandleBuffer != NULL) { @@ -620,9 +644,11 @@ ProcessHandles( Gather and print PEIM data. Only prints complete PEIM records - + + @retval EFI_SUCCESS The operation was successful. + @retval EFI_ABORTED The user aborts the operation. **/ -VOID +EFI_STATUS ProcessPeims( VOID ) @@ -634,6 +660,9 @@ ProcessPeims( UINTN LogEntryKey; UINTN TIndex; EFI_STRING StringPtrUnknown; + EFI_STATUS Status; + + Status = EFI_SUCCESS; StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL); @@ -687,7 +716,12 @@ ProcessPeims( ); } } + if (ShellGetExecutionBreakFlag ()) { + Status = EFI_ABORTED; + break; + } } + return Status; } /** @@ -697,9 +731,11 @@ ProcessPeims( Only prints records where Handle is NULL Increment TIndex for every record, even skipped ones, so that we have an indication of every measurement record taken. - + + @retval EFI_SUCCESS The operation was successful. + @retval EFI_ABORTED The user aborts the operation. **/ -VOID +EFI_STATUS ProcessGlobal( VOID ) @@ -711,6 +747,9 @@ ProcessGlobal( UINTN LogEntryKey; UINTN Index; // Index, or number, of the measurement record being processed EFI_STRING StringPtrUnknown; + EFI_STATUS Status; + + Status = EFI_SUCCESS; StringPtrUnknown = HiiGetString (gHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtr = HiiGetString (gHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL); @@ -770,8 +809,13 @@ ProcessGlobal( } } } + if (ShellGetExecutionBreakFlag ()) { + Status = EFI_ABORTED; + break; + } Index++; } + return Status; } /**