]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Include/Protocol/EfiShell.h
This adds the new APIs for UEFI Shell 2.1 and makes a new structure for shell impleme...
[mirror_edk2.git] / ShellPkg / Include / Protocol / EfiShell.h
Content-type: text/html ]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Include/Protocol/EfiShell.h


500 - Internal Server Error

Malformed UTF-8 character (fatal) at (eval 6) line 1, <$fd> line 966.
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
044ea4e5 4 Copyright (c) 2006 - 2014, Intel Corporation. All rights reserved.<BR>\r
1e6e84c7 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
94b17fa1 12\r
13**/\r
14\r
15#ifndef __EFI_SHELL_PROTOCOL__\r
16#define __EFI_SHELL_PROTOCOL__\r
17\r
a405b86d 18#include <ShellBase.h>\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
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
a405b86d 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 SHELL_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
94b17fa1 35} EFI_SHELL_FILE_INFO;\r
a31bd33c 36\r
94b17fa1 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
1e6e84c7 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
94b17fa1 55 closed.\r
56\r
1e6e84c7 57 @param[in] FileHandle The file handle to be closed.\r
94b17fa1 58\r
a31bd33c 59 @retval EFI_SUCCESS The file closed sucessfully.\r
94b17fa1 60**/\r
61typedef\r
62EFI_STATUS\r
63(EFIAPI *EFI_SHELL_CLOSE_FILE)(\r
a405b86d 64 IN SHELL_FILE_HANDLE FileHandle\r
94b17fa1 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
1e6e84c7 73\r
94b17fa1 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
1e6e84c7 76\r
94b17fa1 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
1e6e84c7 81 @param[in] FileName Pointer to NULL-terminated file path.\r
a405b86d 82 @param[in] FileAttribs The new file's attrbiutes. The different attributes are\r
a31bd33c 83 described in EFI_FILE_PROTOCOL.Open().\r
a405b86d 84 @param[out] FileHandle On return, points to the created file handle or directory's handle.\r
94b17fa1 85\r
a31bd33c 86 @retval EFI_SUCCESS The file was opened. FileHandle points to the new file's handle.\r
94b17fa1 87 @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r
1e6e84c7 88 @retval EFI_UNSUPPORTED The file path could not be opened.\r
a31bd33c 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
94b17fa1 102**/\r
103typedef\r
104EFI_STATUS\r
105(EFIAPI *EFI_SHELL_CREATE_FILE)(\r
a405b86d 106 IN CONST CHAR16 *FileName,\r
107 IN UINT64 FileAttribs,\r
108 OUT SHELL_FILE_HANDLE *FileHandle\r
94b17fa1 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
941b3569 118 @param[in] FileHandle The file handle to delete.\r
94b17fa1 119\r
1e6e84c7 120 @retval EFI_SUCCESS The file was closed and deleted and the handle was closed.\r
94b17fa1 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
a405b86d 126 IN SHELL_FILE_HANDLE FileHandle\r
94b17fa1 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
1e6e84c7 134 @param[in] FileName Points to the NULL-terminated file name.\r
94b17fa1 135\r
1e6e84c7 136 @retval EFI_SUCCESS The file was deleted.\r
94b17fa1 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
1e6e84c7 151 VOID\r
152 );\r
94b17fa1 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
1e6e84c7 160 VOID\r
161 );\r
94b17fa1 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
1e6e84c7 169\r
94b17fa1 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
1e6e84c7 173\r
94b17fa1 174 The CommandLine is executed from the current working directory on the current\r
175 device.\r
176\r
1e6e84c7 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
941b3569 180 containing the command line. If NULL then the command-\r
181 line will be empty.\r
1e6e84c7 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
941b3569 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
1e6e84c7 188 @retval EFI_SUCCESS The command executed successfully. The status code\r
941b3569 189 returned by the command is pointed to by StatusCode.\r
94b17fa1 190 @retval EFI_INVALID_PARAMETER The parameters are invalid.\r
941b3569 191 @retval EFI_OUT_OF_RESOURCES Out of resources.\r
192 @retval EFI_UNSUPPORTED Nested shell invocations are not allowed.\r
94b17fa1 193**/\r
194typedef\r
195EFI_STATUS\r
196(EFIAPI *EFI_SHELL_EXECUTE) (\r
a405b86d 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
94b17fa1 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
1e6e84c7 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
941b3569 216 were found.\r
94b17fa1 217\r
941b3569 218 @retval EFI_SUCCESS Files found.\r
219 @retval EFI_NOT_FOUND No files found.\r
a31bd33c 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
94b17fa1 223**/\r
224typedef\r
225EFI_STATUS\r
226(EFIAPI *EFI_SHELL_FIND_FILES)(\r
a405b86d 227 IN CONST CHAR16 *FilePattern,\r
228 OUT EFI_SHELL_FILE_INFO **FileList\r
94b17fa1 229 );\r
230\r
231/**\r
232 Find all files in a specified directory.\r
233\r
941b3569 234 @param[in] FileDirHandle Handle of the directory to search.\r
1e6e84c7 235 @param[out] FileList On return, points to the list of files in the directory\r
941b3569 236 or NULL if there are no files in the directory.\r
94b17fa1 237\r
941b3569 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
94b17fa1 242**/\r
243typedef\r
244EFI_STATUS\r
245(EFIAPI *EFI_SHELL_FIND_FILES_IN_DIR)(\r
a405b86d 246IN SHELL_FILE_HANDLE FileDirHandle,\r
247OUT EFI_SHELL_FILE_INFO **FileList\r
94b17fa1 248);\r
249\r
250/**\r
a31bd33c 251 Flushes data back to a device.\r
1e6e84c7 252\r
94b17fa1 253 This function flushes all modified data associated with a file to a device.\r
254\r
1e6e84c7 255 @param[in] FileHandle The handle of the file to flush.\r
94b17fa1 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
a405b86d 268 IN SHELL_FILE_HANDLE FileHandle\r
94b17fa1 269 );\r
270\r
271/**\r
272 Frees the file list.\r
1e6e84c7 273\r
94b17fa1 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
1e6e84c7 277 @param[in] FileList The file list to free. Type EFI_SHELL_FILE_INFO is\r
278 defined in OpenFileList().\r
94b17fa1 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
1e6e84c7 296 @param[in] FileSystemMapping A pointer to the file system mapping. If NULL,\r
94b17fa1 297 then the current working directory is returned.\r
1e6e84c7 298\r
94b17fa1 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
a31bd33c 311\r
94b17fa1 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
d2b4564b 319 If EFI_DEVICE_NAME_USE_COMPONENT_NAME is set, then the function will return the\r
69817bf8 320 device's name using the EFI_COMPONENT_NAME2_PROTOCOL, if present on\r
d2b4564b 321 DeviceHandle.\r
322\r
323 If EFI_DEVICE_NAME_USE_DEVICE_PATH is set, then the function will return the\r
69817bf8 324 device's name using the EFI_DEVICE_PATH_PROTOCOL, if present on DeviceHandle.\r
d2b4564b 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
941b3569 329 @param[in] DeviceHandle The handle of the device.\r
1e6e84c7 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
a31bd33c 333 specification, Appendix M.\r
1e6e84c7 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
94b17fa1 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
e26d7b59 344(EFIAPI *EFI_SHELL_GET_DEVICE_NAME) (\r
a405b86d 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
94b17fa1 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
941b3569 356 @param[in] Mapping A pointer to the mapping\r
94b17fa1 357\r
1e6e84c7 358 @retval !=NULL Pointer to the device path that corresponds to the\r
359 device mapping. The returned pointer does not need\r
94b17fa1 360 to be freed.\r
1e6e84c7 361 @retval NULL There is no device path associated with the\r
94b17fa1 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
a31bd33c 376 @param[in] Path The pointer to the path.\r
94b17fa1 377\r
1e6e84c7 378 @return The pointer of the file path. The file path is callee\r
94b17fa1 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
941b3569 388 Gets either a single or list of environment variables.\r
389\r
1e6e84c7 390 If name is not NULL then this function returns the current value of the specified\r
941b3569 391 environment variable.\r
94b17fa1 392\r
1e6e84c7 393 If Name is NULL than a list of all environment variable names is returned. Each a\r
941b3569 394 NULL terminated string with a double NULL terminating the list.\r
94b17fa1 395\r
1e6e84c7 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
941b3569 402 NULL.\r
94b17fa1 403\r
1e6e84c7 404 @return A pointer to the returned string.\r
941b3569 405 The returned pointer does not need to be freed by the caller.\r
406\r
1e6e84c7 407 @retval NULL The environment variable doesn't exist or there are\r
941b3569 408 no environment variables.\r
94b17fa1 409**/\r
410typedef\r
411CONST CHAR16 *\r
412(EFIAPI *EFI_SHELL_GET_ENV) (\r
941b3569 413 IN CONST CHAR16 *Name OPTIONAL\r
94b17fa1 414 );\r
415\r
044ea4e5
JC
416/**\r
417 Gets the environment variable and Attributes, or list of environment variables. Can be \r
418 used instead of GetEnv().\r
419\r
420 This function returns the current value of the specified environment variable and\r
421 the Attributes. If no variable name was specified, then all of the known\r
422 variables will be returned.\r
423\r
424 @param[in] Name A pointer to the environment variable name. If Name is NULL,\r
425 then the function will return all of the defined shell \r
426 environment variables. In the case where multiple environment\r
427 variables are being returned, each variable will be terminated \r
428 by a NULL, and the list will be terminated by a double NULL.\r
429 @param[out] Attributes If not NULL, a pointer to the returned attributes bitmask for\r
430 the environment variable. In the case where Name is NULL, and\r
431 multiple environment variables are being returned, Attributes\r
432 is undefined.\r
433\r
434