]>
Commit | Line | Data |
---|---|---|
a405b86d | 1 | /** @file\r |
2 | function definitions for internal to shell functions.\r | |
3 | \r | |
4 | Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r | |
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 | |
54 | typedef 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 | |
60 | typedef 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 | |
72 | typedef union {\r | |
73 | SHELL_BITS Bits;\r | |
74 | UINT16 AllBits;\r | |
75 | } SHELL_BIT_UNION;\r | |
76 | \r | |
77 | typedef 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 | |
84 | typedef 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 | |
91 | typedef 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 | |
a405b86d | 112 | } SHELL_INFO;\r |
113 | \r | |
114 | extern SHELL_INFO ShellInfoObject;\r | |
115 | \r | |
116 | /**\r | |
117 | Sets all the alias' that were registered with the ShellCommandLib library.\r | |
118 | \r | |
119 | @retval EFI_SUCCESS all init commands were run sucessfully.\r | |
120 | **/\r | |
121 | EFI_STATUS\r | |
122 | EFIAPI\r | |
123 | SetBuiltInAlias(\r | |
124 | VOID\r | |
125 | );\r | |
126 | \r | |
127 | /**\r | |
128 | This function will populate the 2 device path protocol parameters based on the\r | |
129 | global gImageHandle. the DevPath will point to the device path for the handle that has\r | |
130 | loaded image protocol installed on it. the FilePath will point to the device path\r | |
131 | for the file that was loaded.\r | |
132 | \r | |
133 | @param[in,out] DevPath on a sucessful return the device path to the loaded image\r | |
134 | @param[in,out] FilePath on a sucessful return the device path to the file\r | |
135 | \r | |
136 | @retval EFI_SUCCESS the 2 device paths were sucessfully returned.\r | |
137 | @return other a error from gBS->HandleProtocol\r | |
138 | \r | |
139 | @sa HandleProtocol\r | |
140 | **/\r | |
141 | EFI_STATUS\r | |
142 | EFIAPI\r | |
143 | GetDevicePathsForImageAndFile (\r | |
144 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DevPath,\r | |
145 | IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath\r | |
146 | );\r | |
147 | \r | |
148 | /**\r | |
149 | Process all Uefi Shell 2.0 command line options.\r | |
150 | \r | |
151 | see Uefi Shell 2.0 section 3.2 for full details.\r | |
152 | \r | |
153 | the command line should resemble the following:\r | |
154 | \r | |
155 | shell.efi [ShellOpt-options] [options] [file-name [file-name-options]]\r | |
156 | \r | |
157 | ShellOpt options Options which control the initialization behavior of the shell.\r | |
158 | These options are read from the EFI global variable "ShellOpt"\r | |
159 | and are processed before options or file-name.\r | |
160 | \r | |
161 | options Options which control the initialization behavior of the shell.\r | |
162 | \r | |
163 | file-name The name of a UEFI shell application or script to be executed\r | |
164 | after initialization is complete. By default, if file-name is\r | |
165 | specified, then -nostartup is implied. Scripts are not supported\r | |
166 | by level 0.\r | |
167 | \r | |
168 | file-nameoptions The command-line options that are passed to file-name when it\r | |
169 | is invoked.\r | |
170 | \r | |
171 | This will initialize the ShellInitSettings global variable.\r | |
172 | \r | |
173 | @retval EFI_SUCCESS the variable is initialized.\r | |
174 | **/\r | |
175 | EFI_STATUS\r | |
176 | EFIAPI\r | |
177 | ProcessCommandLine(\r | |
178 | VOID\r | |
179 | );\r | |
180 | \r | |
181 | /**\r | |
182 | Handles all interaction with the default startup script.\r | |
183 | \r | |
184 | this will check that the correct command line parameters were passed, handle the delay, and then start running the script.\r | |
185 | \r | |
186 | @param[in] ImagePath The path to the image for shell. The first place to look for the startup script.\r | |
187 | @param[in] FilePath The path to the file for shell. The second place to look for the startup script.\r | |
188 | \r | |
189 | @retval EFI_SUCCESS The variable is initialized.\r | |
190 | **/\r | |
191 | EFI_STATUS\r | |
192 | EFIAPI\r | |
193 | DoStartupScript(\r | |
194 | IN EFI_DEVICE_PATH_PROTOCOL *ImagePath,\r | |
195 | IN EFI_DEVICE_PATH_PROTOCOL *FilePath\r | |
196 | );\r | |
197 | \r | |
198 | /**\r | |
199 | Function to perform the shell prompt looping. It will do a single prompt,\r | |
200 | dispatch the result, and then return. It is expected that the caller will\r | |
201 | call this function in a loop many times.\r | |
202 | \r | |
203 | @retval EFI_SUCCESS\r | |
204 | @retval RETURN_ABORTED\r | |
205 | **/\r | |
206 | EFI_STATUS\r | |
207 | EFIAPI\r | |
208 | DoShellPrompt (\r | |
209 | VOID\r | |
210 | );\r | |
211 | \r | |
212 | /**\r | |
213 | Add a buffer to the Buffer To Free List for safely returning buffers to other\r | |
214 | places without risking letting them modify internal shell information.\r | |
215 | \r | |
216 | @param Buffer Something to pass to FreePool when the shell is exiting.\r | |
217 | **/\r | |
218 | VOID*\r | |
219 | EFIAPI\r | |
220 | AddBufferToFreeList(\r | |
221 | VOID *Buffer\r | |
222 | );\r | |
223 | \r | |
224 | /**\r | |
225 | Add a buffer to the Command History List.\r | |
226 | \r | |
227 | @param Buffer[in] The line buffer to add.\r | |
228 | **/\r | |
229 | VOID\r | |
230 | EFIAPI\r | |
231 | AddLineToCommandHistory(\r | |
232 | IN CONST CHAR16 *Buffer\r | |
233 | );\r | |
234 | \r | |
235 | /**\r | |
236 | Function will process and run a command line.\r | |
237 | \r | |
238 | This will determine if the command line represents an internal shell command or dispatch an external application.\r | |
239 | \r | |
240 | @param[in] CmdLine the command line to parse\r | |
241 | \r | |
242 | @retval EFI_SUCCESS the command was completed\r | |
243 | @retval EFI_ABORTED the command's operation was aborted\r | |
244 | **/\r | |
245 | EFI_STATUS\r | |
246 | EFIAPI\r | |
247 | RunCommand(\r | |
248 | IN CONST CHAR16 *CmdLine\r | |
249 | );\r | |
250 | \r | |
251 | /**\r | |
252 | Function determins if the CommandName COULD be a valid command. It does not determine whether\r | |
253 | this is a valid command. It only checks for invalid characters.\r | |
254 | \r | |
255 | @param[in] CommandName The name to check\r | |
256 | \r | |
257 | @retval TRUE CommandName could be a command name\r | |
258 | @retval FALSE CommandName could not be a valid command name\r | |
259 | **/\r | |
260 | BOOLEAN\r | |
261 | EFIAPI\r | |
262 | IsValidCommandName(\r | |
263 | IN CONST CHAR16 *CommandName\r | |
264 | );\r | |
265 | \r | |
266 | /**\r | |
267 | Function to process a NSH script file via SHELL_FILE_HANDLE.\r | |
268 | \r | |
269 | @param[in] Handle The handle to the already opened file.\r | |
270 | @param[in] Name The name of the script file.\r | |
271 | \r | |
272 | @retval EFI_SUCCESS the script completed sucessfully\r | |
273 | **/\r | |
274 | EFI_STATUS\r | |
275 | EFIAPI\r | |
276 | RunScriptFileHandle (\r | |
277 | IN SHELL_FILE_HANDLE Handle,\r | |
278 | IN CONST CHAR16 *Name\r | |
279 | );\r | |
280 | \r | |
281 | /**\r | |
282 | Function to process a NSH script file.\r | |
283 | \r | |
284 | @param[in] ScriptPath Pointer to the script file name (including file system path).\r | |
285 | \r | |
286 | @retval EFI_SUCCESS the script completed sucessfully\r | |
287 | **/\r | |
288 | EFI_STATUS\r | |
289 | EFIAPI\r | |
290 | RunScriptFile (\r | |
291 | IN CONST CHAR16 *ScriptPath\r | |
292 | );\r | |
293 | \r | |
294 | \r | |
295 | #endif //_SHELL_INTERNAL_HEADER_\r | |
296 | \r |