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