]> git.proxmox.com Git - mirror_edk2.git/blobdiff - ShellPkg/Application/Shell/Shell.h
MdeModulePkg-DxeCore: rename CoreGetMemoryMapPropertiesTable
[mirror_edk2.git] / ShellPkg / Application / Shell / Shell.h
index 3699fb233de76b79d242610bad5e4db9d6557b56..29b36b003a52ff1281c80ee1e8b25c574f689143 100644 (file)
@@ -1,7 +1,8 @@
 /** @file\r
   function definitions for internal to shell functions.\r
 \r
-  Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
+  (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
+  Copyright (c) 2009 - 2016, 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
@@ -19,6 +20,7 @@
 #include <ShellBase.h>\r
 \r
 #include <Guid/ShellVariableGuid.h>\r
+#include <Guid/ShellAliasGuid.h>\r
 \r
 #include <Protocol/LoadedImage.h>\r
 #include <Protocol/SimpleTextOut.h>\r
@@ -27,6 +29,7 @@
 #include <Protocol/EfiShellEnvironment2.h>\r
 #include <Protocol/EfiShellParameters.h>\r
 #include <Protocol/BlockIo.h>\r
+#include <Protocol/HiiPackageList.h>\r
 \r
 #include <Library/BaseLib.h>\r
 #include <Library/UefiApplicationEntryPoint.h>\r
 #include <Library/HiiLib.h>\r
 #include <Library/PrintLib.h>\r
 #include <Library/HandleParsingLib.h>\r
+#include <Library/FileHandleLib.h>\r
+#include <Library/UefiHiiServicesLib.h>\r
 \r
 #include "ShellParametersProtocol.h"\r
 #include "ShellProtocol.h"\r
 #include "ShellEnvVar.h"\r
 #include "ConsoleLogger.h"\r
 #include "ShellManParser.h"\r
+#include "ConsoleWrappers.h"\r
+#include "FileHandleWrappers.h"\r
+\r
+extern CONST CHAR16 mNoNestingEnvVarName[];\r
+extern CONST CHAR16 mNoNestingTrue[];\r
+extern CONST CHAR16 mNoNestingFalse[];\r
 \r
 typedef struct {\r
   LIST_ENTRY        Link;           ///< Standard linked list handler.\r
@@ -66,7 +77,9 @@ typedef struct {
   UINT32  NoMap:1;        ///< Was "-nomap"         found on command line.\r
   UINT32  NoVersion:1;    ///< Was "-noversion"     found on command line.\r
   UINT32  Delay:1;        ///< Was "-delay[:n]      found on command line\r
-  UINT32  Reserved:8;     ///< Extra bits\r
+  UINT32  Exit:1;         ///< Was "-_exit"         found on command line\r
+  UINT32  NoNest:1;       ///< Was "-nonest"        found on command line\r
+  UINT32  Reserved:7;     ///< Extra bits\r
 } SHELL_BITS;\r
 \r
 typedef union {\r
@@ -105,22 +118,59 @@ typedef struct {
   EFI_SHELL_PARAMETERS_PROTOCOL *OldShellParameters;  ///< old shell parameters to reinstall upon exiting.\r
   SHELL_PROTOCOL_HANDLE_LIST    OldShellList;         ///< List of other instances to reinstall when closing.\r
   SPLIT_LIST                    SplitList;            ///< List of Splits in FILO stack.\r
-  EFI_HANDLE                    CtrlCNotifyHandle1;   ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
-  EFI_HANDLE                    CtrlCNotifyHandle2;   ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
-  EFI_HANDLE                    CtrlCNotifyHandle3;   ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
-  EFI_HANDLE                    CtrlCNotifyHandle4;   ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
-  EFI_HANDLE                    CtrlSNotifyHandle1;   ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
-  EFI_HANDLE                    CtrlSNotifyHandle2;   ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
-  EFI_HANDLE                    CtrlSNotifyHandle3;   ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
-  EFI_HANDLE                    CtrlSNotifyHandle4;   ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
+  VOID                          *CtrlCNotifyHandle1;  ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
+  VOID                          *CtrlCNotifyHandle2;  ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
+  VOID                          *CtrlCNotifyHandle3;  ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
+  VOID                          *CtrlCNotifyHandle4;  ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
+  VOID                          *CtrlSNotifyHandle1;  ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
+  VOID                          *CtrlSNotifyHandle2;  ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
+  VOID                          *CtrlSNotifyHandle3;  ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
+  VOID                          *CtrlSNotifyHandle4;  ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
+  BOOLEAN                       HaltOutput;           ///< TRUE to start a CTRL-S halt.\r
 } SHELL_INFO;\r
 \r
+#pragma pack(1)\r
+///\r
+/// HII specific Vendor Device Path definition.\r
+///\r
+typedef struct {\r
+  VENDOR_DEVICE_PATH             VendorDevicePath;\r
+  EFI_DEVICE_PATH_PROTOCOL       End;\r
+} SHELL_MAN_HII_VENDOR_DEVICE_PATH;\r
+#pragma pack()\r
+\r
 extern SHELL_INFO ShellInfoObject;\r
 \r
+/**\r
+  Converts the command line to it's post-processed form.  this replaces variables and alias' per UEFI Shell spec.\r
+\r
+  @param[in,out] CmdLine        pointer to the command line to update\r
+\r
+  @retval EFI_SUCCESS           The operation was successful\r
+  @retval EFI_OUT_OF_RESOURCES  A memory allocation failed.\r
+  @return                       some other error occurred\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ProcessCommandLineToFinal(\r
+  IN OUT CHAR16 **CmdLine\r
+  );\r
+\r
+/**\r
+  Function to update the shell variable "lasterror".\r
+\r
+  @param[in] ErrorCode      the error code to put into lasterror\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+SetLastError(\r
+  IN CONST SHELL_STATUS   ErrorCode\r
+  );\r
+\r
 /**\r
   Sets all the alias' that were registered with the ShellCommandLib library.\r
 \r
-  @retval EFI_SUCCESS           all init commands were run sucessfully.\r
+  @retval EFI_SUCCESS           all init commands were run successfully.\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -134,10 +184,10 @@ SetBuiltInAlias(
   loaded image protocol installed on it.  the FilePath will point to the device path\r
   for the file that was loaded.\r
 \r
-  @param[in,out] DevPath       on a sucessful return the device path to the loaded image\r
-  @param[in,out] FilePath      on a sucessful return the device path to the file\r
+  @param[in, out] DevPath       on a successful return the device path to the loaded image\r
+  @param[in, out] FilePath      on a successful return the device path to the file\r
 \r
-  @retval EFI_SUCCESS           the 2 device paths were sucessfully returned.\r
+  @retval EFI_SUCCESS           the 2 device paths were successfully returned.\r
   @return other                 a error from gBS->HandleProtocol\r
 \r
   @sa HandleProtocol\r
@@ -253,7 +303,26 @@ RunCommand(
   );\r
 \r
 /**\r
-  Function determins if the CommandName COULD be a valid command.  It does not determine whether\r
+  Function will process and run a command line.\r
+\r
+  This will determine if the command line represents an internal shell \r
+  command or dispatch an external application.\r
+\r
+  @param[in] CmdLine      The command line to parse.\r
+  @param[out] CommandStatus   The status from the command line.\r
+\r
+  @retval EFI_SUCCESS     The command was completed.\r
+  @retval EFI_ABORTED     The command's operation was aborted.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+RunShellCommand(\r
+  IN CONST CHAR16   *CmdLine,\r
+  OUT EFI_STATUS    *CommandStatus\r
+  );\r
+\r
+/**\r
+  Function determines if the CommandName COULD be a valid command.  It does not determine whether\r
   this is a valid command.  It only checks for invalid characters.\r
 \r
   @param[in] CommandName    The name to check\r
@@ -273,7 +342,7 @@ IsValidCommandName(
   @param[in] Handle             The handle to the already opened file.\r
   @param[in] Name               The name of the script file.\r
 \r
-  @retval EFI_SUCCESS           the script completed sucessfully\r
+  @retval EFI_SUCCESS           the script completed successfully\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
@@ -286,15 +355,72 @@ RunScriptFileHandle (
   Function to process a NSH script file.\r
 \r
   @param[in] ScriptPath         Pointer to the script file name (including file system path).\r
+  @param[in] Handle             the handle of the script file already opened.\r
+  @param[in] CmdLine            the command line to run.\r
+  @param[in] ParamProtocol      the shell parameters protocol pointer\r
 \r
-  @retval EFI_SUCCESS           the script completed sucessfully\r
+  @retval EFI_SUCCESS           the script completed successfully\r
 **/\r
 EFI_STATUS\r
 EFIAPI\r
 RunScriptFile (\r
-  IN CONST CHAR16 *ScriptPath\r
+  IN CONST CHAR16                   *ScriptPath,\r
+  IN SHELL_FILE_HANDLE              Handle OPTIONAL,\r
+  IN CONST CHAR16                   *CmdLine,\r
+  IN EFI_SHELL_PARAMETERS_PROTOCOL  *ParamProtocol\r
   );\r
 \r
+/**\r
+  Return the pointer to the first occurrence of any character from a list of characters.\r
+\r
+  @param[in] String           the string to parse\r
+  @param[in] CharacterList    the list of character to look for\r
+  @param[in] EscapeCharacter  An escape character to skip\r
+\r
+  @return the location of the first character in the string\r
+  @retval CHAR_NULL no instance of any character in CharacterList was found in String\r
+**/\r
+CONST CHAR16*\r
+EFIAPI\r
+FindFirstCharacter(\r
+  IN CONST CHAR16 *String,\r
+  IN CONST CHAR16 *CharacterList,\r
+  IN CONST CHAR16 EscapeCharacter\r
+  );\r
+\r
+/**\r
+  Cleans off leading and trailing spaces and tabs.\r
+\r
+  @param[in] String pointer to the string to trim them off.\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+TrimSpaces(\r
+  IN CHAR16 **String\r
+  );\r
+\r
+/**\r
+  \r
+  Create a new buffer list and stores the old one to OldBufferList  \r
+\r
+  @param OldBufferList   The temporary list head used to store the nodes in BufferToFreeList.\r
+**/\r
+VOID\r
+SaveBufferList (\r
+  OUT LIST_ENTRY     *OldBufferList\r
+  );\r
+\r
+/**\r
+  Restore previous nodes into BufferToFreeList .\r
+\r
+  @param OldBufferList   The temporary list head used to store the nodes in BufferToFreeList.\r
+**/\r
+VOID\r
+RestoreBufferList (\r
+  IN OUT LIST_ENTRY     *OldBufferList\r
+  );\r
+\r
+\r
 \r
 #endif //_SHELL_INTERNAL_HEADER_\r
 \r