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