]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Include/Protocol/EfiShellEnvironment2.h
updating comments mostly. also added some new lib functions.
[mirror_edk2.git] / ShellPkg / Include / Protocol / EfiShellEnvironment2.h
CommitLineData
94b17fa1 1/** @file\r
9b3bf083 2 Defines for EFI shell environment 2 ported to EDK II build environment. (no spec)\r
94b17fa1 3\r
b3011f40 4 Copyright (c) 2005 - 2010, Intel Corporation<BR>\r
5 All rights reserved. This program and the accompanying materials\r
6 are licensed and made available under the terms and conditions of the BSD License\r
7 which accompanies this distribution. The full text of the license may be found at\r
8 http://opensource.org/licenses/bsd-license.php\r
94b17fa1 9\r
b3011f40 10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
94b17fa1 12\r
13**/\r
14\r
15 \r
b3011f40 16#if !defined (_SHELL_ENVIRONMENT_2_PROTOCOL_H_)\r
17#define _SHELL_ENVIRONMENT_2_PROTOCOL_H_\r
94b17fa1 18\r
19#define DEFAULT_INIT_ROW 1\r
20#define DEFAULT_AUTO_LF FALSE\r
21\r
94b17fa1 22/**\r
a31bd33c 23 This function is a prototype for a function that dumps information on a protocol \r
24 to a given location. The location is dependant on the implementation. This is \r
94b17fa1 25 used when programatically adding shell commands.\r
26\r
b3011f40 27 @param Handle The handle the protocol is on.\r
28 @param Interface The interface to the protocol.\r
94b17fa1 29\r
30**/\r
31typedef\r
32VOID\r
33(EFIAPI *SHELLENV_DUMP_PROTOCOL_INFO) (\r
34 IN EFI_HANDLE Handle,\r
35 IN VOID *Interface\r
36 );\r
37\r
38/**\r
a31bd33c 39 This function is a prototype for each command internal to the EFI shell \r
40 implementation. The specific command depends on the implementation. This is \r
94b17fa1 41 used when programatically adding shell commands.\r
42\r
a31bd33c 43 @param ImageHandle The handle to the binary shell.\r
44 @param SystemTable Pointer to the system table.\r
94b17fa1 45\r
a31bd33c 46 @retval EFI_SUCCESS The command ran to completion\r
47 @retval other An error ocurred. Any error is possible \r
94b17fa1 48 depending on the implementation of the shell \r
49 command.\r
50\r
51**/\r
52typedef\r
53EFI_STATUS\r
54(EFIAPI *SHELLENV_INTERNAL_COMMAND) (\r
55 IN EFI_HANDLE ImageHandle,\r
56 IN EFI_SYSTEM_TABLE *SystemTable\r
57 );\r
58\r
59/**\r
60 This function is a prototype for one that gets a help string for a given command. \r
61 This is used when programatically adding shell commands. Upon successful return \r
62 the memory allocated is up to the caller to free.\r
63\r
a31bd33c 64 @param Str Pointer to pointer to string to display for help.\r
94b17fa1 65\r
b3011f40 66 @retval EFI_SUCCESS The help string is in the parameter Str.\r
94b17fa1 67\r
68**/\r
69typedef\r
70EFI_STATUS\r
71(EFIAPI *SHELLCMD_GET_LINE_HELP) (\r
72 IN OUT CHAR16 **Str\r
73 );\r
74\r
75/**\r
a31bd33c 76Structure returned from functions that open multiple files.\r
94b17fa1 77**/\r
78typedef struct {\r
79 UINT32 Signature; ///< SHELL_FILE_ARG_SIGNATURE\r
a31bd33c 80 LIST_ENTRY Link; ///< Linked list helper\r
94b17fa1 81 EFI_STATUS Status; ///< File's status\r
82\r
a31bd33c 83 EFI_FILE_HANDLE Parent; ///< What is the Parent file of this file\r
84 UINT64 OpenMode; ///< How was the file opened\r
85 CHAR16 *ParentName; ///< String representation of parent\r
94b17fa1 86 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; ///< DevicePath for Parent\r
87\r
a31bd33c 88 CHAR16 *FullName; ///< Path and file name for this file\r
89 CHAR16 *FileName; ///< File name for this file\r
94b17fa1 90\r
a31bd33c 91 EFI_FILE_HANDLE Handle; ///< Handle to this file\r
92 EFI_FILE_INFO *Info; ///< Pointer to file info for this file\r
94b17fa1 93} SHELL_FILE_ARG;\r
94\r
a31bd33c 95/// Signature for SHELL_FILE_ARG\r
94b17fa1 96#define SHELL_FILE_ARG_SIGNATURE SIGNATURE_32 ('g', 'r', 'a', 'f') \r
97\r
98/**\r
b3011f40 99GUID for the shell environment2 and shell environment.\r
94b17fa1 100**/\r
101#define SHELL_ENVIRONMENT_PROTOCOL_GUID \\r
102 { \\r
55034088 103 0x47c7b221, 0xc42a, 0x11d2, {0x8e, 0x57, 0x0, 0xa0, 0xc9, 0x69, 0x72, 0x3b} \\r
94b17fa1 104 }\r
105\r
106/**\r
b3011f40 107GUID for the shell environment2 extension (main GUID above).\r
94b17fa1 108**/\r
109#define EFI_SE_EXT_SIGNATURE_GUID \\r
110 { \\r
111 0xd2c18636, 0x40e5, 0x4eb5, {0xa3, 0x1b, 0x36, 0x69, 0x5f, 0xd4, 0x2c, 0x87} \\r
112 }\r
113\r
114#define EFI_SHELL_MAJOR_VER 0x00000001 ///< Major version of the EFI_SHELL_ENVIRONMENT2\r
115#define EFI_SHELL_MINOR_VER 0x00000000 ///< Minor version of the EFI_SHELL_ENVIRONMENT2\r
116\r
117/**\r
a31bd33c 118 Execute a command line\r
94b17fa1 119\r
a31bd33c 120 This function will run the CommandLine. This includes loading any required images, \r
94b17fa1 121 parsing any requires scripts, and it DebugOutput is TRUE printing errors \r
122 encountered directly to the screen.\r
123 \r
a31bd33c 124 @param ParentImageHandle Handle of image executing this operation.\r
b3011f40 125 @param CommandLine The string command line to execute.\r
94b17fa1 126 @param DebugOutput TRUE indicates that errors should be printed directly.\r
127 FALSE supresses error messages.\r
128\r
a31bd33c 129 @retval EFI_SUCCESS The command line executed and completed.\r
130 @retval EFI_ABORTED The operation did not complete due to abort.\r
94b17fa1 131 @retval EFI_INVALID_PARAMETER A parameter did not have a valid value.\r
132 @retval EFI_OUT_OF_RESOURCES A required memory allocation failed.\r
133\r
134@sa HandleProtocol\r
135**/\r
136typedef\r
137EFI_STATUS\r
138(EFIAPI *SHELLENV_EXECUTE) (\r
139 IN EFI_HANDLE *ParentImageHandle,\r
140 IN CHAR16 *CommandLine,\r
141 IN BOOLEAN DebugOutput\r
142 );\r
143\r
144/**\r
b3011f40 145 This function returns a shell environment variable value.\r
94b17fa1 146\r
b3011f40 147 @param Name Pointer to the string with the shell environment \r
148 variable name.\r
94b17fa1 149\r
b3011f40 150 @retval NULL The shell environment variable's value could not be found.\r
151 @retval !NULL The value of the shell environment variable Name.\r
94b17fa1 152\r
153**/\r
154typedef \r
155CHAR16 * \r
156(EFIAPI *SHELLENV_GET_ENV) (\r
157 IN CHAR16 *Name\r
158 );\r
159\r
160/**\r
b3011f40 161 This function returns a shell environment map value.\r
94b17fa1 162\r
b3011f40 163 @param Name Pointer to the string with the shell environment \r
164 map name.\r
94b17fa1 165\r
b3011f40 166 @retval NULL The shell environment map's value could not be found.\r
167 @retval !NULL The value of the shell environment map Name.\r
94b17fa1 168\r
169**/\r
170typedef \r
171CHAR16 * \r
172(EFIAPI *SHELLENV_GET_MAP) (\r
173 IN CHAR16 *Name\r
174 );\r
175\r
176/**\r
177 This function will add an internal command to the shell interface.\r
178\r
179 This will allocate all required memory, put the new command on the command\r
180 list in the correct location.\r
181\r
b3011f40 182 @param Handler The handler function to call when the command gets called.\r
183 @param CmdStr The command name.\r
184 @param GetLineHelp Function to call of get help for this command.\r
94b17fa1 185\r
b3011f40 186 @retval EFI_SUCCESS The command is now part of the command list.\r
187 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
94b17fa1 188 @sa SHELLENV_INTERNAL_COMMAND\r
189 @sa SHELLCMD_GET_LINE_HELP\r
190**/\r
191typedef\r
192EFI_STATUS\r
193(EFIAPI *SHELLENV_ADD_CMD) (\r
194 IN SHELLENV_INTERNAL_COMMAND Handler,\r
195 IN CHAR16 *Cmd,\r
196 IN SHELLCMD_GET_LINE_HELP GetLineHelp\r
197 );\r
198\r
199/**\r
200 Internal interface to add protocol handlers.\r
201\r
202 This function is for internal shell use only. This is how protocol handlers are added.\r
203 This will get the current protocol info and add the new info or update existing info\r
204 and then resave the info.\r
205\r
b3011f40 206 @param SaveId Save this change as an EFI variable.\r
207 @param Protocol The protocol's GUID.\r
94b17fa1 208 @param DumpToken The function pointer to dump token function or \r
b3011f40 209 NULL.\r
94b17fa1 210 @param DumpInfo The function pointer to dump infomation function \r
b3011f40 211 or NULL.\r
212 @param IdString The english name of the protocol.\r
94b17fa1 213**/\r
214typedef\r
215VOID\r
216(EFIAPI *SHELLENV_ADD_PROT) (\r
217 IN EFI_GUID *Protocol,\r
218 IN SHELLENV_DUMP_PROTOCOL_INFO DumpToken OPTIONAL,\r
219 IN SHELLENV_DUMP_PROTOCOL_INFO DumpInfo OPTIONAL,\r
220 IN CHAR16 *IdString\r
221 );\r
222\r
223/**\r
b3011f40 224 This function finds a protocol handle by a GUID. \r
94b17fa1 225\r
226 This function will check for already known protocols by GUID and if one is \r
b3011f40 227 found it will return the name of that protocol. If no name is found and \r
94b17fa1 228 GenId is TRUE it will generate ths string.\r
229\r
b3011f40 230 @param Protocol The GUID of the protocol to look for.\r
231 @param GenId Whether to generate a name string if its not found.\r
94b17fa1 232\r
b3011f40 233 @return !NULL The Name of the protocol.\r
234 @retval NULL The Name was not found and GenId was not TRUE.\r
94b17fa1 235**/\r
236typedef \r
237CHAR16*\r
238(EFIAPI *SHELLENV_GET_PROT) (\r
239 IN EFI_GUID *Protocol, \r
240 IN BOOLEAN GenId\r
241 );\r
242\r
243/**\r
b3011f40 244 This function returns the current directory on a given device.\r
94b17fa1 245\r
246 If DeviceName is specified, then return the current shell directory on that \r
247 device. If DeviceName is NULL, then return the current directory on the \r
248 current device. The caller us responsible to free the returned string when\r
249 no londer required.\r
250\r
b3011f40 251 @param DeviceName The name of the device to get the current \r
252 directory on or NULL for current device.\r
94b17fa1 253\r
254 @return The current directory on the current or specified device.\r
255\r
256**/\r
257typedef \r
258CHAR16*\r
259(EFIAPI *SHELLENV_CUR_DIR) (\r
260 IN CHAR16 *DeviceName OPTIONAL\r
261 );\r
262\r
263/**\r
b3011f40 264 This function will open a group of files that match the Arg path, including \r
265 support for wildcard characters ('?' and '*') in the Arg path. If there are \r
94b17fa1 266 any wildcard characters in the path this function will find any and all files\r
b3011f40 267 that match the wildcards. The return is a double linked list based on the \r
268 LIST_ENTRY linked list structure. Use this in conjunction with the \r
94b17fa1 269 SHELL_FILE_ARG_SIGNATURE to get the SHELL_FILE_ARG structures that are returned.\r
270 The memory allocated by the callee for this list is freed by making a call to \r
271 SHELLENV_FREE_FILE_LIST.\r
272\r
b3011f40 273 @param Arg Pointer Path to files to open.\r
274 @param ListHead Pointer to allocated and initialized list head \r
94b17fa1 275 upon which to append all the opened file structures.\r
276\r
277 @retval EFI_SUCCESS 1 or more files was opened and a struct of each file's\r
278 information was appended to ListHead.\r
b3011f40 279 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
280 @retval EFI_NOT_FOUND No matching files could be found.\r
94b17fa1 281 @sa SHELLENV_FREE_FILE_LIST\r
282**/typedef\r
283EFI_STATUS\r
284(EFIAPI *SHELLENV_FILE_META_ARG) (\r
285 IN CHAR16 *Arg,\r
d2b4564b 286 IN OUT LIST_ENTRY *ListHead\r
94b17fa1 287 );\r
288\r
289/**\r
b3011f40 290 This frees all of the nodes under the ListHead, but not ListHead itself.\r
94b17fa1 291\r
292 @param ListHead Pointer to list to free all nodes of.\r
293\r
294 @retval EFI_SUCCESS always returned.\r
295**/\r
296typedef\r
297EFI_STATUS\r
298(EFIAPI *SHELLENV_FREE_FILE_LIST) (\r
d2b4564b 299 IN OUT LIST_ENTRY *ListHead\r
94b17fa1 300 );\r
301\r
302/**\r
b3011f40 303 This function creates a new instance of the ShellInterface protocol for use on \r
94b17fa1 304 the ImageHandle.\r
305\r
b3011f40 306 This function is for internal shell usage. This will allocate and then populate \r
307 EFI_SHELL_INTERFACE protocol. It is the caller's responsibility to free the \r
94b17fa1 308 memory.\r
309\r
b3011f40 310 @param ImageHandle The handle which will use the new ShellInterface \r
94b17fa1 311 protocol.\r
312\r
313 @return the newly allocated shell interface protocol.\r
314\r
315**/\r
316typedef \r
317EFI_SHELL_INTERFACE* \r
318(EFIAPI *SHELLENV_NEW_SHELL) (\r
319 IN EFI_HANDLE ImageHandle\r
320 );\r
321\r
322/**\r
b3011f40 323 This function determins whether a script file is currently being processed.\r
94b17fa1 324\r
b3011f40 325 A script file (.nsh file) can contain a series of commands and this is useful to \r
94b17fa1 326 know for some shell commands whether they are being run manually or as part of a \r
327 script.\r
328\r
b3011f40 329 @retval TRUE A script file is being processed.\r
330 @retval FALSE A script file is not being processed.\r
94b17fa1 331**/\r
332typedef\r
333BOOLEAN\r
334(EFIAPI *SHELLENV_BATCH_IS_ACTIVE) (\r
335 IN VOID\r
336 );\r
337\r
338/**\r
339 This is an internal shell function to free any and all allocated resources. \r
340 This should be called just closing the shell.\r
341**/\r
342typedef\r
343VOID\r
344(EFIAPI *SHELLENV_FREE_RESOURCES) (\r
345 VOID\r
346 );\r
347\r
348/**\r
349 This function enables the page break mode.\r
350\r
351 This mode causes the output to pause after each complete screen to enable a \r
b3011f40 352 user to more easily read it. If AutoWrap is TRUE then rows with too many \r
353 characters will be chopped and divided into 2 rows. If FALSE then rows with \r
94b17fa1 354 too many characters may not be fully visible to the user on the screen.\r
355\r
b3011f40 356 @param StartRow The row number to start this on.\r
357 @param AutoWrap Whether to auto wrap rows that are too long.\r
94b17fa1 358**/\r
359typedef\r
360VOID\r
361(EFIAPI *SHELLENV_ENABLE_PAGE_BREAK) (\r
362 IN INT32 StartRow,\r
363 IN BOOLEAN AutoWrap\r
364 );\r
365\r
366/**\r
367 This function disables the page break mode.\r
368\r
b3011f40 369 Tisabling this causes the output to print out exactly as coded with no breaks \r
94b17fa1 370 for readability.\r
371**/\r
372typedef\r
373VOID\r
374(EFIAPI *SHELLENV_DISABLE_PAGE_BREAK) (\r
375 IN VOID\r
376 );\r
377\r
378/**\r
379 Get the status of the page break output mode.\r
380\r
b3011f40 381 @retval FALSE Page break output mode is not enabled.\r
382 @retval TRUE Page break output mode is enabled.\r
94b17fa1 383**/\r
384typedef\r
385BOOLEAN\r
386(EFIAPI *SHELLENV_GET_PAGE_BREAK) (\r
387 IN VOID\r
388 );\r
389\r
390/**\r
b3011f40 391 This function sets the keys to filter for for the console in. The valid \r
94b17fa1 392 values to set are:\r
393\r
394 #define EFI_OUTPUT_SCROLL 0x00000001\r
395 #define EFI_OUTPUT_PAUSE 0x00000002\r
396 #define EFI_EXECUTION_BREAK 0x00000004\r
397\r
398 @param KeyFilter The new key filter to use.\r
399**/\r
400typedef\r
401VOID\r
402(EFIAPI *SHELLENV_SET_KEY_FILTER) (\r
403 IN UINT32 KeyFilter\r
404 );\r
405\r
406/**\r
b3011f40 407 This function gets the keys to filter for for the console in. \r
94b17fa1 408\r
b3011f40 409 The valid values to get are:\r
94b17fa1 410 #define EFI_OUTPUT_SCROLL 0x00000001\r
411 #define EFI_OUTPUT_PAUSE 0x00000002\r
412 #define EFI_EXECUTION_BREAK 0x00000004\r
413\r
414 @retval the current filter mask.\r
415**/\r
416typedef\r
417UINT32\r
418(EFIAPI *SHELLENV_GET_KEY_FILTER) (\r
419 IN VOID\r
420 );\r
421\r
422/**\r
b3011f40 423 This function determins if the shell application should break.\r
94b17fa1 424\r
425 This is used to inform a shell application that a break condition has been \r
b3011f40 426 initiated. Long loops should check this to prevent delays to the break.\r
94b17fa1 427\r
b3011f40 428 @retval TRUE A break has been signaled. the application \r
94b17fa1 429 should exit with EFI_ABORTED as soon as possible.\r
b3011f40 430 @retval FALSE Continue as normal.\r
94b17fa1 431**/\r
432typedef\r
433BOOLEAN\r
434(EFIAPI *SHELLENV_GET_EXECUTION_BREAK) (\r
435 IN VOID\r
436 );\r
437\r
438/**\r
439 This is an internal-shell function used to increment the shell nesting level.\r
440\r
441**/\r
442typedef\r
443VOID\r
444(EFIAPI *SHELLENV_INCREMENT_SHELL_NESTING_LEVEL) (\r
445 IN VOID\r
446 );\r
447\r
448/**\r
449 This is an internal-shell function used to decrement the shell nesting level.\r
450**/\r
451typedef\r
452VOID\r
453(EFIAPI *SHELLENV_DECREMENT_SHELL_NESTING_LEVEL) (\r
454 IN VOID\r
455 );\r
456\r
457/**\r
b3011f40 458 This function determins if the caller is running under the root shell.\r
94b17fa1 459\r
b3011f40 460 @retval TRUE The caller is running under the root shell.\r
461 @retval FALSE The caller is not running under the root shell.\r
94b17fa1 462\r
463**/\r
464typedef\r
465BOOLEAN\r
466(EFIAPI *SHELLENV_IS_ROOT_SHELL) (\r
467 IN VOID\r
468 );\r
469\r
470/**\r
471 Close the console proxy to restore the original console.\r
472\r
b3011f40 473 This is an internal shell function to handle shell cascading. It restores the \r
94b17fa1 474 original set of console protocols.\r
475 \r
476 @param ConInHandle The handle of ConIn.\r
b3011f40 477 @param ConIn Pointer to the location to return the pointer to \r
94b17fa1 478 the original console input.\r
479 @param ConOutHandle The handle of ConOut\r
b3011f40 480 @param ConOut Pointer to the location to return the pointer to \r
94b17fa1 481 the original console output.\r
482**/\r
483typedef\r
484VOID\r
485(EFIAPI *SHELLENV_CLOSE_CONSOLE_PROXY) (\r
486 IN EFI_HANDLE ConInHandle,\r
487 IN OUT EFI_SIMPLE_TEXT_INPUT_PROTOCOL **ConIn,\r
488 IN EFI_HANDLE ConOutHandle,\r
489 IN OUT EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL **ConOut\r
490 );\r
491\r
492//\r
493// declarations of handle enumerator\r
494//\r
495/**\r
496 For ease of use the shell maps handle #'s to short numbers.\r
497 This is only done on request for various internal commands and the references \r
498 are immediately freed when the internal command completes.\r
499**/\r
500typedef\r
501VOID\r
502(EFIAPI *INIT_HANDLE_ENUMERATOR) (\r
503 VOID\r
504 );\r
505\r
506/**\r
b3011f40 507 This is an internal shell function to enumerate the handle database.\r
94b17fa1 508\r
b3011f40 509 This function gets the next handle in the handle database. If no handles are \r
510 found EFI_NOT_FOUND is returned. If the previous Handle was the last handle \r
94b17fa1 511 it is set to NULL before returning.\r
512\r
b3011f40 513 This must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
94b17fa1 514\r
b3011f40 515 @param Handle Pointer to pointer to Handle. Will be set\r
94b17fa1 516 on a sucessful return.\r
517\r
b3011f40 518 @retval EFI_SUCCESS The next handle in the handle database is *Handle.\r
519 @retval EFI_NOT_FOUND There is not another handle.\r
94b17fa1 520**/\r
521typedef\r
522EFI_STATUS\r
523(EFIAPI *NEXT_HANDLE) (\r
524 IN OUT EFI_HANDLE **Handle\r
525 );\r
526\r
527/**\r
b3011f40 528 This is an internal shell function to enumerate the handle database.\r
94b17fa1 529\r
b3011f40 530 This function skips the next SkipNum handles in the handle database. If there \r
94b17fa1 531 are not enough handles left to skip that many EFI_ACCESS_DENIED is returned and \r
532 no skip is performed.\r
533\r
b3011f40 534 This must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
94b17fa1 535\r
536 @param SkipNum how many handles to skip\r
537\r
538 @retval EFI_SUCCESS the next handle in the handle database is *Handle\r
539 @retval EFI_ACCESS_DENIED there are not SkipNum handles left in the database\r
540**/\r
541typedef\r
542EFI_STATUS\r
543(EFIAPI *SKIP_HANDLE) (\r
544 IN UINTN SkipNum\r
545 );\r
546\r
547/**\r
b3011f40 548 This is an internal shell function to enumerate the handle database.\r
94b17fa1 549\r
b3011f40 550 This function resets the the handle database so that NEXT_HANDLE and SKIP_HANDLE \r
94b17fa1 551 will start from EnumIndex on the next call. \r
552 \r
b3011f40 553 This must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
94b17fa1 554\r
b3011f40 555 @param EnumIndex Where to start.\r
94b17fa1 556\r
b3011f40 557 @return the number of handles either read out or skipped before this reset.\r
94b17fa1 558**/\r
559typedef\r
560UINTN\r
561(EFIAPI *RESET_HANDLE_ENUMERATOR) (\r
562 IN UINTN EnumIndex\r
563 );\r
564\r
565/**\r
b3011f40 566 This is an internal shell function to enumerate the handle database.\r
94b17fa1 567 \r
b3011f40 568 This must be called after INIT_HANDLE_ENUMERATOR.\r
94b17fa1 569\r
b3011f40 570 This function releases all memory and resources associated with the handle database.\r
571 Tfter this no other handle enumerator functions except INIT_HANDLE_ENUMERATOR will \r
94b17fa1 572 function properly.\r
573**/\r
574typedef\r
575VOID\r
576(EFIAPI *CLOSE_HANDLE_ENUMERATOR) (\r
577 VOID\r
578 );\r
579\r
580/**\r
b3011f40 581 This is an internal shell function to enumerate the handle database.\r
94b17fa1 582\r
b3011f40 583 This function returns the number of handles in the handle database.\r
94b17fa1 584 \r
b3011f40 585 This must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
94b17fa1 586\r
b3011f40 587 @return the number of handles in the handle database.\r
94b17fa1 588**/\r
589typedef\r
590UINTN\r
591(EFIAPI *GET_NUM) (\r
592 VOID\r
593 );\r
594\r
595/**\r
b3011f40 596Handle Enumerator structure.\r
94b17fa1 597**/\r
598typedef struct {\r
b3011f40 599 INIT_HANDLE_ENUMERATOR Init; ///< Pointer to INIT_HANDLE_ENUMERATOR function.\r
600 NEXT_HANDLE Next; ///< Pointer to NEXT_HANDLE function.\r
601 SKIP_HANDLE Skip; ///< Pointer to SKIP_HANDLE function.\r
602 RESET_HANDLE_ENUMERATOR Reset; ///< Pointer to RESET_HANDLE_ENUMERATOR function.\r
603 CLOSE_HANDLE_ENUMERATOR Close; ///< Pointer to CLOSE_HANDLE_ENUMERATOR function.\r
604 GET_NUM GetNum; ///< Pointer to GET_NUM function.\r
94b17fa1 605} HANDLE_ENUMERATOR;\r
b3011f40 606\r
94b17fa1 607/**\r
b3011f40 608 Signature for the PROTOCOL_INFO structure.\r
94b17fa1 609**/\r
610#define PROTOCOL_INFO_SIGNATURE SIGNATURE_32 ('s', 'p', 'i', 'n')\r
b3011f40 611\r
94b17fa1 612/**\r
613 PROTOCOL_INFO structure for protocol enumerator functions.\r
94b17fa1 614**/\r
615typedef struct {\r
b3011f40 616 UINTN Signature; ///< PROTOCOL_INFO_SIGNATURE.\r
617 LIST_ENTRY Link; ///< Standard lined list helper member.\r
94b17fa1 618 //\r
b3011f40 619 // The parsing info for the protocol.\r
94b17fa1 620 //\r
b3011f40 621 EFI_GUID ProtocolId; ///< GUID for the protocol.\r
622 CHAR16 *IdString; ///< Name of the protocol.\r
623 SHELLENV_DUMP_PROTOCOL_INFO DumpToken; ///< Pointer to DumpToken function for the protocol.\r
624 SHELLENV_DUMP_PROTOCOL_INFO DumpInfo; ///< Pointer to DumpInfo function for the protocol.\r
94b17fa1 625 //\r
b3011f40 626 // Patabase info on which handles are supporting this protocol.\r
94b17fa1 627 //\r
b3011f40 628 UINTN NoHandles; ///< How many handles produce this protocol.\r
629 EFI_HANDLE *Handles; ///< The array of handles.\r
94b17fa1 630\r
631} PROTOCOL_INFO;\r
632\r
633//\r
b3011f40 634// Declarations of protocol info enumerator.\r
94b17fa1 635//\r
636/**\r
b3011f40 637 This is an internal shell function to initialize the protocol enumerator.\r
94b17fa1 638\r
b3011f40 639 This must be called before NEXT_PROTOCOL_INFO, SKIP_PROTOCOL_INFO, \r
94b17fa1 640 RESET_PROTOCOL_INFO_ENUMERATOR, and CLOSE_PROTOCOL_INFO_ENUMERATOR are\r
641 called.\r
642**/\r
643typedef\r
644VOID\r
645(EFIAPI *INIT_PROTOCOL_INFO_ENUMERATOR) (\r
646 VOID\r
647 );\r
648\r
649/**\r
b3011f40 650 This function is an internal shell function for enumeration of protocols. \r
94b17fa1 651\r
652 This functiol will return the next protocol in the list. If this is called \r
653 immediately after initialization it will return the first. If this is called\r
654 immediately after reset it will return the protocol first again.\r
655\r
656 This cannot be called after CLOSE_PROTOCOL_INFO_ENUMERATOR, but it must be \r
657 called after INIT_PROTOCOL_INFO_ENUMERATOR.\r
658\r
b3011f40 659 @param ProtocolInfo Pointer to pointer to protocol information structure.\r
94b17fa1 660\r
b3011f40 661 @retval EFI_SUCCESS The next protocol's information was sucessfully returned.\r
662 @retval NULL There are no more protocols.\r
94b17fa1 663**/\r
664typedef\r
665EFI_STATUS\r
666(EFIAPI *NEXT_PROTOCOL_INFO) (\r
667 IN OUT PROTOCOL_INFO **ProtocolInfo\r
668 );\r
669\r
670/**\r
b3011f40 671 This function is an internal shell function for enumeration of protocols. \r
94b17fa1 672\r
673 This cannot be called after CLOSE_PROTOCOL_INFO_ENUMERATOR, but it must be \r
674 called after INIT_PROTOCOL_INFO_ENUMERATOR.\r
675\r
b3011f40 676 This function does nothing and always returns EFI_SUCCESS.\r
94b17fa1 677\r
b3011f40 678 @retval EFI_SUCCESS always returned (see above).\r
94b17fa1 679**/\r
680typedef\r
681EFI_STATUS\r
682(EFIAPI *SKIP_PROTOCOL_INFO) (\r
683 IN UINTN SkipNum\r
684 );\r
685\r
686/**\r
b3011f40 687 This function is an internal shell function for enumeration of protocols. \r
94b17fa1 688\r
689 This cannot be called after CLOSE_PROTOCOL_INFO_ENUMERATOR, but it must be \r
690 called after INIT_PROTOCOL_INFO_ENUMERATOR.\r
691\r
b3011f40 692 This function resets the list of protocols such that the next one in the \r
94b17fa1 693 list is the begining of the list.\r
694**/\r
695typedef\r
696VOID\r
697(EFIAPI *RESET_PROTOCOL_INFO_ENUMERATOR) (\r
698 VOID\r
699 );\r
700\r
701\r
702/**\r
b3011f40 703 This function is an internal shell function for enumeration of protocols. \r
94b17fa1 704\r
705 This must be called after INIT_PROTOCOL_INFO_ENUMERATOR. After this call\r
706 no protocol enumerator calls except INIT_PROTOCOL_INFO_ENUMERATOR may be made.\r
707\r
b3011f40 708 This function frees any memory or resources associated with the protocol\r
94b17fa1 709 enumerator.\r
710**/\r
711typedef\r
712VOID\r
713(EFIAPI *CLOSE_PROTOCOL_INFO_ENUMERATOR) (\r
714 VOID\r
715 );\r
716\r
717/**\r
b3011f40 718 Protocol enumerator structure of function pointers.\r
94b17fa1 719**/\r
720typedef struct {\r
b3011f40 721 INIT_PROTOCOL_INFO_ENUMERATOR Init; ///< Pointer to INIT_PROTOCOL_INFO_ENUMERATOR function.\r
722 NEXT_PROTOCOL_INFO Next; ///< Pointer to NEXT_PROTOCOL_INFO function.\r
723 SKIP_PROTOCOL_INFO Skip; ///< Pointer to SKIP_PROTOCOL_INFO function.\r
724 RESET_PROTOCOL_INFO_ENUMERATOR Reset; ///< Pointer to RESET_PROTOCOL_INFO_ENUMERATOR function.\r
725 CLOSE_PROTOCOL_INFO_ENUMERATOR Close; ///< Pointer to CLOSE_PROTOCOL_INFO_ENUMERATOR function.\r
94b17fa1 726} PROTOCOL_INFO_ENUMERATOR;\r
727\r
728/**\r
b3011f40 729 This function is used to retrieve a user-friendly display name for a handle. \r
94b17fa1 730\r
731 If UseComponentName is TRUE then the component name protocol for this device \r
732 or it's parent device (if required) will be used to obtain the name of the \r
733 device. If UseDevicePath is TRUE it will get the human readable device path\r
734 and return that. If both are TRUE it will try to use component name first\r
735 and device path if that fails. \r
736\r
737 It will use either ComponentName or ComponentName2 protocol, depending on \r
738 what is present.\r
739\r
740 This function will furthur verify whether the handle in question produced either\r
741 EFI_DRIVER_CONFIGRATION_PROTOCOL or EFI_DRIVER_CONFIGURATION2_PROTOCOL and also \r
742 whether the handle in question produced either EFI_DRIVER_DIAGNOSTICS_PROTOCOL or \r
743 EFI_DRIVER_DIAGNOSTICS2_PROTOCOL.\r
744 \r
745 Upon sucessful return the memory for *BestDeviceName is up to the caller to free.\r
746\r
b3011f40 747 @param DeviceHandle The device handle whose name is desired.\r
748 @param UseComponentName Whether to use the ComponentName protocol at all.\r
749 @param UseDevicePath Whether to use the DevicePath protocol at all.\r
750 @param Language Pointer to language string to use.\r
751 @param BestDeviceName Pointer to pointer to string allocated with the name.\r
752 @param ConfigurationStatus Pointer to status for opening a Configuration protocol.\r
753 @param DiagnosticsStatus Pointer to status for opening a Diagnostics protocol.\r
754 @param Display Whether to Print this out to default Print location.\r
755 @param Indent How many characters to indent the printing.\r
94b17fa1 756\r
b3011f40 757 @retval EFI_SUCCESS This function always returns EFI_SUCCESS.\r
94b17fa1 758**/\r
759typedef\r
760EFI_STATUS\r
761(EFIAPI *GET_DEVICE_NAME) (\r
762 EFI_HANDLE DeviceHandle,\r
763 BOOLEAN UseComponentName,\r
764 BOOLEAN UseDevicePath,\r
765 CHAR8 *Language,\r
766 CHAR16 **BestDeviceName,\r
767 EFI_STATUS *ConfigurationStatus,\r
768 EFI_STATUS *DiagnosticsStatus,\r
769 BOOLEAN Display,\r
770 UINTN Indent\r
771 );\r
772\r
773#define EFI_SHELL_COMPATIBLE_MODE_VER L"1.1.1" ///< string for lowest version this shell supports\r
774#define EFI_SHELL_ENHANCED_MODE_VER L"1.1.2" ///< string for highest version this shell supports\r
775\r
776/**\r
b3011f40 777 This function gets the shell mode as stored in the shell environment \r
778 "efishellmode". It will not fail.\r
94b17fa1 779\r
b3011f40 780 @param Mode Returns a string representing one of the \r
94b17fa1 781 2 supported modes of the shell.\r
782\r
b3011f40 783 @retval EFI_SUCCESS This function always returns success.\r
94b17fa1 784**/\r
785typedef\r
786EFI_STATUS\r
787(EFIAPI *GET_SHELL_MODE) (\r
788 OUT CHAR16 **Mode\r
789 );\r
790\r
791/**\r
b3011f40 792 Convert a file system style name to a device path.\r
94b17fa1 793\r
794 This function will convert a shell path name to a Device Path Protocol path.\r
795 This function will allocate any required memory for this operation and it \r
796 is the responsibility of the caller to free that memory when no longer required.\r
797\r
b3011f40 798 If anything prevents the complete conversion free any allocated memory and \r
94b17fa1 799 return NULL.\r
800\r
b3011f40 801 @retval !NULL A pointer to the callee allocated Device Path.\r
802 @retval NULL The operation could not be completed.\r
94b17fa1 803**/\r
804typedef \r
805EFI_DEVICE_PATH_PROTOCOL* \r
806(EFIAPI *SHELLENV_NAME_TO_PATH) (\r
807 IN CHAR16 *Path\r
808 );\r
809\r
810/**\r
b3011f40 811 Converts a device path into a file system map name.\r
812\r
813 If DevPath is NULL, then ASSERT.\r
94b17fa1 814\r
94b17fa1 815 This function looks through the shell environment map for a map whose device\r
816 path matches the DevPath parameter. If one is found the Name is returned via \r
817 Name parameter. If sucessful the caller must free the memory allocated for\r
818 Name.\r
819\r
b3011f40 820 This function will use the internal lock to prevent changes to the map during \r
94b17fa1 821 the lookup operation.\r
822 \r
b3011f40 823 @param DevPath The device path to search for a name for.\r
824 @param ConsistMapping What state to verify map flag VAR_ID_CONSIST.\r
825 @param Name On sucessful return the name of that device path.\r
94b17fa1 826\r
b3011f40 827 @retval EFI_SUCCESS The DevPath was found and the name returned\r
94b17fa1 828 in Name. \r
829 @retval EFI_OUT_OF_RESOURCES A required memory allocation failed.\r
b3011f40 830 @retval EFI_UNSUPPORTED The DevPath was not found in the map.\r
94b17fa1 831**/\r
832typedef\r
833EFI_STATUS\r
834(EFIAPI *SHELLENV_GET_FS_NAME) (\r
835 IN EFI_DEVICE_PATH_PROTOCOL * DevPath,\r
836 IN BOOLEAN ConsistMapping,\r
837 OUT CHAR16 **Name\r
838 );\r
839\r
840/**\r
b3011f40 841 This function will open a group of files that match the Arg path, but will not \r
842 support the wildcard characters ('?' and '*') in the Arg path. If there are \r
94b17fa1 843 any wildcard characters in the path this function will return \r
b3011f40 844 EFI_INVALID_PARAMETER. The return is a double linked list based on the \r
845 LIST_ENTRY linked list structure. Use this in conjunction with the \r
94b17fa1 846 SHELL_FILE_ARG_SIGNATURE to get the SHELL_FILE_ARG structures that are returned.\r
847 The memory allocated by the callee for this list is freed by making a call to \r
848 SHELLENV_FREE_FILE_LIST.\r
849\r
b3011f40 850 @param Arg Pointer Path to files to open.\r
851 @param ListHead Pointer to allocated and initialized list head \r
94b17fa1 852 upon which to append all the opened file structures.\r
853\r
854 @retval EFI_SUCCESS 1 or more files was opened and a struct of each file's\r
855 information was appended to ListHead.\r
b3011f40 856 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
857 @retval EFI_NOT_FOUND No matching files could be found.\r
94b17fa1 858 @sa SHELLENV_FREE_FILE_LIST\r
859**/\r
860typedef\r
861EFI_STATUS\r
862(EFIAPI *SHELLENV_FILE_META_ARG_NO_WILDCARD) (\r
863 IN CHAR16 *Arg,\r
d2b4564b 864 IN OUT LIST_ENTRY *ListHead\r
94b17fa1 865 );\r
866\r
867/**\r
b3011f40 868 This function removes duplicate file listings from lists.\r
94b17fa1 869\r
b3011f40 870 This is a function for use with SHELLENV_FILE_META_ARG_NO_WILDCARD and \r
871 SHELLENV_FILE_META_ARG. This function will verify that there are no duplicate\r
872 files in the list of returned files. Any file listed twice will have one of its\r
94b17fa1 873 instances removed.\r
874\r
b3011f40 875 @param ListHead Pointer to linked list head that was returned from \r
94b17fa1 876 SHELLENV_FILE_META_ARG_NO_WILDCARD or\r
877 SHELLENV_FILE_META_ARG.\r
878\r
b3011f40 879 @retval EFI_SUCCESS This function always returns success.\r
94b17fa1 880\r
881**/\r
882typedef\r
883EFI_STATUS\r
884(EFIAPI *SHELLENV_DEL_DUP_FILE) (\r
d2b4564b 885 IN LIST_ENTRY * ListHead\r
94b17fa1 886 );\r
887\r
888/**\r
889 Converts a File System map name to a device path.\r
890\r
b3011f40 891 if DevPath is NULL, then ASSERT().\r
94b17fa1 892\r
893 This function looks through the shell environment map for a map whose Name \r
894 matches the Name parameter. If one is found the device path pointer is \r
b3011f40 895 updated to point to that file systems device path. The caller should not \r
94b17fa1 896 free the memory from that device path.\r
897\r
b3011f40 898 This function will use the internal lock to prevent changes to the map during \r
94b17fa1 899 the lookup operation.\r
900\r
b3011f40 901 @param Name Pointer to NULL terminated UNICODE string of the \r
902 file system name.\r
903 @param DevPath Pointer to pointer to DevicePath. only valid on \r
904 OUT if sucessful.\r
94b17fa1 905\r
b3011f40 906 @retval EFI_SUCCESS The conversion was successful and the device \r
94b17fa1 907 path was returned.\r
b3011f40 908 @retval EFI_NOT_FOUND The file system could not be found in the map.\r
94b17fa1 909**/\r
910typedef\r
911EFI_STATUS\r
912(EFIAPI *SHELLENV_GET_FS_DEVICE_PATH) (\r
913 IN CHAR16 *Name,\r
914 OUT EFI_DEVICE_PATH_PROTOCOL **DevPath\r
915 );\r
916\r
b3011f40 917/// EFI_SHELL_ENVIRONMENT2 protocol structure.\r
94b17fa1 918typedef struct {\r
919 SHELLENV_EXECUTE Execute;\r
920 SHELLENV_GET_ENV GetEnv;\r
921 SHELLENV_GET_MAP GetMap;\r
922 SHELLENV_ADD_CMD AddCmd;\r
923 SHELLENV_ADD_PROT AddProt;\r
924 SHELLENV_GET_PROT GetProt;\r
925 SHELLENV_CUR_DIR CurDir;\r
926 SHELLENV_FILE_META_ARG FileMetaArg;\r
927 SHELLENV_FREE_FILE_LIST FreeFileList;\r
928\r
929 //\r
b3011f40 930 // The following services are only used by the shell itself.\r
94b17fa1 931 //\r
932 SHELLENV_NEW_SHELL NewShell;\r
933 SHELLENV_BATCH_IS_ACTIVE BatchIsActive;\r
934\r
935 SHELLENV_FREE_RESOURCES FreeResources;\r
936\r
937 //\r
b3011f40 938 // GUID to differentiate ShellEnvironment2 from ShellEnvironment.\r
94b17fa1 939 //\r
940 EFI_GUID SESGuid;\r
941 //\r
b3011f40 942 // Major Version grows if shell environment interface has been changes.\r
94b17fa1 943 //\r
944 UINT32 MajorVersion;\r
945 UINT32 MinorVersion;\r
946 SHELLENV_ENABLE_PAGE_BREAK EnablePageBreak;\r
947 SHELLENV_DISABLE_PAGE_BREAK DisablePageBreak;\r
948 SHELLENV_GET_PAGE_BREAK GetPageBreak;\r
949\r
950 SHELLENV_SET_KEY_FILTER SetKeyFilter;\r
951 SHELLENV_GET_KEY_FILTER GetKeyFilter;\r
952\r
953 SHELLENV_GET_EXECUTION_BREAK GetExecutionBreak;\r
954 SHELLENV_INCREMENT_SHELL_NESTING_LEVEL IncrementShellNestingLevel;\r
955 SHELLENV_DECREMENT_SHELL_NESTING_LEVEL DecrementShellNestingLevel;\r
956 SHELLENV_IS_ROOT_SHELL IsRootShell;\r
957\r
958 SHELLENV_CLOSE_CONSOLE_PROXY CloseConsoleProxy;\r
959 HANDLE_ENUMERATOR HandleEnumerator;\r
960 PROTOCOL_INFO_ENUMERATOR ProtocolInfoEnumerator;\r
961 GET_DEVICE_NAME GetDeviceName;\r
962 GET_SHELL_MODE GetShellMode;\r
963 SHELLENV_NAME_TO_PATH NameToPath;\r
964 SHELLENV_GET_FS_NAME GetFsName;\r
965 SHELLENV_FILE_META_ARG_NO_WILDCARD FileMetaArgNoWildCard;\r
966 SHELLENV_DEL_DUP_FILE DelDupFileArg;\r
967 SHELLENV_GET_FS_DEVICE_PATH GetFsDevicePath;\r
968} EFI_SHELL_ENVIRONMENT2;\r
969\r
970extern EFI_GUID gEfiShellEnvironment2Guid;\r
971extern EFI_GUID gEfiShellEnvironment2ExtGuid;\r
b3011f40 972\r
973#endif // _SHELL_ENVIRONMENT_2_PROTOCOL_H_\r