Roll back check in r15180 which caused the shell always returns EFI_ABORTED no matter what exit-code is specified for "exit" command.

Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Ruiyu Ni <ruiyu.ni@intel.com>
Reviewed-by: Carsey Jaben <jaben.carsey@intel.com>

git-svn-id: https://svn.code.sf.net/p/edk2/code/trunk/edk2@16127 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
Ruiyu Ni
2014-09-18 01:58:03 +00:00
committed by niruiyu
parent 4b6b543e77
commit a308e0588b
4 changed files with 59 additions and 242 deletions

View File

@ -1401,8 +1401,6 @@ EfiShellEnablePageBreak (
is NULL, then the current shell environment is used.
@param[out] StartImageStatus Returned status from gBS->StartImage.
@param[out] ExitDataSize ExitDataSize as returned from gBS->StartImage
@param[out] ExitData ExitData as returned from gBS->StartImage
@retval EFI_SUCCESS The command executed successfully. The status code
returned by the command is pointed to by StatusCode.
@ -1417,9 +1415,7 @@ InternalShellExecuteDevicePath(
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN CONST CHAR16 *CommandLine OPTIONAL,
IN CONST CHAR16 **Environment OPTIONAL,
OUT EFI_STATUS *StartImageStatus OPTIONAL,
OUT UINTN *ExitDataSize OPTIONAL,
OUT CHAR16 **ExitData OPTIONAL
OUT EFI_STATUS *StartImageStatus OPTIONAL
)
{
EFI_STATUS Status;
@ -1429,21 +1425,11 @@ InternalShellExecuteDevicePath(
EFI_LOADED_IMAGE_PROTOCOL *LoadedImage;
LIST_ENTRY OrigEnvs;
EFI_SHELL_PARAMETERS_PROTOCOL ShellParamsProtocol;
UINTN InternalExitDataSize;
UINTN *ExitDataSizePtr;
CHAR16 *ImagePath;
UINTN Index;
CHAR16 *Walker;
CHAR16 *NewCmdLine;
// ExitDataSize is not OPTIONAL for gBS->BootServices, provide somewhere for
// it to be dumped if the caller doesn't want it.
if (ExitData == NULL) {
ExitDataSizePtr = &InternalExitDataSize;
} else {
ExitDataSizePtr = ExitDataSize;
}
if (ParentImageHandle == NULL) {
return (EFI_INVALID_PARAMETER);
}
@ -1547,13 +1533,13 @@ InternalShellExecuteDevicePath(
///@todo initialize and install ShellInterface protocol on the new image for compatibility if - PcdGetBool(PcdShellSupportOldProtocols)
//
// now start the image, passing up exit data if the caller requested it
// now start the image and if the caller wanted the return code pass it to them...
//
if (!EFI_ERROR(Status)) {
StartStatus = gBS->StartImage(
NewHandle,
ExitDataSizePtr,
ExitData
0,
NULL
);
if (StartImageStatus != NULL) {
*StartImageStatus = StartStatus;
@ -1642,8 +1628,6 @@ EfiShellExecute(
CHAR16 *Temp;
EFI_DEVICE_PATH_PROTOCOL *DevPath;
UINTN Size;
UINTN ExitDataSize;
CHAR16 *ExitData;
if ((PcdGet8(PcdShellSupportLevel) < 1)) {
return (EFI_UNSUPPORTED);
@ -1671,32 +1655,7 @@ EfiShellExecute(
DevPath,
Temp,
(CONST CHAR16**)Environment,
StatusCode,
&ExitDataSize,
&ExitData);
if (Status == EFI_ABORTED) {
// If the command exited with an error, the shell should put the exit
// status in ExitData, preceded by a null-terminated string.
ASSERT (ExitDataSize == StrSize (ExitData) + sizeof (SHELL_STATUS));
if (StatusCode != NULL) {
// Skip the null-terminated string
ExitData += StrLen (ExitData) + 1;
// Use CopyMem to avoid alignment faults
CopyMem (StatusCode, ExitData, sizeof (SHELL_STATUS));
// Convert from SHELL_STATUS to EFI_STATUS
// EFI_STATUSes have top bit set when they are errors.
// (See UEFI Spec Appendix D)
if (*StatusCode != SHELL_SUCCESS) {
*StatusCode = (EFI_STATUS) *StatusCode | MAX_BIT;
}
}
FreePool (ExitData);
Status = EFI_SUCCESS;
}
StatusCode);
//
// de-allocate and return