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