]> git.proxmox.com Git - mirror_edk2.git/blame_incremental - ShellPkg/Include/Library/ShellLib.h
ShellPkg: stop using EFI_HANDLE in place of EFI_HII_HANDLE
[mirror_edk2.git] / ShellPkg / Include / Library / ShellLib.h
... / ...
CommitLineData
1/** @file\r
2 Provides interface to shell functionality for shell commands and applications.\r
3\r
4 Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.<BR>\r
5 Copyright 2018 Dell Technologies.<BR>\r
6 SPDX-License-Identifier: BSD-2-Clause-Patent\r
7\r
8**/\r
9\r
10#ifndef __SHELL_LIB__\r
11#define __SHELL_LIB__\r
12\r
13#include <Uefi.h>\r
14#include <Guid/FileInfo.h>\r
15#include <Protocol/SimpleFileSystem.h>\r
16#include <Protocol/LoadedImage.h>\r
17#include <Protocol/EfiShellInterface.h>\r
18#include <Protocol/EfiShellEnvironment2.h>\r
19#include <Protocol/Shell.h>\r
20#include <Protocol/ShellParameters.h>\r
21\r
22#define SHELL_FREE_NON_NULL(Pointer) \\r
23 do { \\r
24 if ((Pointer) != NULL) { \\r
25 FreePool((Pointer)); \\r
26 (Pointer) = NULL; \\r
27 } \\r
28 } while(FALSE)\r
29\r
30extern EFI_SHELL_PARAMETERS_PROTOCOL *gEfiShellParametersProtocol;\r
31extern EFI_SHELL_PROTOCOL *gEfiShellProtocol;\r
32\r
33/**\r
34 Return a clean, fully-qualified version of an input path. If the return value\r
35 is non-NULL the caller must free the memory when it is no longer needed.\r
36\r
37 If asserts are disabled, and if the input parameter is NULL, NULL is returned.\r
38\r
39 If there is not enough memory available to create the fully-qualified path or\r
40 a copy of the input path, NULL is returned.\r
41\r
42 If there is no working directory, a clean copy of Path is returned.\r
43\r
44 Otherwise, the current file system or working directory (as appropriate) is\r
45 prepended to Path and the resulting path is cleaned and returned.\r
46\r
47 NOTE: If the input path is an empty string, then the current working directory\r
48 (if it exists) is returned. In other words, an empty input path is treated\r
49 exactly the same as ".".\r
50\r
51 @param[in] Path A pointer to some file or directory path.\r
52\r
53 @retval NULL The input path is NULL or out of memory.\r
54\r
55 @retval non-NULL A pointer to a clean, fully-qualified version of Path.\r
56 If there is no working directory, then a pointer to a\r
57 clean, but not necessarily fully-qualified version of\r
58 Path. The caller must free this memory when it is no\r
59 longer needed.\r
60**/\r
61CHAR16*\r
62EFIAPI\r
63FullyQualifyPath(\r
64 IN CONST CHAR16 *Path\r
65 );\r
66\r
67/**\r
68 This function will retrieve the information about the file for the handle\r
69 specified and store it in allocated pool memory.\r
70\r
71 This function allocates a buffer to store the file's information. It is the\r
72 caller's responsibility to free the buffer.\r
73\r
74 @param[in] FileHandle The file handle of the file for which information is\r
75 being requested.\r
76\r
77 @retval NULL Information could not be retrieved.\r
78\r
79 @return The information about the file.\r
80**/\r
81EFI_FILE_INFO*\r
82EFIAPI\r
83ShellGetFileInfo (\r
84 IN SHELL_FILE_HANDLE FileHandle\r
85 );\r
86\r
87/**\r
88 This function sets the information about the file for the opened handle\r
89 specified.\r
90\r
91 @param[in] FileHandle The file handle of the file for which information\r
92 is being set.\r
93\r
94 @param[in] FileInfo The information to set.\r
95\r
96 @retval EFI_SUCCESS The information was set.\r
97 @retval EFI_INVALID_PARAMETER A parameter was out of range or invalid.\r
98 @retval EFI_UNSUPPORTED The FileHandle does not support FileInfo.\r
99 @retval EFI_NO_MEDIA The device has no medium.\r
100 @retval EFI_DEVICE_ERROR The device reported an error.\r
101 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
102 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
103 @retval EFI_ACCESS_DENIED The file was opened read only.\r
104 @retval EFI_VOLUME_FULL The volume is full.\r
105**/\r
106EFI_STATUS\r
107EFIAPI\r
108ShellSetFileInfo (\r
109 IN SHELL_FILE_HANDLE FileHandle,\r
110 IN EFI_FILE_INFO *FileInfo\r
111 );\r
112\r
113/**\r
114 This function will open a file or directory referenced by DevicePath.\r
115\r
116 This function opens a file with the open mode according to the file path. The\r
117 Attributes is valid only for EFI_FILE_MODE_CREATE.\r
118\r
119 @param[in, out] FilePath On input, the device path to the file. On output,\r
120 the remaining device path.\r
121 @param[out] FileHandle Pointer to the file handle.\r
122 @param[in] OpenMode The mode to open the file with.\r
123 @param[in] Attributes The file's file attributes.\r
124\r
125 @retval EFI_SUCCESS The information was set.\r
126 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
127 @retval EFI_UNSUPPORTED Could not open the file path.\r
128 @retval EFI_NOT_FOUND The specified file could not be found on the\r
129 device or the file system could not be found on\r
130 the device.\r
131 @retval EFI_NO_MEDIA The device has no medium.\r
132 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the\r
133 medium is no longer supported.\r
134 @retval EFI_DEVICE_ERROR The device reported an error.\r
135 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
136 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
137 @retval EFI_ACCESS_DENIED The file was opened read only.\r
138 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the\r
139 file.\r
140 @retval EFI_VOLUME_FULL The volume is full.\r
141**/\r
142EFI_STATUS\r
143EFIAPI\r
144ShellOpenFileByDevicePath(\r
145 IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath,\r
146 OUT SHELL_FILE_HANDLE *FileHandle,\r
147 IN UINT64 OpenMode,\r
148 IN UINT64 Attributes\r
149 );\r
150\r
151/**\r
152 This function will open a file or directory referenced by filename.\r
153\r
154 If return is EFI_SUCCESS, the Filehandle is the opened file's handle;\r
155 otherwise, the Filehandle is NULL. Attributes is valid only for\r
156 EFI_FILE_MODE_CREATE.\r
157\r
158 @param[in] FileName The pointer to file name.\r
159 @param[out] FileHandle The pointer to the file handle.\r
160 @param[in] OpenMode The mode to open the file with.\r
161 @param[in] Attributes The file's file attributes.\r
162\r
163 @retval EFI_SUCCESS The information was set.\r
164 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
165 @retval EFI_UNSUPPORTED Could not open the file path.\r
166 @retval EFI_NOT_FOUND The specified file could not be found on the\r
167 device or the file system could not be found\r
168 on the device.\r
169 @retval EFI_NO_MEDIA The device has no medium.\r
170 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the\r
171 medium is no longer supported.\r
172 @retval EFI_DEVICE_ERROR The device reported an error.\r
173 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
174 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
175 @retval EFI_ACCESS_DENIED The file was opened read only.\r
176 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the\r
177 file.\r
178 @retval EFI_VOLUME_FULL The volume is full.\r
179**/\r
180EFI_STATUS\r
181EFIAPI\r
182ShellOpenFileByName(\r
183 IN CONST CHAR16 *FileName,\r
184 OUT SHELL_FILE_HANDLE *FileHandle,\r
185 IN UINT64 OpenMode,\r
186 IN UINT64 Attributes\r
187 );\r
188\r
189/**\r
190 This function creates a directory.\r
191\r
192 If return is EFI_SUCCESS, the Filehandle is the opened directory's handle;\r
193 otherwise, the Filehandle is NULL. If the directory already existed, this\r
194 function opens the existing directory.\r
195\r
196 @param[in] DirectoryName The pointer to Directory name.\r
197 @param[out] FileHandle The pointer to the file handle.\r
198\r
199 @retval EFI_SUCCESS The information was set.\r
200 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
201 @retval EFI_UNSUPPORTED Could not open the file path.\r
202 @retval EFI_NOT_FOUND The specified file could not be found on the\r
203 device, or the file system could not be found\r
204 on the device.\r
205 @retval EFI_NO_MEDIA The device has no medium.\r
206 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the\r
207 medium is no longer supported.\r
208 @retval EFI_DEVICE_ERROR The device reported an error.\r
209 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
210 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
211 @retval EFI_ACCESS_DENIED The file was opened read only.\r
212 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the\r
213 file.\r
214 @retval EFI_VOLUME_FULL The volume is full.\r
215**/\r
216EFI_STATUS\r
217EFIAPI\r
218ShellCreateDirectory(\r
219 IN CONST CHAR16 *DirectoryName,\r
220 OUT SHELL_FILE_HANDLE *FileHandle\r
221 );\r
222\r
223/**\r
224 This function reads information from an opened file.\r
225\r
226 If FileHandle is not a directory, the function reads the requested number of\r
227 bytes from the file at the file's current position and returns them in Buffer.\r
228 If the read goes beyond the end of the file, the read length is truncated to the\r
229 end of the file. The file's current position is increased by the number of bytes\r
230 returned. If FileHandle is a directory, the function reads the directory entry\r
231 at the file's current position and returns the entry in Buffer. If the Buffer\r
232 is not large enough to hold the current directory entry, then\r
233 EFI_BUFFER_TOO_SMALL is returned and the current file position is not updated.\r
234 BufferSize is set to be the size of the buffer needed to read the entry. On\r
235 success, the current position is updated to the next directory entry. If there\r
236 are no more directory entries, the read returns a zero-length buffer.\r
237 EFI_FILE_INFO is the structure returned as the directory entry.\r
238\r
239 @param[in] FileHandle The opened file handle.\r
240 @param[in, out] ReadSize On input the size of buffer in bytes. On return\r
241 the number of bytes written.\r
242 @param[out] Buffer The buffer to put read data into.\r
243\r
244 @retval EFI_SUCCESS Data was read.\r
245 @retval EFI_NO_MEDIA The device has no media.\r
246 @retval EFI_DEVICE_ERROR The device reported an error.\r
247 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
248 @retval EFI_BUFFER_TO_SMALL Buffer is too small. ReadSize contains required\r
249 size.\r
250\r
251**/\r
252EFI_STATUS\r
253EFIAPI\r
254ShellReadFile(\r
255 IN SHELL_FILE_HANDLE FileHandle,\r
256 IN OUT UINTN *ReadSize,\r
257 OUT VOID *Buffer\r
258 );\r
259\r
260/**\r
261 Write data to a file.\r
262\r
263 This function writes the specified number of bytes to the file at the current\r
264 file position. The current file position is advanced the actual number of bytes\r
265 written, which is returned in BufferSize. Partial writes only occur when there\r
266 has been a data error during the write attempt (such as "volume space full").\r
267 The file is automatically grown to hold the data if required. Direct writes to\r
268 opened directories are not supported.\r
269\r
270 @param[in] FileHandle The opened file for writing.\r
271\r
272 @param[in, out] BufferSize On input the number of bytes in Buffer. On output\r
273 the number of bytes written.\r
274\r
275 @param[in] Buffer The buffer containing data to write is stored.\r
276\r
277 @retval EFI_SUCCESS Data was written.\r
278 @retval EFI_UNSUPPORTED Writes to an open directory are not supported.\r
279 @retval EFI_NO_MEDIA The device has no media.\r
280 @retval EFI_DEVICE_ERROR The device reported an error.\r
281 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
282 @retval EFI_WRITE_PROTECTED The device is write-protected.\r
283 @retval EFI_ACCESS_DENIED The file was open for read only.\r
284 @retval EFI_VOLUME_FULL The volume is full.\r
285**/\r
286EFI_STATUS\r
287EFIAPI\r
288ShellWriteFile(\r
289 IN SHELL_FILE_HANDLE FileHandle,\r
290 IN OUT UINTN *BufferSize,\r
291 IN VOID *Buffer\r
292 );\r
293\r
294/**\r
295 Close an open file handle.\r
296\r
297 This function closes a specified file handle. All "dirty" cached file data is\r
298 flushed to the device, and the file is closed. In all cases the handle is\r
299 closed.\r
300\r
301 @param[in] FileHandle The file handle to close.\r
302\r
303 @retval EFI_SUCCESS The file handle was closed sucessfully.\r
304 @retval INVALID_PARAMETER One of the parameters has an invalid value.\r
305**/\r
306EFI_STATUS\r
307EFIAPI\r
308ShellCloseFile (\r
309 IN SHELL_FILE_HANDLE *FileHandle\r
310 );\r
311\r
312/**\r
313 Delete a file and close the handle\r
314\r
315 This function closes and deletes a file. In all cases the file handle is closed.\r
316 If the file cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is\r
317 returned, but the handle is still closed.\r
318\r
319 @param[in] FileHandle The file handle to delete.\r
320\r
321 @retval EFI_SUCCESS The file was closed sucessfully.\r
322 @retval EFI_WARN_DELETE_FAILURE The handle was closed, but the file was not\r
323 deleted.\r
324 @retval INVALID_PARAMETER One of the parameters has an invalid value.\r
325**/\r
326EFI_STATUS\r
327EFIAPI\r
328ShellDeleteFile (\r
329 IN SHELL_FILE_HANDLE *FileHandle\r
330 );\r
331\r
332/**\r
333 Set the current position in a file.\r
334\r
335 This function sets the current file position for the handle to the position\r
336 supplied. With the exception of seeking to position 0xFFFFFFFFFFFFFFFF, only\r
337 absolute positioning is supported, and moving past the end of the file is\r
338 allowed (a subsequent write would grow the file). Moving to position\r
339 0xFFFFFFFFFFFFFFFF causes the current position to be set to the end of the file.\r
340 If FileHandle is a directory, the only position that may be set is zero. This\r
341 has the effect of starting the read process of the directory entries over.\r
342\r
343 @param[in] FileHandle The file handle on which the position is being set.\r
344\r
345 @param[in] Position The byte position from the begining of the file.\r
346\r
347 @retval EFI_SUCCESS Operation completed sucessfully.\r
348 @retval EFI_UNSUPPORTED The seek request for non-zero is not valid on\r
349 directories.\r
350 @retval INVALID_PARAMETER One of the parameters has an invalid value.\r
351**/\r
352EFI_STATUS\r
353EFIAPI\r
354ShellSetFilePosition (\r
355 IN SHELL_FILE_HANDLE FileHandle,\r
356 IN UINT64 Position\r
357 );\r
358\r
359/**\r
360 Gets a file's current position\r
361\r
362 This function retrieves the current file position for the file handle. For\r
363 directories, the current file position has no meaning outside of the file\r
364 system driver and as such the operation is not supported. An error is returned\r
365 if FileHandle is a directory.\r
366\r
367 @param[in] FileHandle The open file handle on which to get the position.\r
368 @param[out] Position The byte position from the begining of the file.\r
369\r
370 @retval EFI_SUCCESS The operation completed sucessfully.\r
371 @retval INVALID_PARAMETER One of the parameters has an invalid value.\r
372 @retval EFI_UNSUPPORTED The request is not valid on directories.\r
373**/\r
374EFI_STATUS\r
375EFIAPI\r
376ShellGetFilePosition (\r
377 IN SHELL_FILE_HANDLE FileHandle,\r
378 OUT UINT64 *Position\r
379 );\r
380\r
381/**\r
382 Flushes data on a file\r
383\r
384 This function flushes all modified data associated with a file to a device.\r
385\r
386 @param[in] FileHandle The file handle on which to flush data.\r
387\r
388 @retval EFI_SUCCESS The data was flushed.\r
389 @retval EFI_NO_MEDIA The device has no media.\r
390 @retval EFI_DEVICE_ERROR The device reported an error.\r
391 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
392 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
393 @retval EFI_ACCESS_DENIED The file was opened for read only.\r
394**/\r
395EFI_STATUS\r
396EFIAPI\r
397ShellFlushFile (\r
398 IN SHELL_FILE_HANDLE FileHandle\r
399 );\r
400\r
401/** Retrieve first entry from a directory.\r
402\r
403 This function takes an open directory handle and gets information from the\r
404 first entry in the directory. A buffer is allocated to contain\r
405 the information and a pointer to the buffer is returned in *Buffer. The\r
406 caller can use ShellFindNextFile() to get subsequent directory entries.\r
407\r
408 The buffer will be freed by ShellFindNextFile() when the last directory\r
409 entry is read. Otherwise, the caller must free the buffer, using FreePool,\r
410 when finished with it.\r
411\r
412 @param[in] DirHandle The file handle of the directory to search.\r
413 @param[out] Buffer The pointer to the buffer for the file's information.\r
414\r
415 @retval EFI_SUCCESS Found the first file.\r
416 @retval EFI_NOT_FOUND Cannot find the directory.\r
417 @retval EFI_NO_MEDIA The device has no media.\r
418 @retval EFI_DEVICE_ERROR The device reported an error.\r
419 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
420 @return Others Status of ShellGetFileInfo, ShellSetFilePosition,\r
421 or ShellReadFile.\r
422\r
423 @sa ShellReadFile\r
424**/\r
425EFI_STATUS\r
426EFIAPI\r
427ShellFindFirstFile (\r
428 IN SHELL_FILE_HANDLE DirHandle,\r
429 OUT EFI_FILE_INFO **Buffer\r
430 );\r
431\r
432/** Retrieve next entries from a directory.\r
433\r
434 To use this function, the caller must first call the ShellFindFirstFile()\r
435 function to get the first directory entry. Subsequent directory entries are\r
436 retrieved by using the ShellFindNextFile() function. This function can\r
437 be called several times to get each entry from the directory. If the call of\r
438 ShellFindNextFile() retrieved the last directory entry, the next call of\r
439 this function will set *NoFile to TRUE and free the buffer.\r
440\r
441 @param[in] DirHandle The file handle of the directory.\r
442 @param[in, out] Buffer The pointer to buffer for file's information.\r
443 @param[in, out] NoFile The pointer to boolean when last file is found.\r
444\r
445 @retval EFI_SUCCESS Found the next file.\r
446 @retval EFI_NO_MEDIA The device has no media.\r
447 @retval EFI_DEVICE_ERROR The device reported an error.\r
448 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
449\r
450 @sa ShellReadFile\r
451**/\r
452EFI_STATUS\r
453EFIAPI\r
454ShellFindNextFile(\r
455 IN SHELL_FILE_HANDLE DirHandle,\r
456 IN OUT EFI_FILE_INFO *Buffer,\r
457 IN OUT BOOLEAN *NoFile\r
458 );\r
459\r
460/**\r
461 Retrieve the size of a file.\r
462\r
463 This function extracts the file size info from the FileHandle's EFI_FILE_INFO\r
464 data.\r
465\r
466 @param[in] FileHandle The file handle from which size is retrieved.\r
467 @param[out] Size The pointer to size.\r
468\r
469 @retval EFI_SUCCESS The operation was completed sucessfully.\r
470 @retval EFI_DEVICE_ERROR Cannot access the file.\r
471**/\r
472EFI_STATUS\r
473EFIAPI\r
474ShellGetFileSize (\r
475 IN SHELL_FILE_HANDLE FileHandle,\r
476 OUT UINT64 *Size\r
477 );\r
478\r
479/**\r
480 Retrieves the status of the break execution flag\r
481\r
482 This function is useful to check whether the application is being asked to halt by the shell.\r
483\r
484 @retval TRUE The execution break is enabled.\r
485 @retval FALSE The execution break is not enabled.\r
486**/\r
487BOOLEAN\r
488EFIAPI\r
489ShellGetExecutionBreakFlag(\r
490 VOID\r
491 );\r
492\r
493/**\r
494 Return the value of an environment variable.\r
495\r
496 This function gets the value of the environment variable set by the\r
497 ShellSetEnvironmentVariable function.\r
498\r
499 @param[in] EnvKey The key name of the environment variable.\r
500\r
501 @retval NULL The named environment variable does not exist.\r
502 @return != NULL The pointer to the value of the environment variable.\r
503**/\r
504CONST CHAR16*\r
505EFIAPI\r
506ShellGetEnvironmentVariable (\r
507 IN CONST CHAR16 *EnvKey\r
508 );\r
509\r
510/**\r
511 Set the value of an environment variable.\r
512\r
513 This function changes the current value of the specified environment variable. If the\r
514 environment variable exists and the Value is an empty string, then the environment\r
515 variable is deleted. If the environment variable exists and the Value is not an empty\r
516 string, then the value of the environment variable is changed. If the environment\r
517 variable does not exist and the Value is an empty string, there is no action. If the\r
518 environment variable does not exist and the Value is a non-empty string, then the\r
519 environment variable is created and assigned the specified value.\r
520\r
521 This is not supported pre-UEFI Shell 2.0.\r
522\r
523 @param[in] EnvKey The key name of the environment variable.\r
524 @param[in] EnvVal The Value of the environment variable\r
525 @param[in] Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).\r
526\r
527 @retval EFI_SUCCESS The operation completed sucessfully\r
528 @retval EFI_UNSUPPORTED This operation is not allowed in pre-UEFI 2.0 Shell environments.\r
529**/\r
530EFI_STATUS\r
531EFIAPI\r
532ShellSetEnvironmentVariable (\r
533 IN CONST CHAR16 *EnvKey,\r
534 IN CONST CHAR16 *EnvVal,\r
535 IN BOOLEAN Volatile\r
536 );\r
537\r
538/**\r
539 Cause the shell to parse and execute a command line.\r
540\r
541 This function creates a nested instance of the shell and executes the specified\r
542 command (CommandLine) with the specified environment (Environment). Upon return,\r
543 the status code returned by the specified command is placed in StatusCode.\r
544 If Environment is NULL, then the current environment is used and all changes made\r
545 by the commands executed will be reflected in the current environment. If the\r
546 Environment is non-NULL, then the changes made will be discarded.\r
547 The CommandLine is executed from the current working directory on the current\r
548 device.\r
549\r
550 The EnvironmentVariables and Status parameters are ignored in a pre-UEFI Shell 2.0\r
551 environment. The values pointed to by the parameters will be unchanged by the\r
552 ShellExecute() function. The Output parameter has no effect in a\r
553 UEFI Shell 2.0 environment.\r
554\r
555 @param[in] ParentHandle The parent image starting the operation.\r
556 @param[in] CommandLine The pointer to a NULL terminated command line.\r
557 @param[in] Output True to display debug output. False to hide it.\r
558 @param[in] EnvironmentVariables Optional pointer to array of environment variables\r
559 in the form "x=y". If NULL, the current set is used.\r
560 @param[out] Status The status of the run command line.\r
561\r
562 @retval EFI_SUCCESS The operation completed sucessfully. Status\r
563 contains the status code returned.\r
564 @retval EFI_INVALID_PARAMETER A parameter contains an invalid value.\r
565 @retval EFI_OUT_OF_RESOURCES Out of resources.\r
566 @retval EFI_UNSUPPORTED The operation is not allowed.\r
567**/\r
568EFI_STATUS\r
569EFIAPI\r
570ShellExecute (\r
571 IN EFI_HANDLE *ParentHandle,\r
572 IN CHAR16 *CommandLine,\r
573 IN BOOLEAN Output,\r
574 IN CHAR16 **EnvironmentVariables,\r
575 OUT EFI_STATUS *Status\r
576 );\r
577\r
578/**\r
579 Retreives the current directory path.\r
580\r
581 If the DeviceName is NULL, it returns the current device's current directory\r
582 name. If the DeviceName is not NULL, it returns the current directory name\r
583 on specified drive.\r
584\r
585 Note that the current directory string should exclude the tailing backslash character.\r
586\r
587 @param[in] DeviceName The name of the file system to get directory on.\r
588\r
589 @retval NULL The directory does not exist.\r
590 @retval != NULL The directory.\r
591**/\r
592CONST CHAR16*\r
593EFIAPI\r
594ShellGetCurrentDir (\r
595 IN CHAR16 * CONST DeviceName OPTIONAL\r
596 );\r
597\r
598/**\r
599 Sets (enabled or disabled) the page break mode.\r
600\r
601 When page break mode is enabled the screen will stop scrolling\r
602 and wait for operator input before scrolling a subsequent screen.\r
603\r
604 @param[in] CurrentState TRUE to enable and FALSE to disable.\r
605**/\r
606VOID\r
607EFIAPI\r
608ShellSetPageBreakMode (\r
609 IN BOOLEAN CurrentState\r
610 );\r
611\r
612/**\r
613 Opens a group of files based on a path.\r
614\r
615 This function uses the Arg to open all the matching files. Each matched\r
616 file has a SHELL_FILE_ARG structure to record the file information. These\r
617 structures are placed on the list ListHead. Users can get the SHELL_FILE_ARG\r
618 structures from ListHead to access each file. This function supports wildcards\r
619 and will process '?' and '*' as such. The list must be freed with a call to\r
620 ShellCloseFileMetaArg().\r
621\r
622 If you are NOT appending to an existing list *ListHead must be NULL. If\r
623 *ListHead is NULL then it must be callee freed.\r
624\r
625 @param[in] Arg The pointer to path string.\r
626 @param[in] OpenMode Mode to open files with.\r
627 @param[in, out] ListHead Head of linked list of results.\r
628\r
629 @retval EFI_SUCCESS The operation was sucessful and the list head\r
630 contains the list of opened files.\r
631 @retval != EFI_SUCCESS The operation failed.\r
632\r
633 @sa InternalShellConvertFileListType\r
634**/\r
635EFI_STATUS\r
636EFIAPI\r
637ShellOpenFileMetaArg (\r
638 IN CHAR16 *Arg,\r
639 IN UINT64 OpenMode,\r
640 IN OUT EFI_SHELL_FILE_INFO **ListHead\r
641 );\r
642\r
643/**\r
644 Free the linked list returned from ShellOpenFileMetaArg.\r
645\r
646 @param[in, out] ListHead The pointer to free.\r
647\r
648 @retval EFI_SUCCESS The operation was sucessful.\r
649 @retval EFI_INVALID_PARAMETER A parameter was invalid.\r
650**/\r
651EFI_STATUS\r
652EFIAPI\r
653ShellCloseFileMetaArg (\r
654 IN OUT EFI_SHELL_FILE_INFO **ListHead\r
655 );\r
656\r
657/**\r
658 Find a file by searching the CWD and then the path.\r
659\r
660 If FileName is NULL, then ASSERT.\r
661\r
662 If the return value is not NULL then the memory must be caller freed.\r
663\r
664 @param[in] FileName Filename string.\r
665\r
666 @retval NULL The file was not found.\r
667 @retval !NULL The path to the file.\r
668**/\r
669CHAR16 *\r
670EFIAPI\r
671ShellFindFilePath (\r
672 IN CONST CHAR16 *FileName\r
673 );\r
674\r
675/**\r
676 Find a file by searching the CWD and then the path with a variable set of file\r
677 extensions. If the file is not found it will append each extension in the list\r
678 in the order provided and return the first one that is successful.\r
679\r
680 If FileName is NULL, then ASSERT.\r
681 If FileExtension is NULL, then the behavior is identical to ShellFindFilePath.\r
682\r
683 If the return value is not NULL then the memory must be caller freed.\r
684\r
685 @param[in] FileName The filename string.\r
686 @param[in] FileExtension Semicolon delimited list of possible extensions.\r
687\r
688 @retval NULL The file was not found.\r
689 @retval !NULL The path to the file.\r
690**/\r
691CHAR16 *\r
692EFIAPI\r
693ShellFindFilePathEx (\r
694 IN CONST CHAR16 *FileName,\r
695 IN CONST CHAR16 *FileExtension\r
696 );\r
697\r
698typedef enum {\r
699 TypeFlag = 0, ///< A flag that is present or not present only (IE "-a").\r
700 TypeValue, ///< A flag that has some data following it with a space (IE "-a 1").\r
701 TypePosition, ///< Some data that did not follow a parameter (IE "filename.txt").\r
702 TypeStart, ///< A flag that has variable value appended to the end (IE "-ad", "-afd", "-adf", etc...).\r
703 TypeDoubleValue, ///< A flag that has 2 space seperated value data following it (IE "-a 1 2").\r
704 TypeMaxValue, ///< A flag followed by all the command line data before the next flag.\r
705 TypeTimeValue, ///< A flag that has a time value following it (IE "-a -5:00").\r
706 TypeMax,\r
707} SHELL_PARAM_TYPE;\r
708\r
709typedef struct {\r
710 CHAR16 *Name;\r
711 SHELL_PARAM_TYPE Type;\r
712} SHELL_PARAM_ITEM;\r
713\r
714\r
715/// Helper structure for no parameters (besides -? and -b)\r
716extern SHELL_PARAM_ITEM EmptyParamList[];\r
717\r
718/// Helper structure for -sfo only (besides -? and -b)\r
719extern SHELL_PARAM_ITEM SfoParamList[];\r
720\r
721/**\r
722 Checks the command line arguments passed against the list of valid ones.\r
723 Optionally removes NULL values first.\r
724\r
725 If no initialization is required, then return RETURN_SUCCESS.\r
726\r
727 @param[in] CheckList The pointer to list of parameters to check.\r
728 @param[out] CheckPackage The package of checked values.\r
729 @param[out] ProblemParam Optional pointer to pointer to unicode string for\r
730 the paramater that caused failure.\r
731 @param[in] AutoPageBreak Will automatically set PageBreakEnabled.\r
732 @param[in] AlwaysAllowNumbers Will never fail for number based flags.\r
733\r
734 @retval EFI_SUCCESS The operation completed sucessfully.\r
735 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
736 @retval EFI_INVALID_PARAMETER A parameter was invalid.\r
737 @retval EFI_VOLUME_CORRUPTED The command line was corrupt.\r
738 @retval EFI_DEVICE_ERROR The commands contained 2 opposing arguments. One\r
739 of the command line arguments was returned in\r
740 ProblemParam if provided.\r
741 @retval EFI_NOT_FOUND A argument required a value that was missing.\r
742 The invalid command line argument was returned in\r
743 ProblemParam if provided.\r
744**/\r
745EFI_STATUS\r
746EFIAPI\r
747ShellCommandLineParseEx (\r
748 IN CONST SHELL_PARAM_ITEM *CheckList,\r
749 OUT LIST_ENTRY **CheckPackage,\r
750 OUT CHAR16 **ProblemParam OPTIONAL,\r
751 IN BOOLEAN AutoPageBreak,\r
752 IN BOOLEAN AlwaysAllowNumbers\r
753 );\r
754\r
755/// Make it easy to upgrade from older versions of the shell library.\r
756#define ShellCommandLineParse(CheckList,CheckPackage,ProblemParam,AutoPageBreak) ShellCommandLineParseEx(CheckList,CheckPackage,ProblemParam,AutoPageBreak,FALSE)\r
757\r
758/**\r
759 Frees shell variable list that was returned from ShellCommandLineParse.\r
760\r
761 This function will free all the memory that was used for the CheckPackage\r
762 list of postprocessed shell arguments.\r
763\r
764 If CheckPackage is NULL, then return.\r
765\r
766 @param[in] CheckPackage The list to de-allocate.\r
767 **/\r
768VOID\r
769EFIAPI\r
770ShellCommandLineFreeVarList (\r
771 IN LIST_ENTRY *CheckPackage\r
772 );\r
773\r
774/**\r
775 Checks for presence of a flag parameter.\r
776\r
777 Flag arguments are in the form of "-<Key>" or "/<Key>", but do not have a value following the key.\r
778\r
779 If CheckPackage is NULL then return FALSE.\r
780 If KeyString is NULL then ASSERT().\r
781\r
782 @param[in] CheckPackage The package of parsed command line arguments.\r
783 @param[in] KeyString The Key of the command line argument to check for.\r
784\r
785 @retval TRUE The flag is on the command line.\r
786 @retval FALSE The flag is not on the command line.\r
787**/\r
788BOOLEAN\r
789EFIAPI\r
790ShellCommandLineGetFlag (\r
791 IN CONST LIST_ENTRY * CONST CheckPackage,\r
792 IN CONST CHAR16 * CONST KeyString\r
793 );\r
794\r
795/**\r
796 Returns value from command line argument.\r
797\r
798 Value parameters are in the form of "-<Key> value" or "/<Key> value".\r
799\r
800 If CheckPackage is NULL, then return NULL.\r
801\r
802 @param[in] CheckPackage The package of parsed command line arguments.\r
803 @param[in] KeyString The Key of the command line argument to check for.\r
804\r
805 @retval NULL The flag is not on the command line.\r
806 @retval !=NULL The pointer to unicode string of the value.\r
807**/\r
808CONST CHAR16*\r
809EFIAPI\r
810ShellCommandLineGetValue (\r
811 IN CONST LIST_ENTRY *CheckPackage,\r
812 IN CHAR16 *KeyString\r
813 );\r
814\r
815/**\r
816 Returns raw value from command line argument.\r
817\r
818 Raw value parameters are in the form of "value" in a specific position in the list.\r
819\r
820 If CheckPackage is NULL, then return NULL.\r
821\r
822 @param[in] CheckPackage The package of parsed command line arguments.\r
823 @param[in] Position The position of the value.\r
824\r
825 @retval NULL The flag is not on the command line.\r
826 @retval !=NULL The pointer to unicode string of the value.\r
827**/\r
828CONST CHAR16*\r
829EFIAPI\r
830ShellCommandLineGetRawValue (\r
831 IN CONST LIST_ENTRY * CONST CheckPackage,\r
832 IN UINTN Position\r
833 );\r
834\r
835/**\r
836 Returns the number of command line value parameters that were parsed.\r
837\r
838 This will not include flags.\r
839\r
840 @param[in] CheckPackage The package of parsed command line arguments.\r
841\r
842 @retval (UINTN)-1 No parsing has occurred.\r
843 @retval other The number of value parameters found.\r
844**/\r
845UINTN\r
846EFIAPI\r
847ShellCommandLineGetCount(\r
848 IN CONST LIST_ENTRY *CheckPackage\r
849 );\r
850\r
851/**\r
852 Determines if a parameter is duplicated.\r
853\r
854 If Param is not NULL, then it will point to a callee-allocated string buffer\r
855 with the parameter value, if a duplicate is found.\r
856\r
857 If CheckPackage is NULL, then ASSERT.\r
858\r
859 @param[in] CheckPackage The package of parsed command line arguments.\r
860 @param[out] Param Upon finding one, a pointer to the duplicated parameter.\r
861\r
862 @retval EFI_SUCCESS No parameters were duplicated.\r
863 @retval EFI_DEVICE_ERROR A duplicate was found.\r
864 **/\r
865EFI_STATUS\r
866EFIAPI\r
867ShellCommandLineCheckDuplicate (\r
868 IN CONST LIST_ENTRY *CheckPackage,\r
869 OUT CHAR16 **Param\r
870 );\r
871\r
872/**\r
873 This function causes the shell library to initialize itself. If the shell library\r
874 is already initialized it will de-initialize all the current protocol pointers and\r
875 re-populate them again.\r
876\r
877 When the library is used with PcdShellLibAutoInitialize set to true this function\r
878 will return EFI_SUCCESS and perform no actions.\r
879\r
880 This function is intended for internal access for shell commands only.\r
881\r
882 @retval EFI_SUCCESS The initialization was complete sucessfully.\r
883\r
884**/\r
885EFI_STATUS\r
886EFIAPI\r
887ShellInitialize (\r
888 VOID\r
889 );\r
890\r
891/**\r
892 Print at a specific location on the screen.\r
893\r
894 This function will move the cursor to a given screen location and print the specified string.\r
895\r
896 If -1 is specified for either the Row or Col the current screen location for BOTH\r
897 will be used.\r
898\r
899 If either Row or Col is out of range for the current console, then ASSERT.\r
900 If Format is NULL, then ASSERT.\r
901\r
902 In addition to the standard %-based flags as supported by UefiLib Print() this supports\r
903 the following additional flags:\r
904 %N - Set output attribute to normal\r
905 %H - Set output attribute to highlight\r
906 %E - Set output attribute to error\r
907 %B - Set output attribute to blue color\r
908 %V - Set output attribute to green color\r
909\r
910 Note: The background color is controlled by the shell command cls.\r
911\r
912 @param[in] Col The column to print at.\r
913 @param[in] Row The row to print at.\r
914 @param[in] Format The format string.\r
915 @param[in] ... The variable argument list.\r
916\r
917 @return EFI_SUCCESS The printing was successful.\r
918 @return EFI_DEVICE_ERROR The console device reported an error.\r
919**/\r
920EFI_STATUS\r
921EFIAPI\r
922ShellPrintEx(\r
923 IN INT32 Col OPTIONAL,\r
924 IN INT32 Row OPTIONAL,\r
925 IN CONST CHAR16 *Format,\r
926 ...\r
927 );\r
928\r
929/**\r
930 Print at a specific location on the screen.\r
931\r
932 This function will move the cursor to a given screen location and print the specified string.\r
933\r
934 If -1 is specified for either the Row or Col the current screen location for BOTH\r
935 will be used.\r
936\r
937 If either Row or Col is out of range for the current console, then ASSERT.\r
938 If Format is NULL, then ASSERT.\r
939\r
940 In addition to the standard %-based flags as supported by UefiLib Print() this supports\r
941 the following additional flags:\r
942 %N - Set output attribute to normal.\r
943 %H - Set output attribute to highlight.\r
944 %E - Set output attribute to error.\r
945 %B - Set output attribute to blue color.\r
946 %V - Set output attribute to green color.\r
947\r
948 Note: The background color is controlled by the shell command cls.\r
949\r
950 @param[in] Col The column to print at.\r
951 @param[in] Row The row to print at.\r
952 @param[in] Language The language of the string to retrieve. If this parameter\r
953 is NULL, then the current platform language is used.\r
954 @param[in] HiiFormatStringId The format string Id for getting from Hii.\r
955 @param[in] HiiFormatHandle The format string Handle for getting from Hii.\r
956 @param[in] ... The variable argument list.\r
957\r
958 @return EFI_SUCCESS The printing was successful.\r
959 @return EFI_DEVICE_ERROR The console device reported an error.\r
960**/\r
961EFI_STATUS\r
962EFIAPI\r
963ShellPrintHiiEx(\r
964 IN INT32 Col OPTIONAL,\r
965 IN INT32 Row OPTIONAL,\r
966 IN CONST CHAR8 *Language OPTIONAL,\r
967 IN CONST EFI_STRING_ID HiiFormatStringId,\r
968 IN CONST EFI_HII_HANDLE HiiFormatHandle,\r
969 ...\r
970 );\r
971\r
972/**\r
973 Function to determine if a given filename represents a directory.\r
974\r
975 If DirName is NULL, then ASSERT.\r
976\r
977 @param[in] DirName Path to directory to test.\r
978\r
979 @retval EFI_SUCCESS The Path represents a directory.\r
980 @retval EFI_NOT_FOUND The Path does not represent a directory.\r
981 @retval other The path failed to open.\r
982**/\r
983EFI_STATUS\r
984EFIAPI\r
985ShellIsDirectory(\r
986 IN CONST CHAR16 *DirName\r
987 );\r
988\r
989/**\r
990 Function to determine if a given filename represents a file.\r
991\r
992 This will search the CWD only.\r
993\r
994 If Name is NULL, then ASSERT.\r
995\r
996 @param[in] Name Path to file to test.\r
997\r
998 @retval EFI_SUCCESS The Path represents a file.\r
999 @retval EFI_NOT_FOUND The Path does not represent a file.\r
1000 @retval other The path failed to open.\r
1001**/\r
1002EFI_STATUS\r
1003EFIAPI\r
1004ShellIsFile(\r
1005 IN CONST CHAR16 *Name\r
1006 );\r
1007\r
1008/**\r
1009 Function to determine if a given filename represents a file.\r
1010\r
1011 This will search the CWD and then the Path.\r
1012\r
1013 If Name is NULL, then ASSERT.\r
1014\r
1015 @param[in] Name Path to file to test.\r
1016\r
1017 @retval EFI_SUCCESS The Path represents a file.\r
1018 @retval EFI_NOT_FOUND The Path does not represent a file.\r
1019 @retval other The path failed to open.\r
1020**/\r
1021EFI_STATUS\r
1022EFIAPI\r
1023ShellIsFileInPath(\r
1024 IN CONST CHAR16 *Name\r
1025 );\r
1026\r
1027/**\r
1028 Function to determine whether a string is decimal or hex representation of a number\r
1029 and return the number converted from the string.\r
1030\r
1031 Note: this function cannot be used when (UINTN)(-1), (0xFFFFFFFF) may be a valid\r
1032 result. Use ShellConvertStringToUint64 instead.\r
1033\r
1034 @param[in] String String representation of a number.\r
1035\r
1036 @return The unsigned integer result of the conversion.\r
1037 @retval (UINTN)(-1) An error occured.\r
1038**/\r
1039UINTN\r
1040EFIAPI\r
1041ShellStrToUintn(\r
1042 IN CONST CHAR16 *String\r
1043 );\r
1044\r
1045/**\r
1046 Function return the number converted from a hex representation of a number.\r
1047\r
1048 Note: this function cannot be used when (UINTN)(-1), (0xFFFFFFFF) may be a valid\r
1049 result. Use ShellConvertStringToUint64 instead.\r
1050\r
1051 @param[in] String String representation of a number.\r
1052\r
1053 @return The unsigned integer result of the conversion.\r
1054 @retval (UINTN)(-1) An error occured.\r
1055**/\r
1056UINTN\r
1057EFIAPI\r
1058ShellHexStrToUintn(\r
1059 IN CONST CHAR16 *String\r
1060 );\r
1061\r
1062/**\r
1063 Safely append with automatic string resizing given length of Destination and\r
1064 desired length of copy from Source.\r
1065\r
1066 Append the first D characters of Source to the end of Destination, where D is\r
1067 the lesser of Count and the StrLen() of Source. If appending those D characters\r
1068 will fit within Destination (whose Size is given as CurrentSize) and\r
1069 still leave room for a NULL terminator, then those characters are appended,\r
1070 starting at the original terminating NULL of Destination, and a new terminating\r
1071 NULL is appended.\r
1072\r
1073 If appending D characters onto Destination will result in a overflow of the size\r
1074 given in CurrentSize the string will be grown such that the copy can be performed\r
1075 and CurrentSize will be updated to the new size.\r
1076\r
1077 If Source is NULL, there is nothing to append, so return the current buffer in\r
1078 Destination.\r
1079\r
1080 If Destination is NULL, then ASSERT().\r
1081 If Destination's current length (including NULL terminator) is already more than\r
1082 CurrentSize, then ASSERT().\r
1083\r
1084 @param[in, out] Destination The String to append onto.\r
1085 @param[in, out] CurrentSize On call, the number of bytes in Destination. On\r
1086 return, possibly the new size (still in bytes). If NULL,\r
1087 then allocate whatever is needed.\r
1088 @param[in] Source The String to append from.\r
1089 @param[in] Count The maximum number of characters to append. If 0, then\r
1090 all are appended.\r
1091\r
1092 @return The Destination after appending the Source.\r
1093**/\r
1094CHAR16*\r
1095EFIAPI\r
1096StrnCatGrow (\r
1097 IN OUT CHAR16 **Destination,\r
1098 IN OUT UINTN *CurrentSize,\r
1099 IN CONST CHAR16 *Source,\r
1100 IN UINTN Count\r
1101 );\r
1102\r
1103/**\r
1104 This is a find and replace function. Upon successful return the NewString is a copy of\r
1105 SourceString with each instance of FindTarget replaced with ReplaceWith.\r
1106\r
1107 If SourceString and NewString overlap the behavior is undefined.\r
1108\r
1109 If the string would grow bigger than NewSize it will halt and return error.\r
1110\r
1111 @param[in] SourceString The string with source buffer.\r
1112 @param[in, out] NewString The string with resultant buffer.\r
1113 @param[in] NewSize The size in bytes of NewString.\r
1114 @param[in] FindTarget The string to look for.\r
1115 @param[in] ReplaceWith The string to replace FindTarget with.\r
1116 @param[in] SkipPreCarrot If TRUE will skip a FindTarget that has a '^'\r
1117 immediately before it.\r
1118 @param[in] ParameterReplacing If TRUE will add "" around items with spaces.\r
1119\r
1120 @retval EFI_INVALID_PARAMETER SourceString was NULL.\r
1121 @retval EFI_INVALID_PARAMETER NewString was NULL.\r
1122 @retval EFI_INVALID_PARAMETER FindTarget was NULL.\r
1123 @retval EFI_INVALID_PARAMETER ReplaceWith was NULL.\r
1124 @retval EFI_INVALID_PARAMETER FindTarget had length < 1.\r
1125 @retval EFI_INVALID_PARAMETER SourceString had length < 1.\r
1126 @retval EFI_BUFFER_TOO_SMALL NewSize was less than the minimum size to hold\r
1127 the new string (truncation occurred).\r
1128 @retval EFI_SUCCESS The string was successfully copied with replacement.\r
1129**/\r
1130EFI_STATUS\r
1131EFIAPI\r
1132ShellCopySearchAndReplace(\r
1133 IN CHAR16 CONST *SourceString,\r
1134 IN OUT CHAR16 *NewString,\r
1135 IN UINTN NewSize,\r
1136 IN CONST CHAR16 *FindTarget,\r
1137 IN CONST CHAR16 *ReplaceWith,\r
1138 IN CONST BOOLEAN SkipPreCarrot,\r
1139 IN CONST BOOLEAN ParameterReplacing\r
1140 );\r
1141\r
1142/**\r
1143 Check if a Unicode character is a hexadecimal character.\r
1144\r
1145 This internal function checks if a Unicode character is a\r
1146 numeric character. The valid hexadecimal characters are\r
1147 L'0' to L'9', L'a' to L'f', or L'A' to L'F'.\r
1148\r
1149\r
1150 @param Char The character to check against.\r
1151\r
1152 @retval TRUE The Char is a hexadecmial character.\r
1153 @retval FALSE The Char is not a hexadecmial character.\r
1154\r
1155**/\r
1156BOOLEAN\r
1157EFIAPI\r
1158ShellIsHexaDecimalDigitCharacter (\r
1159 IN CHAR16 Char\r
1160 );\r
1161\r
1162/**\r
1163 Check if a Unicode character is a decimal character.\r
1164\r
1165 This internal function checks if a Unicode character is a\r
1166 decimal character. The valid characters are\r
1167 L'0' to L'9'.\r
1168\r
1169\r
1170 @param Char The character to check against.\r
1171\r
1172 @retval TRUE The Char is a hexadecmial character.\r
1173 @retval FALSE The Char is not a hexadecmial character.\r
1174\r
1175**/\r
1176BOOLEAN\r
1177EFIAPI\r
1178ShellIsDecimalDigitCharacter (\r
1179 IN CHAR16 Char\r
1180 );\r
1181\r
1182///\r
1183/// What type of answer is requested.\r
1184///\r
1185typedef enum {\r
1186 ShellPromptResponseTypeYesNo,\r
1187 ShellPromptResponseTypeYesNoCancel,\r
1188 ShellPromptResponseTypeFreeform,\r
1189 ShellPromptResponseTypeQuitContinue,\r
1190 ShellPromptResponseTypeYesNoAllCancel,\r
1191 ShellPromptResponseTypeEnterContinue,\r
1192 ShellPromptResponseTypeAnyKeyContinue,\r
1193 ShellPromptResponseTypeMax\r
1194} SHELL_PROMPT_REQUEST_TYPE;\r
1195\r
1196///\r
1197/// What answer was given.\r
1198///\r
1199typedef enum {\r
1200 ShellPromptResponseYes,\r
1201 ShellPromptResponseNo,\r
1202 ShellPromptResponseCancel,\r
1203 ShellPromptResponseQuit,\r
1204 ShellPromptResponseContinue,\r
1205 ShellPromptResponseAll,\r
1206 ShellPromptResponseMax\r
1207} SHELL_PROMPT_RESPONSE;\r
1208\r
1209/**\r
1210 Prompt the user and return the resultant answer to the requestor.\r
1211\r
1212 This function will display the requested question on the shell prompt and then\r
1213 wait for an appropriate answer to be input from the console.\r
1214\r
1215 If the SHELL_PROMPT_REQUEST_TYPE is SHELL_PROMPT_REQUEST_TYPE_YESNO, ShellPromptResponseTypeQuitContinue\r
1216 or SHELL_PROMPT_REQUEST_TYPE_YESNOCANCEL then *Response is of type SHELL_PROMPT_RESPONSE.\r
1217\r
1218 If the SHELL_PROMPT_REQUEST_TYPE is ShellPromptResponseTypeFreeform then *Response is of type\r
1219 CHAR16*.\r
1220\r
1221 In either case *Response must be callee freed if Response was not NULL;\r
1222\r
1223 @param Type What type of question is asked. This is used to filter the input\r
1224 to prevent invalid answers to question.\r
1225 @param Prompt The pointer to a string prompt used to request input.\r
1226 @param Response The pointer to Response, which will be populated upon return.\r
1227\r
1228 @retval EFI_SUCCESS The operation was successful.\r
1229 @retval EFI_UNSUPPORTED The operation is not supported as requested.\r
1230 @retval EFI_INVALID_PARAMETER A parameter was invalid.\r
1231 @return other The operation failed.\r
1232**/\r
1233EFI_STATUS\r
1234EFIAPI\r
1235ShellPromptForResponse (\r
1236 IN SHELL_PROMPT_REQUEST_TYPE Type,\r
1237 IN CHAR16 *Prompt OPTIONAL,\r
1238 IN OUT VOID **Response OPTIONAL\r
1239 );\r
1240\r
1241/**\r
1242 Prompt the user and return the resultant answer to the requestor.\r
1243\r
1244 This function is the same as ShellPromptForResponse, except that the prompt is\r
1245 automatically pulled from HII.\r
1246\r
1247 @param[in] Type What type of question is asked. This is used to filter the input\r
1248 to prevent invalid answers to question.\r
1249 @param[in] HiiFormatStringId The format string Id for getting from Hii.\r
1250 @param[in] HiiFormatHandle The format string Handle for getting from Hii.\r
1251 @param[in, out] Response The pointer to Response, which will be populated upon return.\r
1252\r
1253 @retval EFI_SUCCESS The operation was sucessful.\r
1254 @return other The operation failed.\r
1255\r
1256 @sa ShellPromptForResponse\r
1257**/\r
1258EFI_STATUS\r
1259EFIAPI\r
1260ShellPromptForResponseHii (\r
1261 IN SHELL_PROMPT_REQUEST_TYPE Type,\r
1262 IN CONST EFI_STRING_ID HiiFormatStringId,\r
1263 IN CONST EFI_HII_HANDLE HiiFormatHandle,\r
1264 IN OUT VOID **Response\r
1265 );\r
1266\r
1267/**\r
1268 Function to determin if an entire string is a valid number.\r
1269\r
1270 If Hex it must be preceeded with a 0x, 0X, or has ForceHex set TRUE.\r
1271\r
1272 @param[in] String The string to evaluate.\r
1273 @param[in] ForceHex TRUE - always assume hex.\r
1274 @param[in] StopAtSpace TRUE to halt upon finding a space, FALSE to keep going.\r
1275\r
1276 @retval TRUE It is all numeric (dec/hex) characters.\r
1277 @retval FALSE There is a non-numeric character.\r
1278**/\r
1279BOOLEAN\r
1280EFIAPI\r
1281ShellIsHexOrDecimalNumber (\r
1282 IN CONST CHAR16 *String,\r
1283 IN CONST BOOLEAN ForceHex,\r
1284 IN CONST BOOLEAN StopAtSpace\r
1285 );\r
1286\r
1287/**\r
1288 Function to verify and convert a string to its numerical 64 bit representation.\r
1289\r
1290 If Hex it must be preceeded with a 0x, 0X, or has ForceHex set TRUE.\r
1291\r
1292 @param[in] String The string to evaluate.\r
1293 @param[out] Value Upon a successful return the value of the conversion.\r
1294 @param[in] ForceHex TRUE - always assume hex.\r
1295 @param[in] StopAtSpace TRUE to halt upon finding a space, FALSE to\r
1296 process the entire String.\r
1297\r
1298 @retval EFI_SUCCESS The conversion was successful.\r
1299 @retval EFI_INVALID_PARAMETER String contained an invalid character.\r
1300 @retval EFI_NOT_FOUND String was a number, but Value was NULL.\r
1301**/\r
1302EFI_STATUS\r
1303EFIAPI\r
1304ShellConvertStringToUint64(\r
1305 IN CONST CHAR16 *String,\r
1306 OUT UINT64 *Value,\r
1307 IN CONST BOOLEAN ForceHex,\r
1308 IN CONST BOOLEAN StopAtSpace\r
1309 );\r
1310\r
1311/**\r
1312 Function to determine if a given filename exists.\r
1313\r
1314 @param[in] Name Path to test.\r
1315\r
1316 @retval EFI_SUCCESS The Path represents a file.\r
1317 @retval EFI_NOT_FOUND The Path does not represent a file.\r
1318 @retval other The path failed to open.\r
1319**/\r
1320EFI_STATUS\r
1321EFIAPI\r
1322ShellFileExists(\r
1323 IN CONST CHAR16 *Name\r
1324 );\r
1325\r
1326/**\r
1327 Function to read a single line from a SHELL_FILE_HANDLE. The \n is not included in the returned\r
1328 buffer. The returned buffer must be callee freed.\r
1329\r
1330 If the position upon start is 0, then the Ascii Boolean will be set. This should be\r
1331 maintained and not changed for all operations with the same file.\r
1332\r
1333 @param[in] Handle SHELL_FILE_HANDLE to read from.\r
1334 @param[in, out] Ascii Boolean value for indicating whether the file is\r
1335 Ascii (TRUE) or UCS2 (FALSE).\r
1336\r
1337 @return The line of text from the file.\r
1338\r
1339 @sa ShellFileHandleReadLine\r
1340**/\r
1341CHAR16*\r
1342EFIAPI\r
1343ShellFileHandleReturnLine(\r
1344 IN SHELL_FILE_HANDLE Handle,\r
1345 IN OUT BOOLEAN *Ascii\r
1346 );\r
1347\r
1348/**\r
1349 Function to read a single line (up to but not including the \n) from a SHELL_FILE_HANDLE.\r
1350\r
1351 If the position upon start is 0, then the Ascii Boolean will be set. This should be\r
1352 maintained and not changed for all operations with the same file.\r
1353\r
1354 @param[in] Handle SHELL_FILE_HANDLE to read from.\r
1355 @param[in, out] Buffer The pointer to buffer to read into.\r
1356 @param[in, out] Size The pointer to number of bytes in Buffer.\r
1357 @param[in] Truncate If the buffer is large enough, this has no effect.\r
1358 If the buffer is is too small and Truncate is TRUE,\r
1359 the line will be truncated.\r
1360 If the buffer is is too small and Truncate is FALSE,\r
1361 then no read will occur.\r
1362\r
1363 @param[in, out] Ascii Boolean value for indicating whether the file is\r
1364 Ascii (TRUE) or UCS2 (FALSE).\r
1365\r
1366 @retval EFI_SUCCESS The operation was successful. The line is stored in\r
1367 Buffer.\r
1368 @retval EFI_END_OF_FILE There are no more lines in the file.\r
1369 @retval EFI_INVALID_PARAMETER Handle was NULL.\r
1370 @retval EFI_INVALID_PARAMETER Size was NULL.\r
1371 @retval EFI_BUFFER_TOO_SMALL Size was not large enough to store the line.\r
1372 Size was updated to the minimum space required.\r
1373**/\r
1374EFI_STATUS\r
1375EFIAPI\r
1376ShellFileHandleReadLine(\r
1377 IN SHELL_FILE_HANDLE Handle,\r
1378 IN OUT CHAR16 *Buffer,\r
1379 IN OUT UINTN *Size,\r
1380 IN BOOLEAN Truncate,\r
1381 IN OUT BOOLEAN *Ascii\r
1382 );\r
1383\r
1384/**\r
1385 Function to delete a file by name\r
1386\r
1387 @param[in] FileName Pointer to file name to delete.\r
1388\r
1389 @retval EFI_SUCCESS the file was deleted sucessfully\r
1390 @retval EFI_WARN_DELETE_FAILURE the handle was closed, but the file was not\r
1391 deleted\r
1392 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
1393 @retval EFI_NOT_FOUND The specified file could not be found on the\r
1394 device or the file system could not be found\r
1395 on the device.\r
1396 @retval EFI_NO_MEDIA The device has no medium.\r
1397 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the\r
1398 medium is no longer supported.\r
1399 @retval EFI_DEVICE_ERROR The device reported an error.\r
1400 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
1401 @retval EFI_WRITE_PROTECTED The file or medium is write protected.\r
1402 @retval EFI_ACCESS_DENIED The file was opened read only.\r
1403 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the\r
1404 file.\r
1405 @retval other The file failed to open\r
1406**/\r
1407EFI_STATUS\r
1408EFIAPI\r
1409ShellDeleteFileByName(\r
1410 IN CONST CHAR16 *FileName\r
1411 );\r
1412\r
1413/**\r
1414 Function to print help file / man page content in the spec from the UEFI Shell protocol GetHelpText function.\r
1415\r
1416 @param[in] CommandToGetHelpOn Pointer to a string containing the command name of help file to be printed.\r
1417 @param[in] SectionToGetHelpOn Pointer to the section specifier(s).\r
1418 @param[in] PrintCommandText If TRUE, prints the command followed by the help content, otherwise prints\r
1419 the help content only.\r
1420 @retval EFI_DEVICE_ERROR The help data format was incorrect.\r
1421 @retval EFI_NOT_FOUND The help data could not be found.\r
1422 @retval EFI_SUCCESS The operation was successful.\r
1423**/\r
1424EFI_STATUS\r
1425EFIAPI\r
1426ShellPrintHelp (\r
1427 IN CONST CHAR16 *CommandToGetHelpOn,\r
1428 IN CONST CHAR16 *SectionToGetHelpOn,\r
1429 IN BOOLEAN PrintCommandText\r
1430 );\r
1431\r
1432#endif // __SHELL_LIB__\r