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