2 EFI Shell protocol as defined in the UEFI Shell 2.0 specification including errata.
4 Copyright (c) 2006 - 2009, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
15 #ifndef __EFI_SHELL_PROTOCOL__
16 #define __EFI_SHELL_PROTOCOL__
18 #include <Protocol/SimpleFileSystem.h>
19 #include <Guid/FileInfo.h>
21 #define EFI_SHELL_PROTOCOL_GUID \
23 0x6302d008, 0x7f9b, 0x4f30, { 0x87, 0xac, 0x60, 0xc9, 0xfe, 0xf5, 0xda, 0x4e } \
26 // replaced EFI_LIST_ENTRY with LIST_ENTRY for simplicity.
27 // they are identical outside of the name.
29 LIST_ENTRY Link
; ///< Linked list members.
30 EFI_STATUS Status
; ///< Status of opening the file. Valid only if Handle != NULL.
31 CONST CHAR16
*FullName
; ///< Fully qualified filename.
32 CONST CHAR16
*FileName
; ///< name of this file.
33 EFI_FILE_HANDLE Handle
; ///< Handle for interacting with the opened file or NULL if closed.
34 EFI_FILE_INFO
*Info
; ///< Pointer to the FileInfo struct for this file or NULL.
35 } EFI_SHELL_FILE_INFO
;
38 Returns whether any script files are currently being processed.
40 @retval TRUE There is at least one script file active.
41 @retval FALSE No script files are active now.
46 (EFIAPI
*EFI_SHELL_BATCH_IS_ACTIVE
) (
51 Closes the file handle.
53 This function closes a specified file handle. All 'dirty' cached file data is
54 flushed to the device, and the file is closed. In all cases, the handle is
57 @param[in] FileHandle The file handle to be closed
59 @retval EFI_SUCCESS The file closed sucessfully.
63 (EFIAPI
*EFI_SHELL_CLOSE_FILE
)(
64 IN EFI_FILE_HANDLE FileHandle
68 Creates a file or directory by name.
70 This function creates an empty new file or directory with the specified attributes and
71 returns the new file's handle. If the file already exists and is read-only, then
72 EFI_INVALID_PARAMETER will be returned.
74 If the file already existed, it is truncated and its attributes updated. If the file is
75 created successfully, the FileHandle is the file's handle, else, the FileHandle is NULL.
77 If the file name begins with >v, then the file handle which is returned refers to the
78 shell environment variable with the specified name. If the shell environment variable
79 already exists and is non-volatile then EFI_INVALID_PARAMETER is returned.
81 @param[in] FileName Pointer to null-terminated file path.
82 @param[in] FileAttribs The new file's attrbiutes. the different attributes are
83 described in EFI_FILE_PROTOCOL.Open().
84 @param[out] FileHandle On return, points to the created file handle or directory's handle
86 @retval EFI_SUCCESS The file was opened. FileHandle points to the new file's handle.
87 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
88 @retval EFI_UNSUPPORTED could not open the file path
89 @retval EFI_NOT_FOUND The specified file could not be found on the device, or could not
90 file the file system on the device.
91 @retval EFI_NO_MEDIA The device has no medium.
92 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no
94 @retval EFI_DEVICE_ERROR The device reported an error or can't get the file path according
96 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
97 @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write
98 when the media is write-protected.
99 @retval EFI_ACCESS_DENIED The service denied access to the file.
100 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file.
101 @retval EFI_VOLUME_FULL The volume is full.
105 (EFIAPI
*EFI_SHELL_CREATE_FILE
)(
106 IN CONST CHAR16
*FileName
,
107 IN UINT64 FileAttribs
,
108 OUT EFI_FILE_HANDLE
*FileHandle
112 Deletes the file specified by the file handle.
114 This function closes and deletes a file. In all cases, the file handle is closed. If the file
115 cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is returned, but the
116 handle is still closed.
118 @param[in] FileHandle The file handle to delete.
120 @retval EFI_SUCCESS The file was closed and deleted, and the handle was closed.
121 @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not deleted.
125 (EFIAPI
*EFI_SHELL_DELETE_FILE
)(
126 IN EFI_FILE_HANDLE FileHandle
130 Deletes the file specified by the file name.
132 This function deletes a file.
134 @param[in] FileName Points to the null-terminated file name.
136 @retval EFI_SUCCESS The file was closed and deleted, and the handle was closed.
137 @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not deleted.
141 (EFIAPI
*EFI_SHELL_DELETE_FILE_BY_NAME
)(
142 IN CONST CHAR16
*FileName
146 Disables the page break output mode.
150 (EFIAPI
*EFI_SHELL_DISABLE_PAGE_BREAK
) (
155 Enables the page break output mode.
159 (EFIAPI
*EFI_SHELL_ENABLE_PAGE_BREAK
) (
164 Execute the command line.
166 This function creates a nested instance of the shell and executes the specified
167 command (CommandLine) with the specified environment (Environment). Upon return,
168 the status code returned by the specified command is placed in StatusCode.
170 If Environment is NULL, then the current environment is used and all changes made
171 by the commands executed will be reflected in the current environment. If the
172 Environment is non-NULL, then the changes made will be discarded.
174 The CommandLine is executed from the current working directory on the current
177 @param[in] ParentImageHandle A handle of the image that is executing the specified
179 @param[in] CommandLine Points to the null-terminated UCS-2 encoded string
180 containing the command line. If NULL then the command-
182 @param[in] Environment Points to a null-terminated array of environment
183 variables with the format 'x=y', where x is the
184 environment variable name and y is the value. If this
185 is NULL, then the current shell environment is used.
186 @param[out] ErrorCode Points to the status code returned by the command.
188 @retval EFI_SUCCESS The command executed successfully. The status code
189 returned by the command is pointed to by StatusCode.
190 @retval EFI_INVALID_PARAMETER The parameters are invalid.
191 @retval EFI_OUT_OF_RESOURCES Out of resources.
192 @retval EFI_UNSUPPORTED Nested shell invocations are not allowed.
196 (EFIAPI
*EFI_SHELL_EXECUTE
) (
197 IN EFI_HANDLE
*ParentImageHandle
,
198 IN CHAR16
*CommandLine OPTIONAL
,
199 IN CHAR16
**Environment OPTIONAL
,
200 OUT EFI_STATUS
*StatusCode OPTIONAL
204 Find files that match a specified pattern.
206 This function searches for all files and directories that match the specified
207 FilePattern. The FilePattern can contain wild-card characters. The resulting file
208 information is placed in the file list FileList.
210 The files in the file list are not opened. The OpenMode field is set to 0 and the FileInfo
211 field is set to NULL.
213 @param[in] FilePattern Points to a null-terminated shell file path, including wildcards.
214 @param[out] FileList On return, points to the start of a file list containing the names
215 of all matching files or else points to NULL if no matching files
218 @retval EFI_SUCCESS Files found.
219 @retval EFI_NOT_FOUND No files found.
220 @retval EFI_NO_MEDIA The device has no media.
221 @retval EFI_DEVICE_ERROR The device reported an error.
222 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
226 (EFIAPI
*EFI_SHELL_FIND_FILES
)(
227 IN CONST CHAR16
*FilePattern
,
228 OUT EFI_SHELL_FILE_INFO
**FileList
232 Find all files in a specified directory.
234 @param[in] FileDirHandle Handle of the directory to search.
235 @param[out] FileList On return, points to the list of files in the directory
236 or NULL if there are no files in the directory.
238 @retval EFI_SUCCESS File information was returned successfully.
239 @retval EFI_VOLUME_CORRUPTED The file system structures have been corrupted.
240 @retval EFI_DEVICE_ERROR The device reported an error.
241 @retval EFI_NO_MEDIA The device media is not present.
245 (EFIAPI
*EFI_SHELL_FIND_FILES_IN_DIR
)(
246 IN EFI_FILE_HANDLE FileDirHandle
,
247 OUT EFI_SHELL_FILE_INFO
**FileList
251 Flushes data back to a device.
253 This function flushes all modified data associated with a file to a device.
255 @param[in] FileHandle The handle of the file to flush
257 @retval EFI_SUCCESS The data was flushed.
258 @retval EFI_NO_MEDIA The device has no medium.
259 @retval EFI_DEVICE_ERROR The device reported an error.
260 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
261 @retval EFI_WRITE_PROTECTED The file or medium is write-protected.
262 @retval EFI_ACCESS_DENIED The file was opened read-only.
263 @retval EFI_VOLUME_FULL The volume is full.
267 (EFIAPI
*EFI_SHELL_FLUSH_FILE
)(
268 IN EFI_FILE_HANDLE FileHandle
274 This function cleans up the file list and any related data structures. It has no
275 impact on the files themselves.
277 @param[in] FileList The file list to free. Type EFI_SHELL_FILE_INFO is
278 defined in OpenFileList()
280 @retval EFI_SUCCESS Free the file list successfully.
284 (EFIAPI
*EFI_SHELL_FREE_FILE_LIST
) (
285 IN EFI_SHELL_FILE_INFO
**FileList
289 Returns the current directory on the specified device.
291 If FileSystemMapping is NULL, it returns the current working directory. If the
292 FileSystemMapping is not NULL, it returns the current directory associated with the
293 FileSystemMapping. In both cases, the returned name includes the file system
294 mapping (i.e. fs0:\current-dir).
296 @param[in] FileSystemMapping A pointer to the file system mapping. If NULL,
297 then the current working directory is returned.
299 @retval !=NULL The current directory.
300 @retval NULL Current directory does not exist.
304 (EFIAPI
*EFI_SHELL_GET_CUR_DIR
) (
305 IN CONST CHAR16
*FileSystemMapping OPTIONAL
308 typedef UINT32 EFI_SHELL_DEVICE_NAME_FLAGS
;
309 #define EFI_DEVICE_NAME_USE_COMPONENT_NAME 0x00000001
310 #define EFI_DEVICE_NAME_USE_DEVICE_PATH 0x00000002
313 Gets the name of the device specified by the device handle.
315 This function gets the user-readable name of the device specified by the device
316 handle. If no user-readable name could be generated, then *BestDeviceName will be
317 NULL and EFI_NOT_FOUND will be returned.
319 If EFI_DEVICE_NAME_USE_COMPONENT_NAME is set, then the function will return the
320 device's name using the EFI_COMPONENT_NAME2_PROTOCOL, if present on
323 If EFI_DEVICE_NAME_USE_DEVICE_PATH is set, then the function will return the
324 device's name using the EFI_DEVICE_PATH_PROTOCOL, if present on DeviceHandle.
325 If both EFI_DEVICE_NAME_USE_COMPONENT_NAME and
326 EFI_DEVICE_NAME_USE_DEVICE_PATH are set, then
327 EFI_DEVICE_NAME_USE_COMPONENT_NAME will have higher priority.
329 @param[in] DeviceHandle The handle of the device.
330 @param[in] Flags Determines the possible sources of component names.
331 @param[in] Language A pointer to the language specified for the device
332 name, in the same format as described in the UEFI
333 specification, Appendix M.
334 @param[out] BestDeviceName On return, points to the callee-allocated null-
335 terminated name of the device. If no device name
336 could be found, points to NULL. The name must be
337 freed by the caller...
339 @retval EFI_SUCCESS Get the name successfully.
340 @retval EFI_NOT_FOUND Fail to get the device name.
344 (*EFI_SHELL_GET_DEVICE_NAME
) (
345 IN EFI_HANDLE DeviceHandle
,
346 IN EFI_SHELL_DEVICE_NAME_FLAGS Flags
,
348 OUT CHAR16
**BestDeviceName
352 Gets the device path from the mapping.
354 This function gets the device path associated with a mapping.
356 @param[in] Mapping A pointer to the mapping
358 @retval !=NULL Pointer to the device path that corresponds to the
359 device mapping. The returned pointer does not need
361 @retval NULL There is no device path associated with the
365 CONST EFI_DEVICE_PATH_PROTOCOL
*
366 (EFIAPI
*EFI_SHELL_GET_DEVICE_PATH_FROM_MAP
) (
367 IN CONST CHAR16
*Mapping
371 Converts a file system style name to a device path.
373 This function converts a file system style name to a device path, by replacing any
374 mapping references to the associated device path.
376 @param[in] Path The pointer to the path.
378 @return The pointer of the file path. The file path is callee
379 allocated and should be freed by the caller.
382 EFI_DEVICE_PATH_PROTOCOL
*
383 (EFIAPI
*EFI_SHELL_GET_DEVICE_PATH_FROM_FILE_PATH
) (
384 IN CONST CHAR16
*Path
388 This function updated with errata.
390 Gets either a single or list of environment variables.
392 If name is not NULL then this function returns the current value of the specified
393 environment variable.
395 If Name is NULL than a list of all environment variable names is returned. Each a
396 NULL terminated string with a double NULL terminating the list.
398 @param[in] Name A pointer to the environment variable name. If
399 Name is NULL, then the function will return all
400 of the defined shell environment variables. In
401 the case where multiple environment variables are
402 being returned, each variable will be terminated by
403 a NULL, and the list will be terminated by a double
406 @return !=NULL A pointer to the returned string.
407 The returned pointer does not need to be freed by the caller.
409 @retval NULL The environment variable doesn't exist or there are
410 no environment variables.
414 (EFIAPI
*EFI_SHELL_GET_ENV
) (
415 IN CONST CHAR16
*Name OPTIONAL
419 Gets the file information from an open file handle.
421 This function allocates a buffer to store the file's information. It's the caller's
422 responsibility to free the buffer.
424 @param[in] FileHandle A File Handle.
426 @return !=NULL Cannot get the file info.
427 @return NULL A pointer to a buffer with file information.
431 (EFIAPI
*EFI_SHELL_GET_FILE_INFO
)(
432 IN EFI_FILE_HANDLE FileHandle
436 Converts a device path to a file system-style path.
438 This function converts a device path to a file system path by replacing part, or all, of
439 the device path with the file-system mapping. If there are more than one application
440 file system mappings, the one that most closely matches Path will be used.
442 @param[in] Path The pointer to the device path
444 @return all The pointer of the null-terminated file path. The path
445 is callee-allocated and should be freed by the caller.
449 (EFIAPI
*EFI_SHELL_GET_FILE_PATH_FROM_DEVICE_PATH
) (
450 IN CONST EFI_DEVICE_PATH_PROTOCOL
*Path
454 Gets a file's current position.
456 This function returns the current file position for the file handle. For directories, the
457 current file position has no meaning outside of the file system driver and as such, the
458 operation is not supported.
460 @param[in] FileHandle The file handle on which to get the current position.
461 @paramp[out] Position Byte position from the start of the file.
463 @retval EFI_SUCCESS Data was accessed.
464 @retval EFI_UNSUPPORTED The request is not valid on open directories.
468 (EFIAPI
*EFI_SHELL_GET_FILE_POSITION
)(
469 IN EFI_FILE_HANDLE FileHandle
,
474 Gets the size of a file.
476 This function returns the size of the file specified by FileHandle.
478 @param[in] FileHandle The handle of the file.
479 @param[out] Size The size of this file.
481 @retval EFI_SUCCESS Get the file's size.
482 @retval EFI_DEVICE_ERROR Can't access the file.
486 (EFIAPI
*EFI_SHELL_GET_FILE_SIZE
)(
487 IN EFI_FILE_HANDLE FileHandle
,
492 Return help information about a specific command.
494 This function returns the help information for the specified command. The help text
495 can be internal to the shell or can be from a UEFI Shell manual page.
497 If Sections is specified, then each section name listed will be compared in a casesensitive
498 manner, to the section names described in Appendix B. If the section exists,
499 it will be appended to the returned help text. If the section does not exist, no
500 information will be returned. If Sections is NULL, then all help text information
501 available will be returned.
503 @param[in] Command Points to the null-terminated UEFI Shell command name.
504 @param[in] Sections Points to the null-terminated comma-delimited
505 section names to return. If NULL, then all
506 sections will be returned.
507 @param[out] HelpText On return, points to a callee-allocated buffer
508 containing all specified help text.
510 @retval EFI_SUCCESS The help text was returned.
511 @retval EFI_OUT_OF_RESOURCES The necessary buffer could not be allocated to hold the
513 @retval EFI_INVALID_PARAMETER HelpText is NULL.
514 @retval EFI_NOT_FOUND There is no help text available for Command.
518 (EFIAPI
*EFI_SHELL_GET_HELP_TEXT
) (
519 IN CONST CHAR16
*Command
,
520 IN CONST CHAR16
*Sections OPTIONAL
,
521 OUT CHAR16
**HelpText
525 This funciton is updated with Errata.
527 Gets the mapping(s) that most closely matches the device path.
529 This function gets the mapping which corresponds to the device path *DevicePath. If
530 there is no exact match, then the mapping which most closely matches *DevicePath
531 is returned, and *DevicePath is updated to point to the remaining portion of the
532 device path. If there is an exact match, the mapping is returned and *DevicePath
533 points to the end-of-device-path node.
535 If there are multiple map names they will be semi-colon seperated in the
536 NULL-terminated string.
538 @param[in,out] DevicePath On entry, points to a device path pointer. On
539 exit, updates the pointer to point to the
540 portion of the device path after the mapping.
542 @retval NULL No mapping was found.
543 @retval !=NULL Pointer to null-terminated mapping. The buffer
544 is callee allocated and should be freed by the caller.
548 (EFIAPI
*EFI_SHELL_GET_MAP_FROM_DEVICE_PATH
) (
549 IN OUT EFI_DEVICE_PATH_PROTOCOL
**DevicePath
553 Gets the enable status of the page break output mode.
555 User can use this function to determine current page break mode.
557 @retval TRUE The page break output mode is enabled.
558 @retval FALSE The page break output mode is disabled.
562 (EFIAPI
*EFI_SHELL_GET_PAGE_BREAK
) (
567 Judges whether the active shell is the root shell.
569 This function makes the user to know that whether the active Shell is the root shell.
571 @retval TRUE The active Shell is the root Shell.
572 @retval FALSE The active Shell is NOT the root Shell.
576 (EFIAPI
*EFI_SHELL_IS_ROOT_SHELL
) (
581 Opens a file or a directory by file name.
583 This function opens the specified file in the specified OpenMode and returns a file
585 If the file name begins with >v, then the file handle which is returned refers to the
586 shell environment variable with the specified name. If the shell environment variable
587 exists, is non-volatile and the OpenMode indicates EFI_FILE_MODE_WRITE, then
588 EFI_INVALID_PARAMETER is returned.
590 If the file name is >i, then the file handle which is returned refers to the standard
591 input. If the OpenMode indicates EFI_FILE_MODE_WRITE, then EFI_INVALID_PARAMETER
594 If the file name is >o, then the file handle which is returned refers to the standard
595 output. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER
598 If the file name is >e, then the file handle which is returned refers to the standard
599 error. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER
602 If the file name is NUL, then the file handle that is returned refers to the standard NUL
603 file. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER is
606 If return EFI_SUCCESS, the FileHandle is the opened file's handle, else, the
609 @param[in] FileName Points to the null-terminated UCS-2 encoded file name.
610 @param[out] FileHandle On return, points to the file handle.
611 @param[in] OpenMode File open mode. Either EFI_FILE_MODE_READ or
612 EFI_FILE_MODE_WRITE from section 12.4 of the UEFI
614 @retval EFI_SUCCESS The file was opened. FileHandle has the opened file's handle.
615 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value. FileHandle is NULL.
616 @retval EFI_UNSUPPORTED Could not open the file path. FileHandle is NULL.
617 @retval EFI_NOT_FOUND The specified file could not be found on the device or the file
618 system could not be found on the device. FileHandle is NULL.
619 @retval EFI_NO_MEDIA The device has no medium. FileHandle is NULL.
620 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no
621 longer supported. FileHandle is NULL.
622 @retval EFI_DEVICE_ERROR The device reported an error or can't get the file path according
623 the FileName. FileHandle is NULL.
624 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. FileHandle is NULL.
625 @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write
626 when the media is write-protected. FileHandle is NULL.
627 @retval EFI_ACCESS_DENIED The service denied access to the file. FileHandle is NULL.
628 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file. FileHandle
630 @retval EFI_VOLUME_FULL The volume is full. FileHandle is NULL.
634 (EFIAPI
*EFI_SHELL_OPEN_FILE_BY_NAME
) (
635 IN CONST CHAR16
*FileName
,
636 OUT EFI_FILE_HANDLE
*FileHandle
,
641 Opens the files that match the path specified.
643 This function opens all of the files specified by Path. Wildcards are processed
644 according to the rules specified in UEFI Shell 2.0 spec section 3.7.1. Each
645 matching file has an EFI_SHELL_FILE_INFO structure created in a linked list.
647 @param[in] Path A pointer to the path string.
648 @param[in] OpenMode Specifies the mode used to open each file, EFI_FILE_MODE_READ or
650 @param[in,out] FileList Points to the start of a list of files opened.
652 @retval EFI_SUCCESS Create the file list successfully.
653 @return Can't create the file list.
657 (EFIAPI
*EFI_SHELL_OPEN_FILE_LIST
) (
660 IN OUT EFI_SHELL_FILE_INFO
**FileList
664 Opens the root directory of a device.
666 This function opens the root directory of a device and returns a file handle to it.
668 @param[in] DevicePath Points to the device path corresponding to the device where the
669 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL is installed.
670 @param[out] FileHandle On exit, points to the file handle corresponding to the root directory on the
673 @retval EFI_SUCCESS Root opened successfully.
674 @retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be found or the root directory
676 @retval EFI_VOLUME_CORRUPTED The data structures in the volume were corrupted.
677 @retval EFI_DEVICE_ERROR The device had an error.
681 (EFIAPI
*EFI_SHELL_OPEN_ROOT
)(
682 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
683 OUT EFI_FILE_HANDLE
*FileHandle
687 Opens the root directory of a device on a handle.
689 This function opens the root directory of a device and returns a file handle to it.
691 @param[in] DeviceHandle The handle of the device that contains the volume.
692 @param[out] FileHandle On exit, points to the file handle corresponding to the root directory on the
695 @retval EFI_SUCCESS Root opened successfully.
696 @retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be found or the root directory
698 @retval EFI_VOLUME_CORRUPTED The data structures in the volume were corrupted.
699 @retval EFI_DEVICE_ERROR The device had an error.
703 (EFIAPI
*EFI_SHELL_OPEN_ROOT_BY_HANDLE
)(
704 IN EFI_HANDLE DeviceHandle
,
705 OUT EFI_FILE_HANDLE
*FileHandle
709 Reads data from the file.
711 If FileHandle is not a directory, the function reads the requested number of bytes
712 from the file at the file's current position and returns them in Buffer. If the read goes
713 beyond the end of the file, the read length is truncated to the end of the file. The file's
714 current position is increased by the number of bytes returned.
715 If FileHandle is a directory, then an error is returned.
717 @param[in] FileHandle The opened file handle for read.
718 @param[in] ReadSize On input, the size of Buffer, in bytes. On output, the amount of data read.
719 @param[in,out] Buffer The buffer in which data is read.
721 @retval EFI_SUCCESS Data was read.
722 @retval EFI_NO_MEDIA The device has no media.
723 @retval EFI_DEVICE_ERROR The device reported an error.
724 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
725 @retval EFI_BUFFER_TO_SMALL Buffer is too small. ReadSize contains required size.
729 (EFIAPI
*EFI_SHELL_READ_FILE
) (
730 IN EFI_FILE_HANDLE FileHandle
,
731 IN OUT UINTN
*ReadSize
,
736 Deletes the duplicate file names files in the given file list.
738 @param[in] FileList A pointer to the first entry in the file list.
740 @retval EFI_SUCCESS Always success.
744 (EFIAPI
*EFI_SHELL_REMOVE_DUP_IN_FILE_LIST
) (
745 IN EFI_SHELL_FILE_INFO
**FileList
749 // The SetAlias and GetAlias functions were affected by errata.
750 // They are not UEFI Shell 2.0 (no errata) compliant.
754 Changes a shell command alias.
756 This function creates an alias for a shell command.
758 @param[in] Command Points to the null-terminated shell command or existing alias.
759 @param[in] Alias Points to the null-terminated alias for the shell command. If this is NULL, and
760 Command refers to an alias, that alias will be deleted.
761 @param[in] Replace If TRUE and the alias already exists, then the existing alias will be replaced. If
762 FALSE and the alias already exists, then the existing alias is unchanged and
763 EFI_ACCESS_DENIED is returned.
764 @param[in] Volatile if TRUE the Alias being set will be stored in a volatile fashion. if FALSE the
765 Alias being set will be stored in a non-volatile fashion.
767 @retval EFI_SUCCESS Alias created or deleted successfully.
768 @retval EFI_ACCESS_DENIED The alias is a built-in alias or already existed and Replace was set to
773 (EFIAPI
*EFI_SHELL_SET_ALIAS
)(
774 IN CONST CHAR16
*Command
,
775 IN CONST CHAR16
*Alias
,
781 This function returns the command associated with a alias or a list of all
784 @param[in] Alias Points to the null-terminated shell alias.
785 If this parameter is NULL, then all
786 aliases will be returned in ReturnedData.
787 @param[out] Volatile Upon return of a single command if TRUE indicates
788 this is stored in a volatile fashion. FALSE otherwise.
789 @return If Alias is not NULL, it will return a pointer to
790 the null-terminated command for that alias.
791 If Alias is NULL, ReturnedData points to a ';'
792 delimited list of alias (e.g.
793 ReturnedData = "dir;del;copy;mfp") that is null-terminated.
794 @retval NULL An error ocurred.
795 @retval NULL Alias was not a valid Alias.
799 (EFIAPI
*EFI_SHELL_GET_ALIAS
)(
800 IN CONST CHAR16
*Alias
,
801 OUT BOOLEAN
*Volatile OPTIONAL
805 Changes the current directory on the specified device.
807 If the FileSystem is NULL, and the directory Dir does not contain a file system's
808 mapped name, this function changes the current working directory. If FileSystem is
809 NULL and the directory Dir contains a mapped name, then the current file system and
810 the current directory on that file system are changed.
812 If FileSystem is not NULL, and Dir is NULL, then this changes the current working file
815 If FileSystem is not NULL and Dir is not NULL, then this function changes the current
816 directory on the specified file system.
818 If the current working directory or the current working file system is changed then the
819 %cwd% environment variable will be updated
821 @param[in] FileSystem A pointer to the file system's mapped name. If NULL, then the current working
822 directory is changed.
823 @param[in] Dir Points to the null-terminated directory on the device specified by FileSystem.
825 @return !=NULL The current directory.
826 @retval NULL Current directory does not exist.
830 (EFIAPI
*EFI_SHELL_SET_CUR_DIR
) (
831 IN CONST CHAR16
*FileSystem OPTIONAL
,
836 Sets the environment variable.
838 This function changes the current value of the specified environment variable. If the
839 environment variable exists and the Value is an empty string, then the environment
840 variable is deleted. If the environment variable exists and the Value is not an empty
841 string, then the value of the environment variable is changed. If the environment
842 variable does not exist and the Value is an empty string, there is no action. If the
843 environment variable does not exist and the Value is a non-empty string, then the
844 environment variable is created and assigned the specified value.
846 For a description of volatile and non-volatile environment variables, see UEFI Shell
847 2.0 specification section 3.6.1.
849 @param[in] Name Points to the null-terminated environment variable name.
850 @param[in] Value Points to the null-terminated environment variable value. If the value is an
851 empty string then the environment variable is deleted.
852 @param[in] Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).
854 @retval EFI_SUCCESS The environment variable was successfully updated.
858 (EFIAPI
*EFI_SHELL_SET_ENV
) (
859 IN CONST CHAR16
*Name
,
860 IN CONST CHAR16
*Value
,
865 Sets the file information to an opened file handle.
867 This function changes file information.
869 @param[in] FileHandle A file handle
870 @param[in] FileInfo Points to new file information.
872 @retval EFI_SUCCESS The information was set.
873 @retval EFI_NO_MEDIA The device has no medium.
874 @retval EFI_DEVICE_ERROR The device reported an error.
875 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
876 @retval EFI_WRITE_PROTECTED The file or medium is write-protected.
877 @retval EFI_ACCESS_DENIED The file was opened read-only.
878 @retval EFI_VOLUME_FULL The volume is full.
879 @retval EFI_BAD_BUFFER_SIZE BufferSize is smaller than the size of EFI_FILE_INFO.
883 (EFIAPI
*EFI_SHELL_SET_FILE_INFO
)(
884 IN EFI_FILE_HANDLE FileHandle
,
885 IN CONST EFI_FILE_INFO
*FileInfo
889 Sets a file's current position.
891 This function sets the current file position for the handle to the position supplied. With
892 the exception of seeking to position 0xFFFFFFFFFFFFFFFF, only absolute positioning is
893 supported, and seeking past the end of the file is allowed (a subsequent write would
894 grow the file). Seeking to position 0xFFFFFFFFFFFFFFFF causes the current position
895 to be set to the end of the file.
897 @param[in] FileHandle The file handle on which requested position will be set.
898 @param[in] Position Byte position from the start of the file.
900 @retval EFI_SUCCESS Data was written.
901 @retval EFI_UNSUPPORTED The seek request for nonzero is not valid on open directories.
905 (EFIAPI
*EFI_SHELL_SET_FILE_POSITION
)(
906 IN EFI_FILE_HANDLE FileHandle
,
911 This function creates a mapping for a device path.
913 @param[in] DevicePath Points to the device path. If this is NULL and Mapping points to a valid mapping,
914 then the mapping will be deleted.
915 @param[in] Mapping Points to the null-terminated mapping for the device path.
917 @retval EFI_SUCCESS Mapping created or deleted successfully.
918 @retval EFI_NO_MAPPING There is no handle that corresponds exactly to DevicePath. See the
919 boot service function LocateDevicePath().
920 @retval EFI_ACCESS_DENIED The mapping is a built-in alias.
924 (EFIAPI
*EFI_SHELL_SET_MAP
)(
925 IN CONST EFI_DEVICE_PATH_PROTOCOL
*DevicePath
,
926 IN CONST CHAR16
*Mapping
930 Writes data to the file.
932 This function writes the specified number of bytes to the file at the current file position.
933 The current file position is advanced the actual number of bytes written, which is
934 returned in BufferSize. Partial writes only occur when there has been a data error
935 during the write attempt (such as "volume space full"). The file automatically grows to
936 hold the data, if required.
938 Direct writes to opened directories are not supported.
940 @param[in] FileHandle The opened file handle for writing.
941 @param[in,out] BufferSize On input, size of Buffer.
942 @param[in] Buffer The buffer in which data to write.
944 @retval EFI_SUCCESS Data was written.
945 @retval EFI_UNSUPPORTED Writes to open directory are not supported.
946 @retval EFI_NO_MEDIA The device has no media.
947 @retval EFI_DEVICE_ERROR The device reported an error.
948 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
949 @retval EFI_WRITE_PROTECTED The device is write-protected.
950 @retval EFI_ACCESS_DENIED The file was open for read only.
951 @retval EFI_VOLUME_FULL The volume is full.
955 (EFIAPI
*EFI_SHELL_WRITE_FILE
)(
956 IN EFI_FILE_HANDLE FileHandle
,
957 IN OUT UINTN
*BufferSize
,
961 typedef struct _EFI_SHELL_PROTOCOL
{
962 EFI_SHELL_EXECUTE Execute
;
963 EFI_SHELL_GET_ENV GetEnv
;
964 EFI_SHELL_SET_ENV SetEnv
;
965 EFI_SHELL_GET_ALIAS GetAlias
;
966 EFI_SHELL_SET_ALIAS SetAlias
;
967 EFI_SHELL_GET_HELP_TEXT GetHelpText
;
968 EFI_SHELL_GET_DEVICE_PATH_FROM_MAP GetDevicePathFromMap
;
969 EFI_SHELL_GET_MAP_FROM_DEVICE_PATH GetMapFromDevicePath
;
970 EFI_SHELL_GET_DEVICE_PATH_FROM_FILE_PATH GetDevicePathFromFilePath
;
971 EFI_SHELL_GET_FILE_PATH_FROM_DEVICE_PATH GetFilePathFromDevicePath
;
972 EFI_SHELL_SET_MAP SetMap
;
973 EFI_SHELL_GET_CUR_DIR GetCurDir
;
974 EFI_SHELL_SET_CUR_DIR SetCurDir
;
975 EFI_SHELL_OPEN_FILE_LIST OpenFileList
;
976 EFI_SHELL_FREE_FILE_LIST FreeFileList
;
977 EFI_SHELL_REMOVE_DUP_IN_FILE_LIST RemoveDupInFileList
;
978 EFI_SHELL_BATCH_IS_ACTIVE BatchIsActive
;
979 EFI_SHELL_IS_ROOT_SHELL IsRootShell
;
980 EFI_SHELL_ENABLE_PAGE_BREAK EnablePageBreak
;
981 EFI_SHELL_DISABLE_PAGE_BREAK DisablePageBreak
;
982 EFI_SHELL_GET_PAGE_BREAK GetPageBreak
;
983 EFI_SHELL_GET_DEVICE_NAME GetDeviceName
;
984 EFI_SHELL_GET_FILE_INFO GetFileInfo
;
985 EFI_SHELL_SET_FILE_INFO SetFileInfo
;
986 EFI_SHELL_OPEN_FILE_BY_NAME OpenFileByName
;
987 EFI_SHELL_CLOSE_FILE CloseFile
;
988 EFI_SHELL_CREATE_FILE CreateFile
;
989 EFI_SHELL_READ_FILE ReadFile
;
990 EFI_SHELL_WRITE_FILE WriteFile
;
991 EFI_SHELL_DELETE_FILE DeleteFile
;
992 EFI_SHELL_DELETE_FILE_BY_NAME DeleteFileByName
;
993 EFI_SHELL_GET_FILE_POSITION GetFilePosition
;
994 EFI_SHELL_SET_FILE_POSITION SetFilePosition
;
995 EFI_SHELL_FLUSH_FILE FlushFile
;
996 EFI_SHELL_FIND_FILES FindFiles
;
997 EFI_SHELL_FIND_FILES_IN_DIR FindFilesInDir
;
998 EFI_SHELL_GET_FILE_SIZE GetFileSize
;
999 EFI_SHELL_OPEN_ROOT OpenRoot
;
1000 EFI_SHELL_OPEN_ROOT_BY_HANDLE OpenRootByHandle
;
1001 EFI_EVENT ExecutionBreak
;
1002 UINT32 MajorVersion
;
1003 UINT32 MinorVersion
;
1004 } EFI_SHELL_PROTOCOL
;
1006 extern EFI_GUID gEfiShellProtocolGuid
;
1009 SHELL_MAJOR_VERSION
= 2,
1010 SHELL_MINOR_VERSION
= 0