a405b86d |
1 | /** @file\r |
2 | Member functions of EFI_SHELL_PROTOCOL and functions for creation,\r |
3 | manipulation, and initialization of EFI_SHELL_PROTOCOL.\r |
4 | \r |
5 | Copyright (c) 2009 - 2010, Intel Corporation. All rights reserved.<BR>\r |
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 |
13 | \r |
14 | **/\r |
15 | \r |
16 | #ifndef _SHELL_PROTOCOL_HEADER_\r |
17 | #define _SHELL_PROTOCOL_HEADER_\r |
18 | \r |
19 | #include <Uefi.h>\r |
20 | #include <ShellBase.h>\r |
21 | \r |
22 | #include <Guid/ShellVariableGuid.h>\r |
23 | #include <Guid/ShellMapGuid.h>\r |
24 | #include <Guid/ShellAliasGuid.h>\r |
25 | \r |
26 | #include <Protocol/EfiShell.h>\r |
27 | #include <Protocol/EfiShellParameters.h>\r |
28 | #include <Protocol/SimpleFileSystem.h>\r |
29 | #include <Protocol/DevicePathToText.h>\r |
30 | #include <Protocol/ComponentName2.h>\r |
31 | #include <Protocol/LoadedImage.h>\r |
32 | #include <Protocol/UnicodeCollation.h>\r |
33 | #include <Protocol/DevicePath.h>\r |
34 | \r |
35 | #include <Library/UefiBootServicesTableLib.h>\r |
36 | #include <Library/BaseLib.h>\r |
37 | #include <Library/ShellCommandLib.h>\r |
38 | #include <Library/PrintLib.h>\r |
39 | #include <Library/DevicePathLib.h>\r |
40 | #include <Library/UefiRuntimeServicesTableLib.h>\r |
41 | #include <Library/DebugLib.h>\r |
42 | #include <Library/MemoryAllocationLib.h>\r |
43 | #include <Library/BaseMemoryLib.h>\r |
44 | #include <Library/UefiLib.h>\r |
45 | #include <Library/SortLib.h>\r |
46 | #include <Library/PcdLib.h>\r |
47 | #include <Library/ShellLib.h>\r |
48 | \r |
49 | #include "FileHandleWrappers.h"\r |
50 | #include "ShellEnvVar.h"\r |
51 | #include "ShellManParser.h"\r |
52 | \r |
53 | typedef struct {\r |
54 | LIST_ENTRY Link;\r |
55 | EFI_SHELL_PROTOCOL *Interface;\r |
56 | EFI_HANDLE Handle;\r |
57 | } SHELL_PROTOCOL_HANDLE_LIST;\r |
58 | \r |
59 | // flags values...\r |
60 | #define SHELL_MAP_FLAGS_CONSIST BIT1\r |
61 | \r |
62 | /**\r |
63 | Function to create and install on the current handle.\r |
64 | \r |
65 | Will overwrite any existing ShellProtocols in the system to be sure that\r |
66 | the current shell is in control.\r |
67 | \r |
68 | This must be removed via calling CleanUpShellProtocol().\r |
69 | \r |
70 | @param[in,out] NewShell The pointer to the pointer to the structure \r |
71 | to install.\r |
72 | \r |
73 | @retval EFI_SUCCESS The operation was successful.\r |
74 | @return An error from LocateHandle, CreateEvent, or other core function.\r |
75 | **/\r |
76 | EFI_STATUS\r |
77 | EFIAPI\r |
78 | CreatePopulateInstallShellProtocol (\r |
79 | IN OUT EFI_SHELL_PROTOCOL **NewShell\r |
80 | );\r |
81 | \r |
82 | /**\r |
83 | Opposite of CreatePopulateInstallShellProtocol. \r |
84 | \r |
85 | Free all memory and restore the system to the state it was in before calling\r |
86 | CreatePopulateInstallShellProtocol.\r |
87 | \r |
88 | @param[in,out] NewShell The pointer to the new shell protocol structure.\r |
89 | \r |
90 | @retval EFI_SUCCESS The operation was successful.\r |
91 | **/\r |
92 | EFI_STATUS\r |
93 | EFIAPI\r |
94 | CleanUpShellProtocol (\r |
95 | IN OUT EFI_SHELL_PROTOCOL *NewShell\r |
96 | );\r |
97 | \r |
98 | /**\r |
99 | This function creates a mapping for a device path.\r |
100 | \r |
101 | @param DevicePath Points to the device path. If this is NULL and Mapping points to a valid mapping,\r |
102 | then the mapping will be deleted.\r |
103 | @param Mapping Points to the NULL-terminated mapping for the device path. Must end with a ':'\r |
104 | \r |
105 | @retval EFI_SUCCESS Mapping created or deleted successfully.\r |
106 | @retval EFI_NO_MAPPING There is no handle that corresponds exactly to DevicePath. See the\r |
107 | boot service function LocateDevicePath().\r |
108 | @retval EFI_ACCESS_DENIED The mapping is a built-in alias.\r |
109 | @retval EFI_INVALID_PARAMETER Mapping was NULL\r |
110 | @retval EFI_INVALID_PARAMETER Mapping did not end with a ':'\r |
111 | @retval EFI_INVALID_PARAMETER DevicePath was not pointing at a device that had a SIMPLE_FILE_SYSTEM_PROTOCOL installed.\r |
112 | @retval EFI_NOT_FOUND There was no mapping found to delete\r |
113 | @retval EFI_OUT_OF_RESOURCES Memory allocation failed\r |
114 | **/\r |
115 | EFI_STATUS\r |
116 | EFIAPI\r |
117 | EfiShellSetMap(\r |
118 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath OPTIONAL,\r |
119 | IN CONST CHAR16 *Mapping\r |
120 | );\r |
121 | \r |
122 | /**\r |
123 | Gets the device path from the mapping.\r |
124 | \r |
125 | This function gets the device path associated with a mapping.\r |
126 | \r |
127 | @param Mapping A pointer to the mapping\r |
128 | \r |
129 | @retval !=NULL Pointer to the device path that corresponds to the\r |
130 | device mapping. The returned pointer does not need\r |
131 | to be freed.\r |
132 | @retval NULL There is no device path associated with the\r |
133 | specified mapping.\r |
134 | **/\r |
135 | CONST EFI_DEVICE_PATH_PROTOCOL *\r |
136 | EFIAPI\r |
137 | EfiShellGetDevicePathFromMap(\r |
138 | IN CONST CHAR16 *Mapping\r |
139 | );\r |
140 | \r |
141 | /**\r |
142 | Gets the mapping that most closely matches the device path.\r |
143 | \r |
144 | This function gets the mapping which corresponds to the device path *DevicePath. If\r |
145 | there is no exact match, then the mapping which most closely matches *DevicePath\r |
146 | is returned, and *DevicePath is updated to point to the remaining portion of the\r |
147 | device path. If there is an exact match, the mapping is returned and *DevicePath\r |
148 | points to the end-of-device-path node.\r |
149 | \r |
150 | @param DevicePath On entry, points to a device path pointer. On\r |
151 | exit, updates the pointer to point to the\r |
152 | portion of the device path after the mapping.\r |
153 | \r |
154 | @retval NULL No mapping was found.\r |
155 | @return !=NULL Pointer to NULL-terminated mapping. The buffer\r |
156 | is callee allocated and should be freed by the caller.\r |
157 | **/\r |
158 | CONST CHAR16 *\r |
159 | EFIAPI\r |
160 | EfiShellGetMapFromDevicePath(\r |
161 | IN OUT EFI_DEVICE_PATH_PROTOCOL **DevicePath\r |
162 | );\r |
163 | \r |
164 | /**\r |
165 | Converts a device path to a file system-style path.\r |
166 | \r |
167 | This function converts a device path to a file system path by replacing part, or all, of\r |
168 | the device path with the file-system mapping. If there are more than one application\r |
169 | file system mappings, the one that most closely matches Path will be used.\r |
170 | \r |
171 | @param Path The pointer to the device path\r |
172 | \r |
173 | @retval NULL the device path could not be found.\r |
174 | @return all The pointer of the NULL-terminated file path. The path\r |
175 | is callee-allocated and should be freed by the caller.\r |
176 | **/\r |
177 | CHAR16 *\r |
178 | EFIAPI\r |
179 | EfiShellGetFilePathFromDevicePath(\r |
180 | IN CONST EFI_DEVICE_PATH_PROTOCOL *Path\r |
181 | );\r |
182 | \r |
183 | /**\r |
184 | Converts a file system style name to a device path.\r |
185 | \r |
186 | This function converts a file system style name to a device path, by replacing any\r |
187 | mapping references to the associated device path.\r |
188 | \r |
189 | @param Path the pointer to the path\r |
190 | \r |
191 | @return all The pointer of the file path. The file path is callee\r |
192 | allocated and should be freed by the caller.\r |
193 | **/\r |
194 | EFI_DEVICE_PATH_PROTOCOL *\r |
195 | EFIAPI\r |
196 | EfiShellGetDevicePathFromFilePath(\r |
197 | IN CONST CHAR16 *Path\r |
198 | );\r |
199 | \r |
200 | /**\r |
201 | Gets the name of the device specified by the device handle.\r |
202 | \r |
203 | This function gets the user-readable name of the device specified by the device\r |
204 | handle. If no user-readable name could be generated, then *BestDeviceName will be\r |
205 | NULL and EFI_NOT_FOUND will be returned.\r |
206 | \r |
207 | If EFI_DEVICE_NAME_USE_COMPONENT_NAME is set, then the function will return the\r |
208 | device's name using the EFI_COMPONENT_NAME2_PROTOCOL, if present on\r |
209 | DeviceHandle.\r |
210 | \r |
211 | If EFI_DEVICE_NAME_USE_DEVICE_PATH is set, then the function will return the\r |
212 | device's name using the EFI_DEVICE_PATH_PROTOCOL, if present on DeviceHandle.\r |
213 | If both EFI_DEVICE_NAME_USE_COMPONENT_NAME and\r |
214 | EFI_DEVICE_NAME_USE_DEVICE_PATH are set, then\r |
215 | EFI_DEVICE_NAME_USE_COMPONENT_NAME will have higher priority.\r |
216 | \r |
217 | @param DeviceHandle The handle of the device.\r |
218 | @param Flags Determines the possible sources of component names.\r |
219 | Valid bits are:\r |
220 | EFI_DEVICE_NAME_USE_COMPONENT_NAME\r |
221 | EFI_DEVICE_NAME_USE_DEVICE_PATH\r |
222 | @param Language A pointer to the language specified for the device\r |
223 | name, in the same format as described in the UEFI\r |
224 | specification, Appendix M\r |
225 | @param BestDeviceName On return, points to the callee-allocated NULL-\r |
226 | terminated name of the device. If no device name\r |
227 | could be found, points to NULL. The name must be\r |
228 | freed by the caller...\r |
229 | \r |
230 | @retval EFI_SUCCESS Get the name successfully.\r |
231 | @retval EFI_NOT_FOUND Fail to get the device name.\r |
232 | @retval EFI_INVALID_PARAMETER Flags did not have a valid bit set.\r |
233 | @retval EFI_INVALID_PARAMETER BestDeviceName was NULL\r |
234 | @retval EFI_INVALID_PARAMETER DeviceHandle was NULL\r |
235 | **/\r |
236 | EFI_STATUS\r |
237 | EFIAPI\r |
238 | EfiShellGetDeviceName(\r |
239 | IN EFI_HANDLE DeviceHandle,\r |
240 | IN EFI_SHELL_DEVICE_NAME_FLAGS Flags,\r |
241 | IN CHAR8 *Language,\r |
242 | OUT CHAR16 **BestDeviceName\r |
243 | );\r |
244 | \r |
245 | /**\r |
246 | Opens the root directory of a device on a handle\r |
247 | \r |
248 | This function opens the root directory of a device and returns a file handle to it.\r |
249 | \r |
250 | @param DeviceHandle The handle of the device that contains the volume.\r |
251 | @param FileHandle On exit, points to the file handle corresponding to the root directory on the\r |
252 | device.\r |
253 | \r |
254 | @retval EFI_SUCCESS Root opened successfully.\r |
255 | @retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be found or the root directory\r |
256 | could not be opened.\r |
257 | @retval EFI_VOLUME_CORRUPTED The data structures in the volume were corrupted.\r |
258 | @retval EFI_DEVICE_ERROR The device had an error\r |
259 | **/\r |
260 | EFI_STATUS\r |
261 | EFIAPI\r |
262 | EfiShellOpenRootByHandle(\r |
263 | IN EFI_HANDLE DeviceHandle,\r |
264 | OUT SHELL_FILE_HANDLE *FileHandle\r |
265 | );\r |
266 | \r |
267 | /**\r |
268 | Opens the root directory of a device.\r |
269 | \r |
270 | This function opens the root directory of a device and returns a file handle to it.\r |
271 | \r |
272 | @param DevicePath Points to the device path corresponding to the device where the\r |
273 | EFI_SIMPLE_FILE_SYSTEM_PROTOCOL is installed.\r |
274 | @param FileHandle On exit, points to the file handle corresponding to the root directory on the\r |
275 | device.\r |
276 | \r |
277 | @retval EFI_SUCCESS Root opened successfully.\r |
278 | @retval EFI_NOT_FOUND EFI_SIMPLE_FILE_SYSTEM could not be found or the root directory\r |
279 | could not be opened.\r |
280 | @retval EFI_VOLUME_CORRUPTED The data structures in the volume were corrupted.\r |
281 | @retval EFI_DEVICE_ERROR The device had an error\r |
282 | **/\r |
283 | EFI_STATUS\r |
284 | EFIAPI\r |
285 | EfiShellOpenRoot(\r |
286 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r |
287 | OUT SHELL_FILE_HANDLE *FileHandle\r |
288 | );\r |
289 | \r |
290 | /**\r |
291 | Returns whether any script files are currently being processed.\r |
292 | \r |
293 | @retval TRUE There is at least one script file active.\r |
294 | @retval FALSE No script files are active now.\r |
295 | \r |
296 | **/\r |
297 | BOOLEAN\r |
298 | EFIAPI\r |
299 | EfiShellBatchIsActive (\r |
300 | VOID\r |
301 | );\r |
302 | \r |
303 | /**\r |
304 | Worker function to open a file based on a device path. this will open the root\r |
305 | of the volume and then traverse down to the file itself.\r |
306 | \r |
307 | @param DevicePath2 Device Path of the file\r |
308 | @param FileHandle Pointer to the file upon a successful return\r |
309 | @param OpenMode mode to open file in.\r |
310 | @param Attributes the File Attributes to use when creating a new file\r |
311 | \r |
312 | @retval EFI_SUCCESS the file is open and FileHandle is valid\r |
313 | @retval EFI_UNSUPPORTED the device path cotained non-path elements\r |
314 | @retval other an error ocurred.\r |
315 | **/\r |
316 | EFI_STATUS\r |
317 | EFIAPI\r |
318 | InternalOpenFileDevicePath(\r |
319 | IN OUT EFI_DEVICE_PATH_PROTOCOL *DevicePath2,\r |
320 | OUT SHELL_FILE_HANDLE *FileHandle,\r |
321 | IN UINT64 OpenMode,\r |
322 | IN UINT64 Attributes OPTIONAL\r |
323 | );\r |
324 | \r |
325 | /**\r |
326 | Creates a file or directory by name.\r |
327 | \r |
328 | This function creates an empty new file or directory with the specified attributes and\r |
329 | returns the new file's handle. If the file already exists and is read-only, then\r |
330 | EFI_INVALID_PARAMETER will be returned.\r |
331 | \r |
332 | If the file already existed, it is truncated and its attributes updated. If the file is\r |
333 | created successfully, the FileHandle is the file's handle, else, the FileHandle is NULL.\r |
334 | \r |
335 | If the file name begins with >v, then the file handle which is returned refers to the\r |
336 | shell environment variable with the specified name. If the shell environment variable\r |
337 | already exists and is non-volatile then EFI_INVALID_PARAMETER is returned.\r |
338 | \r |
339 | @param FileName Pointer to NULL-terminated file path\r |
340 | @param FileAttribs The new file's attrbiutes. the different attributes are\r |
341 | described in EFI_FILE_PROTOCOL.Open().\r |
342 | @param FileHandle On return, points to the created file handle or directory's handle\r |
343 | \r |
344 | @retval EFI_SUCCESS The file was opened. FileHandle points to the new file's handle.\r |
345 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value.\r |
346 | @retval EFI_UNSUPPORTED could not open the file path\r |
347 | @retval EFI_NOT_FOUND the specified file could not be found on the devide, or could not\r |
348 | file the file system on the device.\r |
349 | @retval EFI_NO_MEDIA the device has no medium.\r |
350 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no\r |
351 | longer supported.\r |
352 | @retval EFI_DEVICE_ERROR The device reported an error or can't get the file path according\r |
353 | the DirName.\r |
354 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted.\r |
355 | @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write\r |
356 | when the media is write-protected.\r |
357 | @retval EFI_ACCESS_DENIED The service denied access to the file.\r |
358 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file.\r |
359 | @retval EFI_VOLUME_FULL The volume is full.\r |
360 | **/\r |
361 | EFI_STATUS\r |
362 | EFIAPI\r |
363 | EfiShellCreateFile(\r |
364 | IN CONST CHAR16 *FileName,\r |
365 | IN UINT64 FileAttribs,\r |
366 | OUT SHELL_FILE_HANDLE *FileHandle\r |
367 | );\r |
368 | \r |
369 | /**\r |
370 | Opens a file or a directory by file name.\r |
371 | \r |
372 | This function opens the specified file in the specified OpenMode and returns a file\r |
373 | handle.\r |
374 | If the file name begins with >v, then the file handle which is returned refers to the\r |
375 | shell environment variable with the specified name. If the shell environment variable\r |
376 | exists, is non-volatile and the OpenMode indicates EFI_FILE_MODE_WRITE, then\r |
377 | EFI_INVALID_PARAMETER is returned.\r |
378 | \r |
379 | If the file name is >i, then the file handle which is returned refers to the standard\r |
380 | input. If the OpenMode indicates EFI_FILE_MODE_WRITE, then EFI_INVALID_PARAMETER\r |
381 | is returned.\r |
382 | \r |
383 | If the file name is >o, then the file handle which is returned refers to the standard\r |
384 | output. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER\r |
385 | is returned.\r |
386 | \r |
387 | If the file name is >e, then the file handle which is returned refers to the standard\r |
388 | error. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER\r |
389 | is returned.\r |
390 | \r |
391 | If the file name is NUL, then the file handle that is returned refers to the standard NUL\r |
392 | file. If the OpenMode indicates EFI_FILE_MODE_READ, then EFI_INVALID_PARAMETER is\r |
393 | returned.\r |
394 | \r |
395 | If return EFI_SUCCESS, the FileHandle is the opened file's handle, else, the\r |
396 | FileHandle is NULL.\r |
397 | \r |
398 | @param FileName Points to the NULL-terminated UCS-2 encoded file name.\r |
399 | @param FileHandle On return, points to the file handle.\r |
400 | @param OpenMode File open mode. Either EFI_FILE_MODE_READ or\r |
401 | EFI_FILE_MODE_WRITE from section 12.4 of the UEFI\r |
402 | Specification.\r |
403 | @retval EFI_SUCCESS The file was opened. FileHandle has the opened file's handle.\r |
404 | @retval EFI_INVALID_PARAMETER One of the parameters has an invalid value. FileHandle is NULL.\r |
405 | @retval EFI_UNSUPPORTED Could not open the file path. FileHandle is NULL.\r |
406 | @retval EFI_NOT_FOUND The specified file could not be found on the device or the file\r |
407 | system could not be found on the device. FileHandle is NULL.\r |
408 | @retval EFI_NO_MEDIA The device has no medium. FileHandle is NULL.\r |
409 | @retval EFI_MEDIA_CHANGED The device has a different medium in it or the medium is no\r |
410 | longer supported. FileHandle is NULL.\r |
411 | @retval EFI_DEVICE_ERROR The device reported an error or can't get the file path according\r |
412 | the FileName. FileHandle is NULL.\r |
413 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted. FileHandle is NULL.\r |
414 | @retval EFI_WRITE_PROTECTED An attempt was made to create a file, or open a file for write\r |
415 | when the media is write-protected. FileHandle is NULL.\r |
416 | @retval EFI_ACCESS_DENIED The service denied access to the file. FileHandle is NULL.\r |
417 | @retval EFI_OUT_OF_RESOURCES Not enough resources were available to open the file. FileHandle\r |
418 | is NULL.\r |
419 | @retval EFI_VOLUME_FULL The volume is full. FileHandle is NULL.\r |
420 | **/\r |
421 | EFI_STATUS\r |
422 | EFIAPI\r |
423 | EfiShellOpenFileByName(\r |
424 | IN CONST CHAR16 *FileName,\r |
425 | OUT SHELL_FILE_HANDLE *FileHandle,\r |
426 | IN UINT64 OpenMode\r |
427 | );\r |
428 | \r |
429 | /**\r |
430 | Deletes the file specified by the file name.\r |
431 | \r |
432 | This function deletes a file.\r |
433 | \r |
434 | @param FileName Points to the NULL-terminated file name.\r |
435 | \r |
436 | @retval EFI_SUCCESS The file was closed and deleted, and the handle was closed.\r |
437 | @retval EFI_WARN_DELETE_FAILURE The handle was closed but the file was not deleted.\r |
438 | @sa EfiShellCreateFile\r |
439 | @sa FileHandleDelete\r |
440 | **/\r |
441 | EFI_STATUS\r |
442 | EFIAPI\r |
443 | EfiShellDeleteFileByName(\r |
444 | IN CONST CHAR16 *FileName\r |
445 | );\r |
446 | \r |
447 | /**\r |
448 | Disables the page break output mode.\r |
449 | **/\r |
450 | VOID\r |
451 | EFIAPI\r |
452 | EfiShellDisablePageBreak (\r |
453 | VOID\r |
454 | );\r |
455 | \r |
456 | /**\r |
457 | Enables the page break output mode.\r |
458 | **/\r |
459 | VOID\r |
460 | EFIAPI\r |
461 | EfiShellEnablePageBreak (\r |
462 | VOID\r |
463 | );\r |
464 | \r |
465 | /**\r |
466 | internal worker function to run a command via Device Path\r |
467 | \r |
468 | @param ParentImageHandle A handle of the image that is executing the specified\r |
469 | command line.\r |
470 | @param DevicePath device path of the file to execute\r |
471 | @param CommandLine Points to the NULL-terminated UCS-2 encoded string\r |
472 | containing the command line. If NULL then the command-\r |
473 | line will be empty.\r |
474 | @param Environment Points to a NULL-terminated array of environment\r |
475 | variables with the format 'x=y', where x is the\r |
476 | environment variable name and y is the value. If this\r |
477 | is NULL, then the current shell environment is used.\r |
478 | @param StatusCode Points to the status code returned by the command.\r |
479 | \r |
480 | @retval EFI_SUCCESS The command executed successfully. The status code\r |
481 | returned by the command is pointed to by StatusCode.\r |
482 | @retval EFI_INVALID_PARAMETER The parameters are invalid.\r |
483 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r |
484 | @retval EFI_UNSUPPORTED Nested shell invocations are not allowed.\r |
485 | **/\r |
486 | EFI_STATUS\r |
487 | EFIAPI\r |
488 | InternalShellExecuteDevicePath(\r |
489 | IN CONST EFI_HANDLE *ParentImageHandle,\r |
490 | IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath,\r |
491 | IN CONST CHAR16 *CommandLine OPTIONAL,\r |
492 | IN CONST CHAR16 **Environment OPTIONAL,\r |
493 | OUT EFI_STATUS *StatusCode OPTIONAL\r |
494 | );\r |
495 | \r |
496 | /**\r |
497 | Execute the command line.\r |
498 | \r |
499 | This function creates a nested instance of the shell and executes the specified\r |
500 | command (CommandLine) with the specified environment (Environment). Upon return,\r |
501 | the status code returned by the specified command is placed in StatusCode.\r |
502 | \r |
503 | If Environment is NULL, then the current environment is used and all changes made\r |
504 | by the commands executed will be reflected in the current environment. If the\r |
505 | Environment is non-NULL, then the changes made will be discarded.\r |
506 | \r |
507 | The CommandLine is executed from the current working directory on the current\r |
508 | device.\r |
509 | \r |
510 | @param ParentImageHandle A handle of the image that is executing the specified\r |
511 | command line.\r |
512 | @param CommandLine Points to the NULL-terminated UCS-2 encoded string\r |
513 | containing the command line. If NULL then the command-\r |
514 | line will be empty.\r |
515 | @param Environment Points to a NULL-terminated array of environment\r |
516 | variables with the format 'x=y', where x is the\r |
517 | environment variable name and y is the value. If this\r |
518 | is NULL, then the current shell environment is used.\r |
519 | @param StatusCode Points to the status code returned by the command.\r |
520 | \r |
521 | @retval EFI_SUCCESS The command executed successfully. The status code\r |
522 | returned by the command is pointed to by StatusCode.\r |
523 | @retval EFI_INVALID_PARAMETER The parameters are invalid.\r |
524 | @retval EFI_OUT_OF_RESOURCES Out of resources.\r |
525 | @retval EFI_UNSUPPORTED Nested shell invocations are not allowed.\r |
526 | **/\r |
527 | EFI_STATUS\r |
528 | EFIAPI\r |
529 | EfiShellExecute(\r |
530 | IN EFI_HANDLE *ParentImageHandle,\r |
531 | IN CHAR16 *CommandLine OPTIONAL,\r |
532 | IN CHAR16 **Environment OPTIONAL,\r |
533 | OUT EFI_STATUS *StatusCode OPTIONAL\r |
534 | );\r |
535 | \r |
536 | /**\r |
537 | Utility cleanup function for EFI_SHELL_FILE_INFO objects.\r |
538 | \r |
539 | 1) frees all pointers (non-NULL)\r |
540 | 2) Closes the SHELL_FILE_HANDLE\r |
541 | \r |
542 | @param FileListNode pointer to the list node to free\r |
543 | **/\r |
544 | VOID\r |
545 | EFIAPI\r |
546 | FreeShellFileInfoNode(\r |
547 | IN EFI_SHELL_FILE_INFO *FileListNode\r |
548 | );\r |
549 | \r |
550 | /**\r |
551 | Frees the file list.\r |
552 | \r |
553 | This function cleans up the file list and any related data structures. It has no\r |
554 | impact on the files themselves.\r |
555 | \r |
556 | @param FileList The file list to free. Type EFI_SHELL_FILE_INFO is\r |
557 | defined in OpenFileList()\r |
558 | \r |
559 | @retval EFI_SUCCESS Free the file list successfully.\r |
560 | @retval EFI_INVALID_PARAMETER FileList was NULL or *FileList was NULL;\r |
561 | **/\r |
562 | EFI_STATUS\r |
563 | EFIAPI\r |
564 | EfiShellFreeFileList(\r |
565 | IN EFI_SHELL_FILE_INFO **FileList\r |
566 | );\r |
567 | \r |
568 | /**\r |
569 | Deletes the duplicate file names files in the given file list.\r |
570 | \r |
571 | This function deletes the reduplicate files in the given file list.\r |
572 | \r |
573 | @param FileList A pointer to the first entry in the file list.\r |
574 | \r |
575 | @retval EFI_SUCCESS Always success.\r |
576 | @retval EFI_INVALID_PARAMETER FileList was NULL or *FileList was NULL;\r |
577 | **/\r |
578 | EFI_STATUS\r |
579 | EFIAPI\r |
580 | EfiShellRemoveDupInFileList(\r |
581 | IN EFI_SHELL_FILE_INFO **FileList\r |
582 | );\r |
583 | \r |
584 | /**\r |
585 | Allocates and populates a EFI_SHELL_FILE_INFO structure. if any memory operation\r |
586 | failed it will return NULL.\r |
587 | \r |
588 | @param[in] BasePath the Path to prepend onto filename for FullPath\r |
589 | @param[in] Status Status member initial value.\r |
590 | @param[in] FullName FullName member initial value.\r |
591 | @param[in] FileName FileName member initial value.\r |
592 | @param[in] Handle Handle member initial value.\r |
593 | @param[in] Info Info struct to copy.\r |
594 | \r |
595 | **/\r |
596 | EFI_SHELL_FILE_INFO *\r |
597 | EFIAPI\r |
598 | CreateAndPopulateShellFileInfo(\r |
599 | IN CONST CHAR16 *BasePath,\r |
600 | IN CONST EFI_STATUS Status,\r |
601 | IN CONST CHAR16 *FullName,\r |
602 | IN CONST CHAR16 *FileName,\r |
603 | IN CONST SHELL_FILE_HANDLE Handle,\r |
604 | IN CONST EFI_FILE_INFO *Info\r |
605 | );\r |
606 | \r |
607 | /**\r |
608 | Find all files in a specified directory.\r |
609 | \r |
610 | @param FileDirHandle Handle of the directory to search.\r |
611 | @param FileList On return, points to the list of files in the directory\r |
612 | or NULL if there are no files in the directory.\r |
613 | \r |
614 | @retval EFI_SUCCESS File information was returned successfully.\r |
615 | @retval EFI_VOLUME_CORRUPTED The file system structures have been corrupted.\r |
616 | @retval EFI_DEVICE_ERROR The device reported an error.\r |
617 | @retval EFI_NO_MEDIA The device media is not present.\r |
618 | @retval EFI_INVALID_PARAMETER The FileDirHandle was not a directory.\r |
619 | **/\r |
620 | EFI_STATUS\r |
621 | EFIAPI\r |
622 | EfiShellFindFilesInDir(\r |
623 | IN SHELL_FILE_HANDLE FileDirHandle,\r |
624 | OUT EFI_SHELL_FILE_INFO **FileList\r |
625 | );\r |
626 | \r |
627 | /**\r |
628 | Find files that match a specified pattern.\r |
629 | \r |
630 | This function searches for all files and directories that match the specified\r |
631 | FilePattern. The FilePattern can contain wild-card characters. The resulting file\r |
632 | information is placed in the file list FileList.\r |
633 | \r |
634 | Wildcards are processed\r |
635 | according to the rules specified in UEFI Shell 2.0 spec section 3.7.1.\r |
636 | \r |
637 | The files in the file list are not opened. The OpenMode field is set to 0 and the FileInfo\r |
638 | field is set to NULL.\r |
639 | \r |
640 | if *FileList is not NULL then it must be a pre-existing and properly initialized list.\r |
641 | \r |
642 | @param FilePattern Points to a NULL-terminated shell file path, including wildcards.\r |
643 | @param FileList On return, points to the start of a file list containing the names\r |
644 | of all matching files or else points to NULL if no matching files\r |
645 | were found. only on a EFI_SUCCESS return will; this be non-NULL.\r |
646 | \r |
647 | @retval EFI_SUCCESS Files found. FileList is a valid list.\r |
648 | @retval EFI_NOT_FOUND No files found.\r |
649 | @retval EFI_NO_MEDIA The device has no media\r |
650 | @retval EFI_DEVICE_ERROR The device reported an error\r |
651 | @retval EFI_VOLUME_CORRUPTED The file system structures are corrupted\r |
652 | **/\r |
653 | EFI_STATUS\r |
654 | EFIAPI\r |
655 | EfiShellFindFiles(\r |
656 | IN CONST CHAR16 *FilePattern,\r |
657 | OUT EFI_SHELL_FILE_INFO **FileList\r |
658 | );\r |
659 | \r |
660 | /**\r |
661 | Opens the files that match the path specified.\r |
662 | \r |
663 | This function opens all of the files specified by Path. Wildcards are processed\r |
664 | according to the rules specified in UEFI Shell 2.0 spec section 3.7.1. Each\r |
665 | matching file has an EFI_SHELL_FILE_INFO structure created in a linked list.\r |
666 | \r |
667 | @param Path A pointer to the path string.\r |
668 | @param OpenMode Specifies the mode used to open each file, EFI_FILE_MODE_READ or\r |
669 | EFI_FILE_MODE_WRITE.\r |
670 | @param FileList Points to the start of a list of files opened.\r |
671 | \r |
672 | @retval EFI_SUCCESS Create the file list successfully.\r |
673 | @return Others Can't create the file list.\r |
674 | **/\r |
675 | EFI_STATUS\r |
676 | EFIAPI\r |
677 | EfiShellOpenFileList(\r |
678 | IN CHAR16 *Path,\r |
679 | IN UINT64 OpenMode,\r |
680 | IN OUT EFI_SHELL_FILE_INFO **FileList\r |
681 | );\r |
682 | \r |
683 | /**\r |
684 | Gets the environment variable.\r |
685 | \r |
686 | This function returns the current value of the specified environment variable.\r |
687 | \r |
688 | @param Name A pointer to the environment variable name\r |
689 | \r |
690 | @return !=NULL The environment variable's value. The returned\r |
691 | pointer does not need to be freed by the caller.\r |
692 | @retval NULL The environment variable doesn't exist.\r |
693 | **/\r |
694 | CONST CHAR16 *\r |
695 | EFIAPI\r |
696 | EfiShellGetEnv(\r |
697 | IN CONST CHAR16 *Name\r |
698 | );\r |
699 | \r |
700 | /**\r |
701 | Sets the environment variable.\r |
702 | \r |
703 | This function changes the current value of the specified environment variable. If the\r |
704 | environment variable exists and the Value is an empty string, then the environment\r |
705 | variable is deleted. If the environment variable exists and the Value is not an empty\r |
706 | string, then the value of the environment variable is changed. If the environment\r |
707 | variable does not exist and the Value is an empty string, there is no action. If the\r |
708 | environment variable does not exist and the Value is a non-empty string, then the\r |
709 | environment variable is created and assigned the specified value.\r |
710 | \r |
711 | For a description of volatile and non-volatile environment variables, see UEFI Shell\r |
712 | 2.0 specification section 3.6.1.\r |
713 | \r |
714 | @param Name Points to the NULL-terminated environment variable name.\r |
715 | @param Value Points to the NULL-terminated environment variable value. If the value is an\r |
716 | empty string then the environment variable is deleted.\r |
717 | @param Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).\r |
718 | \r |
719 | @retval EFI_SUCCESS The environment variable was successfully updated.\r |
720 | **/\r |
721 | EFI_STATUS\r |
722 | EFIAPI\r |
723 | EfiShellSetEnv(\r |
724 | IN CONST CHAR16 *Name,\r |
725 | IN CONST CHAR16 *Value,\r |
726 | IN BOOLEAN Volatile\r |
727 | );\r |
728 | \r |
729 | /**\r |
730 | Returns the current directory on the specified device.\r |
731 | \r |
732 | If FileSystemMapping is NULL, it returns the current working directory. If the\r |
733 | FileSystemMapping is not NULL, it returns the current directory associated with the\r |
734 | FileSystemMapping. In both cases, the returned name includes the file system\r |
735 | mapping (i.e. fs0:\current-dir).\r |
736 | \r |
737 | @param FileSystemMapping A pointer to the file system mapping. If NULL,\r |
738 | then the current working directory is returned.\r |
739 | \r |
740 | @retval !=NULL The current directory.\r |
741 | @retval NULL Current directory does not exist.\r |
742 | **/\r |
743 | CONST CHAR16 *\r |
744 | EFIAPI\r |
745 | EfiShellGetCurDir(\r |
746 | IN CONST CHAR16 *FileSystemMapping OPTIONAL\r |
747 | );\r |
748 | \r |
749 | /**\r |
750 | Changes the current directory on the specified device.\r |
751 | \r |
752 | If the FileSystem is NULL, and the directory Dir does not contain a file system's\r |
753 | mapped name, this function changes the current working directory. If FileSystem is\r |
754 | NULL and the directory Dir contains a mapped name, then the current file system and\r |
755 | the current directory on that file system are changed.\r |
756 | \r |
757 | If FileSystem is not NULL, and Dir is NULL, then this changes the current working file\r |
758 | system.\r |
759 | \r |
760 | If FileSystem is not NULL and Dir is not NULL, then this function changes the current\r |
761 | directory on the specified file system.\r |
762 | \r |
763 | If the current working directory or the current working file system is changed then the\r |
764 | %cwd% environment variable will be updated\r |
765 | \r |
766 | @param FileSystem A pointer to the file system's mapped name. If NULL, then the current working\r |
767 | directory is changed.\r |
768 | @param Dir Points to the NULL-terminated directory on the device specified by FileSystem.\r |
769 | \r |
770 | @retval EFI_SUCCESS The operation was sucessful\r |
771 | **/\r |
772 | EFI_STATUS\r |
773 | EFIAPI\r |
774 | EfiShellSetCurDir(\r |
775 | IN CONST CHAR16 *FileSystem OPTIONAL,\r |
776 | IN CONST CHAR16 *Dir\r |
777 | );\r |
778 | \r |
779 | /**\r |
780 | Return help information about a specific command.\r |
781 | \r |
782 | This function returns the help information for the specified command. The help text\r |
783 | can be internal to the shell or can be from a UEFI Shell manual page.\r |
784 | \r |
785 | If Sections is specified, then each section name listed will be compared in a casesensitive\r |
786 | manner, to the section names described in Appendix B. If the section exists,\r |
787 | it will be appended to the returned help text. If the section does not exist, no\r |
788 | information will be returned. If Sections is NULL, then all help text information\r |
789 | available will be returned.\r |
790 | \r |
791 | @param Command Points to the NULL-terminated UEFI Shell command name.\r |
792 | @param Sections Points to the NULL-terminated comma-delimited\r |
793 | section names to return. If NULL, then all\r |
794 | sections will be returned.\r |
795 | @param HelpText On return, points to a callee-allocated buffer\r |
796 | containing all specified help text.\r |
797 | \r |
798 | @retval EFI_SUCCESS The help text was returned.\r |
799 | @retval EFI_OUT_OF_RESOURCES The necessary buffer could not be allocated to hold the\r |
800 | returned help text.\r |
801 | @retval EFI_INVALID_PARAMETER HelpText is NULL\r |
802 | @retval EFI_NOT_FOUND There is no help text available for Command.\r |
803 | **/\r |
804 | EFI_STATUS\r |
805 | EFIAPI\r |
806 | EfiShellGetHelpText(\r |
807 | IN CONST CHAR16 *Command,\r |
808 | IN CONST CHAR16 *Sections OPTIONAL,\r |
809 | OUT CHAR16 **HelpText\r |
810 | );\r |
811 | \r |
812 | /**\r |
813 | Gets the enable status of the page break output mode.\r |
814 | \r |
815 | User can use this function to determine current page break mode.\r |
816 | \r |
817 | @retval TRUE The page break output mode is enabled\r |
818 | @retval FALSE The page break output mode is disabled\r |
819 | **/\r |
820 | BOOLEAN\r |
821 | EFIAPI\r |
822 | EfiShellGetPageBreak(\r |
823 | VOID\r |
824 | );\r |
825 | \r |
826 | /**\r |
827 | Judges whether the active shell is the root shell.\r |
828 | \r |
829 | This function makes the user to know that whether the active Shell is the root shell.\r |
830 | \r |
831 | @retval TRUE The active Shell is the root Shell.\r |
832 | @retval FALSE The active Shell is NOT the root Shell.\r |
833 | **/\r |
834 | BOOLEAN\r |
835 | EFIAPI\r |
836 | EfiShellIsRootShell(\r |
837 | VOID\r |
838 | );\r |
839 | \r |
840 | /**\r |
841 | This function returns the command associated with a alias or a list of all\r |
842 | alias'.\r |
843 | \r |
844 | @param[in] Command Points to the NULL-terminated shell alias.\r |
845 | If this parameter is NULL, then all\r |
846 | aliases will be returned in ReturnedData.\r |
847 | @param[out] Volatile upon return of a single command if TRUE indicates\r |
848 | this is stored in a volatile fashion. FALSE otherwise.\r |
849 | @return If Alias is not NULL, it will return a pointer to\r |
850 | the NULL-terminated command for that alias.\r |
851 | If Alias is NULL, ReturnedData points to a ';'\r |
852 | delimited list of alias (e.g.\r |
853 | ReturnedData = "dir;del;copy;mfp") that is NULL-terminated.\r |
854 | @retval NULL an error ocurred\r |
855 | @retval NULL Alias was not a valid Alias\r |
856 | **/\r |
857 | CONST CHAR16 *\r |
858 | EFIAPI\r |
859 | EfiShellGetAlias(\r |
860 | IN CONST CHAR16 *Command,\r |
861 | OUT BOOLEAN *Volatile OPTIONAL\r |
862 | );\r |
863 | \r |
864 | /**\r |
865 | Changes a shell command alias.\r |
866 | \r |
867 | This function creates an alias for a shell command or if Alias is NULL it will delete an existing alias.\r |
868 | \r |
869 | this function does not check for built in alias'.\r |
870 | \r |
871 | @param[in] Command Points to the NULL-terminated shell command or existing alias.\r |
872 | @param[in] Alias Points to the NULL-terminated alias for the shell command. If this is NULL, and\r |
873 | Command refers to an alias, that alias will be deleted.\r |
874 | @param[in] Volatile if TRUE the Alias being set will be stored in a volatile fashion. if FALSE the\r |
875 | Alias being set will be stored in a non-volatile fashion.\r |
876 | \r |
877 | @retval EFI_SUCCESS Alias created or deleted successfully.\r |
878 | @retval EFI_NOT_FOUND the Alias intended to be deleted was not found\r |
879 | **/\r |
880 | EFI_STATUS\r |
881 | EFIAPI\r |
882 | InternalSetAlias(\r |
883 | IN CONST CHAR16 *Command,\r |
884 | IN CONST CHAR16 *Alias OPTIONAL,\r |
885 | IN BOOLEAN Volatile\r |
886 | );\r |
887 | \r |
888 | /**\r |
889 | Changes a shell command alias.\r |
890 | \r |
891 | This function creates an alias for a shell command or if Alias is NULL it will delete an existing alias.\r |
892 | \r |
893 | \r |
894 | @param[in] Command Points to the NULL-terminated shell command or existing alias.\r |
895 | @param[in] Alias Points to the NULL-terminated alias for the shell command. If this is NULL, and\r |
896 | Command refers to an alias, that alias will be deleted.\r |
897 | @param[in] Replace If TRUE and the alias already exists, then the existing alias will be replaced. If\r |
898 | FALSE and the alias already exists, then the existing alias is unchanged and\r |
899 | EFI_ACCESS_DENIED is returned.\r |
900 | @param[in] Volatile if TRUE the Alias being set will be stored in a volatile fashion. if FALSE the\r |
901 | Alias being set will be stored in a non-volatile fashion.\r |
902 | \r |
903 | @retval EFI_SUCCESS Alias created or deleted successfully.\r |
904 | @retval EFI_NOT_FOUND the Alias intended to be deleted was not found\r |
905 | @retval EFI_ACCESS_DENIED The alias is a built-in alias or already existed and Replace was set to\r |
906 | FALSE.\r |
907 | **/\r |
908 | EFI_STATUS\r |
909 | EFIAPI\r |
910 | EfiShellSetAlias(\r |
911 | IN CONST CHAR16 *Command,\r |
912 | IN CONST CHAR16 *Alias OPTIONAL,\r |
913 | IN BOOLEAN Replace,\r |
914 | IN BOOLEAN Volatile\r |
915 | );\r |
916 | \r |
917 | /**\r |
918 | Utility cleanup function for EFI_SHELL_FILE_INFO objects.\r |
919 | \r |
920 | 1) frees all pointers (non-NULL)\r |
921 | 2) Closes the SHELL_FILE_HANDLE\r |
922 | \r |
923 | @param FileListNode pointer to the list node to free\r |
924 | **/\r |
925 | VOID\r |
926 | EFIAPI\r |
927 | InternalFreeShellFileInfoNode(\r |
928 | IN EFI_SHELL_FILE_INFO *FileListNode\r |
929 | );\r |
930 | \r |
931 | /**\r |
932 | Internal variable setting function. Allows for setting of the read only variables.\r |
933 | \r |
934 | @param Name Points to the NULL-terminated environment variable name.\r |
935 | @param Value Points to the NULL-terminated environment variable value. If the value is an\r |
936 | empty string then the environment variable is deleted.\r |
937 | @param Volatile Indicates whether the variable is non-volatile (FALSE) or volatile (TRUE).\r |
938 | \r |
939 | @retval EFI_SUCCESS The environment variable was successfully updated.\r |
940 | **/\r |
941 | EFI_STATUS\r |
942 | EFIAPI\r |
943 | InternalEfiShellSetEnv(\r |
944 | IN CONST CHAR16 *Name,\r |
945 | IN CONST CHAR16 *Value,\r |
946 | IN BOOLEAN Volatile\r |
947 | );\r |
948 | \r |
949 | #endif //_SHELL_PROTOCOL_HEADER_\r |
950 | \r |