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