]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Application/Shell/Shell.h
fix for word wrapping.
[mirror_edk2.git] / ShellPkg / Application / Shell / Shell.h
CommitLineData
a405b86d 1/** @file\r
2 function definitions for internal to shell functions.\r
3\r
733f138d 4 Copyright (c) 2009 - 2011, Intel Corporation. All rights reserved.<BR>\r
a405b86d 5 This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
9\r
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
12\r
13**/\r
14\r
15#ifndef _SHELL_INTERNAL_HEADER_\r
16#define _SHELL_INTERNAL_HEADER_\r
17\r
18#include <Uefi.h>\r
19#include <ShellBase.h>\r
20\r
21#include <Guid/ShellVariableGuid.h>\r
22\r
23#include <Protocol/LoadedImage.h>\r
24#include <Protocol/SimpleTextOut.h>\r
25#include <Protocol/EfiShell.h>\r
26#include <Protocol/EfiShellInterface.h>\r
27#include <Protocol/EfiShellEnvironment2.h>\r
28#include <Protocol/EfiShellParameters.h>\r
29#include <Protocol/BlockIo.h>\r
30\r
31#include <Library/BaseLib.h>\r
32#include <Library/UefiApplicationEntryPoint.h>\r
33#include <Library/UefiLib.h>\r
34#include <Library/DebugLib.h>\r
35#include <Library/MemoryAllocationLib.h>\r
36#include <Library/ShellCommandLib.h>\r
37#include <Library/UefiRuntimeServicesTableLib.h>\r
38#include <Library/UefiBootServicesTableLib.h>\r
39#include <Library/DevicePathLib.h>\r
40#include <Library/BaseMemoryLib.h>\r
41#include <Library/PcdLib.h>\r
42#include <Library/ShellLib.h>\r
43#include <Library/SortLib.h>\r
44#include <Library/HiiLib.h>\r
45#include <Library/PrintLib.h>\r
46#include <Library/HandleParsingLib.h>\r
47\r
48#include "ShellParametersProtocol.h"\r
49#include "ShellProtocol.h"\r
50#include "ShellEnvVar.h"\r
51#include "ConsoleLogger.h"\r
52#include "ShellManParser.h"\r
a49f6a2f 53#include "ConsoleWrappers.h"\r
a405b86d 54\r
55typedef struct {\r
56 LIST_ENTRY Link; ///< Standard linked list handler.\r
57 SHELL_FILE_HANDLE *SplitStdOut; ///< ConsoleOut for use in the split.\r
58 SHELL_FILE_HANDLE *SplitStdIn; ///< ConsoleIn for use in the split.\r
59} SPLIT_LIST;\r
60\r
61typedef struct {\r
62 UINT32 Startup:1; ///< Was "-startup" found on command line.\r
63 UINT32 NoStartup:1; ///< Was "-nostartup" found on command line.\r
64 UINT32 NoConsoleOut:1; ///< Was "-noconsoleout" found on command line.\r
65 UINT32 NoConsoleIn:1; ///< Was "-noconsolein" found on command line.\r
66 UINT32 NoInterrupt:1; ///< Was "-nointerrupt" found on command line.\r
67 UINT32 NoMap:1; ///< Was "-nomap" found on command line.\r
68 UINT32 NoVersion:1; ///< Was "-noversion" found on command line.\r
69 UINT32 Delay:1; ///< Was "-delay[:n] found on command line\r
70 UINT32 Reserved:8; ///< Extra bits\r
71} SHELL_BITS;\r
72\r
73typedef union {\r
74 SHELL_BITS Bits;\r
75 UINT16 AllBits;\r
76} SHELL_BIT_UNION;\r
77\r
78typedef struct {\r
79 SHELL_BIT_UNION BitUnion;\r
80 UINTN Delay; ///< Seconds of delay default:5.\r
81 CHAR16 *FileName; ///< Filename to run upon successful initialization.\r
82 CHAR16 *FileOptions; ///< Options to pass to FileName.\r
83} SHELL_INIT_SETTINGS;\r
84\r
85typedef struct {\r
86 BUFFER_LIST CommandHistory;\r
87 UINTN VisibleRowNumber;\r
88 UINTN OriginalVisibleRowNumber;\r
89 BOOLEAN InsertMode; ///< Is the current typing mode insert (FALSE = overwrite).\r
90} SHELL_VIEWING_SETTINGS;\r
91\r
92typedef struct {\r
93 EFI_SHELL_PARAMETERS_PROTOCOL *NewShellParametersProtocol;\r
94 EFI_SHELL_PROTOCOL *NewEfiShellProtocol;\r
95 BOOLEAN PageBreakEnabled;\r
96 BOOLEAN RootShellInstance;\r
97 SHELL_INIT_SETTINGS ShellInitSettings;\r
98 BUFFER_LIST BufferToFreeList; ///< List of buffers that were returned to the user to free.\r
99 SHELL_VIEWING_SETTINGS ViewingSettings;\r
100 EFI_HII_HANDLE HiiHandle; ///< Handle from HiiLib.\r
101 UINTN LogScreenCount; ///< How many screens of log information to save.\r
102 EFI_EVENT UserBreakTimer; ///< Timer event for polling for CTRL-C.\r
103 EFI_DEVICE_PATH_PROTOCOL *ImageDevPath; ///< DevicePath for ourselves.\r
104 EFI_DEVICE_PATH_PROTOCOL *FileDevPath; ///< DevicePath for ourselves.\r
105 CONSOLE_LOGGER_PRIVATE_DATA *ConsoleInfo; ///< Pointer for ConsoleInformation.\r
106 EFI_SHELL_PARAMETERS_PROTOCOL *OldShellParameters; ///< old shell parameters to reinstall upon exiting.\r
107 SHELL_PROTOCOL_HANDLE_LIST OldShellList; ///< List of other instances to reinstall when closing.\r
108 SPLIT_LIST SplitList; ///< List of Splits in FILO stack.\r
8be0ba36 109 EFI_HANDLE CtrlCNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
110 EFI_HANDLE CtrlCNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
111 EFI_HANDLE CtrlCNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
112 EFI_HANDLE CtrlCNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
733f138d 113 EFI_HANDLE CtrlSNotifyHandle1; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
114 EFI_HANDLE CtrlSNotifyHandle2; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
115 EFI_HANDLE CtrlSNotifyHandle3; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
116 EFI_HANDLE CtrlSNotifyHandle4; ///< The NotifyHandle returned from SimpleTextInputEx.RegisterKeyNotify.\r
a49f6a2f 117 BOOLEAN HaltOutput; ///< TRUE to start a CTRL-S halt.\r
a405b86d 118} SHELL_INFO;\r
119\r
120extern SHELL_INFO ShellInfoObject;\r
121\r
122/**\r
123 Sets all the alias' that were registered with the ShellCommandLib library.\r
124\r
125 @retval EFI_SUCCESS all init commands were run sucessfully.\r
126**/\r
127EFI_STATUS\r
128EFIAPI\r
129SetBuiltInAlias(\r
130 VOID\r
131 );\r
132\r
133/**\r
134 This function will populate the 2 device path protocol parameters based on the\r
135 global gImageHandle. the DevPath will point to the device path for the handle that has\r
136 loaded image protocol installed on it. the FilePath will point to the device path\r
137 for the file that was loaded.\r
138\r
139 @param[in,out] DevPath on a sucessful return the device path to the loaded image\r
140 @param[in,out] FilePath on a sucessful return the device path to the file\r
141\r
142 @retval EFI_SUCCESS the 2 device paths were sucessfully returned.\r
143 @return other a error from gBS->HandleProtocol\r
144\r
145 @sa HandleProtocol\r
146**/\r
147EFI_STATUS\r
148EFIAPI\r
149GetDevicePathsForImageAndFile (\r
150 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevPath,\r
151 IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath\r
152 );\r
153\r
154/**\r
155 Process all Uefi Shell 2.0 command line options.\r
156\r
157 see Uefi Shell 2.0 section 3.2 for full details.\r
158\r
159 the command line should resemble the following:\r
160\r
161 shell.efi [ShellOpt-options] [options] [file-name [file-name-options]]\r
162\r
163 ShellOpt options Options which control the initialization behavior of the shell.\r
164 These options are read from the EFI global variable "ShellOpt"\r
165 and are processed before options or file-name.\r
166\r
167 options Options which control the initialization behavior of the shell.\r
168\r
169 file-name The name of a UEFI shell application or script to be executed\r
170 after initialization is complete. By default, if file-name is\r
171 specified, then -nostartup is implied. Scripts are not supported\r
172 by level 0.\r
173\r
174 file-nameoptions The command-line options that are passed to file-name when it\r
175 is invoked.\r
176\r
177 This will initialize the ShellInitSettings global variable.\r
178\r
179 @retval EFI_SUCCESS the variable is initialized.\r
180**/\r
181EFI_STATUS\r
182EFIAPI\r
183ProcessCommandLine(\r
184 VOID\r
185 );\r
186\r
187/**\r
188 Handles all interaction with the default startup script.\r
189\r
190 this will check that the correct command line parameters were passed, handle the delay, and then start running the script.\r
191\r
192 @param[in] ImagePath The path to the image for shell. The first place to look for the startup script.\r
193 @param[in] FilePath The path to the file for shell. The second place to look for the startup script.\r
194\r
195 @retval EFI_SUCCESS The variable is initialized.\r
196**/\r
197EFI_STATUS\r
198EFIAPI\r
199DoStartupScript(\r
200 IN EFI_DEVICE_PATH_PROTOCOL *ImagePath,\r
201 IN EFI_DEVICE_PATH_PROTOCOL *FilePath\r
202 );\r
203\r
204/**\r
205 Function to perform the shell prompt looping. It will do a single prompt,\r
206 dispatch the result, and then return. It is expected that the caller will\r
207 call this function in a loop many times.\r
208\r
209 @retval EFI_SUCCESS\r
210 @retval RETURN_ABORTED\r
211**/\r
212EFI_STATUS\r
213EFIAPI\r
214DoShellPrompt (\r
215 VOID\r
216 );\r
217\r
218/**\r
219 Add a buffer to the Buffer To Free List for safely returning buffers to other\r
220 places without risking letting them modify internal shell information.\r
221\r
222 @param Buffer Something to pass to FreePool when the shell is exiting.\r
223**/\r
224VOID*\r
225EFIAPI\r
226AddBufferToFreeList(\r
227 VOID *Buffer\r
228 );\r
229\r
230/**\r
231 Add a buffer to the Command History List.\r
232\r
233 @param Buffer[in] The line buffer to add.\r
234**/\r
235VOID\r
236EFIAPI\r
237AddLineToCommandHistory(\r
238 IN CONST CHAR16 *Buffer\r
239 );\r
240\r
241/**\r
242 Function will process and run a command line.\r
243\r
244 This will determine if the command line represents an internal shell command or dispatch an external application.\r
245\r
246 @param[in] CmdLine the command line to parse\r
247\r
248 @retval EFI_SUCCESS the command was completed\r
249 @retval EFI_ABORTED the command's operation was aborted\r
250**/\r
251EFI_STATUS\r
252EFIAPI\r
253RunCommand(\r
254 IN CONST CHAR16 *CmdLine\r
255 );\r
256\r
257/**\r
258 Function determins if the CommandName COULD be a valid command. It does not determine whether\r
259 this is a valid command. It only checks for invalid characters.\r
260\r
261 @param[in] CommandName The name to check\r
262\r
263 @retval TRUE CommandName could be a command name\r
264 @retval FALSE CommandName could not be a valid command name\r
265**/\r
266BOOLEAN\r
267EFIAPI\r
268IsValidCommandName(\r
269 IN CONST CHAR16 *CommandName\r
270 );\r
271\r
272/**\r
273 Function to process a NSH script file via SHELL_FILE_HANDLE.\r
274\r
275 @param[in] Handle The handle to the already opened file.\r
276 @param[in] Name The name of the script file.\r
277\r
278 @retval EFI_SUCCESS the script completed sucessfully\r
279**/\r
280EFI_STATUS\r
281EFIAPI\r
282RunScriptFileHandle (\r
283 IN SHELL_FILE_HANDLE Handle,\r
284 IN CONST CHAR16 *Name\r
285 );\r
286\r
287/**\r
288 Function to process a NSH script file.\r
289\r
290 @param[in] ScriptPath Pointer to the script file name (including file system path).\r
291\r
292 @retval EFI_SUCCESS the script completed sucessfully\r
293**/\r
294EFI_STATUS\r
295EFIAPI\r
296RunScriptFile (\r
297 IN CONST CHAR16 *ScriptPath\r
298 );\r
299\r
300\r
301#endif //_SHELL_INTERNAL_HEADER_\r
302\r