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