c0901ea45b0ade79c1431475cc0d1722c4e6e408
[efi/shell/.git] / drvcfg / drvcfg.c
1 /*++
2  
3 Copyright (c) 2005 - 2009, Intel Corporation                                                         
4 All rights reserved. This program and the accompanying materials                          
5 are licensed and made available under the terms and conditions of the BSD License         
6 which accompanies this distribution. The full text of the license may be found at         
7 http://opensource.org/licenses/bsd-license.php                                            
8                                                                                           
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,                     
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.             
11
12 Module Name:
13
14   drvcfg.c
15   
16 Abstract:
17
18   Shell command "drvcfg"
19
20
21
22 Revision History
23
24 --*/
25
26 #include "EfiShellLib.h"
27 #include "drvcfg.h"
28
29 #include EFI_PROTOCOL_DEFINITION (DriverConfiguration)
30
31 extern UINT8  STRING_ARRAY_NAME[];
32
33 //
34 // This is the generated header file which includes whatever needs to be exported (strings + IFR)
35 //
36 #include STRING_DEFINES_FILE
37
38 //
39 // Global Variables
40 //
41 EFI_HII_HANDLE  HiiHandle;
42 EFI_GUID        EfiDrvcfgGuid = EFI_DRVCFG_GUID;
43 SHELL_VAR_CHECK_ITEM  DrvcfgCheckList[] = {
44   {
45     L"-l",
46     0x01,
47     0x40,
48     FlagTypeNeedVar
49   },
50   {
51     L"-c",
52     0x02,
53     0x40,
54     FlagTypeSingle
55   },
56   {
57     L"-f",
58     0x04,
59     0x58,
60     FlagTypeNeedVar
61   },
62   {
63     L"-v",
64     0x08,
65     0x54,
66     FlagTypeSingle
67   },
68   {
69     L"-s",
70     0x10,
71     0x4c,
72     FlagTypeSingle
73   },
74   {
75     L"-b",
76     0x20,
77     0,
78     FlagTypeSingle
79   },
80   {
81     L"-?",
82     0x40,
83     0x1f,
84     FlagTypeSingle
85   },
86   {
87     NULL,
88     0,
89     0,
90     0
91   }
92 };
93
94 EFI_STATUS
95 ShellCmdDriverConfigurationProcessActionRequired (
96   EFI_HANDLE                                DriverImageHandle,
97   EFI_HANDLE                                ControllerHandle,
98   EFI_HANDLE                                ChildHandle,
99   EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED  ActionRequired
100   );
101
102 EFI_BOOTSHELL_CODE(
103   EFI_APPLICATION_ENTRY_POINT(DrvcfgMain)
104 )
105
106 EFI_STATUS
107 SEnvCmdDriverConfiguration (
108   IN EFI_HANDLE               ImageHandle,
109   IN EFI_SYSTEM_TABLE         *SystemTable
110   );
111
112 EFI_STATUS
113 EFIAPI
114 DrvcfgMain (
115   IN EFI_HANDLE               ImageHandle,
116   IN EFI_SYSTEM_TABLE         *SystemTable
117   )
118 /*++
119
120 Routine Description:
121
122   Code for external shell "drvcfg" command.
123
124 Arguments:
125
126   ImageHandle - The image handle
127   SystemTable - The system table
128
129 Returns:
130
131 --*/
132 {
133   EFI_STATUS                                Status;
134   UINTN                                     HandleNumber;
135   EFI_HANDLE                                DriverImageHandle;
136   EFI_HANDLE                                DeviceHandle;
137   EFI_HANDLE                                ChildHandle;
138   UINTN                                     Index;
139   CHAR8                                     *Language;
140   CHAR8                                     *BestLanguage;
141   UINTN                                     DriverImageHandleCount;
142   EFI_HANDLE                                *DriverImageHandleBuffer;
143   UINTN                                     HandleCount;
144   EFI_HANDLE                                *HandleBuffer;
145   UINT32                                    *HandleType;
146   UINTN                                     HandleIndex;
147   UINTN                                     ChildIndex;
148   UINTN                                     ChildHandleCount;
149   EFI_HANDLE                                *ChildHandleBuffer;
150   UINT32                                    *ChildHandleType;
151   EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED  ActionRequired;
152   EFI_DRIVER_CONFIGURATION_PROTOCOL         *DriverConfiguration;
153   BOOLEAN                                   ForceDefaults;
154   UINT32                                    DefaultType;
155   BOOLEAN                                   ValidateOptions;
156   BOOLEAN                                   SetOptions;
157   BOOLEAN                                   AllChildren;
158   SHELL_VAR_CHECK_CODE                      RetCode;
159   CHAR16                                    *Useful;
160   SHELL_ARG_LIST                            *Item;
161   SHELL_VAR_CHECK_PACKAGE                   ChkPck;
162   BOOLEAN                                   Iso639Language;
163
164   Language                = NULL;
165   DriverImageHandle       = NULL;
166   DeviceHandle            = NULL;
167   ChildHandle             = NULL;
168   ForceDefaults           = FALSE;
169   DefaultType             = 0;
170   ValidateOptions         = FALSE;
171   SetOptions              = FALSE;
172   AllChildren             = FALSE;
173   DriverImageHandleCount  = 0;
174   DriverImageHandleBuffer = NULL;
175   ZeroMem (&ChkPck, sizeof (SHELL_VAR_CHECK_PACKAGE));
176
177   EFI_SHELL_APP_INIT (ImageHandle, SystemTable);
178
179   //
180   // Enable tab key which can pause the output
181   //
182   EnableOutputTabPause();
183   
184   Status = LibInitializeStrings (&HiiHandle, STRING_ARRAY_NAME, &EfiDrvcfgGuid);
185
186   if (EFI_ERROR (Status)) {
187     return Status;
188   }
189
190   if (!EFI_PROPER_VERSION (1, 10)) {
191     PrintToken (
192       STRING_TOKEN (STR_SHELLENV_GNC_COMMAND_NOT_SUPPORT),
193       HiiHandle,
194       L"drvcfg",
195       EFI_VERSION_1_10
196       );
197     Status = EFI_UNSUPPORTED;
198     goto Done;
199   }
200
201   ShellInitHandleEnumerator ();
202   ShellInitProtocolInfoEnumerator ();
203
204   if (IS_OLD_SHELL) {
205     Status = SEnvCmdDriverConfiguration (ImageHandle, SystemTable);
206     goto Done;
207   }
208
209   RetCode = LibCheckVariables (SI, DrvcfgCheckList, &ChkPck, &Useful);
210   if (VarCheckOk != RetCode) {
211     switch (RetCode) {
212     case VarCheckDuplicate:
213       PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_DUP_FLAG), HiiHandle, L"drvcfg", Useful);
214       break;
215
216     case VarCheckUnknown:
217       PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_UNKNOWN_FLAG), HiiHandle, L"drvcfg", Useful);
218       break;
219
220     case VarCheckLackValue:
221       PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_LACK_ARG), HiiHandle, L"drvcfg", Useful);
222       break;
223
224     case VarCheckConflict:
225       PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_FLAG_CONFLICT), HiiHandle, L"drvcfg", Useful);
226       break;
227
228     default:
229       break;
230     }
231
232     Status = EFI_INVALID_PARAMETER;
233     goto Done;
234   }
235   //
236   // Out put help.
237   //
238   if (LibCheckVarGetFlag (&ChkPck, L"-b") != NULL) {
239     EnablePageBreak (DEFAULT_INIT_ROW, DEFAULT_AUTO_LF);
240   }
241
242   if (LibCheckVarGetFlag (&ChkPck, L"-?") != NULL) {
243     if (ChkPck.ValueCount > 0 ||
244         ChkPck.FlagCount > 2 ||
245         (2 == ChkPck.FlagCount && !LibCheckVarGetFlag (&ChkPck, L"-b"))
246         ) {
247       PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_TOO_MANY), HiiHandle, L"drvcfg");
248       Status = EFI_INVALID_PARAMETER;
249     } else {
250       PrintToken (STRING_TOKEN (STR_DRVCFG_VERBOSE_HELP), HiiHandle);
251       Status = EFI_SUCCESS;
252     }
253
254     goto Done;
255   }
256   //
257   // Setup Handle and Protocol Globals
258   //
259   Item = LibCheckVarGetFlag (&ChkPck, L"-l");
260   if (Item) {
261     Language = LibGetCommandLineLanguage (Item->VarStr);
262   }
263
264   Item = LibCheckVarGetFlag (&ChkPck, L"-f");
265   if (Item) {
266     ForceDefaults = TRUE;
267     DefaultType   = (UINT32) (StrToUIntegerBase (Item->VarStr, 16, &Status));
268     if (EFI_ERROR (Status)) {
269       PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_INVALID_ARG), HiiHandle, L"drvcfg", Item->VarStr);
270       Status = EFI_INVALID_PARAMETER;
271       goto Done;
272     }
273   }
274
275   if (LibCheckVarGetFlag (&ChkPck, L"-c")) {
276     AllChildren = TRUE;
277   }
278
279   if (LibCheckVarGetFlag (&ChkPck, L"-v")) {
280     ValidateOptions = TRUE;
281   }
282
283   if (LibCheckVarGetFlag (&ChkPck, L"-s")) {
284     SetOptions = TRUE;
285   }
286
287   if (ChkPck.ValueCount > 3) {
288     PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_TOO_MANY), HiiHandle, L"drvcfg");
289     Status = EFI_INVALID_PARAMETER;
290     goto Done;
291   }
292
293   Item = ChkPck.VarList;
294   if (Item != NULL) {
295     HandleNumber = (UINTN) (StrToUIntegerBase (Item->VarStr, 16, &Status));
296     if (EFI_ERROR (Status)) {
297       PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_INVALID_ARG), HiiHandle, L"drvcfg", Item->VarStr);
298       Status = EFI_INVALID_PARAMETER;
299       goto Done;
300     }
301
302     DriverImageHandle = ShellHandleFromIndex (HandleNumber - 1);
303     if (DriverImageHandle == NULL) {
304       PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_INVALID_HANDLE_NUM), HiiHandle, L"drvcfg", Item->VarStr);
305       Status = EFI_INVALID_PARAMETER;
306       goto Done;
307     }
308
309     Item = Item->Next;
310   }
311
312   if (Item != NULL) {
313     HandleNumber = (UINTN) (StrToUIntegerBase (Item->VarStr, 16, &Status));
314     if (EFI_ERROR (Status)) {
315       PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_INVALID_ARG), HiiHandle, L"drvcfg", Item->VarStr);
316       Status = EFI_INVALID_PARAMETER;
317       goto Done;
318     }
319
320     DeviceHandle = ShellHandleFromIndex (HandleNumber - 1);
321     if (DeviceHandle == NULL) {
322       PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_INVALID_HANDLE_NUM), HiiHandle, L"drvcfg", Item->VarStr);
323       Status = EFI_INVALID_PARAMETER;
324       goto Done;
325     }
326
327     Item = Item->Next;
328   }
329
330   if (Item != NULL) {
331     HandleNumber = (UINTN) (StrToUIntegerBase (Item->VarStr, 16, &Status));
332     if (EFI_ERROR (Status)) {
333       PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_INVALID_ARG), HiiHandle, L"drvcfg", Item->VarStr);
334       Status = EFI_INVALID_PARAMETER;
335       goto Done;
336     }
337
338     ChildHandle = ShellHandleFromIndex (HandleNumber - 1);
339     if (ChildHandle == NULL) {
340       PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_INVALID_HANDLE_NUM), HiiHandle, L"drvcfg", Item->VarStr);
341       Status = EFI_INVALID_PARAMETER;
342       goto Done;
343     }
344   }
345
346   if (ChildHandle == NULL && AllChildren) {
347     SetOptions = FALSE;
348   }
349
350   if (ForceDefaults) {
351     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_FORCE_DEFAULT), HiiHandle, DefaultType);
352   } else if (ValidateOptions) {
353     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_VALIDATE_CONFIG_OPTIONS), HiiHandle);
354   } else if (SetOptions) {
355     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_SET_CONFIG_OPTIONS), HiiHandle);
356   } else {
357     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_CONFIGURABLE_COMPONENTS), HiiHandle);
358   }
359   //
360   // Display all handles that support being configured
361   //
362   if (DriverImageHandle == NULL) {
363     Status = LibLocateHandle (
364               ByProtocol,
365               &gEfiDriverConfiguration2ProtocolGuid,
366               NULL,
367               &DriverImageHandleCount,
368               &DriverImageHandleBuffer
369               );
370
371     if (EFI_ERROR (Status)) {
372       Status = LibLocateHandle (
373                 ByProtocol,
374                 &gEfiDriverConfigurationProtocolGuid,
375                 NULL,
376                 &DriverImageHandleCount,
377                 &DriverImageHandleBuffer
378                 );
379     }
380     if (EFI_ERROR (Status)) {
381       Status = EFI_NOT_FOUND;
382       goto Done;
383     }
384   } else {
385     DriverImageHandleCount = 1;
386     //
387     // Allocate buffer to hold the image handle so as to
388     // keep consistent with the above clause
389     //
390     DriverImageHandleBuffer = AllocatePool (sizeof (EFI_HANDLE));
391     ASSERT (DriverImageHandleBuffer);
392     DriverImageHandleBuffer[0] = DriverImageHandle;
393   }
394   //
395   // MARMAR:  We need to look at getting the component name exporters to support more than just LANGUAGE_CODE_ENGLISH
396   //
397   for (Index = 0; Index < DriverImageHandleCount; Index++) {
398     Iso639Language = FALSE;
399     Status = BS->OpenProtocol (
400                   DriverImageHandleBuffer[Index],
401                   &gEfiDriverConfiguration2ProtocolGuid,
402                   (VOID **) &DriverConfiguration,
403                   NULL,
404                   NULL,
405                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
406                   );
407     if (EFI_ERROR (Status)) {
408       Iso639Language = TRUE;
409       Status = BS->OpenProtocol (
410                     DriverImageHandleBuffer[Index],
411                     &gEfiDriverConfigurationProtocolGuid,
412                     (VOID **) &DriverConfiguration,
413                     NULL,
414                     NULL,
415                     EFI_OPEN_PROTOCOL_GET_PROTOCOL
416                     );
417     }
418     if (EFI_ERROR (Status)) {
419       PrintToken (
420         STRING_TOKEN (STR_SHELLENV_PROTID_DRVCFG_NOT_SUPPORT_PROT),
421         HiiHandle,
422         ShellHandleToIndex (DriverImageHandleBuffer[Index])
423         );
424       continue;
425     }
426
427     
428     BestLanguage = LibSelectBestLanguage (
429                           DriverConfiguration->SupportedLanguages,
430                           Iso639Language,
431                           Language
432                           );
433     if (BestLanguage == NULL) {
434       PrintToken (
435         STRING_TOKEN (STR_SHELLENV_PROTID_DRVCFG_HANDLE_NOT_SUPPORT_LANG),
436         HiiHandle,
437         ShellHandleToIndex (DriverImageHandleBuffer[Index]),
438         Language
439         );
440       continue;
441     }
442
443     Status = LibScanHandleDatabase (
444               DriverImageHandleBuffer[Index],
445               NULL,
446               NULL,
447               NULL,
448               &HandleCount,
449               &HandleBuffer,
450               &HandleType
451               );
452     if (EFI_ERROR (Status)) {
453       continue;
454     }
455
456     if (SetOptions && DeviceHandle == NULL) {
457
458       ST->ConOut->ClearScreen (ST->ConOut);
459       Status = DriverConfiguration->SetOptions (
460                                       DriverConfiguration,
461                                       NULL,
462                                       NULL,
463                                       BestLanguage,
464                                       &ActionRequired
465                                       );
466       ST->ConOut->ClearScreen (ST->ConOut);
467
468       PrintToken (
469         STRING_TOKEN (STR_SHELLENV_PROTID_DRV_ALL_LANG),
470         HiiHandle,
471         ShellHandleToIndex (DriverImageHandleBuffer[Index]),
472         DriverConfiguration->SupportedLanguages
473         );
474       if (!EFI_ERROR (Status)) {
475         PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_SET), HiiHandle);
476
477         for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
478
479           if ((HandleType[HandleIndex] & EFI_HANDLE_TYPE_CONTROLLER_HANDLE) == EFI_HANDLE_TYPE_CONTROLLER_HANDLE) {
480
481             ShellCmdDriverConfigurationProcessActionRequired (
482               DriverImageHandleBuffer[Index],
483               HandleBuffer[HandleIndex],
484               NULL,
485               ActionRequired
486               );
487
488           }
489         }
490
491       } else {
492         PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_NOT_SET), HiiHandle, Status);
493       }
494
495       continue;
496     }
497
498     for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
499
500       if ((HandleType[HandleIndex] & EFI_HANDLE_TYPE_CONTROLLER_HANDLE) != EFI_HANDLE_TYPE_CONTROLLER_HANDLE) {
501         continue;
502       }
503
504       if (DeviceHandle != NULL && DeviceHandle != HandleBuffer[HandleIndex]) {
505         continue;
506       }
507
508       if (ChildHandle == NULL) {
509         PrintToken (
510           STRING_TOKEN (STR_SHELLENV_PROTID_DRV_CTRL_LANG),
511           HiiHandle,
512           ShellHandleToIndex (DriverImageHandleBuffer[Index]),
513           ShellHandleToIndex (HandleBuffer[HandleIndex]),
514           DriverConfiguration->SupportedLanguages
515           );
516
517         if (ForceDefaults) {
518           Status = DriverConfiguration->ForceDefaults (
519                                           DriverConfiguration,
520                                           HandleBuffer[HandleIndex],
521                                           NULL,
522                                           DefaultType,
523                                           &ActionRequired
524                                           );
525
526           if (!EFI_ERROR (Status)) {
527             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_DEFAULTS_FORCED), HiiHandle);
528
529             ShellCmdDriverConfigurationProcessActionRequired (
530               DriverImageHandleBuffer[Index],
531               HandleBuffer[HandleIndex],
532               NULL,
533               ActionRequired
534               );
535           } else {
536             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_DEFAULTS_FORCE_FAILED), HiiHandle, Status);
537           }
538         } else if (ValidateOptions) {
539           Status = DriverConfiguration->OptionsValid (
540                                           DriverConfiguration,
541                                           HandleBuffer[HandleIndex],
542                                           NULL
543                                           );
544
545           if (!EFI_ERROR (Status)) {
546             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_VALID), HiiHandle);
547           } else {
548             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_NOT_VALID), HiiHandle, Status);
549           }
550         } else if (SetOptions) {
551           ST->ConOut->ClearScreen (ST->ConOut);
552           Status = DriverConfiguration->SetOptions (
553                                           DriverConfiguration,
554                                           HandleBuffer[HandleIndex],
555                                           NULL,
556                                           BestLanguage,
557                                           &ActionRequired
558                                           );
559           ST->ConOut->ClearScreen (ST->ConOut);
560           PrintToken (
561             STRING_TOKEN (STR_SHELLENV_PROTID_DRV_CTRL_LANG),
562             HiiHandle,
563             ShellHandleToIndex (DriverImageHandleBuffer[Index]),
564             ShellHandleToIndex (HandleBuffer[HandleIndex]),
565             DriverConfiguration->SupportedLanguages
566             );
567           if (!EFI_ERROR (Status)) {
568             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_SET), HiiHandle);
569
570             ShellCmdDriverConfigurationProcessActionRequired (
571               DriverImageHandleBuffer[Index],
572               HandleBuffer[HandleIndex],
573               NULL,
574               ActionRequired
575               );
576
577           } else {
578             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_NOT_SET), HiiHandle, Status);
579           }
580         } else {
581           Print (L"\n");
582         }
583       }
584
585       if (ChildHandle == NULL && !AllChildren) {
586         continue;
587       }
588
589       Status = LibScanHandleDatabase (
590                 DriverImageHandleBuffer[Index],
591                 NULL,
592                 HandleBuffer[HandleIndex],
593                 NULL,
594                 &ChildHandleCount,
595                 &ChildHandleBuffer,
596                 &ChildHandleType
597                 );
598       if (EFI_ERROR (Status)) {
599         continue;
600       }
601
602       for (ChildIndex = 0; ChildIndex < ChildHandleCount; ChildIndex++) {
603
604         if ((ChildHandleType[ChildIndex] & EFI_HANDLE_TYPE_CHILD_HANDLE) != EFI_HANDLE_TYPE_CHILD_HANDLE) {
605           continue;
606         }
607
608         if (ChildHandle != NULL && ChildHandle != ChildHandleBuffer[ChildIndex]) {
609           continue;
610         }
611
612         PrintToken (
613           STRING_TOKEN (STR_SHELLENV_PROTID_DRV_CTRL_CHILD_LANG),
614           HiiHandle,
615           ShellHandleToIndex (DriverImageHandleBuffer[Index]),
616           ShellHandleToIndex (HandleBuffer[HandleIndex]),
617           ShellHandleToIndex (ChildHandleBuffer[ChildIndex]),
618           DriverConfiguration->SupportedLanguages
619           );
620
621         if (ForceDefaults) {
622           Status = DriverConfiguration->ForceDefaults (
623                                           DriverConfiguration,
624                                           HandleBuffer[HandleIndex],
625                                           ChildHandleBuffer[ChildIndex],
626                                           DefaultType,
627                                           &ActionRequired
628                                           );
629
630           if (!EFI_ERROR (Status)) {
631             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_DEFAULTS_FORCED), HiiHandle);
632
633             ShellCmdDriverConfigurationProcessActionRequired (
634               DriverImageHandleBuffer[Index],
635               HandleBuffer[HandleIndex],
636               ChildHandleBuffer[ChildIndex],
637               ActionRequired
638               );
639
640           } else {
641             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_FORCE_DEFAULTS_FAILED), HiiHandle, Status);
642           }
643         } else if (ValidateOptions) {
644           Status = DriverConfiguration->OptionsValid (
645                                           DriverConfiguration,
646                                           HandleBuffer[HandleIndex],
647                                           ChildHandleBuffer[ChildIndex]
648                                           );
649
650           if (!EFI_ERROR (Status)) {
651             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_VALID), HiiHandle);
652           } else {
653             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_NOT_VALID), HiiHandle, Status);
654           }
655         } else if (SetOptions) {
656           ST->ConOut->ClearScreen (ST->ConOut);
657           Status = DriverConfiguration->SetOptions (
658                                           DriverConfiguration,
659                                           HandleBuffer[HandleIndex],
660                                           ChildHandleBuffer[ChildIndex],
661                                           BestLanguage,
662                                           &ActionRequired
663                                           );
664           ST->ConOut->ClearScreen (ST->ConOut);
665           PrintToken (
666             STRING_TOKEN (STR_SHELLENV_PROTID_DRV_CTRL_CHILD_LANG),
667             HiiHandle,
668             ShellHandleToIndex (DriverImageHandleBuffer[Index]),
669             ShellHandleToIndex (HandleBuffer[HandleIndex]),
670             ShellHandleToIndex (ChildHandleBuffer[ChildIndex]),
671             DriverConfiguration->SupportedLanguages
672             );
673           if (!EFI_ERROR (Status)) {
674             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_SET), HiiHandle);
675
676             ShellCmdDriverConfigurationProcessActionRequired (
677               DriverImageHandleBuffer[Index],
678               HandleBuffer[HandleIndex],
679               ChildHandleBuffer[ChildIndex],
680               ActionRequired
681               );
682
683           } else {
684             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_NOT_SET), HiiHandle, Status);
685           }
686         } else {
687           Print (L"\n");
688         }
689       }
690
691       FreePool (ChildHandleBuffer);
692       FreePool (ChildHandleType);
693     }
694
695     FreePool (BestLanguage);
696     FreePool (HandleBuffer);
697     FreePool (HandleType);
698   }
699
700   Status = EFI_SUCCESS;
701 Done:
702   if (DriverImageHandle != NULL && DriverImageHandleCount != 0) {
703     FreePool (DriverImageHandleBuffer);
704   }
705
706   if (Language != NULL) {
707     FreePool (Language);
708   }
709
710   ShellCloseProtocolInfoEnumerator ();
711   ShellCloseHandleEnumerator ();
712   LibCheckVarFreeVarList (&ChkPck);
713   LibUnInitializeStrings ();
714   return Status;
715 }
716
717 EFI_STATUS
718 ShellCmdDriverConfigurationProcessActionRequired (
719   EFI_HANDLE                                DriverImageHandle,
720   EFI_HANDLE                                ControllerHandle,
721   EFI_HANDLE                                ChildHandle,
722   EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED  ActionRequired
723   )
724
725 {
726   CHAR16      ReturnStr[2];
727   EFI_HANDLE  ContextOverride[2];
728
729   switch (ActionRequired) {
730   case EfiDriverConfigurationActionNone:
731     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_NONE), HiiHandle);
732     break;
733
734   case EfiDriverConfigurationActionStopController:
735     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_STOP_CONTROLLER), HiiHandle);
736     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_ENTER_STOP_CONTROL), HiiHandle);
737     Input (L"", ReturnStr, sizeof (ReturnStr) / sizeof (CHAR16));
738     BS->DisconnectController (ControllerHandle, DriverImageHandle, ChildHandle);
739     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_CONTROLLER_STOPPED), HiiHandle);
740     break;
741
742   case EfiDriverConfigurationActionRestartController:
743     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_RESTART_CONTROLLER), HiiHandle);
744     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_ENTER_RESTART_CONTROLLER), HiiHandle);
745     Input (L"", ReturnStr, sizeof (ReturnStr) / sizeof (CHAR16));
746     BS->DisconnectController (ControllerHandle, DriverImageHandle, ChildHandle);
747     ContextOverride[0]  = DriverImageHandle;
748     ContextOverride[1]  = NULL;
749     BS->ConnectController (ControllerHandle, ContextOverride, NULL, TRUE);
750     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_CONTROLLER_RESTARTED), HiiHandle);
751     break;
752
753   case EfiDriverConfigurationActionRestartPlatform:
754     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_RESTART_PLATFORM), HiiHandle);
755     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_ENTER_RESTART_PLATFORM), HiiHandle);
756     Input (L"", ReturnStr, sizeof (ReturnStr) / sizeof (CHAR16));
757     RT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
758     break;
759
760   default:
761     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_UNKNOWN_3), HiiHandle);
762     break;
763   }
764
765   return EFI_SUCCESS;
766 }
767
768 EFI_STATUS
769 EFIAPI
770 DrvcfgGetLineHelp (
771   OUT CHAR16              **Str
772   )
773 /*++
774
775 Routine Description:
776
777   Get this command's line help
778
779 Arguments:
780
781   Str - The line help
782
783 Returns:
784
785   EFI_SUCCESS   - Success
786
787 --*/
788 {
789   return LibCmdGetStringByToken (STRING_ARRAY_NAME, &EfiDrvcfgGuid, STRING_TOKEN (STR_DRVCFG_LINE_HELP), Str);
790 }
791 //
792 // Compatible Support
793 //
794 EFI_STATUS
795 SEnvCmdDriverConfiguration (
796   IN EFI_HANDLE               ImageHandle,
797   IN EFI_SYSTEM_TABLE         *SystemTable
798   )
799 /*++
800
801 Routine Description:
802
803 Arguments:
804
805   ImageHandle - The image handle
806   SystemTable - The system table
807
808 Returns:
809
810   EFI_SUCCESS - Success
811
812 --*/
813 {
814   EFI_STATUS                                Status;
815   CHAR16                                    *Ptr;
816   UINTN                                     HandleNumber;
817   EFI_HANDLE                                DriverImageHandle;
818   EFI_HANDLE                                DeviceHandle;
819   EFI_HANDLE                                ChildHandle;
820   UINTN                                     Index;
821   CHAR8                                     *Language;
822   CHAR8                                     *BestLanguage;
823   UINTN                                     DriverImageHandleCount;
824   EFI_HANDLE                                *DriverImageHandleBuffer;
825   UINTN                                     HandleCount;
826   EFI_HANDLE                                *HandleBuffer;
827   UINT32                                    *HandleType;
828   UINTN                                     HandleIndex;
829   UINTN                                     ChildIndex;
830   UINTN                                     ChildHandleCount;
831   EFI_HANDLE                                *ChildHandleBuffer;
832   UINT32                                    *ChildHandleType;
833   EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED  ActionRequired;
834   EFI_DRIVER_CONFIGURATION_PROTOCOL         *DriverConfiguration;
835   BOOLEAN                                   ForceDefaults;
836   UINT32                                    DefaultType;
837   BOOLEAN                                   ValidateOptions;
838   BOOLEAN                                   SetOptions;
839   BOOLEAN                                   AllChildren;
840   BOOLEAN                                   GetHelp;
841   BOOLEAN                                   Iso639Language;
842
843   //
844   // Setup Handle and Protocol Globals
845   //
846   DriverImageHandle       = NULL;
847   DeviceHandle            = NULL;
848   ChildHandle             = NULL;
849   ForceDefaults           = FALSE;
850   DefaultType             = 0;
851   ValidateOptions         = FALSE;
852   SetOptions              = FALSE;
853   AllChildren             = FALSE;
854   DriverImageHandleCount  = 0;
855   DriverImageHandleBuffer = NULL;
856   GetHelp                 = FALSE;
857   Language                = NULL;
858   
859   for (Index = 1; Index < SI->Argc; Index += 1) {
860     Ptr = SI->Argv[Index];
861     if (*Ptr == '-') {
862       switch (Ptr[1]) {
863       case 'l':
864       case 'L':
865         Language = LibGetCommandLineLanguage (Ptr + 2);
866         break;
867
868       case 'c':
869       case 'C':
870         AllChildren = TRUE;
871         break;
872
873       case 'f':
874       case 'F':
875         if (ValidateOptions || SetOptions) {
876           PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_FLAG_CONFLICT), HiiHandle, L"drvcfg", L"-f");
877           Status = EFI_INVALID_PARAMETER;
878           goto Done;
879         }
880
881         ForceDefaults = TRUE;
882         DefaultType   = (UINT32) (Xtoi (Ptr + 2));
883         break;
884
885       case 'v':
886       case 'V':
887         if (ForceDefaults || SetOptions) {
888           PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_FLAG_CONFLICT), HiiHandle, L"drvcfg", L"-v");
889           Status = EFI_INVALID_PARAMETER;
890           goto Done;
891         }
892
893         ValidateOptions = TRUE;
894         break;
895
896       case 's':
897       case 'S':
898         if (ForceDefaults || ValidateOptions) {
899           PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_FLAG_CONFLICT), HiiHandle, L"drvcfg", L"-s");
900           Status = EFI_INVALID_PARAMETER;
901           goto Done;
902         }
903
904         SetOptions = TRUE;
905         break;
906
907       case 'b':
908       case 'B':
909         EnablePageBreak (DEFAULT_INIT_ROW, DEFAULT_AUTO_LF);
910         break;
911
912       case '?':
913         GetHelp = TRUE;
914         break;
915
916       default:
917         PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_UNKNOWN_FLAG), HiiHandle, L"drvcfg", Ptr);
918         Status = EFI_INVALID_PARAMETER;
919         goto Done;
920       }
921     } else {
922       HandleNumber = ShellHandleNoFromStr (Ptr);
923       if (HandleNumber == 0) {
924         PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_INVALID_HANDLE_NUM), HiiHandle, L"drvcfg", Ptr);
925         Status = EFI_INVALID_PARAMETER;
926         goto Done;
927       }
928
929       if (DriverImageHandle == NULL) {
930         DriverImageHandle = ShellHandleFromIndex (HandleNumber - 1);
931       } else if (DeviceHandle == NULL) {
932         DeviceHandle = ShellHandleFromIndex (HandleNumber - 1);
933       } else if (ChildHandle == NULL) {
934         ChildHandle = ShellHandleFromIndex (HandleNumber - 1);
935       } else {
936         PrintToken (STRING_TOKEN (STR_SHELLENV_GNC_TOO_MANY), HiiHandle, L"drvcfg");
937         Status = EFI_INVALID_PARAMETER;
938         goto Done;
939       }
940     }
941   }
942
943   if (GetHelp) {
944     PrintToken (STRING_TOKEN (STR_NO_HELP), HiiHandle);
945     Status = EFI_SUCCESS;
946     goto Done;
947   }
948
949   if (ChildHandle == NULL && AllChildren) {
950     SetOptions = FALSE;
951   }
952
953   if (ForceDefaults) {
954     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_FORCE_DEFAULT), HiiHandle, DefaultType);
955   } else if (ValidateOptions) {
956     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_VALIDATE_CONFIG_OPTIONS), HiiHandle);
957   } else if (SetOptions) {
958     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_SET_CONFIG_OPTIONS), HiiHandle);
959   } else {
960     PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_CONFIGURABLE_COMPONENTS), HiiHandle);
961   }
962   //
963   // Display all handles that support being configured
964   //
965   if (DriverImageHandle == NULL) {
966     Status = LibLocateHandle (
967               ByProtocol,
968               &gEfiDriverConfiguration2ProtocolGuid,
969               NULL,
970               &DriverImageHandleCount,
971               &DriverImageHandleBuffer
972               );
973
974     if (EFI_ERROR (Status)) {
975       Status = LibLocateHandle (
976                 ByProtocol,
977                 &gEfiDriverConfigurationProtocolGuid,
978                 NULL,
979                 &DriverImageHandleCount,
980                 &DriverImageHandleBuffer
981                 );
982     }
983     if (EFI_ERROR (Status)) {
984       Status = EFI_NOT_FOUND;
985       goto Done;
986     }
987   } else {
988     DriverImageHandleCount = 1;
989     //
990     // Allocate buffer to hold the image handle so as to
991     // keep consistent with the above clause
992     //
993     DriverImageHandleBuffer = AllocatePool (sizeof (EFI_HANDLE));
994     ASSERT (DriverImageHandleBuffer);
995     DriverImageHandleBuffer[0] = DriverImageHandle;
996   }
997   //
998   // MARMAR:  We need to look at getting the component name exporters to support more than just LANGUAGE_CODE_ENGLISH
999   //
1000   for (Index = 0; Index < DriverImageHandleCount; Index++) {
1001     Iso639Language = FALSE;
1002     Status = BS->OpenProtocol (
1003                   DriverImageHandleBuffer[Index],
1004                   &gEfiDriverConfiguration2ProtocolGuid,
1005                   (VOID **) &DriverConfiguration,
1006                   NULL,
1007                   NULL,
1008                   EFI_OPEN_PROTOCOL_GET_PROTOCOL
1009                   );
1010     if (EFI_ERROR (Status)) {
1011       Iso639Language = TRUE;
1012       Status = BS->OpenProtocol (
1013                     DriverImageHandleBuffer[Index],
1014                     &gEfiDriverConfigurationProtocolGuid,
1015                     (VOID **) &DriverConfiguration,
1016                     NULL,
1017                     NULL,
1018                     EFI_OPEN_PROTOCOL_GET_PROTOCOL
1019                     );
1020     }
1021     if (EFI_ERROR (Status)) {
1022       PrintToken (
1023         STRING_TOKEN (STR_SHELLENV_PROTID_DRVCFG_NOT_SUPPORT_PROT),
1024         HiiHandle,
1025         ShellHandleToIndex (DriverImageHandleBuffer[Index])
1026         );
1027       continue;
1028     }
1029
1030     BestLanguage = LibSelectBestLanguage (DriverConfiguration->SupportedLanguages, Iso639Language, Language);
1031     if (BestLanguage == NULL) {
1032       PrintToken (
1033         STRING_TOKEN (STR_SHELLENV_PROTID_DRVCFG_HANDLE_NOT_SUPPORT_LANG),
1034         HiiHandle,
1035         ShellHandleToIndex (DriverImageHandleBuffer[Index]),
1036         Language
1037         );
1038       continue;
1039     }
1040
1041     Status = LibScanHandleDatabase (
1042               DriverImageHandleBuffer[Index],
1043               NULL,
1044               NULL,
1045               NULL,
1046               &HandleCount,
1047               &HandleBuffer,
1048               &HandleType
1049               );
1050     if (EFI_ERROR (Status)) {
1051       continue;
1052     }
1053
1054     if (SetOptions && DeviceHandle == NULL) {
1055
1056       ST->ConOut->ClearScreen (ST->ConOut);
1057       Status = DriverConfiguration->SetOptions (
1058                                       DriverConfiguration,
1059                                       NULL,
1060                                       NULL,
1061                                       BestLanguage,
1062                                       &ActionRequired
1063                                       );
1064       ST->ConOut->ClearScreen (ST->ConOut);
1065
1066       PrintToken (
1067         STRING_TOKEN (STR_SHELLENV_PROTID_DRV_ALL_LANG),
1068         HiiHandle,
1069         ShellHandleToIndex (DriverImageHandleBuffer[Index]),
1070         DriverConfiguration->SupportedLanguages
1071         );
1072       if (!EFI_ERROR (Status)) {
1073         PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_SET), HiiHandle);
1074
1075         for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
1076
1077           if ((HandleType[HandleIndex] & EFI_HANDLE_TYPE_CONTROLLER_HANDLE) == EFI_HANDLE_TYPE_CONTROLLER_HANDLE) {
1078
1079             ShellCmdDriverConfigurationProcessActionRequired (
1080               DriverImageHandleBuffer[Index],
1081               HandleBuffer[HandleIndex],
1082               NULL,
1083               ActionRequired
1084               );
1085
1086           }
1087         }
1088
1089       } else {
1090         PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_NOT_SET), HiiHandle, Status);
1091       }
1092
1093       continue;
1094     }
1095
1096     for (HandleIndex = 0; HandleIndex < HandleCount; HandleIndex++) {
1097
1098       if ((HandleType[HandleIndex] & EFI_HANDLE_TYPE_CONTROLLER_HANDLE) != EFI_HANDLE_TYPE_CONTROLLER_HANDLE) {
1099         continue;
1100       }
1101
1102       if (DeviceHandle != NULL && DeviceHandle != HandleBuffer[HandleIndex]) {
1103         continue;
1104       }
1105
1106       if (ChildHandle == NULL) {
1107         PrintToken (
1108           STRING_TOKEN (STR_SHELLENV_PROTID_DRV_CTRL_LANG),
1109           HiiHandle,
1110           ShellHandleToIndex (DriverImageHandleBuffer[Index]),
1111           ShellHandleToIndex (HandleBuffer[HandleIndex]),
1112           DriverConfiguration->SupportedLanguages
1113           );
1114
1115         if (ForceDefaults) {
1116           Status = DriverConfiguration->ForceDefaults (
1117                                           DriverConfiguration,
1118                                           HandleBuffer[HandleIndex],
1119                                           NULL,
1120                                           DefaultType,
1121                                           &ActionRequired
1122                                           );
1123
1124           if (!EFI_ERROR (Status)) {
1125             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_DEFAULTS_FORCED), HiiHandle);
1126
1127             ShellCmdDriverConfigurationProcessActionRequired (
1128               DriverImageHandleBuffer[Index],
1129               HandleBuffer[HandleIndex],
1130               NULL,
1131               ActionRequired
1132               );
1133           } else {
1134             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_DEFAULTS_FORCE_FAILED), HiiHandle, Status);
1135           }
1136         } else if (ValidateOptions) {
1137           Status = DriverConfiguration->OptionsValid (
1138                                           DriverConfiguration,
1139                                           HandleBuffer[HandleIndex],
1140                                           NULL
1141                                           );
1142
1143           if (!EFI_ERROR (Status)) {
1144             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_VALID), HiiHandle);
1145           } else {
1146             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_NOT_VALID), HiiHandle, Status);
1147           }
1148         } else if (SetOptions) {
1149           ST->ConOut->ClearScreen (ST->ConOut);
1150           Status = DriverConfiguration->SetOptions (
1151                                           DriverConfiguration,
1152                                           HandleBuffer[HandleIndex],
1153                                           NULL,
1154                                           BestLanguage,
1155                                           &ActionRequired
1156                                           );
1157           ST->ConOut->ClearScreen (ST->ConOut);
1158           PrintToken (
1159             STRING_TOKEN (STR_SHELLENV_PROTID_DRV_CTRL_LANG),
1160             HiiHandle,
1161             ShellHandleToIndex (DriverImageHandleBuffer[Index]),
1162             ShellHandleToIndex (HandleBuffer[HandleIndex]),
1163             DriverConfiguration->SupportedLanguages
1164             );
1165           if (!EFI_ERROR (Status)) {
1166             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_SET), HiiHandle);
1167
1168             ShellCmdDriverConfigurationProcessActionRequired (
1169               DriverImageHandleBuffer[Index],
1170               HandleBuffer[HandleIndex],
1171               NULL,
1172               ActionRequired
1173               );
1174
1175           } else {
1176             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_NOT_SET), HiiHandle, Status);
1177           }
1178         } else {
1179           Print (L"\n");
1180         }
1181       }
1182
1183       if (ChildHandle == NULL && !AllChildren) {
1184         continue;
1185       }
1186
1187       Status = LibScanHandleDatabase (
1188                 DriverImageHandleBuffer[Index],
1189                 NULL,
1190                 HandleBuffer[HandleIndex],
1191                 NULL,
1192                 &ChildHandleCount,
1193                 &ChildHandleBuffer,
1194                 &ChildHandleType
1195                 );
1196       if (EFI_ERROR (Status)) {
1197         continue;
1198       }
1199
1200       for (ChildIndex = 0; ChildIndex < ChildHandleCount; ChildIndex++) {
1201
1202         if ((ChildHandleType[ChildIndex] & EFI_HANDLE_TYPE_CHILD_HANDLE) != EFI_HANDLE_TYPE_CHILD_HANDLE) {
1203           continue;
1204         }
1205
1206         if (ChildHandle != NULL && ChildHandle != ChildHandleBuffer[ChildIndex]) {
1207           continue;
1208         }
1209
1210         PrintToken (
1211           STRING_TOKEN (STR_SHELLENV_PROTID_DRV_CTRL_CHILD_LANG),
1212           HiiHandle,
1213           ShellHandleToIndex (DriverImageHandleBuffer[Index]),
1214           ShellHandleToIndex (HandleBuffer[HandleIndex]),
1215           ShellHandleToIndex (ChildHandleBuffer[ChildIndex]),
1216           DriverConfiguration->SupportedLanguages
1217           );
1218
1219         if (ForceDefaults) {
1220           Status = DriverConfiguration->ForceDefaults (
1221                                           DriverConfiguration,
1222                                           HandleBuffer[HandleIndex],
1223                                           ChildHandleBuffer[ChildIndex],
1224                                           DefaultType,
1225                                           &ActionRequired
1226                                           );
1227
1228           if (!EFI_ERROR (Status)) {
1229             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_DEFAULTS_FORCED), HiiHandle);
1230
1231             ShellCmdDriverConfigurationProcessActionRequired (
1232               DriverImageHandleBuffer[Index],
1233               HandleBuffer[HandleIndex],
1234               ChildHandleBuffer[ChildIndex],
1235               ActionRequired
1236               );
1237
1238           } else {
1239             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_FORCE_DEFAULTS_FAILED), HiiHandle, Status);
1240           }
1241         } else if (ValidateOptions) {
1242           Status = DriverConfiguration->OptionsValid (
1243                                           DriverConfiguration,
1244                                           HandleBuffer[HandleIndex],
1245                                           ChildHandleBuffer[ChildIndex]
1246                                           );
1247
1248           if (!EFI_ERROR (Status)) {
1249             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_VALID), HiiHandle);
1250           } else {
1251             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_NOT_VALID), HiiHandle, Status);
1252           }
1253         } else if (SetOptions) {
1254           ST->ConOut->ClearScreen (ST->ConOut);
1255           Status = DriverConfiguration->SetOptions (
1256                                           DriverConfiguration,
1257                                           HandleBuffer[HandleIndex],
1258                                           ChildHandleBuffer[ChildIndex],
1259                                           BestLanguage,
1260                                           &ActionRequired
1261                                           );
1262           ST->ConOut->ClearScreen (ST->ConOut);
1263           PrintToken (
1264             STRING_TOKEN (STR_SHELLENV_PROTID_DRV_CTRL_CHILD_LANG),
1265             HiiHandle,
1266             ShellHandleToIndex (DriverImageHandleBuffer[Index]),
1267             ShellHandleToIndex (HandleBuffer[HandleIndex]),
1268             ShellHandleToIndex (ChildHandleBuffer[ChildIndex]),
1269             DriverConfiguration->SupportedLanguages
1270             );
1271           if (!EFI_ERROR (Status)) {
1272             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_SET), HiiHandle);
1273
1274             ShellCmdDriverConfigurationProcessActionRequired (
1275               DriverImageHandleBuffer[Index],
1276               HandleBuffer[HandleIndex],
1277               ChildHandleBuffer[ChildIndex],
1278               ActionRequired
1279               );
1280
1281           } else {
1282             PrintToken (STRING_TOKEN (STR_SHELLENV_PROTID_OPTIONS_NOT_SET), HiiHandle, Status);
1283           }
1284         } else {
1285           Print (L"\n");
1286         }
1287       }
1288
1289       FreePool (ChildHandleBuffer);
1290       FreePool (ChildHandleType);
1291     }
1292
1293     FreePool (BestLanguage);
1294     FreePool (HandleBuffer);
1295     FreePool (HandleType);
1296   }
1297
1298 Done:
1299   if (DriverImageHandle != NULL && DriverImageHandleCount != 0) {
1300     FreePool (DriverImageHandleBuffer);
1301   }
1302   
1303   if (Language != NULL) {
1304     FreePool (Language);
1305   }
1306   return EFI_SUCCESS;
1307 }