TianoCore EDK2 master
|
#include "Shell.h"
Go to the source code of this file.
Variables | |
SHELL_INFO | ShellInfoObject |
STATIC CONST CHAR16 | mScriptExtension [] = L".NSH" |
STATIC CONST CHAR16 | mExecutableExtensions [] = L".NSH;.EFI" |
STATIC CONST CHAR16 | mStartupScript [] = L"startup.nsh" |
CONST CHAR16 | mNoNestingEnvVarName [] = L"nonesting" |
CONST CHAR16 | mNoNestingTrue [] = L"True" |
CONST CHAR16 | mNoNestingFalse [] = L"False" |
This is THE shell (application)
Copyright (c) 2009 - 2019, Intel Corporation. All rights reserved.
(C) Copyright 2013-2014 Hewlett-Packard Development Company, L.P.
Copyright 2015-2018 Dell Technologies.
Copyright (C) 2023, Apple Inc. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent
Definition in file Shell.c.
VOID * AddBufferToFreeList | ( | VOID * | Buffer | ) |
EFI_STATUS ChangeMappedDrive | ( | IN CONST CHAR16 * | CmdLine | ) |
EFI_STATUS DoHelpUpdate | ( | IN OUT CHAR16 ** | CmdLine | ) |
EFI_STATUS DoShellPrompt | ( | VOID | ) |
EFI_STATUS DoStartupScript | ( | IN EFI_DEVICE_PATH_PROTOCOL * | ImagePath, |
IN EFI_DEVICE_PATH_PROTOCOL * | FilePath | ||
) |
Handles all interaction with the default startup script.
this will check that the correct command line parameters were passed, handle the delay, and then start running the script.
ImagePath | the path to the image for shell. first place to look for the startup script |
FilePath | the path to the file for shell. second place to look for the startup script. |
EFI_SUCCESS | the variable is initialized. |
CONST CHAR16 * FindFirstCharacter | ( | IN CONST CHAR16 * | String, |
IN CONST CHAR16 * | CharacterList, | ||
IN CONST CHAR16 | EscapeCharacter | ||
) |
Return the pointer to the first occurrence of any character from a list of characters.
[in] | String | the string to parse |
[in] | CharacterList | the list of character to look for |
[in] | EscapeCharacter | An escape character to skip |
CHAR_NULL | no instance of any character in CharacterList was found in String |
CHAR16 * FindNextInstance | ( | IN CONST CHAR16 * | SourceString, |
IN CONST CHAR16 * | FindString, | ||
IN CONST BOOLEAN | CheckForEscapeCharacter | ||
) |
Parse for the next instance of one string within another string. Can optionally make sure that the string was not escaped (^ character) per the shell specification.
[in] | SourceString | The string to search within |
[in] | FindString | The string to look for |
[in] | CheckForEscapeCharacter | TRUE to skip escaped instances of FinfString, otherwise will return even escaped instances |
EFI_STATUS GetDevicePathsForImageAndFile | ( | IN OUT EFI_DEVICE_PATH_PROTOCOL ** | DevPath, |
IN OUT EFI_DEVICE_PATH_PROTOCOL ** | FilePath | ||
) |
This function will populate the 2 device path protocol parameters based on the global gImageHandle. The DevPath will point to the device path for the handle that has loaded image protocol installed on it. The FilePath will point to the device path for the file that was loaded.
[in,out] | DevPath | On a successful return the device path to the loaded image. |
[in,out] | FilePath | On a successful return the device path to the file. |
EFI_SUCCESS | The 2 device paths were successfully returned. |
other | A error from gBS->HandleProtocol. |
Takes the Argv[0] part of the command line and determine the meaning of it.
[in] | CmdName | pointer to the command line to update. |
Internal_Command | The name is an internal command. |
File_Sys_Change | the name is a file system change. |
Script_File_Name | the name is a NSH script file. |
Unknown_Invalid | the name is unknown. |
Efi_Application | the name is an application (.EFI). |
EFI_STATUS InternalEfiShellStartCtrlSMonitor | ( | VOID | ) |
Internal function to determine if 2 command names are really the same.
[in] | Command1 | The pointer to the first command name. |
[in] | Command2 | The pointer to the second command name. |
TRUE | The 2 command names are the same. |
FALSE | The 2 command names are not the same. |
BOOLEAN IsValidEnvironmentVariableName | ( | IN CONST CHAR16 * | BeginPercent, |
IN CONST CHAR16 * | EndPercent | ||
) |
Check whether the string between a pair of % is a valid environment variable name.
[in] | BeginPercent | pointer to the first percent. |
[in] | EndPercent | pointer to the last percent. |
TRUE | is a valid environment variable name. |
FALSE | is NOT a valid environment variable name. |
EFI_STATUS IsValidSplit | ( | IN CONST CHAR16 * | CmdLine | ) |
CHAR16 * LocateStartupScript | ( | IN EFI_DEVICE_PATH_PROTOCOL * | ImageDevicePath, |
IN EFI_DEVICE_PATH_PROTOCOL * | FileDevicePath | ||
) |
Function try to find location of the Startup.nsh file.
The buffer is callee allocated and should be freed by the caller.
ImageDevicePath | The path to the image for shell. first place to look for the startup script |
FileDevicePath | The path to the file for shell. second place to look for the startup script. |
NULL | No Startup.nsh file was found. |
EFI_STATUS ProcessCommandLine | ( | VOID | ) |
Process all Uefi Shell 2.0 command line options.
see Uefi Shell 2.0 section 3.2 for full details.
the command line must resemble the following:
shell.efi [ShellOpt-options] [options] [file-name [file-name-options]]
ShellOpt-options Options which control the initialization behavior of the shell. These options are read from the EFI global variable "ShellOpt" and are processed before options or file-name.
options Options which control the initialization behavior of the shell.
file-name The name of a UEFI shell application or script to be executed after initialization is complete. By default, if file-name is specified, then -nostartup is implied. Scripts are not supported by level 0.
file-name-options The command-line options that are passed to file-name when it is invoked.
This will initialize the ShellInfoObject.ShellInitSettings global variable.
EFI_SUCCESS | The variable is initialized. |
EFI_STATUS ProcessCommandLineToFinal | ( | IN OUT CHAR16 ** | CmdLine | ) |
Converts the command line to its post-processed form. this replaces variables and alias' per UEFI Shell spec.
[in,out] | CmdLine | pointer to the command line to update |
EFI_SUCCESS | The operation was successful |
EFI_OUT_OF_RESOURCES | A memory allocation failed. |
EFI_STATUS ProcessNewSplitCommandLine | ( | IN CONST CHAR16 * | CmdLine | ) |
VOID RestoreBufferList | ( | IN OUT LIST_ENTRY * | OldBufferList | ) |
EFI_STATUS RunCommand | ( | IN CONST CHAR16 * | CmdLine | ) |
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.
[in] | CmdLine | The command line to parse. |
EFI_SUCCESS | The command was completed. |
EFI_ABORTED | The command's operation was aborted. |
EFI_STATUS RunCommandOrFile | ( | IN SHELL_OPERATION_TYPES | Type, |
IN CONST CHAR16 * | CmdLine, | ||
IN CHAR16 * | FirstParameter, | ||
IN EFI_SHELL_PARAMETERS_PROTOCOL * | ParamProtocol, | ||
OUT EFI_STATUS * | CommandStatus | ||
) |
Function to run the command or file.
[in] | Type | the type of operation being run. |
[in] | CmdLine | the command line to run. |
[in] | FirstParameter | the first parameter on the command line |
[in] | ParamProtocol | the shell parameters protocol pointer |
[out] | CommandStatus | the status from the command line. |
EFI_SUCCESS | The command was completed. |
EFI_ABORTED | The command's operation was aborted. |
EFI_STATUS RunInternalCommand | ( | IN CONST CHAR16 * | CmdLine, |
IN CHAR16 * | FirstParameter, | ||
IN EFI_SHELL_PARAMETERS_PROTOCOL * | ParamProtocol, | ||
OUT EFI_STATUS * | CommandStatus | ||
) |
Run an internal shell command.
This API will update the shell's environment since these commands are libraries.
[in] | CmdLine | the command line to run. |
[in] | FirstParameter | the first parameter on the command line |
[in] | ParamProtocol | the shell parameters protocol pointer |
[out] | CommandStatus | the status from the command line. |
EFI_SUCCESS | The command was completed. |
EFI_ABORTED | The command's operation was aborted. |
EFI_STATUS RunScriptFile | ( | IN CONST CHAR16 * | ScriptPath, |
IN SHELL_FILE_HANDLE Handle | OPTIONAL, | ||
IN CONST CHAR16 * | CmdLine, | ||
IN EFI_SHELL_PARAMETERS_PROTOCOL * | ParamProtocol | ||
) |
Function to process a NSH script file.
[in] | ScriptPath | Pointer to the script file name (including file system path). |
[in] | Handle | the handle of the script file already opened. |
[in] | CmdLine | the command line to run. |
[in] | ParamProtocol | the shell parameters protocol pointer |
EFI_SUCCESS | the script completed successfully |
EFI_STATUS RunScriptFileHandle | ( | IN SHELL_FILE_HANDLE | Handle, |
IN CONST CHAR16 * | Name | ||
) |
EFI_STATUS RunShellCommand | ( | IN CONST CHAR16 * | CmdLine, |
OUT EFI_STATUS * | CommandStatus | ||
) |
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.
[in] | CmdLine | The command line to parse. |
[out] | CommandStatus | The status from the command line. |
EFI_SUCCESS | The command was completed. |
EFI_ABORTED | The command's operation was aborted. |
EFI_STATUS RunSplitCommand | ( | IN CONST CHAR16 * | CmdLine, |
IN SHELL_FILE_HANDLE | StdIn, | ||
IN SHELL_FILE_HANDLE | StdOut | ||
) |
Internal function to run a command line with pipe usage.
[in] | CmdLine | The pointer to the command line. |
[in] | StdIn | The pointer to the Standard input. |
[in] | StdOut | The pointer to the Standard output. |
EFI_SUCCESS | The split command is executed successfully. |
other | Some error occurs when executing the split command. |
VOID SaveBufferList | ( | OUT LIST_ENTRY * | OldBufferList | ) |
EFI_STATUS SetBuiltInAlias | ( | VOID | ) |
EFI_STATUS SetLastError | ( | IN CONST SHELL_STATUS | ErrorCode | ) |
EFI_STATUS SetupAndRunCommandOrFile | ( | IN SHELL_OPERATION_TYPES | Type, |
IN CHAR16 * | CmdLine, | ||
IN CHAR16 * | FirstParameter, | ||
IN EFI_SHELL_PARAMETERS_PROTOCOL * | ParamProtocol, | ||
OUT EFI_STATUS * | CommandStatus | ||
) |
Function to setup StdIn, StdErr, StdOut, and then run the command or file.
[in] | Type | the type of operation being run. |
[in] | CmdLine | the command line to run. |
[in] | FirstParameter | the first parameter on the command line. |
[in] | ParamProtocol | the shell parameters protocol pointer |
[out] | CommandStatus | the status from the command line. |
EFI_SUCCESS | The command was completed. |
EFI_ABORTED | The command's operation was aborted. |
EFI_STATUS ShellConvertAlias | ( | IN OUT CHAR16 ** | CommandString | ) |
Checks if a string is an alias for another command. If yes, then it replaces the alias name with the correct command name.
[in,out] | CommandString | Upon entry the potential alias. Upon return the command name if it was an alias. If it was not an alias it will be unchanged. This function may change the buffer to fit the command name. |
EFI_SUCCESS | The name was changed. |
EFI_SUCCESS | The name was not an alias. |
EFI_OUT_OF_RESOURCES | A memory allocation failed. |
Function allocates a new command line and replaces all instances of environment variable names that are correctly preset to their values.
If the return value is not NULL the memory must be caller freed.
[in] | OriginalCommandLine | The original command line |
NULL | An error occurred. |
EFI_STATUS ShellSubstituteAliases | ( | IN CHAR16 ** | CmdLine | ) |
Take the original command line, substitute any alias in the first group of space delimited characters, free the original string, return the modified copy.
[in] | CmdLine | pointer to the command line to update. |
EFI_SUCCESS | the function was successful. |
EFI_OUT_OF_RESOURCES | a memory allocation failed. |
EFI_STATUS ShellSubstituteVariables | ( | IN CHAR16 ** | CmdLine | ) |
Take the original command line, substitute any variables, free the original string, return the modified copy.
[in] | CmdLine | pointer to the command line to update. |
EFI_SUCCESS | the function was successful. |
EFI_OUT_OF_RESOURCES | a memory allocation failed. |
EFI_STATUS StripUnreplacedEnvironmentVariables | ( | IN OUT CHAR16 * | CmdLine | ) |
EFI_STATUS TrimSpaces | ( | IN CHAR16 ** | String | ) |
EFI_STATUS EFIAPI UefiMain | ( | IN EFI_HANDLE | ImageHandle, |
IN EFI_SYSTEM_TABLE * | SystemTable | ||
) |
The entry point for the application.
[in] | ImageHandle | The firmware allocated handle for the EFI image. |
[in] | SystemTable | A pointer to the EFI System Table. |
EFI_SUCCESS | The entry point is executed successfully. |
other | Some error occurs when executing this entry point. |
EFI_STATUS VerifySplit | ( | IN CONST CHAR16 * | CmdLine | ) |
Determine if a command line contains with a split contains only valid commands.
[in] | CmdLine | The command line to parse. |
EFI_SUCCESS | CmdLine has only valid commands, application, or has no split. |
EFI_ABORTED | CmdLine has at least one invalid command or application. |
SHELL_INFO ShellInfoObject |