]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Include/Library/ShellLib.h
ShellPkg/UefiShellLib: drop DeviceHandle param of ShellOpenFileByDevicePath()
[mirror_edk2.git] / ShellPkg / Include / Library / ShellLib.h
index fd46c7f43fb31165e0ae95364f613ca7266f6030..92fddc50f5dd525f07deeb4568d64e8748328825 100644 (file)
@@ -1,31 +1,48 @@
 /** @file\r
   Provides interface to shell functionality for shell commands and applications.\r
 \r
-Copyright (c) 2006 - 2009, Intel Corporation<BR>\r
-All rights reserved. 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
+  Copyright (c) 2006 - 2018, 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
+  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
-#if !defined(__SHELL_LIB__)\r
+#ifndef __SHELL_LIB__\r
 #define __SHELL_LIB__\r
 \r
+#include <Uefi.h>\r
+#include <Guid/FileInfo.h>\r
 #include <Protocol/SimpleFileSystem.h>\r
-#include <Protocol/EfiShell.h>\r
+#include <Protocol/LoadedImage.h>\r
+#include <Protocol/EfiShellInterface.h>\r
+#include <Protocol/EfiShellEnvironment2.h>\r
+#include <Protocol/Shell.h>\r
+#include <Protocol/ShellParameters.h>\r
+\r
+#define SHELL_FREE_NON_NULL(Pointer)  \\r
+  do {                                \\r
+    if ((Pointer) != NULL) {          \\r
+      FreePool((Pointer));            \\r
+      (Pointer) = NULL;               \\r
+    }                                 \\r
+  } while(FALSE)\r
+\r
+extern EFI_SHELL_PARAMETERS_PROTOCOL *gEfiShellParametersProtocol;\r
+extern EFI_SHELL_PROTOCOL            *gEfiShellProtocol;\r
 \r
 /**\r
-  This function will retrieve the information about the file for the handle \r
+  This function will retrieve the information about the file for the handle\r
   specified and store it in allocated pool memory.\r
 \r
-  This function allocates a buffer to store the file's information. It is the \r
+  This function allocates a buffer to store the file's information. It is the\r
   caller's responsibility to free the buffer.\r
 \r
-  @param[in] FileHandle         The file handle of the file for which information is \r
+  @param[in] FileHandle         The file handle of the file for which information is\r
                                 being requested.\r
 \r
   @retval NULL                  Information could not be retrieved.\r
@@ -35,179 +52,178 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 EFI_FILE_INFO*\r
 EFIAPI\r
 ShellGetFileInfo (\r
-  IN EFI_FILE_HANDLE            FileHandle\r
+  IN SHELL_FILE_HANDLE          FileHandle\r
   );\r
 \r
 /**\r
-  This function will set the information about the file for the opened handle \r
+  This function sets the information about the file for the opened handle\r
   specified.\r
 \r
-  @param[in]  FileHandle        The file handle of the file for which information \r
+  @param[in]  FileHandle        The file handle of the file for which information\r
                                 is being set.\r
 \r
-  @param[in] FileInfo           The infotmation to set.\r
+  @param[in]  FileInfo          The information to set.\r
 \r
-  @retval EFI_SUCCESS            The information was set.\r
-  @retval EFI_UNSUPPORTED       The InformationType is not known.\r
-  @retval EFI_NO_MEDIA               The device has no medium.\r
-  @retval EFI_DEVICE_ERROR         The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
+  @retval EFI_SUCCESS           The information was set.\r
+  @retval EFI_INVALID_PARAMETER A parameter was out of range or invalid.\r
+  @retval EFI_UNSUPPORTED       The FileHandle does not support FileInfo.\r
+  @retval EFI_NO_MEDIA          The device has no medium.\r
+  @retval EFI_DEVICE_ERROR      The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
   @retval EFI_WRITE_PROTECTED   The file or medium is write protected.\r
-  @retval EFI_ACCESS_DENIED        The file was opened read only.\r
-  @retval EFI_VOLUME_FULL            The volume is full.\r
+  @retval EFI_ACCESS_DENIED     The file was opened read only.\r
+  @retval EFI_VOLUME_FULL       The volume is full.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 ShellSetFileInfo (\r
-  IN EFI_FILE_HANDLE           FileHandle,\r
+  IN SHELL_FILE_HANDLE          FileHandle,\r
   IN EFI_FILE_INFO              *FileInfo\r
   );\r
 \r
 /**\r
   This function will open a file or directory referenced by DevicePath.\r
 \r
-  This function opens a file with the open mode according to the file path. The \r
+  This function opens a file with the open mode according to the file path. The\r
   Attributes is valid only for EFI_FILE_MODE_CREATE.\r
 \r
-  @param[in]  FilePath                     On input the device path to the file.  On output \r
-                              the remaining device path.\r
-  @param[out]  DeviceHandle    Pointer to the system device handle.\r
-  @param[out]  FileHandle                Pointer to the file handle.\r
-  @param[in]  OpenMode         The mode to open the file with.\r
-  @param[in]  Attributes               The file's file attributes.\r
-\r
-  @retval EFI_SUCCESS                  The information was set.\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 \r
-                                device or the file system could not be found on \r
+  @param[in, out]  FilePath      On input, the device path to the file.  On output,\r
+                                 the remaining device path.\r
+  @param[out]   FileHandle       Pointer to the file handle.\r
+  @param[in]    OpenMode         The mode to open the file with.\r
+  @param[in]    Attributes       The file's file attributes.\r
+\r
+  @retval EFI_SUCCESS         The information was set.\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\r
+                                device or the file system could not be found on\r
                                 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 \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\r
                                 medium is no longer supported.\r
-  @retval EFI_DEVICE_ERROR         The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
-  @retval EFI_WRITE_PROTECTED    The file or medium is write protected.\r
-  @retval EFI_ACCESS_DENIED        The file was opened read only.\r
-  @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the \r
+  @retval EFI_DEVICE_ERROR      The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
+  @retval EFI_WRITE_PROTECTED   The file or medium is write protected.\r
+  @retval EFI_ACCESS_DENIED     The file was opened read only.\r
+  @retval EFI_OUT_OF_RESOURCES  Not enough resources were available to open the\r
                                 file.\r
-  @retval EFI_VOLUME_FULL            The volume is full.\r
+  @retval EFI_VOLUME_FULL       The volume is full.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 ShellOpenFileByDevicePath(\r
-  IN OUT EFI_DEVICE_PATH_PROTOCOL        **FilePath,\r
-  OUT EFI_HANDLE                       *DeviceHandle,\r
-  OUT EFI_FILE_HANDLE                  *FileHandle,\r
-  IN UINT64                            OpenMode,\r
-  IN UINT64                            Attributes\r
+  IN OUT EFI_DEVICE_PATH_PROTOCOL     **FilePath,\r
+  OUT SHELL_FILE_HANDLE               *FileHandle,\r
+  IN UINT64                           OpenMode,\r
+  IN UINT64                           Attributes\r
   );\r
 \r
 /**\r
   This function will open a file or directory referenced by filename.\r
 \r
-  If return is EFI_SUCCESS, the Filehandle is the opened file's handle; \r
-  otherwise, the Filehandle is NULL. The Attributes is valid only for \r
+  If return is EFI_SUCCESS, the Filehandle is the opened file's handle;\r
+  otherwise, the Filehandle is NULL. Attributes is valid only for\r
   EFI_FILE_MODE_CREATE.\r
 \r
-  @param[in] FileName                Pointer to file name.\r
-  @param[out] FileHandle                   Pointer to the file handle.\r
-  @param[in] OpenMode                  The mode to open the file with.\r
-  @param[in] Attributes                      The file's file attributes.\r
+  @param[in] FilePath           The pointer to file name.\r
+  @param[out] FileHandle        The pointer to the file handle.\r
+  @param[in] OpenMode           The mode to open the file with.\r
+  @param[in] Attributes         The file's file attributes.\r
 \r
-  @retval EFI_SUCCESS                  The information was set.\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 \r
-                                device or the file system could not be found \r
+  @retval EFI_SUCCESS         The information was set.\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\r
+                                device or the file system could not be found\r
                                 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 \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\r
                                 medium is no longer supported.\r
-  @retval EFI_DEVICE_ERROR         The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
-  @retval EFI_WRITE_PROTECTED    The file or medium is write protected.\r
-  @retval EFI_ACCESS_DENIED        The file was opened read only.\r
-  @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the \r
+  @retval EFI_DEVICE_ERROR      The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
+  @retval EFI_WRITE_PROTECTED   The file or medium is write protected.\r
+  @retval EFI_ACCESS_DENIED     The file was opened read only.\r
+  @retval EFI_OUT_OF_RESOURCES  Not enough resources were available to open the\r
                                 file.\r
-  @retval EFI_VOLUME_FULL            The volume is full.\r
+  @retval EFI_VOLUME_FULL       The volume is full.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 ShellOpenFileByName(\r
-  IN CONST CHAR16                          *FilePath,\r
-  OUT EFI_FILE_HANDLE           *FileHandle,\r
+  IN CONST CHAR16               *FilePath,\r
+  OUT SHELL_FILE_HANDLE         *FileHandle,\r
   IN UINT64                     OpenMode,\r
-  IN UINT64                            Attributes\r
+  IN UINT64                     Attributes\r
   );\r
 \r
 /**\r
   This function creates a directory.\r
 \r
-  If return is EFI_SUCCESS, the Filehandle is the opened directory's handle; \r
-  otherwise, the Filehandle is NULL. If the directory already existed, this \r
+  If return is EFI_SUCCESS, the Filehandle is the opened directory's handle;\r
+  otherwise, the Filehandle is NULL. If the directory already existed, this\r
   function opens the existing directory.\r
 \r
-  @param[in]  DirectoryName     Pointer to Directory name.\r
-  @param[out] FileHandle        Pointer to the file handle.\r
+  @param[in]  DirectoryName     The pointer to Directory name.\r
+  @param[out] FileHandle        The pointer to the file handle.\r
 \r
-  @retval EFI_SUCCESS                  The information was set.\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 \r
-                                device or the file system could not be found \r
+  @retval EFI_SUCCESS         The information was set.\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\r
+                                device, or the file system could not be found\r
                                 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 \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\r
                                 medium is no longer supported.\r
-  @retval EFI_DEVICE_ERROR         The device reported an error.\r
-  @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
-  @retval EFI_WRITE_PROTECTED    The file or medium is write protected.\r
-  @retval EFI_ACCESS_DENIED        The file was opened read only.\r
-  @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the \r
+  @retval EFI_DEVICE_ERROR      The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED  The file system structures are corrupted.\r
+  @retval EFI_WRITE_PROTECTED   The file or medium is write protected.\r
+  @retval EFI_ACCESS_DENIED     The file was opened read only.\r
+  @retval EFI_OUT_OF_RESOURCES  Not enough resources were available to open the\r
                                 file.\r
-  @retval EFI_VOLUME_FULL            The volume is full.\r
+  @retval EFI_VOLUME_FULL       The volume is full.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 ShellCreateDirectory(\r
   IN CONST CHAR16             *DirectoryName,\r
-  OUT EFI_FILE_HANDLE         *FileHandle\r
+  OUT SHELL_FILE_HANDLE       *FileHandle\r
   );\r
 \r
 /**\r
   This function reads information from an opened file.\r
 \r
-  If FileHandle is not a directory, the function reads the requested number of \r
-  bytes from the file at the file's current position and returns them in Buffer. \r
+  If FileHandle is not a directory, the function reads the requested number of\r
+  bytes from the file at the file's current position and returns them in Buffer.\r
   If the read goes beyond the end of the file, the read length is truncated to the\r
-  end of the file. The file's current position is increased by the number of bytes \r
-  returned.  If FileHandle is a directory, the function reads the directory entry \r
-  at the file's current position and returns the entry in Buffer. If the Buffer \r
-  is not large enough to hold the current directory entry, then \r
-  EFI_BUFFER_TOO_SMALL is returned and the current file position is not updated. \r
-  BufferSize is set to be the size of the buffer needed to read the entry. On \r
-  success, the current position is updated to the next directory entry. If there \r
-  are no more directory entries, the read returns a zero-length buffer. \r
+  end of the file. The file's current position is increased by the number of bytes\r
+  returned.  If FileHandle is a directory, the function reads the directory entry\r
+  at the file's current position and returns the entry in Buffer. If the Buffer\r
+  is not large enough to hold the current directory entry, then\r
+  EFI_BUFFER_TOO_SMALL is returned and the current file position is not updated.\r
+  BufferSize is set to be the size of the buffer needed to read the entry. On\r
+  success, the current position is updated to the next directory entry. If there\r
+  are no more directory entries, the read returns a zero-length buffer.\r
   EFI_FILE_INFO is the structure returned as the directory entry.\r
 \r
-  @param[in] FileHandle         The opened file handle.\r
-  @param[in] ReadSize           On input the size of buffer in bytes.  On return \r
-                                the number of bytes written.\r
-  @param[out] Buffer            The buffer to put read data into.\r
+  @param[in] FileHandle          The opened file handle.\r
+  @param[in, out] ReadSize       On input the size of buffer in bytes.  On return\r
+                                 the number of bytes written.\r
+  @param[out] Buffer             The buffer to put read data into.\r
 \r
-  @retval EFI_SUCCESS            Data was read.\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
-  @retval EFI_BUFFER_TO_SMALL    Buffer is too small. ReadSize contains required \r
+  @retval EFI_SUCCESS           Data was read.\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
+  @retval EFI_BUFFER_TO_SMALL   Buffer is too small. ReadSize contains required\r
                                 size.\r
 \r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 ShellReadFile(\r
-  IN EFI_FILE_HANDLE            FileHandle,\r
+  IN SHELL_FILE_HANDLE          FileHandle,\r
   IN OUT UINTN                  *ReadSize,\r
   OUT VOID                      *Buffer\r
   );\r
@@ -215,112 +231,112 @@ ShellReadFile(
 /**\r
   Write data to a file.\r
 \r
-  This function writes the specified number of bytes to the file at the current \r
-  file position. The current file position is advanced the actual number of bytes \r
-  written, which is returned in BufferSize. Partial writes only occur when there \r
-  has been a data error during the write attempt (such as "volume space full"). \r
-  The file is automatically grown to hold the data if required. Direct writes to \r
+  This function writes the specified number of bytes to the file at the current\r
+  file position. The current file position is advanced the actual number of bytes\r
+  written, which is returned in BufferSize. Partial writes only occur when there\r
+  has been a data error during the write attempt (such as "volume space full").\r
+  The file is automatically grown to hold the data if required. Direct writes to\r
   opened directories are not supported.\r
 \r
-  @param[in] FileHandle         The opened file for writing.\r
+  @param[in] FileHandle          The opened file for writing.\r
 \r
-  @param[in] BufferSize         On input the number of bytes in Buffer.  On output\r
-                                the number of bytes written.\r
+  @param[in, out] BufferSize     On input the number of bytes in Buffer.  On output\r
+                                 the number of bytes written.\r
 \r
-  @param[in] Buffer             The buffer containing data to write is stored.\r
+  @param[in] Buffer              The buffer containing data to write is stored.\r
 \r
-  @retval EFI_SUCCESS            Data was written.\r
-  @retval EFI_UNSUPPORTED            Writes to an open directory are not supported.\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
-  @retval EFI_WRITE_PROTECTED    The device is write-protected.\r
-  @retval EFI_ACCESS_DENIED        The file was open for read only.\r
-  @retval EFI_VOLUME_FULL            The volume is full.\r
+  @retval EFI_SUCCESS           Data was written.\r
+  @retval EFI_UNSUPPORTED       Writes to an open directory are not supported.\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
+  @retval EFI_WRITE_PROTECTED   The device is write-protected.\r
+  @retval EFI_ACCESS_DENIED     The file was open for read only.\r
+  @retval EFI_VOLUME_FULL       The volume is full.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 ShellWriteFile(\r
-  IN EFI_FILE_HANDLE            FileHandle,\r
+  IN SHELL_FILE_HANDLE          FileHandle,\r
   IN OUT UINTN                  *BufferSize,\r
   IN VOID                       *Buffer\r
   );\r
 \r
-/** \r
+/**\r
   Close an open file handle.\r
 \r
-  This function closes a specified file handle. All "dirty" cached file data is \r
-  flushed to the device, and the file is closed. In all cases the handle is \r
+  This function closes a specified file handle. All "dirty" cached file data is\r
+  flushed to the device, and the file is closed. In all cases the handle is\r
   closed.\r
 \r
   @param[in] FileHandle           The file handle to close.\r
 \r
   @retval EFI_SUCCESS             The file handle was closed sucessfully.\r
-  @retval INVALID_PARAMETER            One of the parameters has an invalid value.\r
+  @retval INVALID_PARAMETER       One of the parameters has an invalid value.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 ShellCloseFile (\r
-  IN EFI_FILE_HANDLE            *FileHandle\r
+  IN SHELL_FILE_HANDLE          *FileHandle\r
   );\r
 \r
 /**\r
   Delete a file and close the handle\r
 \r
   This function closes and deletes a file. In all cases the file handle is closed.\r
-  If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is \r
+  If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is\r
   returned, but the handle is still closed.\r
 \r
   @param[in] FileHandle             The file handle to delete.\r
 \r
   @retval EFI_SUCCESS               The file was closed sucessfully.\r
-  @retval EFI_WARN_DELETE_FAILURE   The handle was closed, but the file was not \r
+  @retval EFI_WARN_DELETE_FAILURE   The handle was closed, but the file was not\r
                                     deleted.\r
-  @retval INVALID_PARAMETER                One of the parameters has an invalid value.\r
+  @retval INVALID_PARAMETER         One of the parameters has an invalid value.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 ShellDeleteFile (\r
-  IN EFI_FILE_HANDLE           *FileHandle\r
+  IN SHELL_FILE_HANDLE          *FileHandle\r
   );\r
 \r
 /**\r
   Set the current position in a file.\r
 \r
-  This function sets the current file position for the handle to the position \r
+  This function sets the current file position for the handle to the position\r
   supplied. With the exception of seeking to position 0xFFFFFFFFFFFFFFFF, only\r
-  absolute positioning is supported, and seeking past the end of the file is \r
-  allowed (a subsequent write would grow the file). Seeking to position \r
+  absolute positioning is supported, and moving past the end of the file is\r
+  allowed (a subsequent write would grow the file). Moving to position\r
   0xFFFFFFFFFFFFFFFF causes the current position to be set to the end of the file.\r
-  If FileHandle is a directory, the only position that may be set is zero. This \r
+  If FileHandle is a directory, the only position that may be set is zero. This\r
   has the effect of starting the read process of the directory entries over.\r
 \r
   @param[in] FileHandle         The file handle on which the position is being set.\r
 \r
-  @param[in] Position           Byte position from begining of file.\r
+  @param[in] Position           The byte position from the begining of the file.\r
 \r
   @retval EFI_SUCCESS           Operation completed sucessfully.\r
-  @retval EFI_UNSUPPORTED       The seek request for non-zero is not valid on \r
+  @retval EFI_UNSUPPORTED       The seek request for non-zero is not valid on\r
                                 directories.\r
   @retval INVALID_PARAMETER     One of the parameters has an invalid value.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 ShellSetFilePosition (\r
-  IN EFI_FILE_HANDLE           FileHandle,\r
-  IN UINT64            Position\r
+  IN SHELL_FILE_HANDLE  FileHandle,\r
+  IN UINT64             Position\r
   );\r
 \r
-/** \r
+/**\r
   Gets a file's current position\r
 \r
-  This function retrieves the current file position for the file handle. For \r
-  directories, the current file position has no meaning outside of the file \r
+  This function retrieves the current file position for the file handle. For\r
+  directories, the current file position has no meaning outside of the file\r
   system driver and as such the operation is not supported. An error is returned\r
   if FileHandle is a directory.\r
 \r
   @param[in] FileHandle         The open file handle on which to get the position.\r
-  @param[out] Position          Byte position from begining of file.\r
+  @param[out] Position          The byte position from the begining of the file.\r
 \r
   @retval EFI_SUCCESS           The operation completed sucessfully.\r
   @retval INVALID_PARAMETER     One of the parameters has an invalid value.\r
@@ -329,13 +345,13 @@ ShellSetFilePosition (
 EFI_STATUS\r
 EFIAPI\r
 ShellGetFilePosition (\r
-  IN EFI_FILE_HANDLE            FileHandle,\r
+  IN SHELL_FILE_HANDLE          FileHandle,\r
   OUT UINT64                    *Position\r
   );\r
 \r
 /**\r
   Flushes data on a file\r
-  \r
+\r
   This function flushes all modified data associated with a file to a device.\r
 \r
   @param[in] FileHandle         The file handle on which to flush data.\r
@@ -350,70 +366,76 @@ ShellGetFilePosition (
 EFI_STATUS\r
 EFIAPI\r
 ShellFlushFile (\r
-  IN EFI_FILE_HANDLE            FileHandle\r
+  IN SHELL_FILE_HANDLE          FileHandle\r
   );\r
 \r
-/**\r
-  Retrieves the first file from a directory\r
+/** Retrieve first entry from a directory.\r
 \r
-  This function takes an open directory handle and gets the first file \r
-  in the directory's info. Caller can use ShellFindNextFile() to get \r
-  subsequent files.\r
+  This function takes an open directory handle and gets information from the\r
+  first entry in the directory.  A buffer is allocated to contain\r
+  the information and a pointer to the buffer is returned in *Buffer.  The\r
+  caller can use ShellFindNextFile() to get subsequent directory entries.\r
 \r
-  Caller must use FreePool on *Buffer opon completion of all file searching.\r
+  The buffer will be freed by ShellFindNextFile() when the last directory\r
+  entry is read.  Otherwise, the caller must free the buffer, using FreePool,\r
+  when finished with it.\r
 \r
-  @param[in] DirHandle          The file handle of the directory to search\r
-  @param[out] Buffer            Pointer to pointer to buffer for file's information\r
+  @param[in]  DirHandle         The file handle of the directory to search.\r
+  @param[out] Buffer            The pointer to the buffer for the file's information.\r
 \r
   @retval EFI_SUCCESS           Found the first file.\r
   @retval EFI_NOT_FOUND         Cannot find the directory.\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
-  @return ShellReadFile\r
+  @return Others                Status of ShellGetFileInfo, ShellSetFilePosition,\r
+                                or ShellReadFile.\r
+\r
+  @sa ShellReadFile\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 ShellFindFirstFile (\r
-  IN EFI_FILE_HANDLE            DirHandle,\r
-  OUT EFI_FILE_INFO             **Buffer\r
+  IN      SHELL_FILE_HANDLE       DirHandle,\r
+     OUT  EFI_FILE_INFO         **Buffer\r
   );\r
 \r
-/**\r
-  Retrieves the next file in a directory.\r
+/** Retrieve next entries from a directory.\r
 \r
-  To use this function, caller must call the ShellFindFirstFile() to get the \r
-  first file, and then use this function get other files. This function can be \r
-  called for several times to get each file's information in the directory. If \r
-  the call of ShellFindNextFile() got the last file in the directory, the next \r
-  call of this function has no file to get. *NoFile will be set to TRUE and the \r
-  data in Buffer is meaningless. \r
+  To use this function, the caller must first call the ShellFindFirstFile()\r
+  function to get the first directory entry.  Subsequent directory entries are\r
+  retrieved by using the ShellFindNextFile() function.  This function can\r
+  be called several times to get each entry from the directory.  If the call of\r
+  ShellFindNextFile() retrieved the last directory entry, the next call of\r
+  this function will set *NoFile to TRUE and free the buffer.\r
 \r
-  @param[in] DirHandle          The file handle of the directory.\r
-  @param[out] Buffer                         Pointer to buffer for file's information.\r
-  @param[out] NoFile                         Pointer to boolean when last file is found.\r
+  @param[in]  DirHandle         The file handle of the directory.\r
+  @param[in, out] Buffer        The pointer to buffer for file's information.\r
+  @param[in, out] NoFile        The pointer to boolean when last file is found.\r
 \r
   @retval EFI_SUCCESS           Found the next file.\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
+  @sa ShellReadFile\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 ShellFindNextFile(\r
-  IN EFI_FILE_HANDLE             DirHandle,\r
-  OUT EFI_FILE_INFO              *Buffer,\r
-  OUT BOOLEAN                    *NoFile\r
+  IN      SHELL_FILE_HANDLE       DirHandle,\r
+  IN OUT  EFI_FILE_INFO          *Buffer,\r
+  IN OUT  BOOLEAN                *NoFile\r
   );\r
 \r
 /**\r
   Retrieve the size of a file.\r
 \r
-  This function extracts the file size info from the FileHandle's EFI_FILE_INFO \r
+  This function extracts the file size info from the FileHandle's EFI_FILE_INFO\r
   data.\r
 \r
   @param[in] FileHandle         The file handle from which size is retrieved.\r
-  @param[out] Size              Pointer to size.\r
+  @param[out] Size              The pointer to size.\r
 \r
   @retval EFI_SUCCESS           The operation was completed sucessfully.\r
   @retval EFI_DEVICE_ERROR      Cannot access the file.\r
@@ -421,7 +443,7 @@ ShellFindNextFile(
 EFI_STATUS\r
 EFIAPI\r
 ShellGetFileSize (\r
-  IN EFI_FILE_HANDLE            FileHandle,\r
+  IN SHELL_FILE_HANDLE          FileHandle,\r
   OUT UINT64                    *Size\r
   );\r
 \r
@@ -430,8 +452,8 @@ ShellGetFileSize (
 \r
   This function is useful to check whether the application is being asked to halt by the shell.\r
 \r
-  @retval TRUE                  the execution break is enabled\r
-  @retval FALSE                 the execution break is not enabled\r
+  @retval TRUE                  The execution break is enabled.\r
+  @retval FALSE                 The execution break is not enabled.\r
 **/\r
 BOOLEAN\r
 EFIAPI\r
@@ -442,13 +464,13 @@ ShellGetExecutionBreakFlag(
 /**\r
   Return the value of an environment variable.\r
 \r
-  This function gets the value of the environment variable set by the \r
+  This function gets the value of the environment variable set by the\r
   ShellSetEnvironmentVariable function.\r
 \r
   @param[in] EnvKey             The key name of the environment variable.\r
 \r
   @retval NULL                  The named environment variable does not exist.\r
-  @return != NULL               pointer to the value of the environment variable.\r
+  @return != NULL               The pointer to the value of the environment variable.\r
 **/\r
 CONST CHAR16*\r
 EFIAPI\r
@@ -473,8 +495,8 @@ ShellGetEnvironmentVariable (
   @param[in] EnvVal             The Value of the environment variable\r
   @param[in] Volatile           Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).\r
 \r
-  @retval EFI_SUCCESS           the operation was completed sucessfully\r
-  @retval EFI_UNSUPPORTED       This operation is not allowed in pre UEFI 2.0 Shell environments\r
+  @retval EFI_SUCCESS           The operation completed sucessfully\r
+  @retval EFI_UNSUPPORTED       This operation is not allowed in pre-UEFI 2.0 Shell environments.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -496,14 +518,16 @@ ShellSetEnvironmentVariable (
   The CommandLine is executed from the current working directory on the current\r
   device.\r
 \r
-  EnvironmentVariables and Status are only supported for UEFI Shell 2.0 (or later).\r
-  Output is only supported for pre-UEFI Shell 2.0\r
+  The EnvironmentVariables and Status parameters are ignored in a pre-UEFI Shell 2.0\r
+  environment.  The values pointed to by the parameters will be unchanged by the\r
+  ShellExecute() function.  The Output parameter has no effect in a\r
+  UEFI Shell 2.0 environment.\r
 \r
-  @param[in] ImageHandle          Parent image that is starting the operation.\r
-  @param[in] CommandLine          Pointer to null terminated command line.\r
+  @param[in] ParentHandle         The parent image starting the operation.\r
+  @param[in] CommandLine          The pointer to a NULL terminated command line.\r
   @param[in] Output               True to display debug output.  False to hide it.\r
   @param[in] EnvironmentVariables Optional pointer to array of environment variables\r
-                                  in the form "x=y".  If NULL current set is used.\r
+                                  in the form "x=y".  If NULL, the current set is used.\r
   @param[out] Status              The status of the run command line.\r
 \r
   @retval EFI_SUCCESS             The operation completed sucessfully.  Status\r
@@ -525,10 +549,12 @@ ShellExecute (
 /**\r
   Retreives the current directory path.\r
 \r
-  If the DeviceName is NULL, it returns the current device's current directory \r
-  name. If the DeviceName is not NULL, it returns the current directory name \r
+  If the DeviceName is NULL, it returns the current device's current directory\r
+  name. If the DeviceName is not NULL, it returns the current directory name\r
   on specified drive.\r
 \r
+  Note that the current directory string should exclude the tailing backslash character.\r
+\r
   @param[in] DeviceName         The name of the file system to get directory on.\r
 \r
   @retval NULL                  The directory does not exist.\r
@@ -537,18 +563,18 @@ ShellExecute (
 CONST CHAR16*\r
 EFIAPI\r
 ShellGetCurrentDir (\r
-  IN CHAR16                     *DeviceName OPTIONAL\r
+  IN CHAR16                     * CONST DeviceName OPTIONAL\r
   );\r
 \r
 /**\r
   Sets (enabled or disabled) the page break mode.\r
 \r
-  When page break mode is enabled the screen will stop scrolling \r
+  When page break mode is enabled the screen will stop scrolling\r
   and wait for operator input before scrolling a subsequent screen.\r
 \r
   @param[in] CurrentState       TRUE to enable and FALSE to disable.\r
 **/\r
-VOID \r
+VOID\r
 EFIAPI\r
 ShellSetPageBreakMode (\r
   IN BOOLEAN                    CurrentState\r
@@ -557,21 +583,21 @@ ShellSetPageBreakMode (
 /**\r
   Opens a group of files based on a path.\r
 \r
-  This function uses the Arg to open all the matching files. Each matched \r
-  file has a SHELL_FILE_ARG structure to record the file information. These \r
-  structures are placed on the list ListHead. Users can get the SHELL_FILE_ARG \r
+  This function uses the Arg to open all the matching files. Each matched\r
+  file has a SHELL_FILE_ARG structure to record the file information. These\r
+  structures are placed on the list ListHead. Users can get the SHELL_FILE_ARG\r
   structures from ListHead to access each file. This function supports wildcards\r
-  and will process '?' and '*' as such.  The list must be freed with a call to \r
+  and will process '?' and '*' as such.  The list must be freed with a call to\r
   ShellCloseFileMetaArg().\r
 \r
-  If you are NOT appending to an existing list *ListHead must be NULL.  If \r
+  If you are NOT appending to an existing list *ListHead must be NULL.  If\r
   *ListHead is NULL then it must be callee freed.\r
 \r
-  @param[in] Arg                Pointer to path string.\r
-  @param[in] OpenMode           Mode to open files with.\r
-  @param[in] ListHead           Head of linked list of results.\r
+  @param[in] Arg                 The pointer to path string.\r
+  @param[in] OpenMode            Mode to open files with.\r
+  @param[in, out] ListHead       Head of linked list of results.\r
 \r
-  @retval EFI_SUCCESS           The operation was sucessful and the list head \r
+  @retval EFI_SUCCESS           The operation was sucessful and the list head\r
                                 contains the list of opened files.\r
   @retval != EFI_SUCCESS        The operation failed.\r
 \r
@@ -588,7 +614,7 @@ ShellOpenFileMetaArg (
 /**\r
   Free the linked list returned from ShellOpenFileMetaArg.\r
 \r
-  @param[in] ListHead           The pointer to free.\r
+  @param[in, out] ListHead       The pointer to free.\r
 \r
   @retval EFI_SUCCESS           The operation was sucessful.\r
   @retval EFI_INVALID_PARAMETER A parameter was invalid.\r
@@ -617,6 +643,29 @@ ShellFindFilePath (
   IN CONST CHAR16 *FileName\r
   );\r
 \r
+/**\r
+  Find a file by searching the CWD and then the path with a variable set of file\r
+  extensions.  If the file is not found it will append each extension in the list\r
+  in the order provided and return the first one that is successful.\r
+\r
+  If FileName is NULL, then ASSERT.\r
+  If FileExtension is NULL, then the behavior is identical to ShellFindFilePath.\r
+\r
+  If the return value is not NULL then the memory must be caller freed.\r
+\r
+  @param[in] FileName           The filename string.\r
+  @param[in] FileExtension      Semicolon delimited list of possible extensions.\r
+\r
+  @retval NULL                  The file was not found.\r
+  @retval !NULL                 The path to the file.\r
+**/\r
+CHAR16 *\r
+EFIAPI\r
+ShellFindFilePathEx (\r
+  IN CONST CHAR16 *FileName,\r
+  IN CONST CHAR16 *FileExtension\r
+  );\r
+\r
 typedef enum {\r
   TypeFlag  = 0,    ///< A flag that is present or not present only (IE "-a").\r
   TypeValue,        ///< A flag that has some data following it with a space (IE "-a 1").\r
@@ -624,27 +673,31 @@ typedef enum {
   TypeStart,        ///< A flag that has variable value appended to the end (IE "-ad", "-afd", "-adf", etc...).\r
   TypeDoubleValue,  ///< A flag that has 2 space seperated value data following it (IE "-a 1 2").\r
   TypeMaxValue,     ///< A flag followed by all the command line data before the next flag.\r
+  TypeTimeValue,    ///< A flag that has a time value following it (IE "-a -5:00").\r
   TypeMax,\r
-} ParamType;\r
+} SHELL_PARAM_TYPE;\r
 \r
 typedef struct {\r
-  CHAR16      *Name;\r
-  ParamType   Type;\r
+  CHAR16             *Name;\r
+  SHELL_PARAM_TYPE   Type;\r
 } SHELL_PARAM_ITEM;\r
 \r
 \r
 /// Helper structure for no parameters (besides -? and -b)\r
 extern SHELL_PARAM_ITEM EmptyParamList[];\r
 \r
+/// Helper structure for -sfo only (besides -? and -b)\r
+extern SHELL_PARAM_ITEM SfoParamList[];\r
+\r
 /**\r
-  Checks the command line arguments passed against the list of valid ones.  \r
+  Checks the command line arguments passed against the list of valid ones.\r
   Optionally removes NULL values first.\r
-  \r
+\r
   If no initialization is required, then return RETURN_SUCCESS.\r
-  \r
-  @param[in] CheckList          Pointer to list of parameters to check.\r
-  @param[out] CheckPackage      Package of checked values.\r
-  @param[out] ProblemParam      Optional pointer to pointer to unicode string for \r
+\r
+  @param[in] CheckList          The pointer to list of parameters to check.\r
+  @param[out] CheckPackage      The package of checked values.\r
+  @param[out] ProblemParam      Optional pointer to pointer to unicode string for\r
                                 the paramater that caused failure.\r
   @param[in] AutoPageBreak      Will automatically set PageBreakEnabled.\r
   @param[in] AlwaysAllowNumbers Will never fail for number based flags.\r
@@ -652,13 +705,11 @@ extern SHELL_PARAM_ITEM EmptyParamList[];
   @retval EFI_SUCCESS           The operation completed sucessfully.\r
   @retval EFI_OUT_OF_RESOURCES  A memory allocation failed.\r
   @retval EFI_INVALID_PARAMETER A parameter was invalid.\r
-  @retval EFI_VOLUME_CORRUPTED  The command line was corrupt.  An argument was \r
-                                duplicated.  The duplicated command line argument \r
-                                was returned in ProblemParam if provided.\r
+  @retval EFI_VOLUME_CORRUPTED  The command line was corrupt.\r
   @retval EFI_DEVICE_ERROR      The commands contained 2 opposing arguments.  One\r
-                                of the command line arguments was returned in \r
+                                of the command line arguments was returned in\r
                                 ProblemParam if provided.\r
-  @retval EFI_NOT_FOUND         A argument required a value that was missing.  \r
+  @retval EFI_NOT_FOUND         A argument required a value that was missing.\r
                                 The invalid command line argument was returned in\r
                                 ProblemParam if provided.\r
 **/\r
@@ -698,33 +749,33 @@ ShellCommandLineFreeVarList (
 \r
   If CheckPackage is NULL then return FALSE.\r
   If KeyString is NULL then ASSERT().\r
-  \r
+\r
   @param[in] CheckPackage       The package of parsed command line arguments.\r
   @param[in] KeyString          The Key of the command line argument to check for.\r
 \r
   @retval TRUE                  The flag is on the command line.\r
   @retval FALSE                 The flag is not on the command line.\r
-  **/\r
+**/\r
 BOOLEAN\r
 EFIAPI\r
 ShellCommandLineGetFlag (\r
-  IN CONST LIST_ENTRY              *CheckPackage,\r
-  IN CHAR16                        *KeyString\r
+  IN CONST LIST_ENTRY         * CONST CheckPackage,\r
+  IN CONST CHAR16             * CONST KeyString\r
   );\r
 \r
 /**\r
   Returns value from command line argument.\r
 \r
   Value parameters are in the form of "-<Key> value" or "/<Key> value".\r
-  \r
+\r
   If CheckPackage is NULL, then return NULL.\r
 \r
   @param[in] CheckPackage       The package of parsed command line arguments.\r
   @param[in] KeyString          The Key of the command line argument to check for.\r
 \r
   @retval NULL                  The flag is not on the command line.\r
-  @retval !=NULL                Pointer to unicode string of the value.\r
-  **/\r
+  @retval !=NULL                The pointer to unicode string of the value.\r
+**/\r
 CONST CHAR16*\r
 EFIAPI\r
 ShellCommandLineGetValue (\r
@@ -736,41 +787,43 @@ ShellCommandLineGetValue (
   Returns raw value from command line argument.\r
 \r
   Raw value parameters are in the form of "value" in a specific position in the list.\r
-  \r
+\r
   If CheckPackage is NULL, then return NULL.\r
 \r
   @param[in] CheckPackage       The package of parsed command line arguments.\r
   @param[in] Position           The position of the value.\r
 \r
   @retval NULL                  The flag is not on the command line.\r
-  @retval !=NULL                Pointer to unicode string of the value.\r
-  **/\r
+  @retval !=NULL                The pointer to unicode string of the value.\r
+**/\r
 CONST CHAR16*\r
 EFIAPI\r
 ShellCommandLineGetRawValue (\r
-  IN CONST LIST_ENTRY              *CheckPackage,\r
-  IN UINT32                        Position\r
+  IN CONST LIST_ENTRY              * CONST CheckPackage,\r
+  IN UINT                        Position\r
   );\r
 \r
 /**\r
-  Returns the number of command line value parameters that were parsed.  \r
-  \r
+  Returns the number of command line value parameters that were parsed.\r
+\r
   This will not include flags.\r
 \r
-  @retval (UINTN)-1     No parsing has ocurred.\r
-  @return               The number of value parameters found.\r
+  @param[in] CheckPackage       The package of parsed command line arguments.\r
+\r
+  @retval (UINTN)-1             No parsing has occurred.\r
+  @retval other                 The number of value parameters found.\r
 **/\r
 UINTN\r
 EFIAPI\r
 ShellCommandLineGetCount(\r
-  VOID\r
+  IN CONST LIST_ENTRY              *CheckPackage\r
   );\r
 \r
 /**\r
-  Determins if a parameter is duplicated.\r
+  Determines if a parameter is duplicated.\r
 \r
-  If Param is not NULL then it will point to a callee allocated string buffer \r
-  with the parameter value if a duplicate is found.\r
+  If Param is not NULL, then it will point to a callee-allocated string buffer\r
+  with the parameter value, if a duplicate is found.\r
 \r
   If CheckPackage is NULL, then ASSERT.\r
 \r
@@ -789,7 +842,7 @@ ShellCommandLineCheckDuplicate (
 \r
 /**\r
   This function causes the shell library to initialize itself.  If the shell library\r
-  is already initialized it will de-initialize all the current protocol poitners and\r
+  is already initialized it will de-initialize all the current protocol pointers and\r
   re-populate them again.\r
 \r
   When the library is used with PcdShellLibAutoInitialize set to true this function\r
@@ -797,7 +850,7 @@ ShellCommandLineCheckDuplicate (
 \r
   This function is intended for internal access for shell commands only.\r
 \r
-  @retval EFI_SUCCESS   the initialization was complete sucessfully\r
+  @retval EFI_SUCCESS   The initialization was complete sucessfully.\r
 \r
 **/\r
 EFI_STATUS\r
@@ -810,14 +863,14 @@ ShellInitialize (
   Print at a specific location on the screen.\r
 \r
   This function will move the cursor to a given screen location and print the specified string.\r
-  \r
-  If -1 is specified for either the Row or Col the current screen location for BOTH \r
+\r
+  If -1 is specified for either the Row or Col the current screen location for BOTH\r
   will be used.\r
 \r
   If either Row or Col is out of range for the current console, then ASSERT.\r
   If Format is NULL, then ASSERT.\r
 \r
-  In addition to the standard %-based flags as supported by UefiLib Print() this supports \r
+  In addition to the standard %-based flags as supported by UefiLib Print() this supports\r
   the following additional flags:\r
     %N       -   Set output attribute to normal\r
     %H       -   Set output attribute to highlight\r
@@ -827,14 +880,15 @@ ShellInitialize (
 \r
   Note: The background color is controlled by the shell command cls.\r
 \r
-  @param[in] Row        The row to print at.\r
   @param[in] Col        The column to print at.\r
+  @param[in] Row        The row to print at.\r
   @param[in] Format     The format string.\r
+  @param[in] ...        The variable argument list.\r
 \r
-  @return The number of characters printed to the screen.\r
+  @return EFI_SUCCESS           The printing was successful.\r
+  @return EFI_DEVICE_ERROR      The console device reported an error.\r
 **/\r
-\r
-UINTN\r
+EFI_STATUS\r
 EFIAPI\r
 ShellPrintEx(\r
   IN INT32                Col OPTIONAL,\r
@@ -847,14 +901,14 @@ ShellPrintEx(
   Print at a specific location on the screen.\r
 \r
   This function will move the cursor to a given screen location and print the specified string.\r
-  \r
-  If -1 is specified for either the Row or Col the current screen location for BOTH \r
+\r
+  If -1 is specified for either the Row or Col the current screen location for BOTH\r
   will be used.\r
 \r
   If either Row or Col is out of range for the current console, then ASSERT.\r
   If Format is NULL, then ASSERT.\r
 \r
-  In addition to the standard %-based flags as supported by UefiLib Print() this supports \r
+  In addition to the standard %-based flags as supported by UefiLib Print() this supports\r
   the following additional flags:\r
     %N       -   Set output attribute to normal.\r
     %H       -   Set output attribute to highlight.\r
@@ -864,18 +918,23 @@ ShellPrintEx(
 \r
   Note: The background color is controlled by the shell command cls.\r
 \r
-  @param[in] Row                The row to print at.\r
   @param[in] Col                The column to print at.\r
+  @param[in] Row                The row to print at.\r
+  @param[in] Language           The language of the string to retrieve.  If this parameter\r
+                                is NULL, then the current platform language is used.\r
   @param[in] HiiFormatStringId  The format string Id for getting from Hii.\r
   @param[in] HiiFormatHandle    The format string Handle for getting from Hii.\r
+  @param[in] ...                The variable argument list.\r
 \r
-  @return the number of characters printed to the screen.\r
+  @return EFI_SUCCESS           The printing was successful.\r
+  @return EFI_DEVICE_ERROR      The console device reported an error.\r
 **/\r
-UINTN\r
+EFI_STATUS\r
 EFIAPI\r
 ShellPrintHiiEx(\r
   IN INT32                Col OPTIONAL,\r
   IN INT32                Row OPTIONAL,\r
+  IN CONST CHAR8          *Language OPTIONAL,\r
   IN CONST EFI_STRING_ID  HiiFormatStringId,\r
   IN CONST EFI_HANDLE     HiiFormatHandle,\r
   ...\r
@@ -901,6 +960,8 @@ ShellIsDirectory(
 /**\r
   Function to determine if a given filename represents a file.\r
 \r
+  This will search the CWD only.\r
+\r
   If Name is NULL, then ASSERT.\r
 \r
   @param[in] Name         Path to file to test.\r
@@ -916,12 +977,35 @@ ShellIsFile(
   );\r
 \r
 /**\r
-  Function to determine whether a string is decimal or hex representation of a number \r
+  Function to determine if a given filename represents a file.\r
+\r
+  This will search the CWD and then the Path.\r
+\r
+  If Name is NULL, then ASSERT.\r
+\r
+  @param[in] Name         Path to file to test.\r
+\r
+  @retval EFI_SUCCESS     The Path represents a file.\r
+  @retval EFI_NOT_FOUND   The Path does not represent a file.\r
+  @retval other           The path failed to open.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellIsFileInPath(\r
+  IN CONST CHAR16 *Name\r
+  );\r
+\r
+/**\r
+  Function to determine whether a string is decimal or hex representation of a number\r
   and return the number converted from the string.\r
 \r
-  @param[in] String   String representation of a number\r
+  Note: this function cannot be used when (UINTN)(-1), (0xFFFFFFFF) may be a valid\r
+  result.  Use ShellConvertStringToUint64 instead.\r
+\r
+  @param[in] String   String representation of a number.\r
 \r
   @return             The unsigned integer result of the conversion.\r
+  @retval (UINTN)(-1) An error occured.\r
 **/\r
 UINTN\r
 EFIAPI\r
@@ -930,38 +1014,55 @@ ShellStrToUintn(
   );\r
 \r
 /**\r
-  Safely append with automatic string resizing given length of Destination and \r
+  Function return the number converted from a hex representation of a number.\r
+\r
+  Note: this function cannot be used when (UINTN)(-1), (0xFFFFFFFF) may be a valid\r
+  result.  Use ShellConvertStringToUint64 instead.\r
+\r
+  @param[in] String   String representation of a number.\r
+\r
+  @return             The unsigned integer result of the conversion.\r
+  @retval (UINTN)(-1) An error occured.\r
+**/\r
+UINTN\r
+EFIAPI\r
+ShellHexStrToUintn(\r
+  IN CONST CHAR16 *String\r
+  );\r
+\r
+/**\r
+  Safely append with automatic string resizing given length of Destination and\r
   desired length of copy from Source.\r
 \r
-  Append the first D characters of Source to the end of Destination, where D is \r
-  the lesser of Count and the StrLen() of Source. If appending those D characters \r
-  will fit within Destination (whose Size is given as CurrentSize) and \r
-  still leave room for a null terminator, then those characters are appended, \r
-  starting at the original terminating null of Destination, and a new terminating \r
-  null is appended.\r
+  Append the first D characters of Source to the end of Destination, where D is\r
+  the lesser of Count and the StrLen() of Source. If appending those D characters\r
+  will fit within Destination (whose Size is given as CurrentSize) and\r
+  still leave room for a NULL terminator, then those characters are appended,\r
+  starting at the original terminating NULL of Destination, and a new terminating\r
+  NULL is appended.\r
 \r
   If appending D characters onto Destination will result in a overflow of the size\r
   given in CurrentSize the string will be grown such that the copy can be performed\r
   and CurrentSize will be updated to the new size.\r
 \r
-  If Source is NULL, there is nothing to append, just return the current buffer in \r
+  If Source is NULL, there is nothing to append, so return the current buffer in\r
   Destination.\r
 \r
   If Destination is NULL, then ASSERT().\r
-  If Destination's current length (including NULL terminator) is already more than \r
+  If Destination's current length (including NULL terminator) is already more than\r
   CurrentSize, then ASSERT().\r
 \r
-  @param[in,out] Destination    The String to append onto.\r
-  @param[in,out] CurrentSize    On call the number of bytes in Destination.  On \r
-                                return possibly the new size (still in bytes).  If NULL\r
-                                then allocate whatever is needed.\r
-  @param[in]     Source         The String to append from.\r
-  @param[in]     Count          Maximum number of characters to append.  If 0 then \r
-                                all are appended.\r
+  @param[in, out] Destination    The String to append onto.\r
+  @param[in, out] CurrentSize    On call, the number of bytes in Destination.  On\r
+                                 return, possibly the new size (still in bytes).  If NULL,\r
+                                 then allocate whatever is needed.\r
+  @param[in]      Source         The String to append from.\r
+  @param[in]      Count          The maximum number of characters to append.  If 0, then\r
+                                 all are appended.\r
 \r
-  @return                       The Destination after apending the Source.\r
+  @return                       The Destination after appending the Source.\r
 **/\r
-CHAR16* \r
+CHAR16*\r
 EFIAPI\r
 StrnCatGrow (\r
   IN OUT CHAR16           **Destination,\r
@@ -970,4 +1071,333 @@ StrnCatGrow (
   IN     UINTN            Count\r
   );\r
 \r
+/**\r
+  This is a find and replace function.  Upon successful return the NewString is a copy of\r
+  SourceString with each instance of FindTarget replaced with ReplaceWith.\r
+\r
+  If SourceString and NewString overlap the behavior is undefined.\r
+\r
+  If the string would grow bigger than NewSize it will halt and return error.\r
+\r
+  @param[in] SourceString              The string with source buffer.\r
+  @param[in, out] NewString            The string with resultant buffer.\r
+  @param[in] NewSize                   The size in bytes of NewString.\r
+  @param[in] FindTarget                The string to look for.\r
+  @param[in] ReplaceWith               The string to replace FindTarget with.\r
+  @param[in] SkipPreCarrot             If TRUE will skip a FindTarget that has a '^'\r
+                                       immediately before it.\r
+  @param[in] ParameterReplacing        If TRUE will add "" around items with spaces.\r
+\r
+  @retval EFI_INVALID_PARAMETER       SourceString was NULL.\r
+  @retval EFI_INVALID_PARAMETER       NewString was NULL.\r
+  @retval EFI_INVALID_PARAMETER       FindTarget was NULL.\r
+  @retval EFI_INVALID_PARAMETER       ReplaceWith was NULL.\r
+  @retval EFI_INVALID_PARAMETER       FindTarget had length < 1.\r
+  @retval EFI_INVALID_PARAMETER       SourceString had length < 1.\r
+  @retval EFI_BUFFER_TOO_SMALL        NewSize was less than the minimum size to hold\r
+                                      the new string (truncation occurred).\r
+  @retval EFI_SUCCESS                 The string was successfully copied with replacement.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellCopySearchAndReplace(\r
+  IN CHAR16 CONST                     *SourceString,\r
+  IN OUT CHAR16                       *NewString,\r
+  IN UINTN                            NewSize,\r
+  IN CONST CHAR16                     *FindTarget,\r
+  IN CONST CHAR16                     *ReplaceWith,\r
+  IN CONST BOOLEAN                    SkipPreCarrot,\r
+  IN CONST BOOLEAN                    ParameterReplacing\r
+  );\r
+\r
+/**\r
+  Check if a Unicode character is a hexadecimal character.\r
+\r
+  This internal function checks if a Unicode character is a\r
+  numeric character.  The valid hexadecimal characters are\r
+  L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r
+\r
+\r
+  @param  Char  The character to check against.\r
+\r
+  @retval TRUE  The Char is a hexadecmial character.\r
+  @retval FALSE The Char is not a hexadecmial character.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ShellIsHexaDecimalDigitCharacter (\r
+  IN      CHAR16                    Char\r
+  );\r
+\r
+/**\r
+  Check if a Unicode character is a decimal character.\r
+\r
+  This internal function checks if a Unicode character is a\r
+  decimal character.  The valid characters are\r
+  L'0' to L'9'.\r
+\r
+\r
+  @param  Char  The character to check against.\r
+\r
+  @retval TRUE  The Char is a hexadecmial character.\r
+  @retval FALSE The Char is not a hexadecmial character.\r
+\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ShellIsDecimalDigitCharacter (\r
+  IN      CHAR16                    Char\r
+  );\r
+\r
+///\r
+/// What type of answer is requested.\r
+///\r
+typedef enum {\r
+  ShellPromptResponseTypeYesNo,\r
+  ShellPromptResponseTypeYesNoCancel,\r
+  ShellPromptResponseTypeFreeform,\r
+  ShellPromptResponseTypeQuitContinue,\r
+  ShellPromptResponseTypeYesNoAllCancel,\r
+  ShellPromptResponseTypeEnterContinue,\r
+  ShellPromptResponseTypeAnyKeyContinue,\r
+  ShellPromptResponseTypeMax\r
+} SHELL_PROMPT_REQUEST_TYPE;\r
+\r
+///\r
+/// What answer was given.\r
+///\r
+typedef enum {\r
+  ShellPromptResponseYes,\r
+  ShellPromptResponseNo,\r
+  ShellPromptResponseCancel,\r
+  ShellPromptResponseQuit,\r
+  ShellPromptResponseContinue,\r
+  ShellPromptResponseAll,\r
+  ShellPromptResponseMax\r
+} SHELL_PROMPT_RESPONSE;\r
+\r
+/**\r
+  Prompt the user and return the resultant answer to the requestor.\r
+\r
+  This function will display the requested question on the shell prompt and then\r
+  wait for an appropriate answer to be input from the console.\r
+\r
+  If the SHELL_PROMPT_REQUEST_TYPE is SHELL_PROMPT_REQUEST_TYPE_YESNO, ShellPromptResponseTypeQuitContinue\r
+  or SHELL_PROMPT_REQUEST_TYPE_YESNOCANCEL then *Response is of type SHELL_PROMPT_RESPONSE.\r
+\r
+  If the SHELL_PROMPT_REQUEST_TYPE is ShellPromptResponseTypeFreeform then *Response is of type\r
+  CHAR16*.\r
+\r
+  In either case *Response must be callee freed if Response was not NULL;\r
+\r
+  @param Type                     What type of question is asked.  This is used to filter the input\r
+                                  to prevent invalid answers to question.\r
+  @param Prompt                   The pointer to a string prompt used to request input.\r
+  @param Response                 The pointer to Response, which will be populated upon return.\r
+\r
+  @retval EFI_SUCCESS             The operation was successful.\r
+  @retval EFI_UNSUPPORTED         The operation is not supported as requested.\r
+  @retval EFI_INVALID_PARAMETER   A parameter was invalid.\r
+  @return other                   The operation failed.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellPromptForResponse (\r
+  IN SHELL_PROMPT_REQUEST_TYPE   Type,\r
+  IN CHAR16         *Prompt OPTIONAL,\r
+  IN OUT VOID       **Response OPTIONAL\r
+  );\r
+\r
+/**\r
+  Prompt the user and return the resultant answer to the requestor.\r
+\r
+  This function is the same as ShellPromptForResponse, except that the prompt is\r
+  automatically pulled from HII.\r
+\r
+  @param[in] Type What type of question is asked.  This is used to filter the input\r
+                  to prevent invalid answers to question.\r
+  @param[in] HiiFormatStringId   The format string Id for getting from Hii.\r
+  @param[in] HiiFormatHandle     The format string Handle for getting from Hii.\r
+  @param[in, out] Response       The pointer to Response, which will be populated upon return.\r
+\r
+  @retval EFI_SUCCESS The operation was sucessful.\r
+  @return other       The operation failed.\r
+\r
+  @sa ShellPromptForResponse\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellPromptForResponseHii (\r
+  IN SHELL_PROMPT_REQUEST_TYPE         Type,\r
+  IN CONST EFI_STRING_ID  HiiFormatStringId,\r
+  IN CONST EFI_HANDLE     HiiFormatHandle,\r
+  IN OUT VOID             **Response\r
+  );\r
+\r
+/**\r
+  Function to determin if an entire string is a valid number.\r
+\r
+  If Hex it must be preceeded with a 0x, 0X, or has ForceHex set TRUE.\r
+\r
+  @param[in] String       The string to evaluate.\r
+  @param[in] ForceHex     TRUE - always assume hex.\r
+  @param[in] StopAtSpace  TRUE to halt upon finding a space, FALSE to keep going.\r
+\r
+  @retval TRUE        It is all numeric (dec/hex) characters.\r
+  @retval FALSE       There is a non-numeric character.\r
+**/\r
+BOOLEAN\r
+EFIAPI\r
+ShellIsHexOrDecimalNumber (\r
+  IN CONST CHAR16   *String,\r
+  IN CONST BOOLEAN  ForceHex,\r
+  IN CONST BOOLEAN  StopAtSpace\r
+  );\r
+\r
+/**\r
+  Function to verify and convert a string to its numerical 64 bit representation.\r
+\r
+  If Hex it must be preceeded with a 0x, 0X, or has ForceHex set TRUE.\r
+\r
+  @param[in] String       The string to evaluate.\r
+  @param[out] Value       Upon a successful return the value of the conversion.\r
+  @param[in] ForceHex     TRUE - always assume hex.\r
+  @param[in] StopAtSpace  TRUE to halt upon finding a space, FALSE to\r
+                          process the entire String.\r
+\r
+  @retval EFI_SUCCESS             The conversion was successful.\r
+  @retval EFI_INVALID_PARAMETER   String contained an invalid character.\r
+  @retval EFI_NOT_FOUND           String was a number, but Value was NULL.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellConvertStringToUint64(\r
+  IN CONST CHAR16   *String,\r
+     OUT   UINT64   *Value,\r
+  IN CONST BOOLEAN  ForceHex,\r
+  IN CONST BOOLEAN  StopAtSpace\r
+  );\r
+\r
+/**\r
+  Function to determine if a given filename exists.\r
+\r
+  @param[in] Name         Path to test.\r
+\r
+  @retval EFI_SUCCESS     The Path represents a file.\r
+  @retval EFI_NOT_FOUND   The Path does not represent a file.\r
+  @retval other           The path failed to open.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellFileExists(\r
+  IN CONST CHAR16 *Name\r
+  );\r
+\r
+/**\r
+  Function to read a single line from a SHELL_FILE_HANDLE. The \n is not included in the returned\r
+  buffer.  The returned buffer must be callee freed.\r
+\r
+  If the position upon start is 0, then the Ascii Boolean will be set.  This should be\r
+  maintained and not changed for all operations with the same file.\r
+\r
+  @param[in]       Handle        SHELL_FILE_HANDLE to read from.\r
+  @param[in, out]  Ascii         Boolean value for indicating whether the file is\r
+                                 Ascii (TRUE) or UCS2 (FALSE).\r
+\r
+  @return                        The line of text from the file.\r
+\r
+  @sa ShellFileHandleReadLine\r
+**/\r
+CHAR16*\r
+EFIAPI\r
+ShellFileHandleReturnLine(\r
+  IN SHELL_FILE_HANDLE            Handle,\r
+  IN OUT BOOLEAN                *Ascii\r
+  );\r
+\r
+/**\r
+  Function to read a single line (up to but not including the \n) from a SHELL_FILE_HANDLE.\r
+\r
+  If the position upon start is 0, then the Ascii Boolean will be set.  This should be\r
+  maintained and not changed for all operations with the same file.\r
+\r
+  @param[in]       Handle        SHELL_FILE_HANDLE to read from.\r
+  @param[in, out]  Buffer        The pointer to buffer to read into.\r
+  @param[in, out]  Size          The pointer to number of bytes in Buffer.\r
+  @param[in]       Truncate      If the buffer is large enough, this has no effect.\r
+                                 If the buffer is is too small and Truncate is TRUE,\r
+                                 the line will be truncated.\r
+                                 If the buffer is is too small and Truncate is FALSE,\r
+                                 then no read will occur.\r
+\r
+  @param[in, out]  Ascii         Boolean value for indicating whether the file is\r
+                                 Ascii (TRUE) or UCS2 (FALSE).\r
+\r
+  @retval EFI_SUCCESS           The operation was successful.  The line is stored in\r
+                                Buffer.\r
+  @retval EFI_END_OF_FILE       There are no more lines in the file.\r
+  @retval EFI_INVALID_PARAMETER Handle was NULL.\r
+  @retval EFI_INVALID_PARAMETER Size was NULL.\r
+  @retval EFI_BUFFER_TOO_SMALL  Size was not large enough to store the line.\r
+                                Size was updated to the minimum space required.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellFileHandleReadLine(\r
+  IN SHELL_FILE_HANDLE          Handle,\r
+  IN OUT CHAR16                 *Buffer,\r
+  IN OUT UINTN                  *Size,\r
+  IN BOOLEAN                    Truncate,\r
+  IN OUT BOOLEAN                *Ascii\r
+  );\r
+\r
+/**\r
+  Function to delete a file by name\r
+\r
+  @param[in]       FileName       Pointer to file name to delete.\r
+\r
+  @retval EFI_SUCCESS             the file was deleted sucessfully\r
+  @retval EFI_WARN_DELETE_FAILURE the handle was closed, but the file was not\r
+                                  deleted\r
+  @retval EFI_INVALID_PARAMETER   One of the parameters has an invalid value.\r
+  @retval EFI_NOT_FOUND           The specified file could not be found on the\r
+                                  device or the file system could not be found\r
+                                  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\r
+                                  medium is no longer supported.\r
+  @retval EFI_DEVICE_ERROR        The device reported an error.\r
+  @retval EFI_VOLUME_CORRUPTED    The file system structures are corrupted.\r
+  @retval EFI_WRITE_PROTECTED     The file or medium is write protected.\r
+  @retval EFI_ACCESS_DENIED       The file was opened read only.\r
+  @retval EFI_OUT_OF_RESOURCES    Not enough resources were available to open the\r
+                                  file.\r
+  @retval other                   The file failed to open\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellDeleteFileByName(\r
+  IN CONST CHAR16               *FileName\r
+  );\r
+\r
+/**\r
+  Function to print help file / man page content in the spec from the UEFI Shell protocol GetHelpText function.\r
+\r
+  @param[in] CommandToGetHelpOn  Pointer to a string containing the command name of help file to be printed.\r
+  @param[in] SectionToGetHelpOn  Pointer to the section specifier(s).\r
+  @param[in] PrintCommandText    If TRUE, prints the command followed by the help content, otherwise prints\r
+                                 the help content only.\r
+  @retval EFI_DEVICE_ERROR       The help data format was incorrect.\r
+  @retval EFI_NOT_FOUND          The help data could not be found.\r
+  @retval EFI_SUCCESS            The operation was successful.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ShellPrintHelp (\r
+  IN CONST CHAR16     *CommandToGetHelpOn,\r
+  IN CONST CHAR16     *SectionToGetHelpOn,\r
+  IN BOOLEAN          PrintCommandText\r
+  );\r
+\r
 #endif // __SHELL_LIB__\r