X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ShellPkg%2FApplication%2FShell%2FShell.h;h=ff0849446817a5ccb681fc48044e205d22c7a38f;hb=0c83ac57f5c236a70766673ada65fff6b78596d6;hp=3699fb233de76b79d242610bad5e4db9d6557b56;hpb=733f138d84a25a5993bc32ffe016c364daba686c;p=mirror_edk2.git diff --git a/ShellPkg/Application/Shell/Shell.h b/ShellPkg/Application/Shell/Shell.h index 3699fb233d..ff08494468 100644 --- a/ShellPkg/Application/Shell/Shell.h +++ b/ShellPkg/Application/Shell/Shell.h @@ -1,7 +1,8 @@ /** @file function definitions for internal to shell functions. - Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.
+ (C) Copyright 2014 Hewlett-Packard Development Company, L.P.
+ Copyright (c) 2009 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License which accompanies this distribution. The full text of the license may be found at @@ -16,17 +17,18 @@ #define _SHELL_INTERNAL_HEADER_ #include -#include #include +#include #include #include -#include +#include #include #include -#include +#include #include +#include #include #include @@ -44,17 +46,25 @@ #include #include #include +#include +#include #include "ShellParametersProtocol.h" #include "ShellProtocol.h" #include "ShellEnvVar.h" #include "ConsoleLogger.h" #include "ShellManParser.h" +#include "ConsoleWrappers.h" +#include "FileHandleWrappers.h" + +extern CONST CHAR16 mNoNestingEnvVarName[]; +extern CONST CHAR16 mNoNestingTrue[]; +extern CONST CHAR16 mNoNestingFalse[]; typedef struct { LIST_ENTRY Link; ///< Standard linked list handler. - SHELL_FILE_HANDLE *SplitStdOut; ///< ConsoleOut for use in the split. - SHELL_FILE_HANDLE *SplitStdIn; ///< ConsoleIn for use in the split. + SHELL_FILE_HANDLE SplitStdOut; ///< ConsoleOut for use in the split. + SHELL_FILE_HANDLE SplitStdIn; ///< ConsoleIn for use in the split. } SPLIT_LIST; typedef struct { @@ -66,7 +76,9 @@ typedef struct { UINT32 NoMap:1; ///< Was "-nomap" found on command line. UINT32 NoVersion:1; ///< Was "-noversion" found on command line. UINT32 Delay:1; ///< Was "-delay[:n] found on command line - UINT32 Reserved:8; ///< Extra bits + UINT32 Exit:1; ///< Was "-_exit" found on command line + UINT32 NoNest:1; ///< Was "-nonest" found on command line + UINT32 Reserved:7; ///< Extra bits } SHELL_BITS; typedef union { @@ -105,25 +117,59 @@ typedef struct { EFI_SHELL_PARAMETERS_PROTOCOL *OldShellParameters; ///< old shell parameters to reinstall upon exiting. SHELL_PROTOCOL_HANDLE_LIST OldShellList; ///< List of other instances to reinstall when closing. SPLIT_LIST SplitList; ///< List of Splits in FILO stack. - EFI_HANDLE CtrlCNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. - EFI_HANDLE CtrlCNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. - EFI_HANDLE CtrlCNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. - EFI_HANDLE CtrlCNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. - EFI_HANDLE CtrlSNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. - EFI_HANDLE CtrlSNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. - EFI_HANDLE CtrlSNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. - EFI_HANDLE CtrlSNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. + VOID *CtrlCNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. + VOID *CtrlCNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. + VOID *CtrlCNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. + VOID *CtrlCNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. + VOID *CtrlSNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. + VOID *CtrlSNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. + VOID *CtrlSNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. + VOID *CtrlSNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify. + BOOLEAN HaltOutput; ///< TRUE to start a CTRL-S halt. } SHELL_INFO; +#pragma pack(1) +/// +/// HII specific Vendor Device Path definition. +/// +typedef struct { + VENDOR_DEVICE_PATH VendorDevicePath; + EFI_DEVICE_PATH_PROTOCOL End; +} SHELL_MAN_HII_VENDOR_DEVICE_PATH; +#pragma pack() + extern SHELL_INFO ShellInfoObject; +/** + Converts the command line to it's post-processed form. this replaces variables and alias' per UEFI Shell spec. + + @param[in,out] CmdLine pointer to the command line to update + + @retval EFI_SUCCESS The operation was successful + @retval EFI_OUT_OF_RESOURCES A memory allocation failed. + @return some other error occurred +**/ +EFI_STATUS +ProcessCommandLineToFinal( + IN OUT CHAR16 **CmdLine + ); + +/** + Function to update the shell variable "lasterror". + + @param[in] ErrorCode the error code to put into lasterror +**/ +EFI_STATUS +SetLastError( + IN CONST SHELL_STATUS ErrorCode + ); + /** Sets all the alias' that were registered with the ShellCommandLib library. - @retval EFI_SUCCESS all init commands were run sucessfully. + @retval EFI_SUCCESS all init commands were run successfully. **/ EFI_STATUS -EFIAPI SetBuiltInAlias( VOID ); @@ -134,16 +180,15 @@ SetBuiltInAlias( loaded image protocol installed on it. the FilePath will point to the device path for the file that was loaded. - @param[in,out] DevPath on a sucessful return the device path to the loaded image - @param[in,out] FilePath on a sucessful return the device path to the file + @param[in, out] DevPath on a successful return the device path to the loaded image + @param[in, out] FilePath on a successful return the device path to the file - @retval EFI_SUCCESS the 2 device paths were sucessfully returned. + @retval EFI_SUCCESS the 2 device paths were successfully returned. @return other a error from gBS->HandleProtocol @sa HandleProtocol **/ EFI_STATUS -EFIAPI GetDevicePathsForImageAndFile ( IN OUT EFI_DEVICE_PATH_PROTOCOL **DevPath, IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath @@ -177,7 +222,6 @@ GetDevicePathsForImageAndFile ( @retval EFI_SUCCESS the variable is initialized. **/ EFI_STATUS -EFIAPI ProcessCommandLine( VOID ); @@ -193,7 +237,6 @@ ProcessCommandLine( @retval EFI_SUCCESS The variable is initialized. **/ EFI_STATUS -EFIAPI DoStartupScript( IN EFI_DEVICE_PATH_PROTOCOL *ImagePath, IN EFI_DEVICE_PATH_PROTOCOL *FilePath @@ -208,7 +251,6 @@ DoStartupScript( @retval RETURN_ABORTED **/ EFI_STATUS -EFIAPI DoShellPrompt ( VOID ); @@ -220,7 +262,6 @@ DoShellPrompt ( @param Buffer Something to pass to FreePool when the shell is exiting. **/ VOID* -EFIAPI AddBufferToFreeList( VOID *Buffer ); @@ -231,7 +272,6 @@ AddBufferToFreeList( @param Buffer[in] The line buffer to add. **/ VOID -EFIAPI AddLineToCommandHistory( IN CONST CHAR16 *Buffer ); @@ -247,13 +287,30 @@ AddLineToCommandHistory( @retval EFI_ABORTED the command's operation was aborted **/ EFI_STATUS -EFIAPI RunCommand( IN CONST CHAR16 *CmdLine ); /** - Function determins if the CommandName COULD be a valid command. It does not determine whether + Function will process and run a command line. + + This will determine if the command line represents an internal shell + command or dispatch an external application. + + @param[in] CmdLine The command line to parse. + @param[out] CommandStatus The status from the command line. + + @retval EFI_SUCCESS The command was completed. + @retval EFI_ABORTED The command's operation was aborted. +**/ +EFI_STATUS +RunShellCommand( + IN CONST CHAR16 *CmdLine, + OUT EFI_STATUS *CommandStatus + ); + +/** + Function determines if the CommandName COULD be a valid command. It does not determine whether this is a valid command. It only checks for invalid characters. @param[in] CommandName The name to check @@ -262,7 +319,6 @@ RunCommand( @retval FALSE CommandName could not be a valid command name **/ BOOLEAN -EFIAPI IsValidCommandName( IN CONST CHAR16 *CommandName ); @@ -273,10 +329,9 @@ IsValidCommandName( @param[in] Handle The handle to the already opened file. @param[in] Name The name of the script file. - @retval EFI_SUCCESS the script completed sucessfully + @retval EFI_SUCCESS the script completed successfully **/ EFI_STATUS -EFIAPI RunScriptFileHandle ( IN SHELL_FILE_HANDLE Handle, IN CONST CHAR16 *Name @@ -286,15 +341,69 @@ RunScriptFileHandle ( Function to process a NSH script file. @param[in] ScriptPath Pointer to the script file name (including file system path). + @param[in] Handle the handle of the script file already opened. + @param[in] CmdLine the command line to run. + @param[in] ParamProtocol the shell parameters protocol pointer - @retval EFI_SUCCESS the script completed sucessfully + @retval EFI_SUCCESS the script completed successfully **/ EFI_STATUS -EFIAPI RunScriptFile ( - IN CONST CHAR16 *ScriptPath + IN CONST CHAR16 *ScriptPath, + IN SHELL_FILE_HANDLE Handle OPTIONAL, + IN CONST CHAR16 *CmdLine, + IN EFI_SHELL_PARAMETERS_PROTOCOL *ParamProtocol ); +/** + Return the pointer to the first occurrence of any character from a list of characters. + + @param[in] String the string to parse + @param[in] CharacterList the list of character to look for + @param[in] EscapeCharacter An escape character to skip + + @return the location of the first character in the string + @retval CHAR_NULL no instance of any character in CharacterList was found in String +**/ +CONST CHAR16* +FindFirstCharacter( + IN CONST CHAR16 *String, + IN CONST CHAR16 *CharacterList, + IN CONST CHAR16 EscapeCharacter + ); + +/** + Cleans off leading and trailing spaces and tabs. + + @param[in] String pointer to the string to trim them off. +**/ +EFI_STATUS +TrimSpaces( + IN CHAR16 **String + ); + +/** + + Create a new buffer list and stores the old one to OldBufferList + + @param OldBufferList The temporary list head used to store the nodes in BufferToFreeList. +**/ +VOID +SaveBufferList ( + OUT LIST_ENTRY *OldBufferList + ); + +/** + Restore previous nodes into BufferToFreeList . + + @param OldBufferList The temporary list head used to store the nodes in BufferToFreeList. +**/ +VOID +RestoreBufferList ( + IN OUT LIST_ENTRY *OldBufferList + ); + + #endif //_SHELL_INTERNAL_HEADER_