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