UEFI Shell Specification September 25, 2008 Revision 2.
The material contained herein is not a license, either expressly or impliedly, to any intellectual property owned or controlled by any of the authors or developers of this material or to any contribution thereto.
Contents 1 Introduction .....................................................................................................1 1.1 1.2 1.3 2 Overview ..............................................................................................1 Related Information................................................................................1 Terms...................................................................................................1 Code Definitions ......................................
2.3 3 UEFI Shell Features .........................................................................................55 3.1 3.2 3.3 3.4 3.5 3.6 3.7 3.8 3.9 3.10 3.11 4 Levels Of Support.................................................................................55 Invocation...........................................................................................56 Initialization ........................................................................................57 3.3.1 Finding startup.nsh..
cls ............................................................................................88 comp ............................................................................................ 89 connect ............................................................................................91 cp ............................................................................................93 date ............................................................................................96 dblk ......
smbiosview ....................................................................................... 194 stall .......................................................................................... 196 time .......................................................................................... 197 timezone .......................................................................................... 199 touch ..........................................................................................
A.3.3.2.1 Examples: ................................................................................................... 217 A.3.3.3 CSD of ATAPI device path node....................................................................... 217 A.3.3.4 CSD of LUN Device path node ......................................................................... 217 A.3.3.4.1 Examples: ................................................................................................... 217 A.3.3.
Tables Table Table Table Table Table Table Table Table Table Table Table Table Table Table Table Table Table Table Table Table Table Table Table Table Table Table Table Table Table Table Table viii 1 Support Levels .................................................................................... 55 2 Standard Command Line Options ........................................................... 56 3: UEFI Shell Invocation Options...............................................................
Revision History Revision Number 2.0 Description Initial UEFI release Revision Date 9/25/08 § Version 2.
1 Introduction 1.1 Overview The UEFI Shell environment provides an API, a command prompt and a rich set of commands that extend and enhance the UEFI Shell’s capability. 1.2 Related Information The following publications and sources of information may be useful or are referred to by this document: Extensible Firmware Interface Specification, Version 1.10, Intel, 2001, http://developer.intel.com/technology/efi. Unified Extensible Firmware Interface Specification, Version 2.
UEFI Application An application following the UEFI specification. The only difference between a UEFI application and a UEFI driver is that an application is unloaded from memory when it exits regardless of return status, while a driver that returns a successful return status is not unloaded when its entry point exits. UEFI Driver A driver following the UEFI specification driver model. UEFI Specification Version 2.0 The first UEFI specification released by the Unified EFI Forum. UEFI Specification Version 2.
2 Code Definitions 2.1 Introduction Formatted: Bullets and Numbering 2.2 EFI_SHELL_PROTOCOL EFI_SHELL_PROTOCOL Summary Provides shell services to UEFI applications. 3 Version 2.
GUID #define EFI_SHELL_PROTOCOL_GUID \ { 0x6302d008, 0x7f9b, 0x4f30, \ { 0x87, 0xac, 0x60, 0xc9, 0xfe, 0xf5, 0xda, 0x4e } } Protocol Interface Structure typedef struct _EFI_SHELL_PROTOCOL { EFI_SHELL_EXECUTE EFI_SHELL_GET_ENV EFI_SHELL_SET_ENV EFI_SHELL_SET_ALIAS EFI_SHELL_GET_HELP_TEXT EFI_SHELL_GET_DEVICE_PATH_FROM_MAP EFI_SHELL_GET_MAP_FROM_DEVICE_PATH EFI_SHELL_GET_DEVICE_PATH_FROM_FILE_PATH EFI_SHELL_GET_FILE_PATH_FROM_DEVICE_PATH EFI_SHELL_SET_MAP Execute; GetEnv; SetEnv; SetAlias; GetHelpText; GetD
Causes the shell to parse and execute the command line. See the Execute() function description below. GetEnv Gets the environment variable. See the GetEnv() function description below. SetEnv Changes a specific environment variable. Set the SetEnv() function description below. SetAlias Adds or removes the alias for a specific shell command. See the SetAlias() function description below. GetDevicePathFromMap Returns the device path that corresponds to a mapping.
IsRootShell Judges whether the active Shell is the root shell. See the IsRootShell() function description below. EnablePageBreak Enables the page break output mode. See the EnablePageBreak() function description below. DisablePageBreak Disables the page break output mode. See the DisablePageBreak() function description below. GetPageBreak Gets the enable status of the page break output mode. See the GetPageBreak() function description below.
GetFilePosition Return the current read/write position within a file. See the GetFilePosition() function description. FlushFile Write all buffered data to a file. See the FlushFile() function description. FindFiles Return all files that match a pattern in a file list. See the FindFiles() function description. FindFilesInDir Return all files in a specified directory in a file list. See the FindFilesInDir() function description. GetFileSize Return the size of a file.
EFI_SHELL_PROTOCOL.BatchIsActive() Summary Returns whether any script files are currently being processed. Prototype typedef BOOLEAN (EFIAPI *EFI_SHELL_BATCH_IS_ACTIVE) ( VOID ); Parameters None Description This function tells whether any script files are currently being processed Status Codes Returned TRUE FALSE 8 There is at least one script file active. No script files are active now. Version 2.
EFI_SHELL_PROTOCOL.CloseFile() Summary Closes the file handle. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_CLOSE_FILE)( IN EFI_FILE_HANDLE FileHandle ); Parameters FileHandle The file handle to be closed Description This function closes a specified file handle. All “dirty” cached file data is flushed to the device, and the file is closed. In all cases, the handle is closed. Status Codes Returned EFI_SUCCESS Version 2.
EFI_SHELL_PROTOCOL.CreateFile() Summary Creates a file or directory by name. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_CREATE_FILE)( IN CONST CHAR16 *FileName, IN UINT64 FileAttribs, OUT EFI_FILE_HANDLE *FileHandle ); Parameters FileName Points to the null-terminated file path. FileAttribs The new file’s attributes. The different attributes are described in EFI_FILE_PROTOCOL.Open(). FileHandle On return, points to the created file or directory’s handle.
EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no longer supported. EFI_DEVICE_ERROR The device reported an error or can’t get the file path according the DirName. EFI_VOLUME_CORRUPTED The file system structures are corrupted. EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write when the media is write-protected. EFI_ACCESS_DENIED The service denied access to the file.
EFI_SHELL_PROTOCOL.DeleteFile() Summary Deletes the file specified by the file handle. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_DELETE_FILE)( IN EFI_FILE_HANDLE FileHandle ); Parameters FileHandle The file handle to delete. Description This function closes and deletes a file. In all cases, the file handle is closed. If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is returned, but the handle is still closed.
EFI_SHELL_PROTOCOL.DeleteFileByName() Summary Deletes the file specified by the file handle. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_DELETE_FILE_BY_NAME)( IN CONST CHAR16 *FileName ); Parameters FileName Points to the null-terminated file name. Description This function deletes a file. Status Codes Returned EFI_SUCCESS The file was closed and deleted, and the handle was closed. EFI_WARN_DELETE_FAILURE The handle was closed but the file was not deleted. Version 2.
EFI_SHELL_PROTOCOL.DisablePageBreak() Summary Disables the page break output mode. Prototype typedef VOID (EFIAPI *EFI_SHELL_DISABLE_PAGE_BREAK) ( VOID ); Parameters None Description This function disables the page break output mode. Status Codes Returned None 14 Version 2.
EFI_SHELL_PROTOCOL.EnablePageBreak() Summary Enables the page break output mode. Prototype typedef VOID (EFIAPI *EFI_SHELL_ENABLE_PAGE_BREAK) ( VOID ); Parameters None Description This function enables the page break output mode. Status Codes Returned None Version 2.
EFI_SHELL_PROTOCOL.Execute() Summary Execute the command line. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_EXECUTE) ( IN EFI_HANDLE *ParentImageHandle, IN CHAR16 *CommandLine OPTIONAL, IN CHAR16 **Environment OPTIONAL, OUT EFI_STATUS *StatusCode OPTIONAL ); Parameters ParentImageHandle A handle of the image that is executing the specified command line. CommandLine Points to the null-terminated UCS-2 encoded string containing the command line. If NULL then the command-line will be empty.
pointed to by StatusCode. EFI_INVALID_PARAMETER The parameters are invalid. EFI_OUT_OF_RESOURCES Out of resources. EFI_UNSUPPORTED Nested shell invocations are not allowed. Version 2.
EFI_SHELL_PROTOCOL.FindFiles() Summary Find files that match a specified pattern. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_FIND_FILES)( IN CONST CHAR16 *FilePattern, OUT EFI_SHELL_FILE_INFO **FileList ); Parameters FilePattern Points to a null-terminated shell file path, including wildcards. FileList On return, points to the start of a file list containing the names of all matching files or else points to NULL if no matching files were found.
EFI_SHELL_PROTOCOL.FindFilesInDir() Summary Find all files in a specified directory. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_FIND_FILES_IN_DIR)( IN EFI_FILE_HANDLE FileDirHandle, OUT EFI_SHELL_FILE_INFO **FileList ); Parameters FileDirHandle Handle of the directory to search. FileList On return, points to the list of files in the directory or NULL if there are no files in the directory. Status Codes Returned EFI_SUCCESS File information was returned successfully.
EFI_SHELL_PROTOCOL.FlushFile() Summary Flushes data back to a device Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_FLUSH_FILE)( IN EFI_FILE_HANDLE FileHandle ); Parameters FileHandle The handle of the file to flush. Description This function flushes all modified data associated with a file to a device. Status Codes Returned EFI_SUCCESS The data was flushed. EFI_NO_MEDIA The device has no medium. EFI_DEVICE_ERROR The device reported an error.
EFI_SHELL_PROTOCOL.FreeFileList() Summary Frees the file list. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_FREE_FILE_LIST) ( IN EFI_SHELL_FILE_INFO **FileList ); Parameters FileList The file list to free. Type EFI_SHELL_FILE_INFO is defined in OpenFileList() Description This function cleans up the file list and any related data structures. It has no impact on the files themselves. Status Codes Returned EFI_SUCCESS Version 2.0 Free the file list successfully.
EFI_SHELL_PROTOCOL.GetCurDir() Summary Returns the current directory on the specified device. Prototype typedef CONST CHAR16 * (EFIAPI *EFI_SHELL_GET_CUR_DIR) ( IN CONST CHAR16 *FileSystemMapping OPTIONAL ); Parameters FileSystemMapping A pointer to the file system mapping. If NULL, then the current working directory is returned. Description If FileSystemMapping is NULL, it returns the current working directory.
EFI_SHELL_PROTOCOL.GetDeviceName() Summary Gets the name of the device specified by the device handle. Prototype typedef EFI_STATUS (*EFI_SHELL_GET_DEVICE_NAME) ( IN EFI_HANDLE IN EFI_SHELL_DEVICE_NAME_FLAGS IN CHAR8 OUT CHAR16 ); DeviceHandle, Flags, *Language, **BestDeviceName Parameters DeviceHandle The handle of the device. Flags Determines the possible sources of component names. See “Related Definitions” below for more information.
If EFI_DEVICE_NAME_USE_DEVICE_PATH is set, then the function will return the device’s name using the EFI_DEVICE_PATH_PROTOCOL, if present on DeviceHandle. If both EFI_DEVICE_NAME_USE_COMPONENT_NAME and EFI_DEVICE_NAME_USE_DEVICE_PATH are set, then EFI_DEVICE_NAME_USE_COMPONENT_NAME will have higher priority. Status Codes Returned EFI_SUCCESS Get the name successfully. EFI_NOT_FOUND Fail to get the device name. 24 Version 2.
EFI_SHELL_PROTOCOL.GetDevicePathFromMap() Summary Gets the device path from the mapping. Prototype typedef CONST EFI_DEVICE_PATH_PROTOCOL * (EFIAPI *EFI_SHELL_GET_DEVICE_PATH_FROM_MAP) ( IN CONST CHAR16 *Mapping ); Parameters Mapping A pointer to the mapping. Description This function gets the device path associated with a mapping. Status Codes Returned ≠NULL Pointer to the device path that corresponds to the device mapping. The returned pointer does not need to be freed.
EFI_SHELL_PROTOCOL.GetDevicePathFromFilePath() Summary Converts a file system style name to a device path. Prototype typedef EFI_DEVICE_PATH_PROTOCOL * (EFIAPI *EFI_SHELL_GET_DEVICE_PATH_FROM_FILE_PATH) ( IN CONST CHAR16 *Path ); Parameters Path The pointer to the path. Description This function converts a file system style name to a device path, by replacing any mapping references to the associated device path. Status Codes Returned The pointer of the file path.
EFI_SHELL_PROTOCOL.GetEnv() Summary Gets the environment variable. Prototype typedef CONST CHAR16 * (EFIAPI *EFI_SHELL_GET_ENV) ( IN CONST CHAR16 *Name ); Parameters Name A pointer to the environment variable name. Description This function returns the current value of the specified environment variable. Status Codes Returned ≠NULL The environment variable’s value. The returned pointer does not need to be freed by the caller. NULL The environment variable doesn’t exist. Version 2.
EFI_SHELL_PROTOCOL.GetFileInfo() Summary Gets the file information from an open file handle. Prototype typedef EFI_FILE_INFO * (EFIAPI *EFI_SHELL_GET_FILE_INFO)( IN EFI_FILE_HANDLE FileHandle ); Parameters FileHandle A file handle Description This function allocates a buffer to store the file’s information. It’s the caller’s responsibility to free the buffer. Returns ≠NULL Cannot get the file info. NULL A pointer to a buffer with file information. 28 Version 2.
EFI_SHELL_PROTOCOL.GetFilePathFromDevicePath() Summary Converts a device path to a file system-style path. Prototype typedef CHAR16 * (EFIAPI *EFI_SHELL_GET_FILE_PATH_FROM_DEVICE_PATH) ( IN CONST EFI_DEVICE_PATH_PROTOCOL *Path ); Parameters Path The pointer to the device path. Description This function converts a device path to a file system path by replacing part, or all, of the device path with the file-system mapping.
EFI_SHELL_PROTOCOL.GetFilePosition() Summary Gets a file’s current position Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_GET_FILE_POSITION)( IN EFI_FILE_HANDLE FileHandle, OUT UINT64 *Position ); Parameters FileHandle The file handle on which to get the current position. Position Byte position from the start of the file Description This function returns the current file position for the file handle.
EFI_SHELL_PROTOCOL.GetFileSize() Summary Gets the size of a file. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_GET_FILE_SIZE)( IN EFI_FILE_HANDLE FileHandle, OUT UINT64 *Size ); Parameters FileHandle The handle of the file. Size The size of this file. Description This function returns the size of the file specified by FileHandle. Status Codes Returned EFI_SUCCESS Get the file’s size. EFI_DEVICE_ERROR Can’t access the file. Version 2.
EFI_SHELL_PROTOCOL.GetHelpText() Summary Return help information about a specific command. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_GET_HELP_TEXT) ( IN CONST CHAR16 *Command, IN CONST CHAR16 *Sections, OUT CHAR16 **HelpText ); Parameters Command Points to the null-terminated UEFI Shell command name. Sections Points to the null-terminated comma-delimited section names to return. If NULL, then all sections will be returned.
EFI_SHELL_PROTOCOL.GetMapFromDevicePath() Summary Gets the mapping that most closely matches the device path. Prototype typedef CONST CHAR16 * (EFIAPI *EFI_SHELL_GET_MAP_FROM_DEVICE_PATH) ( IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath ); Parameters DevicePath On entry, points to a device path pointer. On exit, updates the pointer to point to the portion of the device path after the mapping. Description This function gets the mapping which corresponds to the device path *DevicePath.
EFI_SHELL_PROTOCOL.GetPageBreak() Summary Gets the enable status of the page break output mode. Prototype typedef BOOLEAN (EFIAPI *EFI_SHELL_GET_PAGE_BREAK) ( VOID ); Parameters None Description User can use this function to determine current page break mode. Status Codes Returned TRUE The page break output mode is enabled FALSE The page break output mode is disabled Version 2.
EFI_SHELL_PROTOCOL.IsRootShell() Summary Judges whether the active shell is the root shell. Prototype typedef BOOLEAN (EFIAPI *EFI_SHELL_IS_ROOT_SHELL) ( VOID ); Parameters None Description This function makes the user to know that whether the active Shell is the root shell. Status Codes Returned TRUE The active Shell is the root Shell. FALSE The active Shell is NOT the root Shell. 36 Version 2.
EFI_SHELL_PROTOCOL.OpenFileByName() Summary Opens a file or a directory by file name. Prototype typdef EFI_STATUS (EFIAPI *EFI_SHELL_OPEN_FILE_BY_NAME) ( IN CONST CHAR16 *FileName, OUT EFI_FILE_HANDLE *FileHandle, IN UINT64 OpenMode ); Parameters FileName Points to the null-terminated UCS-2 encoded file name. FileHandle On return, points to the file handle. OpenMode File open mode. Either EFI_FILE_MODE_READ or EFI_FILE_MODE_WRITE from section 12.4 of the UEFI Specification.
If the file name is NUL, then the file handle that is returned refers to the standard NUL file. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER is returned. If return EFI_SUCCESS, the FileHandle is the opened file’s handle, else, the FileHandle is NULL. Status Codes Returned EFI_SUCCESS The file was opened. FileHandle has the opened file’s handle. EFI_INVALID_PARAMETER One of the parameters has an invalid value. FileHandle is NULL. EFI_UNSUPPORTED Could not open the file path.
EFI_SHELL_PROTOCOL.OpenFileList() Summary Opens the files that match the path specified. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_OPEN_FILE_LIST) ( IN CHAR16 *Path, IN UINT64 OpenMode, IN OUT EFI_SHELL_FILE_INFO **FileList ); Parameters Path A pointer to the path string. OpenMode Specifies the mode used to open each file, EFI_FILE_MODE_READ or EFI_FILE_MODE_WRITE. FileList Points to the start of a list of files opened. Description This function opens all of the files specified by Path.
FullName Specifies the full name of the file, including the path. Handle The file handle of the file after it was opened. Info The file information for the opened file. Status Codes Returned EFI_SUCCESS Others 40 Create the file list successfully. Can’t create the file list. Version 2.
EFI_SHELL_PROTOCOL.OpenRoot() Summary Opens the root directory of a device. Prototype typedef EFI_STATUS (EFIAPI EFI_SHELL_OPEN_ROOT)( IN EFI_DEVICE_PATH_PROTOCOL *DevicePath OUT EFI_FILE_HANDLE *FileHandle ); Parameters DevicePath Points to the device path corresponding to the device where the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL is installed. FileHandle On exit, points to the file handle corresponding to the root directory on the device.
EFI_SHELL_PROTOCOL.OpenRootByHandle() Summary Opens the root directory of a device on a handle Prototype typedef EFI_STATUS (EFIAPI EFI_SHELL_OPEN_ROOT_BY_HANDLE)( IN EFI_HANDLE DeviceHandle, OUT EFI_FILE_HANDLE *FileHandle ); Parameters DeviceHandle The handle of the device that contains the volume. FileHandle On exit, points to the file handle corresponding to the root directory on the device. Description This function opens the root directory of a device and returns a file handle to it.
EFI_SHELL_PROTOCOL.ReadFile() Summary Reads data from the file. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_READ_FILE) ( IN EFI_FILE_HANDLE FileHandle, IN OUT UINTN *ReadSize, OUT VOID *Buffer ); Parameters FileHandle The opened file handle for read ReadSize On input, the size of Buffer, in bytes. On output, the amount of data read. Buffer The buffer in which data is read.
EFI_SHELL_PROTOCOL.RemoveDupInFileList() Summary Deletes the duplicate file names files in the given file list. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_REMOVE_DUP_IN_FILE_LIST) ( IN EFI_SHELL_FILE_INFO **FileList ); Parameters FileList A pointer to the first entry in the file list. Description This function deletes the reduplicate files in the given file list. Status Codes Returned EFI_SUCCESS 44 Always success. Version 2.
EFI_SHELL_PROTOCOL.SetAlias() Summary Changes a shell command alias. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_SET_ALIAS)( IN CONST CHAR16 *Command, IN CONST CHAR16 *Alias, IN BOOLEAN Replace ); Parameters Command Points to the null-terminated shell command or existing alias. Alias Points to the null-terminated alias for the shell command. If this is NULL, and Command refers to an alias, that alias will be deleted.
EFI_SHELL_PROTOCOL.SetCurDir() Summary Changes the current directory on the specified device. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_SET_CUR_DIR) ( IN CONST CHAR16 *FileSystem OPTIONAL, IN CONST CHAR16 *Dir ); Parameters FileSystem A pointer to the file system’s mapped name. If NULL, then the current working directory is changed. Dir Points to the null-terminated directory on the device specified by FileSystem.
EFI_SHELL_PROTOCOL.SetEnv() Summary Sets the environment variable. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_SET_ENV) ( IN CONST CHAR16 *Name, IN CONST CHAR16 *Value, IN BOOLEAN Volatile ); Parameters Name Points to the null-terminated environment variable name. Value Points to the null-terminated environment variable value. If the value is an empty string then the environment variable is deleted. Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).
EFI_SHELL_PROTOCOL.SetFileInfo() Summary Sets the file information to an opened file handle. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_SET_FILE_INFO)( IN EFI_FILE_HANDLE FileHandle, IN CONST EFI_FILE_INFO *FileInfo ); Parameters FileHandle A file handle FileInfo Points to new file information. Description This function changes file information. Status Codes Returned EFI_SUCCESS The information was set. EFI_NO_MEDIA The device has no medium. EFI_DEVICE_ERROR The device reported an error.
EFI_SHELL_PROTOCOL.SetFilePosition() Summary Sets a file’s current position Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_SET_FILE_POSITION)( IN EFI_FILE_HANDLE FileHandle, IN UINT64 Position ); Parameters FileHandle The file handle on which requested position will be set. Position Byte position from the start of the file Description This function sets the current file position for the handle to the position supplied.
EFI_SHELL_PROTOCOL.SetMap() Summary Changes a shell command alias. Prototype typedef EFI_STATUS (EFIAPI *EFI_SHELL_SET_MAP)( IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN CONST CHAR16 *Mapping ); Parameters DevicePath Points to the device path. If this is NULL and Mapping points to a valid mapping, then the mapping will be deleted. Mapping Points to the null-terminated mapping for the device path. Description This function creates a mapping for a device path.
EFI_SHELL_PROTOCOL.WriteFile() Summary Writes data to the file. Prototype typedef EFI_STATUS (EFIAPI EFI_SHELL_WRITE_FILE)( IN EFI_FILE_HANDLE FileHandle, IN OUT UINTN *BufferSize, OUT VOID *Buffer ); Parameters FileHandle The opened file handle for writing. BufferSize On input, size of Buffer. Buffer The buffer in which data to write. Description This function writes the specified number of bytes to the file at the current file position.
2.3 EFI_SHELL_PARAMETERS_PROTOCOL EFI_SHELL_PARAMETERS_PROTOCOL Summary Shell application’s arguments.
54 Version 2.
3 UEFI Shell Features The UEFI Shell supports an interactive command-line interface, scripting, and a standard set of commands. All the commands can be invoked by entering the name of the command at the command prompt. For external commands, they must reside in a file system. So, to run them users need to have at least one mapped file system and put those external commands under this file system. The active drive may be changed by entering the mapped name followed by a ‘:’ at the command prompt. 3.
PATH support determines whether the PATH environment variable will be used to determine the location of executables. ALIAS support determines whether the ALIAS environment variable will be used to determine alternate names for shell commands. Interactive determines whether or not an interactive session can be started. For more information on scripting, see UEFI Shell Script (Chapter 4). For more information on processing of the startup.nsh file, please see UEFI Shell Initialization (section 3.3).
3.3 -noconsolein Console input will not be accepted from the user. This has no effect for UEFI Shells that do not support an interactive mode. -delay[:n] Specifies the integer number of seconds the shell will delay prior to the execution of startup.nsh. Ignored for shell level 0 or if –nostartup is specified. If n is not specified, the default is 5 seconds. If 0 is specified, then there will be no delay. If –nointerrupt is specified, then there will be no delay.
11. If startup.nsh is supported and enabled (see –startup and –nostartup), the script will be launched. 12. If a file name was specified among the command-line options, then the image or script (if supported) is launched. 3.3.1 Finding startup.nsh When executing startup.nsh, the shell will search for it first in the directory where the shell itself was launched. If it cannot find the startup.
3.4.1 Special Characters When the shell scans its input, it always treats certain characters (#, >, <, |, %, *, ?, ^, “, space, [, ] and newline) specially. The usage of these characters is briefly listed here: Table 3 Special Characters in Shell Character Description newline Ends a command line. space Ends an argument, if it is not in a quotation. # Starts a comment. > Used for output redirection. < Used for input redirection | Used for pipe command support.
For information about how the quotes are treated in each of the options, see “Shell Commands”, chapter 5). 3.4.4 Redirection 3.4.4.1 Output Redirection Output of EFI Shell commands can be redirected to files.
2>>v Append standard error to an environment variable, encoded as UCS2. The UEFI Shell will redirect standard output to a single file or variable and standard error to a single file or variable. Redirecting both standard output and standard error to different files or variables is allowed, but not to the same file or variable. Redirecting standard output to more than one file or variable on the same command is not supported.
UEFI_Shell_Command [options] | UEFI_Shell_Command When piping from an environment variable, the environment variable must already exist. If it does not, an error will be generated. Any Unicode Byte Ordering Characters are ignored. Table 6 Input Redirection Syntax Character Sequence Description | Pipe output of a command to another program in UCS-2 format. |a Pipe output of a command to another program in ASCII format.
Figure 1 Variable substitution flow chart 3.6.1 Environment Variables Environment variables are variables that can hold the user specified contents and can be used on the command line or in scripts. Each environment variable has a casesensitive name (a C-style identifier) and a string value. Environment variables can be either volatile (they will lose their value on reset or power-off) or non-volatile (they will maintain their value across reset or power-off).
Table 7 Environment Variables with Special Meaning to the UEFI Shell Variable V/NV Description RO/RW cwd V/RO The current working directory, including the current working file system. See “Current Directory” (page TBD) for more information. Lasterror V/RO Last returned error from a UEFI Shell command or batch script path V/RW The UEFI Shell has a default volatile environment variable path, which contains the default path that UEFI Shell will search if necessary.
uefiversion V/RO Reflects the revision of the UEFI specification that the underlying firmware supports. The contents will look like this: 2.10 3.6.2 Positional Parameters Positional parameters are the first ten arguments (%0-%9) passed from the command line into a UEFI shell script. The first parameter after the UEFI Shell script name becomes %1, the second %2, the third %3 , and so on. %0 is the full path name of the script itself.
the variable substitution. So if %myvariable% is set to dir and dir is aliased to ls, entering %myvariable% in command line will cause the ls command to be executed. Alias substitution is not recursive. There are several built-in aliases (sometimes referred to as synonyms) provided by the UEFI Shell for the following commands: Table 8 Built-in Aliases for the UEFI Shell Original Command 3.7 Built-In Alias Description ls dir List directory contents rm del Delete a file cp copy Copy a file.
[] can be either wildcard characters or literal file name characters, the UEFI Shell will try to take them as wildcard characters first to match files, if there are files matched, no further interpretation. Otherwise, they will be considered as literal characters in file names. Table 9 Wildcard Character Expansion Character Sequence Description * Matches zero or more characters in a file name. ? Matches exactly one character in a file name.
3.9 Nesting the Shell The UEFI Shell supports nested shell execution. The UEFI Shell can run the shell from within itself. The maximum nesting level is determined by how much memory the system has. The command exit can be used to exit the current shell instance. If the current shell is a child shell, it will return to the parent shell. Newly launched shell will have a brand new execution environment except for environment variables and aliases. 3.
3.10.3 Output Streaming Control The UEFI Shell supports the ability to pause and resume the streaming of characters to the output device. The user can press the CTRL-S key sequence to pause and any key to resume the output results produced by the current running commands or applications. It is especially useful for the commands and applications that may produce a great deal of the output results. 3.10.
implementation of the shell. Some of these command profiles are standard (see “Shell Command Profiles”, section 5.2) and others can be defined by implementers. During installation, UEFI Shell applications may provide a help file (as described in “Command-Line Help”, section 3.11.2) to support the standard help command. During installation, UEFI Shell applications may update a help file for the help category/categories to which the application belongs.
4 Scripts UEFI Shell scripts allow user to simplify routine or repetitive tasks. A shell script program is a UCS-2 or ASCII text file that contains one or more commands and has a .nsh file name extension. When the file name is typed at the command prompt, commands in the file are executed sequentially. All shell commands can be executed in scripts. In addition, some script-only commands are also provided to do basic flow control.
else, endif, and goto, the script will exit. If the error arousing script is a called by another script, the caller script will continue to execute. The lasterror shell variable allows scripts to test the results of the most recently executed command using the if command. This variable is maintained by the shell, is read-only, and cannot be modified by command set. Script-only commands, as well as echo, which are used to control the logic of the script, do not affect the value of variable lasterror.
5 5.1 Shell Commands Overview This section describes the standard UEFI Shell commands. The table below lists all standard UEFI Shell commands. Version 2.
Table 10 Commands from Default Build Shell Command Description Required at Shell Level or Profile alias Displays, creates, or deletes aliases in the UEFI Shell environment 3 attrib Displays or changes the attributes of files or directories.
Command Description Required at Shell Level or Profile alias Displays, creates, or deletes aliases in the UEFI Shell environment 3 attrib Displays or changes the attributes of files or directories. 2 edit Full screen editor for ASCII or UCS-2 files. Debug1 eficompress Compress a file using EFI Compression Algorithm. Debug1 efidecompress Decompress a file using EFI Decompression Algorithm. Debug1 else Conditionally execute commands if a previous if condition was false.
Command Description Required at Shell Level or Profile alias Displays, creates, or deletes aliases in the UEFI Shell environment 3 attrib Displays or changes the attributes of files or directories. 2 mkdir Creates one or more new directories. 2 mm Displays or modifies MEM/MMIO/IO/PCI/PCIE address space. Debug1 mode Displays or changes the console output device mode. Debug1 mv Moves one or more files to a destination within a file system.
Command Description Required at Shell Level or Profile alias Displays, creates, or deletes aliases in the UEFI Shell environment 3 attrib Displays or changes the attributes of files or directories. 2 unload Unloads a driver image that was already loaded. Driver1 ver Displays the version information for this EFI firmware. 3 5.1.
5.2 Shell Command Profiles Shell command profiles are groups of shell commands that are identified by a profile name. Profile names that begin with the ‘_’ character are reserved for individual implementations. For information on how profiles are identified, see section 3.3.2 (Supported Profiles). For more information on how profiles are updated when new commands are installed, see section 3.11 There are four standard profiles: Table 12Standard Profiles Profile Name 5.
Description This command displays, creates, or deletes aliases in the UEFI Shell environment. An alias provides a new name for an existing UEFI Shell command or UEFI application. Once the alias is created, it can be used to run the command or launch the UEFI application. There are some aliases that are predefined in the UEFI Shell environment. These aliases provide the MS-DOS and UNIX equivalent names for the file manipulation commands. See Built-In Aliases (section 3.6.4) for more details.
Shell> Shell> md rd * fs0 80 alias -v fs0 floppy alias : mkdir : rm : floppy Version 2.
attrib Summary Displays or changes the attributes of files or directories. Usage attrib [+a|-a] [+s|-s] [+h|-h] [+r|-r] [file...] [directory...] Options +a|-a Set or clear the ‘archive’ attribute +s|-s Set or clear the ‘system’ attribute +h|-h Set or clear the ‘hidden’ attribute +r|-r Set or clear the ‘read-only’ attribute file File name (wild cards are permitted) directory Directory name (wildcards are permitted) Description This command displays and sets the attributes of files or directories.
Status Codes Returned SHELL_SUCCESS The action was completed as requested. SHELL_NOT_FOUND The requested file was not found. SHELL_INVALID_PARAMETER One of the passed in parameters was incorrectly formatted or its value was out of bounds. SHELL_SECURITY_VIOLATION This function was not performed due to a security violation SHELL_WRITE_PROTECTED The media that the action was to take place on is write-protected.
bcfg Summary Manages the boot and driver options that are stored in NVRAM. Usage bcfg driver|boot [dump [-v]] [add # file "desc"] [addp # file “desc”] [addh # handle “desc”] [rm #] [mv # #] [-opt # [[filename]|[”data”]] | [KeyData *]] Options driver Display/modify the driver option list boot Display/modify the boot option list dump Display the option list -v Display the option list with extra info including the optional data. add Add an option.
associated with the driver or boot option optional data or else the quotedelimited data which will be associated with the driver or boot option optional data. KeyData The packed value associated with a hot-key. This is the equivalent of the EFI_KEY_DATA value in the UEFI specification. ScanCode This is the UEFI-defined Scan code portion of the EFI_INPUT_KEY struction. This value is directly associated with the preceding KeyData value and there may be 1 to 4 entries per the UEFI specification.
Shell> bcfg boot –opt 3 0x40000200 0 0x42 Status Codes Returned SHELL_SUCCESS The action was completed as requested. SHELL_NOT_FOUND The requested option was not found. SHELL_INVALID_PARAMETER One of the passed in parameters was incorrectly formatted or its value was out of bounds. SHELL_UNSUPPORTED The action as requested was unsupported.
cd Summary Displays or changes the current directory. Usage cd [path] Options path The relative or absolute directory path. Description This command changes the current working directory that is used by the UEFI Shell environment. If a file system mapping is specified, then the current working directory is changed for that device. Otherwise, the current working directory is changed for the current device.
Examples To change the current filesystem to the mapped fs0 filesystem: Shell> fs0: To change the current directory to subdirectory 'efi': fs0:\> cd efi To change the current directory to the parent directory (fs0:\): fs0:\efi\> cd ..
cls Summary Clears the standard output and optionally changes the background color. Usage cls [color] Options color - New background color 0 - Black 1 - Blue 2 - Green 3 - Cyan 4 - Red 5 - Magenta 6 - Yellow 7 - Light gray Description This command clears the standard output device with an optional background color attribute. If color is not specified, then the background color does not change. Status Codes Returned SHELL_SUCCESS The action was completed as requested.
comp Summary Compares the contents of two files on a byte for byte basis. Usage comp [-b] file1 file2 Options -b file1 file2 - Display one screen at a time - First file name (directory name or wildcards not permitted) - Second file name (directory name or wildcards not permitted) Description This command compares the contents of two files in binary mode. It displays up to 10 differences between the two files. For each difference, up to 32 bytes from the location where the difference starts is dumped.
fs0:\> comp bios.inf bios2.inf Compare fs0:\bios.inf to fs0:\bios2.inf Difference #1: File1: fs0:\bios.inf 00000000: 5F File2: fs0:\bios2.inf 00000000: 33 Difference #2: File1: fs0:\bios.inf 0000000C: 00 00 00 00 File2: fs0:\bios2.inf 0000000C: 25 32 03 03 [difference(s) encountered] 90 *_* *3* *....* *%2..* Version 2.
connect Summary Binds a driver to a specific device and starts the driver. Usage connect [[DeviceHandle] [DriverHandle] | [-c] | [-r]] Options -r Recursively scan all handles and check to see if any loaded or embedded driver can match the specified device. If so, the driver will be bound to the device. Additionally, if more device handles are created during the binding, these handles will also be checked to see if a matching driver can bind to these devices as well.
Status Codes Returned SHELL_SUCCESS The action was completed as requested. SHELL_SECURITY_VIOLATION This function was not performed due to a security violation SHELL_INVALID_PARAMETER One of the passed in parameters was incorrectly formatted or its value was out of bounds.
cp Summary Copies one or more source files or directories to a destination. Usage cp [-r] [-q] src [src...] [dst] Options src Source file/directory name (wildcards are permitted) dst Destination file/directory name (wildcards are not permitted). If not specified, then the current working directory is assumed to be the destination. If there are more than one directory specified, then the last is always assumed to be the destination. -r Recursive copy.
When copying to another directory, the directory must already exist. Status Codes Returned SHELL_SUCCESS The action was completed as requested. SHELL_INVALID_PARAMETER One of the passed in parameters was incorrectly formatted or its value was out of bounds. SHELL_OUT_OF_RESOURCES There was insufficient space to save the requested file at the destination.
fs0:\> cp -r test1 test2 boot \test copying fs0:\test1 -> fs0:\test\test1 copying fs0:\test1\test1.txt -> fs0:\test\test1\test1.txt - [ok] copying fs0:\test2 -> fs0:\test\test2 copying fs0:\test2\test2.txt -> fs0:\test\test2\test2.txt - [ok] copying fs0:\boot -> fs0:\test\boot copying fs0:\boot\shell.efi -> fs0:\test\boot\shell.
date Summary Displays and sets the current date for the system. Usage date [mm/dd/[yy]yy][-sfo] Options mm Month of the date to be set (1-12) dd Day of the date to be set (1-31) yy/yyyy Year of the date to be set. If only two digits, then 9x = 199x, otherwise 20xx. -sfo Standard-format output. See "Related Definitions" below. Description This command displays and/or sets the current date for the system. If no parameters are used, it shows the current date.
Shell > date 8/4/97 Shell > date 08/04/2097 Shell > Shell > date 8/4/98 Shell > date 08/04/1998 Shell > The range of valid years is from 1998–2099. Standard-Format Output The standard-format from the date command has a single table: Date, with the following columns: Table 14Date Command Table Column 2 Description Day (from 1-31) 3 Month (from 1-12) 4 Year (from 1998-2099) Status Codes Returned SHELL_SUCCESS The action was completed as requested.
dblk Summary Displays the contents of one or more blocks from a block device. Usage dblk device [lba] [blocks] [-b] Options device Block device name lba Index of the first block to be displayed (a hexadecimal number). The default is 0. blocks Number of blocks to be displayed (a hexadecimal number). The default is 0. If larger than 0x10, then only 0x10 are displayed. -b Display one screen at a time. Description This command displays the contents of one or more blocks from a block device.
Shell>dblk fs0 12 20 • To display one block of blk2, beginning from the first block (blk0): Version 2.
fs1:\tmps1> dblk blk2 0 1 LBA 0000000000000000 Size 00000000: EB 3C 90 4D 53 *.<.MSDOS5.0.....* 00000010: 02 00 02 00 00 *........?...?...* 00000020: 8E 2F 03 00 80 *./....),...NO NA* 00000030: 4D 45 20 20 20 3.* 00000040: 8E D1 BC F0 7B ......* 00000050: 38 4E 24 7D 24 *8N$.$....<.r...:* 00000060: 66 A1 1C 7C 26 *f...&f;.&.W.u...* 00000070: 02 88 56 02 80 *..V....s.3..F...* 00000080: 66 16 03 46 1C *f..F..V..F....v.* 00000090: 60 89 46 FC 89 ....^..* 000000A0: C3 48 F7 F3 01 *.H...F..N.a.....
Fat 16 BPB FatLabel: 'NO NAME ' SystemId: 'FAT16 ' OemId: 'MSDOS5.0' SectorSize 200 SectorsPerCluster 4 ReservedSectors 8 # Fats 2 Root Entries 200 Media F8 Sectors 32F8E SectorsPerFat CC SectorsPerTrack 3F Heads 255 Version 2.
del Summary Internal alias for the rm command. 102 Version 2.
devices Summary Displays the list of devices managed by UEFI drivers. Usage devices [-b] [-l XXX] Options -b -l XXX - Display one screen at a time - Display devices using the specified ISO 639-2 language Description The command prints a list of devices that are being managed by drivers that follow the UEFI Driver Model.
3 The device type: R – Root Controller B – Bus Controller D – Device Controller 4 A managing driver supports the Driver Configuration Protocol: Yes (Y) or No (N) 5 A managing driver supports the Driver Diagnostics Protocol: Yes (Y) or No (N) 6 The number of parent controllers for this device 7 The number of this type of devices. 8 The number of child controllers produced by this device 9 The name of the device from the Component Name Protocol 104 Version 2.
devtree Summary Displays the tree of devices compliant with the UEFI Driver Model. Usage devtree [-b] [-d] [-l XXX] [DeviceHandle] Options DeviceHandle Display device tree below a certain handle -b Display one screen at a time -d Display device tree using device paths -l Display device tree using the specified language Description This command prints a tree of devices that are being managed by drivers that follow the UEFI Driver Model.
dh Summary Displays the device handles in the UEFI environment. Usage dh [-l ] [handle | -p ] [-d] [-v] Options handle Specific handle to dump information about (a hexadecimal number). If not present, then all information will be dumped. -p Dumps all handles of a protocol specified by the GUID. -d Dumps UEFI Driver Model-related information. -l Dumps information using the language codes, as described in Appendix M of the UEFI specification.
Examples To display all handles and display one screen at a time: Shell> dh -b Handle dump 1: Image(DXE Core) 2: FwVol FwFileSys FwVolBlk DevPath(MemMap(11:1B500001D4FFC8)) 3: Image(Ebc) 4: DevPath(MemMap(11:1CA0000-1CB0000)) 5: Image(WinNtThunk) 6: WinNtThunk DevPath(..76F3-11D4-BCEA-0080C73C8881)) 7: Image(WinNtBusDriver) DriverBinding ... To display the detailed information on handle 0x30: Shell> dh 30 Handle 30 (01AF5308) IsaIo ROM Size......: 00000000 ROM Location..
Shell> dh -p Image -b Handle dump by protocol 'image' 1: Image(DXE Core) 5: Image(WinNtThunk) 7: Image(WinNtBusDriver) DriverBinding 8: Image(Metronome) A: Image(IsaBus) DriverBinding B: Image(WinNtConsole) DriverBinding ... Standard-Format Output When using the –sfo command-line option, the dh shell command will produce one of two tables: HandlesInfo or HandleInfo.
dir Summary An internal alias for the ls command. Version 2.
disconnect Summary Disconnects one or more drivers from the specified devices. Usage disconnect DeviceHandle [DriverHandle [ChildHandle]] Options DeviceHandle Device handle (a hexadecimal number). If not specified, then disconnect DriverHandle. DriverHandle Driver handle (a hexadecimal number) ChildHandle Child handle of a device (a hexadecimal number). If not specified, then all child handles of DeviceHandle will be disconnected. -r Disconnect all drivers from all devices.
fs0:\> disconnect 28 17 • To disconnect driver 0x17 from controlling the child 0x32 of device 0x28 fs0:\> disconnect 28 17 32 Version 2.
dmem Summary Displays the contents of system or device memory. Usage dmem [-b] [address] [size] [-MMIO] Options address Starting address in hexadecimal format size Number of bytes to display in hexadecimal format -b Display one screen at a time -MMIO Forces address cycles to the PCI bus Description This command displays the contents of system memory or device memory. address and size should be typed in hex value. If Address is not specified, then the contents of the EFI System Table are displayed.
Examples * To display the EFI system table pointer entries: fs0:\> dmem Memory Address 000000003FF7D808 200 Bytes 3FF7D808: 49 42 49 20 53 59 53 54-02 00 01 SYST....x...* 3FF7D818: 5C 3E 6A FE 00 00 00 00-88 2E 1B *\>j........?....* 3FF7D828: 26 00 0C 00 00 00 00 00-88 D3 1A *&..........?....* 3FF7D838: A8 CE 1A 3F 00 00 00 00-88 F2 1A *...?.......?....* 3FF7D848: 28 EE 1A 3F 00 00 00 00-08 DD 1A *(..?.......?....* 3FF7D858: A8 EB 1A 3F 00 00 00 00-18 C3 3F *...?..........
3FF7D9E8: 00 00 00 00 00 00 00 00-00 00 00 00 00 00 00 00 *................* 3FF7D9F8: 00 00 00 00 00 00 00 00-70 68 06 30 A0 00 00 00 *........ph.0....* Valid EFI Header at Address 000000003FF7D808 -------------------------------------------System: Table Structure size 00000078 revision 00010002 ConIn (3F1AD388) ConOut (3F1AF288) StdErr (3F1ADD08) Runtime Services 000000003F3FC318 Boot Services 000000003F3F4B00 SAL System Table 000000003FF22760 ACPI Table 000000003FFD9FC0 ACPI 2.
dmpstore Summary Manages all UEFI NVRAM variables. Usage dmpstore [-b] [-d] [-all | ([variable] [–guid guid])] dmpstore [-all | ([variable] [–guid guid])] -s file dmpstore [-all | ([variable] [–guid guid])] -l file Options -b Display one screen at a time variable Specifies the name of the variable name. May be a literal name or a pattern as specified in the MetaiMatch() function of the EFI_UNICODE_COLLATION2_PROCOOL. -guid Specifies the GUID of the variables to be displayed.
--- X --- All variables with the specified GUID will be operated on. X --- --- The variable with the GUID EFI_GLOBAL_VARIABLE and the name(s) Variable will be operated on. X X --- The variable with the specified GUID and name Variable will be operated on. The variable value is printed as hexadecimal dump. Option –d is used to delete variables. Option –s and –l are used to save and load variables to and from file.
drivers Summary Displays a list of information for drivers that follow the UEFI Driver Model in the UEFI environment. Usage drivers [-l XXX] Options -l Displays drivers using the language code XXX, which has the format specified by Appendix M of the UEFI specification. -sfo Displays information as described in “Standard-Format Output” below. Description This command displays a list of information for drivers that follow the UEFI Driver Model in the UEFI environment.
Examples • To display the list: Shell> drivers T D D Y C I R P F A V VERSION E G G #D #C DRIVER NAME NAME === ======= = = = == == ===================================== ========== 39 00000010 D - - 1 - Platform Console Management Driver ConPlatform 3A 00000010 D - - 1 - Platform Console Management Driver ConPlatform 3B 00000010 B - - 1 1 Console Splitter Driver ConSplitter 3C 00000010 ? - - - - Console Splitter Driver ConSplitter 3D 00000010 B - - 1 1 Console Splitter Driver ConSplitter 3E 00000010 ? - - -
7 Devices Managed. The number of devices that this driver is managing. 8 Child Devices. The number of child devices that this driver has produced. 9 Driver Name. The name of the driver from the Component Name Protocol. 10 Driver Image Path. The device path from which the driver was loaded. Version 2.
drvcfg Summary Configures the driver using the platform’s underlying configuration infrastructure. Usage drvcfg [-l XXX] [-c] [-f |-v|-s] [DriverHandle [DeviceHandle [ChildHandle]]] [-i filename] [-o filename] Options Type The type of default configuration options to force on the controller. 0 - Standard Defaults. 1 - Manufacturing Defaults. 2 - Safe Defaults. 4000-FFFF - Custom Defaults.
-o Export the settings of the specified driver instance to a file Description This command invokes the platform’s Configuration infrastructure. The table below describes the values for the Type parameter. Other values depend on the driver’s implementation. Table Default Values for the “Type” Parameter Value Type of Default Description 0x0000 Standard Defaults Places a controller in a state that is prepared for normal operation in a platform.
Shell> drvcfg –f 0 17 To force defaults on device 0x28 that is managed by driver 0x17: Shell> drvcfg –f 0 17 28 To force defaults on all child devices of device 0x28 that is managed by driver 0x17: Shell> drvcfg –f 0 17 28 –c 122 Version 2.
To force defaults on child device 0x30 of device 0x28 that is managed by driver 0x17: Shell> drvcfg –f 0 17 28 30 To validate options on all devices: Shell> drvcfg –v To validate options on all devices that are managed by driver 0x17: Shell> drvcfg –v 17 To validate options on device 0x28 that is managed by driver 0x17: Shell> drvcfg –v 17 28 To validate options on all child devices of device 0x28 that is managed by driver 0x17: Shell> drvcfg –v 17 28 –c To validate options on child device 0x30 of device 0x
drvdiag Summary Invokes the Driver Diagnostics Protocol.
Examples To display the list of devices that are available for diagnostics: Shell> drvdiag To display the list of devices and child devices that are available for diagnostics: Shell> drvdiag –c To run diagnostics in standard mode on all devices: Shell> drvdiag –s To run diagnostics in standard mode on all devices in English: Shell> drvdiag –s –l eng To run diagnostics in standard mode on all devices in Spanish: Shell> drvdiag –s –l spa To run diagnostics in standard mode on all devices and child devices: Sh
echo Summary Controls whether or not script commands are displayed as they are read from the script file and prints the given message to the display. Usage echo [-on|-off] echo [message] Options message Message to display -on Enables display when reading commands from script files. -off Disables display when reading commands from script files. Description The first form of this command controls whether or not script commands are displayed as they are read from the script file.
fs0:\> HelloWorld.nsh +HelloWorld.nsh> echo Hello World Hello World • To turn command echoing off: fs0:\> echo -off • To display the current echo setting: fs0:\> echo Echo is off Version 2.
edit Summary Full screen editor for ASCII or UCS-2 files. Usage edit [file] Options file Name of file to be edited. If none is specified, then an empty file will be created with a default file name. Description This command allows a file to be edited using a full screen editor. The editor supports both UCS-2 and ASCII file types. The following example shows typical output for help on this command. Examples • 128 To edit the 'shell.log' file: fs0:\> edit shell.log Version 2.
eficompress Summary Compress a file using EFI Compression Algorithm. Usage eficompress infile outfile Options infile outfile - Filename for uncompressed input file - Filename for compressed output file Description This command is used to compress a file using EFI Compression Algorithm and write the compressed form out to a new file. Examples • To compress a file named ‘uncompressed’ to file ‘compressed’: fs0:\> eficompress uncompressed compressed Version 2.
efidecompress Summary Decompress a file using EFI Decompression Algorithm. Usage efidecompress infile outfile Options infile Filename of compressed input file outfile Filename of decompressed output file Description This command is used to decompress a file using EFI Decompression Algorithm and write the decompressed form out to a new file. Examples • 130 To decompress a file named ‘compressed’ to file ‘uncompressed’: fs0:\> efidecompress compressed uncompressed Version 2.
exit Summary Exits the UEFI Shell or the current script. Usage exit [/b] [exit-code] Options /b Indicates that only the current UEFI shell script should be terminated. Ignored if not used within a script. exit-code If exiting a UEFI shell script, the value that will be placed into the environment variable lasterror. If exiting an instance of the UEFI shell, the value that will be returned to the caller. If not specified, then 0 will be returned.
for Usage for %indexvar in set command [arguments] [command [arguments]] … endfor for %indexvar run (start end [step]) command [arguments] [command [arguments]] … endfor Description The for command executes one or more commands for each item in a set of items. The set may be text strings or filenames or a mixture of both, separated by spaces (if not in a quotation).
Examples # # Sample for loop – listing all .txt files # echo -off for %a in *.txt echo %a exists endfor If in current directory, there are 2 files named file1.txt and file2.txt, the output of the sample script will be: Sample1> echo –off file1.txt exists file2.txt exists Theoretically it is legal for 2 nested for commands to use the same alphabet letter as their index variable, for instance, a.
getmtc Usage getmtc Description This command displays the current monotonic counter value. The lower 32 bits increment every time this command is executed. Every time the system is reset, the upper 32 bits will be incremented, and the lower 32 bits will be reset to 0. The following example is typical output from help for this command. Status Codes Returned SHELL_SUCCESS The action was completed as requested. SHELL_DEVICE_ERROR The underlying device was not working correctly.
goto Usage goto label Description The goto command directs script file execution to the line in the script file after the given label. The command is not supported from the interactive shell. A label is a line beginning with a colon (:). It can appear either after the goto command, or before the goto command. The search for label is done forward in the script file, from the current file position.
guid Summary Displays all registered EFI GUIDs. Usage guid [-b] Options -b Display one screen at a time Description This command displays a list of all the GUIDs that have been registered with the UEFI environment. Examples Note: 1. Only displays the GUIDs included in the core EFI build at the time the core was built. Additional GUIDs may have been added by the BIOS integrator.
help Summary Displays the list of commands that are built into the UEFI Shell. Usage help [cmd | pattern | special] [-usage] [-verbose] [-section sectionname][-b] Options cmd Command to display help about. pattern Pattern which describes the commands to be displayed. special Displays a list of the special characters used in the shell command line. -usage Display the usage information for the command.
Examples To display the list of commands in the UEFI Shell and break after one screen: Shell> help –b ? - Displays commands list or verbose help of a command alias - Displays, creates, or deletes aliases in the UEFI Shell attrib - Displays or changes the attributes of files or directories cd - Displays or changes the current directory cls - Clears the standard output with an optional background color connect - Binds an EFI driver to a device and starts the driver copy - Copies one or more files/directories
hexedit Summary Full screen hex editor for files, block devices, or memory.
if Controls which script commands will be executed based on provided conditional expressions.
In the second usage, the string1 == string2 condition is true if the two strings are identical. Here the comparison can be case sensitive or insensitive, it depends on the optional switch /i. If /i is specified, it will compare strings in the case insensitive manner; otherwise, it compares strings in the case sensitive manner. In the third usage, general purpose comparison is supported using expressions optionally separated by and or or.
appear at the start of the line (just after the if itself). The two may appear in either order. When performing comparisons, the Unicode Byte Ordering Character is ignored at the beginning of any argument.
Table 21 Boolean Functions Function Definition IsInt Evaluates to true if the parameter string that follows is a number (as defined below) and false otherwise. Exists Evaluates to true if the file specified by string exists is in the current working directory or false if not. Available Evaluates to true if the file specified by string is in the current working directory or current path.
Examples # # Example script for “if” command usages 1 and 2 # if exist fs0:\myscript.nsh then myscript myarg1 myarg2 endif if %myvar% == runboth then myscript1 myscript2 else echo ^%myvar^% != runboth endif In this example, if the script file myscript.nsh exists in fs0:\, this script will be launched with 2 arguments, myarg1 and myarg2.
ifconfig Summary Modify the default IP address of the UEFI IP4 Network Stack. Usage ifConfig [-?] [-c [Name]] [-l [Name]] [-s dhcp | > [permanent]] Options Name Adapter name, i.e., eth0 -c [Name] Clear the configuration for all or specified interface, and the network stack for related interface will fall back to the DHCP as default. -l [Name] List the configuration for all or the specified interface.
Examples To list the configuration for the interface eth0: Shell:\> IfConfig -l eth0 To use DHCP4 to request the IP4 address configuration dynamically for the interface eth0: Shell:\> IfConfig –s eth0 dhcp To use the static IP4 address configuration for the interface eth0, and this configuration survives the network reload: Shell:\> IfConfig –s 192.168.0.1 permanent 146 eth0 static 192.168.0.5 255.255.255.0 Version 2.
ipconfig Summary Displays or modifies the current IP configuration. Usage ipconfig [-r]|[-b] [-c Instance] [IpAddress [-m NetMask]] Options -r Restart the PXE base code and DHCP settings -b Display one screen at a time -c, -controller Specify the 0-based handle of the EFI_SIMPLE_NETWORK_PROTOCOL instance to use. IpAddress IP address in a.b.c.d format -m, -mask Network mask in 255.255.255.0 format Description This command displays or modifies the IP configuration of EFI_PXE_BASE_CODE_PROTOCOL.
load Summary Loads a UEFI driver into memory. Usage load [-nc] file [file...] Options -nc Load the driver, but do not connect the driver. File File that contains the image of the UEFI driver (wildcards are permitted) Description This command loads an driver into memory. It can load multiple files at one time, and the file name supports wildcards.
Examples fs0:\> load Isabus.efi load: Image 'fs0:\Isabus.efi' loaded at 18FE000 - Success fs0:\> load Isabus.efi IsaSerial.efi load: Image 'fs0:\Isabus.efi' loaded at 18E5000 - Success load: Image 'fs0:\IsaSerial.efi' loaded at 18DC000 - Success fs0:\> load Isa*.efi load: Image 'fs0:\IsaBus.efi' loaded at 18D4000 - Success load: Image 'fs0:\IsaSerial.efi' loaded at 18CB000 – Success fs0:\> load –nc IsaBus.efi load: Image ‘fs0:\Isabus.efi’ loaded at 18FE000 - Success Version 2.
loadpcirom Summary Loads a UEFI driver from a file in the format of a PCI Option ROM. Usage loadpcirom [-nc] romfile [romfile...] Options -nc romfile - Load the ROM image but do not connect the driver - PCI option ROM image file (wildcards are permitted) Description This command is used to load PCI option ROM images into memory for execution. The file can contain legacy images and multiple PE32 images, in which case all PE32 images will be loaded.
ls Summary Lists a directory's contents or file information. Usage ls [-r] [-a[attrib]][-sfo][file] Options -r Displays recursively (including subdirectories) -a Display only those files with the attributes which follow. If no attributes are listed, then all files will be listed. If –a is not specified, then all non-system and non-hidden files will be listed. The attributes (attrib) may be one or more of the following: 1. a - Archive 2. s - System 3. h - Hidden 4. - Read-only r 5.
specified, only the files that have all those attributes will be listed. If -a is followed by nothing, then all files/directories are displayed, regardless of their attributes. If -a itself is not specified, then all files except system and hidden files are displayed. Status Codes Returned SHELL_SUCCESS The action was completed as requested. SHELL_INVALID_PARAMETER One of the passed in parameters was incorrectly formatted or its value was out of bounds.
fs0:\> ls -ar Directory of: fs0:\ 06/18/01 11:14p 1 File(s) 0 Dir(s) r 29 29 bytes readme.txt 28,739 28,739 bytes IsaBus.efi To display the files with attribute of 's': fs0:\> ls -as isabus.efi Directory of: fs0:\ 06/18/01 10:59p 1 File(s) 0 Dir(s) To display all in fs0:\efi directory recursively: fs0:\> ls -r -a efi To search for files with the specified type in the current directory recursively: fs0:\> ls -r -a *.
5 Attributes. List of file attributes. The string can contain zero or more of the following (but no repeats): a – Archive d – Directory h – Hidden r – Read-Only s – System 6 File Creation Time. Time when the file was created, in the format: hh:mm:ss. 7 File Creation Date. Date when the file was created, in the format: dd.mm.yyyy. 8 File Access Time. Time when the file was accessed, in the format: hh:mm:ss 9 File Access Date. Date when the file was accessed, in the format: dd.mm.
map Summary Defines a mapping between a user-defined name and a device handle. Usage map [-d ] map [[-r][-v][-c][-f][-u][-t ][sname]] map [sname handle | mapping] Options sname MappingMapped name handle The number of handle, which is same as dumped from 'dh' mapping The device’s mapped name. Use this parameter to assign a new mapping to a device. The mapping must end with a ‘:’. -sfo Output will be formatted according to “Standard-Format Output” below.
Description This command creates a mapping between a user-defined name and a device. The most common use of this command is to create a the mapped name for devices that support a file system protocol. Once these mappings are created, the names can be used with all the file manipulation commands. The UEFI Shell environment creates default mappings for all of the devices that support a recognized file system.
Table 24 Standard Formatted Output (Mappings) Column Number Description 2 Mapped Name. The mapped device name. 3 Device Path. The device path which corresponds to the mapped device name. 4 Consistent Name. The consistent mapped name (if any) which is equivalent to MappedName. If MappedName is already a consistent mapped name, then this column is empty. Version 2.
md Summary An internal alias for the mkdir command. ' 158 Version 2.
mem Summary This is a built-in alias for dmem. Version 2.
memmap Summary Displays the memory map maintained by the EFI environment. Usage memmap [-b] Options -b Display one screen at a time Description This command displays the memory map that is maintained by the EFI environment. The EFI environment keeps track all the physical memory in the system and how it is currently being used. The EFI Specification defines a set of Memory Type Descriptors. Please see the EFI Specification for a description of how each of these memory types is used.
fs0:\> memmap Type Start End # Pages Attributes available 0000000000750000-0000000001841FFF 00000000000010F2 0000000000000009 LoaderCode 0000000001842000-00000000018A3FFF 0000000000000062 0000000000000009 available 00000000018A4000-00000000018C1FFF 000000000000001E 0000000000000009 LoaderData 00000000018C2000-00000000018CAFFF 0000000000000009 0000000000000009 BS_code 00000000018CB000-0000000001905FFF 000000000000003B 0000000000000009 BS_data 0000000001906000-00000000019C9FFF 00000000000000C4 000000000000000
5 Number Of 4KB Pages 6 Attributes Table 26 Standard-Format Output for memmap (Summary) Column Number Description 2 Total Memory Size (bytes) 3 Reserved Memory Total Size (bytes) 4 Boot Service Code Total Size (bytes) 5 Boot Service Data Total Size (bytes) 6 Runtime Code Total Size (bytes) 7 Runtime Data Total Size (bytes) 8 Loader Code Total Size (bytes) 9 Loader Data Total Size (bytes) 10 Available Total Size (bytes) 162 Version 2.
mkdir Summary Creates one or more new directories. Usage mkdir dir [dir...] Options dir Name of directory or directories to be created. Wildcards are not allowed. Description This command creates one or more new directories. If dir includes nested directories, then parent directories will be created before child directories. If the directory already exists, then the command will exit with an error. Status Codes Returned SHELL_SUCCESS The action was completed as requested.
fs0:\> mkdir temp1 temp2 fs0:\> ls Directory of: fs0:\ 06/18/01 06/18/01 06/18/01 06/18/01 06/18/01 164 08:05p
11:14p r 11:50p 11:52p 11:52p 1 File(s) 4 Dir(s) 512 29 512 512 512 211 bytes test readme.txt rafter temp1 temp2 Version 2.mm Summary Displays or modifies MEM/MMIO/IO/PCI/PCIE address space. Usage mm address [value] [-w 1|2|4|8] [-MEM | -MMIO | -IO | -PCI | -PCIE] [-n] Options address Starting address value The value to write. If not specified, then the current value will be displayed. -MEM Memory Address type. -IO IO Address type -PCI PCI Configuration Space. The address will have the format 0x000000ssbbddffrr, where ss = Segment, bb = Bus, dd = Device, ff = Function and rr = Register.
If Value is specified which should be typed in hex value, this command will write this value to specified address. Otherwise when this command is executed, the current contents of Address are displayed. If Value is specified, then –n is assumed. If -n is not specified, the command will run in interactive mode and the user has the option of modifying the contents by typing in a hex value. When the user pressed ‘ENTER’, then next address is displayed. This is continued until the user enters ‘q’.
Shell> mm 0000000000 -PCI PCI 0x0000000000000000 : PCI 0x0000000000000001 : PCI 0x0000000000000002 : PCI 0x0000000000000003 : PCI 0x0000000000000004 : PCI 0x0000000000000005 : 0x86 0x80 0x30 0x11 0x06 0x00 > > > > > > q These contents can also be displayed by 'PCI 00 00 00'.
mode Summary Displays or changes the console output device mode. Usage mode [col row] Options row Number of rows col Number of columns Description This command is used to change the display mode for the console output device. When this command is used without any parameters, it shows the list of modes that the standard output device currently supports. The mode command can then be used with the row and col parameter to change the number of rows and columns on the standard output device.
Shell> mode 80 50 Available modes on standard output col 80 row 25 col 80 row 50 * col 80 row 43 col 100 row 100 Version 2.
mv Summary Moves one or more files to a destination within a file system. Usage mv src [src...] [dst] Options src Source file/directory name (wildcards are permitted) dst Destination file/directory name (wildcards are permitted). If not specified, then the current working directory is assumed to be the destination. If there is more than one argument on the command line, the last one will always be considered the destination.
Examples To rename a file: fs0:\> mv IsaBus.efi Bus.efi moving fs0:\IsaBus.efi -> \Bus.efi - [ok] Version 2.
openinfo Summary Displays the protocols and agents associated with a handle. Usage openinfo Handle [-b] Options Handle Display open protocol information for specified handle -b Display one screen at a time Description This command is used to display the open protocols on a given handle. The example below is typical output from help for this command.
parse Summary Command used to retrieve a value from a particular record which was output in a standard formatted output. Usage parse filename tablename column [-i ] [-s ] Options filename Source file name tablename The name of the table being parsed. column The one-based column index to use to determine which value from a particular record to parse. -i Start parsing with the nth instance of specified tablename, after the specified instance of ShellCommand.
fs0:\> parse temp.txt VolumeInfo 2 MikesVolume Below is an example using the Index parameter: fs0:\> parse temp.txt FileInfo 3 –i 3 795 Status Codes Returned SHELL_SUCCESS The action was completed as requested. SHELL_INVALID_PARAMETER One of the passed in parameters was incorrectly formatted or its value was out of bounds. SHELL_NOT_FOUND The source file was not able to be found SHELL_SECURITY_VIOLATION This function was not performed due to a security violation 174 Version 2.
pause Usage pause [-q] Description The pause command prints a message to the display and then suspends script file execution and waits for keyboard input. Pressing any key resumes execution, except for q or Q. If q or Q is pressed, script processing terminates; otherwise execution continues with the next line after the pause command. The pause command is available only in scripts. Switch –q can hide the message and it’s optional. Examples Following script is a sample of 'pause' command: fs0:\> type pause.
pci Summary Displays PCI device list or PCI function configuration space. Usage pci [Bus Dev [Func] [-s Seg] [-i]] Options Bus Bus number Dev Device number Func Function number -s Optional segment number Seg specified -i Information interpreted Description This command will display all the PCI devices found in the system. And it can also display the configuration space of a PCI device according to the specified bus (Bus), device (Dev),and function (Func) addresses.
Shell> PCI Seg --00 Bus --00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 02 00 02 00 02 Dev Func --- ---00 00 ==> Bridge Device - Host/PCI bridge Vendor 8086 Device 1130 Prog Interface 0 01 00 ==> Bridge Device - PCI/PCI bridge Vendor 8086 Device 1131 Prog Interface 0 1E 00 ==> Bridge Device - PCI/PCI bridge Vendor 8086 Device 244E Prog Interface 0 1F 00 ==> Bridge Device - PCI/ISA bridge Vendor 8086 Device 2440 Prog Interface 0 1F 01 ==> Mass Storage Controlle
Shell> PCI 00 00 00 -i PCI Segment 00 Bus 00000000: 86 80 30 ........* 00000010: 08 00 00 ............* 00000020: 00 00 00 *................* 00000030: 00 00 00 *................* 00000040: 00 00 00 *................* 00000050: 50 00 09 *P..8............* 00000060: 00 00 00 *................* 00000070: 00 00 18 *................* 00000080: DE 2C CF *.,..............* 00000090: 00 00 D6 *........3.3.....* 000000A0: 02 00 20 .............* 000000B0: 00 00 00 *....0...........* 000000C0: 00 00 00 *............
Start Type Space Prefetchable? Size Limit ---------------------------------------------------------------20000000 Mem 32 bits YES 04000000 24000000 ---------------------------------------------------------------No Expansion ROM(30) Cardbus CIS ptr(28): Sub VendorID(2C): Capabilities Ptr(34): Interrupt Line(3C): Min_Gnt(3E): 00000000 0000 88 00 00 Subsystem ID(2E): Interrupt Pin(3D): Max_Lat(3F): 0000 00 00 To display configuration space of Segment 0, Bus 0, Device 0, Function 0: Shell> PCI 00 00 00 -s 0
ping Summary Ping the target host with IPv4 stack. Usage Ping [-n count] [-l size] TargetIp Options -n Number of echo request datagram to be sent. -l Size of data buffer in echo request datagram. TargetIp IPv4 address of the target machine. Description This command uses the ICMPv4 ECHO_REQUEST datagram to elicit ECHO_REPLY from a host. Examples To ping the target host with 64 bytes data: Shell:\> ping -l 64 192.168.0.
reconnect Summary Reconnects drivers to the specific device. Usage reconnect DeviceHandle [DriverHandle [ChildHandle]] reconnect -r Options DeviceHandle Device handle (a hexadecimal number) DriverHandle Driver handle (a hexadecimal number). If not specified, all drivers on the specified device will be reconnected. ChildHandle Child handle of device (a hexadecimal number). If not specified, then all child handles of the specified device will be reconnected. -r Reconnect drivers to all devices.
Shell> reconnect -r To reconnect all drivers to device 0x28: fs0:\> reconnect 28 To disconnect 0x17 from 0x28 then reconnect drivers with 0x17 as highest priority to device 0x28: fs0:\> reconnect 28 17 To disconnect 0x17 from 0x28 destroying child 0x32 then reconnect drivers with 0x17 as highest priority to device 0x28 fs0:\> reconnect 28 17 32 182 Version 2.
reset Summary Resets the system. Usage reset [-w [string]] reset [-s [string]] reset [-c [string]] Options -s -w -c string - Performs a shutdown Performs a warm boot Performs a cold boot String to be passed to reset service Description This command resets the system. The default is to perform a cold reset unless the -w parameter is specified. If the reset string is specified, then it is passed into the Reset() function, so the system can know the reason for the system reset.
rm Summary Deletes one or more files or directories. Usage rm [-q] file/directory [file/directory ...] Options -q Quiet mode; does not prompt user for a confirmation file File name (wildcards are permitted) directory Directory name (wildcards are permitted) Description This command deletes one or more files or directories. If the target is a directory, it will delete the directory, including all its subdirectories.
fs0:\> ls test Directory of: fs0:\test 06/18/01 06/18/01 06/19/01 06/19/01 01:01p
01:01p 12:59a 12:59a 0 File(s) 4 Dir(s) 512 0 512 512 0 bytes . .. temp1 temp2 Error occurs and RM will exit: fs0:\> rm test\temp11 temp2 rm/del: Cannot find 'fs0:\test\temp11' - Not Found To remove multiple directories with wildcards: fs0:\> rm test\temp* rm/del: Remove subtree 'fs0:\test\temp1' [y/n]? y removing fs0:\test\temp1\temp1.txt - [ok] removing fs0:\test\temp1\boot\nshell.sermode Summary Sets serial port attributes. Usage sermode [handle [baudrate parity databits stopbits]] Options handle Device handle for a serial port in hexadecimal. The dh command can be used to retrieve the right handle. baudrate Baud rate for specified serial port. The following values are supported: 50, 75, 110, 150, 300, 600, 1200, 1800, 2000, 2400, 3600, 4800, 7200, 9600(default), 19200, 38400, 57600, 115200, 230400, and 460800. All other values will be converted to the next highest setting.
Description This command displays or sets baud rate, parity attribute, data bits and stop bits of serial ports. If no attributes are specified, then the current settings are displayed. If no handle is specified, then all serial ports are displayed.
set Summary Displays, changes or deletes a UEFI Shell environment variables. Usage set [-v] [sname [value]] set [-d ] Options -d Deletes the environment variable -v Volatile variable sname Environment variable name value Environment variable value Description This command is used to maintain the UEFI Shell environment variables. This command can do the following: • Display the environment variables. • Create new environment variables. • Change the value of existing environment variables.
SHELL_OUT_OF_RESOURCES A request to set a variable in a non-volatile fashion could not be completed. The resulting non-volatile request has been converted into a volatile request. Examples To add an environment variable: Shell> set DiagnosticPath fs0:\efi\diag;fs1:\efi\diag To display environment variables: Shell> set * path : . diagnosticPath : fs0:\efi1.1\diag;fs1:\efi1.1\diag To delete an environment variable: Shell> set -d diagnosticpath Shell> set * path : .
setsize Summary Adjusts the size of a file. Usage setsize size file [file...] Options file The file or files which will have its size adjusted. size The desired size of the file once it is adjusted. Setting the size smaller than the actual data contained in this file will truncate this data. Description This command adjusts the size of a particular target file.
setvar Summary Changes the value of a UEFI variable. Usage setvar variable-name [–guid guid][-bs][-rs][-nv] [=data] Options variable-name The name of the UEFI variable to modify or display. -guid Specifies the GUID of the UEFI variable to modify or display. If not present, then the GUID EFI_GLOBAL_VARIABLE, as defined in chapter 3.2 of the UEFI specification. -bs Indicates that the variable is a boot variable. Should only be present for new variables, otherwise it is ignored.
Description This command changes the UEFI variable specified by name and guid. If = is specified, but data is not, the variable is deleted, if it exists. If = is not specified, then the current variable contents are displayed. If =data is specified, then the variable’s value is changed to the value specified by data. -bs, -rt and –nv are only useful if the variable already exists. If the variable already exists and the attributes cannot be changed, then -1 is returned. 192 Version 2.
shift Usage shift Description The shift command shifts the contents of a UEFI Shell script’s positional parameters so that %1 is discarded, %2 is copied to %1, %3 is copied to %2, %4 is copied to %3 and so on. This allows UEFI Shell scripts to process script parameters from left to right. Note: This command does not change the UEFI shell environment variable lasterror. Note: The shift command is available only in UEFI Shell scripts.
smbiosview Summary Displays SMBIOS information. Usage smbiosview [-t SmbiosType]|[-h SmbiosHandle]|[-s]|[-a] Options -t Display all structures of SmbiosType.
Version 2.
stall Summary Stalls the operation for a specified number of microseconds. Usage stall time Options time The number of microseconds for the processor to stall. Description This command would be used to establish a timed stall of operations during a script. Status Codes Returned SHELL_SUCCESS The action was completed as requested. SHELL_DEVICE_ERROR There was a hardware error associated with this request.
time Summary Displays or sets the current time for the system. Usage time [hh:mm[:ss]] [-tz tz] [-d dl] Options hh New hour (0-23) (required) mm New minute (0-59) (required) ss New second (0-59) If not specified, then zero will be used. -tz Timezone adjustment, measured in minutes offset from GMT. Valid values can be between -1440 and 1440 or 2047. If not present or set to 2047, time is interpreted as local time.
Shell > time 00000017:000004:0000 Shell > time 17:04:00 (GMT+08:00) Shell > The seconds parameter is optional. If there is no seconds number, it will set to zero by default. Status Codes Returned SHELL_SUCCESS The action was completed as requested.
timezone Summary Displays or sets time zone information. Usage timezone [-s hh:mm | -l] [-b] [-f] Options -s Set time zone associated with hh:mm offset from GMT -l Display list of all time zones -b Display one screen at a time -f Display full information for specified timezone Description This command displays and sets the current time zone for the system. If no parameters are used, it shows the current time zone.
Shell> timezone -l GMT-12:00, International Date Line West GMT-11:00, Midway Island, Samoa GMT-10:00, Hawaii GMT-09:00, Alaska GMT-08:00, Pacific Time(US & Canada); Tijuana GMT-07:00, Arizona, Chihuahua, La Paz, Mazatlan GMT-06:00, Central America, Central Time(US & Canada) GMT-05:00, Bogota, Lima, Quito, Eastern Time(US & Canada) GMT-04:00, Atlantic Time(Canada), Caracas, Santiago GMT-03:30, Newfoundland GMT-03:00, Brasilia, Buenos Aires, Georgetown, Greenland GMT-02:00, Mid-Atlantic GMT-01:00, Azores, Cap
touch Summary Updates the time and date on a file to the current time and date. Usage touch [-r] file [file …] Options file The name or pattern of the file or directory. There can be multiple files on the command-line. -r Recurse into subdirectories Description This command updates the time and date on the file that is specified by the file parameter to the current time and date. If multiple files are specified on the command line, it will continue processing.
type Summary Sends the contents of a file to the standard output device. Usage type [-a|-u] file [file...] Options file Name of the file to display. -a Display the file as if it is encoded as 8-bit ASCII -u Displays the file as if it were encoded as UCS-2 Unicode. Description This command sends the contents of a file to the standard output device. If no options are used, then the command attempts to automatically detect the file type. If it fails, then UCS-2 is presumed.
fs0:\> type -u pause.nsh # # Example script for 'pause' command # echo pause.nsh begin.. date time pause echo pause.nsh done. To display multiple files: fs0:\> type test.* How to Install? time stall 3000000 time Version 2.
unload Summary Unloads a driver image that was already loaded. Usage unload [-n] [-v|-verbose] Handle Options -n Skips all prompts during unloading, so that it can be used in a script file. -v, -verbose Dump verbose status information before the image is unloaded. Handle Handle of driver to unload, always taken as hexadecimal number Description This command unloads a driver image that was already loaded and which supports the unloading option (see EFI_LOADED_IMAGE_PROTOCOL’s Unload() member.
ver Summary Displays the version information for the UEFI Shell and the underlying UEFI firmware. Usage ver [-s|-terse] Options -s Displays only the UEFI Shell version -terse Description This command displays the version information for this EFI Firmware or the version information for the UEFI Shell itself. The information is retrieved through the EFI System Table or the Shell image.
From the EFI System Table's FIrmwareRevision field Status Codes Returned SHELL_SUCCESS 206 The action was completed as requested. Version 2.
vol Summary Displays the volume information for the file system that is specified by fs. Usage vol [fs] [-n ] vol [fs] [-d] Options fs The name of the file system. VolumeLabel The name of the file system. The following characters cannot be used: % ^ * + = [ ] | : ; “ < > ? / . No spaces are allowed in the volume label. -d Empty volume label. Description This command displays the volume information for the file system that is specified by fs.
shell> vol fs0 –n help_test Volume HELP_TEST (rw) 1,457,664 bytes total disk space 1,149,440 bytes available on disk 512 bytes in each allocation unit To get rid of the label of fs0: fs0:\> vol fs0 -d Volume has no label (rw) 1,457,664 bytes total disk space 220,160 bytes available on disk 512 bytes in each allocation unit 208 Version 2.
Appendix A UEFI Shell Consistent Mapping Design This appendix describes how device assignments are created. A.1 Requirement: 1. The shell shall support consistent device assignments across (through) reboots. e.g. same concept as how you assign the letter D: to a partition under DOS/Windows. 2. The shell commands shall support defining mappings. For identical machines with the same hardware configurations the mapping result should always be the same. 3. Not use the NV storage.
The change of the number or physical connection of hardware which can have child hardware devices will be considered as hardware configuration change. Example: A.2.2.1 A.2.2.2 A.2.3 Hardware configuration change example 1. Change IDE disk from IDE primary master to slave 2. Change USB device from port0 to port1 3. Add or remove a SCSI controller adapt card Formatted: Bullets and Numbering Hardware configuration not change example 1.
2. Use certain algorithm to sort all the condensed device paths 3. Adding/Removing controller(s) would change the index (hardware configuration change) Formatted: Bullets and Numbering CSD(Connection Specific Descriptor): A string of numbers and characters, which identifies how the device connects to parent controller. A.2.5 1. Specify the connection of device 2.
The 4 USB devices are the hard disks, so their MTDs are “hd”. A.2.5.2 Step 2: Determine HI HI is determined by ACPI device path node and hardware device path node 1. Algorithm to calculate the HI 2. Enumerate all device path exist in system, whether there is a file system on it or not. 3. Split the device path: the hardware and ACPI device path node part consists of the HI device path that generates the HI and the remain device path consist the CSD device path which generate the CSD.
UHC1 UHC2 UHC3 UHC4 A.2.5.3 acpi(pnp0a03,0)/pci(1d|0) acpi(pnp0a03,0)/pci(1d|1) acpi(pnp0a03,0)/pci(1d|2) acpi(pnp0a03,0)/pci(1d|3) - 5 8 12 20 Step 3: Determine CSD For each kind device path node, there are rules to translate the device path node to the CSD. A.2.5.3.
acpi(pnp0a03,0)/pci(1d,0)/usb(0,1)/usb(1,1)/HD(Part4, sigxxx) Æ hd5a1b1e acpi(pnp0a03,0)/pci(1d,3)/usb(0,1)/usb(5,1)/HD(Part2, sigxxx) Æ hd8a1d1c acpi(pnp0a03,0)/pci(1d,1)/usb(1,0)/HD(Part3, sigxxx) Æ hd12b0d acpi(pnp0a03,0)/pci(1d,2)/usb(1,0)/ usb(2,0)/HD(Part1, sigxxx) Æ hd20b0c0b A.3 Implementation Consistent Mapping = MTD fp floppy hd hard disk cd cd rom f unknown media HI 1. Extract the hardware device path node and ACPI device path node from each device path in system, 2.
MESSAGING_DEVICE MSG_ATAPI CSD Node IDE channel index (0 for primary, master, 3 for secondary slave) MESSAGING_DEVICE MSG_SCSI CSD Node Use LUN number and PUN number for SCSI node MESSAGING_DEVICE MSG_FIBRECHANNEL CSD Node Use WWW number and LUN number for fibre channel device node MESSAGING_DEVICE MSG_1394 CSD Node Use GUID as CSD for 1394 device path node MESSAGING_DEVICE MSG_USB CSD Node Use interface number and port number for USB node MESSAGING_DEVICE MSG_USB_CLASS NONE Not proce
BBS_DEVICE A.3.1 BBS_BBS NONE Don’t process. Get the MTD The MTD is a string that carries device’s media info. Such as floppy, hard disk or others. The MTD is a string that makes the mapping more readable. Now, the MTD has four types: fp(floppy), hd(hard disk), cd(CD Rom) and f(unknown type). The MTD’s info come from the device path. the algorithm go through each node of the device path to find the special node that can specify this device’s MTD.
A.3.3.1.1 Example usb(0,1) Æ a1 usb(1,0) Æ b0 A.3.3.2 Floppy Devices General consistent mapping rule Use _UID for CSD A.3.3.2.1 A.3.3.3 Examples: 1. acpi(pnp0604,0) Æ a 2. acpi(pnp0604,1) Æ b 3. IDE Devices Formatted: Bullets and Numbering CSD of ATAPI device path node ATAPI node Æ ide channel index 0 for primary, master, 3 for secondary slave A.3.3.4 CSD of LUN Device path node Use the LUN number A.3.3.4.1 Examples: USB(0x2,0x1)/Unit(0x0) Æ c10 USB(0x2,0x1)/Unit(0x2) Æ c12 A.3.3.
A.3.3.7.1 Examples Ata(Primary,Master) Æ a Ata(Primary, Slave) Æ b Ata(Secondary,Master) Æ c Ata(Secondary, Slave) Æ d HD(p2, sig*) Æ c CD(Entry0) Æ a SCSI device A.3.3.8 CSD of SCSI device path node Use LUN number and PUN number for scsi node A.3.3.8.1 Examples: scsi(1,0) Æ b0 scsi(2,0) Æ c0 scsi(2,0)/scsi(1,0) Æ c0b0 A.3.3.
A.3.3.14 UART Device Path Use Baud Rate, Data Bits, Parity, Stop Bits as CSD A.3.3.15 Vendor-Defined Device Path Use guid as CSD {18ABEA39-F472-4278-BD55-E8C81C7030E1} Æ biklokdjpehcechilnffoimibmhadaob A.3.3.16 Vendor-defined Media Device Path Use Vendor_GUID as CSD A.3.3.17 File Path Media Device Path Put file path in MTD A.4 Function & Structure.
Pseudo Code foreach handle in System { Get DevicePath form handle; If DevicePath is null { Continue; } HIDevicePath = ExtractHI(DevicePath); Add the HIDevicePath to the HDPT } Sort the HDPT Status Codes Returned SHELL_SUCCESS Success to get the HI device path table. SHELL_OUT_OF_RESOURCE Can not create the HI device path table.
Sort the HI device path table.
222 Version 2.
Appendix B UEFI Help Manual Page Syntax The manual page files are standard text files with title and section heading information embedded using commands which begin with a ‘.’. The following two macros are supported: .TH command-name 0 “short-description” Title header. When printing multi-page help, this will appear at the top of each page. .SH section-name Sub-header. Specifies one of several standard sub-headings.
224 Version 2.
Appendix C UEFI Shell Status Codes Most UEFI Shell commands return SHELL_STATUS code values. These UEFI Shell status codes are enumerated below. Table 31 SHELL_STATUS return codes Mnemonic Value Description SHELL_SUCCESS 0 The operation completed successfully SHELL_LOAD_ERROR 1 The image failed to load. SHELL_INVALID_PARAMETER 2 There was an error in the command-line options. SHELL_UNSUPPORTED 3 The operation is not supported.
SHELL_SECURITY_VIOLATION 26 The function was not performed due to a security violation. SHELL_NOT_EQUAL 27 The function was performed and resulted in an unequal comparison.. 226 Version 2.
Appendix D UEFI Shell Command Standard Formatted Output This section describes the general, table-based standard output format for UEFI shell commands. The format is designed so that tools can easily process output produced by shell commands. UEFI shell commands using standard formatted output display the same information they would normally display, except using rows and columns of comma-delimited data. The first column always contains a C-style identifier which describes the type of data on the row.
sfo-columns, | sfo-column sfo-column := quoted-string | Example VolumeInfo, "TimsVolume","400000000","32000000","16000000" FileInfo, "fs0:/efi/boot/winloader.efi","45670","arsh" FileInfo, "fs0:/efi/boot/timsfile.txt","1250","a" FileInfo, "fs0:/efi/boot/readme.txt","795","a" 228 Version 2.