94b17fa1 |
1 | /** @file\r |
2 | Provides interface to shell functionality for shell commands and applications.\r |
3 | \r |
4 | Copyright (c) 2006 - 2009, Intel Corporation\r |
5 | All rights reserved. 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 | #if !defined(__SHELL_LIB__)\r |
16 | #define __SHELL_LIB__\r |
17 | \r |
18 | #include <Protocol/SimpleFileSystem.h>\r |
94b17fa1 |
19 | #include <Protocol/EfiShell.h>\r |
20 | \r |
21 | /**\r |
22 | This function will retrieve the information about the file for the handle \r |
23 | specified and store it in allocated pool memory.\r |
24 | \r |
69817bf8 |
25 | This function allocates a buffer to store the file's information. It is the \r |
26 | caller's responsibility to free the buffer\r |
94b17fa1 |
27 | \r |
28 | @param FileHandle The file handle of the file for which information is \r |
29 | being requested.\r |
30 | \r |
31 | @retval NULL information could not be retrieved.\r |
32 | \r |
33 | @return the information about the file\r |
34 | **/\r |
35 | EFI_FILE_INFO*\r |
36 | EFIAPI\r |
37 | ShellGetFileInfo (\r |
38 | IN EFI_FILE_HANDLE FileHandle\r |
39 | );\r |
40 | \r |
41 | /**\r |
42 | This function will set the information about the file for the opened handle \r |
43 | specified.\r |
44 | \r |
45 | @param FileHandle The file handle of the file for which information \r |
46 | is being set\r |
47 | \r |
48 | @param FileInfo The infotmation to set.\r |
49 | \r |
9eb53ac3 |
50 | @retval EFI_SUCCESS The information was set.\r |
94b17fa1 |
51 | @retval EFI_UNSUPPORTED The InformationType is not known.\r |
52 | @retval EFI_NO_MEDIA The device has no medium.\r |
53 | @retval EFI_DEVICE_ERROR The device reported an error.\r |
54 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r |
55 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r |
56 | @retval EFI_ACCESS_DENIED The file was opened read only.\r |
57 | @retval EFI_VOLUME_FULL The volume is full.\r |
58 | **/\r |
59 | EFI_STATUS\r |
60 | EFIAPI\r |
61 | ShellSetFileInfo (\r |
62 | IN EFI_FILE_HANDLE FileHandle,\r |
63 | IN EFI_FILE_INFO *FileInfo\r |
64 | );\r |
65 | \r |
66 | /**\r |
67 | This function will open a file or directory referenced by DevicePath.\r |
68 | \r |
69 | This function opens a file with the open mode according to the file path. The \r |
70 | Attributes is valid only for EFI_FILE_MODE_CREATE.\r |
71 | \r |
72 | @param FilePath on input the device path to the file. On output \r |
73 | the remaining device path.\r |
74 | @param DeviceHandle pointer to the system device handle.\r |
75 | @param FileHandle pointer to the file handle.\r |
76 | @param OpenMode the mode to open the file with.\r |
77 | @param Attributes the file's file attributes.\r |
78 | \r |
79 | @retval EFI_SUCCESS The information was set.\r |
80 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r |
81 | @retval EFI_UNSUPPORTED Could not open the file path. \r |
82 | @retval EFI_NOT_FOUND The specified file could not be found on the \r |
83 | device or the file system could not be found on \r |
84 | the device.\r |
85 | @retval EFI_NO_MEDIA The device has no medium.\r |
86 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the \r |
87 | medium is no longer supported.\r |
88 | @retval EFI_DEVICE_ERROR The device reported an error.\r |
89 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r |
90 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r |
91 | @retval EFI_ACCESS_DENIED The file was opened read only.\r |
92 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the \r |
93 | file.\r |
94 | @retval EFI_VOLUME_FULL The volume is full.\r |
95 | **/\r |
96 | EFI_STATUS\r |
97 | EFIAPI\r |
98 | ShellOpenFileByDevicePath(\r |
99 | IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,\r |
100 | OUT EFI_HANDLE *DeviceHandle,\r |
101 | OUT EFI_FILE_HANDLE *FileHandle,\r |
102 | IN UINT64 OpenMode,\r |
103 | IN UINT64 Attributes\r |
104 | );\r |
105 | \r |
106 | /**\r |
107 | This function will open a file or directory referenced by filename.\r |
108 | \r |
69817bf8 |
109 | If return is EFI_SUCCESS, the Filehandle is the opened file's handle; \r |
94b17fa1 |
110 | otherwise, the Filehandle is NULL. The Attributes is valid only for \r |
111 | EFI_FILE_MODE_CREATE.\r |
112 | \r |
113 | @param FileName pointer to file name\r |
114 | @param FileHandle pointer to the file handle.\r |
115 | @param OpenMode the mode to open the file with.\r |
116 | @param Attributes the file's file attributes.\r |
117 | \r |
9eb53ac3 |
118 | @retval EFI_SUCCESS The information was set.\r |
94b17fa1 |
119 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r |
9eb53ac3 |
120 | @retval EFI_UNSUPPORTED Could not open the file path. \r |
94b17fa1 |
121 | @retval EFI_NOT_FOUND The specified file could not be found on the \r |
122 | device or the file system could not be found \r |
123 | on the device.\r |
9eb53ac3 |
124 | @retval EFI_NO_MEDIA The device has no medium.\r |
125 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the \r |
94b17fa1 |
126 | medium is no longer supported.\r |
9eb53ac3 |
127 | @retval EFI_DEVICE_ERROR The device reported an error.\r |
94b17fa1 |
128 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r |
9eb53ac3 |
129 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r |
130 | @retval EFI_ACCESS_DENIED The file was opened read only.\r |
94b17fa1 |
131 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the \r |
132 | file.\r |
9eb53ac3 |
133 | @retval EFI_VOLUME_FULL The volume is full.\r |
94b17fa1 |
134 | **/\r |
135 | EFI_STATUS\r |
136 | EFIAPI\r |
137 | ShellOpenFileByName(\r |
b82bfcc1 |
138 | IN CONST CHAR16 *FilePath,\r |
94b17fa1 |
139 | OUT EFI_FILE_HANDLE *FileHandle,\r |
140 | IN UINT64 OpenMode,\r |
141 | IN UINT64 Attributes\r |
142 | );\r |
143 | \r |
144 | /**\r |
145 | This function create a directory\r |
146 | \r |
147 | If return is EFI_SUCCESS, the Filehandle is the opened directory's handle; \r |
148 | otherwise, the Filehandle is NULL. If the directory already existed, this \r |
149 | function opens the existing directory.\r |
150 | \r |
151 | @param DirectoryName pointer to Directory name\r |
152 | @param FileHandle pointer to the file handle.\r |
153 | \r |
154 | @retval EFI_SUCCESS The information was set.\r |
155 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r |
156 | @retval EFI_UNSUPPORTED Could not open the file path. \r |
157 | @retval EFI_NOT_FOUND The specified file could not be found on the \r |
158 | device or the file system could not be found \r |
159 | on the device.\r |
9eb53ac3 |
160 | @retval EFI_NO_MEDIA The device has no medium.\r |
161 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the \r |
94b17fa1 |
162 | medium is no longer supported.\r |
9eb53ac3 |
163 | @retval EFI_DEVICE_ERROR The device reported an error.\r |
94b17fa1 |
164 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r |
9eb53ac3 |
165 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r |
166 | @retval EFI_ACCESS_DENIED The file was opened read only.\r |
94b17fa1 |
167 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the \r |
168 | file.\r |
9eb53ac3 |
169 | @retval EFI_VOLUME_FULL The volume is full.\r |
94b17fa1 |
170 | **/\r |
171 | EFI_STATUS\r |
172 | EFIAPI\r |
173 | ShellCreateDirectory(\r |
b82bfcc1 |
174 | IN CONST CHAR16 *DirectoryName,\r |
94b17fa1 |
175 | OUT EFI_FILE_HANDLE *FileHandle\r |
176 | );\r |
177 | \r |
178 | /**\r |
179 | This function reads information from an opened file.\r |
180 | \r |
181 | If FileHandle is not a directory, the function reads the requested number of \r |
69817bf8 |
182 | bytes from the file at the file's current position and returns them in Buffer. \r |
94b17fa1 |
183 | If the read goes beyond the end of the file, the read length is truncated to the\r |
69817bf8 |
184 | end of the file. The file's current position is increased by the number of bytes \r |
94b17fa1 |
185 | returned. If FileHandle is a directory, the function reads the directory entry \r |
69817bf8 |
186 | at the file's current position and returns the entry in Buffer. If the Buffer \r |
94b17fa1 |
187 | is not large enough to hold the current directory entry, then \r |
188 | EFI_BUFFER_TOO_SMALL is returned and the current file position is not updated. \r |
189 | BufferSize is set to be the size of the buffer needed to read the entry. On \r |
190 | success, the current position is updated to the next directory entry. If there \r |
191 | are no more directory entries, the read returns a zero-length buffer. \r |
192 | EFI_FILE_INFO is the structure returned as the directory entry.\r |
193 | \r |
194 | @param FileHandle the opened file handle\r |
195 | \r |
196 | @param ReadSize on input the size of buffer in bytes. on return \r |
197 | the number of bytes written.\r |
198 | \r |
199 | @param Buffer the buffer to put read data into.\r |
200 | \r |
9eb53ac3 |
201 | @retval EFI_SUCCESS Data was read.\r |
202 | @retval EFI_NO_MEDIA The device has no media.\r |
203 | @retval EFI_DEVICE_ERROR The device reported an error.\r |
204 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r |
205 | @retval EFI_BUFFER_TO_SMALL Buffer is too small. ReadSize contains required \r |
94b17fa1 |
206 | size.\r |
207 | \r |
208 | **/\r |
209 | EFI_STATUS\r |
210 | EFIAPI\r |
211 | ShellReadFile(\r |
212 | IN EFI_FILE_HANDLE FileHandle,\r |
213 | IN OUT UINTN *ReadSize,\r |
214 | OUT VOID *Buffer\r |
215 | );\r |
216 | \r |
217 | /**\r |
218 | Write data to a file.\r |
219 | \r |
220 | This function writes the specified number of bytes to the file at the current \r |
221 | file position. The current file position is advanced the actual number of bytes \r |
222 | written, which is returned in BufferSize. Partial writes only occur when there \r |
69817bf8 |
223 | has been a data error during the write attempt (such as "volume space full"). \r |
94b17fa1 |
224 | The file is automatically grown to hold the data if required. Direct writes to \r |
225 | opened directories are not supported.\r |
226 | \r |
227 | @param FileHandle The opened file for writing\r |
228 | \r |
229 | @param BufferSize on input the number of bytes in Buffer. On output\r |
230 | the number of bytes written.\r |
231 | \r |
232 | @param Buffer the buffer containing data to write is stored.\r |
233 | \r |
234 | @retval EFI_SUCCESS Data was written.\r |
9eb53ac3 |
235 | @retval EFI_UNSUPPORTED Writes to an open directory are not supported.\r |
94b17fa1 |
236 | @retval EFI_NO_MEDIA The device has no media.\r |
9eb53ac3 |
237 | @retval EFI_DEVICE_ERROR The device reported an error.\r |
94b17fa1 |
238 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r |
239 | @retval EFI_WRITE_PROTECTED The device is write-protected.\r |
9eb53ac3 |
240 | @retval EFI_ACCESS_DENIED The file was open for read only.\r |
241 | @retval EFI_VOLUME_FULL The volume is full.\r |
94b17fa1 |
242 | **/\r |
243 | EFI_STATUS\r |
244 | EFIAPI\r |
245 | ShellWriteFile(\r |
246 | IN EFI_FILE_HANDLE FileHandle,\r |
247 | IN OUT UINTN *BufferSize,\r |
08d7f8e8 |
248 | IN VOID *Buffer\r |
94b17fa1 |
249 | );\r |
250 | \r |
251 | /** \r |
252 | Close an open file handle.\r |
253 | \r |
69817bf8 |
254 | This function closes a specified file handle. All "dirty" cached file data is \r |
94b17fa1 |
255 | flushed to the device, and the file is closed. In all cases the handle is \r |
256 | closed.\r |
257 | \r |
258 | @param FileHandle the file handle to close.\r |
259 | \r |
260 | @retval EFI_SUCCESS the file handle was closed sucessfully.\r |
261 | @retval INVALID_PARAMETER One of the parameters has an invalid value.\r |
262 | **/\r |
263 | EFI_STATUS\r |
264 | EFIAPI\r |
265 | ShellCloseFile (\r |
266 | IN EFI_FILE_HANDLE *FileHandle\r |
267 | );\r |
268 | \r |
269 | /**\r |
270 | Delete a file and close the handle\r |
271 | \r |
272 | This function closes and deletes a file. In all cases the file handle is closed.\r |
273 | If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is \r |
274 | returned, but the handle is still closed.\r |
275 | \r |
276 | @param FileHandle the file handle to delete\r |
277 | \r |
278 | @retval EFI_SUCCESS the file was closed sucessfully\r |
279 | @retval EFI_WARN_DELETE_FAILURE the handle was closed, but the file was not \r |
280 | deleted\r |
281 | @retval INVALID_PARAMETER One of the parameters has an invalid value.\r |
282 | **/\r |
283 | EFI_STATUS\r |
284 | EFIAPI\r |
285 | ShellDeleteFile (\r |
286 | IN EFI_FILE_HANDLE *FileHandle\r |
287 | );\r |
288 | \r |
289 | /**\r |
290 | Set the current position in a file.\r |
291 | \r |
292 | This function sets the current file position for the handle to the position \r |
293 | supplied. With the exception of seeking to position 0xFFFFFFFFFFFFFFFF, only\r |
294 | absolute positioning is supported, and seeking past the end of the file is \r |
295 | allowed (a subsequent write would grow the file). Seeking to position \r |
296 | 0xFFFFFFFFFFFFFFFF causes the current position to be set to the end of the file.\r |
297 | If FileHandle is a directory, the only position that may be set is zero. This \r |
298 | has the effect of starting the read process of the directory entries over.\r |
299 | \r |
300 | @param FileHandle The file handle on which the position is being set\r |
301 | \r |
302 | @param Position Byte position from begining of file\r |
303 | \r |
304 | @retval EFI_SUCCESS Operation completed sucessfully.\r |
305 | @retval EFI_UNSUPPORTED the seek request for non-zero is not valid on \r |
306 | directories.\r |
307 | @retval INVALID_PARAMETER One of the parameters has an invalid value.\r |
308 | **/\r |
309 | EFI_STATUS\r |
310 | EFIAPI\r |
311 | ShellSetFilePosition (\r |
312 | IN EFI_FILE_HANDLE FileHandle,\r |
313 | IN UINT64 Position\r |
314 | );\r |
315 | \r |
316 | /** \r |
317 | Gets a file's current position\r |
318 | \r |
319 | This function retrieves the current file position for the file handle. For \r |
320 | directories, the current file position has no meaning outside of the file \r |
321 | system driver and as such the operation is not supported. An error is returned\r |
322 | if FileHandle is a directory.\r |
323 | \r |
324 | @param FileHandle The open file handle on which to get the position.\r |
325 | @param Position Byte position from begining of file.\r |
326 | \r |
327 | @retval EFI_SUCCESS the operation completed sucessfully.\r |
328 | @retval INVALID_PARAMETER One of the parameters has an invalid value.\r |
329 | @retval EFI_UNSUPPORTED the request is not valid on directories.\r |
330 | **/\r |
331 | EFI_STATUS\r |
332 | EFIAPI\r |
333 | ShellGetFilePosition (\r |
334 | IN EFI_FILE_HANDLE FileHandle,\r |
335 | OUT UINT64 *Position\r |
336 | );\r |
337 | \r |
338 | /**\r |
339 | Flushes data on a file\r |
340 | \r |
341 | This function flushes all modified data associated with a file to a device.\r |
342 | \r |
343 | @param FileHandle The file handle on which to flush data\r |
344 | \r |
345 | @retval EFI_SUCCESS The data was flushed.\r |
346 | @retval EFI_NO_MEDIA The device has no media.\r |
347 | @retval EFI_DEVICE_ERROR The device reported an error.\r |
348 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r |
349 | @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r |
350 | @retval EFI_ACCESS_DENIED The file was opened for read only.\r |
351 | **/\r |
352 | EFI_STATUS\r |
353 | EFIAPI\r |
354 | ShellFlushFile (\r |
355 | IN EFI_FILE_HANDLE FileHandle\r |
356 | );\r |
357 | \r |
358 | /**\r |
359 | Retrieves the first file from a directory\r |
360 | \r |
361 | This function takes an open directory handle and gets the first file \r |
362 | in the directory's info. Caller can use ShellFindNextFile() to get \r |
363 | subsequent files.\r |
364 | \r |
d2b4564b |
365 | Caller must use FreePool on *Buffer opon completion of all file searching.\r |
366 | \r |
94b17fa1 |
367 | @param DirHandle The file handle of the directory to search\r |
d2b4564b |
368 | @param Buffer Pointer to pointer to buffer for file's information\r |
94b17fa1 |
369 | \r |
370 | @retval EFI_SUCCESS Found the first file.\r |
371 | @retval EFI_NOT_FOUND Cannot find the directory.\r |
372 | @retval EFI_NO_MEDIA The device has no media.\r |
373 | @retval EFI_DEVICE_ERROR The device reported an error.\r |
374 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r |
375 | @return ShellReadFile\r |
376 | **/\r |
377 | EFI_STATUS\r |
378 | EFIAPI\r |
379 | ShellFindFirstFile (\r |
380 | IN EFI_FILE_HANDLE DirHandle,\r |
d2b4564b |
381 | OUT EFI_FILE_INFO **Buffer\r |
94b17fa1 |
382 | );\r |
383 | \r |
384 | /**\r |
385 | Retrieves the next file in a directory.\r |
386 | \r |
387 | To use this function, caller must call the ShellFindFirstFile() to get the \r |
388 | first file, and then use this function get other files. This function can be \r |
389 | called for several times to get each file's information in the directory. If \r |
390 | the call of ShellFindNextFile() got the last file in the directory, the next \r |
391 | call of this function has no file to get. *NoFile will be set to TRUE and the \r |
392 | data in Buffer is meaningless. \r |
393 | \r |
394 | @param DirHandle the file handle of the directory\r |
395 | @param Buffer pointer to buffer for file's information\r |
396 | @param NoFile pointer to boolean when last file is found\r |
397 | \r |
398 | @retval EFI_SUCCESS Found the next file.\r |
399 | @retval EFI_NO_MEDIA The device has no media.\r |
400 | @retval EFI_DEVICE_ERROR The device reported an error.\r |
401 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r |
402 | **/\r |
403 | EFI_STATUS\r |
404 | EFIAPI\r |
405 | ShellFindNextFile(\r |
406 | IN EFI_FILE_HANDLE DirHandle,\r |
407 | OUT EFI_FILE_INFO *Buffer,\r |
408 | OUT BOOLEAN *NoFile\r |
409 | );\r |
410 | \r |
411 | /**\r |
412 | Retrieve the size of a file.\r |
413 | \r |
69817bf8 |
414 | This function extracts the file size info from the FileHandle's EFI_FILE_INFO \r |
94b17fa1 |
415 | data.\r |
416 | \r |
417 | @param FileHandle file handle from which size is retrieved\r |
418 | @param Size pointer to size\r |
419 | \r |
420 | @retval EFI_SUCCESS operation was completed sucessfully\r |
421 | @retval EFI_DEVICE_ERROR cannot access the file\r |
422 | **/\r |
423 | EFI_STATUS\r |
424 | EFIAPI\r |
425 | ShellGetFileSize (\r |
426 | IN EFI_FILE_HANDLE FileHandle,\r |
427 | OUT UINT64 *Size\r |
428 | );\r |
429 | \r |
430 | /**\r |
431 | Retrieves the status of the break execution flag\r |
432 | \r |
433 | this function is useful to check whether the application is being asked to halt by the shell.\r |
434 | \r |
435 | @retval TRUE the execution break is enabled\r |
436 | @retval FALSE the execution break is not enabled\r |
437 | **/\r |
438 | BOOLEAN\r |
439 | EFIAPI\r |
440 | ShellGetExecutionBreakFlag(\r |
441 | VOID\r |
442 | );\r |
443 | \r |
444 | /**\r |
445 | return the value of an environment variable\r |
446 | \r |
447 | this function gets the value of the environment variable set by the \r |
448 | ShellSetEnvironmentVariable function\r |
449 | \r |
450 | @param EnvKey The key name of the environment variable.\r |
451 | \r |
452 | @retval NULL the named environment variable does not exist.\r |
453 | @return != NULL pointer to the value of the environment variable\r |
454 | **/\r |
455 | CONST CHAR16*\r |
456 | EFIAPI\r |
457 | ShellGetEnvironmentVariable (\r |
9b3bf083 |
458 | IN CONST CHAR16 *EnvKey\r |
94b17fa1 |
459 | );\r |
460 | \r |
461 | /**\r |
462 | set the value of an environment variable\r |
463 | \r |
464 | This function changes the current value of the specified environment variable. If the\r |
465 | environment variable exists and the Value is an empty string, then the environment\r |
466 | variable is deleted. If the environment variable exists and the Value is not an empty\r |
467 | string, then the value of the environment variable is changed. If the environment\r |
468 | variable does not exist and the Value is an empty string, there is no action. If the\r |
469 | environment variable does not exist and the Value is a non-empty string, then the\r |
470 | environment variable is created and assigned the specified value.\r |
471 | \r |
472 | This is not supported pre-UEFI Shell 2.0.\r |
473 | \r |
474 | @param EnvKey The key name of the environment variable.\r |
475 | @param EnvVal The Value of the environment variable\r |
476 | @param Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).\r |
477 | \r |
478 | @retval EFI_SUCCESS the operation was completed sucessfully\r |
479 | @retval EFI_UNSUPPORTED This operation is not allowed in pre UEFI 2.0 Shell environments\r |
480 | **/\r |
481 | EFI_STATUS\r |
482 | EFIAPI\r |
483 | ShellSetEnvironmentVariable (\r |
484 | IN CONST CHAR16 *EnvKey,\r |
485 | IN CONST CHAR16 *EnvVal,\r |
486 | IN BOOLEAN Volatile\r |
487 | );\r |
488 | \r |
489 | /**\r |
490 | cause the shell to parse and execute a command line.\r |
491 | \r |
492 | This function creates a nested instance of the shell and executes the specified\r |
493 | command (CommandLine) with the specified environment (Environment). Upon return,\r |
494 | the status code returned by the specified command is placed in StatusCode.\r |
495 | If Environment is NULL, then the current environment is used and all changes made\r |
496 | by the commands executed will be reflected in the current environment. If the\r |
497 | Environment is non-NULL, then the changes made will be discarded.\r |
498 | The CommandLine is executed from the current working directory on the current\r |
499 | device.\r |
500 | \r |
501 | EnvironmentVariables and Status are only supported for UEFI Shell 2.0.\r |
502 | Output is only supported for pre-UEFI Shell 2.0\r |
503 | \r |
504 | @param ImageHandle Parent image that is starting the operation\r |
505 | @param CommandLine pointer to null terminated command line.\r |
506 | @param Output true to display debug output. false to hide it.\r |
507 | @param EnvironmentVariables optional pointer to array of environment variables\r |
508 | in the form "x=y". if NULL current set is used.\r |
509 | @param Status the status of the run command line.\r |
510 | \r |
511 | @retval EFI_SUCCESS the operation completed sucessfully. Status\r |
512 | contains the status code returned.\r |
513 | @retval EFI_INVALID_PARAMETER a parameter contains an invalid value\r |
514 | @retval EFI_OUT_OF_RESOURCES out of resources\r |
515 | @retval EFI_UNSUPPORTED the operation is not allowed.\r |
516 | **/\r |
517 | EFI_STATUS\r |
518 | EFIAPI\r |
519 | ShellExecute (\r |
520 | IN EFI_HANDLE *ParentHandle,\r |
521 | IN CHAR16 *CommandLine,\r |
522 | IN BOOLEAN Output,\r |
523 | IN CHAR16 **EnvironmentVariables,\r |
524 | OUT EFI_STATUS *Status\r |
525 | );\r |
526 | \r |
527 | /**\r |
528 | Retreives the current directory path\r |
529 | \r |
69817bf8 |
530 | If the DeviceName is NULL, it returns the current device's current directory \r |
94b17fa1 |
531 | name. If the DeviceName is not NULL, it returns the current directory name \r |
532 | on specified drive.\r |
533 | \r |
534 | @param DeviceName the name of the drive to get directory on\r |
535 | \r |
536 | @retval NULL the directory does not exist\r |
537 | @return != NULL the directory\r |
538 | **/\r |
539 | CONST CHAR16*\r |
540 | EFIAPI\r |
541 | ShellGetCurrentDir (\r |
542 | IN CHAR16 *DeviceName OPTIONAL\r |
543 | );\r |
544 | \r |
545 | /**\r |
546 | sets (enabled or disabled) the page break mode\r |
547 | \r |
548 | when page break mode is enabled the screen will stop scrolling \r |
549 | and wait for operator input before scrolling a subsequent screen.\r |
550 | \r |
551 | @param CurrentState TRUE to enable and FALSE to disable\r |
552 | **/\r |
553 | VOID \r |
554 | EFIAPI\r |
555 | ShellSetPageBreakMode (\r |
556 | IN BOOLEAN CurrentState\r |
557 | );\r |
558 | \r |
559 | /**\r |
560 | Opens a group of files based on a path.\r |
561 | \r |
562 | This function uses the Arg to open all the matching files. Each matched \r |
563 | file has a SHELL_FILE_ARG structure to record the file information. These \r |
564 | structures are placed on the list ListHead. Users can get the SHELL_FILE_ARG \r |
565 | structures from ListHead to access each file. This function supports wildcards\r |
566 | and will process '?' and '*' as such. the list must be freed with a call to \r |
567 | ShellCloseFileMetaArg().\r |
568 | \r |
9b3bf083 |
569 | If you are NOT appending to an existing list *ListHead must be NULL.\r |
94b17fa1 |
570 | \r |
571 | @param Arg pointer to path string\r |
572 | @param OpenMode mode to open files with\r |
573 | @param ListHead head of linked list of results\r |
574 | \r |
575 | @retval EFI_SUCCESS the operation was sucessful and the list head \r |
576 | contains the list of opened files\r |
577 | #retval EFI_UNSUPPORTED a previous ShellOpenFileMetaArg must be closed first.\r |
578 | *ListHead is set to NULL.\r |
579 | @return != EFI_SUCCESS the operation failed\r |
580 | \r |
581 | @sa InternalShellConvertFileListType\r |
582 | **/\r |
583 | EFI_STATUS\r |
584 | EFIAPI\r |
585 | ShellOpenFileMetaArg (\r |
586 | IN CHAR16 *Arg,\r |
587 | IN UINT64 OpenMode,\r |
588 | IN OUT EFI_SHELL_FILE_INFO **ListHead\r |
589 | );\r |
590 | \r |
591 | /**\r |
592 | Free the linked list returned from ShellOpenFileMetaArg\r |
593 | \r |
594 | @param ListHead the pointer to free\r |
595 | \r |
596 | @retval EFI_SUCCESS the operation was sucessful\r |
597 | @retval EFI_INVALID_PARAMETER A parameter was invalid\r |
598 | **/\r |
599 | EFI_STATUS\r |
600 | EFIAPI\r |
601 | ShellCloseFileMetaArg (\r |
602 | IN OUT EFI_SHELL_FILE_INFO **ListHead\r |
603 | );\r |
604 | \r |
605 | typedef enum {\r |
606 | TypeFlag = 0,\r |
607 | TypeValue,\r |
608 | TypePosition,\r |
9eb53ac3 |
609 | TypeStart,\r |
94b17fa1 |
610 | TypeMax,\r |
611 | } ParamType;\r |
612 | \r |
613 | typedef struct {\r |
614 | CHAR16 *Name;\r |
615 | ParamType Type;\r |
616 | } SHELL_PARAM_ITEM;\r |
617 | \r |
d2b4564b |
618 | \r |
619 | /// Helper structure for no parameters (besides -? and -b)\r |
620 | extern SHELL_PARAM_ITEM EmptyParamList[];\r |
621 | \r |
94b17fa1 |
622 | /**\r |
623 | Checks the command line arguments passed against the list of valid ones. \r |
624 | Optionally removes NULL values first.\r |
625 | \r |
626 | If no initialization is required, then return RETURN_SUCCESS.\r |
627 | \r |
628 | @param CheckList pointer to list of parameters to check\r |
629 | @param CheckPackage Package of checked values\r |
630 | @param ProblemParam optional pointer to pointer to unicode string for \r |
631 | the paramater that caused failure.\r |
632 | @param AutoPageBreak will automatically set PageBreakEnabled\r |
633 | \r |
634 | @retval EFI_SUCCESS The operation completed sucessfully.\r |
635 | @retval EFI_OUT_OF_RESOURCES A memory allocation failed\r |
636 | @retval EFI_INVALID_PARAMETER A parameter was invalid\r |
637 | @retval EFI_VOLUME_CORRUPTED the command line was corrupt. an argument was \r |
638 | duplicated. the duplicated command line argument \r |
639 | was returned in ProblemParam if provided.\r |
640 | @retval EFI_DEVICE_ERROR the commands contained 2 opposing arguments. one\r |
641 | of the command line arguments was returned in \r |
642 | ProblemParam if provided.\r |
643 | @retval EFI_NOT_FOUND a argument required a value that was missing. \r |
644 | the invalid command line argument was returned in\r |
645 | ProblemParam if provided.\r |
646 | **/\r |
647 | EFI_STATUS\r |
648 | EFIAPI\r |
649 | ShellCommandLineParse (\r |
650 | IN CONST SHELL_PARAM_ITEM *CheckList,\r |
651 | OUT LIST_ENTRY **CheckPackage,\r |
652 | OUT CHAR16 **ProblemParam OPTIONAL,\r |
653 | IN BOOLEAN AutoPageBreak\r |
654 | );\r |
655 | \r |
656 | /**\r |
657 | Frees shell variable list that was returned from ShellCommandLineParse.\r |
658 | \r |
659 | This function will free all the memory that was used for the CheckPackage\r |
660 | list of postprocessed shell arguments.\r |
661 | \r |
662 | this function has no return value.\r |
663 | \r |
664 | if CheckPackage is NULL, then return\r |
665 | \r |
666 | @param CheckPackage the list to de-allocate\r |
667 | **/\r |
668 | VOID\r |
669 | EFIAPI\r |
670 | ShellCommandLineFreeVarList (\r |
671 | IN LIST_ENTRY *CheckPackage\r |
672 | );\r |
673 | \r |
674 | /**\r |
675 | Checks for presence of a flag parameter\r |
676 | \r |
677 | flag arguments are in the form of "-<Key>" or "/<Key>", but do not have a value following the key\r |
678 | \r |
679 | if CheckPackage is NULL then return FALSE.\r |
680 | if KeyString is NULL then ASSERT()\r |
681 | \r |
682 | @param CheckPackage The package of parsed command line arguments\r |
683 | @param KeyString the Key of the command line argument to check for\r |
684 | \r |
685 | @retval TRUE the flag is on the command line\r |
686 | @retval FALSE the flag is not on the command line\r |
687 | **/\r |
688 | BOOLEAN\r |
689 | EFIAPI\r |
690 | ShellCommandLineGetFlag (\r |
691 | IN CONST LIST_ENTRY *CheckPackage,\r |
692 | IN CHAR16 *KeyString\r |
693 | );\r |
694 | \r |
695 | /**\r |
696 | returns value from command line argument\r |
697 | \r |
698 | value parameters are in the form of "-<Key> value" or "/<Key> value"\r |
699 | \r |
700 | if CheckPackage is NULL, then return NULL;\r |
701 | \r |
702 | @param CheckPackage The package of parsed command line arguments\r |
703 | @param KeyString the Key of the command line argument to check for\r |
704 | \r |
705 | @retval NULL the flag is not on the command line\r |
706 | @return !=NULL pointer to unicode string of the value\r |
707 | **/\r |
708 | CONST CHAR16*\r |
709 | EFIAPI\r |
710 | ShellCommandLineGetValue (\r |
711 | IN CONST LIST_ENTRY *CheckPackage,\r |
712 | IN CHAR16 *KeyString\r |
713 | );\r |
714 | \r |
715 | /**\r |
716 | returns raw value from command line argument\r |
717 | \r |
718 | raw value parameters are in the form of "value" in a specific position in the list\r |
719 | \r |
720 | if CheckPackage is NULL, then return NULL;\r |
721 | \r |
722 | @param CheckPackage The package of parsed command line arguments\r |
723 | @param Position the position of the value \r |
724 | \r |
725 | @retval NULL the flag is not on the command line\r |
726 | @return !=NULL pointer to unicode string of the value\r |
727 | **/\r |
728 | CONST CHAR16*\r |
729 | EFIAPI\r |
730 | ShellCommandLineGetRawValue (\r |
731 | IN CONST LIST_ENTRY *CheckPackage,\r |
732 | IN UINT32 Position\r |
733 | );\r |
734 | \r |
d2b4564b |
735 | /**\r |
736 | This function causes the shell library to initialize itself. If the shell library\r |
737 | is already initialized it will de-initialize all the current protocol poitners and\r |
738 | re-populate them again.\r |
739 | \r |
740 | When the library is used with PcdShellLibAutoInitialize set to true this function\r |
741 | will return EFI_SUCCESS and perform no actions.\r |
742 | \r |
743 | This function is intended for internal access for shell commands only.\r |
744 | \r |
745 | @retval EFI_SUCCESS the initialization was complete sucessfully\r |
746 | \r |
747 | **/\r |
748 | EFI_STATUS\r |
749 | EFIAPI\r |
750 | ShellInitialize (\r |
751 | );\r |
752 | \r |
b1f95a06 |
753 | /**\r |
754 | Print at a specific location on the screen.\r |
755 | \r |
756 | This function will move the cursor to a given screen location, print the specified string, \r |
757 | and return the cursor to the original locaiton. \r |
758 | \r |
759 | If -1 is specified for either the Row or Col the current screen location for BOTH \r |
760 | will be used and the cursor's position will not be moved back to an original location.\r |
761 | \r |
762 | if either Row or Col is out of range for the current console, then ASSERT\r |
763 | if Format is NULL, then ASSERT\r |
764 | \r |
765 | In addition to the standard %-based flags as supported by UefiLib Print() this supports \r |
766 | the following additional flags:\r |
767 | %N - Set output attribute to normal\r |
768 | %H - Set output attribute to highlight\r |
769 | %E - Set output attribute to error\r |
770 | %B - Set output attribute to blue color\r |
771 | %V - Set output attribute to green color\r |
772 | \r |
773 | Note: The background color is controlled by the shell command cls.\r |
774 | \r |
775 | @param[in] Row the row to print at\r |
776 | @param[in] Col the column to print at\r |
777 | @param[in] Format the format string\r |
778 | \r |
779 | @return the number of characters printed to the screen\r |
780 | **/\r |
781 | \r |
782 | UINTN\r |
783 | EFIAPI\r |
784 | ShellPrintEx(\r |
785 | IN INT32 Col OPTIONAL,\r |
786 | IN INT32 Row OPTIONAL,\r |
787 | IN CONST CHAR16 *Format,\r |
788 | ...\r |
789 | );\r |
790 | \r |
e9880e25 |
791 | #endif // __SHELL_LIB__\r |