--- /dev/null
+/** @file\r
+ Defines for EFI shell environment 2 ported to EDK II build environment.\r
+\r
+Copyright (c) 2005, 2009 Intel Corporation\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
+\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
+ \r
+#ifndef _SHELLENV2_H_\r
+#define _SHELLENV2_H_\r
+\r
+#include <Protocol\SimpleTextIn.h>\r
+#include <Protocol\SimpleTextOut.h>\r
+#include <Protocol\EfiShellInterface.h>\r
+\r
+#define DEFAULT_INIT_ROW 1\r
+#define DEFAULT_AUTO_LF FALSE\r
+\r
+\r
+/**\r
+ this function is a prototype for a function that dumps information on a protocol \r
+ to a given location. the location is dependant on the implementation. This is \r
+ used when programatically adding shell commands.\r
+\r
+ @param Handle the handle the protocol is on\r
+ @param Interface the interface to the protocol\r
+\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_DUMP_PROTOCOL_INFO) (\r
+ IN EFI_HANDLE Handle,\r
+ IN VOID *Interface\r
+ );\r
+\r
+/**\r
+ this function is a prototype foe each command internal to the EFI shell \r
+ implementation. the specific command depends on the implementation. This is \r
+ used when programatically adding shell commands.\r
+\r
+ @param ImageHandle The handle to the binary shell\r
+ @param SystemTable pointer to the system table.\r
+\r
+ @retval EFI_SUCCESS the command ran to completion\r
+ @return other an error ocurred. any error is possible \r
+ depending on the implementation of the shell \r
+ command.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_INTERNAL_COMMAND) (\r
+ IN EFI_HANDLE ImageHandle,\r
+ IN EFI_SYSTEM_TABLE *SystemTable\r
+ );\r
+\r
+/**\r
+ This function is a prototype for one that gets a help string for a given command. \r
+ This is used when programatically adding shell commands. Upon successful return \r
+ the memory allocated is up to the caller to free.\r
+\r
+ @param Str pointer to pointer to string to display for help.\r
+\r
+ @retval EFI_SUCCESS the help string is in the parameter Str.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLCMD_GET_LINE_HELP) (\r
+ IN OUT CHAR16 **Str\r
+ );\r
+\r
+/**\r
+* Structure returned from functions that open multiple files\r
+**/\r
+typedef struct {\r
+ UINT32 Signature; ///< SHELL_FILE_ARG_SIGNATURE\r
+ EFI_LIST_ENTRY Link; ///< linked list helper\r
+ EFI_STATUS Status; ///< File's status\r
+\r
+ EFI_FILE_HANDLE Parent; ///< what is the Parent file of this file\r
+ UINT64 OpenMode; ///< how was the file opened\r
+ CHAR16 *ParentName; ///< string representation of parent\r
+ EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; ///< DevicePath for Parent\r
+\r
+ CHAR16 *FullName; ///< path and file name for this file\r
+ CHAR16 *FileName; ///< file name for this file\r
+\r
+ EFI_FILE_HANDLE Handle; ///< handle to this file\r
+ EFI_FILE_INFO *Info; ///< pointer to file info for this file\r
+} SHELL_FILE_ARG;\r
+\r
+/// signature for SHELL_FILE_ARG\r
+#define SHELL_FILE_ARG_SIGNATURE SIGNATURE_32 ('g', 'r', 'a', 'f') \r
+\r
+/**\r
+* GUID for the shell environment2 and shell environment\r
+**/\r
+#define SHELL_ENVIRONMENT_PROTOCOL_GUID \\r
+ { \\r
+ 0x47c7b221, 0xc42a, 0x11d2, 0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b \\r
+ }\r
+\r
+/**\r
+* GUID for the shell environment2 extension (main GUID same as shell environment)\r
+**/\r
+#define EFI_SE_EXT_SIGNATURE_GUID \\r
+ { \\r
+ 0xd2c18636, 0x40e5, 0x4eb5, {0xa3, 0x1b, 0x36, 0x69, 0x5f, 0xd4, 0x2c, 0x87} \\r
+ }\r
+\r
+#define EFI_SHELL_MAJOR_VER 0x00000001 ///< Major version of the EFI_SHELL_ENVIRONMENT2\r
+#define EFI_SHELL_MINOR_VER 0x00000000 ///< Minor version of the EFI_SHELL_ENVIRONMENT2\r
+\r
+/**\r
+ execute a command line\r
+\r
+ this function will run the CommandLine. This includes loading any required images, \r
+ parsing any requires scripts, and it DebugOutput is TRUE printing errors \r
+ encountered directly to the screen.\r
+ \r
+ @param ParentImageHandle Handle of image executing this operation\r
+ @param CommandLine string command line to execute\r
+ @param DebugOutput TRUE indicates that errors should be printed directly.\r
+ FALSE supresses error messages.\r
+\r
+ @retval EFI_SUCCESS the command line executed and completed.\r
+ @retval EFI_ABORTED the operation did not complete due to abort.\r
+ @retval EFI_INVALID_PARAMETER A parameter did not have a valid value.\r
+ @retval EFI_OUT_OF_RESOURCES A required memory allocation failed.\r
+\r
+@sa HandleProtocol\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_EXECUTE) (\r
+ IN EFI_HANDLE *ParentImageHandle,\r
+ IN CHAR16 *CommandLine,\r
+ IN BOOLEAN DebugOutput\r
+ );\r
+\r
+/**\r
+ this function returns a shell environment variable value.\r
+\r
+ @param Name pointer to the string with the shell environment \r
+ variables name\r
+\r
+ @retval NULL the shell environment variable's value could not be found\r
+ @retval !NULL the value of the shell environment variable Name\r
+\r
+**/\r
+typedef \r
+CHAR16 * \r
+(EFIAPI *SHELLENV_GET_ENV) (\r
+ IN CHAR16 *Name\r
+ );\r
+\r
+/**\r
+ this function returns a shell environment map value.\r
+\r
+ @param Name pointer to the string with the shell environment \r
+ map name\r
+\r
+ @retval NULL the shell environment map's value could not be found\r
+ @retval !NULL the value of the shell environment map Name\r
+\r
+**/\r
+typedef \r
+CHAR16 * \r
+(EFIAPI *SHELLENV_GET_MAP) (\r
+ IN CHAR16 *Name\r
+ );\r
+\r
+/**\r
+ This function will add an internal command to the shell interface.\r
+\r
+ This will allocate all required memory, put the new command on the command\r
+ list in the correct location.\r
+\r
+ @param Handler the handler function to call when the command gets called\r
+ @param CmdStr The command name\r
+ @param GetLineHelp function to call of get help for this command\r
+\r
+ @retval EFI_SUCCESS the command is now part of the command list\r
+ @retval EFI_OUT_OF_RESOURCES a memory allocation failed.\r
+ @sa SHELLENV_INTERNAL_COMMAND\r
+ @sa SHELLCMD_GET_LINE_HELP\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_ADD_CMD) (\r
+ IN SHELLENV_INTERNAL_COMMAND Handler,\r
+ IN CHAR16 *Cmd,\r
+ IN SHELLCMD_GET_LINE_HELP GetLineHelp\r
+ );\r
+\r
+/**\r
+ Internal interface to add protocol handlers.\r
+\r
+ This function is for internal shell use only. This is how protocol handlers are added.\r
+ This will get the current protocol info and add the new info or update existing info\r
+ and then resave the info.\r
+\r
+ @param SaveId save this change as an EFI variable\r
+ @param Protocol the protocol's GUID\r
+ @param DumpToken The function pointer to dump token function or \r
+ NULL\r
+ @param DumpInfo The function pointer to dump infomation function \r
+ or NULL\r
+ @param IdString The english name of the protocol\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_ADD_PROT) (\r
+ IN EFI_GUID *Protocol,\r
+ IN SHELLENV_DUMP_PROTOCOL_INFO DumpToken OPTIONAL,\r
+ IN SHELLENV_DUMP_PROTOCOL_INFO DumpInfo OPTIONAL,\r
+ IN CHAR16 *IdString\r
+ );\r
+\r
+/**\r
+ this function finds a protocol handle by a GUID. \r
+\r
+ This function will check for already known protocols by GUID and if one is \r
+ found it will return the name of that protocol. if no name is found and \r
+ GenId is TRUE it will generate ths string.\r
+\r
+ @param Protocol the GUID of the protocol to look for.\r
+ @param GenId whether to generate a name string if its not found.\r
+\r
+ @return !NULL the Name of the protocol.\r
+ @retval NULL the Name was not found and GenId was not TRUE.\r
+**/\r
+typedef \r
+CHAR16*\r
+(EFIAPI *SHELLENV_GET_PROT) (\r
+ IN EFI_GUID *Protocol, \r
+ IN BOOLEAN GenId\r
+ );\r
+\r
+/**\r
+ this function returns the current directory on a given device\r
+\r
+ If DeviceName is specified, then return the current shell directory on that \r
+ device. If DeviceName is NULL, then return the current directory on the \r
+ current device. The caller us responsible to free the returned string when\r
+ no londer required.\r
+\r
+ @param DeviceName the name of the device to get the current \r
+ directory on or NULL for current device\r
+\r
+ @return The current directory on the current or specified device.\r
+\r
+**/\r
+typedef \r
+CHAR16*\r
+(EFIAPI *SHELLENV_CUR_DIR) (\r
+ IN CHAR16 *DeviceName OPTIONAL\r
+ );\r
+\r
+/**\r
+ this function will open a group of files that match the Arg path, including \r
+ support for wildcard characters ('?' and '*') in the Arg path. if there are \r
+ any wildcard characters in the path this function will find any and all files\r
+ that match the wildcards. the return is a double linked list based on the \r
+ EFI_LIST_ENTRY linked list structure. use this in conjunction with the \r
+ SHELL_FILE_ARG_SIGNATURE to get the SHELL_FILE_ARG structures that are returned.\r
+ The memory allocated by the callee for this list is freed by making a call to \r
+ SHELLENV_FREE_FILE_LIST.\r
+\r
+ @param Arg pointer Path to files to open\r
+ @param ListHead pointer to allocated and initialized list head \r
+ upon which to append all the opened file structures.\r
+\r
+ @retval EFI_SUCCESS 1 or more files was opened and a struct of each file's\r
+ information was appended to ListHead.\r
+ @retval EFI_OUT_OF_RESOURCES a memory allocation failed.\r
+ @retval EFI_NOT_FOUND no matching files could be found.\r
+ @sa SHELLENV_FREE_FILE_LIST\r
+**/typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_FILE_META_ARG) (\r
+ IN CHAR16 *Arg,\r
+ IN OUT EFI_LIST_ENTRY *ListHead\r
+ );\r
+\r
+/**\r
+ this frees all of the nodes under the ListHead, but not ListHead itself.\r
+\r
+ @param ListHead Pointer to list to free all nodes of.\r
+\r
+ @retval EFI_SUCCESS always returned.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_FREE_FILE_LIST) (\r
+ IN OUT EFI_LIST_ENTRY *ListHead\r
+ );\r
+\r
+/**\r
+ this function creates a new instance of the ShellInterface protocol for use on \r
+ the ImageHandle.\r
+\r
+ This function is for internal shell usage. this will allocate and then populate \r
+ EFI_SHELL_INTERFACE protocol. it is the caller's responsibility to free the \r
+ memory.\r
+\r
+ @param ImageHandle the handle which will use the new ShellInterface \r
+ protocol.\r
+\r
+ @return the newly allocated shell interface protocol.\r
+\r
+**/\r
+typedef \r
+EFI_SHELL_INTERFACE* \r
+(EFIAPI *SHELLENV_NEW_SHELL) (\r
+ IN EFI_HANDLE ImageHandle\r
+ );\r
+\r
+/**\r
+ this function determins whether a script file is currently being processed.\r
+\r
+ a script file (.nsh file) can contain a series of commands and this is useful to \r
+ know for some shell commands whether they are being run manually or as part of a \r
+ script.\r
+\r
+ @retval TRUE A script file is being processed\r
+ @return FALSE A script file is not being processed\r
+**/\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *SHELLENV_BATCH_IS_ACTIVE) (\r
+ IN VOID\r
+ );\r
+\r
+/**\r
+ This is an internal shell function to free any and all allocated resources. \r
+ This should be called just closing the shell.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_FREE_RESOURCES) (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ This function enables the page break mode.\r
+\r
+ This mode causes the output to pause after each complete screen to enable a \r
+ user to more easily read it. if AutoWrap is TRUE then rows with too many \r
+ characters will be chopped and divided into 2 rows. if FALSE then rows with \r
+ too many characters may not be fully visible to the user on the screen.\r
+\r
+ @param StartRow the row number to start this on.\r
+ @param AutoWrap whether to auto wrap rows that are \r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_ENABLE_PAGE_BREAK) (\r
+ IN INT32 StartRow,\r
+ IN BOOLEAN AutoWrap\r
+ );\r
+\r
+/**\r
+ This function disables the page break mode.\r
+\r
+ disabling this causes the output to print out exactly as coded with no breaks \r
+ for readability.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_DISABLE_PAGE_BREAK) (\r
+ IN VOID\r
+ );\r
+\r
+/**\r
+ Get the status of the page break output mode.\r
+\r
+ @retval FALSE page break output mode is not enabled\r
+ @retval TRUE page break output mode is enabled\r
+**/\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *SHELLENV_GET_PAGE_BREAK) (\r
+ IN VOID\r
+ );\r
+\r
+/**\r
+ this function sets the keys to filter for for the console in. the valid \r
+ values to set are:\r
+\r
+ #define EFI_OUTPUT_SCROLL 0x00000001\r
+ #define EFI_OUTPUT_PAUSE 0x00000002\r
+ #define EFI_EXECUTION_BREAK 0x00000004\r
+\r
+ @param KeyFilter The new key filter to use.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_SET_KEY_FILTER) (\r
+ IN UINT32 KeyFilter\r
+ );\r
+\r
+/**\r
+ this function gets the keys to filter for for the console in. the valid \r
+ values to get are:\r
+\r
+ #define EFI_OUTPUT_SCROLL 0x00000001\r
+ #define EFI_OUTPUT_PAUSE 0x00000002\r
+ #define EFI_EXECUTION_BREAK 0x00000004\r
+\r
+ @retval the current filter mask.\r
+**/\r
+typedef\r
+UINT32\r
+(EFIAPI *SHELLENV_GET_KEY_FILTER) (\r
+ IN VOID\r
+ );\r
+\r
+/**\r
+ this function determins if the shell application should break.\r
+\r
+ This is used to inform a shell application that a break condition has been \r
+ initiated. long loops should check this to prevent delays to the break.\r
+\r
+ @retval TRUE a break has been signaled. the application \r
+ should exit with EFI_ABORTED as soon as possible.\r
+ @retval FALSE continue as normal.\r
+**/\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *SHELLENV_GET_EXECUTION_BREAK) (\r
+ IN VOID\r
+ );\r
+\r
+/**\r
+ This is an internal-shell function used to increment the shell nesting level.\r
+\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_INCREMENT_SHELL_NESTING_LEVEL) (\r
+ IN VOID\r
+ );\r
+\r
+/**\r
+ This is an internal-shell function used to decrement the shell nesting level.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_DECREMENT_SHELL_NESTING_LEVEL) (\r
+ IN VOID\r
+ );\r
+\r
+/**\r
+ this function determins if the caller is running under the root shell.\r
+\r
+ @retval TRUE The caller is running under the root shell\r
+ @retval FALSE The caller is not running under the root shell\r
+\r
+**/\r
+typedef\r
+BOOLEAN\r
+(EFIAPI *SHELLENV_IS_ROOT_SHELL) (\r
+ IN VOID\r
+ );\r
+\r
+/**\r
+ Close the console proxy to restore the original console.\r
+\r
+ This is an internal shell function to handle shell cascading. it restores the \r
+ original set of console protocols.\r
+ \r
+ @param ConInHandle The handle of ConIn.\r
+ @param ConIn pointer to the location to return the pointer to \r
+ the original console input.\r
+ @param ConOutHandle The handle of ConOut\r
+ @param ConOut pointer to the location to return the pointer to \r
+ the original console output.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *SHELLENV_CLOSE_CONSOLE_PROXY) (\r
+ IN EFI_HANDLE ConInHandle,\r
+ IN OUT EFI_SIMPLE_TEXT_INPUT_PROTOCOL **ConIn,\r
+ IN EFI_HANDLE ConOutHandle,\r
+ IN OUT EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL **ConOut\r
+ );\r
+\r
+//\r
+// declarations of handle enumerator\r
+//\r
+/**\r
+ For ease of use the shell maps handle #'s to short numbers.\r
+ This is only done on request for various internal commands and the references \r
+ are immediately freed when the internal command completes.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *INIT_HANDLE_ENUMERATOR) (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ this is an internal shell function to enumerate the handle database.\r
+\r
+ this function gets the next handle in the handle database. if no handles are \r
+ found EFI_NOT_FOUND is returned. if the previous Handle was the last handle \r
+ it is set to NULL before returning.\r
+\r
+ this must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
+\r
+ @param Handle pointer to pointer to Handle. will be set\r
+ on a sucessful return.\r
+\r
+ @retval EFI_SUCCESS the next handle in the handle database is *Handle\r
+ @retval EFI_NOT_FOUND there is not another handle.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *NEXT_HANDLE) (\r
+ IN OUT EFI_HANDLE **Handle\r
+ );\r
+\r
+/**\r
+ this is an internal shell function to enumerate the handle database.\r
+\r
+ this function skips the next SkipNum handles in the handle database. If there \r
+ are not enough handles left to skip that many EFI_ACCESS_DENIED is returned and \r
+ no skip is performed.\r
+\r
+ this must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
+\r
+ @param SkipNum how many handles to skip\r
+\r
+ @retval EFI_SUCCESS the next handle in the handle database is *Handle\r
+ @retval EFI_ACCESS_DENIED there are not SkipNum handles left in the database\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SKIP_HANDLE) (\r
+ IN UINTN SkipNum\r
+ );\r
+\r
+/**\r
+ this is an internal shell function to enumerate the handle database.\r
+\r
+ this function resets the the handle database so that NEXT_HANDLE and SKIP_HANDLE \r
+ will start from EnumIndex on the next call. \r
+ \r
+ this must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
+\r
+ @param EnumIndex where to start.\r
+\r
+ @retval the number of handles either read out or skipped before this reset.\r
+**/\r
+typedef\r
+UINTN\r
+(EFIAPI *RESET_HANDLE_ENUMERATOR) (\r
+ IN UINTN EnumIndex\r
+ );\r
+\r
+/**\r
+ this is an internal shell function to enumerate the handle database.\r
+ \r
+ this must be called after INIT_HANDLE_ENUMERATOR.\r
+\r
+ this function releases all memory and resources associated with the handle database.\r
+ after this no other handle enumerator functions except INIT_HANDLE_ENUMERATOR will \r
+ function properly.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *CLOSE_HANDLE_ENUMERATOR) (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ this is an internal shell function to enumerate the handle database.\r
+\r
+ this function returns the number of handles in the handle database.\r
+ \r
+ this must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
+\r
+ @retval the number of handles in the handle database.\r
+**/\r
+typedef\r
+UINTN\r
+(EFIAPI *GET_NUM) (\r
+ VOID\r
+ );\r
+\r
+/**\r
+Handle Enumerator structure\r
+**/\r
+typedef struct {\r
+ INIT_HANDLE_ENUMERATOR Init; ///< pointer to INIT_HANDLE_ENUMERATOR function\r
+ NEXT_HANDLE Next; ///< pointer to NEXT_HANDLE function\r
+ SKIP_HANDLE Skip; ///< pointer to SKIP_HANDLE function\r
+ RESET_HANDLE_ENUMERATOR Reset; ///< pointer to RESET_HANDLE_ENUMERATOR function\r
+ CLOSE_HANDLE_ENUMERATOR Close; ///< pointer to CLOSE_HANDLE_ENUMERATOR function\r
+ GET_NUM GetNum; ///< pointer to GET_NUM function\r
+} HANDLE_ENUMERATOR;\r
+/**\r
+ signature for the PROTOCOL_INFO structure \r
+**/\r
+#define PROTOCOL_INFO_SIGNATURE SIGNATURE_32 ('s', 'p', 'i', 'n')\r
+/**\r
+ PROTOCOL_INFO structure for protocol enumerator functions.\r
+\r
+**/\r
+typedef struct {\r
+ UINTN Signature; ///< PROTOCOL_INFO_SIGNATURE \r
+ EFI_LIST_ENTRY Link; ///< standard lined list helper member\r
+ //\r
+ // parsing info for the protocol\r
+ //\r
+ EFI_GUID ProtocolId; ///< GUID for the protocol\r
+ CHAR16 *IdString; ///< Name of the protocol\r
+ SHELLENV_DUMP_PROTOCOL_INFO DumpToken; ///< pointer to DumpToken function for the protocol\r
+ SHELLENV_DUMP_PROTOCOL_INFO DumpInfo; ///< pointer to DumpInfo function for the protocol\r
+ //\r
+ // database info on which handles are supporting this protocol\r
+ //\r
+ UINTN NoHandles; ///< how many handles produce this protocol\r
+ EFI_HANDLE *Handles; ///< array of handles\r
+\r
+} PROTOCOL_INFO;\r
+\r
+//\r
+// declarations of protocol info enumerator\r
+//\r
+/**\r
+ this is an internal shell function to initialize the protocol enumerator.\r
+\r
+ this must be called before NEXT_PROTOCOL_INFO, SKIP_PROTOCOL_INFO, \r
+ RESET_PROTOCOL_INFO_ENUMERATOR, and CLOSE_PROTOCOL_INFO_ENUMERATOR are\r
+ called.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *INIT_PROTOCOL_INFO_ENUMERATOR) (\r
+ VOID\r
+ );\r
+\r
+/**\r
+ this function is an internal shell function for enumeration of protocols. \r
+\r
+ This functiol will return the next protocol in the list. If this is called \r
+ immediately after initialization it will return the first. If this is called\r
+ immediately after reset it will return the protocol first again.\r
+\r
+ This cannot be called after CLOSE_PROTOCOL_INFO_ENUMERATOR, but it must be \r
+ called after INIT_PROTOCOL_INFO_ENUMERATOR.\r
+\r
+ @param ProtocolInfo pointer to pointer to protocol information structure.\r
+\r
+ @retval EFI_SUCCESS the next protocol's information was sucessfully returned. \r
+ If there were no more protocols NULL was returned.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *NEXT_PROTOCOL_INFO) (\r
+ IN OUT PROTOCOL_INFO **ProtocolInfo\r
+ );\r
+\r
+/**\r
+ this function is an internal shell function for enumeration of protocols. \r
+\r
+ This cannot be called after CLOSE_PROTOCOL_INFO_ENUMERATOR, but it must be \r
+ called after INIT_PROTOCOL_INFO_ENUMERATOR.\r
+\r
+ this function does nothing and always returns EFI_SUCCESS.\r
+\r
+ @retval EFI_SUCCESS always returned (see note).\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SKIP_PROTOCOL_INFO) (\r
+ IN UINTN SkipNum\r
+ );\r
+\r
+/**\r
+ this function is an internal shell function for enumeration of protocols. \r
+\r
+ This cannot be called after CLOSE_PROTOCOL_INFO_ENUMERATOR, but it must be \r
+ called after INIT_PROTOCOL_INFO_ENUMERATOR.\r
+\r
+ this function resets the list of protocols such that the next one in the \r
+ list is the begining of the list.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *RESET_PROTOCOL_INFO_ENUMERATOR) (\r
+ VOID\r
+ );\r
+\r
+\r
+/**\r
+ this function is an internal shell function for enumeration of protocols. \r
+\r
+ This must be called after INIT_PROTOCOL_INFO_ENUMERATOR. After this call\r
+ no protocol enumerator calls except INIT_PROTOCOL_INFO_ENUMERATOR may be made.\r
+\r
+ this function frees any memory or resources associated with the protocol\r
+ enumerator.\r
+**/\r
+typedef\r
+VOID\r
+(EFIAPI *CLOSE_PROTOCOL_INFO_ENUMERATOR) (\r
+ VOID\r
+ );\r
+\r
+/**\r
+* protocol enumerator structure of function pointers.\r
+**/\r
+typedef struct {\r
+ INIT_PROTOCOL_INFO_ENUMERATOR Init; ///< pointer to INIT_PROTOCOL_INFO_ENUMERATOR function\r
+ NEXT_PROTOCOL_INFO Next; ///< pointer to NEXT_PROTOCOL_INFO function\r
+ SKIP_PROTOCOL_INFO Skip; ///< pointer to SKIP_PROTOCOL_INFO function\r
+ RESET_PROTOCOL_INFO_ENUMERATOR Reset; ///< pointer to RESET_PROTOCOL_INFO_ENUMERATOR function\r
+ CLOSE_PROTOCOL_INFO_ENUMERATOR Close; ///< pointer to CLOSE_PROTOCOL_INFO_ENUMERATOR function\r
+} PROTOCOL_INFO_ENUMERATOR;\r
+\r
+/**\r
+ this function is used to retrieve a user-friendly display name for a handle. \r
+\r
+ If UseComponentName is TRUE then the component name protocol for this device \r
+ or it's parent device (if required) will be used to obtain the name of the \r
+ device. If UseDevicePath is TRUE it will get the human readable device path\r
+ and return that. If both are TRUE it will try to use component name first\r
+ and device path if that fails. \r
+\r
+ It will use either ComponentName or ComponentName2 protocol, depending on \r
+ what is present.\r
+\r
+ This function will furthur verify whether the handle in question produced either\r
+ EFI_DRIVER_CONFIGRATION_PROTOCOL or EFI_DRIVER_CONFIGURATION2_PROTOCOL and also \r
+ whether the handle in question produced either EFI_DRIVER_DIAGNOSTICS_PROTOCOL or \r
+ EFI_DRIVER_DIAGNOSTICS2_PROTOCOL.\r
+ \r
+ Upon sucessful return the memory for *BestDeviceName is up to the caller to free.\r
+\r
+ @param DeviceHandle the device handle whose name is desired\r
+ @param UseComponentName whether to use the ComponentName protocol at all\r
+ @param UseDevicePath whether to use the DevicePath protocol at all\r
+ @param Language pointer to language string to use\r
+ @param BestDeviceName pointer to pointer to string allocated with the name\r
+ @param ConfigurationStatus pointer to status for opening a Configuration protocol\r
+ @param DiagnosticsStatus pointer to status for opening a Diagnostics protocol\r
+ @param Display Whether to Print this out to default Print location\r
+ @param Indent how many characters to indent the printing\r
+\r
+ @retval EFI_SUCCESS this function always returns EFI_SUCCESS\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *GET_DEVICE_NAME) (\r
+ EFI_HANDLE DeviceHandle,\r
+ BOOLEAN UseComponentName,\r
+ BOOLEAN UseDevicePath,\r
+ CHAR8 *Language,\r
+ CHAR16 **BestDeviceName,\r
+ EFI_STATUS *ConfigurationStatus,\r
+ EFI_STATUS *DiagnosticsStatus,\r
+ BOOLEAN Display,\r
+ UINTN Indent\r
+ );\r
+\r
+#define EFI_SHELL_COMPATIBLE_MODE_VER L"1.1.1" ///< string for lowest version this shell supports\r
+#define EFI_SHELL_ENHANCED_MODE_VER L"1.1.2" ///< string for highest version this shell supports\r
+\r
+/**\r
+ this function gets the shell mode as stored in the shell environment \r
+ "efishellmode". it will not fail.\r
+\r
+ @param Mode returns a string representing one of the \r
+ 2 supported modes of the shell.\r
+\r
+ @retval EFI_SUCCESS this function always returns success\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *GET_SHELL_MODE) (\r
+ OUT CHAR16 **Mode\r
+ );\r
+\r
+/**\r
+ Convert a file system style name to an file path\r
+\r
+ This function will convert a shell path name to a Device Path Protocol path.\r
+ This function will allocate any required memory for this operation and it \r
+ is the responsibility of the caller to free that memory when no longer required.\r
+\r
+ if anything prevents the complete conversion free any allocated memory and \r
+ return NULL.\r
+\r
+ @retval !NULL a pointer to the callee allocated Device Path\r
+ @retval NULL the operation could not be completed.\r
+**/\r
+typedef \r
+EFI_DEVICE_PATH_PROTOCOL* \r
+(EFIAPI *SHELLENV_NAME_TO_PATH) (\r
+ IN CHAR16 *Path\r
+ );\r
+\r
+/**\r
+ converts a device path into a file system map name.\r
+\r
+ if DevPath is NULL then ASSERT\r
+ This function looks through the shell environment map for a map whose device\r
+ path matches the DevPath parameter. If one is found the Name is returned via \r
+ Name parameter. If sucessful the caller must free the memory allocated for\r
+ Name.\r
+\r
+ this function will use the internal lock to prevent changes to the map during \r
+ the lookup operation.\r
+ \r
+ @param DevPath The device path to search for a name for\r
+ @param ConsistMapping what state to verify map flag VAR_ID_CONSIST\r
+ @param Name on sucessful return the name of that device path\r
+\r
+ @retval EFI_SUCCESS the DevPath was found and the name returned\r
+ in Name. \r
+ @retval EFI_OUT_OF_RESOURCES A required memory allocation failed.\r
+ @retval EFI_UNSUPPORTED the DevPath was not found in the map\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_GET_FS_NAME) (\r
+ IN EFI_DEVICE_PATH_PROTOCOL * DevPath,\r
+ IN BOOLEAN ConsistMapping,\r
+ OUT CHAR16 **Name\r
+ );\r
+\r
+/**\r
+ this function will open a group of files that match the Arg path, but will not \r
+ support the wildcard characters ('?' and '*') in the Arg path. if there are \r
+ any wildcard characters in the path this function will return \r
+ EFI_INVALID_PARAMETER. the return is a double linked list based on the \r
+ EFI_LIST_ENTRY linked list structure. use this in conjunction with the \r
+ SHELL_FILE_ARG_SIGNATURE to get the SHELL_FILE_ARG structures that are returned.\r
+ The memory allocated by the callee for this list is freed by making a call to \r
+ SHELLENV_FREE_FILE_LIST.\r
+\r
+ @param Arg pointer Path to files to open\r
+ @param ListHead pointer to allocated and initialized list head \r
+ upon which to append all the opened file structures.\r
+\r
+ @retval EFI_SUCCESS 1 or more files was opened and a struct of each file's\r
+ information was appended to ListHead.\r
+ @retval EFI_OUT_OF_RESOURCES a memory allocation failed.\r
+ @retval EFI_NOT_FOUND no matching files could be found.\r
+ @sa SHELLENV_FREE_FILE_LIST\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_FILE_META_ARG_NO_WILDCARD) (\r
+ IN CHAR16 *Arg,\r
+ IN OUT EFI_LIST_ENTRY *ListHead\r
+ );\r
+\r
+/**\r
+ this function removes duplicate file listings from lists.\r
+\r
+ this is a function for use with SHELLENV_FILE_META_ARG_NO_WILDCARD and \r
+ SHELLENV_FILE_META_ARG. this function will verify that there are no duplicate\r
+ files in the list of returned files. any file listed twice will have one of its\r
+ instances removed.\r
+\r
+ @param ListHead pointer to linked list head that was returned from \r
+ SHELLENV_FILE_META_ARG_NO_WILDCARD or\r
+ SHELLENV_FILE_META_ARG.\r
+\r
+ @retval EFI_SUCCESS this function always returns success.\r
+\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_DEL_DUP_FILE) (\r
+ IN EFI_LIST_ENTRY * ListHead\r
+ );\r
+\r
+/**\r
+ Converts a File System map name to a device path.\r
+\r
+ if DevPath is NULL then ASSERT()\r
+\r
+ This function looks through the shell environment map for a map whose Name \r
+ matches the Name parameter. If one is found the device path pointer is \r
+ updated to point to that file systems device path. the caller should not \r
+ free the memory from that device path.\r
+\r
+ this function will use the internal lock to prevent changes to the map during \r
+ the lookup operation.\r
+\r
+ @param Name pointer to NULL terminated UNICODE string of the \r
+ file system name\r
+ @param DevPath pointer to pointer to DevicePath. only valid on \r
+ OUT if sucessful\r
+\r
+ @retval EFI_SUCCESS the conversion was successful and the device \r
+ path was returned.\r
+ @retval EFI_NOT_FOUND the file system could not be found in the map.\r
+**/\r
+typedef\r
+EFI_STATUS\r
+(EFIAPI *SHELLENV_GET_FS_DEVICE_PATH) (\r
+ IN CHAR16 *Name,\r
+ OUT EFI_DEVICE_PATH_PROTOCOL **DevPath\r
+ );\r
+\r
+/// EFI_SHELL_ENVIRONMENT2 protocol structure\r
+/// contains pointers to functions\r
+typedef struct {\r
+ SHELLENV_EXECUTE Execute;\r
+ SHELLENV_GET_ENV GetEnv;\r
+ SHELLENV_GET_MAP GetMap;\r
+ SHELLENV_ADD_CMD AddCmd;\r
+ SHELLENV_ADD_PROT AddProt;\r
+ SHELLENV_GET_PROT GetProt;\r
+ SHELLENV_CUR_DIR CurDir;\r
+ SHELLENV_FILE_META_ARG FileMetaArg;\r
+ SHELLENV_FREE_FILE_LIST FreeFileList;\r
+\r
+ //\r
+ // The following services are only used by the shell itself\r
+ //\r
+ SHELLENV_NEW_SHELL NewShell;\r
+ SHELLENV_BATCH_IS_ACTIVE BatchIsActive;\r
+\r
+ SHELLENV_FREE_RESOURCES FreeResources;\r
+\r
+ //\r
+ // GUID to differentiate ShellEnvironment2 from ShellEnvironment\r
+ //\r
+ EFI_GUID SESGuid;\r
+ //\r
+ // Major Version grows if shell environment interface has been changes\r
+ //\r
+ UINT32 MajorVersion;\r
+ UINT32 MinorVersion;\r
+ SHELLENV_ENABLE_PAGE_BREAK EnablePageBreak;\r
+ SHELLENV_DISABLE_PAGE_BREAK DisablePageBreak;\r
+ SHELLENV_GET_PAGE_BREAK GetPageBreak;\r
+\r
+ SHELLENV_SET_KEY_FILTER SetKeyFilter;\r
+ SHELLENV_GET_KEY_FILTER GetKeyFilter;\r
+\r
+ SHELLENV_GET_EXECUTION_BREAK GetExecutionBreak;\r
+ SHELLENV_INCREMENT_SHELL_NESTING_LEVEL IncrementShellNestingLevel;\r
+ SHELLENV_DECREMENT_SHELL_NESTING_LEVEL DecrementShellNestingLevel;\r
+ SHELLENV_IS_ROOT_SHELL IsRootShell;\r
+\r
+ SHELLENV_CLOSE_CONSOLE_PROXY CloseConsoleProxy;\r
+ HANDLE_ENUMERATOR HandleEnumerator;\r
+ PROTOCOL_INFO_ENUMERATOR ProtocolInfoEnumerator;\r
+ GET_DEVICE_NAME GetDeviceName;\r
+ GET_SHELL_MODE GetShellMode;\r
+ SHELLENV_NAME_TO_PATH NameToPath;\r
+ SHELLENV_GET_FS_NAME GetFsName;\r
+ SHELLENV_FILE_META_ARG_NO_WILDCARD FileMetaArgNoWildCard;\r
+ SHELLENV_DEL_DUP_FILE DelDupFileArg;\r
+ SHELLENV_GET_FS_DEVICE_PATH GetFsDevicePath;\r
+} EFI_SHELL_ENVIRONMENT2;\r
+\r
+extern EFI_GUID gEfiShellEnvironment2Guid;\r
+extern EFI_GUID gEfiShellEnvironment2ExtGuid;\r
+#endif // _SHELLENV_H_\r