]> git.proxmox.com Git - mirror_edk2.git/blame - ShellPkg/Include/Protocol/EfiShellEnvironment2.h
Refine comments and two code style.
[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
1e6e84c7 4 Copyright (c) 2005 - 2010, Intel Corporation. All rights reserved.<BR>\r
5 This program and the accompanying materials\r
b3011f40 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
1e6e84c7 15\r
a405b86d 16#ifndef _SHELL_ENVIRONMENT_2_PROTOCOL_H_\r
b3011f40 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
1e6e84c7 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
a405b86d 27 @param[in] Handle The handle the protocol is on.\r
28 @param[in] 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
1e6e84c7 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
a405b86d 43 @param[in] ImageHandle The handle to the binary shell.\r
44 @param[in] SystemTable The pointer to the system table.\r
94b17fa1 45\r
a405b86d 46 @retval EFI_SUCCESS The command completed.\r
47 @retval other An error occurred. Any error is possible\r
1e6e84c7 48 depending on the implementation of the shell\r
94b17fa1 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
1e6e84c7 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
94b17fa1 62 the memory allocated is up to the caller to free.\r
63\r
4ff7e37b 64 @param[in, out] 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
1e6e84c7 79 UINT32 Signature; ///< SHELL_FILE_ARG_SIGNATURE.\r
80 LIST_ENTRY Link; ///< Linked list helper.\r
81 EFI_STATUS Status; ///< File's status.\r
94b17fa1 82\r
1e6e84c7 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
86 EFI_DEVICE_PATH_PROTOCOL *ParentDevicePath; ///< DevicePath for Parent.\r
94b17fa1 87\r
1e6e84c7 88 CHAR16 *FullName; ///< Path and file name for this file.\r
89 CHAR16 *FileName; ///< File name for this file.\r
94b17fa1 90\r
1e6e84c7 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
1e6e84c7 95/// Signature for SHELL_FILE_ARG.\r
96#define SHELL_FILE_ARG_SIGNATURE SIGNATURE_32 ('g', 'r', 'a', 'f')\r
94b17fa1 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
a405b86d 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
94b17fa1 116\r
117/**\r
1e6e84c7 118 Execute a command line.\r
94b17fa1 119\r
1e6e84c7 120 This function will run the CommandLine. This includes loading any required images,\r
121 parsing any requires scripts, and if DebugOutput is TRUE printing errors\r
94b17fa1 122 encountered directly to the screen.\r
1e6e84c7 123\r
a405b86d 124 @param[in] ParentImageHandle Handle of the image executing this operation.\r
125 @param[in] CommandLine The string command line to execute.\r
126 @param[in] DebugOutput TRUE indicates that errors should be printed directly.\r
94b17fa1 127 FALSE supresses error messages.\r
128\r
a31bd33c 129 @retval EFI_SUCCESS The command line executed and completed.\r
a405b86d 130 @retval EFI_ABORTED The operation aborted.\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
a405b86d 147 @param[in] Name The pointer to the string with the shell environment\r
b3011f40 148 variable name.\r
94b17fa1 149\r
b3011f40 150 @retval NULL The shell environment variable's value could not be found.\r
1e6e84c7 151 @retval !=NULL The value of the shell environment variable Name.\r
94b17fa1 152\r
153**/\r
1e6e84c7 154typedef\r
155CHAR16 *\r
94b17fa1 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
a405b86d 163 @param[in] Name The pointer to the string with the shell environment\r
b3011f40 164 map name.\r
94b17fa1 165\r
b3011f40 166 @retval NULL The shell environment map's value could not be found.\r
1e6e84c7 167 @retval !=NULL The value of the shell environment map Name.\r
94b17fa1 168\r
169**/\r
1e6e84c7 170typedef\r
171CHAR16 *\r
94b17fa1 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
a405b86d 182 @param[in] Handler The handler function to call when the command gets called.\r
183 @param[in] Cmd The command name.\r
184 @param[in] GetLineHelp The function to call of type "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
a405b86d 206 @param[in] Protocol The pointer to the protocol's GUID.\r
207 @param[in] DumpToken The function pointer to dump token function or\r
b3011f40 208 NULL.\r
a405b86d 209 @param[in] DumpInfo The function pointer to dump infomation function\r
b3011f40 210 or NULL.\r
a405b86d 211 @param[in] IdString The English name of the protocol.\r
94b17fa1 212**/\r
213typedef\r
214VOID\r
215(EFIAPI *SHELLENV_ADD_PROT) (\r
216 IN EFI_GUID *Protocol,\r
217 IN SHELLENV_DUMP_PROTOCOL_INFO DumpToken OPTIONAL,\r
218 IN SHELLENV_DUMP_PROTOCOL_INFO DumpInfo OPTIONAL,\r
219 IN CHAR16 *IdString\r
220 );\r
221\r
222/**\r
1e6e84c7 223 This function finds a protocol handle by a GUID.\r
94b17fa1 224\r
1e6e84c7 225 This function will check for already known protocols by GUID and if one is\r
226 found it will return the name of that protocol. If no name is found and\r
94b17fa1 227 GenId is TRUE it will generate ths string.\r
228\r
a405b86d 229 @param[in] Protocol The GUID of the protocol to look for.\r
230 @param[in] GenId Whether to generate a name string if it is not found.\r
94b17fa1 231\r
a405b86d 232 @return !NULL The Name of the protocol.\r
233 @retval NULL The Name was not found, and GenId was not TRUE.\r
94b17fa1 234**/\r
1e6e84c7 235typedef\r
94b17fa1 236CHAR16*\r
237(EFIAPI *SHELLENV_GET_PROT) (\r
1e6e84c7 238 IN EFI_GUID *Protocol,\r
94b17fa1 239 IN BOOLEAN GenId\r
240 );\r
241\r
242/**\r
1e6e84c7 243 This function returns a string array containing the current directory on\r
244 a given device.\r
94b17fa1 245\r
1e6e84c7 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
94b17fa1 248 current device. The caller us responsible to free the returned string when\r
a405b86d 249 no longer required.\r
94b17fa1 250\r
a405b86d 251 @param[in] DeviceName The name of the device to get the current\r
252 directory on, or NULL for current device.\r
94b17fa1 253\r
1e6e84c7 254 @return String array with the current directory on the current or specified device.\r
94b17fa1 255\r
256**/\r
1e6e84c7 257typedef\r
94b17fa1 258CHAR16*\r
259(EFIAPI *SHELLENV_CUR_DIR) (\r
260 IN CHAR16 *DeviceName OPTIONAL\r
261 );\r
262\r
263/**\r
1e6e84c7 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
1e6e84c7 267 that match the wildcards. It returns 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
1e6e84c7 270 The memory allocated by the callee for this list is freed by making a call to\r
94b17fa1 271 SHELLENV_FREE_FILE_LIST.\r
272\r
4ff7e37b
ED
273 @param[in] Arg The pointer Path to files to open.\r
274 @param[in, out] ListHead The pointer to the allocated and initialized list head\r
275 upon which to append all opened file structures.\r
94b17fa1 276\r
a405b86d 277 @retval EFI_SUCCESS One or more files was opened and a struct of each file's\r
94b17fa1 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
4ff7e37b 292 @param[in, out] ListHead Pointer to list to free all nodes of.\r
94b17fa1 293\r
a405b86d 294 @retval EFI_SUCCESS This function always returns EFI_SUCCESS.\r
94b17fa1 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
1e6e84c7 303 This function creates a new instance of the ShellInterface protocol for use on\r
94b17fa1 304 the ImageHandle.\r
305\r
1e6e84c7 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
a405b86d 310 @param[in] ImageHandle The handle which will use the new ShellInterface\r
94b17fa1 311 protocol.\r
312\r
a405b86d 313 @return The newly allocated shell interface protocol.\r
94b17fa1 314\r
315**/\r
1e6e84c7 316typedef\r
317EFI_SHELL_INTERFACE*\r
94b17fa1 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
1e6e84c7 325 A script file (.nsh file) can contain a series of commands and this is useful to\r
326 know for some shell commands whether they are being run manually or as part of a\r
94b17fa1 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
a405b86d 335 VOID\r
94b17fa1 336 );\r
337\r
338/**\r
1e6e84c7 339 This is an internal shell function to free any and all allocated resources.\r
a405b86d 340 This should be called immediately prior to closing the shell.\r
94b17fa1 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
1e6e84c7 351 This mode causes the output to pause after each complete screen to enable a\r
a405b86d 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
a405b86d 356 @param[in] StartRow The row number to start this on.\r
357 @param[in] 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
a405b86d 369 Disabling 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
a405b86d 375 VOID\r
94b17fa1 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
a405b86d 387 VOID\r
94b17fa1 388 );\r
389\r
390/**\r
1e6e84c7 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
a405b86d 398 @param[in] KeyFilter The new key filter to use.\r
94b17fa1 399**/\r
400typedef\r
401VOID\r
402(EFIAPI *SHELLENV_SET_KEY_FILTER) (\r
403 IN UINT32 KeyFilter\r
404 );\r
405\r
406/**\r
1e6e84c7 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
a405b86d 414 @retval The current filter mask.\r
94b17fa1 415**/\r
416typedef\r
417UINT32\r
418(EFIAPI *SHELLENV_GET_KEY_FILTER) (\r
a405b86d 419 VOID\r
94b17fa1 420 );\r
421\r
422/**\r
b3011f40 423 This function determins if the shell application should break.\r
94b17fa1 424\r
1e6e84c7 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
a405b86d 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
a405b86d 435 VOID\r
94b17fa1 436 );\r
437\r
438/**\r
a405b86d 439 This is an internal shell function used to increment the shell nesting level.\r
94b17fa1 440\r
441**/\r
442typedef\r
443VOID\r
444(EFIAPI *SHELLENV_INCREMENT_SHELL_NESTING_LEVEL) (\r
a405b86d 445 VOID\r
94b17fa1 446 );\r
447\r
448/**\r
a405b86d 449 This is an internal shell function used to decrement the shell nesting level.\r
94b17fa1 450**/\r
451typedef\r
452VOID\r
453(EFIAPI *SHELLENV_DECREMENT_SHELL_NESTING_LEVEL) (\r
a405b86d 454 VOID\r
94b17fa1 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
a405b86d 467 VOID\r
94b17fa1 468 );\r
469\r
470/**\r
471 Close the console proxy to restore the original console.\r
472\r
1e6e84c7 473 This is an internal shell function to handle shell cascading. It restores the\r
94b17fa1 474 original set of console protocols.\r
1e6e84c7 475\r
4ff7e37b
ED
476 @param[in] ConInHandle The handle of ConIn.\r
477 @param[in, out] ConIn The pointer to the location to return the pointer to\r
478 the original console input.\r
479 @param[in] ConOutHandle The handle of ConOut\r
480 @param[in, out] ConOut The pointer to the location to return the pointer to\r
481 the original console output.\r
94b17fa1 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
1e6e84c7 497 This is only done on request for various internal commands and the references\r
94b17fa1 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
1e6e84c7 509 This function gets the next handle in the handle database. If no handles are\r
a405b86d 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
4ff7e37b
ED
515 @param[in, out] Handle The pointer to pointer to Handle. It is set\r
516 on a sucessful return.\r
94b17fa1 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
1e6e84c7 530 This function skips the next SkipNum handles in the handle database. If there\r
531 are not enough handles left to skip that many EFI_ACCESS_DENIED is returned and\r
94b17fa1 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
a405b86d 536 @param[in] SkipNum How many handles to skip\r
94b17fa1 537\r
a405b86d 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
94b17fa1 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
1e6e84c7 550 This function resets the the handle database so that NEXT_HANDLE and SKIP_HANDLE\r
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
a405b86d 555 @param[in] EnumIndex Where to start.\r
94b17fa1 556\r
a405b86d 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
1e6e84c7 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
a405b86d 571 After 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
1e6e84c7 584\r
b3011f40 585 This must be called after INIT_HANDLE_ENUMERATOR and before CLOSE_HANDLE_ENUMERATOR.\r
94b17fa1 586\r
a405b86d 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
a405b86d 599 INIT_HANDLE_ENUMERATOR Init; ///< The pointer to INIT_HANDLE_ENUMERATOR function.\r
600 NEXT_HANDLE Next; ///< The pointer to NEXT_HANDLE function.\r
601 SKIP_HANDLE Skip; ///< The pointer to SKIP_HANDLE function.\r
602 RESET_HANDLE_ENUMERATOR Reset; ///< The pointer to RESET_HANDLE_ENUMERATOR function.\r
603 CLOSE_HANDLE_ENUMERATOR Close; ///< The pointer to CLOSE_HANDLE_ENUMERATOR function.\r
604 GET_NUM GetNum; ///< The 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
a405b86d 617 LIST_ENTRY Link; ///< Standard linked list helper member.\r
94b17fa1 618 //\r
b3011f40 619 // The parsing info for the protocol.\r
94b17fa1 620 //\r
a405b86d 621 EFI_GUID ProtocolId; ///< The GUID for the protocol.\r
622 CHAR16 *IdString; ///< The name of the protocol.\r
623 SHELLENV_DUMP_PROTOCOL_INFO DumpToken; ///< The pointer to DumpToken function for the protocol.\r
624 SHELLENV_DUMP_PROTOCOL_INFO DumpInfo; ///< The 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
a405b86d 628 UINTN NoHandles; ///< The number of handles producing this protocol.\r
b3011f40 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
1e6e84c7 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
1e6e84c7 650 This function is an internal shell function for enumeration of protocols.\r
94b17fa1 651\r
a405b86d 652 This function returns the next protocol on the list. If this is called\r
653 immediately after initialization, it will return the first protocol on the list.\r
654 If this is called immediately after reset, it will return the first protocol again.\r
94b17fa1 655\r
1e6e84c7 656 This cannot be called after CLOSE_PROTOCOL_INFO_ENUMERATOR, but it must be\r
94b17fa1 657 called after INIT_PROTOCOL_INFO_ENUMERATOR.\r
658\r
4ff7e37b 659 @param[in, out] ProtocolInfo The 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
1e6e84c7 671 This function is an internal shell function for enumeration of protocols.\r
94b17fa1 672\r
1e6e84c7 673 This cannot be called after CLOSE_PROTOCOL_INFO_ENUMERATOR, but it must be\r
94b17fa1 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
a405b86d 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
1e6e84c7 687 This function is an internal shell function for enumeration of protocols.\r
94b17fa1 688\r
1e6e84c7 689 This cannot be called after CLOSE_PROTOCOL_INFO_ENUMERATOR, but it must be\r
94b17fa1 690 called after INIT_PROTOCOL_INFO_ENUMERATOR.\r
691\r
1e6e84c7 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
1e6e84c7 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
a405b86d 721 INIT_PROTOCOL_INFO_ENUMERATOR Init; ///< The pointer to INIT_PROTOCOL_INFO_ENUMERATOR function.\r
722 NEXT_PROTOCOL_INFO Next; ///< The pointer to NEXT_PROTOCOL_INFO function.\r
723 SKIP_PROTOCOL_INFO Skip; ///< The pointer to SKIP_PROTOCOL_INFO function.\r
724 RESET_PROTOCOL_INFO_ENUMERATOR Reset; ///< The pointer to RESET_PROTOCOL_INFO_ENUMERATOR function.\r
725 CLOSE_PROTOCOL_INFO_ENUMERATOR Close; ///< The pointer to CLOSE_PROTOCOL_INFO_ENUMERATOR function.\r
94b17fa1 726} PROTOCOL_INFO_ENUMERATOR;\r
727\r
728/**\r
1e6e84c7 729 This function is used to retrieve a user-friendly display name for a handle.\r
94b17fa1 730\r
1e6e84c7 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
94b17fa1 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
1e6e84c7 735 and device path if that fails.\r
94b17fa1 736\r
1e6e84c7 737 It will use either ComponentName or ComponentName2 protocol, depending on\r
94b17fa1 738 what is present.\r
739\r
740 This function will furthur verify whether the handle in question produced either\r
1e6e84c7 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
94b17fa1 743 EFI_DRIVER_DIAGNOSTICS2_PROTOCOL.\r
1e6e84c7 744\r
a405b86d 745 Upon successful return, the memory for *BestDeviceName is up to the caller to free.\r
94b17fa1 746\r
4ff7e37b
ED
747 @param[in] DeviceHandle The device handle whose name is desired.\r
748 @param[in] UseComponentName Whether to use the ComponentName protocol at all.\r
749 @param[in] UseDevicePath Whether to use the DevicePath protocol at all.\r
750 @param[in] Language The pointer to the language string to use.\r
751 @param[in, out] BestDeviceName The pointer to pointer to string allocated with the name.\r
752 @param[out] ConfigurationStatus The pointer to status for opening a Configuration protocol.\r
753 @param[out] DiagnosticsStatus The pointer to status for opening a Diagnostics protocol.\r
754 @param[in] Display Whether to Print this out to default Print location.\r
755 @param[in] 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
a405b86d 762 IN EFI_HANDLE DeviceHandle,\r
763 IN BOOLEAN UseComponentName,\r
764 IN BOOLEAN UseDevicePath,\r
765 IN CHAR8 *Language,\r
766 IN OUT CHAR16 **BestDeviceName,\r
767 OUT EFI_STATUS *ConfigurationStatus,\r
768 OUT EFI_STATUS *DiagnosticsStatus,\r
769 IN BOOLEAN Display,\r
770 IN UINTN Indent\r
94b17fa1 771 );\r
772\r
a405b86d 773#define EFI_SHELL_COMPATIBLE_MODE_VER L"1.1.1" ///< The string for lowest version this shell supports.\r
774#define EFI_SHELL_ENHANCED_MODE_VER L"1.1.2" ///< The string for highest version this shell supports.\r
94b17fa1 775\r
776/**\r
1e6e84c7 777 This function gets the shell mode as stored in the shell environment\r
b3011f40 778 "efishellmode". It will not fail.\r
94b17fa1 779\r
a405b86d 780 @param[out] 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
1e6e84c7 795 This function will allocate any required memory for this operation and it\r
94b17fa1 796 is the responsibility of the caller to free that memory when no longer required.\r
797\r
1e6e84c7 798 If anything prevents the complete conversion free any allocated memory and\r
94b17fa1 799 return NULL.\r
800\r
a405b86d 801 @param[in] Path The path to convert.\r
802\r
b3011f40 803 @retval !NULL A pointer to the callee allocated Device Path.\r
804 @retval NULL The operation could not be completed.\r
94b17fa1 805**/\r
1e6e84c7 806typedef\r
807EFI_DEVICE_PATH_PROTOCOL*\r
94b17fa1 808(EFIAPI *SHELLENV_NAME_TO_PATH) (\r
809 IN CHAR16 *Path\r
810 );\r
811\r
812/**\r
b3011f40 813 Converts a device path into a file system map name.\r
814\r
815 If DevPath is NULL, then ASSERT.\r
94b17fa1 816\r
94b17fa1 817 This function looks through the shell environment map for a map whose device\r
1e6e84c7 818 path matches the DevPath parameter. If one is found the Name is returned via\r
94b17fa1 819 Name parameter. If sucessful the caller must free the memory allocated for\r
820 Name.\r
821\r
1e6e84c7 822 This function will use the internal lock to prevent changes to the map during\r
94b17fa1 823 the lookup operation.\r
1e6e84c7 824\r
a405b86d 825 @param[in] DevPath The device path to search for a name for.\r
826 @param[in] ConsistMapping What state to verify map flag VAR_ID_CONSIST.\r
827 @param[out] Name On sucessful return the name of that device path.\r
94b17fa1 828\r
b3011f40 829 @retval EFI_SUCCESS The DevPath was found and the name returned\r
1e6e84c7 830 in Name.\r
94b17fa1 831 @retval EFI_OUT_OF_RESOURCES A required memory allocation failed.\r
b3011f40 832 @retval EFI_UNSUPPORTED The DevPath was not found in the map.\r
94b17fa1 833**/\r
834typedef\r
835EFI_STATUS\r
836(EFIAPI *SHELLENV_GET_FS_NAME) (\r
837 IN EFI_DEVICE_PATH_PROTOCOL * DevPath,\r
838 IN BOOLEAN ConsistMapping,\r
839 OUT CHAR16 **Name\r
840 );\r
841\r
842/**\r
1e6e84c7 843 This function will open a group of files that match the Arg path, but will not\r
844 support the wildcard characters ('?' and '*') in the Arg path. If there are\r
845 any wildcard characters in the path this function will return\r
846 EFI_INVALID_PARAMETER. The return is a double linked list based on the\r
847 LIST_ENTRY linked list structure. Use this in conjunction with the\r
94b17fa1 848 SHELL_FILE_ARG_SIGNATURE to get the SHELL_FILE_ARG structures that are returned.\r
1e6e84c7 849 The memory allocated by the callee for this list is freed by making a call to\r
94b17fa1 850 SHELLENV_FREE_FILE_LIST.\r
851\r
4ff7e37b
ED
852 @param[in] Arg The pointer to the path of the files to be opened.\r
853 @param[in, out] ListHead The pointer to allocated and initialized list head\r
854 upon which to append all the opened file structures.\r
94b17fa1 855\r
a405b86d 856 @retval EFI_SUCCESS One or more files was opened and a struct of each file's\r
94b17fa1 857 information was appended to ListHead.\r
b3011f40 858 @retval EFI_OUT_OF_RESOURCES A memory allocation failed.\r
859 @retval EFI_NOT_FOUND No matching files could be found.\r
94b17fa1 860 @sa SHELLENV_FREE_FILE_LIST\r
861**/\r
862typedef\r
863EFI_STATUS\r
864(EFIAPI *SHELLENV_FILE_META_ARG_NO_WILDCARD) (\r
865 IN CHAR16 *Arg,\r
d2b4564b 866 IN OUT LIST_ENTRY *ListHead\r
94b17fa1 867 );\r
868\r
869/**\r
b3011f40 870 This function removes duplicate file listings from lists.\r
94b17fa1 871\r
1e6e84c7 872 This is a function for use with SHELLENV_FILE_META_ARG_NO_WILDCARD and\r
b3011f40 873 SHELLENV_FILE_META_ARG. This function will verify that there are no duplicate\r
874 files in the list of returned files. Any file listed twice will have one of its\r
94b17fa1 875 instances removed.\r
876\r
a405b86d 877 @param[in] ListHead The pointer to linked list head that was returned from\r
94b17fa1 878 SHELLENV_FILE_META_ARG_NO_WILDCARD or\r
879 SHELLENV_FILE_META_ARG.\r
880\r
b3011f40 881 @retval EFI_SUCCESS This function always returns success.\r
94b17fa1 882\r
883**/\r
884typedef\r
885EFI_STATUS\r
886(EFIAPI *SHELLENV_DEL_DUP_FILE) (\r
d2b4564b 887 IN LIST_ENTRY * ListHead\r
94b17fa1 888 );\r
889\r
890/**\r
891 Converts a File System map name to a device path.\r
892\r
a405b86d 893 If DevPath is NULL, then ASSERT().\r
94b17fa1 894\r
1e6e84c7 895 This function looks through the shell environment map for a map whose Name\r
a405b86d 896 matches the Name parameter. If one is found, the device path pointer is\r
1e6e84c7 897 updated to point to that file systems device path. The caller should not\r
94b17fa1 898 free the memory from that device path.\r
899\r
1e6e84c7 900 This function will use the internal lock to prevent changes to the map during\r
94b17fa1 901 the lookup operation.\r
902\r
a405b86d 903 @param[in] Name The pointer to the NULL terminated UNICODE string of the\r
b3011f40 904 file system name.\r
a405b86d 905 @param[out] DevPath The pointer to pointer to DevicePath. Only valid on\r
906 successful return.\r
94b17fa1 907\r
a405b86d 908 @retval EFI_SUCCESS The conversion was successful, and the device\r
94b17fa1 909 path was returned.\r
b3011f40 910 @retval EFI_NOT_FOUND The file system could not be found in the map.\r
94b17fa1 911**/\r
912typedef\r
913EFI_STATUS\r
914(EFIAPI *SHELLENV_GET_FS_DEVICE_PATH) (\r
915 IN CHAR16 *Name,\r
916 OUT EFI_DEVICE_PATH_PROTOCOL **DevPath\r
917 );\r
918\r
b3011f40 919/// EFI_SHELL_ENVIRONMENT2 protocol structure.\r
94b17fa1 920typedef struct {\r
921 SHELLENV_EXECUTE Execute;\r
922 SHELLENV_GET_ENV GetEnv;\r
923 SHELLENV_GET_MAP GetMap;\r
924 SHELLENV_ADD_CMD AddCmd;\r
925 SHELLENV_ADD_PROT AddProt;\r
926 SHELLENV_GET_PROT GetProt;\r
927 SHELLENV_CUR_DIR CurDir;\r
928 SHELLENV_FILE_META_ARG FileMetaArg;\r
929 SHELLENV_FREE_FILE_LIST FreeFileList;\r
930\r
931 //\r
b3011f40 932 // The following services are only used by the shell itself.\r
94b17fa1 933 //\r
934 SHELLENV_NEW_SHELL NewShell;\r
935 SHELLENV_BATCH_IS_ACTIVE BatchIsActive;\r
936\r
937 SHELLENV_FREE_RESOURCES FreeResources;\r
938\r
939 //\r
b3011f40 940 // GUID to differentiate ShellEnvironment2 from ShellEnvironment.\r
94b17fa1 941 //\r
942 EFI_GUID SESGuid;\r
943 //\r
b3011f40 944 // Major Version grows if shell environment interface has been changes.\r
94b17fa1 945 //\r
946 UINT32 MajorVersion;\r
947 UINT32 MinorVersion;\r
948 SHELLENV_ENABLE_PAGE_BREAK EnablePageBreak;\r
949 SHELLENV_DISABLE_PAGE_BREAK DisablePageBreak;\r
950 SHELLENV_GET_PAGE_BREAK GetPageBreak;\r
951\r
952 SHELLENV_SET_KEY_FILTER SetKeyFilter;\r
953 SHELLENV_GET_KEY_FILTER GetKeyFilter;\r
954\r
955 SHELLENV_GET_EXECUTION_BREAK GetExecutionBreak;\r
956 SHELLENV_INCREMENT_SHELL_NESTING_LEVEL IncrementShellNestingLevel;\r
957 SHELLENV_DECREMENT_SHELL_NESTING_LEVEL DecrementShellNestingLevel;\r
958 SHELLENV_IS_ROOT_SHELL IsRootShell;\r
959\r
960 SHELLENV_CLOSE_CONSOLE_PROXY CloseConsoleProxy;\r
961 HANDLE_ENUMERATOR HandleEnumerator;\r
962 PROTOCOL_INFO_ENUMERATOR ProtocolInfoEnumerator;\r
963 GET_DEVICE_NAME GetDeviceName;\r
964 GET_SHELL_MODE GetShellMode;\r
965 SHELLENV_NAME_TO_PATH NameToPath;\r
966 SHELLENV_GET_FS_NAME GetFsName;\r
967 SHELLENV_FILE_META_ARG_NO_WILDCARD FileMetaArgNoWildCard;\r
968 SHELLENV_DEL_DUP_FILE DelDupFileArg;\r
969 SHELLENV_GET_FS_DEVICE_PATH GetFsDevicePath;\r
970} EFI_SHELL_ENVIRONMENT2;\r
971\r
972extern EFI_GUID gEfiShellEnvironment2Guid;\r
973extern EFI_GUID gEfiShellEnvironment2ExtGuid;\r
b3011f40 974\r
975#endif // _SHELL_ENVIRONMENT_2_PROTOCOL_H_\r