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