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