UEFI Programming Model

The UEFI Shell provides a programming API. You can use it to write your own UEFI applications for calling some of the Shell programmatic APIs or protocols. For more information, see the UEFI Shell Specification and EDK2. The UEFI Shell provides a programming API as listed in the following table. EFI_SHELL_PROTOCOL provides Shell services to UEFI applications. It provides UEFI Shell applications access to the low-level Shell functions, including files, pipes, environment variables, the current working directory, mappings, help text, aliases, and launching Shell applications and scripts.

Table 13: UEFI Application APIs

Function Type

Function Name

Description

EFI_SHELL_EXECUTE

Execute

Causes the Shell to parse and execute the command line.

EFI_SHELL_GET_ENV

GetEnv

Gets the environment variable.

EFI_SHELL_SET_ENV

SetEnv

Changes a specific environment variable.

EFI_SHELL_GET_ALIAS

GetAlias

Retrieves the alias for a specific Shell command.

EFI_SHELL_SET_ALIAS

SetAlias

Adds or removes the alias for a specific Shell command.

EFI_SHELL_GET_HELP_TEXT

GetHelpText

Returns help information about a specific command.

EFI_SHELL_GET_DEVICE_PATH_FROM_MAP

GetDevicePathFromMap

Returns the device path that corresponds to a mapping.

EFI_SHELL_GET_MAP_FROM_DEVICE_PATH

GetMapFromDevicePath

Returns the mapping that corresponds to a particular device path.

EFI_SHELL_GET_DEVICE_PATH_FROM_FILE_PATH

GetDevicePathFromFilePath

Converts a file path to a device path, where all mappings have been replaced with the corresponding device paths.

EFI_SHELL_GET_FILE_PATH_FROM_DEVICE_PATH

GetFilePathFromDevicePath

Converts a device path to a file path, where the portion of the device path corresponding to one of the mappings is replaced with that mapping.

EFI_SHELL_SET_MAP

SetMap

Creates, updates, or deletes a mapping between a device and a device path.

EFI_SHELL_GET_CUR_DIR

GetCurDir

Returns the current directory on a device.

EFI_SHELL_SET_CUR_DIR

SetCurDir

Changes the current directory on a device.

EFI_SHELL_OPEN_FILE_LIST

OpenFileList

Opens the files that match the path pattern specified.

EFI_SHELL_FREE_FILE_LIST

FreeFileList

Frees the file list created by OpenFileList().

EFI_SHELL_REMOVE_DUP_IN_FILE_LIST

RemoveDupInFileList

Deletes the duplicate files in the given file list.

EFI_SHELL_BATCH_IS_ACTIVE

BatchIsActive

Displays whether any script files are being processed.

EFI_SHELL_IS_ROOT_SHELL

IsRootShell

Verifies whether the active Shell is the root Shell.

EFI_SHELL_ENABLE_PAGE_BREAK

EnablePageBreak

Enables the page break output mode.

EFI_SHELL_DISABLE_PAGE_BREAK

DisablePageBreak

Disables the page break output mode.

EFI_SHELL_GET_PAGE_BREAK

GetPageBreak

Gets the enable status of the page break output mode.

EFI_SHELL_GET_DEVICE_NAME

GetDeviceName

Gets the name of the device specified by the device handle.

EFI_SHELL_GET_FILE_INFO

GetFileInfo

Displays information about a specific file handle.

EFI_SHELL_SET_FILE_INFO

SetFileInfo

Changes information about a specific file handle.

EFI_SHELL_OPEN_FILE_BY_NAME

OpenFileByName

Opens a file specified by name and returns a file handle.

EFI_SHELL_CLOSE_FILE

CloseFile

Closes an open file.

EFI_SHELL_CREATE_FILE

CreateFile

Creates a file.

EFI_SHELL_READ_FILE

ReadFile

Reads data from a file.

EFI_SHELL_WRITE_FILE

WriteFile

Writes data to a file.

EFI_SHELL_DELETE_FILE

DeleteFile

Deletes a file.

EFI_SHELL_DELETE_FILE_BY_NAME

DeleteFileByName

Deletes a file by name.

EFI_SHELL_GET_FILE_POSITION

GetFilePosition

Displays the current read/write position within a file.

EFI_SHELL_SET_FILE_POSITION

SetFilePosition

Changes the current read/write position within a file.

EFI_SHELL_FLUSH_FILE

FlushFile

Writes all buffered data to a file.

EFI_SHELL_FIND_FILES

FindFiles

Displays all files that match a pattern in a file list.

EFI_SHELL_FIND_FILES_IN_DIR

FindFilesInDir

Displays all files in a specified directory in a file list.

EFI_SHELL_GET_FILE_SIZE

GetFileSize

Displays the size of a file.

EFI_SHELL_OPEN_ROOT

OpenRoot

Displays the root directory of a file system.

EFI_SHELL_OPEN_ROOT_BY_HANDLE

OpenRootByHandle

Displays the root directory of a file system on a particular handle.

EFI_EVENT

ExecutionBreak

An event signaled by the UEFI Shell when the user presses CTRL-C to indicate that the current UEFI Shell command execution should be interrupted.

UINT32

MajorVersion

The major version of the Shell environment.

UINT32

MinorVersion

The minor version of the Shell environment.