]> git.proxmox.com Git - mirror_edk2.git/blob - ShellPkg/Include/Protocol/EfiShell.h
First (Alpha) release of ShellPkg
[mirror_edk2.git] / ShellPkg / Include / Protocol / EfiShell.h
1 /** @file
2 EFI Shell protocol as defined in the UEFI Shell 2.0 specification.
3
4 Copyright (c) 2006 - 2009, Intel Corporation
5 All rights reserved. This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution. The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12
13 **/
14
15 #ifndef __EFI_SHELL_PROTOCOL__
16 #define __EFI_SHELL_PROTOCOL__
17
18 #include <Protocol/SimpleFileSystem.h>
19 #include <Guid/FileInfo.h>
20
21 #define EFI_SHELL_PROTOCOL_GUID \
22 { \
23 0x6302d008, 0x7f9b, 0x4f30, { 0x87, 0xac, 0x60, 0xc9, 0xfe, 0xf5, 0xda, 0x4e } \
24 }
25
26 typedef struct _EFI_LIST_ENTRY {
27 struct _EFI_LIST_ENTRY *Flink;
28 struct _EFI_LIST_ENTRY *Blink;
29 } EFI_LIST_ENTRY;
30
31 typedef struct {
32 EFI_LIST_ENTRY Link;
33 EFI_STATUS Status;
34 CONST CHAR16 *FullName;
35 CONST CHAR16 *FileName;
36 EFI_FILE_HANDLE Handle;
37 EFI_FILE_INFO *Info;
38 } EFI_SHELL_FILE_INFO;
39 /**
40 Returns whether any script files are currently being processed.
41
42 @retval TRUE There is at least one script file active.
43 @retval FALSE No script files are active now.
44
45 **/
46 typedef
47 BOOLEAN
48 (EFIAPI *EFI_SHELL_BATCH_IS_ACTIVE) (
49 VOID
50 );
51
52 /**
53 Closes the file handle.
54
55 This function closes a specified file handle. All 'dirty' cached file data is
56 flushed to the device, and the file is closed. In all cases, the handle is
57 closed.
58
59 @param FileHandle The file handle to be closed
60
61 @retval EFI_SUCCESS the file closed sucessfully
62 **/
63 typedef
64 EFI_STATUS
65 (EFIAPI *EFI_SHELL_CLOSE_FILE)(
66 IN EFI_FILE_HANDLE FileHandle
67 );
68
69 /**
70 Creates a file or directory by name.
71
72 This function creates an empty new file or directory with the specified attributes and
73 returns the new file's handle. If the file already exists and is read-only, then
74 EFI_INVALID_PARAMETER will be returned.
75
76 If the file already existed, it is truncated and its attributes updated. If the file is
77 created successfully, the FileHandle is the file's handle, else, the FileHandle is NULL.
78
79 If the file name begins with >v, then the file handle which is returned refers to the
80 shell environment variable with the specified name. If the shell environment variable
81 already exists and is non-volatile then EFI_INVALID_PARAMETER is returned.
82
83 @param FileName Pointer to null-terminated file path
84 @param FileAttribs The new file's attrbiutes. the different attributes are
85 described in EFI_FILE_PROTOCOL.Open().
86 @param FileHandle On return, points to the created file handle or directory's handle
87
88 @retval EFI_SUCCESS The file was opened. FileHandle points to the new file's handle.
89 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.
90 @retval EFI_UNSUPPORTED could not open the file path
91 @retval EFI_NOT_FOUND the specified file could not be found on the devide, or could not
92 file the file system on the device.
93 @retval EFI_NO_MEDIA the device has no medium.
94 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no
95 longer supported.
96 @retval EFI_DEVICE_ERROR The device reported an error or can't get the file path according
97 the DirName.
98 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
99 @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write
100 when the media is write-protected.
101 @retval EFI_ACCESS_DENIED The service denied access to the file.
102 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file.
103 @retval EFI_VOLUME_FULL The volume is full.
104 **/
105 typedef
106 EFI_STATUS
107 (EFIAPI *EFI_SHELL_CREATE_FILE)(
108 IN CONST CHAR16 *FileName,
109 IN UINT64 FileAttribs,
110 OUT EFI_FILE_HANDLE *FileHandle
111 );
112
113 /**
114 Deletes the file specified by the file handle.
115
116 This function closes and deletes a file. In all cases, the file handle is closed. If the file
117 cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is returned, but the
118 handle is still closed.
119
120 @param FileHandle The file handle to delete.
121
122 @retval EFI_SUCCESS The file was closed and deleted, and the handle was closed.
123 @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not deleted.
124 **/
125 typedef
126 EFI_STATUS
127 (EFIAPI *EFI_SHELL_DELETE_FILE)(
128 IN EFI_FILE_HANDLE FileHandle
129 );
130
131 /**
132 Deletes the file specified by the file name.
133
134 This function deletes a file.
135
136 @param FileName Points to the null-terminated file name.
137
138 @retval EFI_SUCCESS The file was closed and deleted, and the handle was closed.
139 @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not deleted.
140 **/
141 typedef
142 EFI_STATUS
143 (EFIAPI *EFI_SHELL_DELETE_FILE_BY_NAME)(
144 IN CONST CHAR16 *FileName
145 );
146
147 /**
148 Disables the page break output mode.
149 **/
150 typedef
151 VOID
152 (EFIAPI *EFI_SHELL_DISABLE_PAGE_BREAK) (
153 VOID
154 );
155
156 /**
157 Enables the page break output mode.
158 **/
159 typedef
160 VOID
161 (EFIAPI *EFI_SHELL_ENABLE_PAGE_BREAK) (
162 VOID
163 );
164
165 /**
166 Execute the command line.
167
168 This function creates a nested instance of the shell and executes the specified
169 command (CommandLine) with the specified environment (Environment). Upon return,
170 the status code returned by the specified command is placed in StatusCode.
171
172 If Environment is NULL, then the current environment is used and all changes made
173 by the commands executed will be reflected in the current environment. If the
174 Environment is non-NULL, then the changes made will be discarded.
175
176 The CommandLine is executed from the current working directory on the current
177 device.
178
179 @param ParentImageHandle A handle of the image that is executing the specified
180 command line.
181 @param CommandLine Points to the null-terminated UCS-2 encoded string
182 containing the command line. If NULL then the command-
183 line will be empty.
184 @param Environment Points to a null-terminated array of environment
185 variables with the format 'x=y', where x is the
186 environment variable name and y is the value. If this
187 is NULL, then the current shell environment is used.
188 @param ErrorCode Points to the status code returned by the command.
189
190 @retval EFI_SUCCESS The command executed successfully. The status code
191 returned by the command is pointed to by StatusCode.
192 @retval EFI_INVALID_PARAMETER The parameters are invalid.
193 @retval EFI_OUT_OF_RESOURCES Out of resources.
194 @retval EFI_UNSUPPORTED Nested shell invocations are not allowed.
195 **/
196 typedef
197 EFI_STATUS
198 (EFIAPI *EFI_SHELL_EXECUTE) (
199 IN EFI_HANDLE *ParentImageHandle,
200 IN CHAR16 *CommandLine OPTIONAL,
201 IN CHAR16 **Environment OPTIONAL,
202 OUT EFI_STATUS *StatusCode OPTIONAL
203 );
204
205 /**
206 Find files that match a specified pattern.
207
208 This function searches for all files and directories that match the specified
209 FilePattern. The FilePattern can contain wild-card characters. The resulting file
210 information is placed in the file list FileList.
211
212 The files in the file list are not opened. The OpenMode field is set to 0 and the FileInfo
213 field is set to NULL.
214
215 @param FilePattern Points to a null-terminated shell file path, including wildcards.
216 @param FileList On return, points to the start of a file list containing the names
217 of all matching files or else points to NULL if no matching files
218 were found.
219
220 @retval EFI_SUCCESS Files found.
221 @retval EFI_NOT_FOUND No files found.
222 @retval EFI_NO_MEDIA The device has no media
223 @retval EFI_DEVICE_ERROR The device reported an error
224 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
225 **/
226 typedef
227 EFI_STATUS
228 (EFIAPI *EFI_SHELL_FIND_FILES)(
229 IN CONST CHAR16 *FilePattern,
230 OUT EFI_SHELL_FILE_INFO **FileList
231 );
232
233 /**
234 Find all files in a specified directory.
235
236 @param FileDirHandle Handle of the directory to search.
237 @param FileList On return, points to the list of files in the directory
238 or NULL if there are no files in the directory.
239
240 @retval EFI_SUCCESS File information was returned successfully.
241 @retval EFI_VOLUME_CORRUPTED The file system structures have been corrupted.
242 @retval EFI_DEVICE_ERROR The device reported an error.
243 @retval EFI_NO_MEDIA The device media is not present.
244 **/
245 typedef
246 EFI_STATUS
247 (EFIAPI *EFI_SHELL_FIND_FILES_IN_DIR)(
248 IN EFI_FILE_HANDLE FileDirHandle,
249 OUT EFI_SHELL_FILE_INFO **FileList
250 );
251
252 /**
253 Flushes data back to a device
254
255 This function flushes all modified data associated with a file to a device.
256
257 @param FileHandle The handle of the file to flush
258
259 @retval EFI_SUCCESS The data was flushed.
260 @retval EFI_NO_MEDIA The device has no medium.
261 @retval EFI_DEVICE_ERROR The device reported an error.
262 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
263 @retval EFI_WRITE_PROTECTED The file or medium is write-protected.
264 @retval EFI_ACCESS_DENIED The file was opened read-only.
265 @retval EFI_VOLUME_FULL The volume is full.
266 **/
267 typedef
268 EFI_STATUS
269 (EFIAPI *EFI_SHELL_FLUSH_FILE)(
270 IN EFI_FILE_HANDLE FileHandle
271 );
272
273 /**
274 Frees the file list.
275
276 This function cleans up the file list and any related data structures. It has no
277 impact on the files themselves.
278
279 @param FileList The file list to free. Type EFI_SHELL_FILE_INFO is
280 defined in OpenFileList()
281
282 @retval EFI_SUCCESS Free the file list successfully.
283 **/
284 typedef
285 EFI_STATUS
286 (EFIAPI *EFI_SHELL_FREE_FILE_LIST) (
287 IN EFI_SHELL_FILE_INFO **FileList
288 );
289
290 /**
291 Returns the current directory on the specified device.
292
293 If FileSystemMapping is NULL, it returns the current working directory. If the
294 FileSystemMapping is not NULL, it returns the current directory associated with the
295 FileSystemMapping. In both cases, the returned name includes the file system
296 mapping (i.e. fs0:\current-dir).
297
298 @param FileSystemMapping A pointer to the file system mapping. If NULL,
299 then the current working directory is returned.
300
301 @retval !=NULL The current directory.
302 @retval NULL Current directory does not exist.
303 **/
304 typedef
305 CONST CHAR16 *
306 (EFIAPI *EFI_SHELL_GET_CUR_DIR) (
307 IN CONST CHAR16 *FileSystemMapping OPTIONAL
308 );
309
310 typedef UINT32 EFI_SHELL_DEVICE_NAME_FLAGS;
311 #define EFI_DEVICE_NAME_USE_COMPONENT_NAME 0x00000001
312 #define EFI_DEVICE_NAME_USE_DEVICE_PATH 0x00000002
313 /**
314 Gets the name of the device specified by the device handle.
315
316 This function gets the user-readable name of the device specified by the device
317 handle. If no user-readable name could be generated, then *BestDeviceName will be
318 NULL and EFI_NOT_FOUND will be returned.
319
320 @param DeviceHandle The handle of the device.
321 @param Flags Determines the possible sources of component names.
322 @param Language A pointer to the language specified for the device
323 name, in the same format as described in the UEFI
324 specification, Appendix M
325 @param BestDeviceName On return, points to the callee-allocated null-
326 terminated name of the device. If no device name
327 could be found, points to NULL. The name must be
328 freed by the caller...
329
330 @retval EFI_SUCCESS Get the name successfully.
331 @retval EFI_NOT_FOUND Fail to get the device name.
332 **/
333 typedef
334 EFI_STATUS
335 (*EFI_SHELL_GET_DEVICE_NAME) (
336 IN EFI_HANDLE DeviceHandle,
337 IN EFI_SHELL_DEVICE_NAME_FLAGS Flags,
338 IN CHAR8 *Language,
339 OUT CHAR16 **BestDeviceName
340 );
341
342 /**
343 Gets the device path from the mapping.
344
345 This function gets the device path associated with a mapping.
346
347 @param Mapping A pointer to the mapping
348
349 @retval !=NULL Pointer to the device path that corresponds to the
350 device mapping. The returned pointer does not need
351 to be freed.
352 @retval NULL There is no device path associated with the
353 specified mapping.
354 **/
355 typedef
356 CONST EFI_DEVICE_PATH_PROTOCOL *
357 (EFIAPI *EFI_SHELL_GET_DEVICE_PATH_FROM_MAP) (
358 IN CONST CHAR16 *Mapping
359 );
360
361 /**
362 Converts a file system style name to a device path.
363
364 This function converts a file system style name to a device path, by replacing any
365 mapping references to the associated device path.
366
367 @param Path the pointer to the path
368
369 @return all The pointer of the file path. The file path is callee
370 allocated and should be freed by the caller.
371 **/
372 typedef
373 EFI_DEVICE_PATH_PROTOCOL *
374 (EFIAPI *EFI_SHELL_GET_DEVICE_PATH_FROM_FILE_PATH) (
375 IN CONST CHAR16 *Path
376 );
377
378 /**
379 Gets the environment variable.
380
381 This function returns the current value of the specified environment variable.
382
383 @param Name A pointer to the environment variable name
384
385 @return !=NULL The environment variable's value. The returned
386 pointer does not need to be freed by the caller.
387 @retval NULL The environment variable doesn't exist.
388 **/
389 typedef
390 CONST CHAR16 *
391 (EFIAPI *EFI_SHELL_GET_ENV) (
392 IN CONST CHAR16 *Name
393 );
394
395 /**
396 Gets the file information from an open file handle.
397
398 This function allocates a buffer to store the file's information. It's the caller's
399 responsibility to free the buffer.
400
401 @param FileHandle A File Handle
402
403 @return !=NULL Cannot get the file info.
404 @return NULL A pointer to a buffer with file information.
405 **/
406 typedef
407 EFI_FILE_INFO *
408 (EFIAPI *EFI_SHELL_GET_FILE_INFO)(
409 IN EFI_FILE_HANDLE FileHandle
410 );
411
412 /**
413 Converts a device path to a file system-style path.
414
415 This function converts a device path to a file system path by replacing part, or all, of
416 the device path with the file-system mapping. If there are more than one application
417 file system mappings, the one that most closely matches Path will be used.
418
419 @param Path The pointer to the device path
420
421 @return all The pointer of the null-terminated file path. The path
422 is callee-allocated and should be freed by the caller.
423 **/
424 typedef
425 CHAR16 *
426 (EFIAPI *EFI_SHELL_GET_FILE_PATH_FROM_DEVICE_PATH) (
427 IN CONST EFI_DEVICE_PATH_PROTOCOL *Path
428 );
429
430 /**
431 Gets a file's current position
432
433 This function returns the current file position for the file handle. For directories, the
434 current file position has no meaning outside of the file system driver and as such, the
435 operation is not supported.
436
437 @param FileHandle The file handle on which to get the current position.
438 @param Position Byte position from the start of the file
439
440 @retval EFI_SUCCESS Data was accessed.
441 @retval EFI_UNSUPPORTED The request is not valid on open directories.
442 **/
443 typedef
444 EFI_STATUS
445 (EFIAPI *EFI_SHELL_GET_FILE_POSITION)(
446 IN EFI_FILE_HANDLE FileHandle,
447 OUT UINT64 *Position
448 );
449
450 /**
451 Gets the size of a file.
452
453 This function returns the size of the file specified by FileHandle.
454
455 @param FileHandle The handle of the file.
456 @param Size The size of this file.
457
458 @retval EFI_SUCCESS Get the file's size.
459 @retval EFI_DEVICE_ERROR Can't access the file.
460 **/
461 typedef
462 EFI_STATUS
463 (EFIAPI *EFI_SHELL_GET_FILE_SIZE)(
464 IN EFI_FILE_HANDLE FileHandle,
465 OUT UINT64 *Size
466 );
467
468 /**
469 Return help information about a specific command.
470
471 This function returns the help information for the specified command. The help text
472 can be internal to the shell or can be from a UEFI Shell manual page.
473
474 If Sections is specified, then each section name listed will be compared in a casesensitive
475 manner, to the section names described in Appendix B. If the section exists,
476 it will be appended to the returned help text. If the section does not exist, no
477 information will be returned. If Sections is NULL, then all help text information
478 available will be returned.
479
480 @param Command Points to the null-terminated UEFI Shell command name.
481 @param Sections Points to the null-terminated comma-delimited
482 section names to return. If NULL, then all
483 sections will be returned.
484 @param HelpText On return, points to a callee-allocated buffer
485 containing all specified help text.
486
487 @retval EFI_SUCCESS The help text was returned.
488 @retval EFI_OUT_OF_RESOURCES The necessary buffer could not be allocated to hold the
489 returned help text.
490 @retval EFI_INVALID_PARAMETER HelpText is NULL
491 @retval EFI_NOT_FOUND There is no help text available for Command.
492 **/
493 typedef
494 EFI_STATUS
495 (EFIAPI *EFI_SHELL_GET_HELP_TEXT) (
496 IN CONST CHAR16 *Command,
497 IN CONST CHAR16 *Sections,
498 OUT CHAR16 **HelpText
499 );
500
501 /**
502 Gets the mapping that most closely matches the device path.
503
504 This function gets the mapping which corresponds to the device path *DevicePath. If
505 there is no exact match, then the mapping which most closely matches *DevicePath
506 is returned, and *DevicePath is updated to point to the remaining portion of the
507 device path. If there is an exact match, the mapping is returned and *DevicePath
508 points to the end-of-device-path node.
509
510 @param DevicePath On entry, points to a device path pointer. On
511 exit, updates the pointer to point to the
512 portion of the device path after the mapping.
513
514 @retval NULL No mapping was found.
515 @return !=NULL Pointer to null-terminated mapping. The buffer
516 is callee allocated and should be freed by the caller.
517 **/
518 typedef
519 CONST CHAR16 *
520 (EFIAPI *EFI_SHELL_GET_MAP_FROM_DEVICE_PATH) (
521 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath
522 );
523
524 /**
525 Gets the enable status of the page break output mode.
526
527 User can use this function to determine current page break mode.
528
529 @retval TRUE The page break output mode is enabled
530 @retval FALSE The page break output mode is disabled
531 **/
532 typedef
533 BOOLEAN
534 (EFIAPI *EFI_SHELL_GET_PAGE_BREAK) (
535 VOID
536 );
537
538 /**
539 Judges whether the active shell is the root shell.
540
541 This function makes the user to know that whether the active Shell is the root shell.
542
543 @retval TRUE The active Shell is the root Shell.
544 @retval FALSE The active Shell is NOT the root Shell.
545 **/
546 typedef
547 BOOLEAN
548 (EFIAPI *EFI_SHELL_IS_ROOT_SHELL) (
549 VOID
550 );
551
552 /**
553 Opens a file or a directory by file name.
554
555 This function opens the specified file in the specified OpenMode and returns a file
556 handle.
557 If the file name begins with >v, then the file handle which is returned refers to the
558 shell environment variable with the specified name. If the shell environment variable
559 exists, is non-volatile and the OpenMode indicates EFI_FILE_MODE_WRITE, then
560 EFI_INVALID_PARAMETER is returned.
561
562 If the file name is >i, then the file handle which is returned refers to the standard
563 input. If the OpenMode indicates EFI_FILE_MODE_WRITE, then EFI_INVALID_PARAMETER
564 is returned.
565
566 If the file name is >o, then the file handle which is returned refers to the standard
567 output. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER
568 is returned.
569
570 If the file name is >e, then the file handle which is returned refers to the standard
571 error. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER
572 is returned.
573
574 If the file name is NUL, then the file handle that is returned refers to the standard NUL
575 file. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER is
576 returned.
577
578 If return EFI_SUCCESS, the FileHandle is the opened file's handle, else, the
579 FileHandle is NULL.
580
581 @param FileName Points to the null-terminated UCS-2 encoded file name.
582 @param FileHandle On return, points to the file handle.
583 @param OpenMode File open mode. Either EFI_FILE_MODE_READ or
584 EFI_FILE_MODE_WRITE from section 12.4 of the UEFI
585 Specification.
586 @retval EFI_SUCCESS The file was opened. FileHandle has the opened file's handle.
587 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value. FileHandle is NULL.
588 @retval EFI_UNSUPPORTED Could not open the file path. FileHandle is NULL.
589 @retval EFI_NOT_FOUND The specified file could not be found on the device or the file
590 system could not be found on the device. FileHandle is NULL.
591 @retval EFI_NO_MEDIA The device has no medium. FileHandle is NULL.
592 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no
593 longer supported. FileHandle is NULL.
594 @retval EFI_DEVICE_ERROR The device reported an error or can't get the file path according
595 the FileName. FileHandle is NULL.
596 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. FileHandle is NULL.
597 @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write
598 when the media is write-protected. FileHandle is NULL.
599 @retval EFI_ACCESS_DENIED The service denied access to the file. FileHandle is NULL.
600 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file. FileHandle
601 is NULL.
602 @retval EFI_VOLUME_FULL The volume is full. FileHandle is NULL.
603 **/
604 typedef
605 EFI_STATUS
606 (EFIAPI *EFI_SHELL_OPEN_FILE_BY_NAME) (
607 IN CONST CHAR16 *FileName,
608 OUT EFI_FILE_HANDLE *FileHandle,
609 IN UINT64 OpenMode
610 );
611
612 /**
613 Opens the files that match the path specified.
614
615 This function opens all of the files specified by Path. Wildcards are processed
616 according to the rules specified in UEFI Shell 2.0 spec section 3.7.1. Each
617 matching file has an EFI_SHELL_FILE_INFO structure created in a linked list.
618
619 @param Path A pointer to the path string.
620 @param OpenMode Specifies the mode used to open each file, EFI_FILE_MODE_READ or
621 EFI_FILE_MODE_WRITE.
622 @param FileList Points to the start of a list of files opened.
623
624 @retval EFI_SUCCESS Create the file list successfully.
625 @return Others Can't create the file list.
626 **/
627 typedef
628 EFI_STATUS
629 (EFIAPI *EFI_SHELL_OPEN_FILE_LIST) (
630 IN CHAR16 *Path,
631 IN UINT64 OpenMode,
632 IN OUT EFI_SHELL_FILE_INFO **FileList
633 );
634
635 /**
636 Opens the root directory of a device.
637
638 This function opens the root directory of a device and returns a file handle to it.
639
640 @param DevicePath Points to the device path corresponding to the device where the
641 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL is installed.
642 @param FileHandle On exit, points to the file handle corresponding to the root directory on the
643 device.
644
645 @retval EFI_SUCCESS Root opened successfully.
646 @retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be found or the root directory
647 could not be opened.
648 @retval EFI_VOLUME_CORRUPTED The data structures in the volume were corrupted.
649 @retval EFI_DEVICE_ERROR The device had an error
650 **/
651 typedef
652 EFI_STATUS
653 (EFIAPI *EFI_SHELL_OPEN_ROOT)(
654 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,
655 OUT EFI_FILE_HANDLE *FileHandle
656 );
657
658 /**
659 Opens the root directory of a device on a handle
660
661 This function opens the root directory of a device and returns a file handle to it.
662
663 @param DeviceHandle The handle of the device that contains the volume.
664 @param FileHandle On exit, points to the file handle corresponding to the root directory on the
665 device.
666
667 @retval EFI_SUCCESS Root opened successfully.
668 @retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be found or the root directory
669 could not be opened.
670 @retval EFI_VOLUME_CORRUPTED The data structures in the volume were corrupted.
671 @retval EFI_DEVICE_ERROR The device had an error
672 **/
673 typedef
674 EFI_STATUS
675 (EFIAPI *EFI_SHELL_OPEN_ROOT_BY_HANDLE)(
676 IN EFI_HANDLE DeviceHandle,
677 OUT EFI_FILE_HANDLE *FileHandle
678 );
679
680 /**
681 Reads data from the file.
682
683 If FileHandle is not a directory, the function reads the requested number of bytes
684 from the file at the file's current position and returns them in Buffer. If the read goes
685 beyond the end of the file, the read length is truncated to the end of the file. The file's
686 current position is increased by the number of bytes returned.
687 If FileHandle is a directory, then an error is returned.
688
689 @param FileHandle The opened file handle for read
690 @param ReadSize On input, the size of Buffer, in bytes. On output, the amount of data read.
691 @param Buffer The buffer in which data is read.
692
693 @retval EFI_SUCCESS Data was read.
694 @retval EFI_NO_MEDIA The device has no media
695 @retval EFI_DEVICE_ERROR The device reported an error
696 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
697 @retval EFI_BUFFER_TO_SMALL Buffer is too small. ReadSize contains required size
698 **/
699 typedef
700 EFI_STATUS
701 (EFIAPI *EFI_SHELL_READ_FILE) (
702 IN EFI_FILE_HANDLE FileHandle,
703 IN OUT UINTN *ReadSize,
704 OUT VOID *Buffer
705 );
706
707 /**
708 Deletes the duplicate file names files in the given file list.
709
710 This function deletes the reduplicate files in the given file list.
711
712 @param FileList A pointer to the first entry in the file list.
713
714 @retval EFI_SUCCESS Always success.
715 **/
716 typedef
717 EFI_STATUS
718 (EFIAPI *EFI_SHELL_REMOVE_DUP_IN_FILE_LIST) (
719 IN EFI_SHELL_FILE_INFO **FileList
720 );
721
722 /**
723 Changes a shell command alias.
724
725 This function creates an alias for a shell command.
726
727 @param Command Points to the null-terminated shell command or existing alias.
728 @param Alias Points to the null-terminated alias for the shell command. If this is NULL, and
729 Command refers to an alias, that alias will be deleted.
730 @param Replace If TRUE and the alias already exists, then the existing alias will be replaced. If
731 FALSE and the alias already exists, then the existing alias is unchanged and
732 EFI_ACCESS_DENIED is returned.
733
734 @retval EFI_SUCCESS Alias created or deleted successfully.
735 @retval EFI_ACCESS_DENIED The alias is a built-in alias or already existed and Replace was set to
736 FALSE.
737 **/
738 typedef
739 EFI_STATUS
740 (EFIAPI *EFI_SHELL_SET_ALIAS)(
741 IN CONST CHAR16 *Command,
742 IN CONST CHAR16 *Alias,
743 IN BOOLEAN Replace
744 );
745
746 /**
747 Changes the current directory on the specified device.
748
749 If the FileSystem is NULL, and the directory Dir does not contain a file system's
750 mapped name, this function changes the current working directory. If FileSystem is
751 NULL and the directory Dir contains a mapped name, then the current file system and
752 the current directory on that file system are changed.
753
754 If FileSystem is not NULL, and Dir is NULL, then this changes the current working file
755 system.
756
757 If FileSystem is not NULL and Dir is not NULL, then this function changes the current
758 directory on the specified file system.
759
760 If the current working directory or the current working file system is changed then the
761 %cwd% environment variable will be updated
762
763 @param FileSystem A pointer to the file system's mapped name. If NULL, then the current working
764 directory is changed.
765 @param Dir Points to the null-terminated directory on the device specified by FileSystem.
766
767 @return !=NULL The current directory.
768 @retval NULL Current directory does not exist.
769 **/
770 typedef
771 EFI_STATUS
772 (EFIAPI *EFI_SHELL_SET_CUR_DIR) (
773 IN CONST CHAR16 *FileSystem OPTIONAL,
774 IN CONST CHAR16 *Dir
775 );
776
777 /**
778 Sets the environment variable.
779
780 This function changes the current value of the specified environment variable. If the
781 environment variable exists and the Value is an empty string, then the environment
782 variable is deleted. If the environment variable exists and the Value is not an empty
783 string, then the value of the environment variable is changed. If the environment
784 variable does not exist and the Value is an empty string, there is no action. If the
785 environment variable does not exist and the Value is a non-empty string, then the
786 environment variable is created and assigned the specified value.
787
788 For a description of volatile and non-volatile environment variables, see UEFI Shell
789 2.0 specification section 3.6.1.
790
791 @param Name Points to the null-terminated environment variable name.
792 @param Value Points to the null-terminated environment variable value. If the value is an
793 empty string then the environment variable is deleted.
794 @param Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).
795
796 @retval EFI_SUCCESS The environment variable was successfully updated.
797 **/
798 typedef
799 EFI_STATUS
800 (EFIAPI *EFI_SHELL_SET_ENV) (
801 IN CONST CHAR16 *Name,
802 IN CONST CHAR16 *Value,
803 IN BOOLEAN Volatile
804 );
805
806 /**
807 Sets the file information to an opened file handle.
808
809 This function changes file information.
810
811 @param FileHandle A file handle
812 @param FileInfo Points to new file information.
813
814 @retval EFI_SUCCESS The information was set.
815 @retval EFI_NO_MEDIA The device has no medium.
816 @retval EFI_DEVICE_ERROR The device reported an error.
817 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.
818 @retval EFI_WRITE_PROTECTED The file or medium is write-protected.
819 @retval EFI_ACCESS_DENIED The file was opened read-only.
820 @retval EFI_VOLUME_FULL The volume is full.
821 @retval EFI_BAD_BUFFER_SIZE BufferSize is smaller than the size of EFI_FILE_INFO.
822 **/
823 typedef
824 EFI_STATUS
825 (EFIAPI *EFI_SHELL_SET_FILE_INFO)(
826 IN EFI_FILE_HANDLE FileHandle,
827 IN CONST EFI_FILE_INFO *FileInfo
828 );
829
830 /**
831 Sets a file's current position
832
833 This function sets the current file position for the handle to the position supplied. With
834 the exception of seeking to position 0xFFFFFFFFFFFFFFFF, only absolute positioning is
835 supported, and seeking past the end of the file is allowed (a subsequent write would
836 grow the file). Seeking to position 0xFFFFFFFFFFFFFFFF causes the current position
837 to be set to the end of the file.
838
839 @param FileHandle The file handle on which requested position will be set.
840 @param Position Byte position from the start of the file
841
842 @retval EFI_SUCCESS Data was written.
843 @retval EFI_UNSUPPORTED The seek request for nonzero is not valid on open directories.
844 **/
845 typedef
846 EFI_STATUS
847 (EFIAPI *EFI_SHELL_SET_FILE_POSITION)(
848 IN EFI_FILE_HANDLE FileHandle,
849 IN UINT64 Position
850 );
851
852 /**
853 This function creates a mapping for a device path.
854
855 @param DevicePath Points to the device path. If this is NULL and Mapping points to a valid mapping,
856 then the mapping will be deleted.
857 @param Mapping Points to the null-terminated mapping for the device path.
858
859 @retval EFI_SUCCESS Mapping created or deleted successfully.
860 @retval EFI_NO_MAPPING There is no handle that corresponds exactly to DevicePath. See the
861 boot service function LocateDevicePath().
862 @retval EFI_ACCESS_DENIED The mapping is a built-in alias.
863 **/
864 typedef
865 EFI_STATUS
866 (EFIAPI *EFI_SHELL_SET_MAP)(
867 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,
868 IN CONST CHAR16 *Mapping
869 );
870
871 /**
872 Writes data to the file.
873
874 This function writes the specified number of bytes to the file at the current file position.
875 The current file position is advanced the actual number of bytes written, which is
876 returned in BufferSize. Partial writes only occur when there has been a data error
877 during the write attempt (such as "volume space full"). The file automatically grows to
878 hold the data, if required.
879
880 Direct writes to opened directories are not supported.
881
882 @param FileHandle The opened file handle for writing.
883 @param BufferSize On input, size of Buffer.
884 @param Buffer The buffer in which data to write.
885
886 @retval EFI_SUCCESS Data was written.
887 @retval EFI_UNSUPPORTED Writes to open directory are not supported
888 @retval EFI_NO_MEDIA The device has no media
889 @retval EFI_DEVICE_ERROR The device reported an error
890 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted
891 @retval EFI_WRITE_PROTECTED The device is write-protected
892 @retval EFI_ACCESS_DENIED The file was open for read only
893 @retval EFI_VOLUME_FULL The volume is full
894 **/
895 typedef
896 EFI_STATUS
897 (EFIAPI *EFI_SHELL_WRITE_FILE)(
898 IN EFI_FILE_HANDLE FileHandle,
899 IN OUT UINTN *BufferSize,
900 OUT VOID *Buffer
901 );
902
903 typedef struct _EFI_SHELL_PROTOCOL {
904 EFI_SHELL_EXECUTE Execute;
905 EFI_SHELL_GET_ENV GetEnv;
906 EFI_SHELL_SET_ENV SetEnv;
907 EFI_SHELL_SET_ALIAS SetAlias;
908 EFI_SHELL_GET_HELP_TEXT GetHelpText;
909 EFI_SHELL_GET_DEVICE_PATH_FROM_MAP GetDevicePathFromMap;
910 EFI_SHELL_GET_MAP_FROM_DEVICE_PATH GetMapFromDevicePath;
911 EFI_SHELL_GET_DEVICE_PATH_FROM_FILE_PATH GetDevicePathFromFilePath;
912 EFI_SHELL_GET_FILE_PATH_FROM_DEVICE_PATH GetFilePathFromDevicePath;
913 EFI_SHELL_SET_MAP SetMap;
914 EFI_SHELL_GET_CUR_DIR GetCurDir;
915 EFI_SHELL_SET_CUR_DIR SetCurDir;
916 EFI_SHELL_OPEN_FILE_LIST OpenFileList;
917 EFI_SHELL_FREE_FILE_LIST FreeFileList;
918 EFI_SHELL_REMOVE_DUP_IN_FILE_LIST RemoveDupInFileList;
919 EFI_SHELL_BATCH_IS_ACTIVE BatchIsActive;
920 EFI_SHELL_IS_ROOT_SHELL IsRootShell;
921 EFI_SHELL_ENABLE_PAGE_BREAK EnablePageBreak;
922 EFI_SHELL_DISABLE_PAGE_BREAK DisablePageBreak;
923 EFI_SHELL_GET_PAGE_BREAK GetPageBreak;
924 EFI_SHELL_GET_DEVICE_NAME GetDeviceName;
925 EFI_SHELL_GET_FILE_INFO GetFileInfo;
926 EFI_SHELL_SET_FILE_INFO SetFileInfo;
927 EFI_SHELL_OPEN_FILE_BY_NAME OpenFileByName;
928 EFI_SHELL_CLOSE_FILE CloseFile;
929 EFI_SHELL_CREATE_FILE CreateFile;
930 EFI_SHELL_READ_FILE ReadFile;
931 EFI_SHELL_WRITE_FILE WriteFile;
932 EFI_SHELL_DELETE_FILE DeleteFile;
933 EFI_SHELL_DELETE_FILE_BY_NAME DeleteFileByName;
934 EFI_SHELL_GET_FILE_POSITION GetFilePosition;
935 EFI_SHELL_SET_FILE_POSITION SetFilePosition;
936 EFI_SHELL_FLUSH_FILE FlushFile;
937 EFI_SHELL_FIND_FILES FindFiles;
938 EFI_SHELL_FIND_FILES_IN_DIR FindFilesInDir;
939 EFI_SHELL_GET_FILE_SIZE GetFileSize;
940 EFI_SHELL_OPEN_ROOT OpenRoot;
941 EFI_SHELL_OPEN_ROOT_BY_HANDLE OpenRootByHandle;
942 EFI_EVENT ExecutionBreak;
943 UINT32 MajorVersion;
944 UINT32 MinorVersion;
945 } EFI_SHELL_PROTOCOL;
946
947 extern EFI_GUID gEfiShellProtocolGuid;
948
949 #endif