]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Application/Shell/ShellProtocol.h
fixes for IPF, CTRL-C support, and file redirection.
[mirror_edk2.git] / ShellPkg / Application / Shell / ShellProtocol.h
1 /** @file
2 Member functions of EFI_SHELL_PROTOCOL and functions for creation,
3 manipulation, and initialization of EFI_SHELL_PROTOCOL.
4
5 Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>
6 This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
10
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
13
14 **/
15
16 #ifndef _SHELL_PROTOCOL_HEADER_
17 #define _SHELL_PROTOCOL_HEADER_
18
19 #include <Uefi.h>
20 #include <ShellBase.h>
21
22 #include <Guid/ShellVariableGuid.h>
23 #include <Guid/ShellMapGuid.h>
24 #include <Guid/ShellAliasGuid.h>
25
26 #include <Protocol/EfiShell.h>
27 #include <Protocol/EfiShellParameters.h>
28 #include <Protocol/SimpleFileSystem.h>
29 #include <Protocol/DevicePathToText.h>
30 #include <Protocol/ComponentName2.h>
31 #include <Protocol/LoadedImage.h>
32 #include <Protocol/UnicodeCollation.h>
33 #include <Protocol/DevicePath.h>
34 #include <Protocol/SimpleTextInEx.h>
35
36 #include <Library/UefiBootServicesTableLib.h>
37 #include <Library/BaseLib.h>
38 #include <Library/ShellCommandLib.h>
39 #include <Library/PrintLib.h>
40 #include <Library/DevicePathLib.h>
41 #include <Library/UefiRuntimeServicesTableLib.h>
42 #include <Library/DebugLib.h>
43 #include <Library/MemoryAllocationLib.h>
44 #include <Library/BaseMemoryLib.h>
45 #include <Library/UefiLib.h>
46 #include <Library/SortLib.h>
47 #include <Library/PcdLib.h>
48 #include <Library/ShellLib.h>
49
50 #include "FileHandleWrappers.h"
51 #include "ShellEnvVar.h"
52 #include "ShellManParser.h"
53
54 typedef struct {
55 LIST_ENTRY Link;
56 EFI_SHELL_PROTOCOL *Interface;
57 EFI_HANDLE Handle;
58 } SHELL_PROTOCOL_HANDLE_LIST;
59
60 // flags values...
61 #define SHELL_MAP_FLAGS_CONSIST BIT1
62
63 /**
64 Function to create and install on the current handle.
65
66 Will overwrite any existing ShellProtocols in the system to be sure that
67 the current shell is in control.
68
69 This must be removed via calling CleanUpShellProtocol().
70
71 @param[in,out] NewShell The pointer to the pointer to the structure
72 to install.
73
74 @retval EFI_SUCCESS The operation was successful.
75 @return An error from LocateHandle, CreateEvent, or other core function.
76 **/
77 EFI_STATUS
78 EFIAPI
79 CreatePopulateInstallShellProtocol (
80 IN OUT EFI_SHELL_PROTOCOL **NewShell
81 );
82
83 /**
84 Opposite of CreatePopulateInstallShellProtocol.
85
86 Free all memory and restore the system to the state it was in before calling
87 CreatePopulateInstallShellProtocol.
88
89 @param[in,out] NewShell The pointer to the new shell protocol structure.
90
91 @retval EFI_SUCCESS The operation was successful.
92 **/
93 EFI_STATUS
94 EFIAPI
95 CleanUpShellProtocol (
96 IN OUT EFI_SHELL_PROTOCOL *NewShell
97 );
98
99 /**
100 This function creates a mapping for a device path.
101
102 @param DevicePath Points to the device path. If this is NULL and Mapping points to a valid mapping,
103 then the mapping will be deleted.
104 @param Mapping Points to the NULL-terminated mapping for the device path. Must end with a ':'
105
106 @retval EFI_SUCCESS Mapping created or deleted successfully.
107 @retval EFI_NO_MAPPING There is no handle that corresponds exactly to DevicePath. See the
108 boot service function LocateDevicePath().
109 @retval EFI_ACCESS_DENIED The mapping is a built-in alias.
110 @retval EFI_INVALID_PARAMETER Mapping was NULL
111 @retval EFI_INVALID_PARAMETER Mapping did not end with a ':'
112 @retval EFI_INVALID_PARAMETER DevicePath was not pointing at a device that had a SIMPLE_FILE_SYSTEM_PROTOCOL installed.
113 @retval EFI_NOT_FOUND There was no mapping found to delete
114 @retval EFI_OUT_OF_RESOURCES Memory allocation failed
115 **/
116 EFI_STATUS
117 EFIAPI
118 EfiShellSetMap(
119 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL,
120 IN CONST CHAR16 *Mapping
121 );
122
123 /**
124 Gets the device path from the mapping.
125
126 This function gets the device path associated with a mapping.
127
128 @param Mapping A pointer to the mapping
129
130 @retval !=NULL Pointer to the device path that corresponds to the
131 device mapping. The returned pointer does not need
132 to be freed.
133 @retval NULL There is no device path associated with the
134 specified mapping.
135 **/
136 CONST EFI_DEVICE_PATH_PROTOCOL *
137 EFIAPI
138 EfiShellGetDevicePathFromMap(
139 IN CONST CHAR16 *Mapping
140 );
141
142 /**
143 Gets the mapping that most closely matches the device path.
144
145 This function gets the mapping which corresponds to the device path *DevicePath. If
146 there is no exact match, then the mapping which most closely matches *DevicePath
147 is returned, and *DevicePath is updated to point to the remaining portion of the
148 device path. If there is an exact match, the mapping is returned and *DevicePath
149 points to the end-of-device-path node.
150
151 @param DevicePath On entry, points to a device path pointer. On
152 exit, updates the pointer to point to the
153 portion of the device path after the mapping.
154
155 @retval NULL No mapping was found.
156 @return !=NULL Pointer to NULL-terminated mapping. The buffer
157 is callee allocated and should be freed by the caller.
158 **/
159 CONST CHAR16 *
160 EFIAPI
161 EfiShellGetMapFromDevicePath(
162 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
163 );
164
165 /**
166 Converts a device path to a file system-style path.
167
168 This function converts a device path to a file system path by replacing part, or all, of
169 the device path with the file-system mapping. If there are more than one application
170 file system mappings, the one that most closely matches Path will be used.
171
172 @param Path The pointer to the device path
173
174 @retval NULL the device path could not be found.
175 @return all The pointer of the NULL-terminated file path. The path
176 is callee-allocated and should be freed by the caller.
177 **/
178 CHAR16 *
179 EFIAPI
180 EfiShellGetFilePathFromDevicePath(
181 IN CONST EFI_DEVICE_PATH_PROTOCOL *Path
182 );
183
184 /**
185 Converts a file system style name to a device path.
186
187 This function converts a file system style name to a device path, by replacing any
188 mapping references to the associated device path.
189
190 @param Path the pointer to the path
191
192 @return all The pointer of the file path. The file path is callee
193 allocated and should be freed by the caller.
194 **/
195 EFI_DEVICE_PATH_PROTOCOL *
196 EFIAPI
197 EfiShellGetDevicePathFromFilePath(
198 IN CONST CHAR16 *Path
199 );
200
201 /**
202 Gets the name of the device specified by the device handle.
203
204 This function gets the user-readable name of the device specified by the device
205 handle. If no user-readable name could be generated, then *BestDeviceName will be
206 NULL and EFI_NOT_FOUND will be returned.
207
208 If EFI_DEVICE_NAME_USE_COMPONENT_NAME is set, then the function will return the
209 device's name using the EFI_COMPONENT_NAME2_PROTOCOL, if present on
210 DeviceHandle.
211
212 If EFI_DEVICE_NAME_USE_DEVICE_PATH is set, then the function will return the
213 device's name using the EFI_DEVICE_PATH_PROTOCOL, if present on DeviceHandle.
214 If both EFI_DEVICE_NAME_USE_COMPONENT_NAME and
215 EFI_DEVICE_NAME_USE_DEVICE_PATH are set, then
216 EFI_DEVICE_NAME_USE_COMPONENT_NAME will have higher priority.
217
218 @param DeviceHandle The handle of the device.
219 @param Flags Determines the possible sources of component names.
220 Valid bits are:
221 EFI_DEVICE_NAME_USE_COMPONENT_NAME
222 EFI_DEVICE_NAME_USE_DEVICE_PATH
223 @param Language A pointer to the language specified for the device
224 name, in the same format as described in the UEFI
225 specification, Appendix M
226 @param BestDeviceName On return, points to the callee-allocated NULL-
227 terminated name of the device. If no device name
228 could be found, points to NULL. The name must be
229 freed by the caller...
230
231 @retval EFI_SUCCESS Get the name successfully.
232 @retval EFI_NOT_FOUND Fail to get the device name.
233 @retval EFI_INVALID_PARAMETER Flags did not have a valid bit set.
234 @retval EFI_INVALID_PARAMETER BestDeviceName was NULL
235 @retval EFI_INVALID_PARAMETER DeviceHandle was NULL
236 **/
237 EFI_STATUS
238 EFIAPI
239 EfiShellGetDeviceName(
240 IN EFI_HANDLE DeviceHandle,
241 IN EFI_SHELL_DEVICE_NAME_FLAGS Flags,
242 IN CHAR8 *Language,
243 OUT CHAR16 **BestDeviceName
244 );
245
246 /**
247 Opens the root directory of a device on a handle
248
249 This function opens the root directory of a device and returns a file handle to it.
250
251 @param DeviceHandle The handle of the device that contains the volume.
252 @param FileHandle On exit, points to the file handle corresponding to the root directory on the
253 device.
254
255 @retval EFI_SUCCESS Root opened successfully.
256 @retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be found or the root directory
257 could not be opened.
258 @retval EFI_VOLUME_CORRUPTED The data structures in the volume were corrupted.
259 @retval EFI_DEVICE_ERROR The device had an error
260 **/
261 EFI_STATUS
262 EFIAPI
263 EfiShellOpenRootByHandle(
264 IN EFI_HANDLE DeviceHandle,
265 OUT SHELL_FILE_HANDLE *FileHandle
266 );
267
268 /**
269 Opens the root directory of a device.
270
271 This function opens the root directory of a device and returns a file handle to it.
272
273 @param DevicePath Points to the device path corresponding to the device where the
274 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL is installed.
275 @param FileHandle On exit, points to the file handle corresponding to the root directory on the
276 device.
277
278 @retval EFI_SUCCESS Root opened successfully.
279 @retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be found or the root directory
280 could not be opened.
281 @retval EFI_VOLUME_CORRUPTED The data structures in the volume were corrupted.
282 @retval EFI_DEVICE_ERROR The device had an error
283 **/
284 EFI_STATUS
285 EFIAPI
286 EfiShellOpenRoot(
287 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
288 OUT SHELL_FILE_HANDLE *FileHandle
289 );
290
291 /**
292 Returns whether any script files are currently being processed.
293
294 @retval TRUE There is at least one script file active.
295 @retval FALSE No script files are active now.
296
297 **/
298 BOOLEAN
299 EFIAPI
300 EfiShellBatchIsActive (
301 VOID
302 );
303
304 /**
305 Worker function to open a file based on a device path. this will open the root
306 of the volume and then traverse down to the file itself.
307
308 @param DevicePath2 Device Path of the file
309 @param FileHandle Pointer to the file upon a successful return
310 @param OpenMode mode to open file in.
311 @param Attributes the File Attributes to use when creating a new file
312
313 @retval EFI_SUCCESS the file is open and FileHandle is valid
314 @retval EFI_UNSUPPORTED the device path cotained non-path elements
315 @retval other an error ocurred.
316 **/
317 EFI_STATUS
318 EFIAPI
319 InternalOpenFileDevicePath(
320 IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath2,
321 OUT SHELL_FILE_HANDLE *FileHandle,
322 IN UINT64 OpenMode,
323 IN UINT64 Attributes OPTIONAL
324 );
325
326 /**
327 Creates a file or directory by name.
328
329 This function creates an empty new file or directory with the specified attributes and
330 returns the new file's handle. If the file already exists and is read-only, then
331 EFI_INVALID_PARAMETER will be returned.
332
333 If the file already existed, it is truncated and its attributes updated. If the file is
334 created successfully, the FileHandle is the file's handle, else, the FileHandle is NULL.
335
336 If the file name begins with >v, then the file handle which is returned refers to the
337 shell environment variable with the specified name. If the shell environment variable
338 already exists and is non-volatile then EFI_INVALID_PARAMETER is returned.
339
340 @param FileName Pointer to NULL-terminated file path
341 @param FileAttribs The new file's attrbiutes. the different attributes are
342 described in EFI_FILE_PROTOCOL.Open().
343 @param FileHandle On return, points to the created file handle or directory's handle
344
345 @retval EFI_SUCCESS The file was opened. FileHandle points to the new file's handle.
346 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
347 @retval EFI_UNSUPPORTED could not open the file path
348 @retval EFI_NOT_FOUND the specified file could not be found on the devide, or could not
349 file the file system on the device.
350 @retval EFI_NO_MEDIA the device has no medium.
351 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no
352 longer supported.
353 @retval EFI_DEVICE_ERROR The device reported an error or can't get the file path according
354 the DirName.
355 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
356 @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write
357 when the media is write-protected.
358 @retval EFI_ACCESS_DENIED The service denied access to the file.
359 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file.
360 @retval EFI_VOLUME_FULL The volume is full.
361 **/
362 EFI_STATUS
363 EFIAPI
364 EfiShellCreateFile(
365 IN CONST CHAR16 *FileName,
366 IN UINT64 FileAttribs,
367 OUT SHELL_FILE_HANDLE *FileHandle
368 );
369
370 /**
371 Opens a file or a directory by file name.
372
373 This function opens the specified file in the specified OpenMode and returns a file
374 handle.
375 If the file name begins with >v, then the file handle which is returned refers to the
376 shell environment variable with the specified name. If the shell environment variable
377 exists, is non-volatile and the OpenMode indicates EFI_FILE_MODE_WRITE, then
378 EFI_INVALID_PARAMETER is returned.
379
380 If the file name is >i, then the file handle which is returned refers to the standard
381 input. If the OpenMode indicates EFI_FILE_MODE_WRITE, then EFI_INVALID_PARAMETER
382 is returned.
383
384 If the file name is >o, then the file handle which is returned refers to the standard
385 output. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER
386 is returned.
387
388 If the file name is >e, then the file handle which is returned refers to the standard
389 error. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER
390 is returned.
391
392 If the file name is NUL, then the file handle that is returned refers to the standard NUL
393 file. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER is
394 returned.
395
396 If return EFI_SUCCESS, the FileHandle is the opened file's handle, else, the
397 FileHandle is NULL.
398
399 @param FileName Points to the NULL-terminated UCS-2 encoded file name.
400 @param FileHandle On return, points to the file handle.
401 @param OpenMode File open mode. Either EFI_FILE_MODE_READ or
402 EFI_FILE_MODE_WRITE from section 12.4 of the UEFI
403 Specification.
404 @retval EFI_SUCCESS The file was opened. FileHandle has the opened file's handle.
405 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value. FileHandle is NULL.
406 @retval EFI_UNSUPPORTED Could not open the file path. FileHandle is NULL.
407 @retval EFI_NOT_FOUND The specified file could not be found on the device or the file
408 system could not be found on the device. FileHandle is NULL.
409 @retval EFI_NO_MEDIA The device has no medium. FileHandle is NULL.
410 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no
411 longer supported. FileHandle is NULL.
412 @retval EFI_DEVICE_ERROR The device reported an error or can't get the file path according
413 the FileName. FileHandle is NULL.
414 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. FileHandle is NULL.
415 @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write
416 when the media is write-protected. FileHandle is NULL.
417 @retval EFI_ACCESS_DENIED The service denied access to the file. FileHandle is NULL.
418 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file. FileHandle
419 is NULL.
420 @retval EFI_VOLUME_FULL The volume is full. FileHandle is NULL.
421 **/
422 EFI_STATUS
423 EFIAPI
424 EfiShellOpenFileByName(
425 IN CONST CHAR16 *FileName,
426 OUT SHELL_FILE_HANDLE *FileHandle,
427 IN UINT64 OpenMode
428 );
429
430 /**
431 Deletes the file specified by the file name.
432
433 This function deletes a file.
434
435 @param FileName Points to the NULL-terminated file name.
436
437 @retval EFI_SUCCESS The file was closed and deleted, and the handle was closed.
438 @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not deleted.
439 @sa EfiShellCreateFile
440 @sa FileHandleDelete
441 **/
442 EFI_STATUS
443 EFIAPI
444 EfiShellDeleteFileByName(
445 IN CONST CHAR16 *FileName
446 );
447
448 /**
449 Disables the page break output mode.
450 **/
451 VOID
452 EFIAPI
453 EfiShellDisablePageBreak (
454 VOID
455 );
456
457 /**
458 Enables the page break output mode.
459 **/
460 VOID
461 EFIAPI
462 EfiShellEnablePageBreak (
463 VOID
464 );
465
466 /**
467 internal worker function to run a command via Device Path
468
469 @param ParentImageHandle A handle of the image that is executing the specified
470 command line.
471 @param DevicePath device path of the file to execute
472 @param CommandLine Points to the NULL-terminated UCS-2 encoded string
473 containing the command line. If NULL then the command-
474 line will be empty.
475 @param Environment Points to a NULL-terminated array of environment
476 variables with the format 'x=y', where x is the
477 environment variable name and y is the value. If this
478 is NULL, then the current shell environment is used.
479 @param StatusCode Points to the status code returned by the command.
480
481 @retval EFI_SUCCESS The command executed successfully. The status code
482 returned by the command is pointed to by StatusCode.
483 @retval EFI_INVALID_PARAMETER The parameters are invalid.
484 @retval EFI_OUT_OF_RESOURCES Out of resources.
485 @retval EFI_UNSUPPORTED Nested shell invocations are not allowed.
486 **/
487 EFI_STATUS
488 EFIAPI
489 InternalShellExecuteDevicePath(
490 IN CONST EFI_HANDLE *ParentImageHandle,
491 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
492 IN CONST CHAR16 *CommandLine OPTIONAL,
493 IN CONST CHAR16 **Environment OPTIONAL,
494 OUT EFI_STATUS *StatusCode OPTIONAL
495 );
496
497 /**
498 Execute the command line.
499
500 This function creates a nested instance of the shell and executes the specified
501 command (CommandLine) with the specified environment (Environment). Upon return,
502 the status code returned by the specified command is placed in StatusCode.
503
504 If Environment is NULL, then the current environment is used and all changes made
505 by the commands executed will be reflected in the current environment. If the
506 Environment is non-NULL, then the changes made will be discarded.
507
508 The CommandLine is executed from the current working directory on the current
509 device.
510
511 @param ParentImageHandle A handle of the image that is executing the specified
512 command line.
513 @param CommandLine Points to the NULL-terminated UCS-2 encoded string
514 containing the command line. If NULL then the command-
515 line will be empty.
516 @param Environment Points to a NULL-terminated array of environment
517 variables with the format 'x=y', where x is the
518 environment variable name and y is the value. If this
519 is NULL, then the current shell environment is used.
520 @param StatusCode Points to the status code returned by the command.
521
522 @retval EFI_SUCCESS The command executed successfully. The status code
523 returned by the command is pointed to by StatusCode.
524 @retval EFI_INVALID_PARAMETER The parameters are invalid.
525 @retval EFI_OUT_OF_RESOURCES Out of resources.
526 @retval EFI_UNSUPPORTED Nested shell invocations are not allowed.
527 **/
528 EFI_STATUS
529 EFIAPI
530 EfiShellExecute(
531 IN EFI_HANDLE *ParentImageHandle,
532 IN CHAR16 *CommandLine OPTIONAL,
533 IN CHAR16 **Environment OPTIONAL,
534 OUT EFI_STATUS *StatusCode OPTIONAL
535 );
536
537 /**
538 Utility cleanup function for EFI_SHELL_FILE_INFO objects.
539
540 1) frees all pointers (non-NULL)
541 2) Closes the SHELL_FILE_HANDLE
542
543 @param FileListNode pointer to the list node to free
544 **/
545 VOID
546 EFIAPI
547 FreeShellFileInfoNode(
548 IN EFI_SHELL_FILE_INFO *FileListNode
549 );
550
551 /**
552 Frees the file list.
553
554 This function cleans up the file list and any related data structures. It has no
555 impact on the files themselves.
556
557 @param FileList The file list to free. Type EFI_SHELL_FILE_INFO is
558 defined in OpenFileList()
559
560 @retval EFI_SUCCESS Free the file list successfully.
561 @retval EFI_INVALID_PARAMETER FileList was NULL or *FileList was NULL;
562 **/
563 EFI_STATUS
564 EFIAPI
565 EfiShellFreeFileList(
566 IN EFI_SHELL_FILE_INFO **FileList
567 );
568
569 /**
570 Deletes the duplicate file names files in the given file list.
571
572 This function deletes the reduplicate files in the given file list.
573
574 @param FileList A pointer to the first entry in the file list.
575
576 @retval EFI_SUCCESS Always success.
577 @retval EFI_INVALID_PARAMETER FileList was NULL or *FileList was NULL;
578 **/
579 EFI_STATUS
580 EFIAPI
581 EfiShellRemoveDupInFileList(
582 IN EFI_SHELL_FILE_INFO **FileList
583 );
584
585 /**
586 Allocates and populates a EFI_SHELL_FILE_INFO structure. if any memory operation
587 failed it will return NULL.
588
589 @param[in] BasePath the Path to prepend onto filename for FullPath
590 @param[in] Status Status member initial value.
591 @param[in] FullName FullName member initial value.
592 @param[in] FileName FileName member initial value.
593 @param[in] Handle Handle member initial value.
594 @param[in] Info Info struct to copy.
595
596 **/
597 EFI_SHELL_FILE_INFO *
598 EFIAPI
599 CreateAndPopulateShellFileInfo(
600 IN CONST CHAR16 *BasePath,
601 IN CONST EFI_STATUS Status,
602 IN CONST CHAR16 *FullName,
603 IN CONST CHAR16 *FileName,
604 IN CONST SHELL_FILE_HANDLE Handle,
605 IN CONST EFI_FILE_INFO *Info
606 );
607
608 /**
609 Find all files in a specified directory.
610
611 @param FileDirHandle Handle of the directory to search.
612 @param FileList On return, points to the list of files in the directory
613 or NULL if there are no files in the directory.
614
615 @retval EFI_SUCCESS File information was returned successfully.
616 @retval EFI_VOLUME_CORRUPTED The file system structures have been corrupted.
617 @retval EFI_DEVICE_ERROR The device reported an error.
618 @retval EFI_NO_MEDIA The device media is not present.
619 @retval EFI_INVALID_PARAMETER The FileDirHandle was not a directory.
620 **/
621 EFI_STATUS
622 EFIAPI
623 EfiShellFindFilesInDir(
624 IN SHELL_FILE_HANDLE FileDirHandle,
625 OUT EFI_SHELL_FILE_INFO **FileList
626 );
627
628 /**
629 Find files that match a specified pattern.
630
631 This function searches for all files and directories that match the specified
632 FilePattern. The FilePattern can contain wild-card characters. The resulting file
633 information is placed in the file list FileList.
634
635 Wildcards are processed
636 according to the rules specified in UEFI Shell 2.0 spec section 3.7.1.
637
638 The files in the file list are not opened. The OpenMode field is set to 0 and the FileInfo
639 field is set to NULL.
640
641 if *FileList is not NULL then it must be a pre-existing and properly initialized list.
642
643 @param FilePattern Points to a NULL-terminated shell file path, including wildcards.
644 @param FileList On return, points to the start of a file list containing the names
645 of all matching files or else points to NULL if no matching files
646 were found. only on a EFI_SUCCESS return will; this be non-NULL.
647
648 @retval EFI_SUCCESS Files found. FileList is a valid list.
649 @retval EFI_NOT_FOUND No files found.
650 @retval EFI_NO_MEDIA The device has no media
651 @retval EFI_DEVICE_ERROR The device reported an error
652 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
653 **/
654 EFI_STATUS
655 EFIAPI
656 EfiShellFindFiles(
657 IN CONST CHAR16 *FilePattern,
658 OUT EFI_SHELL_FILE_INFO **FileList
659 );
660
661 /**
662 Opens the files that match the path specified.
663
664 This function opens all of the files specified by Path. Wildcards are processed
665 according to the rules specified in UEFI Shell 2.0 spec section 3.7.1. Each
666 matching file has an EFI_SHELL_FILE_INFO structure created in a linked list.
667
668 @param Path A pointer to the path string.
669 @param OpenMode Specifies the mode used to open each file, EFI_FILE_MODE_READ or
670 EFI_FILE_MODE_WRITE.
671 @param FileList Points to the start of a list of files opened.
672
673 @retval EFI_SUCCESS Create the file list successfully.
674 @return Others Can't create the file list.
675 **/
676 EFI_STATUS
677 EFIAPI
678 EfiShellOpenFileList(
679 IN CHAR16 *Path,
680 IN UINT64 OpenMode,
681 IN OUT EFI_SHELL_FILE_INFO **FileList
682 );
683
684 /**
685 Gets the environment variable.
686
687 This function returns the current value of the specified environment variable.
688
689 @param Name A pointer to the environment variable name
690
691 @return !=NULL The environment variable's value. The returned
692 pointer does not need to be freed by the caller.
693 @retval NULL The environment variable doesn't exist.
694 **/
695 CONST CHAR16 *
696 EFIAPI
697 EfiShellGetEnv(
698 IN CONST CHAR16 *Name
699 );
700
701 /**
702 Sets the environment variable.
703
704 This function changes the current value of the specified environment variable. If the
705 environment variable exists and the Value is an empty string, then the environment
706 variable is deleted. If the environment variable exists and the Value is not an empty
707 string, then the value of the environment variable is changed. If the environment
708 variable does not exist and the Value is an empty string, there is no action. If the
709 environment variable does not exist and the Value is a non-empty string, then the
710 environment variable is created and assigned the specified value.
711
712 For a description of volatile and non-volatile environment variables, see UEFI Shell
713 2.0 specification section 3.6.1.
714
715 @param Name Points to the NULL-terminated environment variable name.
716 @param Value Points to the NULL-terminated environment variable value. If the value is an
717 empty string then the environment variable is deleted.
718 @param Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).
719
720 @retval EFI_SUCCESS The environment variable was successfully updated.
721 **/
722 EFI_STATUS
723 EFIAPI
724 EfiShellSetEnv(
725 IN CONST CHAR16 *Name,
726 IN CONST CHAR16 *Value,
727 IN BOOLEAN Volatile
728 );
729
730 /**
731 Returns the current directory on the specified device.
732
733 If FileSystemMapping is NULL, it returns the current working directory. If the
734 FileSystemMapping is not NULL, it returns the current directory associated with the
735 FileSystemMapping. In both cases, the returned name includes the file system
736 mapping (i.e. fs0:\current-dir).
737
738 @param FileSystemMapping A pointer to the file system mapping. If NULL,
739 then the current working directory is returned.
740
741 @retval !=NULL The current directory.
742 @retval NULL Current directory does not exist.
743 **/
744 CONST CHAR16 *
745 EFIAPI
746 EfiShellGetCurDir(
747 IN CONST CHAR16 *FileSystemMapping OPTIONAL
748 );
749
750 /**
751 Changes the current directory on the specified device.
752
753 If the FileSystem is NULL, and the directory Dir does not contain a file system's
754 mapped name, this function changes the current working directory. If FileSystem is
755 NULL and the directory Dir contains a mapped name, then the current file system and
756 the current directory on that file system are changed.
757
758 If FileSystem is not NULL, and Dir is NULL, then this changes the current working file
759 system.
760
761 If FileSystem is not NULL and Dir is not NULL, then this function changes the current
762 directory on the specified file system.
763
764 If the current working directory or the current working file system is changed then the
765 %cwd% environment variable will be updated
766
767 @param FileSystem A pointer to the file system's mapped name. If NULL, then the current working
768 directory is changed.
769 @param Dir Points to the NULL-terminated directory on the device specified by FileSystem.
770
771 @retval EFI_SUCCESS The operation was sucessful
772 **/
773 EFI_STATUS
774 EFIAPI
775 EfiShellSetCurDir(
776 IN CONST CHAR16 *FileSystem OPTIONAL,
777 IN CONST CHAR16 *Dir
778 );
779
780 /**
781 Return help information about a specific command.
782
783 This function returns the help information for the specified command. The help text
784 can be internal to the shell or can be from a UEFI Shell manual page.
785
786 If Sections is specified, then each section name listed will be compared in a casesensitive
787 manner, to the section names described in Appendix B. If the section exists,
788 it will be appended to the returned help text. If the section does not exist, no
789 information will be returned. If Sections is NULL, then all help text information
790 available will be returned.
791
792 @param Command Points to the NULL-terminated UEFI Shell command name.
793 @param Sections Points to the NULL-terminated comma-delimited
794 section names to return. If NULL, then all
795 sections will be returned.
796 @param HelpText On return, points to a callee-allocated buffer
797 containing all specified help text.
798
799 @retval EFI_SUCCESS The help text was returned.
800 @retval EFI_OUT_OF_RESOURCES The necessary buffer could not be allocated to hold the
801 returned help text.
802 @retval EFI_INVALID_PARAMETER HelpText is NULL
803 @retval EFI_NOT_FOUND There is no help text available for Command.
804 **/
805 EFI_STATUS
806 EFIAPI
807 EfiShellGetHelpText(
808 IN CONST CHAR16 *Command,
809 IN CONST CHAR16 *Sections OPTIONAL,
810 OUT CHAR16 **HelpText
811 );
812
813 /**
814 Gets the enable status of the page break output mode.
815
816 User can use this function to determine current page break mode.
817
818 @retval TRUE The page break output mode is enabled
819 @retval FALSE The page break output mode is disabled
820 **/
821 BOOLEAN
822 EFIAPI
823 EfiShellGetPageBreak(
824 VOID
825 );
826
827 /**
828 Judges whether the active shell is the root shell.
829
830 This function makes the user to know that whether the active Shell is the root shell.
831
832 @retval TRUE The active Shell is the root Shell.
833 @retval FALSE The active Shell is NOT the root Shell.
834 **/
835 BOOLEAN
836 EFIAPI
837 EfiShellIsRootShell(
838 VOID
839 );
840
841 /**
842 This function returns the command associated with a alias or a list of all
843 alias'.
844
845 @param[in] Command Points to the NULL-terminated shell alias.
846 If this parameter is NULL, then all
847 aliases will be returned in ReturnedData.
848 @param[out] Volatile upon return of a single command if TRUE indicates
849 this is stored in a volatile fashion. FALSE otherwise.
850 @return If Alias is not NULL, it will return a pointer to
851 the NULL-terminated command for that alias.
852 If Alias is NULL, ReturnedData points to a ';'
853 delimited list of alias (e.g.
854 ReturnedData = "dir;del;copy;mfp") that is NULL-terminated.
855 @retval NULL an error ocurred
856 @retval NULL Alias was not a valid Alias
857 **/
858 CONST CHAR16 *
859 EFIAPI
860 EfiShellGetAlias(
861 IN CONST CHAR16 *Command,
862 OUT BOOLEAN *Volatile OPTIONAL
863 );
864
865 /**
866 Changes a shell command alias.
867
868 This function creates an alias for a shell command or if Alias is NULL it will delete an existing alias.
869
870 this function does not check for built in alias'.
871
872 @param[in] Command Points to the NULL-terminated shell command or existing alias.
873 @param[in] Alias Points to the NULL-terminated alias for the shell command. If this is NULL, and
874 Command refers to an alias, that alias will be deleted.
875 @param[in] Volatile if TRUE the Alias being set will be stored in a volatile fashion. if FALSE the
876 Alias being set will be stored in a non-volatile fashion.
877
878 @retval EFI_SUCCESS Alias created or deleted successfully.
879 @retval EFI_NOT_FOUND the Alias intended to be deleted was not found
880 **/
881 EFI_STATUS
882 EFIAPI
883 InternalSetAlias(
884 IN CONST CHAR16 *Command,
885 IN CONST CHAR16 *Alias OPTIONAL,
886 IN BOOLEAN Volatile
887 );
888
889 /**
890 Changes a shell command alias.
891
892 This function creates an alias for a shell command or if Alias is NULL it will delete an existing alias.
893
894
895 @param[in] Command Points to the NULL-terminated shell command or existing alias.
896 @param[in] Alias Points to the NULL-terminated alias for the shell command. If this is NULL, and
897 Command refers to an alias, that alias will be deleted.
898 @param[in] Replace If TRUE and the alias already exists, then the existing alias will be replaced. If
899 FALSE and the alias already exists, then the existing alias is unchanged and
900 EFI_ACCESS_DENIED is returned.
901 @param[in] Volatile if TRUE the Alias being set will be stored in a volatile fashion. if FALSE the
902 Alias being set will be stored in a non-volatile fashion.
903
904 @retval EFI_SUCCESS Alias created or deleted successfully.
905 @retval EFI_NOT_FOUND the Alias intended to be deleted was not found
906 @retval EFI_ACCESS_DENIED The alias is a built-in alias or already existed and Replace was set to
907 FALSE.
908 **/
909 EFI_STATUS
910 EFIAPI
911 EfiShellSetAlias(
912 IN CONST CHAR16 *Command,
913 IN CONST CHAR16 *Alias OPTIONAL,
914 IN BOOLEAN Replace,
915 IN BOOLEAN Volatile
916 );
917
918 /**
919 Utility cleanup function for EFI_SHELL_FILE_INFO objects.
920
921 1) frees all pointers (non-NULL)
922 2) Closes the SHELL_FILE_HANDLE
923
924 @param FileListNode pointer to the list node to free
925 **/
926 VOID
927 EFIAPI
928 InternalFreeShellFileInfoNode(
929 IN EFI_SHELL_FILE_INFO *FileListNode
930 );
931
932 /**
933 Internal variable setting function. Allows for setting of the read only variables.
934
935 @param Name Points to the NULL-terminated environment variable name.
936 @param Value Points to the NULL-terminated environment variable value. If the value is an
937 empty string then the environment variable is deleted.
938 @param Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).
939
940 @retval EFI_SUCCESS The environment variable was successfully updated.
941 **/
942 EFI_STATUS
943 EFIAPI
944 InternalEfiShellSetEnv(
945 IN CONST CHAR16 *Name,
946 IN CONST CHAR16 *Value,
947 IN BOOLEAN Volatile
948 );
949
950 /**
951 Function to start monitoring for CTRL-C using SimpleTextInputEx. This
952 feature's enabled state was not known when the shell initially launched.
953
954 @retval EFI_SUCCESS The feature is enabled.
955 @retval EFI_OUT_OF_RESOURCES There is not enough mnemory available.
956 **/
957 EFI_STATUS
958 EFIAPI
959 InernalEfiShellStartMonitor(
960 VOID
961 );
962 #endif //_SHELL_PROTOCOL_HEADER_
963