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