ShellPkg/UefiDpLib: Support execution break

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>
This commit is contained in:
Cinnamon Shia 2016-03-07 11:23:08 +08:00 committed by Star Zeng
parent 3e9de670ec
commit 196ccda08f
4 changed files with 110 additions and 25 deletions

View File

@ -14,7 +14,7 @@
timer information to calculate elapsed time for each measurement. timer information to calculate elapsed time for each measurement.
Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved. Copyright (c) 2009 - 2015, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR> (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -137,10 +137,10 @@ InitCumulativeData (
@param[in] ImageHandle The image handle. @param[in] ImageHandle The image handle.
@param[in] SystemTable The system table. @param[in] SystemTable The system table.
@retval EFI_SUCCESS Command completed successfully. @retval SHELL_SUCCESS Command completed successfully.
@retval EFI_INVALID_PARAMETER Command usage error. @retval SHELL_INVALID_PARAMETER Command usage error.
@retval SHELL_ABORTED The user aborts the operation.
@retval value Unknown error. @retval value Unknown error.
**/ **/
SHELL_STATUS SHELL_STATUS
EFIAPI EFIAPI
@ -168,6 +168,7 @@ ShellCommandRunDp (
BOOLEAN CumulativeMode; BOOLEAN CumulativeMode;
CONST CHAR16 *CustomCumulativeToken; CONST CHAR16 *CustomCumulativeToken;
PERF_CUM_DATA *CustomCumulativeData; PERF_CUM_DATA *CustomCumulativeData;
SHELL_STATUS ShellStatus;
StringPtr = NULL; StringPtr = NULL;
SummaryMode = FALSE; SummaryMode = FALSE;
@ -179,6 +180,7 @@ ShellCommandRunDp (
ExcludeMode = FALSE; ExcludeMode = FALSE;
CumulativeMode = FALSE; CumulativeMode = FALSE;
CustomCumulativeData = NULL; CustomCumulativeData = NULL;
ShellStatus = SHELL_SUCCESS;
// Get DP's entry time as soon as possible. // Get DP's entry time as soon as possible.
// This is used as the Shell-Phase end time. // This is used as the Shell-Phase end time.
@ -329,14 +331,22 @@ ShellCommandRunDp (
ProcessCumulative (CustomCumulativeData); ProcessCumulative (CustomCumulativeData);
} else if (AllMode) { } else if (AllMode) {
if (TraceMode) { if (TraceMode) {
DumpAllTrace( Number2Display, ExcludeMode); Status = DumpAllTrace( Number2Display, ExcludeMode);
if (Status == EFI_ABORTED) {
ShellStatus = SHELL_ABORTED;
goto Done;
}
} }
if (ProfileMode) { if (ProfileMode) {
DumpAllProfile( Number2Display, ExcludeMode); DumpAllProfile( Number2Display, ExcludeMode);
} }
} else if (RawMode) { } else if (RawMode) {
if (TraceMode) { if (TraceMode) {
DumpRawTrace( Number2Display, ExcludeMode); Status = DumpRawTrace( Number2Display, ExcludeMode);
if (Status == EFI_ABORTED) {
ShellStatus = SHELL_ABORTED;
goto Done;
}
} }
if (ProfileMode) { if (ProfileMode) {
DumpRawProfile( Number2Display, ExcludeMode); DumpRawProfile( Number2Display, ExcludeMode);
@ -347,11 +357,24 @@ ShellCommandRunDp (
ProcessPhases ( Ticker ); ProcessPhases ( Ticker );
if ( ! SummaryMode) { if ( ! SummaryMode) {
Status = ProcessHandles ( ExcludeMode); Status = ProcessHandles ( ExcludeMode);
if ( ! EFI_ERROR( Status)) { if (Status == EFI_ABORTED) {
ProcessPeims (); ShellStatus = SHELL_ABORTED;
ProcessGlobal (); goto Done;
ProcessCumulative (NULL);
} }
Status = ProcessPeims ();
if (Status == EFI_ABORTED) {
ShellStatus = SHELL_ABORTED;
goto Done;
}
Status = ProcessGlobal ();
if (Status == EFI_ABORTED) {
ShellStatus = SHELL_ABORTED;
goto Done;
}
ProcessCumulative (NULL);
} }
} }
if (ProfileMode) { if (ProfileMode) {
@ -362,11 +385,12 @@ ShellCommandRunDp (
DumpStatistics(); DumpStatistics();
} }
Done:
SHELL_FREE_NON_NULL (StringPtr); SHELL_FREE_NON_NULL (StringPtr);
if (CustomCumulativeData != NULL) { if (CustomCumulativeData != NULL) {
SHELL_FREE_NON_NULL (CustomCumulativeData->Name); SHELL_FREE_NON_NULL (CustomCumulativeData->Name);
} }
SHELL_FREE_NON_NULL (CustomCumulativeData); SHELL_FREE_NON_NULL (CustomCumulativeData);
return SHELL_SUCCESS; return ShellStatus;
} }

View File

@ -7,7 +7,7 @@
DpUtilities.c, DpTrace.c, and DpProfile.c are included here. DpUtilities.c, DpTrace.c, and DpProfile.c are included here.
Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved. Copyright (c) 2009 - 2013, Intel Corporation. All rights reserved.
(C) Copyright 2015 Hewlett Packard Enterprise Development LP<BR> (C) Copyright 2015-2016 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -198,8 +198,11 @@ GatherStatistics(
@param[in] Limit The number of records to print. Zero is ALL. @param[in] Limit The number of records to print. Zero is ALL.
@param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display. @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( DumpAllTrace(
IN UINTN Limit, IN UINTN Limit,
IN BOOLEAN ExcludeFlag IN BOOLEAN ExcludeFlag
@ -221,9 +224,10 @@ DumpAllTrace(
@param[in] Limit The number of records to print. Zero is ALL. @param[in] Limit The number of records to print. Zero is ALL.
@param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display. @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( DumpRawTrace(
IN UINTN Limit, IN UINTN Limit,
IN BOOLEAN ExcludeFlag IN BOOLEAN ExcludeFlag
@ -246,7 +250,9 @@ ProcessPhases(
@param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display. @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 EFI_STATUS
ProcessHandles( ProcessHandles(
@ -259,8 +265,10 @@ ProcessHandles(
Only prints complete PEIM records Only prints complete PEIM records
@retval EFI_SUCCESS The operation was successful.
@retval EFI_ABORTED The user aborts the operation.
**/ **/
VOID EFI_STATUS
ProcessPeims( ProcessPeims(
VOID VOID
); );
@ -273,8 +281,10 @@ ProcessPeims(
Increment TIndex for every record, even skipped ones, so that we have an Increment TIndex for every record, even skipped ones, so that we have an
indication of every measurement record taken. 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( ProcessGlobal(
VOID VOID
); );

View File

@ -136,8 +136,11 @@ GatherStatistics(
@param[in] Limit The number of records to print. Zero is ALL. @param[in] Limit The number of records to print. Zero is ALL.
@param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display. @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( DumpAllTrace(
IN UINTN Limit, IN UINTN Limit,
IN BOOLEAN ExcludeFlag IN BOOLEAN ExcludeFlag
@ -257,12 +260,18 @@ DumpAllTrace(
ElapsedTime ElapsedTime
); );
} }
if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED;
break;
}
} }
} }
if (HandleBuffer != NULL) { if (HandleBuffer != NULL) {
FreePool (HandleBuffer); FreePool (HandleBuffer);
} }
SHELL_FREE_NON_NULL (IncFlag); SHELL_FREE_NON_NULL (IncFlag);
return Status;
} }
/** /**
@ -282,8 +291,10 @@ DumpAllTrace(
@param[in] Limit The number of records to print. Zero is ALL. @param[in] Limit The number of records to print. Zero is ALL.
@param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display. @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( DumpRawTrace(
IN UINTN Limit, IN UINTN Limit,
IN BOOLEAN ExcludeFlag IN BOOLEAN ExcludeFlag
@ -298,6 +309,9 @@ DumpRawTrace(
EFI_STRING StringPtr; EFI_STRING StringPtr;
EFI_STRING StringPtrUnknown; EFI_STRING StringPtrUnknown;
EFI_STATUS Status;
Status = EFI_SUCCESS;
StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL); StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_RAWTRACE), NULL);
@ -361,8 +375,13 @@ DumpRawTrace(
Measurement.Module Measurement.Module
); );
} }
if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED;
break;
} }
} }
return Status;
}
/** /**
Gather and print Major Phase metrics. Gather and print Major Phase metrics.
@ -510,7 +529,9 @@ ProcessPhases(
@param[in] ExcludeFlag TRUE to exclude individual Cumulative items from display. @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 EFI_STATUS
ProcessHandles( ProcessHandles(
@ -606,6 +627,10 @@ ProcessHandles(
); );
} }
} }
if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED;
break;
}
} }
} }
if (HandleBuffer != NULL) { if (HandleBuffer != NULL) {
@ -619,8 +644,10 @@ ProcessHandles(
Only prints complete PEIM records Only prints complete PEIM records
@retval EFI_SUCCESS The operation was successful.
@retval EFI_ABORTED The user aborts the operation.
**/ **/
VOID EFI_STATUS
ProcessPeims( ProcessPeims(
VOID VOID
) )
@ -632,6 +659,9 @@ ProcessPeims(
UINTN LogEntryKey; UINTN LogEntryKey;
UINTN TIndex; UINTN TIndex;
EFI_STRING StringPtrUnknown; EFI_STRING StringPtrUnknown;
EFI_STATUS Status;
Status = EFI_SUCCESS;
StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL); StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_PEIMS), NULL);
@ -685,8 +715,13 @@ ProcessPeims(
); );
} }
} }
if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED;
break;
} }
} }
return Status;
}
/** /**
Gather and print global data. Gather and print global data.
@ -696,8 +731,10 @@ ProcessPeims(
Increment TIndex for every record, even skipped ones, so that we have an Increment TIndex for every record, even skipped ones, so that we have an
indication of every measurement record taken. 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( ProcessGlobal(
VOID VOID
) )
@ -709,6 +746,9 @@ ProcessGlobal(
UINTN LogEntryKey; UINTN LogEntryKey;
UINTN Index; // Index, or number, of the measurement record being processed UINTN Index; // Index, or number, of the measurement record being processed
EFI_STRING StringPtrUnknown; EFI_STRING StringPtrUnknown;
EFI_STATUS Status;
Status = EFI_SUCCESS;
StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL); StringPtrUnknown = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_ALIT_UNKNOWN), NULL);
StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL); StringPtr = HiiGetString (gDpHiiHandle, STRING_TOKEN (STR_DP_SECTION_GENERAL), NULL);
@ -766,8 +806,13 @@ ProcessGlobal(
} }
} }
} }
if (ShellGetExecutionBreakFlag ()) {
Status = EFI_ABORTED;
break;
}
Index++; Index++;
} }
return Status; //*HP_ISS_EDK2_CONTRIUTION
} }
/** /**

View File

@ -2,6 +2,7 @@
Main file for NULL named library for dp command functions. Main file for NULL named library for dp command functions.
Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR> Copyright (c) 2010 - 2013, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License 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 which accompanies this distribution. The full text of the license may be found at
@ -47,6 +48,11 @@ extern EFI_HANDLE gDpHiiHandle;
@param[in] ImageHandle Handle to the Image (NULL if Internal). @param[in] ImageHandle Handle to the Image (NULL if Internal).
@param[in] SystemTable Pointer to the System Table (NULL if Internal). @param[in] SystemTable Pointer to the System Table (NULL if Internal).
@retval SHELL_SUCCESS Command completed successfully.
@retval SHELL_INVALID_PARAMETER Command usage error.
@retval SHELL_ABORTED The user aborts the operation.
@retval value Unknown error.
**/ **/
SHELL_STATUS SHELL_STATUS
EFIAPI EFIAPI