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