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