TianoCore EDK2 master
Loading...
Searching...
No Matches
UefiShellCommandLib.c File Reference

Go to the source code of this file.

Functions

EFI_STATUS EFIAPI CommandInit (VOID)
 
RETURN_STATUS EFIAPI ShellCommandLibConstructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
VOID FreeFileHandleList (IN BUFFER_LIST *List)
 
RETURN_STATUS EFIAPI ShellCommandLibDestructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
CONST EFI_SHELL_DYNAMIC_COMMAND_PROTOCOLShellCommandFindDynamicCommand (IN CONST CHAR16 *CommandString)
 
BOOLEAN ShellCommandDynamicCommandExists (IN CONST CHAR16 *CommandString)
 
BOOLEAN ShellCommandIsCommandOnInternalList (IN CONST CHAR16 *CommandString)
 
BOOLEAN EFIAPI ShellCommandIsCommandOnList (IN CONST CHAR16 *CommandString)
 
CHAR16 * ShellCommandGetDynamicCommandHelp (IN CONST CHAR16 *CommandString)
 
CHAR16 * ShellCommandGetInternalCommandHelp (IN CONST CHAR16 *CommandString)
 
CHAR16 *EFIAPI ShellCommandGetCommandHelp (IN CONST CHAR16 *CommandString)
 
RETURN_STATUS EFIAPI ShellCommandRegisterCommandName (IN CONST CHAR16 *CommandString, IN SHELL_RUN_COMMAND CommandHandler, IN SHELL_GET_MAN_FILENAME GetManFileName, IN UINT32 ShellMinSupportLevel, IN CONST CHAR16 *ProfileName, IN CONST BOOLEAN CanAffectLE, IN CONST EFI_HII_HANDLE HiiHandle, IN CONST EFI_STRING_ID ManFormatHelp)
 
CONST CHAR16 *EFIAPI ShellCommandGetProfileList (VOID)
 
RETURN_STATUS EFIAPI ShellCommandRunCommandHandler (IN CONST CHAR16 *CommandString, IN OUT SHELL_STATUS *RetVal, IN OUT BOOLEAN *CanAffectLE OPTIONAL)
 
CONST CHAR16 *EFIAPI ShellCommandGetManFileNameHandler (IN CONST CHAR16 *CommandString)
 
CONST COMMAND_LIST *EFIAPI ShellCommandGetCommandList (IN CONST BOOLEAN Sort)
 
RETURN_STATUS EFIAPI ShellCommandRegisterAlias (IN CONST CHAR16 *Command, IN CONST CHAR16 *Alias)
 
CONST ALIAS_LIST *EFIAPI ShellCommandGetInitAliasList (VOID)
 
BOOLEAN EFIAPI ShellCommandIsOnAliasList (IN CONST CHAR16 *Alias)
 
BOOLEAN EFIAPI ShellCommandGetEchoState (VOID)
 
VOID EFIAPI ShellCommandSetEchoState (IN BOOLEAN State)
 
VOID EFIAPI ShellCommandRegisterExit (IN BOOLEAN ScriptOnly, IN CONST UINT64 ErrorCode)
 
BOOLEAN EFIAPI ShellCommandGetExit (VOID)
 
UINT64 EFIAPI ShellCommandGetExitCode (VOID)
 
BOOLEAN EFIAPI ShellCommandGetScriptExit (VOID)
 
VOID EFIAPI DeleteScriptFileStruct (IN SCRIPT_FILE *Script)
 
SCRIPT_FILE *EFIAPI ShellCommandGetCurrentScriptFile (VOID)
 
SCRIPT_FILE *EFIAPI ShellCommandSetNewScript (IN SCRIPT_FILE *Script OPTIONAL)
 
CHAR16 *EFIAPI ShellCommandCreateNewMappingName (IN CONST SHELL_MAPPING_TYPE Type)
 
EFI_STATUS EFIAPI ShellCommandAddMapItemAndUpdatePath (IN CONST CHAR16 *Name, IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN CONST UINT64 Flags, IN CONST BOOLEAN Path)
 
EFI_STATUS EFIAPI ShellCommandCreateInitialMappingsAndPaths (VOID)
 
EFI_STATUS EFIAPI ShellCommandUpdateMapping (VOID)
 
EFI_FILE_PROTOCOL *EFIAPI ConvertShellHandleToEfiFileProtocol (IN CONST SHELL_FILE_HANDLE Handle)
 
SHELL_FILE_HANDLE EFIAPI ConvertEfiFileProtocolToShellHandle (IN CONST EFI_FILE_PROTOCOL *Handle, IN CONST CHAR16 *Path)
 
CONST CHAR16 *EFIAPI ShellFileHandleGetPath (IN CONST SHELL_FILE_HANDLE Handle)
 
BOOLEAN EFIAPI ShellFileHandleRemove (IN CONST SHELL_FILE_HANDLE Handle)
 
BOOLEAN EFIAPI ShellFileHandleEof (IN SHELL_FILE_HANDLE Handle)
 
VOID EFIAPI FreeBufferList (IN BUFFER_LIST *List)
 
VOID EFIAPI DumpHex (IN UINTN Indent, IN UINTN Offset, IN UINTN DataSize, IN VOID *UserData)
 
CHAR16 *EFIAPI CatSDumpHex (IN CHAR16 *Buffer, IN UINTN Indent, IN UINTN Offset, IN UINTN DataSize, IN VOID *UserData)
 
STATIC INTN EFIAPI UniqueNameCompare (IN CONST VOID *Unique1AsVoid, IN CONST VOID *Unique2AsVoid)
 
STATIC INTN EFIAPI UniqueNameAliasCompare (IN CONST VOID *UniqueAliasAsVoid, IN CONST VOID *UniqueAsVoid)
 
EFI_STATUS EFIAPI ShellSortFileList (IN OUT EFI_SHELL_FILE_INFO **FileList, OUT EFI_SHELL_FILE_INFO **Duplicates OPTIONAL, IN SHELL_SORT_FILE_LIST Order)
 

Variables

STATIC SHELL_COMMAND_INTERNAL_LIST_ENTRY mCommandList
 
STATIC SCRIPT_FILE_LIST mScriptList
 
STATIC ALIAS_LIST mAliasList
 
STATIC BOOLEAN mEchoState
 
STATIC BOOLEAN mExitRequested
 
STATIC UINT64 mExitCode
 
STATIC BOOLEAN mExitScript
 
STATIC CHAR16 * mProfileList
 
STATIC UINTN mProfileListSize
 
STATIC UINTN mFsMaxCount = 0
 
STATIC UINTN mBlkMaxCount = 0
 
STATIC BUFFER_LIST mFileHandleList
 
STATIC CONST CHAR8 Hex []
 
EFI_UNICODE_COLLATION_PROTOCOLgUnicodeCollation = NULL
 
SHELL_MAP_LIST gShellMapList
 List of Mappings - DeviceName and Drive Letter(ism).
 
SHELL_MAP_LISTgShellCurMapping = NULL
 Pointer to node of current directory in the mMapList.
 
CONST CHAR16 * SupportLevel []
 

Detailed Description

Provides interface to shell internal functions for shell commands.

Copyright (c) 2009 - 2018, Intel Corporation. All rights reserved.
(C) Copyright 2013-2015 Hewlett-Packard Development Company, L.P.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP

SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file UefiShellCommandLib.c.

Function Documentation

◆ CatSDumpHex()

CHAR16 *EFIAPI CatSDumpHex ( IN CHAR16 *  Buffer,
IN UINTN  Indent,
IN UINTN  Offset,
IN UINTN  DataSize,
IN VOID *  UserData 
)

Dump HEX data into buffer.

Parameters
[in]BufferHEX data to be dumped in Buffer.
[in]IndentHow many spaces to indent the output.
[in]OffsetThe offset of the printing.
[in]DataSizeThe size in bytes of UserData.
[in]UserDataThe data to print out.

Definition at line 1982 of file UefiShellCommandLib.c.

◆ CommandInit()

EFI_STATUS EFIAPI CommandInit ( VOID  )

Function to make sure that the global protocol pointers are valid. must be called after constructor before accessing the pointers.

Definition at line 65 of file UefiShellCommandLib.c.

◆ ConvertEfiFileProtocolToShellHandle()

SHELL_FILE_HANDLE EFIAPI ConvertEfiFileProtocolToShellHandle ( IN CONST EFI_FILE_PROTOCOL Handle,
IN CONST CHAR16 *  Path 
)

Converts a EFI_FILE_PROTOCOL* to an SHELL_FILE_HANDLE.

Parameters
[in]HandleThe pointer to EFI_FILE_PROTOCOL to convert.
[in]PathThe path to the file for verification.
Returns
A SHELL_FILE_HANDLE representing the same file.
Return values
NULLThere was not enough memory.

Definition at line 1742 of file UefiShellCommandLib.c.

◆ ConvertShellHandleToEfiFileProtocol()

EFI_FILE_PROTOCOL *EFIAPI ConvertShellHandleToEfiFileProtocol ( IN CONST SHELL_FILE_HANDLE  Handle)

Converts a SHELL_FILE_HANDLE to an EFI_FILE_PROTOCOL*.

Parameters
[in]HandleThe SHELL_FILE_HANDLE to convert.
Returns
a EFI_FILE_PROTOCOL* representing the same file.

Definition at line 1724 of file UefiShellCommandLib.c.

◆ DeleteScriptFileStruct()

VOID EFIAPI DeleteScriptFileStruct ( IN SCRIPT_FILE Script)

Function to cleanup all memory from a SCRIPT_FILE structure.

Parameters
[in]ScriptThe pointer to the structure to cleanup.

Definition at line 1141 of file UefiShellCommandLib.c.

◆ DumpHex()

VOID EFIAPI DumpHex ( IN UINTN  Indent,
IN UINTN  Offset,
IN UINTN  DataSize,
IN VOID *  UserData 
)

Dump some hexadecimal data to the screen.

Parameters
[in]IndentHow many spaces to indent the output.
[in]OffsetThe offset of the printing.
[in]DataSizeThe size in bytes of UserData.
[in]UserDataThe data to print out.

Definition at line 1929 of file UefiShellCommandLib.c.

◆ FreeBufferList()

VOID EFIAPI FreeBufferList ( IN BUFFER_LIST List)

Frees any BUFFER_LIST defined type.

Parameters
[in]ListThe BUFFER_LIST object to free.

Definition at line 1892 of file UefiShellCommandLib.c.

◆ FreeFileHandleList()

VOID FreeFileHandleList ( IN BUFFER_LIST List)

Frees list of file handles.

Parameters
[in]ListThe list to free.

Definition at line 195 of file UefiShellCommandLib.c.

◆ ShellCommandAddMapItemAndUpdatePath()

EFI_STATUS EFIAPI ShellCommandAddMapItemAndUpdatePath ( IN CONST CHAR16 *  Name,
IN CONST EFI_DEVICE_PATH_PROTOCOL DevicePath,
IN CONST UINT64  Flags,
IN CONST BOOLEAN  Path 
)

Function to add a map node to the list of map items and update the "path" environment variable (optionally).

If Path is TRUE (during initialization only), the path environment variable will also be updated to include default paths on the new map name...

Path should be FALSE when this function is called from the protocol SetMap function.

Parameters
[in]NameThe human readable mapped name.
[in]DevicePathThe Device Path for this map.
[in]FlagsThe Flags attribute for this map item.
[in]PathTRUE to update path, FALSE to skip this step (should only be TRUE during initialization).
Return values
EFI_SUCCESSThe addition was successful.
EFI_OUT_OF_RESOURCESA memory allocation failed.
EFI_INVALID_PARAMETERA parameter was invalid.

Definition at line 1299 of file UefiShellCommandLib.c.

◆ ShellCommandCreateInitialMappingsAndPaths()

EFI_STATUS EFIAPI ShellCommandCreateInitialMappingsAndPaths ( VOID  )

Creates the default map names for each device path in the system with a protocol depending on the Type.

Creates the consistent map names for each device path in the system with a protocol depending on the Type.

Note: This will reset all mappings in the system("map -r").

Also sets up the default path environment variable if Type is FileSystem.

Return values
EFI_SUCCESSAll map names were created successfully.
EFI_NOT_FOUNDNo protocols were found in the system.
Returns
Error returned from gBS->LocateHandle().
See also
LocateHandle

Definition at line 1389 of file UefiShellCommandLib.c.

◆ ShellCommandCreateNewMappingName()

CHAR16 *EFIAPI ShellCommandCreateNewMappingName ( IN CONST SHELL_MAPPING_TYPE  Type)

Function to generate the next default mapping name.

If the return value is not NULL then it must be callee freed.

Parameters
TypeWhat kind of mapping name to make.
Return values
NULLa memory allocation failed.
Returns
a new map name string

Definition at line 1255 of file UefiShellCommandLib.c.

◆ ShellCommandDynamicCommandExists()

BOOLEAN ShellCommandDynamicCommandExists ( IN CONST CHAR16 *  CommandString)

Checks if a command exists as a dynamic command protocol instance

Parameters
[in]CommandStringThe command string to check for on the list.

Definition at line 369 of file UefiShellCommandLib.c.

◆ ShellCommandFindDynamicCommand()

CONST EFI_SHELL_DYNAMIC_COMMAND_PROTOCOL * ShellCommandFindDynamicCommand ( IN CONST CHAR16 *  CommandString)

Find a dynamic command protocol instance given a command name string.

Parameters
CommandStringthe command name string
Returns
instance the command protocol instance, if dynamic command instance found
Return values
NULLno dynamic command protocol instance found for name

Definition at line 319 of file UefiShellCommandLib.c.

◆ ShellCommandGetCommandHelp()

CHAR16 *EFIAPI ShellCommandGetCommandHelp ( IN CONST CHAR16 *  CommandString)

Get the help text for a command.

Parameters
[in]CommandStringThe command name.
Return values
NULLNo help text was found.
Returns
String of help text.Caller reuiqred to free.

Definition at line 513 of file UefiShellCommandLib.c.

◆ ShellCommandGetCommandList()

CONST COMMAND_LIST *EFIAPI ShellCommandGetCommandList ( IN CONST BOOLEAN  Sort)

Get the list of all available shell internal commands. This is a linked list (via LIST_ENTRY structure). enumerate through it using the BaseLib linked list functions. do not modify the values.

Parameters
[in]SortTRUE to alphabetically sort the values first. FALSE otherwise.
Returns
a Linked list of all available shell commands.

Definition at line 860 of file UefiShellCommandLib.c.

◆ ShellCommandGetCurrentScriptFile()

SCRIPT_FILE *EFIAPI ShellCommandGetCurrentScriptFile ( VOID  )

Function to return a pointer to the currently running script file object.

Return values
NULLA script file is not currently running.
Returns
A pointer to the current script file object.

Definition at line 1188 of file UefiShellCommandLib.c.

◆ ShellCommandGetDynamicCommandHelp()

CHAR16 * ShellCommandGetDynamicCommandHelp ( IN CONST CHAR16 *  CommandString)

Get the help text for a dynamic command.

Parameters
[in]CommandStringThe command name.
Return values
NULLNo help text was found.
Returns
String of help text. Caller required to free.

Definition at line 443 of file UefiShellCommandLib.c.

◆ ShellCommandGetEchoState()

BOOLEAN EFIAPI ShellCommandGetEchoState ( VOID  )

Function to determine current state of ECHO. Echo determines if lines from scripts and ECHO commands are enabled.

Return values
TRUEEcho is currently enabled
FALSEEcho is currently disabled

Definition at line 1038 of file UefiShellCommandLib.c.

◆ ShellCommandGetExit()

BOOLEAN EFIAPI ShellCommandGetExit ( VOID  )

Retrieve the Exit indicator.

Return values
TRUEExit was indicated.
FALSEExis was not indicated.

Definition at line 1094 of file UefiShellCommandLib.c.

◆ ShellCommandGetExitCode()

UINT64 EFIAPI ShellCommandGetExitCode ( VOID  )

Retrieve the Exit code.

If ShellCommandGetExit returns FALSE than the return from this is undefined.

Returns
the value passed into RegisterExit.

Definition at line 1110 of file UefiShellCommandLib.c.

◆ ShellCommandGetInitAliasList()

CONST ALIAS_LIST *EFIAPI ShellCommandGetInitAliasList ( VOID  )

Get the list of all shell alias commands. This is a linked list (via LIST_ENTRY structure). enumerate through it using the BaseLib linked list functions. do not modify the values.

Returns
a Linked list of all requested shell alias'.

Definition at line 967 of file UefiShellCommandLib.c.

◆ ShellCommandGetInternalCommandHelp()

CHAR16 * ShellCommandGetInternalCommandHelp ( IN CONST CHAR16 *  CommandString)

Get the help text for an internal command.

Parameters
[in]CommandStringThe command name.
Return values
NULLNo help text was found.
Returns
String of help text. Caller reuiqred to free.

Definition at line 469 of file UefiShellCommandLib.c.

◆ ShellCommandGetManFileNameHandler()

CONST CHAR16 *EFIAPI ShellCommandGetManFileNameHandler ( IN CONST CHAR16 *  CommandString)

Checks if a command string has been registered for CommandString and if so it returns the MAN filename specified for that command.

If CommandString is NULL, then ASSERT().

Parameters
[in]CommandStringPointer to the command name. This is the name found on the command line in the shell.\
Return values
NULLthe commandString was not a registered command.
Returns
other the name of the MAN file.
See also
SHELL_GET_MAN_FILENAME

Definition at line 815 of file UefiShellCommandLib.c.

◆ ShellCommandGetProfileList()

CONST CHAR16 *EFIAPI ShellCommandGetProfileList ( VOID  )

Function to get the current Profile string.

Return values
NULLThere are no installed profiles.
Returns
A semi-colon delimited list of profiles.

Definition at line 706 of file UefiShellCommandLib.c.

◆ ShellCommandGetScriptExit()

BOOLEAN EFIAPI ShellCommandGetScriptExit ( VOID  )

Retrieve the Exit script indicator.

If ShellCommandGetExit returns FALSE than the return from this is undefined.

Return values
TRUEScriptOnly was indicated.
FALSEScriptOnly was not indicated.

Definition at line 1127 of file UefiShellCommandLib.c.

◆ ShellCommandIsCommandOnInternalList()

BOOLEAN ShellCommandIsCommandOnInternalList ( IN CONST CHAR16 *  CommandString)

Checks if a command is already on the internal command list.

Parameters
[in]CommandStringThe command string to check for on the list.

Definition at line 382 of file UefiShellCommandLib.c.

◆ ShellCommandIsCommandOnList()

BOOLEAN EFIAPI ShellCommandIsCommandOnList ( IN CONST CHAR16 *  CommandString)

Checks if a command exists, either internally or through the dynamic command protocol.

Parameters
[in]CommandStringThe command string to check for on the list.

Definition at line 423 of file UefiShellCommandLib.c.

◆ ShellCommandIsOnAliasList()

BOOLEAN EFIAPI ShellCommandIsOnAliasList ( IN CONST CHAR16 *  Alias)

Determine if a given alias is on the list of built in alias'.

Parameters
[in]AliasThe alias to test for
Return values
TRUEThe alias is a built in alias
FALSEThe alias is not a built in alias

Definition at line 984 of file UefiShellCommandLib.c.

◆ ShellCommandLibConstructor()

RETURN_STATUS EFIAPI ShellCommandLibConstructor ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Constructor for the Shell Command library.

Initialize the library and determine if the underlying is a UEFI Shell 2.0 or an EFI shell.

Parameters
ImageHandlethe image handle of the process
SystemTablethe EFI System Table pointer
Return values
EFI_SUCCESSthe initialization was complete successfully

Definition at line 162 of file UefiShellCommandLib.c.

◆ ShellCommandLibDestructor()

RETURN_STATUS EFIAPI ShellCommandLibDestructor ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Destructor for the library. free any resources.

Parameters
ImageHandlethe image handle of the process
SystemTablethe EFI System Table pointer
Return values
RETURN_SUCCESSthis function always returns success

Definition at line 231 of file UefiShellCommandLib.c.

◆ ShellCommandRegisterAlias()

RETURN_STATUS EFIAPI ShellCommandRegisterAlias ( IN CONST CHAR16 *  Command,
IN CONST CHAR16 *  Alias 
)

Registers aliases to be set as part of the initialization of the shell application.

If Command is NULL, then ASSERT(). If Alias is NULL, then ASSERT().

Parameters
[in]CommandPointer to the Command
[in]AliasPointer to Alias
Return values
RETURN_SUCCESSThe handlers were registered.
RETURN_OUT_OF_RESOURCESThere are not enough resources available to register the shell command.

Definition at line 885 of file UefiShellCommandLib.c.

◆ ShellCommandRegisterCommandName()

RETURN_STATUS EFIAPI ShellCommandRegisterCommandName ( IN CONST CHAR16 *  CommandString,
IN SHELL_RUN_COMMAND  CommandHandler,
IN SHELL_GET_MAN_FILENAME  GetManFileName,
IN UINT32  ShellMinSupportLevel,
IN CONST CHAR16 *  ProfileName,
IN CONST BOOLEAN  CanAffectLE,
IN CONST EFI_HII_HANDLE  HiiHandle,
IN CONST EFI_STRING_ID  ManFormatHelp 
)

Registers handlers of type SHELL_RUN_COMMAND and SHELL_GET_MAN_FILENAME for each shell command.

If the ShellSupportLevel is greater than the value of the PcdShellSupportLevel then return RETURN_UNSUPPORTED.

Registers the handlers specified by GetHelpInfoHandler and CommandHandler with the command specified by CommandString. If the command named by CommandString has already been registered, then return RETURN_ALREADY_STARTED.

If there are not enough resources available to register the handlers then RETURN_OUT_OF_RESOURCES is returned.

If CommandString is NULL, then ASSERT(). If GetHelpInfoHandler is NULL, then ASSERT(). If CommandHandler is NULL, then ASSERT(). If ProfileName is NULL, then ASSERT().

Parameters
[in]CommandStringPointer to the command name. This is the name to look for on the command line in the shell.
[in]CommandHandlerPointer to a function that runs the specified command.
[in]GetManFileNamePointer to a function that provides man filename.
[in]ShellMinSupportLevelminimum Shell Support Level which has this function.
[in]ProfileNameprofile name to require for support of this function.
[in]CanAffectLEindicates whether this command's return value can change the LASTERROR environment variable.
[in]HiiHandleHandle of this command's HII entry.
[in]ManFormatHelpHII locator for the help text.
Return values
RETURN_SUCCESSThe handlers were registered.
RETURN_OUT_OF_RESOURCESThere are not enough resources available to register the shell command.
RETURN_UNSUPPORTEDthe ShellMinSupportLevel was higher than the currently allowed support level.
RETURN_ALREADY_STARTEDThe CommandString represents a command that is already registered. Only 1 handler set for a given command is allowed.
See also
SHELL_GET_MAN_FILENAME
SHELL_RUN_COMMAND

Definition at line 577 of file UefiShellCommandLib.c.

◆ ShellCommandRegisterExit()

VOID EFIAPI ShellCommandRegisterExit ( IN BOOLEAN  ScriptOnly,
IN CONST UINT64  ErrorCode 
)

Indicate that the current shell or script should exit.

Parameters
[in]ScriptOnlyTRUE if exiting a script; FALSE otherwise.
[in]ErrorCodeThe 64 bit error code to return.

Definition at line 1071 of file UefiShellCommandLib.c.

◆ ShellCommandRunCommandHandler()

RETURN_STATUS EFIAPI ShellCommandRunCommandHandler ( IN CONST CHAR16 *  CommandString,
IN OUT SHELL_STATUS RetVal,
IN OUT BOOLEAN *CanAffectLE  OPTIONAL 
)

Checks if a command string has been registered for CommandString and if so it runs the previously registered handler for that command with the command line.

If CommandString is NULL, then ASSERT().

If Sections is specified, then each section name listed will be compared in a casesensitive manner, to the section names described in Appendix B UEFI Shell 2.0 spec. If the section exists, it will be appended to the returned help text. If the section does not exist, no information will be returned. If Sections is NULL, then all help text information available will be returned.

Parameters
[in]CommandStringPointer to the command name. This is the name found on the command line in the shell.
[in,out]RetValPointer to the return vaule from the command handler.
[in,out]CanAffectLEindicates whether this command's return value needs to be placed into LASTERROR environment variable.
Return values
RETURN_SUCCESSThe handler was run.
RETURN_NOT_FOUNDThe CommandString did not match a registered command name.
See also
SHELL_RUN_COMMAND

Definition at line 739 of file UefiShellCommandLib.c.

◆ ShellCommandSetEchoState()

VOID EFIAPI ShellCommandSetEchoState ( IN BOOLEAN  State)

Function to set current state of ECHO. Echo determines if lines from scripts and ECHO commands are enabled.

If State is TRUE, Echo will be enabled. If State is FALSE, Echo will be disabled.

Parameters
[in]StateHow to set echo.

Definition at line 1056 of file UefiShellCommandLib.c.

◆ ShellCommandSetNewScript()

SCRIPT_FILE *EFIAPI ShellCommandSetNewScript ( IN SCRIPT_FILE *Script  OPTIONAL)

Function to set a new script as the currently running one.

This function will correctly stack and unstack nested scripts.

Parameters
[in]ScriptPointer to new script information structure. if NULL will remove and de-allocate the top-most Script structure.
Returns
A pointer to the current running script file after this change. NULL if removing the final script.

Definition at line 1215 of file UefiShellCommandLib.c.

◆ ShellCommandUpdateMapping()

EFI_STATUS EFIAPI ShellCommandUpdateMapping ( VOID  )

Add mappings for any devices without one. Do not change any existing maps.

Return values
EFI_SUCCESSThe operation was successful.

Definition at line 1606 of file UefiShellCommandLib.c.

◆ ShellFileHandleEof()

BOOLEAN EFIAPI ShellFileHandleEof ( IN SHELL_FILE_HANDLE  Handle)

Function to determine if a SHELL_FILE_HANDLE is at the end of the file.

This will NOT work on directories.

If Handle is NULL, then ASSERT.

Parameters
[in]Handlethe file handle
Return values
TRUEthe position is at the end of the file
FALSEthe position is not at the end of the file

Definition at line 1853 of file UefiShellCommandLib.c.

◆ ShellFileHandleGetPath()

CONST CHAR16 *EFIAPI ShellFileHandleGetPath ( IN CONST SHELL_FILE_HANDLE  Handle)

Find the path that was logged with the specified SHELL_FILE_HANDLE.

Parameters
[in]HandleThe SHELL_FILE_HANDLE to query on.
Returns
A pointer to the path for the file.

Definition at line 1787 of file UefiShellCommandLib.c.

◆ ShellFileHandleRemove()

BOOLEAN EFIAPI ShellFileHandleRemove ( IN CONST SHELL_FILE_HANDLE  Handle)

Remove a SHELL_FILE_HANDLE from the list of SHELL_FILE_HANDLES.

Parameters
[in]HandleThe SHELL_FILE_HANDLE to remove.
Return values
TRUEThe item was removed.
FALSEThe item was not found.

Definition at line 1816 of file UefiShellCommandLib.c.

◆ ShellSortFileList()

EFI_STATUS EFIAPI ShellSortFileList ( IN OUT EFI_SHELL_FILE_INFO **  FileList,
OUT EFI_SHELL_FILE_INFO **Duplicates  OPTIONAL,
IN SHELL_SORT_FILE_LIST  Order 
)

Sort an EFI_SHELL_FILE_INFO list, optionally moving duplicates to a separate list.

Parameters
[in,out]FileListThe list of EFI_SHELL_FILE_INFO objects to sort.
                     If FileList is NULL on input, then FileList is
                     considered an empty, hence already sorted, list.

                     Otherwise, if (*FileList) is NULL on input, then
                     EFI_INVALID_PARAMETER is returned.

                     Otherwise, the caller is responsible for having
                     initialized (*FileList)->Link with
                     InitializeListHead(). No other fields in the
                     (**FileList) head element are accessed by this
                     function.

                     On output, (*FileList) is sorted according to Order.
                     If Duplicates is NULL on input, then duplicate
                     elements are preserved, sorted stably, on
                     (*FileList). If Duplicates is not NULL on input,
                     then duplicates are moved (stably sorted) to the
                     new, dynamically allocated (*Duplicates) list.
[out]DuplicatesIf Duplicates is NULL on input, (*FileList) will be a monotonically ordered list on output, with duplicates stably sorted.

If Duplicates is not NULL on input, (*FileList) will be a strictly monotonically oredered list on output, with duplicates separated (stably sorted) to (*Duplicates). All fields except Link will be zero-initialized in the (**Duplicates) head element. If no duplicates exist, then (*Duplicates) is set to NULL on output.

Parameters
[in]OrderDetermines the comparison operation between EFI_SHELL_FILE_INFO objects.
Return values
EFI_INVALID_PARAMETER(UINTN)Order is greater than or equal to (UINTN)ShellSortFileListMax. Neither the (*FileList) nor the (*Duplicates) list has been modified.
EFI_INVALID_PARAMETER(*FileList) was NULL on input. Neither the (*FileList) nor the (*Duplicates) list has been modified.
EFI_OUT_OF_RESOURCESMemory allocation failed. Neither the (*FileList) nor the (*Duplicates) list has been modified.
EFI_SUCCESSSorting successful, including the case when FileList is NULL on input.

Definition at line 2165 of file UefiShellCommandLib.c.

◆ UniqueNameAliasCompare()

STATIC INTN EFIAPI UniqueNameAliasCompare ( IN CONST VOID *  UniqueAliasAsVoid,
IN CONST VOID *  UniqueAsVoid 
)

ORDERED_COLLECTION_KEY_COMPARE function for SHELL_SORT_UNIQUE_NAME objects.

Parameters
[in]UniqueAliasAsVoidThe CHAR16 string UniqueAlias, passed in as a pointer-to-VOID.
[in]UniqueAsVoidThe SHELL_SORT_UNIQUE_NAME object (Unique), passed in as a pointer-to-VOID.
Return values
<0If UniqueAlias compares less than Unique->Alias.
0If UniqueAlias compares equal to Unique->Alias.
>0If UniqueAlias compares greater than Unique->Alias.

Definition at line 2086 of file UefiShellCommandLib.c.

◆ UniqueNameCompare()

STATIC INTN EFIAPI UniqueNameCompare ( IN CONST VOID *  Unique1AsVoid,
IN CONST VOID *  Unique2AsVoid 
)

ORDERED_COLLECTION_USER_COMPARE function for SHELL_SORT_UNIQUE_NAME objects.

Parameters
[in]Unique1AsVoidThe first SHELL_SORT_UNIQUE_NAME object (Unique1), passed in as a pointer-to-VOID.
[in]Unique2AsVoidThe second SHELL_SORT_UNIQUE_NAME object (Unique2), passed in as a pointer-to-VOID.
Return values
<0If Unique1 compares less than Unique2.
0If Unique1 compares equal to Unique2.
>0If Unique1 compares greater than Unique2.

Definition at line 2047 of file UefiShellCommandLib.c.

Variable Documentation

◆ gShellCurMapping

SHELL_MAP_LIST* gShellCurMapping = NULL

Pointer to node of current directory in the mMapList.

Definition at line 50 of file UefiShellCommandLib.c.

◆ gShellMapList

SHELL_MAP_LIST gShellMapList

List of Mappings - DeviceName and Drive Letter(ism).

Definition at line 49 of file UefiShellCommandLib.c.

◆ gUnicodeCollation

EFI_UNICODE_COLLATION_PROTOCOL* gUnicodeCollation = NULL

Definition at line 48 of file UefiShellCommandLib.c.

◆ Hex

STATIC CONST CHAR8 Hex[]
Initial value:
= {
'0',
'1',
'2',
'3',
'4',
'5',
'6',
'7',
'8',
'9',
'A',
'B',
'C',
'D',
'E',
'F'
}

Definition at line 28 of file UefiShellCommandLib.c.

◆ mAliasList

STATIC ALIAS_LIST mAliasList

Definition at line 17 of file UefiShellCommandLib.c.

◆ mBlkMaxCount

STATIC UINTN mBlkMaxCount = 0

Definition at line 25 of file UefiShellCommandLib.c.

◆ mCommandList

Definition at line 15 of file UefiShellCommandLib.c.

◆ mEchoState

STATIC BOOLEAN mEchoState

Definition at line 18 of file UefiShellCommandLib.c.

◆ mExitCode

STATIC UINT64 mExitCode

Definition at line 20 of file UefiShellCommandLib.c.

◆ mExitRequested

STATIC BOOLEAN mExitRequested

Definition at line 19 of file UefiShellCommandLib.c.

◆ mExitScript

STATIC BOOLEAN mExitScript

Definition at line 21 of file UefiShellCommandLib.c.

◆ mFileHandleList

STATIC BUFFER_LIST mFileHandleList

Definition at line 26 of file UefiShellCommandLib.c.

◆ mFsMaxCount

STATIC UINTN mFsMaxCount = 0

Definition at line 24 of file UefiShellCommandLib.c.

◆ mProfileList

STATIC CHAR16* mProfileList

Definition at line 22 of file UefiShellCommandLib.c.

◆ mProfileListSize

STATIC UINTN mProfileListSize

Definition at line 23 of file UefiShellCommandLib.c.

◆ mScriptList

STATIC SCRIPT_FILE_LIST mScriptList

Definition at line 16 of file UefiShellCommandLib.c.

◆ SupportLevel

CONST CHAR16* SupportLevel[]
Initial value:
= {
L"Minimal",
L"Scripting",
L"Basic",
L"Interactive"
}

Definition at line 52 of file UefiShellCommandLib.c.