TianoCore EDK2 master
Loading...
Searching...
No Matches
DrvCfg.c
Go to the documentation of this file.
1
13
14STATIC CONST EFI_GUID *CfgGuidList[] = { &gEfiDriverConfigurationProtocolGuid, &gEfiDriverConfiguration2ProtocolGuid, NULL };
15
29 OUT EFI_HII_HANDLE *HiiHandle,
31 )
32{
33 EFI_HII_HANDLE *HandleBuffer;
34 UINTN HandleBufferSize;
35 VOID *MainBuffer;
36 UINTN MainBufferSize;
37 EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
38 EFI_HII_PACKAGE_HEADER *PackageHeader;
39 UINTN LoopVariable;
41 EFI_STATUS Status;
42
43 ASSERT (DevPath1 != NULL);
44 ASSERT (HiiHandle != NULL);
45 ASSERT (*HiiHandle == NULL);
46 ASSERT (HiiDb != NULL);
47
48 HandleBufferSize = 0;
49 HandleBuffer = NULL;
50 Status = HiiDb->ListPackageLists (HiiDb, EFI_HII_PACKAGE_DEVICE_PATH, NULL, &HandleBufferSize, HandleBuffer);
51 if (Status == EFI_BUFFER_TOO_SMALL) {
52 HandleBuffer = AllocateZeroPool (HandleBufferSize);
53 if (HandleBuffer == NULL) {
54 Status = EFI_OUT_OF_RESOURCES;
55 } else {
56 Status = HiiDb->ListPackageLists (HiiDb, EFI_HII_PACKAGE_DEVICE_PATH, NULL, &HandleBufferSize, HandleBuffer);
57 }
58 }
59
60 if (EFI_ERROR (Status)) {
61 SHELL_FREE_NON_NULL (HandleBuffer);
62 return (Status);
63 }
64
65 if (HandleBuffer == NULL) {
66 return EFI_NOT_FOUND;
67 }
68
69 for (LoopVariable = 0; LoopVariable < (HandleBufferSize/sizeof (HandleBuffer[0])) && *HiiHandle == NULL; LoopVariable++) {
70 MainBufferSize = 0;
71 MainBuffer = NULL;
72 Status = HiiDb->ExportPackageLists (HiiDb, HandleBuffer[LoopVariable], &MainBufferSize, MainBuffer);
73 if (Status == EFI_BUFFER_TOO_SMALL) {
74 MainBuffer = AllocateZeroPool (MainBufferSize);
75 if (MainBuffer != NULL) {
76 Status = HiiDb->ExportPackageLists (HiiDb, HandleBuffer[LoopVariable], &MainBufferSize, MainBuffer);
77 }
78 }
79
80 if (EFI_ERROR (Status)) {
81 continue;
82 }
83
84 //
85 // Enumerate through the block of returned memory.
86 // This should actually be a small block, but we need to be sure.
87 //
88 for (PackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *)MainBuffer
89 ; PackageListHeader != NULL && ((CHAR8 *)PackageListHeader) < (((CHAR8 *)MainBuffer)+MainBufferSize) && *HiiHandle == NULL
90 ; PackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *)(((CHAR8 *)(PackageListHeader)) + PackageListHeader->PackageLength))
91 {
92 for (PackageHeader = (EFI_HII_PACKAGE_HEADER *)(((CHAR8 *)(PackageListHeader))+sizeof (EFI_HII_PACKAGE_LIST_HEADER))
93 ; PackageHeader != NULL && ((CHAR8 *)PackageHeader) < (((CHAR8 *)MainBuffer)+MainBufferSize) && PackageHeader->Type != EFI_HII_PACKAGE_END && *HiiHandle == NULL
94 ; PackageHeader = (EFI_HII_PACKAGE_HEADER *)(((CHAR8 *)(PackageHeader))+PackageHeader->Length))
95 {
96 if (PackageHeader->Type == EFI_HII_PACKAGE_DEVICE_PATH) {
97 DevPath2 = (EFI_DEVICE_PATH_PROTOCOL *)(((CHAR8 *)PackageHeader) + sizeof (EFI_HII_PACKAGE_HEADER));
98 if (DevicePathCompare (&DevPath1, &DevPath2) == 0) {
99 *HiiHandle = HandleBuffer[LoopVariable];
100 break;
101 }
102 }
103 }
104 }
105
106 SHELL_FREE_NON_NULL (MainBuffer);
107 }
108
109 SHELL_FREE_NON_NULL (HandleBuffer);
110
111 if (*HiiHandle == NULL) {
112 return (EFI_NOT_FOUND);
113 }
114
115 return (EFI_SUCCESS);
116}
117
129 IN CONST EFI_HANDLE Handle,
130 OUT EFI_HII_HANDLE *HiiHandle,
132 )
133{
134 EFI_STATUS Status;
135 EFI_DEVICE_PATH_PROTOCOL *DevPath1;
136
137 if ((HiiHandle == NULL) || (HiiDb == NULL)) {
138 return (EFI_INVALID_PARAMETER);
139 }
140
141 *HiiHandle = NULL;
142
143 if (Handle == NULL) {
144 return (EFI_SUCCESS);
145 }
146
147 DevPath1 = NULL;
148 Status = gBS->OpenProtocol (Handle, &gEfiDevicePathProtocolGuid, (VOID **)&DevPath1, gImageHandle, NULL, EFI_OPEN_PROTOCOL_GET_PROTOCOL);
149 if (EFI_ERROR (Status) || (DevPath1 == NULL)) {
150 return (EFI_NOT_FOUND);
151 }
152
153 return (FindHiiHandleViaDevPath (DevPath1, HiiHandle, HiiDb));
154}
155
164 IN CONST EFI_HANDLE Handle,
165 IN CONST CHAR16 *FileName
166 )
167{
168 EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
169 EFI_STATUS Status;
170 VOID *MainBuffer;
171 UINTN MainBufferSize;
172 EFI_HII_HANDLE HiiHandle;
173 SHELL_FILE_HANDLE FileHandle;
174
175 HiiDatabase = NULL;
176 MainBufferSize = 0;
177 MainBuffer = NULL;
178 FileHandle = NULL;
179
180 Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ|EFI_FILE_MODE_WRITE|EFI_FILE_MODE_CREATE, 0);
181 if (EFI_ERROR (Status)) {
183 -1,
184 -1,
185 NULL,
186 STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL),
187 gShellDriver1HiiHandle,
188 L"drvcfg",
189 FileName,
190 Status
191 );
192 return (SHELL_DEVICE_ERROR);
193 }
194
195 //
196 // Locate HII Database protocol
197 //
198 Status = gBS->LocateProtocol (
199 &gEfiHiiDatabaseProtocolGuid,
200 NULL,
201 (VOID **)&HiiDatabase
202 );
203
204 if (EFI_ERROR (Status) || (HiiDatabase == NULL)) {
206 -1,
207 -1,
208 NULL,
209 STRING_TOKEN (STR_GEN_PROTOCOL_NF),
210 gShellDriver1HiiHandle,
211 L"drvcfg",
212 L"EfiHiiDatabaseProtocol",
213 &gEfiHiiDatabaseProtocolGuid
214 );
215 ShellCloseFile (&FileHandle);
216 return (SHELL_NOT_FOUND);
217 }
218
219 HiiHandle = NULL;
220 Status = ConvertHandleToHiiHandle (Handle, &HiiHandle, HiiDatabase);
221 if (EFI_ERROR (Status)) {
223 -1,
224 -1,
225 NULL,
226 STRING_TOKEN (STR_GEN_HANDLE_NOT),
227 gShellDriver1HiiHandle,
228 L"drvcfg",
230 L"Device"
231 );
232 ShellCloseFile (&FileHandle);
233 return (SHELL_DEVICE_ERROR);
234 }
235
236 Status = HiiDatabase->ExportPackageLists (HiiDatabase, HiiHandle, &MainBufferSize, MainBuffer);
237 if (Status == EFI_BUFFER_TOO_SMALL) {
238 MainBuffer = AllocateZeroPool (MainBufferSize);
239 if (MainBuffer == NULL) {
241 -1,
242 -1,
243 NULL,
244 STRING_TOKEN (STR_GEN_OUT_MEM),
245 gShellDriver1HiiHandle,
246 L"drvcfg"
247 );
248 ShellCloseFile (&FileHandle);
249 return (SHELL_OUT_OF_RESOURCES);
250 }
251
252 Status = HiiDatabase->ExportPackageLists (HiiDatabase, HiiHandle, &MainBufferSize, MainBuffer);
253 if (EFI_ERROR (Status)) {
254 SHELL_FREE_NON_NULL (MainBuffer);
256 -1,
257 -1,
258 NULL,
259 STRING_TOKEN (STR_GEN_OUT_MEM),
260 gShellDriver1HiiHandle,
261 L"drvcfg"
262 );
263 ShellCloseFile (&FileHandle);
264 return (SHELL_DEVICE_ERROR);
265 }
266 }
267
268 Status = ShellWriteFile (FileHandle, &MainBufferSize, MainBuffer);
269
270 ShellCloseFile (&FileHandle);
271 SHELL_FREE_NON_NULL (MainBuffer);
272
273 if (EFI_ERROR (Status)) {
275 -1,
276 -1,
277 NULL,
278 STRING_TOKEN (STR_FILE_WRITE_FAIL),
279 gShellDriver1HiiHandle,
280 L"drvcfg",
281 FileName
282 );
283 return (SHELL_DEVICE_ERROR);
284 }
285
287 -1,
288 -1,
289 NULL,
290 STRING_TOKEN (STR_DRVCFG_COMP),
291 gShellDriver1HiiHandle
292 );
293
294 return (SHELL_SUCCESS);
295}
296
305 IN EFI_HANDLE Handle,
306 IN CONST CHAR16 *FileName
307 )
308{
309 EFI_HII_DATABASE_PROTOCOL *HiiDatabase;
310 EFI_STATUS Status;
311 VOID *MainBuffer;
312 UINT64 Temp;
313 UINTN MainBufferSize;
314 EFI_HII_HANDLE HiiHandle;
315 SHELL_FILE_HANDLE FileHandle;
316 CHAR16 *TempDevPathString;
317 EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
318 EFI_HII_PACKAGE_HEADER *PackageHeader;
320 UINTN HandleIndex;
321 SHELL_STATUS ShellStatus;
322
323 HiiDatabase = NULL;
324 MainBufferSize = 0;
325 MainBuffer = NULL;
326 FileHandle = NULL;
327 ShellStatus = SHELL_SUCCESS;
328
329 Status = ShellOpenFileByName (FileName, &FileHandle, EFI_FILE_MODE_READ, 0);
330 if (EFI_ERROR (Status)) {
332 -1,
333 -1,
334 NULL,
335 STRING_TOKEN (STR_GEN_FILE_OPEN_FAIL),
336 gShellDriver1HiiHandle,
337 L"drvcfg",
338 FileName,
339 Status
340 );
341
342 ShellStatus = SHELL_DEVICE_ERROR;
343 goto Done;
344 }
345
346 //
347 // Locate HII Database protocol
348 //
349 Status = gBS->LocateProtocol (
350 &gEfiHiiDatabaseProtocolGuid,
351 NULL,
352 (VOID **)&HiiDatabase
353 );
354
355 if (EFI_ERROR (Status) || (HiiDatabase == NULL)) {
357 -1,
358 -1,
359 NULL,
360 STRING_TOKEN (STR_GEN_PROTOCOL_NF),
361 gShellDriver1HiiHandle,
362 L"drvcfg",
363 L"EfiHiiDatabaseProtocol",
364 &gEfiHiiDatabaseProtocolGuid
365 );
366
367 ShellStatus = SHELL_NOT_FOUND;
368 goto Done;
369 }
370
371 Status = ShellGetFileSize (FileHandle, &Temp);
372 MainBufferSize = (UINTN)Temp;
373 if (EFI_ERROR (Status)) {
375 -1,
376 -1,
377 NULL,
378 STRING_TOKEN (STR_FILE_READ_FAIL),
379 gShellDriver1HiiHandle,
380 L"drvcfg",
381 FileName
382 );
383
384 ShellStatus = SHELL_DEVICE_ERROR;
385 goto Done;
386 }
387
388 MainBuffer = AllocateZeroPool ((UINTN)MainBufferSize);
389 if (MainBuffer == NULL) {
391 -1,
392 -1,
393 NULL,
394 STRING_TOKEN (STR_GEN_OUT_MEM),
395 gShellDriver1HiiHandle,
396 L"drvcfg"
397 );
398
399 ShellStatus = SHELL_OUT_OF_RESOURCES;
400 goto Done;
401 }
402
403 if (EFI_ERROR (Status)) {
405 -1,
406 -1,
407 NULL,
408 STRING_TOKEN (STR_GEN_OUT_MEM),
409 gShellDriver1HiiHandle,
410 L"drvcfg"
411 );
412
413 ShellStatus = SHELL_DEVICE_ERROR;
414 goto Done;
415 }
416
417 Status = ShellReadFile (FileHandle, &MainBufferSize, MainBuffer);
418 if (EFI_ERROR (Status)) {
420 -1,
421 -1,
422 NULL,
423 STRING_TOKEN (STR_FILE_READ_FAIL),
424 gShellDriver1HiiHandle,
425 L"drvcfg",
426 FileName
427 );
428
429 ShellStatus = SHELL_DEVICE_ERROR;
430 goto Done;
431 }
432
433 ShellCloseFile (&FileHandle);
434 FileHandle = NULL;
435
436 if (Handle != NULL) {
437 //
438 // User override in place. Just do it.
439 //
440 HiiHandle = NULL;
441 Status = ConvertHandleToHiiHandle (Handle, &HiiHandle, HiiDatabase);
442 if (EFI_ERROR (Status)) {
444 -1,
445 -1,
446 NULL,
447 STRING_TOKEN (STR_GEN_HANDLE_NOT),
448 gShellDriver1HiiHandle,
449 L"drvcfg",
451 L"Device"
452 );
453
454 ShellStatus = SHELL_DEVICE_ERROR;
455 goto Done;
456 }
457
458 Status = HiiDatabase->UpdatePackageList (HiiDatabase, HiiHandle, MainBuffer);
459 if (EFI_ERROR (Status)) {
461 -1,
462 -1,
463 NULL,
464 STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN),
465 gShellDriver1HiiHandle,
466 L"drvcfg",
467 L"HiiDatabase->UpdatePackageList",
468 Status
469 );
470
471 ShellStatus = SHELL_DEVICE_ERROR;
472 goto Done;
473 }
474 } else {
475 //
476 // we need to parse the buffer and try to match the device paths for each item to try to find it's device path.
477 //
478
479 for (PackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *)MainBuffer
480 ; PackageListHeader != NULL && ((CHAR8 *)PackageListHeader) < (((CHAR8 *)MainBuffer)+MainBufferSize)
481 ; PackageListHeader = (EFI_HII_PACKAGE_LIST_HEADER *)(((CHAR8 *)(PackageListHeader)) + PackageListHeader->PackageLength))
482 {
483 for (PackageHeader = (EFI_HII_PACKAGE_HEADER *)(((CHAR8 *)(PackageListHeader))+sizeof (EFI_HII_PACKAGE_LIST_HEADER))
484 ; PackageHeader != NULL && ((CHAR8 *)PackageHeader) < (((CHAR8 *)MainBuffer)+MainBufferSize) && PackageHeader->Type != EFI_HII_PACKAGE_END
485 ; PackageHeader = (EFI_HII_PACKAGE_HEADER *)(((CHAR8 *)(PackageHeader))+PackageHeader->Length))
486 {
487 if (PackageHeader->Type == EFI_HII_PACKAGE_DEVICE_PATH) {
488 HiiHandle = NULL;
489 Status = FindHiiHandleViaDevPath ((EFI_DEVICE_PATH_PROTOCOL *)(((CHAR8 *)PackageHeader) + sizeof (EFI_HII_PACKAGE_HEADER)), &HiiHandle, HiiDatabase);
490 if (EFI_ERROR (Status)) {
491 //
492 // print out an error.
493 //
494 TempDevPathString = ConvertDevicePathToText ((EFI_DEVICE_PATH_PROTOCOL *)(((CHAR8 *)PackageHeader) + sizeof (EFI_HII_PACKAGE_HEADER)), TRUE, TRUE);
495 if (TempDevPathString == NULL) {
497 -1,
498 -1,
499 NULL,
500 STRING_TOKEN (STR_GEN_OUT_MEM),
501 gShellDriver1HiiHandle,
502 L"drvcfg"
503 );
504
505 ShellStatus = SHELL_OUT_OF_RESOURCES;
506 goto Done;
507 }
508
510 -1,
511 -1,
512 NULL,
513 STRING_TOKEN (STR_DRVCFG_IN_FILE_NF),
514 gShellDriver1HiiHandle,
515 TempDevPathString
516 );
517 SHELL_FREE_NON_NULL (TempDevPathString);
518 } else {
519 Status = HiiDatabase->UpdatePackageList (HiiDatabase, HiiHandle, PackageListHeader);
520 if (EFI_ERROR (Status)) {
522 -1,
523 -1,
524 NULL,
525 STRING_TOKEN (STR_GEN_UEFI_FUNC_WARN),
526 gShellDriver1HiiHandle,
527 L"drvcfg",
528 L"HiiDatabase->UpdatePackageList",
529 Status
530 );
531
532 ShellStatus = SHELL_DEVICE_ERROR;
533 goto Done;
534 } else {
535 DevPath = (EFI_DEVICE_PATH_PROTOCOL *)(((CHAR8 *)PackageHeader) + sizeof (EFI_HII_PACKAGE_HEADER));
536 gBS->LocateDevicePath (&gEfiHiiConfigAccessProtocolGuid, &DevPath, &Handle);
537 HandleIndex = ConvertHandleToHandleIndex (Handle);
539 -1,
540 -1,
541 NULL,
542 STRING_TOKEN (STR_DRVCFG_DONE_HII),
543 gShellDriver1HiiHandle,
544 HandleIndex
545 );
546 }
547 }
548 }
549 }
550 }
551 }
552
553Done:
554 SHELL_FREE_NON_NULL (MainBuffer);
555
556 if (FileHandle != NULL) {
557 ShellCloseFile (&FileHandle);
558 }
559
560 if (ShellStatus == SHELL_SUCCESS) {
562 -1,
563 -1,
564 NULL,
565 STRING_TOKEN (STR_DRVCFG_COMP),
566 gShellDriver1HiiHandle
567 );
568 }
569
570 return ShellStatus;
571}
572
585 EFI_HANDLE DriverImageHandle,
586 EFI_HANDLE ControllerHandle,
587 EFI_HANDLE ChildHandle,
589 )
590{
591 EFI_HANDLE ConnectControllerContextOverride[2];
592
593 switch (ActionRequired) {
595 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DRVCFG_NONE), gShellDriver1HiiHandle);
596 break;
597
599 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DRVCFG_STOP), gShellDriver1HiiHandle);
600 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DRVCFG_ENTER_S), gShellDriver1HiiHandle, L"stop controller");
601 ShellPromptForResponse (ShellPromptResponseTypeEnterContinue, NULL, NULL);
602
603 gBS->DisconnectController (ControllerHandle, DriverImageHandle, ChildHandle);
604 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DRVCFG_CTLR_S), gShellDriver1HiiHandle, L"stopped");
605 break;
606
608 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DRVCFG_RESTART_S), gShellDriver1HiiHandle, L"controller");
609 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DRVCFG_ENTER_S), gShellDriver1HiiHandle, L"restart controller");
610 ShellPromptForResponse (ShellPromptResponseTypeEnterContinue, NULL, NULL);
611
612 gBS->DisconnectController (ControllerHandle, DriverImageHandle, ChildHandle);
613 ConnectControllerContextOverride[0] = DriverImageHandle;
614 ConnectControllerContextOverride[1] = NULL;
615 gBS->ConnectController (ControllerHandle, ConnectControllerContextOverride, NULL, TRUE);
616 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DRVCFG_CTLR_S), gShellDriver1HiiHandle, L"restarted");
617 break;
618
620 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DRVCFG_RESTART_S), gShellDriver1HiiHandle, L"platform");
621 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DRVCFG_ENTER_S), gShellDriver1HiiHandle, L"restart platform");
622 ShellPromptForResponse (ShellPromptResponseTypeEnterContinue, NULL, NULL);
623
624 gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
625 break;
626
627 default:
628 return (EFI_INVALID_PARAMETER);
629 }
630
631 return EFI_SUCCESS;
632}
633
652 IN CONST CHAR8 *Language,
653 IN BOOLEAN ForceDefaults,
654 IN UINT32 DefaultType,
655 IN BOOLEAN AllChildren,
656 IN BOOLEAN ValidateOptions,
657 IN BOOLEAN SetOptions,
658 IN EFI_HANDLE DriverImageHandle,
659 IN EFI_HANDLE DeviceHandle,
660 IN EFI_HANDLE ChildHandle
661 )
662{
663 EFI_STATUS Status;
664 SHELL_STATUS ShellStatus;
665 UINTN OuterLoopCounter;
666 CHAR8 *BestLanguage;
667 UINTN DriverImageHandleCount;
668 EFI_HANDLE *DriverImageHandleBuffer;
669 UINTN HandleCount;
670 EFI_HANDLE *HandleBuffer;
671 UINTN *HandleType;
672 UINTN LoopCounter;
673 UINTN ChildIndex;
674 UINTN ChildHandleCount;
675 EFI_HANDLE *ChildHandleBuffer;
676 UINTN *ChildHandleType;
678 EFI_DRIVER_CONFIGURATION_PROTOCOL *DriverConfiguration;
679 BOOLEAN Iso639Language;
680 UINTN HandleIndex1;
681 UINTN HandleIndex2;
682 UINTN HandleIndex3;
683
684 ShellStatus = SHELL_SUCCESS;
685
686 if ((ChildHandle == NULL) && AllChildren) {
687 SetOptions = FALSE;
688 }
689
690 if (ForceDefaults) {
692 -1,
693 -1,
694 NULL,
695 STRING_TOKEN (STR_DRVCFG_FORCE_D),
696 gShellDriver1HiiHandle,
697 DefaultType
698 );
699 } else if (ValidateOptions) {
701 -1,
702 -1,
703 NULL,
704 STRING_TOKEN (STR_DRVCFG_VALIDATE),
705 gShellDriver1HiiHandle
706 );
707 } else if (SetOptions) {
709 -1,
710 -1,
711 NULL,
712 STRING_TOKEN (STR_DRVCFG_SET),
713 gShellDriver1HiiHandle
714 );
715 }
716
717 if (DriverImageHandle == 0) {
718 DriverImageHandleBuffer = GetHandleListByProtocolList (CfgGuidList);
719 if (DriverImageHandleBuffer == NULL) {
720 ShellStatus = SHELL_NOT_FOUND;
721 goto Done;
722 }
723
724 for (
725 HandleBuffer = DriverImageHandleBuffer, DriverImageHandleCount = 0
726 ; HandleBuffer != NULL && *HandleBuffer != NULL
727 ; HandleBuffer++, DriverImageHandleCount++)
728 {
729 }
730 } else {
731 DriverImageHandleCount = 1;
732 //
733 // Allocate buffer to hold the image handle so as to
734 // keep consistent with the above clause
735 //
736 DriverImageHandleBuffer = AllocatePool (sizeof (EFI_HANDLE));
737 if (DriverImageHandleBuffer == NULL) {
738 ASSERT (DriverImageHandleBuffer);
739 ShellStatus = SHELL_OUT_OF_RESOURCES;
740 goto Done;
741 }
742
743 DriverImageHandleBuffer[0] = DriverImageHandle;
744 }
745
746 for (OuterLoopCounter = 0; OuterLoopCounter < DriverImageHandleCount; OuterLoopCounter++) {
747 Iso639Language = FALSE;
748 Status = gBS->OpenProtocol (
749 DriverImageHandleBuffer[OuterLoopCounter],
750 &gEfiDriverConfiguration2ProtocolGuid,
751 (VOID **)&DriverConfiguration,
752 NULL,
753 NULL,
754 EFI_OPEN_PROTOCOL_GET_PROTOCOL
755 );
756 if (EFI_ERROR (Status)) {
757 Iso639Language = TRUE;
758 Status = gBS->OpenProtocol (
759 DriverImageHandleBuffer[OuterLoopCounter],
760 &gEfiDriverConfigurationProtocolGuid,
761 (VOID **)&DriverConfiguration,
762 NULL,
763 NULL,
764 EFI_OPEN_PROTOCOL_GET_PROTOCOL
765 );
766 }
767
768 if (EFI_ERROR (Status)) {
769 // ShellPrintHiiEx(
770 // -1,
771 // -1,
772 // NULL,
773 // STRING_TOKEN (STR_DRVCFG_NOT_SUPPORT),
774 // gShellDriver1HiiHandle,
775 // ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter])
776 // );
777 ShellStatus = SHELL_UNSUPPORTED;
778 continue;
779 }
780
781 BestLanguage = GetBestLanguage (
782 DriverConfiguration->SupportedLanguages,
783 Iso639Language,
784 Language != NULL ? Language : "",
785 DriverConfiguration->SupportedLanguages,
786 NULL
787 );
788 if (BestLanguage == NULL) {
790 -1,
791 -1,
792 NULL,
793 STRING_TOKEN (STR_GEN_NO_VALUE),
794 gShellDriver1HiiHandle,
795 L"drvcfg",
796 L"-l"
797 );
798 ShellStatus = SHELL_INVALID_PARAMETER;
799 continue;
800 }
801
803 DriverImageHandleBuffer[OuterLoopCounter],
804 NULL,
805 &HandleCount,
806 &HandleBuffer,
807 &HandleType
808 );
809 if (EFI_ERROR (Status)) {
810 continue;
811 }
812
813 if (SetOptions && (DeviceHandle == NULL)) {
814 gST->ConOut->ClearScreen (gST->ConOut);
815 Status = DriverConfiguration->SetOptions (
816 DriverConfiguration,
817 NULL,
818 NULL,
819 BestLanguage,
820 &ActionRequired
821 );
822 gST->ConOut->ClearScreen (gST->ConOut);
823
825 -1,
826 -1,
827 NULL,
828 STRING_TOKEN (STR_DRVCFG_ALL_LANG),
829 gShellDriver1HiiHandle,
830 ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]),
831 DriverConfiguration->SupportedLanguages
832 );
833 if (!EFI_ERROR (Status)) {
835 -1,
836 -1,
837 NULL,
838 STRING_TOKEN (STR_DRVCFG_OPTIONS_SET),
839 gShellDriver1HiiHandle
840 );
841 for (LoopCounter = 0; LoopCounter < HandleCount; LoopCounter++) {
842 if ((HandleType[LoopCounter] & HR_CONTROLLER_HANDLE) == HR_CONTROLLER_HANDLE) {
844 DriverImageHandleBuffer[OuterLoopCounter],
845 HandleBuffer[LoopCounter],
846 NULL,
847 ActionRequired
848 );
849 }
850 }
851 } else {
853 -1,
854 -1,
855 NULL,
856 STRING_TOKEN (STR_DRVCFG_NOT_SET),
857 gShellDriver1HiiHandle,
858 Status
859 );
860 }
861
862 continue;
863 }
864
865 for (LoopCounter = 0; LoopCounter < HandleCount; LoopCounter++) {
866 if ((HandleType[LoopCounter] & HR_CONTROLLER_HANDLE) != HR_CONTROLLER_HANDLE) {
867 continue;
868 }
869
870 if ((DeviceHandle != NULL) && (DeviceHandle != HandleBuffer[LoopCounter])) {
871 continue;
872 }
873
874 if (ChildHandle == NULL) {
875 HandleIndex1 = ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]);
876 HandleIndex2 = ConvertHandleToHandleIndex (HandleBuffer[LoopCounter]);
878 -1,
879 -1,
880 NULL,
881 STRING_TOKEN (STR_DRVCFG_CTRL_LANG),
882 gShellDriver1HiiHandle,
883 HandleIndex1,
884 HandleIndex2,
885 DriverConfiguration->SupportedLanguages
886 );
887
888 if (ForceDefaults) {
889 Status = DriverConfiguration->ForceDefaults (
890 DriverConfiguration,
891 HandleBuffer[LoopCounter],
892 NULL,
893 DefaultType,
894 &ActionRequired
895 );
896
897 if (!EFI_ERROR (Status)) {
899 -1,
900 -1,
901 NULL,
902 STRING_TOKEN (STR_DRVCFG_DEF_FORCED),
903 gShellDriver1HiiHandle
904 );
906 DriverImageHandleBuffer[OuterLoopCounter],
907 HandleBuffer[LoopCounter],
908 NULL,
909 ActionRequired
910 );
911 } else {
913 -1,
914 -1,
915 NULL,
916 STRING_TOKEN (STR_DRVCFG_FORCE_FAILED),
917 gShellDriver1HiiHandle,
918 Status
919 );
920 ShellStatus = SHELL_DEVICE_ERROR;
921 }
922 } else if (ValidateOptions) {
923 Status = DriverConfiguration->OptionsValid (
924 DriverConfiguration,
925 HandleBuffer[LoopCounter],
926 NULL
927 );
928
929 if (!EFI_ERROR (Status)) {
931 -1,
932 -1,
933 NULL,
934 STRING_TOKEN (STR_DRVCFG_OPTIONS_VALID),
935 gShellDriver1HiiHandle
936 );
937 } else {
939 -1,
940 -1,
941 NULL,
942 STRING_TOKEN (STR_DRVCFG_OPTIONS_INV),
943 gShellDriver1HiiHandle,
944 Status
945 );
946 ShellStatus = SHELL_DEVICE_ERROR;
947 }
948 } else if (SetOptions) {
949 gST->ConOut->ClearScreen (gST->ConOut);
950 Status = DriverConfiguration->SetOptions (
951 DriverConfiguration,
952 HandleBuffer[LoopCounter],
953 NULL,
954 BestLanguage,
955 &ActionRequired
956 );
957 gST->ConOut->ClearScreen (gST->ConOut);
958 HandleIndex1 = ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]);
959 HandleIndex2 = ConvertHandleToHandleIndex (HandleBuffer[LoopCounter]);
961 -1,
962 -1,
963 NULL,
964 STRING_TOKEN (STR_DRVCFG_CTRL_LANG),
965 gShellDriver1HiiHandle,
966 HandleIndex1,
967 HandleIndex2,
968 DriverConfiguration->SupportedLanguages
969 );
970 if (!EFI_ERROR (Status)) {
972 -1,
973 -1,
974 NULL,
975 STRING_TOKEN (STR_DRVCFG_OPTIONS_SET),
976 gShellDriver1HiiHandle
977 );
978
980 DriverImageHandleBuffer[OuterLoopCounter],
981 HandleBuffer[LoopCounter],
982 NULL,
983 ActionRequired
984 );
985 } else {
987 -1,
988 -1,
989 NULL,
990 STRING_TOKEN (STR_DRVCFG_NOT_SET),
991 gShellDriver1HiiHandle,
992 Status
993 );
994 ShellStatus = SHELL_DEVICE_ERROR;
995 }
996 } else {
997 Print (L"\n");
998 }
999 }
1000
1001 if ((ChildHandle == NULL) && !AllChildren) {
1002 continue;
1003 }
1004
1006 DriverImageHandleBuffer[OuterLoopCounter],
1007 HandleBuffer[LoopCounter],
1008 &ChildHandleCount,
1009 &ChildHandleBuffer,
1010 &ChildHandleType
1011 );
1012 if (EFI_ERROR (Status)) {
1013 continue;
1014 }
1015
1016 for (ChildIndex = 0; ChildIndex < ChildHandleCount; ChildIndex++) {
1017 if ((ChildHandleType[ChildIndex] & HR_CHILD_HANDLE) != HR_CHILD_HANDLE) {
1018 continue;
1019 }
1020
1021 if ((ChildHandle != NULL) && (ChildHandle != ChildHandleBuffer[ChildIndex])) {
1022 continue;
1023 }
1024
1025 HandleIndex1 = ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]);
1026 HandleIndex2 = ConvertHandleToHandleIndex (HandleBuffer[LoopCounter]);
1027 HandleIndex3 = ConvertHandleToHandleIndex (ChildHandleBuffer[ChildIndex]);
1029 -1,
1030 -1,
1031 NULL,
1032 STRING_TOKEN (STR_DRVCFG_CHILD_LANG),
1033 gShellDriver1HiiHandle,
1034 HandleIndex1,
1035 HandleIndex2,
1036 HandleIndex3,
1037 DriverConfiguration->SupportedLanguages
1038 );
1039
1040 if (ForceDefaults) {
1041 Status = DriverConfiguration->ForceDefaults (
1042 DriverConfiguration,
1043 HandleBuffer[LoopCounter],
1044 ChildHandleBuffer[ChildIndex],
1045 DefaultType,
1046 &ActionRequired
1047 );
1048
1049 if (!EFI_ERROR (Status)) {
1051 -1,
1052 -1,
1053 NULL,
1054 STRING_TOKEN (STR_DRVCFG_DEF_FORCED),
1055 gShellDriver1HiiHandle
1056 );
1057
1059 DriverImageHandleBuffer[OuterLoopCounter],
1060 HandleBuffer[LoopCounter],
1061 ChildHandleBuffer[ChildIndex],
1062 ActionRequired
1063 );
1064 } else {
1066 -1,
1067 -1,
1068 NULL,
1069 STRING_TOKEN (STR_DRVCFG_FORCE_FAILED),
1070 gShellDriver1HiiHandle,
1071 Status
1072 );
1073 ShellStatus = SHELL_DEVICE_ERROR;
1074 }
1075 } else if (ValidateOptions) {
1076 Status = DriverConfiguration->OptionsValid (
1077 DriverConfiguration,
1078 HandleBuffer[LoopCounter],
1079 ChildHandleBuffer[ChildIndex]
1080 );
1081
1082 if (!EFI_ERROR (Status)) {
1084 -1,
1085 -1,
1086 NULL,
1087 STRING_TOKEN (STR_DRVCFG_OPTIONS_VALID),
1088 gShellDriver1HiiHandle
1089 );
1090 } else {
1092 -1,
1093 -1,
1094 NULL,
1095 STRING_TOKEN (STR_DRVCFG_OPTIONS_INV),
1096 gShellDriver1HiiHandle,
1097 Status
1098 );
1099 ShellStatus = SHELL_DEVICE_ERROR;
1100 }
1101 } else if (SetOptions) {
1102 gST->ConOut->ClearScreen (gST->ConOut);
1103 Status = DriverConfiguration->SetOptions (
1104 DriverConfiguration,
1105 HandleBuffer[LoopCounter],
1106 ChildHandleBuffer[ChildIndex],
1107 BestLanguage,
1108 &ActionRequired
1109 );
1110 gST->ConOut->ClearScreen (gST->ConOut);
1111 HandleIndex1 = ConvertHandleToHandleIndex (DriverImageHandleBuffer[OuterLoopCounter]);
1112 HandleIndex2 = ConvertHandleToHandleIndex (HandleBuffer[LoopCounter]);
1113 HandleIndex3 = ConvertHandleToHandleIndex (ChildHandleBuffer[ChildIndex]);
1115 -1,
1116 -1,
1117 NULL,
1118 STRING_TOKEN (STR_DRVCFG_CHILD_LANG),
1119 gShellDriver1HiiHandle,
1120 HandleIndex1,
1121 HandleIndex2,
1122 HandleIndex3,
1123 DriverConfiguration->SupportedLanguages
1124 );
1125 if (!EFI_ERROR (Status)) {
1127 -1,
1128 -1,
1129 NULL,
1130 STRING_TOKEN (STR_DRVCFG_OPTIONS_SET),
1131 gShellDriver1HiiHandle
1132 );
1133
1135 DriverImageHandleBuffer[OuterLoopCounter],
1136 HandleBuffer[LoopCounter],
1137 ChildHandleBuffer[ChildIndex],
1138 ActionRequired
1139 );
1140 } else {
1142 -1,
1143 -1,
1144 NULL,
1145 STRING_TOKEN (STR_DRVCFG_NOT_SET),
1146 gShellDriver1HiiHandle,
1147 Status
1148 );
1149 ShellStatus = SHELL_DEVICE_ERROR;
1150 }
1151 } else {
1152 Print (L"\n");
1153 }
1154 }
1155
1156 FreePool (ChildHandleBuffer);
1157 FreePool (ChildHandleType);
1158 }
1159
1160 FreePool (BestLanguage);
1161 FreePool (HandleBuffer);
1162 FreePool (HandleType);
1163 }
1164
1165 if ((DriverImageHandle != NULL) && (DriverImageHandleCount != 0)) {
1166 FreePool (DriverImageHandleBuffer);
1167 }
1168
1169Done:
1170 return ShellStatus;
1171}
1172
1184 IN CONST BOOLEAN ChildrenToo,
1185 IN CONST CHAR8 *Language,
1186 IN CONST BOOLEAN UseHii
1187 )
1188{
1189 EFI_HANDLE *HandleList;
1190 EFI_HANDLE *CurrentHandle;
1191 BOOLEAN Found;
1192 UINTN Index2;
1193
1194 Found = FALSE;
1195 HandleList = NULL;
1196 CurrentHandle = NULL;
1197
1198 if (UseHii) {
1199 //
1200 // HII method
1201 //
1202 HandleList = GetHandleListByProtocol (&gEfiHiiConfigAccessProtocolGuid);
1203 for (CurrentHandle = HandleList; CurrentHandle != NULL && *CurrentHandle != NULL; CurrentHandle++) {
1204 Found = TRUE;
1205 Index2 = *CurrentHandle == NULL ? 0 : ConvertHandleToHandleIndex (*CurrentHandle);
1207 -1,
1208 -1,
1209 NULL,
1210 STRING_TOKEN (STR_DRVCFG_LINE_HII),
1211 gShellDriver1HiiHandle,
1212 Index2
1213 );
1214 }
1215
1216 SHELL_FREE_NON_NULL (HandleList);
1217 }
1218
1219 if (PreHiiDrvCfg (
1220 Language,
1221 FALSE,
1222 0,
1223 ChildrenToo,
1224 FALSE,
1225 FALSE,
1226 0,
1227 0,
1228 0
1229 ) == SHELL_SUCCESS)
1230 {
1231 Found = TRUE;
1232 }
1233
1234 if (!Found) {
1235 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_DRVCFG_NONE_FOUND), gShellDriver1HiiHandle);
1236 return (SHELL_SUCCESS);
1237 }
1238
1239 return (SHELL_SUCCESS);
1240}
1241
1242STATIC CONST SHELL_PARAM_ITEM ParamListHii[] = {
1243 { L"-s", TypeFlag },
1244 { L"-l", TypeValue },
1245 { L"-f", TypeValue },
1246 { L"-o", TypeValue },
1247 { L"-i", TypeValue },
1248 { NULL, TypeMax }
1249};
1250STATIC CONST SHELL_PARAM_ITEM ParamListPreHii[] = {
1251 { L"-c", TypeFlag },
1252 { L"-s", TypeFlag },
1253 { L"-v", TypeFlag },
1254 { L"-l", TypeValue },
1255 { L"-f", TypeValue },
1256 { NULL, TypeMax }
1257};
1258
1266EFIAPI
1268 IN EFI_HANDLE ImageHandle,
1269 IN EFI_SYSTEM_TABLE *SystemTable
1270 )
1271{
1272 EFI_STATUS Status;
1273 LIST_ENTRY *Package;
1274 CHAR16 *ProblemParam;
1275 SHELL_STATUS ShellStatus;
1276 CHAR8 *Language;
1277 CONST CHAR16 *Lang;
1278 CONST CHAR16 *HandleIndex1;
1279 CONST CHAR16 *HandleIndex2;
1280 CONST CHAR16 *HandleIndex3;
1281 CONST CHAR16 *ForceTypeString;
1282 BOOLEAN Force;
1283 BOOLEAN Set;
1284 BOOLEAN Validate;
1285 BOOLEAN InFromFile;
1286 BOOLEAN OutToFile;
1287 BOOLEAN AllChildren;
1288 BOOLEAN UseHii;
1289 UINT32 ForceType;
1290 UINT64 Intermediate;
1291 EFI_HANDLE Handle1;
1292 EFI_HANDLE Handle2;
1293 EFI_HANDLE Handle3;
1294 CONST CHAR16 *FileName;
1295
1296 ShellStatus = SHELL_SUCCESS;
1297 Status = EFI_SUCCESS;
1298 Language = NULL;
1299 UseHii = TRUE;
1300 ProblemParam = NULL;
1301
1302 //
1303 // initialize the shell lib (we must be in non-auto-init...)
1304 //
1305 Status = ShellInitialize ();
1306 ASSERT_EFI_ERROR (Status);
1307
1308 Status = CommandInit ();
1309 ASSERT_EFI_ERROR (Status);
1310
1311 //
1312 // parse the command line
1313 //
1314 Status = ShellCommandLineParse (ParamListHii, &Package, &ProblemParam, TRUE);
1315 if (EFI_ERROR (Status) || (ShellCommandLineGetCount (Package) > 2)) {
1316 UseHii = FALSE;
1317 if (Package != NULL) {
1319 }
1320
1321 SHELL_FREE_NON_NULL (ProblemParam);
1322 Status = ShellCommandLineParse (ParamListPreHii, &Package, &ProblemParam, TRUE);
1323 if (EFI_ERROR (Status)) {
1324 if ((Status == EFI_VOLUME_CORRUPTED) && (ProblemParam != NULL)) {
1325 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM), gShellDriver1HiiHandle, L"drvcfg", ProblemParam);
1326 FreePool (ProblemParam);
1327 ShellStatus = SHELL_INVALID_PARAMETER;
1328 goto Done;
1329 } else {
1330 ASSERT (FALSE);
1331 }
1332 }
1333 }
1334
1335 if (ShellStatus == SHELL_SUCCESS) {
1336 if (ShellCommandLineGetCount (Package) > 4) {
1337 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_TOO_MANY), gShellDriver1HiiHandle, L"drvcfg");
1338 ShellStatus = SHELL_INVALID_PARAMETER;
1339 goto Done;
1340 }
1341
1342 Lang = ShellCommandLineGetValue (Package, L"-l");
1343 if (Lang != NULL) {
1344 Language = AllocateZeroPool (StrSize (Lang));
1345 if (Language == NULL) {
1346 ShellStatus = SHELL_OUT_OF_RESOURCES;
1347 goto Done;
1348 }
1349
1350 AsciiSPrint (Language, StrSize (Lang), "%S", Lang);
1351 } else if (ShellCommandLineGetFlag (Package, L"-l")) {
1352 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"drvcfg", L"-l");
1353 ShellStatus = SHELL_INVALID_PARAMETER;
1354 goto Done;
1355 }
1356
1357 Set = ShellCommandLineGetFlag (Package, L"-s");
1358 Validate = ShellCommandLineGetFlag (Package, L"-v");
1359 InFromFile = ShellCommandLineGetFlag (Package, L"-i");
1360 OutToFile = ShellCommandLineGetFlag (Package, L"-o");
1361 AllChildren = ShellCommandLineGetFlag (Package, L"-c");
1362 Force = ShellCommandLineGetFlag (Package, L"-f");
1363 ForceTypeString = ShellCommandLineGetValue (Package, L"-f");
1364
1365 if (OutToFile) {
1366 FileName = ShellCommandLineGetValue (Package, L"-o");
1367 } else if (InFromFile) {
1368 FileName = ShellCommandLineGetValue (Package, L"-i");
1369 } else {
1370 FileName = NULL;
1371 }
1372
1373 if (FileName == NULL) {
1374 ASSERT (FileName != NULL);
1375 ShellStatus = SHELL_INVALID_PARAMETER;
1376 goto Done;
1377 }
1378
1379 if (InFromFile && EFI_ERROR (ShellFileExists (FileName))) {
1380 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FIND_FAIL), gShellDriver1HiiHandle, L"drvcfg", FileName);
1381 ShellStatus = SHELL_INVALID_PARAMETER;
1382 goto Done;
1383 }
1384
1385 if (OutToFile && !EFI_ERROR (ShellFileExists (FileName))) {
1386 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_FILE_EXIST), gShellDriver1HiiHandle, L"drvcfg", FileName);
1387 ShellStatus = SHELL_INVALID_PARAMETER;
1388 goto Done;
1389 }
1390
1391 if (Force && (ForceTypeString == NULL)) {
1392 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"drvcfg", L"-f");
1393 ShellStatus = SHELL_INVALID_PARAMETER;
1394 goto Done;
1395 }
1396
1397 if (Force) {
1398 Status = ShellConvertStringToUint64 (ForceTypeString, &Intermediate, FALSE, FALSE);
1399 if (EFI_ERROR (Status)) {
1400 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PROBLEM_VAL), gShellDriver1HiiHandle, L"drvcfg", ForceTypeString, L"-f");
1401 ShellStatus = SHELL_INVALID_PARAMETER;
1402 goto Done;
1403 }
1404
1405 ForceType = (UINT32)Intermediate;
1406 } else {
1407 ForceType = 0;
1408 }
1409
1410 HandleIndex1 = ShellCommandLineGetRawValue (Package, 1);
1411 Handle1 = NULL;
1412 if ((HandleIndex1 != NULL) && !EFI_ERROR (ShellConvertStringToUint64 (HandleIndex1, &Intermediate, TRUE, FALSE))) {
1413 Handle1 = ConvertHandleIndexToHandle ((UINTN)Intermediate);
1414 if ((Handle1 == NULL) || ((UINT64)(UINTN)Intermediate != Intermediate)) {
1415 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"drvcfg", HandleIndex1);
1416 ShellStatus = SHELL_INVALID_PARAMETER;
1417 goto Done;
1418 }
1419 }
1420
1421 HandleIndex2 = ShellCommandLineGetRawValue (Package, 2);
1422 Handle2 = NULL;
1423 if ((HandleIndex2 != NULL) && !EFI_ERROR (ShellConvertStringToUint64 (HandleIndex2, &Intermediate, TRUE, FALSE))) {
1424 Handle2 = ConvertHandleIndexToHandle ((UINTN)Intermediate);
1425 if ((Handle2 == NULL) || ((UINT64)(UINTN)Intermediate != Intermediate)) {
1426 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"drvcfg", HandleIndex2);
1427 ShellStatus = SHELL_INVALID_PARAMETER;
1428 goto Done;
1429 }
1430 }
1431
1432 HandleIndex3 = ShellCommandLineGetRawValue (Package, 3);
1433 Handle3 = NULL;
1434 if ((HandleIndex3 != NULL) && !EFI_ERROR (ShellConvertStringToUint64 (HandleIndex3, &Intermediate, TRUE, FALSE))) {
1435 Handle3 = ConvertHandleIndexToHandle ((UINTN)Intermediate);
1436 if ((Handle3 == NULL) || ((UINT64)(UINTN)Intermediate != Intermediate)) {
1437 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_INV_HANDLE), gShellDriver1HiiHandle, L"drvcfg", HandleIndex3);
1438 ShellStatus = SHELL_INVALID_PARAMETER;
1439 goto Done;
1440 }
1441 }
1442
1443 if ((InFromFile || OutToFile) && (FileName == NULL)) {
1444 if (FileName == NULL) {
1445 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_NO_VALUE), gShellDriver1HiiHandle, L"drvcfg", InFromFile ? L"-i" : L"-o");
1446 } else {
1447 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_HANDLE_REQ), gShellDriver1HiiHandle, L"drvcfg");
1448 }
1449
1450 ShellStatus = SHELL_INVALID_PARAMETER;
1451 goto Done;
1452 }
1453
1454 if (!UseHii && (InFromFile || OutToFile)) {
1455 if (InFromFile) {
1456 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDriver1HiiHandle, L"drvcfg", L"-i");
1457 ShellStatus = SHELL_INVALID_PARAMETER;
1458 goto Done;
1459 }
1460
1461 if (OutToFile) {
1462 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_INV), gShellDriver1HiiHandle, L"drvcfg", L"-o");
1463 ShellStatus = SHELL_INVALID_PARAMETER;
1464 goto Done;
1465 }
1466 }
1467
1468 if (Validate && Force) {
1469 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDriver1HiiHandle, L"drvcfg", L"-v", L"-f");
1470 ShellStatus = SHELL_INVALID_PARAMETER;
1471 goto Done;
1472 }
1473
1474 if (Validate && Set) {
1475 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDriver1HiiHandle, L"drvcfg", L"-v", L"-s");
1476 ShellStatus = SHELL_INVALID_PARAMETER;
1477 goto Done;
1478 }
1479
1480 if (Set && Force) {
1481 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDriver1HiiHandle, L"drvcfg", L"-s", L"-f");
1482 ShellStatus = SHELL_INVALID_PARAMETER;
1483 goto Done;
1484 }
1485
1486 if (OutToFile && InFromFile) {
1487 ShellPrintHiiEx (-1, -1, NULL, STRING_TOKEN (STR_GEN_PARAM_CONFLICT), gShellDriver1HiiHandle, L"drvcfg", L"-i", L"-o");
1488 ShellStatus = SHELL_INVALID_PARAMETER;
1489 goto Done;
1490 }
1491
1492 //
1493 // We do HII first.
1494 //
1495 if (UseHii) {
1496 if ((Handle1 != NULL) && EFI_ERROR (gBS->OpenProtocol (Handle1, &gEfiHiiConfigAccessProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
1497 //
1498 // no HII on this handle.
1499 //
1500 ShellStatus = SHELL_UNSUPPORTED;
1501 } else if (Validate) {
1502 } else if (Force) {
1503 } else if (Set) {
1504 } else if (InFromFile) {
1505 ShellStatus = ConfigFromFile (Handle1, FileName);
1506 if ((Handle1 != NULL) && (ShellStatus == SHELL_SUCCESS)) {
1507 goto Done;
1508 }
1509 } else if (OutToFile) {
1510 ShellStatus = ConfigToFile (Handle1, FileName);
1511 if ((Handle1 != NULL) && (ShellStatus == SHELL_SUCCESS)) {
1512 goto Done;
1513 }
1514 } else if (HandleIndex1 == NULL) {
1515 //
1516 // display all that are configurable
1517 //
1518 ShellStatus = PrintConfigInfoOnAll (AllChildren, Language, UseHii);
1519 goto Done;
1520 } else {
1521 if (!EFI_ERROR (gBS->OpenProtocol (Handle1, &gEfiHiiConfigAccessProtocolGuid, NULL, gImageHandle, NULL, EFI_OPEN_PROTOCOL_TEST_PROTOCOL))) {
1523 -1,
1524 -1,
1525 NULL,
1526 STRING_TOKEN (STR_DRVCFG_LINE_HII),
1527 gShellDriver1HiiHandle,
1529 );
1530 goto Done;
1531 }
1532 }
1533 }
1534
1535 //
1536 // We allways need to do this one since it does both by default.
1537 //
1538 if (!InFromFile && !OutToFile) {
1539 ShellStatus = PreHiiDrvCfg (
1540 Language,
1541 Force,
1542 ForceType,
1543 AllChildren,
1544 Validate,
1545 Set,
1546 Handle1,
1547 Handle2,
1548 Handle3
1549 );
1550 }
1551
1552 if (ShellStatus == SHELL_UNSUPPORTED) {
1554 -1,
1555 -1,
1556 NULL,
1557 STRING_TOKEN (STR_DRVCFG_NOT_SUPPORT),
1558 gShellDriver1HiiHandle,
1560 );
1561 }
1562 }
1563
1564Done:
1566 SHELL_FREE_NON_NULL (Language);
1567 return (ShellStatus);
1568}
UINT64 UINTN
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
Definition: String.c:72
CHAR16 *EFIAPI ConvertDevicePathToText(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevicePath, IN BOOLEAN DisplayOnly, IN BOOLEAN AllowShortcuts)
EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED
@ EfiDriverConfigurationActionNone
@ EfiDriverConfigurationActionRestartPlatform
@ EfiDriverConfigurationActionRestartController
@ EfiDriverConfigurationActionStopController
EFI_STATUS ShellCmdDriverConfigurationProcessActionRequired(EFI_HANDLE DriverImageHandle, EFI_HANDLE ControllerHandle, EFI_HANDLE ChildHandle, EFI_DRIVER_CONFIGURATION_ACTION_REQUIRED ActionRequired)
Definition: DrvCfg.c:584
SHELL_STATUS ConfigFromFile(IN EFI_HANDLE Handle, IN CONST CHAR16 *FileName)
Definition: DrvCfg.c:304
SHELL_STATUS PreHiiDrvCfg(IN CONST CHAR8 *Language, IN BOOLEAN ForceDefaults, IN UINT32 DefaultType, IN BOOLEAN AllChildren, IN BOOLEAN ValidateOptions, IN BOOLEAN SetOptions, IN EFI_HANDLE DriverImageHandle, IN EFI_HANDLE DeviceHandle, IN EFI_HANDLE ChildHandle)
Definition: DrvCfg.c:651
SHELL_STATUS EFIAPI ShellCommandRunDrvCfg(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
Definition: DrvCfg.c:1267
SHELL_STATUS ConfigToFile(IN CONST EFI_HANDLE Handle, IN CONST CHAR16 *FileName)
Definition: DrvCfg.c:163
EFI_STATUS ConvertHandleToHiiHandle(IN CONST EFI_HANDLE Handle, OUT EFI_HII_HANDLE *HiiHandle, IN EFI_HII_DATABASE_PROTOCOL *HiiDb)
Definition: DrvCfg.c:128
SHELL_STATUS PrintConfigInfoOnAll(IN CONST BOOLEAN ChildrenToo, IN CONST CHAR8 *Language, IN CONST BOOLEAN UseHii)
Definition: DrvCfg.c:1183
EFI_STATUS FindHiiHandleViaDevPath(IN CONST EFI_DEVICE_PATH_PROTOCOL *DevPath1, OUT EFI_HII_HANDLE *HiiHandle, IN EFI_HII_DATABASE_PROTOCOL *HiiDb)
Definition: DrvCfg.c:27
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STATUS EFIAPI ParseHandleDatabaseByRelationshipWithType(IN CONST EFI_HANDLE DriverBindingHandle OPTIONAL, IN CONST EFI_HANDLE ControllerHandle OPTIONAL, IN UINTN *HandleCount, OUT EFI_HANDLE **HandleBuffer, OUT UINTN **HandleType)
EFI_HANDLE EFIAPI ConvertHandleIndexToHandle(IN CONST UINTN TheIndex)
UINTN EFIAPI ConvertHandleToHandleIndex(IN CONST EFI_HANDLE TheHandle)
EFI_HANDLE *EFIAPI GetHandleListByProtocolList(IN CONST EFI_GUID **ProtocolGuids)
EFI_HANDLE *EFIAPI GetHandleListByProtocol(IN CONST EFI_GUID *ProtocolGuid OPTIONAL)
UINTN EFIAPI AsciiSPrint(OUT CHAR8 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR8 *FormatString,...)
Definition: PrintLib.c:813
EFI_RUNTIME_SERVICES * gRT
#define NULL
Definition: Base.h:319
#define CONST
Definition: Base.h:259
#define STATIC
Definition: Base.h:264
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define OUT
Definition: Base.h:284
#define ASSERT_EFI_ERROR(StatusParameter)
Definition: DebugLib.h:462
SHELL_STATUS
Definition: Shell.h:21
@ SHELL_OUT_OF_RESOURCES
Definition: Shell.h:73
@ SHELL_SUCCESS
Definition: Shell.h:25
@ SHELL_NOT_FOUND
Definition: Shell.h:101
@ SHELL_UNSUPPORTED
Definition: Shell.h:40
@ SHELL_DEVICE_ERROR
Definition: Shell.h:63
@ SHELL_INVALID_PARAMETER
Definition: Shell.h:35
EFI_STATUS EFIAPI Set(IN EMBEDDED_GPIO *This, IN EMBEDDED_GPIO_PIN Gpio, IN EMBEDDED_GPIO_MODE Mode)
Definition: PL061Gpio.c:219
VOID *EFIAPI AllocatePool(IN UINTN AllocationSize)
EFI_STATUS EFIAPI CommandInit(VOID)
EFI_STATUS EFIAPI ShellGetFileSize(IN SHELL_FILE_HANDLE FileHandle, OUT UINT64 *Size)
CONST CHAR16 *EFIAPI ShellCommandLineGetValue(IN CONST LIST_ENTRY *CheckPackage, IN CHAR16 *KeyString)
#define ShellCommandLineParse(CheckList, CheckPackage, ProblemParam, AutoPageBreak)
Make it easy to upgrade from older versions of the shell library.
Definition: ShellLib.h:755
EFI_STATUS EFIAPI ShellPrintHiiEx(IN INT32 Col OPTIONAL, IN INT32 Row OPTIONAL, IN CONST CHAR8 *Language OPTIONAL, IN CONST EFI_STRING_ID HiiFormatStringId, IN CONST EFI_HII_HANDLE HiiFormatHandle,...)
BOOLEAN EFIAPI ShellCommandLineGetFlag(IN CONST LIST_ENTRY *CONST CheckPackage, IN CONST CHAR16 *CONST KeyString)
@ TypeValue
A flag that has some data following it with a space (IE "-a 1").
Definition: ShellLib.h:700
@ TypeFlag
A flag that is present or not present only (IE "-a").
Definition: ShellLib.h:699
EFI_STATUS EFIAPI ShellOpenFileByName(IN CONST CHAR16 *FileName, OUT SHELL_FILE_HANDLE *FileHandle, IN UINT64 OpenMode, IN UINT64 Attributes)
Definition: UefiShellLib.c:720
EFI_STATUS EFIAPI ShellPromptForResponse(IN SHELL_PROMPT_REQUEST_TYPE Type, IN CHAR16 *Prompt OPTIONAL, IN OUT VOID **Response OPTIONAL)
EFI_STATUS EFIAPI ShellFileExists(IN CONST CHAR16 *Name)
VOID EFIAPI ShellCommandLineFreeVarList(IN LIST_ENTRY *CheckPackage)
EFI_STATUS EFIAPI ShellInitialize(VOID)
Definition: UefiShellLib.c:532
CONST CHAR16 *EFIAPI ShellCommandLineGetRawValue(IN CONST LIST_ENTRY *CONST CheckPackage, IN UINTN Position)
UINTN EFIAPI ShellCommandLineGetCount(IN CONST LIST_ENTRY *CheckPackage)
EFI_STATUS EFIAPI ShellConvertStringToUint64(IN CONST CHAR16 *String, OUT UINT64 *Value, IN CONST BOOLEAN ForceHex, IN CONST BOOLEAN StopAtSpace)
EFI_STATUS EFIAPI ShellWriteFile(IN SHELL_FILE_HANDLE FileHandle, IN OUT UINTN *BufferSize, IN VOID *Buffer)
Definition: UefiShellLib.c:947
EFI_STATUS EFIAPI ShellCloseFile(IN SHELL_FILE_HANDLE *FileHandle)
Definition: UefiShellLib.c:969
EFI_STATUS EFIAPI ShellReadFile(IN SHELL_FILE_HANDLE FileHandle, IN OUT UINTN *ReadSize, OUT VOID *Buffer)
Definition: UefiShellLib.c:912
INTN EFIAPI DevicePathCompare(IN CONST VOID *Buffer1, IN CONST VOID *Buffer2)
Definition: BaseSortLib.c:73
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
EFI_SYSTEM_TABLE * gST
EFI_HANDLE gImageHandle
EFI_BOOT_SERVICES * gBS
#define STRING_TOKEN(t)
VOID * EFI_HII_HANDLE
UINTN EFIAPI Print(IN CONST CHAR16 *Format,...)
Definition: UefiLibPrint.c:113
CHAR8 *EFIAPI GetBestLanguage(IN CONST CHAR8 *SupportedLanguages, IN UINTN Iso639Language,...)
Definition: UefiLib.c:1522
@ EfiResetCold
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
Definition: UefiSpec.h:2064
Definition: Base.h:213