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