TianoCore EDK2 master
Loading...
Searching...
No Matches
Shell.h File Reference

Go to the source code of this file.

Data Structures

struct  SPLIT_LIST
 
struct  SHELL_BITS
 
union  SHELL_BIT_UNION
 
struct  SHELL_INIT_SETTINGS
 
struct  SHELL_VIEWING_SETTINGS
 
struct  SHELL_INFO
 
struct  SHELL_MAN_HII_VENDOR_DEVICE_PATH
 

Functions

EFI_STATUS ProcessCommandLineToFinal (IN OUT CHAR16 **CmdLine)
 
EFI_STATUS SetLastError (IN CONST SHELL_STATUS ErrorCode)
 
EFI_STATUS SetBuiltInAlias (VOID)
 
EFI_STATUS GetDevicePathsForImageAndFile (IN OUT EFI_DEVICE_PATH_PROTOCOL **DevPath, IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath)
 
EFI_STATUS ProcessCommandLine (VOID)
 
EFI_STATUS DoStartupScript (IN EFI_DEVICE_PATH_PROTOCOL *ImagePath, IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
 
EFI_STATUS DoShellPrompt (VOID)
 
VOID * AddBufferToFreeList (VOID *Buffer)
 
VOID AddLineToCommandHistory (IN CONST CHAR16 *Buffer)
 
EFI_STATUS RunCommand (IN CONST CHAR16 *CmdLine)
 
EFI_STATUS RunShellCommand (IN CONST CHAR16 *CmdLine, OUT EFI_STATUS *CommandStatus)
 
EFI_STATUS RunScriptFileHandle (IN SHELL_FILE_HANDLE Handle, IN CONST CHAR16 *Name)
 
EFI_STATUS RunScriptFile (IN CONST CHAR16 *ScriptPath, IN SHELL_FILE_HANDLE Handle OPTIONAL, IN CONST CHAR16 *CmdLine, IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol)
 
CONST CHAR16 * FindFirstCharacter (IN CONST CHAR16 *String, IN CONST CHAR16 *CharacterList, IN CONST CHAR16 EscapeCharacter)
 
EFI_STATUS TrimSpaces (IN CHAR16 **String)
 
VOID SaveBufferList (OUT LIST_ENTRY *OldBufferList)
 
VOID RestoreBufferList (IN OUT LIST_ENTRY *OldBufferList)
 

Variables

CONST CHAR16 mNoNestingEnvVarName []
 
CONST CHAR16 mNoNestingTrue []
 
CONST CHAR16 mNoNestingFalse []
 
SHELL_INFO ShellInfoObject
 

Detailed Description

function definitions for internal to shell functions.

(C) Copyright 2014 Hewlett-Packard Development Company, L.P.
Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file Shell.h.

Function Documentation

◆ AddBufferToFreeList()

VOID * AddBufferToFreeList ( VOID *  Buffer)

Add a buffer to the Buffer To Free List for safely returning buffers to other places without risking letting them modify internal shell information.

Parameters
BufferSomething to pass to FreePool when the shell is exiting.

Definition at line 1480 of file Shell.c.

◆ AddLineToCommandHistory()

VOID AddLineToCommandHistory ( IN CONST CHAR16 *  Buffer)

Add a buffer to the Command History List.

Parameters
Buffer[in]The line buffer to add.

Add a buffer to the Line History List

Parameters
BufferThe line buffer to add.

Definition at line 1534 of file Shell.c.

◆ DoShellPrompt()

EFI_STATUS DoShellPrompt ( VOID  )

Function to perform the shell prompt looping. It will do a single prompt, dispatch the result, and then return. It is expected that the caller will call this function in a loop many times.

Return values
EFI_SUCCESS
RETURN_ABORTED

Definition at line 1409 of file Shell.c.

◆ DoStartupScript()

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.

Parameters
[in]ImagePathThe path to the image for shell. The first place to look for the startup script.
[in]FilePathThe path to the file for shell. The second place to look for the startup script.
Return values
EFI_SUCCESSThe variable is initialized.

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.

Parameters
ImagePaththe path to the image for shell. first place to look for the startup script
FilePaththe path to the file for shell. second place to look for the startup script.
Return values
EFI_SUCCESSthe variable is initialized.

Definition at line 1296 of file Shell.c.

◆ FindFirstCharacter()

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.

Parameters
[in]Stringthe string to parse
[in]CharacterListthe list of character to look for
[in]EscapeCharacterAn escape character to skip
Returns
the location of the first character in the string
Return values
CHAR_NULLno instance of any character in CharacterList was found in String

Definition at line 3337 of file Shell.c.

◆ GetDevicePathsForImageAndFile()

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.

Parameters
[in,out]DevPathon a successful return the device path to the loaded image
[in,out]FilePathon a successful return the device path to the file
Return values
EFI_SUCCESSthe 2 device paths were successfully returned.
Returns
other a error from gBS->HandleProtocol
See also
HandleProtocol

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.

Parameters
[in,out]DevPathOn a successful return the device path to the loaded image.
[in,out]FilePathOn a successful return the device path to the file.
Return values
EFI_SUCCESSThe 2 device paths were successfully returned.
otherA error from gBS->HandleProtocol.
See also
HandleProtocol

Definition at line 876 of file Shell.c.

◆ ProcessCommandLine()

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 should 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-nameoptions The command-line options that are passed to file-name when it is invoked.

This will initialize the ShellInitSettings global variable.

Return values
EFI_SUCCESSthe variable is initialized.

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.

Return values
EFI_SUCCESSThe variable is initialized.

Definition at line 955 of file Shell.c.

◆ ProcessCommandLineToFinal()

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.

Parameters
[in,out]CmdLinepointer to the command line to update
Return values
EFI_SUCCESSThe operation was successful
EFI_OUT_OF_RESOURCESA memory allocation failed.
Returns
some other error occurred

Definition at line 2407 of file Shell.c.

◆ RestoreBufferList()

VOID RestoreBufferList ( IN OUT LIST_ENTRY OldBufferList)

Restore previous nodes into BufferToFreeList .

Parameters
OldBufferListThe temporary list head used to store the nodes in BufferToFreeList.

Definition at line 1520 of file Shell.c.

◆ RunCommand()

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.

Parameters
[in]CmdLinethe command line to parse
Return values
EFI_SUCCESSthe command was completed
EFI_ABORTEDthe command's operation was aborted

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.

Parameters
[in]CmdLineThe command line to parse.
Return values
EFI_SUCCESSThe command was completed.
EFI_ABORTEDThe command's operation was aborted.

Definition at line 2918 of file Shell.c.

◆ RunScriptFile()

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.

Parameters
[in]ScriptPathPointer to the script file name (including file system path).
[in]Handlethe handle of the script file already opened.
[in]CmdLinethe command line to run.
[in]ParamProtocolthe shell parameters protocol pointer
Return values
EFI_SUCCESSthe script completed successfully

Definition at line 3275 of file Shell.c.

◆ RunScriptFileHandle()

EFI_STATUS RunScriptFileHandle ( IN SHELL_FILE_HANDLE  Handle,
IN CONST CHAR16 *  Name 
)

Function to process a NSH script file via SHELL_FILE_HANDLE.

Parameters
[in]HandleThe handle to the already opened file.
[in]NameThe name of the script file.
Return values
EFI_SUCCESSthe script completed successfully

Definition at line 2934 of file Shell.c.

◆ RunShellCommand()

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.

Parameters
[in]CmdLineThe command line to parse.
[out]CommandStatusThe status from the command line.
Return values
EFI_SUCCESSThe command was completed.
EFI_ABORTEDThe command's operation was aborted.

Definition at line 2780 of file Shell.c.

◆ SaveBufferList()

VOID SaveBufferList ( OUT LIST_ENTRY OldBufferList)

Create a new buffer list and stores the old one to OldBufferList

Parameters
OldBufferListThe temporary list head used to store the nodes in BufferToFreeList.

Definition at line 1506 of file Shell.c.

◆ SetBuiltInAlias()

EFI_STATUS SetBuiltInAlias ( VOID  )

Sets all the alias' that were registered with the ShellCommandLib library.

Return values
EFI_SUCCESSall init commands were run successfully.

Definition at line 782 of file Shell.c.

◆ SetLastError()

EFI_STATUS SetLastError ( IN CONST SHELL_STATUS  ErrorCode)

Function to update the shell variable "lasterror".

Parameters
[in]ErrorCodethe error code to put into lasterror

Function to update the shell variable "lasterror".

Parameters
[in]ErrorCodethe error code to put into lasterror.

Definition at line 2377 of file Shell.c.

◆ TrimSpaces()

EFI_STATUS TrimSpaces ( IN CHAR16 **  String)

Cleans off leading and trailing spaces and tabs.

Parameters
[in]Stringpointer to the string to trim them off.

Definition at line 89 of file Shell.c.

Variable Documentation

◆ mNoNestingEnvVarName

CONST CHAR16 mNoNestingEnvVarName[]
extern

Definition at line 79 of file Shell.c.

◆ mNoNestingFalse

CONST CHAR16 mNoNestingFalse[]
extern

Definition at line 81 of file Shell.c.

◆ mNoNestingTrue

CONST CHAR16 mNoNestingTrue[]
extern

Definition at line 80 of file Shell.c.

◆ ShellInfoObject

SHELL_INFO ShellInfoObject
extern

Definition at line 17 of file Shell.c.