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