TianoCore EDK2 master
Loading...
Searching...
No Matches
BootOption.c
Go to the documentation of this file.
1
14
18#define MAX_CHAR 480
19
25VOID
27 VOID
28 )
29{
30 EFI_INPUT_KEY Key;
31 CHAR16 *StringBuffer1;
32 CHAR16 *StringBuffer2;
33 EFI_STATUS Status;
35
36 //
37 // Use BrowserEx2 protocol to check whether reset is required.
38 //
39 Status = gBS->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid, NULL, (VOID **)&FormBrowserEx2);
40
41 //
42 // check any reset required change is applied? if yes, reset system
43 //
44 if (!EFI_ERROR (Status) && FormBrowserEx2->IsResetRequired ()) {
45 StringBuffer1 = AllocateZeroPool (MAX_CHAR * sizeof (CHAR16));
46 ASSERT (StringBuffer1 != NULL);
47 StringBuffer2 = AllocateZeroPool (MAX_CHAR * sizeof (CHAR16));
48 ASSERT (StringBuffer2 != NULL);
49 StrCpyS (StringBuffer1, MAX_CHAR, L"Configuration changed. Reset to apply it Now.");
50 StrCpyS (StringBuffer2, MAX_CHAR, L"Press ENTER to reset");
51 //
52 // Popup a menu to notice user
53 //
54 do {
55 CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuffer1, StringBuffer2, NULL);
56 } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
57
58 FreePool (StringBuffer1);
59 FreePool (StringBuffer2);
60
61 gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);
62 }
63}
64
76 UINTN MenuType
77 )
78{
79 BM_MENU_ENTRY *MenuEntry;
80 UINTN ContextSize;
81
82 //
83 // Get context size according to menu type
84 //
85 switch (MenuType) {
86 case BM_LOAD_CONTEXT_SELECT:
87 ContextSize = sizeof (BM_LOAD_CONTEXT);
88 break;
89
90 case BM_FILE_CONTEXT_SELECT:
91 ContextSize = sizeof (BM_FILE_CONTEXT);
92 break;
93
94 case BM_CONSOLE_CONTEXT_SELECT:
95 ContextSize = sizeof (BM_CONSOLE_CONTEXT);
96 break;
97
98 case BM_TERMINAL_CONTEXT_SELECT:
99 ContextSize = sizeof (BM_TERMINAL_CONTEXT);
100 break;
101
102 case BM_HANDLE_CONTEXT_SELECT:
103 ContextSize = sizeof (BM_HANDLE_CONTEXT);
104 break;
105
106 default:
107 ContextSize = 0;
108 break;
109 }
110
111 if (ContextSize == 0) {
112 return NULL;
113 }
114
115 //
116 // Create new menu entry
117 //
118 MenuEntry = AllocateZeroPool (sizeof (BM_MENU_ENTRY));
119 if (MenuEntry == NULL) {
120 return NULL;
121 }
122
123 MenuEntry->VariableContext = AllocateZeroPool (ContextSize);
124 if (MenuEntry->VariableContext == NULL) {
125 FreePool (MenuEntry);
126 return NULL;
127 }
128
129 MenuEntry->Signature = BM_MENU_ENTRY_SIGNATURE;
130 MenuEntry->ContextSelection = MenuType;
131 return MenuEntry;
132}
133
140VOID
142 BM_MENU_ENTRY *MenuEntry
143 )
144{
145 BM_LOAD_CONTEXT *LoadContext;
146 BM_FILE_CONTEXT *FileContext;
147 BM_CONSOLE_CONTEXT *ConsoleContext;
148 BM_TERMINAL_CONTEXT *TerminalContext;
149 BM_HANDLE_CONTEXT *HandleContext;
150
151 //
152 // Select by the type in Menu entry for current context type
153 //
154 switch (MenuEntry->ContextSelection) {
155 case BM_LOAD_CONTEXT_SELECT:
156 LoadContext = (BM_LOAD_CONTEXT *)MenuEntry->VariableContext;
157 FreePool (LoadContext->FilePathList);
158 if (LoadContext->OptionalData != NULL) {
159 FreePool (LoadContext->OptionalData);
160 }
161
162 FreePool (LoadContext);
163 break;
164
165 case BM_FILE_CONTEXT_SELECT:
166 FileContext = (BM_FILE_CONTEXT *)MenuEntry->VariableContext;
167
168 if (!FileContext->IsRoot) {
169 FreePool (FileContext->DevicePath);
170 } else {
171 if (FileContext->FHandle != NULL) {
172 FileContext->FHandle->Close (FileContext->FHandle);
173 }
174 }
175
176 if (FileContext->FileName != NULL) {
177 FreePool (FileContext->FileName);
178 }
179
180 if (FileContext->Info != NULL) {
181 FreePool (FileContext->Info);
182 }
183
184 FreePool (FileContext);
185 break;
186
187 case BM_CONSOLE_CONTEXT_SELECT:
188 ConsoleContext = (BM_CONSOLE_CONTEXT *)MenuEntry->VariableContext;
189 FreePool (ConsoleContext->DevicePath);
190 FreePool (ConsoleContext);
191 break;
192
193 case BM_TERMINAL_CONTEXT_SELECT:
194 TerminalContext = (BM_TERMINAL_CONTEXT *)MenuEntry->VariableContext;
195 FreePool (TerminalContext->DevicePath);
196 FreePool (TerminalContext);
197 break;
198
199 case BM_HANDLE_CONTEXT_SELECT:
200 HandleContext = (BM_HANDLE_CONTEXT *)MenuEntry->VariableContext;
201 FreePool (HandleContext);
202 break;
203
204 default:
205 break;
206 }
207
208 FreePool (MenuEntry->DisplayString);
209 if (MenuEntry->HelpString != NULL) {
210 FreePool (MenuEntry->HelpString);
211 }
212
213 FreePool (MenuEntry);
214}
215
230 BM_MENU_OPTION *MenuOption,
231 UINTN MenuNumber
232 )
233{
234 BM_MENU_ENTRY *NewMenuEntry;
235 UINTN Index;
236 LIST_ENTRY *List;
237
238 ASSERT (MenuNumber < MenuOption->MenuNumber);
239
240 List = MenuOption->Head.ForwardLink;
241 for (Index = 0; Index < MenuNumber; Index++) {
242 List = List->ForwardLink;
243 }
244
245 NewMenuEntry = CR (List, BM_MENU_ENTRY, Link, BM_MENU_ENTRY_SIGNATURE);
246
247 return NewMenuEntry;
248}
249
255VOID
257 BM_MENU_OPTION *FreeMenu
258 )
259{
260 BM_MENU_ENTRY *MenuEntry;
261
262 while (!IsListEmpty (&FreeMenu->Head)) {
263 MenuEntry = CR (
264 FreeMenu->Head.ForwardLink,
266 Link,
267 BM_MENU_ENTRY_SIGNATURE
268 );
269 RemoveEntryList (&MenuEntry->Link);
270 BOpt_DestroyMenuEntry (MenuEntry);
271 }
272
273 FreeMenu->MenuNumber = 0;
274}
275
289 IN BMM_CALLBACK_DATA *CallbackData
290 )
291{
292 UINTN Index;
293 UINT16 BootString[10];
294 UINT8 *LoadOptionFromVar;
295 UINTN BootOptionSize;
296 BOOLEAN BootNextFlag;
297 UINT16 *BootOrderList;
298 UINTN BootOrderListSize;
299 UINT16 *BootNext;
300 UINTN BootNextSize;
301 BM_MENU_ENTRY *NewMenuEntry;
302 BM_LOAD_CONTEXT *NewLoadContext;
303 UINT8 *LoadOptionPtr;
304 UINTN StringSize;
305 UINTN OptionalDataSize;
306 UINT8 *LoadOptionEnd;
307 EFI_DEVICE_PATH_PROTOCOL *DevicePath;
308 UINTN MenuCount;
309 UINT8 *Ptr;
311 UINTN BootOptionCount;
312
313 MenuCount = 0;
314 BootOrderListSize = 0;
315 BootNextSize = 0;
316 BootOrderList = NULL;
317 BootNext = NULL;
318 LoadOptionFromVar = NULL;
321
322 //
323 // Get the BootOrder from the Var
324 //
325 GetEfiGlobalVariable2 (L"BootOrder", (VOID **)&BootOrderList, &BootOrderListSize);
326 if (BootOrderList == NULL) {
327 return EFI_NOT_FOUND;
328 }
329
330 //
331 // Get the BootNext from the Var
332 //
333 GetEfiGlobalVariable2 (L"BootNext", (VOID **)&BootNext, &BootNextSize);
334 if (BootNext != NULL) {
335 if (BootNextSize != sizeof (UINT16)) {
336 FreePool (BootNext);
337 BootNext = NULL;
338 }
339 }
340
341 BootOption = EfiBootManagerGetLoadOptions (&BootOptionCount, LoadOptionTypeBoot);
342 for (Index = 0; Index < BootOrderListSize / sizeof (UINT16); Index++) {
343 //
344 // Don't display the hidden/inactive boot option
345 //
346 if (((BootOption[Index].Attributes & LOAD_OPTION_HIDDEN) != 0) || ((BootOption[Index].Attributes & LOAD_OPTION_ACTIVE) == 0)) {
347 continue;
348 }
349
350 UnicodeSPrint (BootString, sizeof (BootString), L"Boot%04x", BootOrderList[Index]);
351 //
352 // Get all loadoptions from the VAR
353 //
354 GetEfiGlobalVariable2 (BootString, (VOID **)&LoadOptionFromVar, &BootOptionSize);
355 if (LoadOptionFromVar == NULL) {
356 continue;
357 }
358
359 if (BootNext != NULL) {
360 BootNextFlag = (BOOLEAN)(*BootNext == BootOrderList[Index]);
361 } else {
362 BootNextFlag = FALSE;
363 }
364
365 NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);
366 ASSERT (NULL != NewMenuEntry);
367
368 NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
369
370 LoadOptionPtr = LoadOptionFromVar;
371 LoadOptionEnd = LoadOptionFromVar + BootOptionSize;
372
373 NewMenuEntry->OptionNumber = BootOrderList[Index];
374 NewLoadContext->Deleted = FALSE;
375 NewLoadContext->IsBootNext = BootNextFlag;
376
377 //
378 // Is a Legacy Device?
379 //
380 Ptr = (UINT8 *)LoadOptionFromVar;
381
382 //
383 // Attribute = *(UINT32 *)Ptr;
384 //
385 Ptr += sizeof (UINT32);
386
387 //
388 // FilePathSize = *(UINT16 *)Ptr;
389 //
390 Ptr += sizeof (UINT16);
391
392 //
393 // Description = (CHAR16 *)Ptr;
394 //
395 Ptr += StrSize ((CHAR16 *)Ptr);
396
397 //
398 // Now Ptr point to Device Path
399 //
400 DevicePath = (EFI_DEVICE_PATH_PROTOCOL *)Ptr;
401 if ((BBS_DEVICE_PATH == DevicePath->Type) && (BBS_BBS_DP == DevicePath->SubType)) {
402 NewLoadContext->IsLegacy = TRUE;
403 } else {
404 NewLoadContext->IsLegacy = FALSE;
405 }
406
407 //
408 // LoadOption is a pointer type of UINT8
409 // for easy use with following LOAD_OPTION
410 // embedded in this struct
411 //
412
413 NewLoadContext->Attributes = *(UINT32 *)LoadOptionPtr;
414
415 LoadOptionPtr += sizeof (UINT32);
416
417 NewLoadContext->FilePathListLength = *(UINT16 *)LoadOptionPtr;
418 LoadOptionPtr += sizeof (UINT16);
419
420 StringSize = StrSize ((UINT16 *)LoadOptionPtr);
421
422 NewLoadContext->Description = AllocateZeroPool (StrSize ((UINT16 *)LoadOptionPtr));
423 ASSERT (NewLoadContext->Description != NULL);
424 StrCpyS (NewLoadContext->Description, StrSize ((UINT16 *)LoadOptionPtr) / sizeof (UINT16), (UINT16 *)LoadOptionPtr);
425
426 ASSERT (NewLoadContext->Description != NULL);
427 NewMenuEntry->DisplayString = NewLoadContext->Description;
428 NewMenuEntry->DisplayStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL);
429
430 LoadOptionPtr += StringSize;
431
432 NewLoadContext->FilePathList = AllocateZeroPool (NewLoadContext->FilePathListLength);
433 ASSERT (NewLoadContext->FilePathList != NULL);
434 CopyMem (
435 NewLoadContext->FilePathList,
436 (EFI_DEVICE_PATH_PROTOCOL *)LoadOptionPtr,
437 NewLoadContext->FilePathListLength
438 );
439
440 NewMenuEntry->HelpString = UiDevicePathToStr (NewLoadContext->FilePathList);
441 NewMenuEntry->HelpStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->HelpString, NULL);
442
443 LoadOptionPtr += NewLoadContext->FilePathListLength;
444
445 if (LoadOptionPtr < LoadOptionEnd) {
446 OptionalDataSize = BootOptionSize -
447 sizeof (UINT32) -
448 sizeof (UINT16) -
449 StringSize -
450 NewLoadContext->FilePathListLength;
451
452 NewLoadContext->OptionalData = AllocateZeroPool (OptionalDataSize);
453 ASSERT (NewLoadContext->OptionalData != NULL);
454 CopyMem (
455 NewLoadContext->OptionalData,
456 LoadOptionPtr,
457 OptionalDataSize
458 );
459 }
460
461 InsertTailList (&BootOptionMenu.Head, &NewMenuEntry->Link);
462 MenuCount++;
463 FreePool (LoadOptionFromVar);
464 }
465
466 EfiBootManagerFreeLoadOptions (BootOption, BootOptionCount);
467
468 if (BootNext != NULL) {
469 FreePool (BootNext);
470 }
471
472 if (BootOrderList != NULL) {
473 FreePool (BootOrderList);
474 }
475
476 BootOptionMenu.MenuNumber = MenuCount;
477 return EFI_SUCCESS;
478}
479
493 VOID
494 )
495{
496 UINTN NoDevicePathHandles;
497 EFI_HANDLE *DevicePathHandle;
498 UINTN Index;
499 EFI_STATUS Status;
500 BM_MENU_ENTRY *NewMenuEntry;
501 BM_HANDLE_CONTEXT *NewHandleContext;
502 EFI_HANDLE CurHandle;
503 UINTN OptionNumber;
505 EFI_LOAD_FILE_PROTOCOL *LoadFile;
506
507 SimpleFs = NULL;
508 LoadFile = NULL;
509
511
512 //
513 // At first, get all handles that support Device Path
514 // protocol which is the basic requirement for
515 // Driver####
516 //
517 Status = gBS->LocateHandleBuffer (
519 &gEfiDevicePathProtocolGuid,
520 NULL,
521 &NoDevicePathHandles,
522 &DevicePathHandle
523 );
524 if (EFI_ERROR (Status)) {
525 return Status;
526 }
527
528 OptionNumber = 0;
529 for (Index = 0; Index < NoDevicePathHandles; Index++) {
530 CurHandle = DevicePathHandle[Index];
531
532 Status = gBS->HandleProtocol (
533 CurHandle,
534 &gEfiSimpleFileSystemProtocolGuid,
535 (VOID **)&SimpleFs
536 );
537 if (Status == EFI_SUCCESS) {
538 continue;
539 }
540
541 Status = gBS->HandleProtocol (
542 CurHandle,
543 &gEfiLoadFileProtocolGuid,
544 (VOID **)&LoadFile
545 );
546 if (Status == EFI_SUCCESS) {
547 continue;
548 }
549
550 NewMenuEntry = BOpt_CreateMenuEntry (BM_HANDLE_CONTEXT_SELECT);
551 if (NULL == NewMenuEntry) {
552 FreePool (DevicePathHandle);
553 return EFI_OUT_OF_RESOURCES;
554 }
555
556 NewHandleContext = (BM_HANDLE_CONTEXT *)NewMenuEntry->VariableContext;
557 NewHandleContext->Handle = CurHandle;
558 NewHandleContext->DevicePath = DevicePathFromHandle (CurHandle);
559 NewMenuEntry->DisplayString = UiDevicePathToStr (NewHandleContext->DevicePath);
560 NewMenuEntry->DisplayStringToken = HiiSetString (mBmmCallbackInfo->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL);
561 NewMenuEntry->HelpString = NULL;
562 NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;
563 NewMenuEntry->OptionNumber = OptionNumber;
564 OptionNumber++;
565 InsertTailList (&DriverMenu.Head, &NewMenuEntry->Link);
566 }
567
568 if (DevicePathHandle != NULL) {
569 FreePool (DevicePathHandle);
570 }
571
572 DriverMenu.MenuNumber = OptionNumber;
573 return EFI_SUCCESS;
574}
575
585UINT16
587 CHAR16 *Type
588 )
589{
590 UINT16 *OrderList;
591 UINTN OrderListSize;
592 UINTN Index;
593 CHAR16 StrTemp[20];
594 UINT16 *OptionBuffer;
595 UINT16 OptionNumber;
596 UINTN OptionSize;
597
598 OrderListSize = 0;
599 OrderList = NULL;
600 OptionNumber = 0;
601 Index = 0;
602
603 UnicodeSPrint (StrTemp, sizeof (StrTemp), L"%sOrder", Type);
604
605 GetEfiGlobalVariable2 (StrTemp, (VOID **)&OrderList, &OrderListSize);
606 for (OptionNumber = 0; ; OptionNumber++) {
607 if (OrderList != NULL) {
608 for (Index = 0; Index < OrderListSize / sizeof (UINT16); Index++) {
609 if (OptionNumber == OrderList[Index]) {
610 break;
611 }
612 }
613 }
614
615 if (Index < OrderListSize / sizeof (UINT16)) {
616 //
617 // The OptionNumber occurs in the OrderList, continue to use next one
618 //
619 continue;
620 }
621
622 UnicodeSPrint (StrTemp, sizeof (StrTemp), L"%s%04x", Type, (UINTN)OptionNumber);
623 DEBUG ((DEBUG_ERROR, "Option = %s\n", StrTemp));
624 GetEfiGlobalVariable2 (StrTemp, (VOID **)&OptionBuffer, &OptionSize);
625 if (NULL == OptionBuffer) {
626 //
627 // The Boot[OptionNumber] / Driver[OptionNumber] NOT occurs, we found it
628 //
629 break;
630 }
631 }
632
633 return OptionNumber;
634}
635
643UINT16
645 VOID
646 )
647{
648 return BOpt_GetOptionNumber (L"Boot");
649}
650
658UINT16
660 VOID
661 )
662{
663 return BOpt_GetOptionNumber (L"Driver");
664}
665
679 IN BMM_CALLBACK_DATA *CallbackData
680 )
681{
682 UINTN Index;
683 UINT16 DriverString[12];
684 UINT8 *LoadOptionFromVar;
685 UINTN DriverOptionSize;
686
687 UINT16 *DriverOrderList;
688 UINTN DriverOrderListSize;
689 BM_MENU_ENTRY *NewMenuEntry;
690 BM_LOAD_CONTEXT *NewLoadContext;
691 UINT8 *LoadOptionPtr;
692 UINTN StringSize;
693 UINTN OptionalDataSize;
694 UINT8 *LoadOptionEnd;
695
696 DriverOrderListSize = 0;
697 DriverOrderList = NULL;
698 DriverOptionSize = 0;
699 LoadOptionFromVar = NULL;
702 //
703 // Get the DriverOrder from the Var
704 //
705 GetEfiGlobalVariable2 (L"DriverOrder", (VOID **)&DriverOrderList, &DriverOrderListSize);
706 if (DriverOrderList == NULL) {
707 return EFI_NOT_FOUND;
708 }
709
710 for (Index = 0; Index < DriverOrderListSize / sizeof (UINT16); Index++) {
712 DriverString,
713 sizeof (DriverString),
714 L"Driver%04x",
715 DriverOrderList[Index]
716 );
717 //
718 // Get all loadoptions from the VAR
719 //
720 GetEfiGlobalVariable2 (DriverString, (VOID **)&LoadOptionFromVar, &DriverOptionSize);
721 if (LoadOptionFromVar == NULL) {
722 continue;
723 }
724
725 NewMenuEntry = BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT);
726 if (NULL == NewMenuEntry) {
727 return EFI_OUT_OF_RESOURCES;
728 }
729
730 NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
731 LoadOptionPtr = LoadOptionFromVar;
732 LoadOptionEnd = LoadOptionFromVar + DriverOptionSize;
733 NewMenuEntry->OptionNumber = DriverOrderList[Index];
734 NewLoadContext->Deleted = FALSE;
735 NewLoadContext->IsLegacy = FALSE;
736
737 //
738 // LoadOption is a pointer type of UINT8
739 // for easy use with following LOAD_OPTION
740 // embedded in this struct
741 //
742
743 NewLoadContext->Attributes = *(UINT32 *)LoadOptionPtr;
744
745 LoadOptionPtr += sizeof (UINT32);
746
747 NewLoadContext->FilePathListLength = *(UINT16 *)LoadOptionPtr;
748 LoadOptionPtr += sizeof (UINT16);
749
750 StringSize = StrSize ((UINT16 *)LoadOptionPtr);
751 NewLoadContext->Description = AllocateZeroPool (StringSize);
752 ASSERT (NewLoadContext->Description != NULL);
753 CopyMem (
754 NewLoadContext->Description,
755 (UINT16 *)LoadOptionPtr,
756 StringSize
757 );
758 NewMenuEntry->DisplayString = NewLoadContext->Description;
759 NewMenuEntry->DisplayStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->DisplayString, NULL);
760
761 LoadOptionPtr += StringSize;
762
763 NewLoadContext->FilePathList = AllocateZeroPool (NewLoadContext->FilePathListLength);
764 ASSERT (NewLoadContext->FilePathList != NULL);
765 CopyMem (
766 NewLoadContext->FilePathList,
767 (EFI_DEVICE_PATH_PROTOCOL *)LoadOptionPtr,
768 NewLoadContext->FilePathListLength
769 );
770
771 NewMenuEntry->HelpString = UiDevicePathToStr (NewLoadContext->FilePathList);
772 NewMenuEntry->HelpStringToken = HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->HelpString, NULL);
773
774 LoadOptionPtr += NewLoadContext->FilePathListLength;
775
776 if (LoadOptionPtr < LoadOptionEnd) {
777 OptionalDataSize = DriverOptionSize -
778 sizeof (UINT32) -
779 sizeof (UINT16) -
780 StringSize -
781 NewLoadContext->FilePathListLength;
782
783 NewLoadContext->OptionalData = AllocateZeroPool (OptionalDataSize);
784 ASSERT (NewLoadContext->OptionalData != NULL);
785 CopyMem (
786 NewLoadContext->OptionalData,
787 LoadOptionPtr,
788 OptionalDataSize
789 );
790 }
791
792 InsertTailList (&DriverOptionMenu.Head, &NewMenuEntry->Link);
793 FreePool (LoadOptionFromVar);
794 }
795
796 if (DriverOrderList != NULL) {
797 FreePool (DriverOrderList);
798 }
799
800 DriverOptionMenu.MenuNumber = Index;
801 return EFI_SUCCESS;
802}
803
810VOID
812 IN BMM_CALLBACK_DATA *CallbackData
813 )
814{
815 BMM_FAKE_NV_DATA *BmmConfig;
816 UINT16 Index;
817 UINT16 OptionOrderIndex;
818 UINTN DeviceType;
819 BM_MENU_ENTRY *NewMenuEntry;
820 BM_LOAD_CONTEXT *NewLoadContext;
821
822 ASSERT (CallbackData != NULL);
823
824 DeviceType = (UINTN)-1;
825 BmmConfig = &CallbackData->BmmFakeNvData;
826 ZeroMem (BmmConfig->BootOptionOrder, sizeof (BmmConfig->BootOptionOrder));
827
828 for (Index = 0, OptionOrderIndex = 0; ((Index < BootOptionMenu.MenuNumber) &&
829 (OptionOrderIndex < (sizeof (BmmConfig->BootOptionOrder) / sizeof (BmmConfig->BootOptionOrder[0]))));
830 Index++)
831 {
832 NewMenuEntry = BOpt_GetMenuEntry (&BootOptionMenu, Index);
833 NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
834
835 if (NewLoadContext->IsLegacy) {
836 if (((BBS_BBS_DEVICE_PATH *)NewLoadContext->FilePathList)->DeviceType != DeviceType) {
837 DeviceType = ((BBS_BBS_DEVICE_PATH *)NewLoadContext->FilePathList)->DeviceType;
838 } else {
839 //
840 // Only show one legacy boot option for the same device type
841 // assuming the boot options are grouped by the device type
842 //
843 continue;
844 }
845 }
846
847 BmmConfig->BootOptionOrder[OptionOrderIndex++] = (UINT32)(NewMenuEntry->OptionNumber + 1);
848 }
849}
850
857VOID
859 IN BMM_CALLBACK_DATA *CallbackData
860 )
861{
862 BMM_FAKE_NV_DATA *BmmConfig;
863 UINT16 Index;
864 UINT16 OptionOrderIndex;
865 UINTN DeviceType;
866 BM_MENU_ENTRY *NewMenuEntry;
867 BM_LOAD_CONTEXT *NewLoadContext;
868
869 ASSERT (CallbackData != NULL);
870
871 DeviceType = (UINTN)-1;
872 BmmConfig = &CallbackData->BmmFakeNvData;
873 ZeroMem (BmmConfig->DriverOptionOrder, sizeof (BmmConfig->DriverOptionOrder));
874
875 for (Index = 0, OptionOrderIndex = 0; ((Index < DriverOptionMenu.MenuNumber) &&
876 (OptionOrderIndex < (sizeof (BmmConfig->DriverOptionOrder) / sizeof (BmmConfig->DriverOptionOrder[0]))));
877 Index++)
878 {
879 NewMenuEntry = BOpt_GetMenuEntry (&DriverOptionMenu, Index);
880 NewLoadContext = (BM_LOAD_CONTEXT *)NewMenuEntry->VariableContext;
881
882 if (NewLoadContext->IsLegacy) {
883 if (((BBS_BBS_DEVICE_PATH *)NewLoadContext->FilePathList)->DeviceType != DeviceType) {
884 DeviceType = ((BBS_BBS_DEVICE_PATH *)NewLoadContext->FilePathList)->DeviceType;
885 } else {
886 //
887 // Only show one legacy boot option for the same device type
888 // assuming the boot options are grouped by the device type
889 //
890 continue;
891 }
892 }
893
894 BmmConfig->DriverOptionOrder[OptionOrderIndex++] = (UINT32)(NewMenuEntry->OptionNumber + 1);
895 }
896}
897
906BOOLEAN
907EFIAPI
910 )
911{
912 EFI_STATUS Status;
914 CHAR16 *FileName;
915
916 Status = EFI_NOT_STARTED;
917 FileName = NULL;
918
919 FileName = ExtractFileNameFromDevicePath (FilePath);
920 if (FileName != NULL) {
922 &BootOption,
923 0,
924 LoadOptionTypeBoot,
925 LOAD_OPTION_ACTIVE,
926 FileName,
927 FilePath,
928 NULL,
929 0
930 );
931 }
932
933 if (!EFI_ERROR (Status)) {
934 //
935 // Since current no boot from removable media directly is allowed */
936 //
937 gST->ConOut->ClearScreen (gST->ConOut);
938 //
939 // Check whether need to reset system.
940 //
942
944 EfiBootManagerBoot (&BootOption);
946
947 FreePool (FileName);
948
949 EfiBootManagerFreeLoadOption (&BootOption);
950 }
951
952 return FALSE;
953}
954
962BOOLEAN
965 IN EFI_FORM_ID FormId
966 )
967{
968 gBootMaintenancePrivate.LoadContext->FilePathList = FilePath;
969
970 UpdateOptionPage (&gBootMaintenancePrivate, FormId, FilePath);
971
972 gBootMaintenancePrivate.FormBrowser2->SendForm (
973 gBootMaintenancePrivate.FormBrowser2,
974 &gBootMaintenancePrivate.BmmHiiHandle,
975 1,
976 &mBootMaintGuid,
977 FormId,
978 NULL,
979 NULL
980 );
981 return TRUE;
982}
983
992BOOLEAN
993EFIAPI
996 )
997{
998 return ReSendForm (FilePath, FORM_BOOT_ADD_ID);
999}
1000
1010BOOLEAN
1011EFIAPI
1014 )
1015{
1016 return ReSendForm (FilePath, FORM_DRV_ADD_FILE_ID);
1017}
UINT64 UINTN
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
Definition: String.c:72
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
Definition: LinkedList.c:403
RETURN_STATUS EFIAPI StrCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
Definition: SafeString.c:226
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
Definition: LinkedList.c:590
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
Definition: LinkedList.c:182
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
Definition: LinkedList.c:259
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI ZeroMem(OUT VOID *Buffer, IN UINTN Length)
CHAR16 * UiDevicePathToStr(IN EFI_DEVICE_PATH_PROTOCOL *DevPath)
CHAR16 * ExtractFileNameFromDevicePath(IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
EFI_STATUS BmmSetConsoleMode(BOOLEAN IsSetupMode)
BM_MENU_OPTION DriverMenu
Definition: Data.c:92
BM_MENU_OPTION DriverOptionMenu
Definition: Data.c:83
BM_MENU_OPTION BootOptionMenu
Definition: Data.c:74
VOID UpdateOptionPage(IN BMM_CALLBACK_DATA *CallbackData, IN EFI_FORM_ID FormId, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
Definition: UpdatePage.c:1035
VOID BOpt_FreeMenu(BM_MENU_OPTION *FreeMenu)
Definition: BootOption.c:256
UINT16 BOpt_GetOptionNumber(CHAR16 *Type)
Definition: BootOption.c:586
BM_MENU_ENTRY * BOpt_GetMenuEntry(BM_MENU_OPTION *MenuOption, UINTN MenuNumber)
Definition: BootOption.c:229
UINT16 BOpt_GetDriverOptionNumber(VOID)
Definition: BootOption.c:659
VOID BmmSetupResetReminder(VOID)
Definition: BootOption.c:26
BOOLEAN ReSendForm(IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN EFI_FORM_ID FormId)
Definition: BootOption.c:963
VOID BOpt_DestroyMenuEntry(BM_MENU_ENTRY *MenuEntry)
Definition: BootOption.c:141
BM_MENU_ENTRY * BOpt_CreateMenuEntry(UINTN MenuType)
Definition: BootOption.c:75
EFI_STATUS BOpt_GetDriverOptions(IN BMM_CALLBACK_DATA *CallbackData)
Definition: BootOption.c:678
BOOLEAN EFIAPI CreateDriverOptionFromFile(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
Definition: BootOption.c:1012
#define MAX_CHAR
Definition: BootOption.c:18
UINT16 BOpt_GetBootOptionNumber(VOID)
Definition: BootOption.c:644
BOOLEAN EFIAPI CreateBootOptionFromFile(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
Definition: BootOption.c:994
EFI_STATUS BOpt_FindDrivers(VOID)
Definition: BootOption.c:492
VOID GetBootOrder(IN BMM_CALLBACK_DATA *CallbackData)
Definition: BootOption.c:811
VOID GetDriverOrder(IN BMM_CALLBACK_DATA *CallbackData)
Definition: BootOption.c:858
BOOLEAN EFIAPI BootFromFile(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
Definition: BootOption.c:908
EFI_STATUS BOpt_GetBootOptions(IN BMM_CALLBACK_DATA *CallbackData)
Definition: BootOption.c:288
#define BBS_BBS_DP
Definition: DevicePath.h:1238
#define BBS_DEVICE_PATH
Definition: DevicePath.h:1233
EFI_DEVICE_PATH_PROTOCOL *EFIAPI DevicePathFromHandle(IN EFI_HANDLE Handle)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
EFI_STRING_ID EFIAPI HiiSetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId OPTIONAL, IN CONST EFI_STRING String, IN CONST CHAR8 *SupportedLanguages OPTIONAL)
Definition: HiiString.c:52
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
Definition: PrintLib.c:408
EFI_RUNTIME_SERVICES * gRT
#define NULL
Definition: Base.h:319
#define TRUE
Definition: Base.h:301
#define FALSE
Definition: Base.h:307
#define IN
Definition: Base.h:279
#define DEBUG(Expression)
Definition: DebugLib.h:434
#define CR(Record, TYPE, Field, TestSignature)
Definition: DebugLib.h:659
RETURN_STATUS EFI_STATUS
Definition: UefiBaseType.h:29
VOID * EFI_HANDLE
Definition: UefiBaseType.h:33
#define EFI_SUCCESS
Definition: UefiBaseType.h:112
VOID EFIAPI EfiBootManagerBoot(IN EFI_BOOT_MANAGER_LOAD_OPTION *BootOption)
Definition: BmBoot.c:1846
EFI_STATUS EFIAPI EfiBootManagerFreeLoadOption(IN EFI_BOOT_MANAGER_LOAD_OPTION *LoadOption)
EFI_BOOT_MANAGER_LOAD_OPTION *EFIAPI EfiBootManagerGetLoadOptions(OUT UINTN *LoadOptionCount, IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE LoadOptionType)
EFI_STATUS EFIAPI EfiBootManagerFreeLoadOptions(IN EFI_BOOT_MANAGER_LOAD_OPTION *LoadOptions, IN UINTN LoadOptionCount)
EFI_STATUS EFIAPI EfiBootManagerInitializeLoadOption(IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *Option, IN UINTN OptionNumber, IN EFI_BOOT_MANAGER_LOAD_OPTION_TYPE OptionType, IN UINT32 Attributes, IN CHAR16 *Description, IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN UINT8 *OptionalData, IN UINT32 OptionalDataSize)
EFI_SYSTEM_TABLE * gST
EFI_BOOT_SERVICES * gBS
EFI_STATUS EFIAPI GetEfiGlobalVariable2(IN CONST CHAR16 *Name, OUT VOID **Value, OUT UINTN *Size OPTIONAL)
Definition: UefiLib.c:1470
VOID EFIAPI CreatePopUp(IN UINTN Attribute, OUT EFI_INPUT_KEY *Key OPTIONAL,...)
Definition: Console.c:393
@ EfiResetCold
@ ByProtocol
Definition: UefiSpec.h:1518
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut
Definition: UefiSpec.h:2064