--- /dev/null
+/** @file\r
+ Member functions of EFI_SHELL_PROTOCOL and functions for creation,\r
+ manipulation, and initialization of EFI_SHELL_PROTOCOL.\r
+\r
+ Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r
+ This program and the accompanying materials\r
+ are licensed and made available under the terms and conditions of the BSD License\r
+ which accompanies this distribution. The full text of the license may be found at\r
+ http://opensource.org/licenses/bsd-license.php\r
+\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+\r
+**/\r
+\r
+#ifndef _SHELL_PROTOCOL_HEADER_\r
+#define _SHELL_PROTOCOL_HEADER_\r
+\r
+#include <Uefi.h>\r
+#include <ShellBase.h>\r
+\r
+#include <Guid/ShellVariableGuid.h>\r
+#include <Guid/ShellMapGuid.h>\r
+#include <Guid/ShellAliasGuid.h>\r
+\r
+#include <Protocol/EfiShell.h>\r
+#include <Protocol/EfiShellParameters.h>\r
+#include <Protocol/SimpleFileSystem.h>\r
+#include <Protocol/DevicePathToText.h>\r
+#include <Protocol/ComponentName2.h>\r
+#include <Protocol/LoadedImage.h>\r
+#include <Protocol/UnicodeCollation.h>\r
+#include <Protocol/DevicePath.h>\r
+\r
+#include <Library/UefiBootServicesTableLib.h>\r
+#include <Library/BaseLib.h>\r
+#include <Library/ShellCommandLib.h>\r
+#include <Library/PrintLib.h>\r
+#include <Library/DevicePathLib.h>\r
+#include <Library/UefiRuntimeServicesTableLib.h>\r
+#include <Library/DebugLib.h>\r
+#include <Library/MemoryAllocationLib.h>\r
+#include <Library/BaseMemoryLib.h>\r
+#include <Library/UefiLib.h>\r
+#include <Library/SortLib.h>\r
+#include <Library/PcdLib.h>\r
+#include <Library/ShellLib.h>\r
+\r
+#include "FileHandleWrappers.h"\r
+#include "ShellEnvVar.h"\r
+#include "ShellManParser.h"\r
+\r
+typedef struct {\r
+ LIST_ENTRY Link;\r
+ EFI_SHELL_PROTOCOL *Interface;\r
+ EFI_HANDLE Handle;\r
+} SHELL_PROTOCOL_HANDLE_LIST;\r
+\r
+// flags values...\r
+#define SHELL_MAP_FLAGS_CONSIST BIT1\r
+\r
+/**\r
+ Function to create and install on the current handle.\r
+\r
+ Will overwrite any existing ShellProtocols in the system to be sure that\r
+ the current shell is in control.\r
+\r
+ This must be removed via calling CleanUpShellProtocol().\r
+\r
+ @param[in,out] NewShell The pointer to the pointer to the structure \r
+ to install.\r
+\r
+ @retval EFI_SUCCESS The operation was successful.\r
+ @return An error from LocateHandle, CreateEvent, or other core function.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CreatePopulateInstallShellProtocol (\r
+ IN OUT EFI_SHELL_PROTOCOL **NewShell\r
+ );\r
+\r
+/**\r
+ Opposite of CreatePopulateInstallShellProtocol. \r
+\r
+ Free all memory and restore the system to the state it was in before calling\r
+ CreatePopulateInstallShellProtocol.\r
+\r
+ @param[in,out] NewShell The pointer to the new shell protocol structure.\r
+\r
+ @retval EFI_SUCCESS The operation was successful.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+CleanUpShellProtocol (\r
+ IN OUT EFI_SHELL_PROTOCOL *NewShell\r
+ );\r
+\r
+/**\r
+ This function creates a mapping for a device path.\r
+\r
+ @param DevicePath Points to the device path. If this is NULL and Mapping points to a valid mapping,\r
+ then the mapping will be deleted.\r
+ @param Mapping Points to the NULL-terminated mapping for the device path. Must end with a ':'\r
+\r
+ @retval EFI_SUCCESS Mapping created or deleted successfully.\r
+ @retval EFI_NO_MAPPING There is no handle that corresponds exactly to DevicePath. See the\r
+ boot service function LocateDevicePath().\r
+ @retval EFI_ACCESS_DENIED The mapping is a built-in alias.\r
+ @retval EFI_INVALID_PARAMETER Mapping was NULL\r
+ @retval EFI_INVALID_PARAMETER Mapping did not end with a ':'\r
+ @retval EFI_INVALID_PARAMETER DevicePath was not pointing at a device that had a SIMPLE_FILE_SYSTEM_PROTOCOL installed.\r
+ @retval EFI_NOT_FOUND There was no mapping found to delete\r
+ @retval EFI_OUT_OF_RESOURCES Memory allocation failed\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiShellSetMap(\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL,\r
+ IN CONST CHAR16 *Mapping\r
+ );\r
+\r
+/**\r
+ Gets the device path from the mapping.\r
+\r
+ This function gets the device path associated with a mapping.\r
+\r
+ @param Mapping A pointer to the mapping\r
+\r
+ @retval !=NULL Pointer to the device path that corresponds to the\r
+ device mapping. The returned pointer does not need\r
+ to be freed.\r
+ @retval NULL There is no device path associated with the\r
+ specified mapping.\r
+**/\r
+CONST EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+EfiShellGetDevicePathFromMap(\r
+ IN CONST CHAR16 *Mapping\r
+ );\r
+\r
+/**\r
+ Gets the mapping that most closely matches the device path.\r
+\r
+ This function gets the mapping which corresponds to the device path *DevicePath. If\r
+ there is no exact match, then the mapping which most closely matches *DevicePath\r
+ is returned, and *DevicePath is updated to point to the remaining portion of the\r
+ device path. If there is an exact match, the mapping is returned and *DevicePath\r
+ points to the end-of-device-path node.\r
+\r
+ @param DevicePath On entry, points to a device path pointer. On\r
+ exit, updates the pointer to point to the\r
+ portion of the device path after the mapping.\r
+\r
+ @retval NULL No mapping was found.\r
+ @return !=NULL Pointer to NULL-terminated mapping. The buffer\r
+ is callee allocated and should be freed by the caller.\r
+**/\r
+CONST CHAR16 *\r
+EFIAPI\r
+EfiShellGetMapFromDevicePath(\r
+ IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r
+ );\r
+\r
+/**\r
+ Converts a device path to a file system-style path.\r
+\r
+ This function converts a device path to a file system path by replacing part, or all, of\r
+ the device path with the file-system mapping. If there are more than one application\r
+ file system mappings, the one that most closely matches Path will be used.\r
+\r
+ @param Path The pointer to the device path\r
+\r
+ @retval NULL the device path could not be found.\r
+ @return all The pointer of the NULL-terminated file path. The path\r
+ is callee-allocated and should be freed by the caller.\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+EfiShellGetFilePathFromDevicePath(\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *Path\r
+ );\r
+\r
+/**\r
+ Converts a file system style name to a device path.\r
+\r
+ This function converts a file system style name to a device path, by replacing any\r
+ mapping references to the associated device path.\r
+\r
+ @param Path the pointer to the path\r
+\r
+ @return all The pointer of the file path. The file path is callee\r
+ allocated and should be freed by the caller.\r
+**/\r
+EFI_DEVICE_PATH_PROTOCOL *\r
+EFIAPI\r
+EfiShellGetDevicePathFromFilePath(\r
+ IN CONST CHAR16 *Path\r
+ );\r
+\r
+/**\r
+ Gets the name of the device specified by the device handle.\r
+\r
+ This function gets the user-readable name of the device specified by the device\r
+ handle. If no user-readable name could be generated, then *BestDeviceName will be\r
+ NULL and EFI_NOT_FOUND will be returned.\r
+\r
+ If EFI_DEVICE_NAME_USE_COMPONENT_NAME is set, then the function will return the\r
+ device's name using the EFI_COMPONENT_NAME2_PROTOCOL, if present on\r
+ DeviceHandle.\r
+\r
+ If EFI_DEVICE_NAME_USE_DEVICE_PATH is set, then the function will return the\r
+ device's name using the EFI_DEVICE_PATH_PROTOCOL, if present on DeviceHandle.\r
+ If both EFI_DEVICE_NAME_USE_COMPONENT_NAME and\r
+ EFI_DEVICE_NAME_USE_DEVICE_PATH are set, then\r
+ EFI_DEVICE_NAME_USE_COMPONENT_NAME will have higher priority.\r
+\r
+ @param DeviceHandle The handle of the device.\r
+ @param Flags Determines the possible sources of component names.\r
+ Valid bits are:\r
+ EFI_DEVICE_NAME_USE_COMPONENT_NAME\r
+ EFI_DEVICE_NAME_USE_DEVICE_PATH\r
+ @param Language A pointer to the language specified for the device\r
+ name, in the same format as described in the UEFI\r
+ specification, Appendix M\r
+ @param BestDeviceName On return, points to the callee-allocated NULL-\r
+ terminated name of the device. If no device name\r
+ could be found, points to NULL. The name must be\r
+ freed by the caller...\r
+\r
+ @retval EFI_SUCCESS Get the name successfully.\r
+ @retval EFI_NOT_FOUND Fail to get the device name.\r
+ @retval EFI_INVALID_PARAMETER Flags did not have a valid bit set.\r
+ @retval EFI_INVALID_PARAMETER BestDeviceName was NULL\r
+ @retval EFI_INVALID_PARAMETER DeviceHandle was NULL\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiShellGetDeviceName(\r
+ IN EFI_HANDLE DeviceHandle,\r
+ IN EFI_SHELL_DEVICE_NAME_FLAGS Flags,\r
+ IN CHAR8 *Language,\r
+ OUT CHAR16 **BestDeviceName\r
+ );\r
+\r
+/**\r
+ Opens the root directory of a device on a handle\r
+\r
+ This function opens the root directory of a device and returns a file handle to it.\r
+\r
+ @param DeviceHandle The handle of the device that contains the volume.\r
+ @param FileHandle On exit, points to the file handle corresponding to the root directory on the\r
+ device.\r
+\r
+ @retval EFI_SUCCESS Root opened successfully.\r
+ @retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be found or the root directory\r
+ could not be opened.\r
+ @retval EFI_VOLUME_CORRUPTED The data structures in the volume were corrupted.\r
+ @retval EFI_DEVICE_ERROR The device had an error\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiShellOpenRootByHandle(\r
+ IN EFI_HANDLE DeviceHandle,\r
+ OUT SHELL_FILE_HANDLE *FileHandle\r
+ );\r
+\r
+/**\r
+ Opens the root directory of a device.\r
+\r
+ This function opens the root directory of a device and returns a file handle to it.\r
+\r
+ @param DevicePath Points to the device path corresponding to the device where the\r
+ EFI_SIMPLE_FILE_SYSTEM_PROTOCOL is installed.\r
+ @param FileHandle On exit, points to the file handle corresponding to the root directory on the\r
+ device.\r
+\r
+ @retval EFI_SUCCESS Root opened successfully.\r
+ @retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be found or the root directory\r
+ could not be opened.\r
+ @retval EFI_VOLUME_CORRUPTED The data structures in the volume were corrupted.\r
+ @retval EFI_DEVICE_ERROR The device had an error\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiShellOpenRoot(\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ OUT SHELL_FILE_HANDLE *FileHandle\r
+ );\r
+\r
+/**\r
+ Returns whether any script files are currently being processed.\r
+\r
+ @retval TRUE There is at least one script file active.\r
+ @retval FALSE No script files are active now.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+EfiShellBatchIsActive (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Worker function to open a file based on a device path. this will open the root\r
+ of the volume and then traverse down to the file itself.\r
+\r
+ @param DevicePath2 Device Path of the file\r
+ @param FileHandle Pointer to the file upon a successful return\r
+ @param OpenMode mode to open file in.\r
+ @param Attributes the File Attributes to use when creating a new file\r
+\r
+ @retval EFI_SUCCESS the file is open and FileHandle is valid\r
+ @retval EFI_UNSUPPORTED the device path cotained non-path elements\r
+ @retval other an error ocurred.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InternalOpenFileDevicePath(\r
+ IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath2,\r
+ OUT SHELL_FILE_HANDLE *FileHandle,\r
+ IN UINT64 OpenMode,\r
+ IN UINT64 Attributes OPTIONAL\r
+ );\r
+\r
+/**\r
+ Creates a file or directory by name.\r
+\r
+ This function creates an empty new file or directory with the specified attributes and\r
+ returns the new file's handle. If the file already exists and is read-only, then\r
+ EFI_INVALID_PARAMETER will be returned.\r
+\r
+ If the file already existed, it is truncated and its attributes updated. If the file is\r
+ created successfully, the FileHandle is the file's handle, else, the FileHandle is NULL.\r
+\r
+ If the file name begins with >v, then the file handle which is returned refers to the\r
+ shell environment variable with the specified name. If the shell environment variable\r
+ already exists and is non-volatile then EFI_INVALID_PARAMETER is returned.\r
+\r
+ @param FileName Pointer to NULL-terminated file path\r
+ @param FileAttribs The new file's attrbiutes. the different attributes are\r
+ described in EFI_FILE_PROTOCOL.Open().\r
+ @param FileHandle On return, points to the created file handle or directory's handle\r
+\r
+ @retval EFI_SUCCESS The file was opened. FileHandle points to the new file's handle.\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
+ @retval EFI_UNSUPPORTED could not open the file path\r
+ @retval EFI_NOT_FOUND the specified file could not be found on the devide, or could not\r
+ file the file system on the device.\r
+ @retval EFI_NO_MEDIA the device has no medium.\r
+ @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no\r
+ longer supported.\r
+ @retval EFI_DEVICE_ERROR The device reported an error or can't get the file path according\r
+ the DirName.\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+ @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write\r
+ when the media is write-protected.\r
+ @retval EFI_ACCESS_DENIED The service denied access to the file.\r
+ @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file.\r
+ @retval EFI_VOLUME_FULL The volume is full.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiShellCreateFile(\r
+ IN CONST CHAR16 *FileName,\r
+ IN UINT64 FileAttribs,\r
+ OUT SHELL_FILE_HANDLE *FileHandle\r
+ );\r
+\r
+/**\r
+ Opens a file or a directory by file name.\r
+\r
+ This function opens the specified file in the specified OpenMode and returns a file\r
+ handle.\r
+ If the file name begins with >v, then the file handle which is returned refers to the\r
+ shell environment variable with the specified name. If the shell environment variable\r
+ exists, is non-volatile and the OpenMode indicates EFI_FILE_MODE_WRITE, then\r
+ EFI_INVALID_PARAMETER is returned.\r
+\r
+ If the file name is >i, then the file handle which is returned refers to the standard\r
+ input. If the OpenMode indicates EFI_FILE_MODE_WRITE, then EFI_INVALID_PARAMETER\r
+ is returned.\r
+\r
+ If the file name is >o, then the file handle which is returned refers to the standard\r
+ output. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER\r
+ is returned.\r
+\r
+ If the file name is >e, then the file handle which is returned refers to the standard\r
+ error. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER\r
+ is returned.\r
+\r
+ If the file name is NUL, then the file handle that is returned refers to the standard NUL\r
+ file. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER is\r
+ returned.\r
+\r
+ If return EFI_SUCCESS, the FileHandle is the opened file's handle, else, the\r
+ FileHandle is NULL.\r
+\r
+ @param FileName Points to the NULL-terminated UCS-2 encoded file name.\r
+ @param FileHandle On return, points to the file handle.\r
+ @param OpenMode File open mode. Either EFI_FILE_MODE_READ or\r
+ EFI_FILE_MODE_WRITE from section 12.4 of the UEFI\r
+ Specification.\r
+ @retval EFI_SUCCESS The file was opened. FileHandle has the opened file's handle.\r
+ @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value. FileHandle is NULL.\r
+ @retval EFI_UNSUPPORTED Could not open the file path. FileHandle is NULL.\r
+ @retval EFI_NOT_FOUND The specified file could not be found on the device or the file\r
+ system could not be found on the device. FileHandle is NULL.\r
+ @retval EFI_NO_MEDIA The device has no medium. FileHandle is NULL.\r
+ @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no\r
+ longer supported. FileHandle is NULL.\r
+ @retval EFI_DEVICE_ERROR The device reported an error or can't get the file path according\r
+ the FileName. FileHandle is NULL.\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. FileHandle is NULL.\r
+ @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write\r
+ when the media is write-protected. FileHandle is NULL.\r
+ @retval EFI_ACCESS_DENIED The service denied access to the file. FileHandle is NULL.\r
+ @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file. FileHandle\r
+ is NULL.\r
+ @retval EFI_VOLUME_FULL The volume is full. FileHandle is NULL.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiShellOpenFileByName(\r
+ IN CONST CHAR16 *FileName,\r
+ OUT SHELL_FILE_HANDLE *FileHandle,\r
+ IN UINT64 OpenMode\r
+ );\r
+\r
+/**\r
+ Deletes the file specified by the file name.\r
+\r
+ This function deletes a file.\r
+\r
+ @param FileName Points to the NULL-terminated file name.\r
+\r
+ @retval EFI_SUCCESS The file was closed and deleted, and the handle was closed.\r
+ @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not deleted.\r
+ @sa EfiShellCreateFile\r
+ @sa FileHandleDelete\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiShellDeleteFileByName(\r
+ IN CONST CHAR16 *FileName\r
+ );\r
+\r
+/**\r
+ Disables the page break output mode.\r
+**/\r
+VOID\r
+EFIAPI\r
+EfiShellDisablePageBreak (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Enables the page break output mode.\r
+**/\r
+VOID\r
+EFIAPI\r
+EfiShellEnablePageBreak (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ internal worker function to run a command via Device Path\r
+\r
+ @param ParentImageHandle A handle of the image that is executing the specified\r
+ command line.\r
+ @param DevicePath device path of the file to execute\r
+ @param CommandLine Points to the NULL-terminated UCS-2 encoded string\r
+ containing the command line. If NULL then the command-\r
+ line will be empty.\r
+ @param Environment Points to a NULL-terminated array of environment\r
+ variables with the format 'x=y', where x is the\r
+ environment variable name and y is the value. If this\r
+ is NULL, then the current shell environment is used.\r
+ @param StatusCode Points to the status code returned by the command.\r
+\r
+ @retval EFI_SUCCESS The command executed successfully. The status code\r
+ returned by the command is pointed to by StatusCode.\r
+ @retval EFI_INVALID_PARAMETER The parameters are invalid.\r
+ @retval EFI_OUT_OF_RESOURCES Out of resources.\r
+ @retval EFI_UNSUPPORTED Nested shell invocations are not allowed.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InternalShellExecuteDevicePath(\r
+ IN CONST EFI_HANDLE *ParentImageHandle,\r
+ IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
+ IN CONST CHAR16 *CommandLine OPTIONAL,\r
+ IN CONST CHAR16 **Environment OPTIONAL,\r
+ OUT EFI_STATUS *StatusCode OPTIONAL\r
+ );\r
+\r
+/**\r
+ Execute the command line.\r
+\r
+ This function creates a nested instance of the shell and executes the specified\r
+ command (CommandLine) with the specified environment (Environment). Upon return,\r
+ the status code returned by the specified command is placed in StatusCode.\r
+\r
+ If Environment is NULL, then the current environment is used and all changes made\r
+ by the commands executed will be reflected in the current environment. If the\r
+ Environment is non-NULL, then the changes made will be discarded.\r
+\r
+ The CommandLine is executed from the current working directory on the current\r
+ device.\r
+\r
+ @param ParentImageHandle A handle of the image that is executing the specified\r
+ command line.\r
+ @param CommandLine Points to the NULL-terminated UCS-2 encoded string\r
+ containing the command line. If NULL then the command-\r
+ line will be empty.\r
+ @param Environment Points to a NULL-terminated array of environment\r
+ variables with the format 'x=y', where x is the\r
+ environment variable name and y is the value. If this\r
+ is NULL, then the current shell environment is used.\r
+ @param StatusCode Points to the status code returned by the command.\r
+\r
+ @retval EFI_SUCCESS The command executed successfully. The status code\r
+ returned by the command is pointed to by StatusCode.\r
+ @retval EFI_INVALID_PARAMETER The parameters are invalid.\r
+ @retval EFI_OUT_OF_RESOURCES Out of resources.\r
+ @retval EFI_UNSUPPORTED Nested shell invocations are not allowed.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiShellExecute(\r
+ IN EFI_HANDLE *ParentImageHandle,\r
+ IN CHAR16 *CommandLine OPTIONAL,\r
+ IN CHAR16 **Environment OPTIONAL,\r
+ OUT EFI_STATUS *StatusCode OPTIONAL\r
+ );\r
+\r
+/**\r
+ Utility cleanup function for EFI_SHELL_FILE_INFO objects.\r
+\r
+ 1) frees all pointers (non-NULL)\r
+ 2) Closes the SHELL_FILE_HANDLE\r
+\r
+ @param FileListNode pointer to the list node to free\r
+**/\r
+VOID\r
+EFIAPI\r
+FreeShellFileInfoNode(\r
+ IN EFI_SHELL_FILE_INFO *FileListNode\r
+ );\r
+\r
+/**\r
+ Frees the file list.\r
+\r
+ This function cleans up the file list and any related data structures. It has no\r
+ impact on the files themselves.\r
+\r
+ @param FileList The file list to free. Type EFI_SHELL_FILE_INFO is\r
+ defined in OpenFileList()\r
+\r
+ @retval EFI_SUCCESS Free the file list successfully.\r
+ @retval EFI_INVALID_PARAMETER FileList was NULL or *FileList was NULL;\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiShellFreeFileList(\r
+ IN EFI_SHELL_FILE_INFO **FileList\r
+ );\r
+\r
+/**\r
+ Deletes the duplicate file names files in the given file list.\r
+\r
+ This function deletes the reduplicate files in the given file list.\r
+\r
+ @param FileList A pointer to the first entry in the file list.\r
+\r
+ @retval EFI_SUCCESS Always success.\r
+ @retval EFI_INVALID_PARAMETER FileList was NULL or *FileList was NULL;\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiShellRemoveDupInFileList(\r
+ IN EFI_SHELL_FILE_INFO **FileList\r
+ );\r
+\r
+/**\r
+ Allocates and populates a EFI_SHELL_FILE_INFO structure. if any memory operation\r
+ failed it will return NULL.\r
+\r
+ @param[in] BasePath the Path to prepend onto filename for FullPath\r
+ @param[in] Status Status member initial value.\r
+ @param[in] FullName FullName member initial value.\r
+ @param[in] FileName FileName member initial value.\r
+ @param[in] Handle Handle member initial value.\r
+ @param[in] Info Info struct to copy.\r
+\r
+**/\r
+EFI_SHELL_FILE_INFO *\r
+EFIAPI\r
+CreateAndPopulateShellFileInfo(\r
+ IN CONST CHAR16 *BasePath,\r
+ IN CONST EFI_STATUS Status,\r
+ IN CONST CHAR16 *FullName,\r
+ IN CONST CHAR16 *FileName,\r
+ IN CONST SHELL_FILE_HANDLE Handle,\r
+ IN CONST EFI_FILE_INFO *Info\r
+ );\r
+\r
+/**\r
+ Find all files in a specified directory.\r
+\r
+ @param FileDirHandle Handle of the directory to search.\r
+ @param FileList On return, points to the list of files in the directory\r
+ or NULL if there are no files in the directory.\r
+\r
+ @retval EFI_SUCCESS File information was returned successfully.\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures have been corrupted.\r
+ @retval EFI_DEVICE_ERROR The device reported an error.\r
+ @retval EFI_NO_MEDIA The device media is not present.\r
+ @retval EFI_INVALID_PARAMETER The FileDirHandle was not a directory.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiShellFindFilesInDir(\r
+ IN SHELL_FILE_HANDLE FileDirHandle,\r
+ OUT EFI_SHELL_FILE_INFO **FileList\r
+ );\r
+\r
+/**\r
+ Find files that match a specified pattern.\r
+\r
+ This function searches for all files and directories that match the specified\r
+ FilePattern. The FilePattern can contain wild-card characters. The resulting file\r
+ information is placed in the file list FileList.\r
+\r
+ Wildcards are processed\r
+ according to the rules specified in UEFI Shell 2.0 spec section 3.7.1.\r
+\r
+ The files in the file list are not opened. The OpenMode field is set to 0 and the FileInfo\r
+ field is set to NULL.\r
+\r
+ if *FileList is not NULL then it must be a pre-existing and properly initialized list.\r
+\r
+ @param FilePattern Points to a NULL-terminated shell file path, including wildcards.\r
+ @param FileList On return, points to the start of a file list containing the names\r
+ of all matching files or else points to NULL if no matching files\r
+ were found. only on a EFI_SUCCESS return will; this be non-NULL.\r
+\r
+ @retval EFI_SUCCESS Files found. FileList is a valid list.\r
+ @retval EFI_NOT_FOUND No files found.\r
+ @retval EFI_NO_MEDIA The device has no media\r
+ @retval EFI_DEVICE_ERROR The device reported an error\r
+ @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiShellFindFiles(\r
+ IN CONST CHAR16 *FilePattern,\r
+ OUT EFI_SHELL_FILE_INFO **FileList\r
+ );\r
+\r
+/**\r
+ Opens the files that match the path specified.\r
+\r
+ This function opens all of the files specified by Path. Wildcards are processed\r
+ according to the rules specified in UEFI Shell 2.0 spec section 3.7.1. Each\r
+ matching file has an EFI_SHELL_FILE_INFO structure created in a linked list.\r
+\r
+ @param Path A pointer to the path string.\r
+ @param OpenMode Specifies the mode used to open each file, EFI_FILE_MODE_READ or\r
+ EFI_FILE_MODE_WRITE.\r
+ @param FileList Points to the start of a list of files opened.\r
+\r
+ @retval EFI_SUCCESS Create the file list successfully.\r
+ @return Others Can't create the file list.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiShellOpenFileList(\r
+ IN CHAR16 *Path,\r
+ IN UINT64 OpenMode,\r
+ IN OUT EFI_SHELL_FILE_INFO **FileList\r
+ );\r
+\r
+/**\r
+ Gets the environment variable.\r
+\r
+ This function returns the current value of the specified environment variable.\r
+\r
+ @param Name A pointer to the environment variable name\r
+\r
+ @return !=NULL The environment variable's value. The returned\r
+ pointer does not need to be freed by the caller.\r
+ @retval NULL The environment variable doesn't exist.\r
+**/\r
+CONST CHAR16 *\r
+EFIAPI\r
+EfiShellGetEnv(\r
+ IN CONST CHAR16 *Name\r
+ );\r
+\r
+/**\r
+ Sets the environment variable.\r
+\r
+ This function changes the current value of the specified environment variable. If the\r
+ environment variable exists and the Value is an empty string, then the environment\r
+ variable is deleted. If the environment variable exists and the Value is not an empty\r
+ string, then the value of the environment variable is changed. If the environment\r
+ variable does not exist and the Value is an empty string, there is no action. If the\r
+ environment variable does not exist and the Value is a non-empty string, then the\r
+ environment variable is created and assigned the specified value.\r
+\r
+ For a description of volatile and non-volatile environment variables, see UEFI Shell\r
+ 2.0 specification section 3.6.1.\r
+\r
+ @param Name Points to the NULL-terminated environment variable name.\r
+ @param Value Points to the NULL-terminated environment variable value. If the value is an\r
+ empty string then the environment variable is deleted.\r
+ @param Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).\r
+\r
+ @retval EFI_SUCCESS The environment variable was successfully updated.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiShellSetEnv(\r
+ IN CONST CHAR16 *Name,\r
+ IN CONST CHAR16 *Value,\r
+ IN BOOLEAN Volatile\r
+ );\r
+\r
+/**\r
+ Returns the current directory on the specified device.\r
+\r
+ If FileSystemMapping is NULL, it returns the current working directory. If the\r
+ FileSystemMapping is not NULL, it returns the current directory associated with the\r
+ FileSystemMapping. In both cases, the returned name includes the file system\r
+ mapping (i.e. fs0:\current-dir).\r
+\r
+ @param FileSystemMapping A pointer to the file system mapping. If NULL,\r
+ then the current working directory is returned.\r
+\r
+ @retval !=NULL The current directory.\r
+ @retval NULL Current directory does not exist.\r
+**/\r
+CONST CHAR16 *\r
+EFIAPI\r
+EfiShellGetCurDir(\r
+ IN CONST CHAR16 *FileSystemMapping OPTIONAL\r
+ );\r
+\r
+/**\r
+ Changes the current directory on the specified device.\r
+\r
+ If the FileSystem is NULL, and the directory Dir does not contain a file system's\r
+ mapped name, this function changes the current working directory. If FileSystem is\r
+ NULL and the directory Dir contains a mapped name, then the current file system and\r
+ the current directory on that file system are changed.\r
+\r
+ If FileSystem is not NULL, and Dir is NULL, then this changes the current working file\r
+ system.\r
+\r
+ If FileSystem is not NULL and Dir is not NULL, then this function changes the current\r
+ directory on the specified file system.\r
+\r
+ If the current working directory or the current working file system is changed then the\r
+ %cwd% environment variable will be updated\r
+\r
+ @param FileSystem A pointer to the file system's mapped name. If NULL, then the current working\r
+ directory is changed.\r
+ @param Dir Points to the NULL-terminated directory on the device specified by FileSystem.\r
+\r
+ @retval EFI_SUCCESS The operation was sucessful\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiShellSetCurDir(\r
+ IN CONST CHAR16 *FileSystem OPTIONAL,\r
+ IN CONST CHAR16 *Dir\r
+ );\r
+\r
+/**\r
+ Return help information about a specific command.\r
+\r
+ This function returns the help information for the specified command. The help text\r
+ can be internal to the shell or can be from a UEFI Shell manual page.\r
+\r
+ If Sections is specified, then each section name listed will be compared in a casesensitive\r
+ manner, to the section names described in Appendix B. If the section exists,\r
+ it will be appended to the returned help text. If the section does not exist, no\r
+ information will be returned. If Sections is NULL, then all help text information\r
+ available will be returned.\r
+\r
+ @param Command Points to the NULL-terminated UEFI Shell command name.\r
+ @param Sections Points to the NULL-terminated comma-delimited\r
+ section names to return. If NULL, then all\r
+ sections will be returned.\r
+ @param HelpText On return, points to a callee-allocated buffer\r
+ containing all specified help text.\r
+\r
+ @retval EFI_SUCCESS The help text was returned.\r
+ @retval EFI_OUT_OF_RESOURCES The necessary buffer could not be allocated to hold the\r
+ returned help text.\r
+ @retval EFI_INVALID_PARAMETER HelpText is NULL\r
+ @retval EFI_NOT_FOUND There is no help text available for Command.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiShellGetHelpText(\r
+ IN CONST CHAR16 *Command,\r
+ IN CONST CHAR16 *Sections OPTIONAL,\r
+ OUT CHAR16 **HelpText\r
+ );\r
+\r
+/**\r
+ Gets the enable status of the page break output mode.\r
+\r
+ User can use this function to determine current page break mode.\r
+\r
+ @retval TRUE The page break output mode is enabled\r
+ @retval FALSE The page break output mode is disabled\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+EfiShellGetPageBreak(\r
+ VOID\r
+ );\r
+\r
+/**\r
+ Judges whether the active shell is the root shell.\r
+\r
+ This function makes the user to know that whether the active Shell is the root shell.\r
+\r
+ @retval TRUE The active Shell is the root Shell.\r
+ @retval FALSE The active Shell is NOT the root Shell.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+EfiShellIsRootShell(\r
+ VOID\r
+ );\r
+\r
+/**\r
+ This function returns the command associated with a alias or a list of all\r
+ alias'.\r
+\r
+ @param[in] Command Points to the NULL-terminated shell alias.\r
+ If this parameter is NULL, then all\r
+ aliases will be returned in ReturnedData.\r
+ @param[out] Volatile upon return of a single command if TRUE indicates\r
+ this is stored in a volatile fashion. FALSE otherwise.\r
+ @return If Alias is not NULL, it will return a pointer to\r
+ the NULL-terminated command for that alias.\r
+ If Alias is NULL, ReturnedData points to a ';'\r
+ delimited list of alias (e.g.\r
+ ReturnedData = "dir;del;copy;mfp") that is NULL-terminated.\r
+ @retval NULL an error ocurred\r
+ @retval NULL Alias was not a valid Alias\r
+**/\r
+CONST CHAR16 *\r
+EFIAPI\r
+EfiShellGetAlias(\r
+ IN CONST CHAR16 *Command,\r
+ OUT BOOLEAN *Volatile OPTIONAL\r
+ );\r
+\r
+/**\r
+ Changes a shell command alias.\r
+\r
+ This function creates an alias for a shell command or if Alias is NULL it will delete an existing alias.\r
+\r
+ this function does not check for built in alias'.\r
+\r
+ @param[in] Command Points to the NULL-terminated shell command or existing alias.\r
+ @param[in] Alias Points to the NULL-terminated alias for the shell command. If this is NULL, and\r
+ Command refers to an alias, that alias will be deleted.\r
+ @param[in] Volatile if TRUE the Alias being set will be stored in a volatile fashion. if FALSE the\r
+ Alias being set will be stored in a non-volatile fashion.\r
+\r
+ @retval EFI_SUCCESS Alias created or deleted successfully.\r
+ @retval EFI_NOT_FOUND the Alias intended to be deleted was not found\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InternalSetAlias(\r
+ IN CONST CHAR16 *Command,\r
+ IN CONST CHAR16 *Alias OPTIONAL,\r
+ IN BOOLEAN Volatile\r
+ );\r
+\r
+/**\r
+ Changes a shell command alias.\r
+\r
+ This function creates an alias for a shell command or if Alias is NULL it will delete an existing alias.\r
+\r
+\r
+ @param[in] Command Points to the NULL-terminated shell command or existing alias.\r
+ @param[in] Alias Points to the NULL-terminated alias for the shell command. If this is NULL, and\r
+ Command refers to an alias, that alias will be deleted.\r
+ @param[in] Replace If TRUE and the alias already exists, then the existing alias will be replaced. If\r
+ FALSE and the alias already exists, then the existing alias is unchanged and\r
+ EFI_ACCESS_DENIED is returned.\r
+ @param[in] Volatile if TRUE the Alias being set will be stored in a volatile fashion. if FALSE the\r
+ Alias being set will be stored in a non-volatile fashion.\r
+\r
+ @retval EFI_SUCCESS Alias created or deleted successfully.\r
+ @retval EFI_NOT_FOUND the Alias intended to be deleted was not found\r
+ @retval EFI_ACCESS_DENIED The alias is a built-in alias or already existed and Replace was set to\r
+ FALSE.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+EfiShellSetAlias(\r
+ IN CONST CHAR16 *Command,\r
+ IN CONST CHAR16 *Alias OPTIONAL,\r
+ IN BOOLEAN Replace,\r
+ IN BOOLEAN Volatile\r
+ );\r
+\r
+/**\r
+ Utility cleanup function for EFI_SHELL_FILE_INFO objects.\r
+\r
+ 1) frees all pointers (non-NULL)\r
+ 2) Closes the SHELL_FILE_HANDLE\r
+\r
+ @param FileListNode pointer to the list node to free\r
+**/\r
+VOID\r
+EFIAPI\r
+InternalFreeShellFileInfoNode(\r
+ IN EFI_SHELL_FILE_INFO *FileListNode\r
+ );\r
+\r
+/**\r
+ Internal variable setting function. Allows for setting of the read only variables.\r
+\r
+ @param Name Points to the NULL-terminated environment variable name.\r
+ @param Value Points to the NULL-terminated environment variable value. If the value is an\r
+ empty string then the environment variable is deleted.\r
+ @param Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).\r
+\r
+ @retval EFI_SUCCESS The environment variable was successfully updated.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+InternalEfiShellSetEnv(\r
+ IN CONST CHAR16 *Name,\r
+ IN CONST CHAR16 *Value,\r
+ IN BOOLEAN Volatile\r
+ );\r
+\r
+#endif //_SHELL_PROTOCOL_HEADER_\r
+\r