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