]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Include/Protocol/EfiShell.h
ShellPkg: Standardized HP Copyright Message String
[mirror_edk2.git] / ShellPkg / Include / Protocol / EfiShell.h
index 35a6e0a2f85d643a6e626ba0dd4e602131f19950..6c1d66a6696d4cbed2436d93b5007aa3fc9166fe 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
   EFI Shell protocol as defined in the UEFI Shell 2.0 specification including errata.\r
 \r
-  Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
+  Copyright (c) 2006 - 2014, 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
@@ -15,7 +16,7 @@
 #ifndef __EFI_SHELL_PROTOCOL__\r
 #define __EFI_SHELL_PROTOCOL__\r
 \r
-#include <Protocol/SimpleFileSystem.h>\r
+#include <ShellBase.h>\r
 #include <Guid/FileInfo.h>\r
 \r
 #define EFI_SHELL_PROTOCOL_GUID \\r
 // replaced EFI_LIST_ENTRY with LIST_ENTRY for simplicity.\r
 // they are identical outside of the name.\r
 typedef struct {\r
-  LIST_ENTRY      Link;       ///< Linked list members.\r
-  EFI_STATUS      Status;     ///< Status of opening the file.  Valid only if Handle != NULL.\r
-  CONST CHAR16    *FullName;  ///< Fully qualified filename.\r
-  CONST CHAR16    *FileName;  ///< name of this file.\r
-  EFI_FILE_HANDLE Handle;     ///< Handle for interacting with the opened file or NULL if closed.\r
-  EFI_FILE_INFO   *Info;      ///< Pointer to the FileInfo struct for this file or NULL.\r
+  LIST_ENTRY        Link;       ///< Linked list members.\r
+  EFI_STATUS        Status;     ///< Status of opening the file.  Valid only if Handle != NULL.\r
+  CONST CHAR16      *FullName;  ///< Fully qualified filename.\r
+  CONST CHAR16      *FileName;  ///< name of this file.\r
+  SHELL_FILE_HANDLE Handle;     ///< Handle for interacting with the opened file or NULL if closed.\r
+  EFI_FILE_INFO     *Info;      ///< Pointer to the FileInfo struct for this file or NULL.\r
 } EFI_SHELL_FILE_INFO;\r
 \r
 /**\r
@@ -61,7 +62,7 @@ BOOLEAN
 typedef\r
 EFI_STATUS\r
 (EFIAPI *EFI_SHELL_CLOSE_FILE)(\r
-  IN EFI_FILE_HANDLE FileHandle\r
+  IN SHELL_FILE_HANDLE FileHandle\r
   );\r
 \r
 /**\r
@@ -79,9 +80,9 @@ EFI_STATUS
   already exists and is non-volatile then EFI_INVALID_PARAMETER is returned.\r
 \r
   @param[in] FileName           Pointer to NULL-terminated file path.\r
-  @param[in] FileAttribs        The new file's attrbiutes.  the different attributes are\r
+  @param[in] FileAttribs        The new file's attrbiutes.  The different attributes are\r
                                 described in EFI_FILE_PROTOCOL.Open().\r
-  @param[out] FileHandle        On return, points to the created file handle or directory's handle\r
+  @param[out] 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
@@ -103,9 +104,9 @@ EFI_STATUS
 typedef\r
 EFI_STATUS\r
 (EFIAPI *EFI_SHELL_CREATE_FILE)(\r
-  IN CONST CHAR16 *FileName,\r
-  IN UINT64 FileAttribs,\r
-  OUT EFI_FILE_HANDLE *FileHandle\r
+  IN CONST CHAR16               *FileName,\r
+  IN UINT64                     FileAttribs,\r
+  OUT SHELL_FILE_HANDLE         *FileHandle\r
   );\r
 \r
 /**\r
@@ -123,7 +124,7 @@ EFI_STATUS
 typedef\r
 EFI_STATUS\r
 (EFIAPI *EFI_SHELL_DELETE_FILE)(\r
-  IN EFI_FILE_HANDLE FileHandle\r
+  IN SHELL_FILE_HANDLE FileHandle\r
   );\r
 \r
 /**\r
@@ -194,10 +195,10 @@ VOID
 typedef\r
 EFI_STATUS\r
 (EFIAPI *EFI_SHELL_EXECUTE) (\r
-  IN EFI_HANDLE *ParentImageHandle,\r
-  IN CHAR16 *CommandLine OPTIONAL,\r
-  IN CHAR16 **Environment OPTIONAL,\r
-  OUT EFI_STATUS *StatusCode OPTIONAL\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
@@ -224,8 +225,8 @@ EFI_STATUS
 typedef\r
 EFI_STATUS\r
 (EFIAPI *EFI_SHELL_FIND_FILES)(\r
-  IN CONST CHAR16 *FilePattern,\r
-  OUT EFI_SHELL_FILE_INFO **FileList\r
+  IN CONST CHAR16               *FilePattern,\r
+  OUT EFI_SHELL_FILE_INFO       **FileList\r
   );\r
 \r
 /**\r
@@ -243,8 +244,8 @@ EFI_STATUS
 typedef\r
 EFI_STATUS\r
 (EFIAPI *EFI_SHELL_FIND_FILES_IN_DIR)(\r
-IN EFI_FILE_HANDLE FileDirHandle,\r
-OUT EFI_SHELL_FILE_INFO **FileList\r
+IN SHELL_FILE_HANDLE            FileDirHandle,\r
+OUT EFI_SHELL_FILE_INFO         **FileList\r
 );\r
 \r
 /**\r
@@ -265,7 +266,7 @@ OUT EFI_SHELL_FILE_INFO **FileList
 typedef\r
 EFI_STATUS\r
 (EFIAPI *EFI_SHELL_FLUSH_FILE)(\r
-  IN EFI_FILE_HANDLE FileHandle\r
+  IN SHELL_FILE_HANDLE FileHandle\r
   );\r
 \r
 /**\r
@@ -341,11 +342,11 @@ typedef UINT32 EFI_SHELL_DEVICE_NAME_FLAGS;
 **/\r
 typedef\r
 EFI_STATUS\r
-(*EFI_SHELL_GET_DEVICE_NAME) (\r
-  IN EFI_HANDLE DeviceHandle,\r
-  IN EFI_SHELL_DEVICE_NAME_FLAGS Flags,\r
-  IN CHAR8 *Language,\r
-  OUT CHAR16 **BestDeviceName\r
+(EFIAPI *EFI_SHELL_GET_DEVICE_NAME) (\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
@@ -413,6 +414,35 @@ CONST CHAR16 *
   IN CONST CHAR16 *Name OPTIONAL\r
   );\r
 \r
+/**\r
+  Gets the environment variable and Attributes, or list of environment variables.  Can be \r
+  used instead of GetEnv().\r
+\r
+  This function returns the current value of the specified environment variable and\r
+  the Attributes. If no variable name was specified, then all of the known\r
+  variables will be returned.\r
+\r
+  @param[in] Name               A pointer to the environment variable name. If Name is NULL,\r
+                                then the function will return all of the defined shell \r
+                                environment variables. In the case where multiple environment\r
+                                variables are being returned, each variable will be terminated \r
+                                by a NULL, and the list will be terminated by a double NULL.\r
+  @param[out] Attributes        If not NULL, a pointer to the returned attributes bitmask for\r
+                                the environment variable. In the case where Name is NULL, and\r
+                                multiple environment variables are being returned, Attributes\r
+                                is undefined.\r
+\r
+  @retval NULL                  The environment variable doesn't exist.  \r
+  @return                       The environment variable's value. The returned pointer does not \r
+                                need to be freed by the caller.  \r
+**/\r
+typedef\r
+CONST CHAR16 *\r
+(EFIAPI *EFI_SHELL_GET_ENV_EX) (\r
+  IN  CONST CHAR16 *Name,\r
+  OUT       UINT32 *Attributes OPTIONAL\r
+  );\r
+\r
 /**\r
   Gets the file information from an open file handle.\r
 \r
@@ -427,7 +457,7 @@ CONST CHAR16 *
 typedef\r
 EFI_FILE_INFO *\r
 (EFIAPI *EFI_SHELL_GET_FILE_INFO)(\r
-  IN EFI_FILE_HANDLE FileHandle\r
+  IN SHELL_FILE_HANDLE FileHandle\r
   );\r
 \r
 /**\r
@@ -464,7 +494,7 @@ CHAR16 *
 typedef\r
 EFI_STATUS\r
 (EFIAPI *EFI_SHELL_GET_FILE_POSITION)(\r
-  IN EFI_FILE_HANDLE FileHandle,\r
+  IN SHELL_FILE_HANDLE FileHandle,\r
   OUT UINT64 *Position\r
   );\r
 \r
@@ -482,10 +512,58 @@ EFI_STATUS
 typedef\r
 EFI_STATUS\r
 (EFIAPI *EFI_SHELL_GET_FILE_SIZE)(\r
-  IN EFI_FILE_HANDLE FileHandle,\r
+  IN SHELL_FILE_HANDLE FileHandle,\r
   OUT UINT64 *Size\r
   );\r
 \r
+/**\r
+  Get the GUID value from a human readable name.\r
+\r
+  If GuidName is a known GUID name, then update Guid to have the correct value for\r
+  that GUID.\r
+\r
+  This function is only available when the major and minor versions in the\r
+  EfiShellProtocol are greater than or equal to 2 and 1, respectively.\r
+\r
+  @param[in]  GuidName   A pointer to the localized name for the GUID being queried.\r
+  @param[out] Guid       A pointer to the GUID structure to be filled in.\r
+\r
+  @retval EFI_SUCCESS             The operation was successful.\r
+  @retval EFI_INVALID_PARAMETER   Guid was NULL.\r
+  @retval EFI_INVALID_PARAMETER   GuidName was NULL.\r
+  @retval EFI_NOT_FOUND           GuidName is not a known GUID Name.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_GET_GUID_FROM_NAME)(\r
+  IN  CONST CHAR16   *GuidName,\r
+  OUT       EFI_GUID *Guid\r
+  );\r
+\r
+/**\r
+  Get the human readable name for a GUID from the value.\r
+\r
+  If Guid is assigned a name, then update *GuidName to point to the name. The callee\r
+  should not modify the value.\r
+\r
+  This function is only available when the major and minor versions in the\r
+  EfiShellProtocol are greater than or equal to 2 and 1, respectively.\r
+\r
+  @param[in]  Guid       A pointer to the GUID being queried.\r
+  @param[out] GuidName   A pointer to a pointer the localized to name for the GUID being requested\r
+\r
+  @retval EFI_SUCCESS             The operation was successful.\r
+  @retval EFI_INVALID_PARAMETER   Guid was NULL.\r
+  @retval EFI_INVALID_PARAMETER   GuidName was NULL.\r
+  @retval EFI_NOT_FOUND           Guid is not assigned a name.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_GET_GUID_NAME)(\r
+  IN  CONST EFI_GUID *Guid,\r
+  OUT CONST CHAR16   **GuidName\r
+  );\r
+\r
 /**\r
   Return help information about a specific command.\r
 \r
@@ -531,9 +609,9 @@ EFI_STATUS
   If there are multiple map names they will be semi-colon seperated in the\r
   NULL-terminated string.\r
 \r
-  @param[in,out] 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
+  @param[in, out] 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
   @retval !=NULL                Pointer to NULL-terminated mapping. The buffer\r
@@ -629,7 +707,7 @@ typedef
 EFI_STATUS\r
 (EFIAPI *EFI_SHELL_OPEN_FILE_BY_NAME) (\r
   IN CONST CHAR16 *FileName,\r
-  OUT EFI_FILE_HANDLE *FileHandle,\r
+  OUT SHELL_FILE_HANDLE *FileHandle,\r
   IN UINT64 OpenMode\r
   );\r
 \r
@@ -640,10 +718,10 @@ EFI_STATUS
   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[in] Path               A pointer to the path string.\r
-  @param[in] OpenMode           Specifies the mode used to open each file, EFI_FILE_MODE_READ or\r
-                                EFI_FILE_MODE_WRITE.\r
-  @param[in,out] FileList       Points to the start of a list of files opened.\r
+  @param[in] Path                A pointer to the path string.\r
+  @param[in] OpenMode            Specifies the mode used to open each file, EFI_FILE_MODE_READ or\r
+                                 EFI_FILE_MODE_WRITE.\r
+  @param[in, out] FileList       Points to the start of a list of files opened.\r
 \r
   @retval EFI_SUCCESS           Create the file list successfully.\r
   @return                       Can't create the file list.\r
@@ -676,7 +754,7 @@ typedef
 EFI_STATUS\r
 (EFIAPI *EFI_SHELL_OPEN_ROOT)(\r
   IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
-  OUT EFI_FILE_HANDLE *FileHandle\r
+  OUT SHELL_FILE_HANDLE *FileHandle\r
   );\r
 \r
 /**\r
@@ -698,7 +776,7 @@ typedef
 EFI_STATUS\r
 (EFIAPI *EFI_SHELL_OPEN_ROOT_BY_HANDLE)(\r
   IN EFI_HANDLE DeviceHandle,\r
-  OUT EFI_FILE_HANDLE *FileHandle\r
+  OUT SHELL_FILE_HANDLE *FileHandle\r
   );\r
 \r
 /**\r
@@ -710,9 +788,9 @@ EFI_STATUS
   current position is increased by the number of bytes returned.\r
   If FileHandle is a directory, then an error is returned.\r
 \r
-  @param[in] FileHandle         The opened file handle for read.\r
-  @param[in] ReadSize           On input, the size of Buffer, in bytes. On output, the amount of data read.\r
-  @param[in,out] Buffer         The buffer in which data is read.\r
+  @param[in] FileHandle          The opened file handle for read.\r
+  @param[in] ReadSize            On input, the size of Buffer, in bytes. On output, the amount of data read.\r
+  @param[in, out] Buffer         The buffer in which data is read.\r
 \r
   @retval EFI_SUCCESS           Data was read.\r
   @retval EFI_NO_MEDIA          The device has no media.\r
@@ -723,11 +801,35 @@ EFI_STATUS
 typedef\r
 EFI_STATUS\r
 (EFIAPI *EFI_SHELL_READ_FILE) (\r
-  IN EFI_FILE_HANDLE FileHandle,\r
+  IN SHELL_FILE_HANDLE FileHandle,\r
   IN OUT UINTN *ReadSize,\r
   IN OUT VOID *Buffer\r
   );\r
 \r
+/**\r
+  Register a GUID and a localized human readable name for it.\r
+\r
+  If Guid is not assigned a name, then assign GuidName to Guid.  This list of GUID\r
+  names must be used whenever a shell command outputs GUID information.\r
+\r
+  This function is only available when the major and minor versions in the\r
+  EfiShellProtocol are greater than or equal to 2 and 1, respectively.\r
+\r
+  @param[in] Guid       A pointer to the GUID being registered.\r
+  @param[in] GuidName   A pointer to the localized name for the GUID being registered.\r
+\r
+  @retval EFI_SUCCESS             The operation was successful.\r
+  @retval EFI_INVALID_PARAMETER   Guid was NULL.\r
+  @retval EFI_INVALID_PARAMETER   GuidName was NULL.\r
+  @retval EFI_ACCESS_DENIED       Guid already is assigned a name.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *EFI_SHELL_REGISTER_GUID_NAME)(\r
+  IN CONST EFI_GUID *Guid,\r
+  IN CONST CHAR16   *GuidName\r
+  );\r
+\r
 /**\r
   Deletes the duplicate file names files in the given file list.\r
 \r
@@ -873,7 +975,7 @@ EFI_STATUS
 typedef\r
 EFI_STATUS\r
 (EFIAPI *EFI_SHELL_SET_FILE_INFO)(\r
-  IN EFI_FILE_HANDLE FileHandle,\r
+  IN SHELL_FILE_HANDLE FileHandle,\r
   IN CONST EFI_FILE_INFO *FileInfo\r
   );\r
 \r
@@ -895,7 +997,7 @@ EFI_STATUS
 typedef\r
 EFI_STATUS\r
 (EFIAPI *EFI_SHELL_SET_FILE_POSITION)(\r
-  IN EFI_FILE_HANDLE FileHandle,\r
+  IN SHELL_FILE_HANDLE FileHandle,\r
   IN UINT64 Position\r
   );\r
 \r
@@ -929,9 +1031,9 @@ EFI_STATUS
 \r
   Direct writes to opened directories are not supported.\r
 \r
-  @param[in] FileHandle             The opened file handle for writing.\r
-  @param[in,out] BufferSize         On input, size of Buffer.\r
-  @param[in] Buffer                 The buffer in which data to write.\r
+  @param[in] FileHandle              The opened file handle for writing.\r
+  @param[in, out] BufferSize         On input, size of Buffer.\r
+  @param[in] Buffer                  The buffer in which data to write.\r
 \r
   @retval EFI_SUCCESS               Data was written.\r
   @retval EFI_UNSUPPORTED           Writes to open directory are not supported.\r
@@ -945,11 +1047,35 @@ EFI_STATUS
 typedef\r
 EFI_STATUS\r
 (EFIAPI *EFI_SHELL_WRITE_FILE)(\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
+// EFI_SHELL_PROTOCOL has been updated since UEFI Shell Spec 2.0\r
+// Usage of this protocol will require version checking before attempting\r
+// to use any new members.  There is no need to check the version for\r
+// members that existed in UEFI Shell Spec 2.0.\r
+//\r
+// Update below for any future UEFI Shell spec changes to this protocol.\r
+//\r
+// Check EFI_SHELL_PROTOCOL MajorVersion and MinorVersion:\r
+// if ((2 == gEfiShellProtocol->MajorVersion) &&\r
+//     (0 == gEfiShellProtocol->MinorVersion)) {\r
+//   //\r
+//   // Cannot call:\r
+//   // RegisterGuidName - UEFI Shell 2.1\r
+//   // GetGuidName      - UEFI Shell 2.1\r
+//   // GetGuidFromName  - UEFI Shell 2.1\r
+//   // GetEnvEx         - UEFI Shell 2.1\r
+//   //\r
+// } else {\r
+//   //\r
+//   // Can use all members\r
+//   //\r
+// }\r
+//\r
 typedef struct _EFI_SHELL_PROTOCOL {\r
   EFI_SHELL_EXECUTE                         Execute;\r
   EFI_SHELL_GET_ENV                         GetEnv;\r
@@ -993,13 +1119,18 @@ typedef struct _EFI_SHELL_PROTOCOL {
   EFI_EVENT                                 ExecutionBreak;\r
   UINT32                                    MajorVersion;\r
   UINT32                                    MinorVersion;\r
+  // Added for Shell 2.1\r
+  EFI_SHELL_REGISTER_GUID_NAME              RegisterGuidName;\r
+  EFI_SHELL_GET_GUID_NAME                   GetGuidName;\r
+  EFI_SHELL_GET_GUID_FROM_NAME              GetGuidFromName;\r
+  EFI_SHELL_GET_ENV_EX                      GetEnvEx;\r
 } EFI_SHELL_PROTOCOL;\r
 \r
 extern EFI_GUID gEfiShellProtocolGuid;\r
 \r
 enum ShellVersion {\r
   SHELL_MAJOR_VERSION = 2,\r
-  SHELL_MINOR_VERSION = 0\r
+  SHELL_MINOR_VERSION = 1\r
 };\r
 \r
 #endif\r