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