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