]> git.proxmox.com Git - mirror_edk2.git/blame - MdePkg/Include/Protocol/Shell.h
MdePkg: Merge ShellBase.h and remove Efi prefix from header files
[mirror_edk2.git] / MdePkg / Include / Protocol / Shell.h
CommitLineData
94b17fa1 1/** @file\r
941b3569 2 EFI Shell protocol as defined in the UEFI Shell 2.0 specification including errata.\r
94b17fa1 3\r
c011b6c9 4 (C) Copyright 2014 Hewlett-Packard Development Company, L.P.<BR>\r
51a09860 5 Copyright (c) 2006 - 2016, Intel Corporation. All rights reserved.<BR>\r
1e6e84c7 6 This program and the accompanying materials\r
7 are licensed and made available under the terms and conditions of the BSD License\r
8 which accompanies this distribution. The full text of the license may be found at\r
9 http://opensource.org/licenses/bsd-license.php\r
10\r
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
94b17fa1 13\r
14**/\r
15\r
51a09860
RN
16#ifndef __EFI_SHELL_PROTOCOL_H__\r
17#define __EFI_SHELL_PROTOCOL_H__\r
94b17fa1 18\r
94b17fa1 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
51a09860
RN
25typedef VOID *SHELL_FILE_HANDLE;\r
26\r
27typedef enum {\r
28 ///\r
29 /// The operation completed successfully.\r
30 ///\r
31 SHELL_SUCCESS = 0,\r
32\r
33 ///\r
34 /// The image failed to load.\r
35 ///\r
36 SHELL_LOAD_ERROR = 1,\r
37\r
38 ///\r
39 /// The parameter was incorrect.\r
40 ///\r
41 SHELL_INVALID_PARAMETER = 2,\r
42\r
43 ///\r
44 /// The operation is not supported.\r
45 ///\r
46 SHELL_UNSUPPORTED = 3,\r
47\r
48 ///\r
49 /// The buffer was not the proper size for the request.\r
50 ///\r
51 SHELL_BAD_BUFFER_SIZE = 4,\r
52\r
53 ///\r
54 /// The buffer was not large enough to hold the requested data.\r
55 /// The required buffer size is returned in the appropriate\r
56 /// parameter when this error occurs.\r
57 ///\r
58 SHELL_BUFFER_TOO_SMALL = 5,\r
59\r
60 ///\r
61 /// There is no data pending upon return.\r
62 ///\r
63 SHELL_NOT_READY = 6,\r
64\r
65 ///\r
66 /// The physical device reported an error while attempting the\r
67 /// operation.\r
68 ///\r
69 SHELL_DEVICE_ERROR = 7,\r
70\r
71 ///\r
72 /// The device cannot be written to.\r
73 ///\r
74 SHELL_WRITE_PROTECTED = 8,\r
75\r
76 ///\r
77 /// The resource has run out.\r
78 ///\r
79 SHELL_OUT_OF_RESOURCES = 9,\r
80\r
81 ///\r
82 /// An inconsistency was detected on the file system causing the\r
83 /// operation to fail.\r
84 ///\r
85 SHELL_VOLUME_CORRUPTED = 10,\r
86\r
87 ///\r
88 /// There is no more space on the file system.\r
89 ///\r
90 SHELL_VOLUME_FULL = 11,\r
91\r
92 ///\r
93 /// The device does not contain any medium to perform the\r
94 /// operation.\r
95 ///\r
96 SHELL_NO_MEDIA = 12,\r
97\r
98 ///\r
99 /// The medium in the device has changed since the last\r
100 /// access.\r
101 ///\r
102 SHELL_MEDIA_CHANGED = 13,\r
103\r
104 ///\r
105 /// The item was not found.\r
106 ///\r
107 SHELL_NOT_FOUND = 14,\r
108\r
109 ///\r
110 /// Access was denied.\r
111 ///\r
112 SHELL_ACCESS_DENIED = 15,\r
113\r
114 // note the skipping of 16 and 17\r
115\r
116 ///\r
117 /// A timeout time expired.\r
118 ///\r
119 SHELL_TIMEOUT = 18,\r
120\r
121 ///\r
122 /// The protocol has not been started.\r
123 ///\r
124 SHELL_NOT_STARTED = 19,\r
125\r
126 ///\r
127 /// The protocol has already been started.\r
128 ///\r
129 SHELL_ALREADY_STARTED = 20,\r
130\r
131 ///\r
132 /// The operation was aborted.\r
133 ///\r
134 SHELL_ABORTED = 21,\r
135\r
136 // note the skipping of 22, 23, and 24\r
137\r
138 ///\r
139 /// A function encountered an internal version that was\r
140 /// incompatible with a version requested by the caller.\r
141 ///\r
142 SHELL_INCOMPATIBLE_VERSION = 25,\r
143\r
144 ///\r
145 /// The function was not performed due to a security violation.\r
146 ///\r
147 SHELL_SECURITY_VIOLATION = 26,\r
148\r
149 ///\r
150 /// The function was performed and resulted in an unequal\r
151 /// comparison..\r
152 ///\r
153 SHELL_NOT_EQUAL = 27\r
154} SHELL_STATUS;\r
155\r
94b17fa1 156\r
d2b4564b 157// replaced EFI_LIST_ENTRY with LIST_ENTRY for simplicity.\r
158// they are identical outside of the name.\r
94b17fa1 159typedef struct {\r
a405b86d 160 LIST_ENTRY Link; ///< Linked list members.\r
161 EFI_STATUS Status; ///< Status of opening the file. Valid only if Handle != NULL.\r
162 CONST CHAR16 *FullName; ///< Fully qualified filename.\r
163 CONST CHAR16 *FileName; ///< name of this file.\r
164 SHELL_FILE_HANDLE Handle; ///< Handle for interacting with the opened file or NULL if closed.\r
165 EFI_FILE_INFO *Info; ///< Pointer to the FileInfo struct for this file or NULL.\r
94b17fa1 166} EFI_SHELL_FILE_INFO;\r
a31bd33c 167\r
94b17fa1 168/**\r
169 Returns whether any script files are currently being processed.\r
170\r
171 @retval TRUE There is at least one script file active.\r
172 @retval FALSE No script files are active now.\r
173\r
174**/\r
175typedef\r
176BOOLEAN\r
177(EFIAPI *EFI_SHELL_BATCH_IS_ACTIVE) (\r
178 VOID\r
179 );\r
180\r
181/**\r
182 Closes the file handle.\r
183\r
1e6e84c7 184 This function closes a specified file handle. All 'dirty' cached file data is\r
185 flushed to the device, and the file is closed. In all cases, the handle is\r
94b17fa1 186 closed.\r
187\r
1e6e84c7 188 @param[in] FileHandle The file handle to be closed.\r
94b17fa1 189\r
a31bd33c 190 @retval EFI_SUCCESS The file closed sucessfully.\r
94b17fa1 191**/\r
192typedef\r
193EFI_STATUS\r
194(EFIAPI *EFI_SHELL_CLOSE_FILE)(\r
a405b86d 195 IN SHELL_FILE_HANDLE FileHandle\r
94b17fa1 196 );\r
197\r
198/**\r
199 Creates a file or directory by name.\r
200\r
201 This function creates an empty new file or directory with the specified attributes and\r
202 returns the new file's handle. If the file already exists and is read-only, then\r
203 EFI_INVALID_PARAMETER will be returned.\r
1e6e84c7 204\r
94b17fa1 205 If the file already existed, it is truncated and its attributes updated. If the file is\r
206 created successfully, the FileHandle is the file's handle, else, the FileHandle is NULL.\r
1e6e84c7 207\r
94b17fa1 208 If the file name begins with >v, then the file handle which is returned refers to the\r
209 shell environment variable with the specified name. If the shell environment variable\r
210 already exists and is non-volatile then EFI_INVALID_PARAMETER is returned.\r
211\r
1e6e84c7 212 @param[in] FileName Pointer to NULL-terminated file path.\r
a405b86d 213 @param[in] FileAttribs The new file's attrbiutes. The different attributes are\r
a31bd33c 214 described in EFI_FILE_PROTOCOL.Open().\r
a405b86d 215 @param[out] FileHandle On return, points to the created file handle or directory's handle.\r
94b17fa1 216\r
a31bd33c 217 @retval EFI_SUCCESS The file was opened. FileHandle points to the new file's handle.\r
94b17fa1 218 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
1e6e84c7 219 @retval EFI_UNSUPPORTED The file path could not be opened.\r
a31bd33c 220 @retval EFI_NOT_FOUND The specified file could not be found on the device, or could not\r
221 file the file system on the device.\r
222 @retval EFI_NO_MEDIA The device has no medium.\r
223 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no\r
224 longer supported.\r
225 @retval EFI_DEVICE_ERROR The device reported an error or can't get the file path according\r
226 the DirName.\r
227 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
228 @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write\r
229 when the media is write-protected.\r
230 @retval EFI_ACCESS_DENIED The service denied access to the file.\r
231 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file.\r
232 @retval EFI_VOLUME_FULL The volume is full.\r
94b17fa1 233**/\r
234typedef\r
235EFI_STATUS\r
236(EFIAPI *EFI_SHELL_CREATE_FILE)(\r
a405b86d 237 IN CONST CHAR16 *FileName,\r
238 IN UINT64 FileAttribs,\r
239 OUT SHELL_FILE_HANDLE *FileHandle\r
94b17fa1 240 );\r
241\r
242/**\r
243 Deletes the file specified by the file handle.\r
244\r
245 This function closes and deletes a file. In all cases, the file handle is closed. If the file\r
246 cannot be deleted, the warning code EFI_WARN_DELETE_FAILURE is returned, but the\r
247 handle is still closed.\r
248\r
941b3569 249 @param[in] FileHandle The file handle to delete.\r
94b17fa1 250\r
1e6e84c7 251 @retval EFI_SUCCESS The file was closed and deleted and the handle was closed.\r
94b17fa1 252 @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not deleted.\r
253**/\r
254typedef\r
255EFI_STATUS\r
256(EFIAPI *EFI_SHELL_DELETE_FILE)(\r
a405b86d 257 IN SHELL_FILE_HANDLE FileHandle\r
94b17fa1 258 );\r
259\r
260/**\r
261 Deletes the file specified by the file name.\r
262\r
263 This function deletes a file.\r
264\r
1e6e84c7 265 @param[in] FileName Points to the NULL-terminated file name.\r
94b17fa1 266\r
1e6e84c7 267 @retval EFI_SUCCESS The file was deleted.\r
94b17fa1 268 @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not deleted.\r
269**/\r
270typedef\r
271EFI_STATUS\r
272(EFIAPI *EFI_SHELL_DELETE_FILE_BY_NAME)(\r
273 IN CONST CHAR16 *FileName\r
274 );\r
275\r
276/**\r
277 Disables the page break output mode.\r
278**/\r
279typedef\r
280VOID\r
281(EFIAPI *EFI_SHELL_DISABLE_PAGE_BREAK) (\r
1e6e84c7 282 VOID\r
283 );\r
94b17fa1 284\r
285/**\r
286 Enables the page break output mode.\r
287**/\r
288typedef\r
289VOID\r
290(EFIAPI *EFI_SHELL_ENABLE_PAGE_BREAK) (\r
1e6e84c7 291 VOID\r
292 );\r
94b17fa1 293\r
294/**\r
295 Execute the command line.\r
296\r
297 This function creates a nested instance of the shell and executes the specified\r
298 command (CommandLine) with the specified environment (Environment). Upon return,\r
299 the status code returned by the specified command is placed in StatusCode.\r
1e6e84c7 300\r
94b17fa1 301 If Environment is NULL, then the current environment is used and all changes made\r
302 by the commands executed will be reflected in the current environment. If the\r
303 Environment is non-NULL, then the changes made will be discarded.\r
1e6e84c7 304\r
94b17fa1 305 The CommandLine is executed from the current working directory on the current\r
306 device.\r
307\r
1e6e84c7 308 @param[in] ParentImageHandle A handle of the image that is executing the specified\r
309 command line.\r
310 @param[in] CommandLine Points to the NULL-terminated UCS-2 encoded string\r
941b3569 311 containing the command line. If NULL then the command-\r
312 line will be empty.\r
1e6e84c7 313 @param[in] Environment Points to a NULL-terminated array of environment\r
314 variables with the format 'x=y', where x is the\r
941b3569 315 environment variable name and y is the value. If this\r
316 is NULL, then the current shell environment is used.\r
317 @param[out] ErrorCode Points to the status code returned by the command.\r
318\r
1e6e84c7 319 @retval EFI_SUCCESS The command executed successfully. The status code\r
941b3569 320 returned by the command is pointed to by StatusCode.\r
94b17fa1 321 @retval EFI_INVALID_PARAMETER The parameters are invalid.\r
941b3569 322 @retval EFI_OUT_OF_RESOURCES Out of resources.\r
323 @retval EFI_UNSUPPORTED Nested shell invocations are not allowed.\r
94b17fa1 324**/\r
325typedef\r
326EFI_STATUS\r
327(EFIAPI *EFI_SHELL_EXECUTE) (\r
a405b86d 328 IN EFI_HANDLE *ParentImageHandle,\r
329 IN CHAR16 *CommandLine OPTIONAL,\r
330 IN CHAR16 **Environment OPTIONAL,\r
331 OUT EFI_STATUS *StatusCode OPTIONAL\r
94b17fa1 332 );\r
333\r
334/**\r
335 Find files that match a specified pattern.\r
336\r
337 This function searches for all files and directories that match the specified\r
338 FilePattern. The FilePattern can contain wild-card characters. The resulting file\r
339 information is placed in the file list FileList.\r
340\r
341 The files in the file list are not opened. The OpenMode field is set to 0 and the FileInfo\r
342 field is set to NULL.\r
343\r
1e6e84c7 344 @param[in] FilePattern Points to a NULL-terminated shell file path, including wildcards.\r
345 @param[out] FileList On return, points to the start of a file list containing the names\r
346 of all matching files or else points to NULL if no matching files\r
941b3569 347 were found.\r
94b17fa1 348\r
941b3569 349 @retval EFI_SUCCESS Files found.\r
350 @retval EFI_NOT_FOUND No files found.\r
a31bd33c 351 @retval EFI_NO_MEDIA The device has no media.\r
352 @retval EFI_DEVICE_ERROR The device reported an error.\r
353 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
94b17fa1 354**/\r
355typedef\r
356EFI_STATUS\r
357(EFIAPI *EFI_SHELL_FIND_FILES)(\r
a405b86d 358 IN CONST CHAR16 *FilePattern,\r
359 OUT EFI_SHELL_FILE_INFO **FileList\r
94b17fa1 360 );\r
361\r
362/**\r
363 Find all files in a specified directory.\r
364\r
941b3569 365 @param[in] FileDirHandle Handle of the directory to search.\r
1e6e84c7 366 @param[out] FileList On return, points to the list of files in the directory\r
941b3569 367 or NULL if there are no files in the directory.\r
94b17fa1 368\r
941b3569 369 @retval EFI_SUCCESS File information was returned successfully.\r
370 @retval EFI_VOLUME_CORRUPTED The file system structures have been corrupted.\r
371 @retval EFI_DEVICE_ERROR The device reported an error.\r
372 @retval EFI_NO_MEDIA The device media is not present.\r
94b17fa1 373**/\r
374typedef\r
375EFI_STATUS\r
376(EFIAPI *EFI_SHELL_FIND_FILES_IN_DIR)(\r
a405b86d 377IN SHELL_FILE_HANDLE FileDirHandle,\r
378OUT EFI_SHELL_FILE_INFO **FileList\r
94b17fa1 379);\r
380\r
381/**\r
a31bd33c 382 Flushes data back to a device.\r
1e6e84c7 383\r
94b17fa1 384 This function flushes all modified data associated with a file to a device.\r
385\r
1e6e84c7 386 @param[in] FileHandle The handle of the file to flush.\r
94b17fa1 387\r
388 @retval EFI_SUCCESS The data was flushed.\r
389 @retval EFI_NO_MEDIA The device has no medium.\r
390 @retval EFI_DEVICE_ERROR The device reported an error.\r
391 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
392 @retval EFI_WRITE_PROTECTED The file or medium is write-protected.\r
393 @retval EFI_ACCESS_DENIED The file was opened read-only.\r
394 @retval EFI_VOLUME_FULL The volume is full.\r
395**/\r
396typedef\r
397EFI_STATUS\r
398(EFIAPI *EFI_SHELL_FLUSH_FILE)(\r
a405b86d 399 IN SHELL_FILE_HANDLE FileHandle\r
94b17fa1 400 );\r
401\r
402/**\r
403 Frees the file list.\r
1e6e84c7 404\r
94b17fa1 405 This function cleans up the file list and any related data structures. It has no\r
406 impact on the files themselves.\r
407\r
1e6e84c7 408 @param[in] FileList The file list to free. Type EFI_SHELL_FILE_INFO is\r
409 defined in OpenFileList().\r
94b17fa1 410\r
411 @retval EFI_SUCCESS Free the file list successfully.\r
412**/\r
413typedef\r
414EFI_STATUS\r
415(EFIAPI *EFI_SHELL_FREE_FILE_LIST) (\r
416 IN EFI_SHELL_FILE_INFO **FileList\r
417 );\r
418\r
419/**\r
420 Returns the current directory on the specified device.\r
421\r
422 If FileSystemMapping is NULL, it returns the current working directory. If the\r
423 FileSystemMapping is not NULL, it returns the current directory associated with the\r
424 FileSystemMapping. In both cases, the returned name includes the file system\r
425 mapping (i.e. fs0:\current-dir).\r
426\r
fbd2dfad
QS
427 Note that the current directory string should exclude the tailing backslash character.\r
428\r
1e6e84c7 429 @param[in] FileSystemMapping A pointer to the file system mapping. If NULL,\r
94b17fa1 430 then the current working directory is returned.\r
1e6e84c7 431\r
94b17fa1 432 @retval !=NULL The current directory.\r
433 @retval NULL Current directory does not exist.\r
434**/\r
435typedef\r
436CONST CHAR16 *\r
437(EFIAPI *EFI_SHELL_GET_CUR_DIR) (\r
438 IN CONST CHAR16 *FileSystemMapping OPTIONAL\r
439 );\r
440\r
441typedef UINT32 EFI_SHELL_DEVICE_NAME_FLAGS;\r
442#define EFI_DEVICE_NAME_USE_COMPONENT_NAME 0x00000001\r
443#define EFI_DEVICE_NAME_USE_DEVICE_PATH 0x00000002\r
a31bd33c 444\r
94b17fa1 445/**\r
446 Gets the name of the device specified by the device handle.\r
447\r
448 This function gets the user-readable name of the device specified by the device\r
449 handle. If no user-readable name could be generated, then *BestDeviceName will be\r
450 NULL and EFI_NOT_FOUND will be returned.\r
451\r
d2b4564b 452 If EFI_DEVICE_NAME_USE_COMPONENT_NAME is set, then the function will return the\r
69817bf8 453 device's name using the EFI_COMPONENT_NAME2_PROTOCOL, if present on\r
d2b4564b 454 DeviceHandle.\r
455\r
456 If EFI_DEVICE_NAME_USE_DEVICE_PATH is set, then the function will return the\r
69817bf8 457 device's name using the EFI_DEVICE_PATH_PROTOCOL, if present on DeviceHandle.\r
d2b4564b 458 If both EFI_DEVICE_NAME_USE_COMPONENT_NAME and\r
459 EFI_DEVICE_NAME_USE_DEVICE_PATH are set, then\r
460 EFI_DEVICE_NAME_USE_COMPONENT_NAME will have higher priority.\r
461\r
941b3569 462 @param[in] DeviceHandle The handle of the device.\r
1e6e84c7 463 @param[in] Flags Determines the possible sources of component names.\r
464 @param[in] Language A pointer to the language specified for the device\r
465 name, in the same format as described in the UEFI\r
a31bd33c 466 specification, Appendix M.\r
1e6e84c7 467 @param[out] BestDeviceName On return, points to the callee-allocated NULL-\r
468 terminated name of the device. If no device name\r
469 could be found, points to NULL. The name must be\r
94b17fa1 470 freed by the caller...\r
471\r
472 @retval EFI_SUCCESS Get the name successfully.\r
473 @retval EFI_NOT_FOUND Fail to get the device name.\r
474**/\r
475typedef\r
476EFI_STATUS\r
e26d7b59 477(EFIAPI *EFI_SHELL_GET_DEVICE_NAME) (\r
a405b86d 478 IN EFI_HANDLE DeviceHandle,\r
479 IN EFI_SHELL_DEVICE_NAME_FLAGS Flags,\r
480 IN CHAR8 *Language,\r
481 OUT CHAR16 **BestDeviceName\r
94b17fa1 482 );\r
483\r
484/**\r
485 Gets the device path from the mapping.\r
486\r
487 This function gets the device path associated with a mapping.\r
488\r
941b3569 489 @param[in] Mapping A pointer to the mapping\r
94b17fa1 490\r
1e6e84c7 491 @retval !=NULL Pointer to the device path that corresponds to the\r
492 device mapping. The returned pointer does not need\r
94b17fa1 493 to be freed.\r
1e6e84c7 494 @retval NULL There is no device path associated with the\r
94b17fa1 495 specified mapping.\r
496**/\r
497typedef\r
498CONST EFI_DEVICE_PATH_PROTOCOL *\r
499(EFIAPI *EFI_SHELL_GET_DEVICE_PATH_FROM_MAP) (\r
500 IN CONST CHAR16 *Mapping\r
501 );\r
502\r
503/**\r
504 Converts a file system style name to a device path.\r
505\r
506 This function converts a file system style name to a device path, by replacing any\r
507 mapping references to the associated device path.\r
508\r
a31bd33c 509 @param[in] Path The pointer to the path.\r
94b17fa1 510\r
1e6e84c7 511 @return The pointer of the file path. The file path is callee\r
94b17fa1 512 allocated and should be freed by the caller.\r
513**/\r
514typedef\r
515EFI_DEVICE_PATH_PROTOCOL *\r
516(EFIAPI *EFI_SHELL_GET_DEVICE_PATH_FROM_FILE_PATH) (\r
517 IN CONST CHAR16 *Path\r
518 );\r
519\r
520/**\r
941b3569 521 Gets either a single or list of environment variables.\r
522\r
1e6e84c7 523 If name is not NULL then this function returns the current value of the specified\r
941b3569 524 environment variable.\r
94b17fa1 525\r
1e6e84c7 526 If Name is NULL than a list of all environment variable names is returned. Each a\r
941b3569 527 NULL terminated string with a double NULL terminating the list.\r
94b17fa1 528\r
1e6e84c7 529 @param[in] Name A pointer to the environment variable name. If\r
530 Name is NULL, then the function will return all\r
531 of the defined shell environment variables. In\r
532 the case where multiple environment variables are\r
533 being returned, each variable will be terminated by\r
534 a NULL, and the list will be terminated by a double\r
941b3569 535 NULL.\r
94b17fa1 536\r
1e6e84c7 537 @return A pointer to the returned string.\r
941b3569 538 The returned pointer does not need to be freed by the caller.\r
539\r
1e6e84c7 540 @retval NULL The environment variable doesn't exist or there are\r
941b3569 541 no environment variables.\r
94b17fa1 542**/\r
543typedef\r
544CONST CHAR16 *\r
545(EFIAPI *EFI_SHELL_GET_ENV) (\r
941b3569 546 IN CONST CHAR16 *Name OPTIONAL\r
94b17fa1 547 );\r
548\r
044ea4e5
JC
549/**\r
550 Gets the environment variable and Attributes, or list of environment variables. Can be \r
551 used instead of GetEnv().\r
552\r
553 This function returns the current value of the specified environment variable and\r
554 the Attributes. If no variable name was specified, then all of the known\r
555 variables will be returned.\r
556\r
557 @param[in] Name A pointer to the environment variable name. If Name is NULL,\r
558 then the function will return all of the defined shell \r
559 environment variables. In the case where multiple environment\r
560 variables are being returned, each variable will be terminated \r
561 by a NULL, and the list will be terminated by a double NULL.\r
562 @param[out] Attributes If not NULL, a pointer to the returned attributes bitmask for\r
563 the environment variable. In the case where Name is NULL, and\r
564 multiple environment variables are being returned, Attributes\r
565 is undefined.\r
566\r
f5ba4007
QS
567 @retval NULL The environment variable doesn't exist. \r
568 @return The environment variable's value. The returned pointer does not \r
044ea4e5
JC
569 need to be freed by the caller. \r
570**/\r
571typedef\r
572CONST CHAR16 *\r
573(EFIAPI *EFI_SHELL_GET_ENV_EX) (\r
574 IN CONST CHAR16 *Name,\r
575 OUT UINT32 *Attributes OPTIONAL\r
576 );\r
577\r
94b17fa1 578/**\r
579 Gets the file information from an open file handle.\r
580\r
581 This function allocates a buffer to store the file's information. It's the caller's\r
582 responsibility to free the buffer.\r
583\r
a31bd33c 584 @param[in] FileHandle A File Handle.\r
94b17fa1 585\r
1e6e84c7 586 @retval NULL Cannot get the file info.\r
587 @return A pointer to a buffer with file information.\r
94b17fa1 588**/\r
589typedef\r
590EFI_FILE_INFO *\r
591(EFIAPI *EFI_SHELL_GET_FILE_INFO)(\r
a405b86d 592 IN SHELL_FILE_HANDLE FileHandle\r
94b17fa1 593 );\r
594\r
595/**\r
596 Converts a device path to a file system-style path.\r
597\r
598 This function converts a device path to a file system path by replacing part, or all, of\r
599 the device path with the file-system mapping. If there are more than one application\r
600 file system mappings, the one that most closely matches Path will be used.\r
601\r
1e6e84c7 602 @param[in] Path The pointer to the device path.\r
94b17fa1 603\r
1e6e84c7 604 @return The pointer of the NULL-terminated file path. The path\r
94b17fa1 605 is callee-allocated and should be freed by the caller.\r
606**/\r
607typedef\r
608CHAR16 *\r
609(EFIAPI *EFI_SHELL_GET_FILE_PATH_FROM_DEVICE_PATH) (\r
610 IN CONST EFI_DEVICE_PATH_PROTOCOL *Path\r
611 );\r
612\r
613/**\r
a31bd33c 614 Gets a file's current position.\r
94b17fa1 615\r
616 This function returns the current file position for the file handle. For directories, the\r
617 current file position has no meaning outside of the file system driver and as such, the\r
618 operation is not supported.\r
619\r
941b3569 620 @param[in] FileHandle The file handle on which to get the current position.\r
1e6e84c7 621 @param[out] Position Byte position from the start of the file.\r
94b17fa1 622\r
623 @retval EFI_SUCCESS Data was accessed.\r
624 @retval EFI_UNSUPPORTED The request is not valid on open directories.\r
625**/\r
626typedef\r
627EFI_STATUS\r
628(EFIAPI *EFI_SHELL_GET_FILE_POSITION)(\r
a405b86d 629 IN SHELL_FILE_HANDLE FileHandle,\r
94b17fa1 630 OUT UINT64 *Position\r
631 );\r
632\r
633/**\r
634 Gets the size of a file.\r
635\r
636 This function returns the size of the file specified by FileHandle.\r
637\r
941b3569 638 @param[in] FileHandle The handle of the file.\r
639 @param[out] Size The size of this file.\r
94b17fa1 640\r
641 @retval EFI_SUCCESS Get the file's size.\r
642 @retval EFI_DEVICE_ERROR Can't access the file.\r
643**/\r
644typedef\r
645EFI_STATUS\r
646(EFIAPI *EFI_SHELL_GET_FILE_SIZE)(\r
a405b86d 647 IN SHELL_FILE_HANDLE FileHandle,\r
94b17fa1 648 OUT UINT64 *Size\r
649 );\r
650\r
044ea4e5
JC
651/**\r
652 Get the GUID value from a human readable name.\r
653\r
654 If GuidName is a known GUID name, then update Guid to have the correct value for\r
655 that GUID.\r
656\r
657 This function is only available when the major and minor versions in the\r
658 EfiShellProtocol are greater than or equal to 2 and 1, respectively.\r
659\r
660 @param[in] GuidName A pointer to the localized name for the GUID being queried.\r
661 @param[out] Guid A pointer to the GUID structure to be filled in.\r
662\r
663 @retval EFI_SUCCESS The operation was successful.\r
664 @retval EFI_INVALID_PARAMETER Guid was NULL.\r
665 @retval EFI_INVALID_PARAMETER GuidName was NULL.\r
666 @retval EFI_NOT_FOUND GuidName is not a known GUID Name.\r
667**/\r
668typedef\r
669EFI_STATUS\r
670(EFIAPI *EFI_SHELL_GET_GUID_FROM_NAME)(\r
671 IN CONST CHAR16 *GuidName,\r
672 OUT EFI_GUID *Guid\r
673 );\r
674\r
675/**\r
676 Get the human readable name for a GUID from the value.\r
677\r
678 If Guid is assigned a name, then update *GuidName to point to the name. The callee\r
679 should not modify the value.\r
680\r
681 This function is only available when the major and minor versions in the\r
682 EfiShellProtocol are greater than or equal to 2 and 1, respectively.\r
683\r
684 @param[in] Guid A pointer to the GUID being queried.\r
685 @param[out] GuidName A pointer to a pointer the localized to name for the GUID being requested\r
686\r
687 @retval EFI_SUCCESS The operation was successful.\r
688 @retval EFI_INVALID_PARAMETER Guid was NULL.\r
689 @retval EFI_INVALID_PARAMETER GuidName was NULL.\r
690 @retval EFI_NOT_FOUND Guid is not assigned a name.\r
691**/\r
692typedef\r
693EFI_STATUS\r
694(EFIAPI *EFI_SHELL_GET_GUID_NAME)(\r
695 IN CONST EFI_GUID *Guid,\r
696 OUT CONST CHAR16 **GuidName\r
697 );\r
698\r
94b17fa1 699/**\r
700 Return help information about a specific command.\r
701\r
702 This function returns the help information for the specified command. The help text\r
703 can be internal to the shell or can be from a UEFI Shell manual page.\r
1e6e84c7 704\r
94b17fa1 705 If Sections is specified, then each section name listed will be compared in a casesensitive\r
706 manner, to the section names described in Appendix B. If the section exists,\r
707 it will be appended to the returned help text. If the section does not exist, no\r
708 information will be returned. If Sections is NULL, then all help text information\r
709 available will be returned.\r
710\r
1e6e84c7 711 @param[in] Command Points to the NULL-terminated UEFI Shell command name.\r
712 @param[in] Sections Points to the NULL-terminated comma-delimited\r
713 section names to return. If NULL, then all\r
94b17fa1 714 sections will be returned.\r
1e6e84c7 715 @param[out] HelpText On return, points to a callee-allocated buffer\r
94b17fa1 716 containing all specified help text.\r
717\r
718 @retval EFI_SUCCESS The help text was returned.\r
1e6e84c7 719 @retval EFI_OUT_OF_RESOURCES The necessary buffer could not be allocated to hold the\r
94b17fa1 720 returned help text.\r
a31bd33c 721 @retval EFI_INVALID_PARAMETER HelpText is NULL.\r
94b17fa1 722 @retval EFI_NOT_FOUND There is no help text available for Command.\r
723**/\r
724typedef\r
725EFI_STATUS\r
726(EFIAPI *EFI_SHELL_GET_HELP_TEXT) (\r
727 IN CONST CHAR16 *Command,\r
b1f95a06 728 IN CONST CHAR16 *Sections OPTIONAL,\r
94b17fa1 729 OUT CHAR16 **HelpText\r
730 );\r
731\r
732/**\r
941b3569 733 Gets the mapping(s) that most closely matches the device path.\r
94b17fa1 734\r
735 This function gets the mapping which corresponds to the device path *DevicePath. If\r
736 there is no exact match, then the mapping which most closely matches *DevicePath\r
737 is returned, and *DevicePath is updated to point to the remaining portion of the\r
738 device path. If there is an exact match, the mapping is returned and *DevicePath\r
739 points to the end-of-device-path node.\r
740\r
1e6e84c7 741 If there are multiple map names they will be semi-colon seperated in the\r
941b3569 742 NULL-terminated string.\r
743\r
4ff7e37b
ED
744 @param[in, out] DevicePath On entry, points to a device path pointer. On\r
745 exit, updates the pointer to point to the\r
746 portion of the device path after the mapping.\r
94b17fa1 747\r
748 @retval NULL No mapping was found.\r
1e6e84c7 749 @retval !=NULL Pointer to NULL-terminated mapping. The buffer\r
94b17fa1 750 is callee allocated and should be freed by the caller.\r
751**/\r
752typedef\r
753CONST CHAR16 *\r
754(EFIAPI *EFI_SHELL_GET_MAP_FROM_DEVICE_PATH) (\r
755 IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r
756 );\r
757\r
758/**\r
759 Gets the enable status of the page break output mode.\r
760\r
761 User can use this function to determine current page break mode.\r
762\r
a31bd33c 763 @retval TRUE The page break output mode is enabled.\r
764 @retval FALSE The page break output mode is disabled.\r
94b17fa1 765**/\r
766typedef\r
767BOOLEAN\r
768(EFIAPI *EFI_SHELL_GET_PAGE_BREAK) (\r
769 VOID\r
770 );\r
771\r
772/**\r
773 Judges whether the active shell is the root shell.\r
774\r
775 This function makes the user to know that whether the active Shell is the root shell.\r
776\r
777 @retval TRUE The active Shell is the root Shell.\r
778 @retval FALSE The active Shell is NOT the root Shell.\r
779**/\r
780typedef\r
781BOOLEAN\r
782(EFIAPI *EFI_SHELL_IS_ROOT_SHELL) (\r
783VOID\r
784);\r
785\r
786/**\r
787 Opens a file or a directory by file name.\r
788\r
789 This function opens the specified file in the specified OpenMode and returns a file\r
790 handle.\r
1e6e84c7 791 If the file name begins with '>v', then the file handle which is returned refers to the\r
94b17fa1 792 shell environment variable with the specified name. If the shell environment variable\r
793 exists, is non-volatile and the OpenMode indicates EFI_FILE_MODE_WRITE, then\r
794 EFI_INVALID_PARAMETER is returned.\r
795\r
1e6e84c7 796 If the file name is '>i', then the file handle which is returned refers to the standard\r
94b17fa1 797 input. If the OpenMode indicates EFI_FILE_MODE_WRITE, then EFI_INVALID_PARAMETER\r
798 is returned.\r
799\r
1e6e84c7 800 If the file name is '>o', then the file handle which is returned refers to the standard\r
94b17fa1 801 output. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER\r
802 is returned.\r
803\r
1e6e84c7 804 If the file name is '>e', then the file handle which is returned refers to the standard\r
94b17fa1 805 error. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER\r
806 is returned.\r
807\r
1e6e84c7 808 If the file name is 'NUL', then the file handle that is returned refers to the standard NUL\r
94b17fa1 809 file. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER is\r
810 returned.\r
811\r
812 If return EFI_SUCCESS, the FileHandle is the opened file's handle, else, the\r
813 FileHandle is NULL.\r
814\r
1e6e84c7 815 @param[in] FileName Points to the NULL-terminated UCS-2 encoded file name.\r
941b3569 816 @param[out] FileHandle On return, points to the file handle.\r
1e6e84c7 817 @param[in] OpenMode File open mode. Either EFI_FILE_MODE_READ or\r
818 EFI_FILE_MODE_WRITE from section 12.4 of the UEFI\r
94b17fa1 819 Specification.\r
820 @retval EFI_SUCCESS The file was opened. FileHandle has the opened file's handle.\r
821 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value. FileHandle is NULL.\r
822 @retval EFI_UNSUPPORTED Could not open the file path. FileHandle is NULL.\r
823 @retval EFI_NOT_FOUND The specified file could not be found on the device or the file\r
824 system could not be found on the device. FileHandle is NULL.\r
825 @retval EFI_NO_MEDIA The device has no medium. FileHandle is NULL.\r
826 @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no\r
827 longer supported. FileHandle is NULL.\r
828 @retval EFI_DEVICE_ERROR The device reported an error or can't get the file path according\r
829 the FileName. FileHandle is NULL.\r
830 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. FileHandle is NULL.\r
831 @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write\r
832 when the media is write-protected. FileHandle is NULL.\r
833 @retval EFI_ACCESS_DENIED The service denied access to the file. FileHandle is NULL.\r
834 @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file. FileHandle\r
835 is NULL.\r
836 @retval EFI_VOLUME_FULL The volume is full. FileHandle is NULL.\r
837**/\r
838typedef\r
839EFI_STATUS\r
840(EFIAPI *EFI_SHELL_OPEN_FILE_BY_NAME) (\r
841 IN CONST CHAR16 *FileName,\r
a405b86d 842 OUT SHELL_FILE_HANDLE *FileHandle,\r
94b17fa1 843 IN UINT64 OpenMode\r
844 );\r
845\r
846/**\r
847 Opens the files that match the path specified.\r
848\r
849 This function opens all of the files specified by Path. Wildcards are processed\r
1e6e84c7 850 according to the rules specified in UEFI Shell 2.0 spec section 3.7.1. Each\r
94b17fa1 851 matching file has an EFI_SHELL_FILE_INFO structure created in a linked list.\r
852\r
4ff7e37b
ED
853 @param[in] Path A pointer to the path string.\r
854 @param[in] OpenMode Specifies the mode used to open each file, EFI_FILE_MODE_READ or\r
855 EFI_FILE_MODE_WRITE.\r
856 @param[in, out] FileList Points to the start of a list of files opened.\r
94b17fa1 857\r
858 @retval EFI_SUCCESS Create the file list successfully.\r
a31bd33c 859 @return Can't create the file list.\r
94b17fa1 860**/\r
861typedef\r
862EFI_STATUS\r
863(EFIAPI *EFI_SHELL_OPEN_FILE_LIST) (\r
864 IN CHAR16 *Path,\r
865 IN UINT64 OpenMode,\r
866 IN OUT EFI_SHELL_FILE_INFO **FileList\r
867 );\r
868\r
869/**\r
870 Opens the root directory of a device.\r
871\r
872 This function opens the root directory of a device and returns a file handle to it.\r
873\r
941b3569 874 @param[in] DevicePath Points to the device path corresponding to the device where the\r
94b17fa1 875 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL is installed.\r
941b3569 876 @param[out] FileHandle On exit, points to the file handle corresponding to the root directory on the\r
94b17fa1 877 device.\r
878\r
879 @retval EFI_SUCCESS Root opened successfully.\r
880 @retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be found or the root directory\r
881 could not be opened.\r
882 @retval EFI_VOLUME_CORRUPTED The data structures in the volume were corrupted.\r
a31bd33c 883 @retval EFI_DEVICE_ERROR The device had an error.\r
94b17fa1 884**/\r
885typedef\r
886EFI_STATUS\r
887(EFIAPI *EFI_SHELL_OPEN_ROOT)(\r
888 IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
a405b86d 889 OUT SHELL_FILE_HANDLE *FileHandle\r
94b17fa1 890 );\r
891\r
892/**\r
a31bd33c 893 Opens the root directory of a device on a handle.\r
94b17fa1 894\r
895 This function opens the root directory of a device and returns a file handle to it.\r
896\r
941b3569 897 @param[in] DeviceHandle The handle of the device that contains the volume.\r
898 @param[out] FileHandle On exit, points to the file handle corresponding to the root directory on the\r
94b17fa1 899 device.\r
900\r
901 @retval EFI_SUCCESS Root opened successfully.\r
902 @retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be found or the root directory\r
903 could not be opened.\r
904 @retval EFI_VOLUME_CORRUPTED The data structures in the volume were corrupted.\r
a31bd33c 905 @retval EFI_DEVICE_ERROR The device had an error.\r
94b17fa1 906**/\r
907typedef\r
908EFI_STATUS\r
909(EFIAPI *EFI_SHELL_OPEN_ROOT_BY_HANDLE)(\r
910 IN EFI_HANDLE DeviceHandle,\r
a405b86d 911 OUT SHELL_FILE_HANDLE *FileHandle\r
94b17fa1 912 );\r
913\r
914/**\r
915 Reads data from the file.\r
916\r
917 If FileHandle is not a directory, the function reads the requested number of bytes\r
918 from the file at the file's current position and returns them in Buffer. If the read goes\r
919 beyond the end of the file, the read length is truncated to the end of the file. The file's\r
920 current position is increased by the number of bytes returned.\r
921 If FileHandle is a directory, then an error is returned.\r
922\r
4ff7e37b
ED
923 @param[in] FileHandle The opened file handle for read.\r
924 @param[in] ReadSize On input, the size of Buffer, in bytes. On output, the amount of data read.\r
925 @param[in, out] Buffer The buffer in which data is read.\r
94b17fa1 926\r
927 @retval EFI_SUCCESS Data was read.\r
a31bd33c 928 @retval EFI_NO_MEDIA The device has no media.\r
929 @retval EFI_DEVICE_ERROR The device reported an error.\r
930 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
931 @retval EFI_BUFFER_TO_SMALL Buffer is too small. ReadSize contains required size.\r
94b17fa1 932**/\r
933typedef\r
934EFI_STATUS\r
935(EFIAPI *EFI_SHELL_READ_FILE) (\r
a405b86d 936 IN SHELL_FILE_HANDLE FileHandle,\r
94b17fa1 937 IN OUT UINTN *ReadSize,\r
941b3569 938 IN OUT VOID *Buffer\r
94b17fa1 939 );\r
940\r
044ea4e5
JC
941/**\r
942 Register a GUID and a localized human readable name for it.\r
943\r
944 If Guid is not assigned a name, then assign GuidName to Guid. This list of GUID\r
945 names must be used whenever a shell command outputs GUID information.\r
946\r
947 This function is only available when the major and minor versions in the\r
948 EfiShellProtocol are greater than or equal to 2 and 1, respectively.\r
949\r
950 @param[in] Guid A pointer to the GUID being registered.\r
951 @param[in] GuidName A pointer to the localized name for the GUID being registered.\r
952\r
953 @retval EFI_SUCCESS The operation was successful.\r
954 @retval EFI_INVALID_PARAMETER Guid was NULL.\r
955 @retval EFI_INVALID_PARAMETER GuidName was NULL.\r
956 @retval EFI_ACCESS_DENIED Guid already is assigned a name.\r
957**/\r
958typedef\r
959EFI_STATUS\r
960(EFIAPI *EFI_SHELL_REGISTER_GUID_NAME)(\r
961 IN CONST EFI_GUID *Guid,\r
962 IN CONST CHAR16 *GuidName\r
963 );\r
964\r
94b17fa1 965/**\r
966 Deletes the duplicate file names files in the given file list.\r
967\r
941b3569 968 @param[in] FileList A pointer to the first entry in the file list.\r
94b17fa1 969\r
970 @retval EFI_SUCCESS Always success.\r
971**/\r
972typedef\r
973EFI_STATUS\r
974(EFIAPI *EFI_SHELL_REMOVE_DUP_IN_FILE_LIST) (\r
975 IN EFI_SHELL_FILE_INFO **FileList\r
976 );\r
977\r
978/**\r
979 Changes a shell command alias.\r
980\r
981 This function creates an alias for a shell command.\r
982\r
1e6e84c7 983 @param[in] Command Points to the NULL-terminated shell command or existing alias.\r
984 @param[in] Alias Points to the NULL-terminated alias for the shell command. If this is NULL, and\r
94b17fa1 985 Command refers to an alias, that alias will be deleted.\r
941b3569 986 @param[in] Replace If TRUE and the alias already exists, then the existing alias will be replaced. If\r
94b17fa1 987 FALSE and the alias already exists, then the existing alias is unchanged and\r
988 EFI_ACCESS_DENIED is returned.\r
1e6e84c7 989 @param[in] Volatile if TRUE the Alias being set will be stored in a volatile fashion. if FALSE the\r
941b3569 990 Alias being set will be stored in a non-volatile fashion.\r
94b17fa1 991\r
992 @retval EFI_SUCCESS Alias created or deleted successfully.\r
993 @retval EFI_ACCESS_DENIED The alias is a built-in alias or already existed and Replace was set to\r
994 FALSE.\r
995**/\r
996typedef\r
997EFI_STATUS\r
998(EFIAPI *EFI_SHELL_SET_ALIAS)(\r
999 IN CONST CHAR16 *Command,\r
1000 IN CONST CHAR16 *Alias,\r
941b3569 1001 IN BOOLEAN Replace,\r
1002 IN BOOLEAN Volatile\r
1003 );\r
1004\r
1005/**\r
369d5f2e 1006 This function returns the command associated with a alias or a list of all\r
1007 alias'.\r
941b3569 1008\r
1e6e84c7 1009 @param[in] Alias Points to the NULL-terminated shell alias.\r
1010 If this parameter is NULL, then all\r
941b3569 1011 aliases will be returned in ReturnedData.\r
a31bd33c 1012 @param[out] Volatile Upon return of a single command if TRUE indicates\r
369d5f2e 1013 this is stored in a volatile fashion. FALSE otherwise.\r
1e6e84c7 1014 @return If Alias is not NULL, it will return a pointer to\r
1015 the NULL-terminated command for that alias.\r
1016 If Alias is NULL, ReturnedData points to a ';'\r
1017 delimited list of alias (e.g.\r
1018 ReturnedData = "dir;del;copy;mfp") that is NULL-terminated.\r
36a9d672 1019 @retval NULL An error ocurred.\r
a31bd33c 1020 @retval NULL Alias was not a valid Alias.\r
941b3569 1021**/\r
1e6e84c7 1022typedef\r
ea109f6b 1023CONST CHAR16 *\r
941b3569 1024(EFIAPI *EFI_SHELL_GET_ALIAS)(\r
369d5f2e 1025 IN CONST CHAR16 *Alias,\r
1026 OUT BOOLEAN *Volatile OPTIONAL\r
94b17fa1 1027 );\r
1028\r
1029/**\r
1030 Changes the current directory on the specified device.\r
1031\r
1032 If the FileSystem is NULL, and the directory Dir does not contain a file system's\r
1033 mapped name, this function changes the current working directory. If FileSystem is\r
1034 NULL and the directory Dir contains a mapped name, then the current file system and\r
1035 the current directory on that file system are changed.\r
1036\r
1037 If FileSystem is not NULL, and Dir is NULL, then this changes the current working file\r
1038 system.\r
1039\r
1040 If FileSystem is not NULL and Dir is not NULL, then this function changes the current\r
1041 directory on the specified file system.\r
1042\r
1043 If the current working directory or the current working file system is changed then the\r
1e6e84c7 1044 %cwd% environment variable will be updated.\r
94b17fa1 1045\r
941b3569 1046 @param[in] FileSystem A pointer to the file system's mapped name. If NULL, then the current working\r
94b17fa1 1047 directory is changed.\r
1e6e84c7 1048 @param[in] Dir Points to the NULL-terminated directory on the device specified by FileSystem.\r
94b17fa1 1049\r
94b17fa1 1050 @retval NULL Current directory does not exist.\r
1e6e84c7 1051 @return The current directory.\r
94b17fa1 1052**/\r
1053typedef\r
1054EFI_STATUS\r
1055(EFIAPI *EFI_SHELL_SET_CUR_DIR) (\r
1056 IN CONST CHAR16 *FileSystem OPTIONAL,\r
1057 IN CONST CHAR16 *Dir\r
1058 );\r
1059\r
1060/**\r
1061 Sets the environment variable.\r
1062\r
1063 This function changes the current value of the specified environment variable. If the\r
1064 environment variable exists and the Value is an empty string, then the environment\r
1065 variable is deleted. If the environment variable exists and the Value is not an empty\r
1066 string, then the value of the environment variable is changed. If the environment\r
1067 variable does not exist and the Value is an empty string, there is no action. If the\r
1068 environment variable does not exist and the Value is a non-empty string, then the\r
1069 environment variable is created and assigned the specified value.\r
1e6e84c7 1070\r
1071 For a description of volatile and non-volatile environment variables, see UEFI Shell\r
94b17fa1 1072 2.0 specification section 3.6.1.\r
1073\r
1e6e84c7 1074 @param[in] Name Points to the NULL-terminated environment variable name.\r
1075 @param[in] Value Points to the NULL-terminated environment variable value. If the value is an\r
94b17fa1 1076 empty string then the environment variable is deleted.\r
125c2cf4 1077 @param[in] Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).\r
94b17fa1 1078\r
1079 @retval EFI_SUCCESS The environment variable was successfully updated.\r
1080**/\r
1081typedef\r
1082EFI_STATUS\r
1083(EFIAPI *EFI_SHELL_SET_ENV) (\r
1084 IN CONST CHAR16 *Name,\r
1085 IN CONST CHAR16 *Value,\r
1086 IN BOOLEAN Volatile\r
1087 );\r
1088\r
1089/**\r
1090 Sets the file information to an opened file handle.\r
1091\r
1e6e84c7 1092 This function changes file information. All file information in the EFI_FILE_INFO\r
1093 struct will be updated to the passed in data.\r
94b17fa1 1094\r
1e6e84c7 1095 @param[in] FileHandle A file handle.\r
a31bd33c 1096 @param[in] FileInfo Points to new file information.\r
94b17fa1 1097\r
1098 @retval EFI_SUCCESS The information was set.\r
1099 @retval EFI_NO_MEDIA The device has no medium.\r
1100 @retval EFI_DEVICE_ERROR The device reported an error.\r
1101 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
1102 @retval EFI_WRITE_PROTECTED The file or medium is write-protected.\r
1103 @retval EFI_ACCESS_DENIED The file was opened read-only.\r
1104 @retval EFI_VOLUME_FULL The volume is full.\r
1105 @retval EFI_BAD_BUFFER_SIZE BufferSize is smaller than the size of EFI_FILE_INFO.\r
1106**/\r
1107typedef\r
1108EFI_STATUS\r
1109(EFIAPI *EFI_SHELL_SET_FILE_INFO)(\r
a405b86d 1110 IN SHELL_FILE_HANDLE FileHandle,\r
94b17fa1 1111 IN CONST EFI_FILE_INFO *FileInfo\r
1112 );\r
1113\r
1114/**\r
a31bd33c 1115 Sets a file's current position.\r
94b17fa1 1116\r
1117 This function sets the current file position for the handle to the position supplied. With\r
1118 the exception of seeking to position 0xFFFFFFFFFFFFFFFF, only absolute positioning is\r
1119 supported, and seeking past the end of the file is allowed (a subsequent write would\r
1120 grow the file). Seeking to position 0xFFFFFFFFFFFFFFFF causes the current position\r
1121 to be set to the end of the file.\r
1122\r
a31bd33c 1123 @param[in] FileHandle The file handle on which requested position will be set.\r
1124 @param[in] Position Byte position from the start of the file.\r
94b17fa1 1125\r
1126 @retval EFI_SUCCESS Data was written.\r
1127 @retval EFI_UNSUPPORTED The seek request for nonzero is not valid on open directories.\r
1128**/\r
1129typedef\r
1130EFI_STATUS\r
1131(EFIAPI *EFI_SHELL_SET_FILE_POSITION)(\r
a405b86d 1132 IN SHELL_FILE_HANDLE FileHandle,\r
94b17fa1 1133 IN UINT64 Position\r
1134 );\r
1135\r
1136/**\r
1137 This function creates a mapping for a device path.\r
1138\r
a31bd33c 1139 @param[in] DevicePath Points to the device path. If this is NULL and Mapping points to a valid mapping,\r
94b17fa1 1140 then the mapping will be deleted.\r
1e6e84c7 1141 @param[in] Mapping Points to the NULL-terminated mapping for the device path.\r
94b17fa1 1142\r
1143 @retval EFI_SUCCESS Mapping created or deleted successfully.\r
1144 @retval EFI_NO_MAPPING There is no handle that corresponds exactly to DevicePath. See the\r
1145 boot service function LocateDevicePath().\r
1146 @retval EFI_ACCESS_DENIED The mapping is a built-in alias.\r
1147**/\r
1148typedef\r
1149EFI_STATUS\r
1150(EFIAPI *EFI_SHELL_SET_MAP)(\r
1151 IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r
1152 IN CONST CHAR16 *Mapping\r
1153 );\r
1154\r
1155/**\r
1156 Writes data to the file.\r
1157\r
1158 This function writes the specified number of bytes to the file at the current file position.\r
1159 The current file position is advanced the actual number of bytes written, which is\r
1160 returned in BufferSize. Partial writes only occur when there has been a data error\r
1161 during the write attempt (such as "volume space full"). The file automatically grows to\r
1162 hold the data, if required.\r
1163\r
1164 Direct writes to opened directories are not supported.\r
1165\r
4ff7e37b
ED
1166 @param[in] FileHandle The opened file handle for writing.\r
1167 @param[in, out] BufferSize On input, size of Buffer.\r
1168 @param[in] Buffer The buffer in which data to write.\r
94b17fa1 1169\r
a31bd33c 1170 @retval EFI_SUCCESS Data was written.\r
1171 @retval EFI_UNSUPPORTED Writes to open directory are not supported.\r
1172 @retval EFI_NO_MEDIA The device has no media.\r
1173 @retval EFI_DEVICE_ERROR The device reported an error.\r
1174 @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r
1175 @retval EFI_WRITE_PROTECTED The device is write-protected.\r
1176 @retval EFI_ACCESS_DENIED The file was open for read only.\r
1177 @retval EFI_VOLUME_FULL The volume is full.\r
94b17fa1 1178**/\r
1179typedef\r
1180EFI_STATUS\r
1181(EFIAPI *EFI_SHELL_WRITE_FILE)(\r
a405b86d 1182 IN SHELL_FILE_HANDLE FileHandle,\r
08d7f8e8 1183 IN OUT UINTN *BufferSize,\r
1184 IN VOID *Buffer\r
94b17fa1 1185 );\r
1186\r
044ea4e5 1187//\r
838b31a6
CP
1188// EFI_SHELL_PROTOCOL has been updated since UEFI Shell Spec 2.0\r
1189// Usage of this protocol will require version checking before attempting\r
1190// to use any new members. There is no need to check the version for\r
1191// members that existed in UEFI Shell Spec 2.0.\r
1192//\r
1193// Update below for any future UEFI Shell spec changes to this protocol.\r
044ea4e5 1194//\r
838b31a6
CP
1195// Check EFI_SHELL_PROTOCOL MajorVersion and MinorVersion:\r
1196// if ((2 == gEfiShellProtocol->MajorVersion) &&\r
1197// (0 == gEfiShellProtocol->MinorVersion)) {\r
1198// //\r
1199// // Cannot call:\r
1200// // RegisterGuidName - UEFI Shell 2.1\r
1201// // GetGuidName - UEFI Shell 2.1\r
1202// // GetGuidFromName - UEFI Shell 2.1\r
1203// // GetEnvEx - UEFI Shell 2.1\r
1204// //\r
1205// } else {\r
1206// //\r
1207// // Can use all members\r
1208// //\r
1209// }\r
1210//\r
1211typedef struct _EFI_SHELL_PROTOCOL {\r
044ea4e5
JC
1212 EFI_SHELL_EXECUTE Execute;\r
1213 EFI_SHELL_GET_ENV GetEnv;\r
1214 EFI_SHELL_SET_ENV SetEnv;\r
1215 EFI_SHELL_GET_ALIAS GetAlias;\r
1216 EFI_SHELL_SET_ALIAS SetAlias;\r
1217 EFI_SHELL_GET_HELP_TEXT GetHelpText;\r
1218 EFI_SHELL_GET_DEVICE_PATH_FROM_MAP GetDevicePathFromMap;\r
1219 EFI_SHELL_GET_MAP_FROM_DEVICE_PATH GetMapFromDevicePath;\r
1220 EFI_SHELL_GET_DEVICE_PATH_FROM_FILE_PATH GetDevicePathFromFilePath;\r
1221 EFI_SHELL_GET_FILE_PATH_FROM_DEVICE_PATH GetFilePathFromDevicePath;\r
1222 EFI_SHELL_SET_MAP SetMap;\r
1223 EFI_SHELL_GET_CUR_DIR GetCurDir;\r
1224 EFI_SHELL_SET_CUR_DIR SetCurDir;\r
1225 EFI_SHELL_OPEN_FILE_LIST OpenFileList;\r
1226 EFI_SHELL_FREE_FILE_LIST FreeFileList;\r
1227 EFI_SHELL_REMOVE_DUP_IN_FILE_LIST RemoveDupInFileList;\r
1228 EFI_SHELL_BATCH_IS_ACTIVE BatchIsActive;\r
1229 EFI_SHELL_IS_ROOT_SHELL IsRootShell;\r
1230 EFI_SHELL_ENABLE_PAGE_BREAK EnablePageBreak;\r
1231 EFI_SHELL_DISABLE_PAGE_BREAK DisablePageBreak;\r
1232 EFI_SHELL_GET_PAGE_BREAK GetPageBreak;\r
1233 EFI_SHELL_GET_DEVICE_NAME GetDeviceName;\r
1234 EFI_SHELL_GET_FILE_INFO GetFileInfo;\r
1235 EFI_SHELL_SET_FILE_INFO SetFileInfo;\r
1236 EFI_SHELL_OPEN_FILE_BY_NAME OpenFileByName;\r
1237 EFI_SHELL_CLOSE_FILE CloseFile;\r
1238 EFI_SHELL_CREATE_FILE CreateFile;\r
1239 EFI_SHELL_READ_FILE ReadFile;\r
1240 EFI_SHELL_WRITE_FILE WriteFile;\r
1241 EFI_SHELL_DELETE_FILE DeleteFile;\r
1242 EFI_SHELL_DELETE_FILE_BY_NAME DeleteFileByName;\r
1243 EFI_SHELL_GET_FILE_POSITION GetFilePosition;\r
1244 EFI_SHELL_SET_FILE_POSITION SetFilePosition;\r
1245 EFI_SHELL_FLUSH_FILE FlushFile;\r
1246 EFI_SHELL_FIND_FILES FindFiles;\r
1247 EFI_SHELL_FIND_FILES_IN_DIR FindFilesInDir;\r
1248 EFI_SHELL_GET_FILE_SIZE GetFileSize;\r
1249 EFI_SHELL_OPEN_ROOT OpenRoot;\r
1250 EFI_SHELL_OPEN_ROOT_BY_HANDLE OpenRootByHandle;\r
1251 EFI_EVENT ExecutionBreak;\r
1252 UINT32 MajorVersion;\r
1253 UINT32 MinorVersion;\r
1254 // Added for Shell 2.1\r
838b31a6
CP
1255 EFI_SHELL_REGISTER_GUID_NAME RegisterGuidName;\r
1256 EFI_SHELL_GET_GUID_NAME GetGuidName;\r
1257 EFI_SHELL_GET_GUID_FROM_NAME GetGuidFromName;\r
1258 EFI_SHELL_GET_ENV_EX GetEnvEx;\r
1259} EFI_SHELL_PROTOCOL;\r
044ea4e5 1260\r
94b17fa1 1261extern EFI_GUID gEfiShellProtocolGuid;\r
1262\r
d2b4564b 1263enum ShellVersion {\r
1264 SHELL_MAJOR_VERSION = 2,\r
044ea4e5 1265 SHELL_MINOR_VERSION = 1\r
d2b4564b 1266};\r
1267\r
94b17fa1 1268#endif\r