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