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