/**
Function will process and run a command line.
This will determine if the command line represents an internal shell
command or dispatch an external application.
@param[in] CmdLine The command line to parse.
@param[out] CommandStatus The status from the command line.
@retval EFI_SUCCESS The command was completed.
@retval EFI_ABORTED The command's operation was aborted.
**/
EFI_STATUS
RunShellCommand(
IN CONST CHAR16 *CmdLine,
OUT EFI_STATUS *CommandStatus
)
case Efi_Application:
Status = SetupAndRunCommandOrFile(Type, CleanOriginal, FirstParameter, ShellInfoObject.NewShellParametersProtocol, CommandStatus);
break;
/**
internal worker function to load and run an image via device path.
@param ParentImageHandle A handle of the image that is executing the specified
command line.
@param DevicePath device path of the file to execute
@param CommandLine Points to the NULL-terminated UCS-2 encoded string
containing the command line. If NULL then the command-
line will be empty.
@param Environment Points to a NULL-terminated array of environment
variables with the format 'x=y', where x is the
environment variable name and y is the value. If this
is NULL, then the current shell environment is used.
@param[out] StartImageStatus Returned status from gBS->StartImage.
@retval EFI_SUCCESS The command executed successfully. The status code
returned by the command is pointed to by StatusCode.
@retval EFI_INVALID_PARAMETER The parameters are invalid.
@retval EFI_OUT_OF_RESOURCES Out of resources.
@retval EFI_UNSUPPORTED Nested shell invocations are not allowed.
**/
EFI_STATUS
InternalShellExecuteDevicePath(
IN CONST EFI_HANDLE *ParentImageHandle,
IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
IN CONST CHAR16 *CommandLine OPTIONAL,
IN CONST CHAR16 **Environment OPTIONAL,
OUT EFI_STATUS *StartImageStatus OPTIONAL
)
....
Status = gBS->InstallProtocolInterface(&NewHandle, &gEfiShellParametersProtocolGuid, EFI_NATIVE_INTERFACE, &ShellParamsProtocol);
ASSERT_EFI_ERROR(Status);
///@todo initialize and install ShellInterface protocol on the new image for compatibility if - PcdGetBool(PcdShellSupportOldProtocols)
//
// now start the image and if the caller wanted the return code pass it to them...
//
if (!EFI_ERROR(Status)) {
StartStatus = gBS->StartImage(
NewHandle,
0,
NULL
);
if (StartImageStatus != NULL) {
*StartImageStatus = StartStatus;
}
CleanupStatus = gBS->UninstallProtocolInterface(
NewHandle,
&gEfiShellParametersProtocolGuid,
&ShellParamsProtocol
);
ASSERT_EFI_ERROR(CleanupStatus);
goto FreeAlloc;
}