2 Provide boot option support for Application "BootMaint"
4 Include file system navigation, system handle selection
6 Boot option manipulation
8 Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
9 This program and the accompanying materials
10 are licensed and made available under the terms and conditions of the BSD License
11 which accompanies this distribution. The full text of the license may be found at
12 http://opensource.org/licenses/bsd-license.php
14 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
15 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
19 #include "BootMaintenanceManager.h"
22 /// Define the maximum characters that will be accepted.
27 Create a menu entry by given menu type.
29 @param MenuType The Menu type to be created.
31 @retval NULL If failed to create the menu.
32 @return the new menu entry.
36 BOpt_CreateMenuEntry (
40 BM_MENU_ENTRY
*MenuEntry
;
44 // Get context size according to menu type
47 case BM_LOAD_CONTEXT_SELECT
:
48 ContextSize
= sizeof (BM_LOAD_CONTEXT
);
51 case BM_FILE_CONTEXT_SELECT
:
52 ContextSize
= sizeof (BM_FILE_CONTEXT
);
55 case BM_CONSOLE_CONTEXT_SELECT
:
56 ContextSize
= sizeof (BM_CONSOLE_CONTEXT
);
59 case BM_TERMINAL_CONTEXT_SELECT
:
60 ContextSize
= sizeof (BM_TERMINAL_CONTEXT
);
63 case BM_HANDLE_CONTEXT_SELECT
:
64 ContextSize
= sizeof (BM_HANDLE_CONTEXT
);
72 if (ContextSize
== 0) {
77 // Create new menu entry
79 MenuEntry
= AllocateZeroPool (sizeof (BM_MENU_ENTRY
));
80 if (MenuEntry
== NULL
) {
84 MenuEntry
->VariableContext
= AllocateZeroPool (ContextSize
);
85 if (MenuEntry
->VariableContext
== NULL
) {
90 MenuEntry
->Signature
= BM_MENU_ENTRY_SIGNATURE
;
91 MenuEntry
->ContextSelection
= MenuType
;
96 Free up all resource allocated for a BM_MENU_ENTRY.
98 @param MenuEntry A pointer to BM_MENU_ENTRY.
102 BOpt_DestroyMenuEntry (
103 BM_MENU_ENTRY
*MenuEntry
106 BM_LOAD_CONTEXT
*LoadContext
;
107 BM_FILE_CONTEXT
*FileContext
;
108 BM_CONSOLE_CONTEXT
*ConsoleContext
;
109 BM_TERMINAL_CONTEXT
*TerminalContext
;
110 BM_HANDLE_CONTEXT
*HandleContext
;
113 // Select by the type in Menu entry for current context type
115 switch (MenuEntry
->ContextSelection
) {
116 case BM_LOAD_CONTEXT_SELECT
:
117 LoadContext
= (BM_LOAD_CONTEXT
*) MenuEntry
->VariableContext
;
118 FreePool (LoadContext
->FilePathList
);
119 if (LoadContext
->OptionalData
!= NULL
) {
120 FreePool (LoadContext
->OptionalData
);
122 FreePool (LoadContext
);
125 case BM_FILE_CONTEXT_SELECT
:
126 FileContext
= (BM_FILE_CONTEXT
*) MenuEntry
->VariableContext
;
128 if (!FileContext
->IsRoot
) {
129 FreePool (FileContext
->DevicePath
);
131 if (FileContext
->FHandle
!= NULL
) {
132 FileContext
->FHandle
->Close (FileContext
->FHandle
);
136 if (FileContext
->FileName
!= NULL
) {
137 FreePool (FileContext
->FileName
);
139 if (FileContext
->Info
!= NULL
) {
140 FreePool (FileContext
->Info
);
142 FreePool (FileContext
);
145 case BM_CONSOLE_CONTEXT_SELECT
:
146 ConsoleContext
= (BM_CONSOLE_CONTEXT
*) MenuEntry
->VariableContext
;
147 FreePool (ConsoleContext
->DevicePath
);
148 FreePool (ConsoleContext
);
151 case BM_TERMINAL_CONTEXT_SELECT
:
152 TerminalContext
= (BM_TERMINAL_CONTEXT
*) MenuEntry
->VariableContext
;
153 FreePool (TerminalContext
->DevicePath
);
154 FreePool (TerminalContext
);
157 case BM_HANDLE_CONTEXT_SELECT
:
158 HandleContext
= (BM_HANDLE_CONTEXT
*) MenuEntry
->VariableContext
;
159 FreePool (HandleContext
);
166 FreePool (MenuEntry
->DisplayString
);
167 if (MenuEntry
->HelpString
!= NULL
) {
168 FreePool (MenuEntry
->HelpString
);
171 FreePool (MenuEntry
);
175 Get the Menu Entry from the list in Menu Entry List.
177 If MenuNumber is great or equal to the number of Menu
178 Entry in the list, then ASSERT.
180 @param MenuOption The Menu Entry List to read the menu entry.
181 @param MenuNumber The index of Menu Entry.
183 @return The Menu Entry.
188 BM_MENU_OPTION
*MenuOption
,
192 BM_MENU_ENTRY
*NewMenuEntry
;
196 ASSERT (MenuNumber
< MenuOption
->MenuNumber
);
198 List
= MenuOption
->Head
.ForwardLink
;
199 for (Index
= 0; Index
< MenuNumber
; Index
++) {
200 List
= List
->ForwardLink
;
203 NewMenuEntry
= CR (List
, BM_MENU_ENTRY
, Link
, BM_MENU_ENTRY_SIGNATURE
);
209 Free resources allocated in Allocate Rountine.
211 @param FreeMenu Menu to be freed
215 BM_MENU_OPTION
*FreeMenu
218 BM_MENU_ENTRY
*MenuEntry
;
219 while (!IsListEmpty (&FreeMenu
->Head
)) {
221 FreeMenu
->Head
.ForwardLink
,
224 BM_MENU_ENTRY_SIGNATURE
226 RemoveEntryList (&MenuEntry
->Link
);
227 BOpt_DestroyMenuEntry (MenuEntry
);
229 FreeMenu
->MenuNumber
= 0;
234 Build the BootOptionMenu according to BootOrder Variable.
235 This Routine will access the Boot#### to get EFI_LOAD_OPTION.
237 @param CallbackData The BMM context data.
239 @return EFI_NOT_FOUND Fail to find "BootOrder" variable.
240 @return EFI_SUCESS Success build boot option menu.
244 BOpt_GetBootOptions (
245 IN BMM_CALLBACK_DATA
*CallbackData
249 UINT16 BootString
[10];
250 UINT8
*LoadOptionFromVar
;
251 UINTN BootOptionSize
;
252 BOOLEAN BootNextFlag
;
253 UINT16
*BootOrderList
;
254 UINTN BootOrderListSize
;
257 BM_MENU_ENTRY
*NewMenuEntry
;
258 BM_LOAD_CONTEXT
*NewLoadContext
;
259 UINT8
*LoadOptionPtr
;
261 UINTN OptionalDataSize
;
262 UINT8
*LoadOptionEnd
;
263 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
266 EFI_BOOT_MANAGER_LOAD_OPTION
*BootOption
;
267 UINTN BootOptionCount
;
270 BootOrderListSize
= 0;
272 BootOrderList
= NULL
;
274 LoadOptionFromVar
= NULL
;
275 BOpt_FreeMenu (&BootOptionMenu
);
276 InitializeListHead (&BootOptionMenu
.Head
);
279 // Get the BootOrder from the Var
281 GetEfiGlobalVariable2 (L
"BootOrder", (VOID
**) &BootOrderList
, &BootOrderListSize
);
282 if (BootOrderList
== NULL
) {
283 return EFI_NOT_FOUND
;
287 // Get the BootNext from the Var
289 GetEfiGlobalVariable2 (L
"BootNext", (VOID
**) &BootNext
, &BootNextSize
);
290 if (BootNext
!= NULL
) {
291 if (BootNextSize
!= sizeof (UINT16
)) {
296 BootOption
= EfiBootManagerGetLoadOptions (&BootOptionCount
, LoadOptionTypeBoot
);
297 for (Index
= 0; Index
< BootOrderListSize
/ sizeof (UINT16
); Index
++) {
299 // Don't display the hidden/inactive boot option
301 if (((BootOption
[Index
].Attributes
& LOAD_OPTION_HIDDEN
) != 0) || ((BootOption
[Index
].Attributes
& LOAD_OPTION_ACTIVE
) == 0)) {
305 UnicodeSPrint (BootString
, sizeof (BootString
), L
"Boot%04x", BootOrderList
[Index
]);
307 // Get all loadoptions from the VAR
309 GetEfiGlobalVariable2 (BootString
, (VOID
**) &LoadOptionFromVar
, &BootOptionSize
);
310 if (LoadOptionFromVar
== NULL
) {
314 if (BootNext
!= NULL
) {
315 BootNextFlag
= (BOOLEAN
) (*BootNext
== BootOrderList
[Index
]);
317 BootNextFlag
= FALSE
;
320 NewMenuEntry
= BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT
);
321 ASSERT (NULL
!= NewMenuEntry
);
323 NewLoadContext
= (BM_LOAD_CONTEXT
*) NewMenuEntry
->VariableContext
;
325 LoadOptionPtr
= LoadOptionFromVar
;
326 LoadOptionEnd
= LoadOptionFromVar
+ BootOptionSize
;
328 NewMenuEntry
->OptionNumber
= BootOrderList
[Index
];
329 NewLoadContext
->Deleted
= FALSE
;
330 NewLoadContext
->IsBootNext
= BootNextFlag
;
333 // Is a Legacy Device?
335 Ptr
= (UINT8
*) LoadOptionFromVar
;
338 // Attribute = *(UINT32 *)Ptr;
340 Ptr
+= sizeof (UINT32
);
343 // FilePathSize = *(UINT16 *)Ptr;
345 Ptr
+= sizeof (UINT16
);
348 // Description = (CHAR16 *)Ptr;
350 Ptr
+= StrSize ((CHAR16
*) Ptr
);
353 // Now Ptr point to Device Path
355 DevicePath
= (EFI_DEVICE_PATH_PROTOCOL
*) Ptr
;
356 if ((BBS_DEVICE_PATH
== DevicePath
->Type
) && (BBS_BBS_DP
== DevicePath
->SubType
)) {
357 NewLoadContext
->IsLegacy
= TRUE
;
359 NewLoadContext
->IsLegacy
= FALSE
;
362 // LoadOption is a pointer type of UINT8
363 // for easy use with following LOAD_OPTION
364 // embedded in this struct
367 NewLoadContext
->Attributes
= *(UINT32
*) LoadOptionPtr
;
369 LoadOptionPtr
+= sizeof (UINT32
);
371 NewLoadContext
->FilePathListLength
= *(UINT16
*) LoadOptionPtr
;
372 LoadOptionPtr
+= sizeof (UINT16
);
374 StringSize
= StrSize((UINT16
*)LoadOptionPtr
);
376 NewLoadContext
->Description
= AllocateZeroPool (StrSize((UINT16
*)LoadOptionPtr
));
377 ASSERT (NewLoadContext
->Description
!= NULL
);
378 StrCpyS (NewLoadContext
->Description
, StrSize((UINT16
*)LoadOptionPtr
) / sizeof (UINT16
), (UINT16
*)LoadOptionPtr
);
380 ASSERT (NewLoadContext
->Description
!= NULL
);
381 NewMenuEntry
->DisplayString
= NewLoadContext
->Description
;
382 NewMenuEntry
->DisplayStringToken
= HiiSetString (CallbackData
->BmmHiiHandle
, 0, NewMenuEntry
->DisplayString
, NULL
);
384 LoadOptionPtr
+= StringSize
;
386 NewLoadContext
->FilePathList
= AllocateZeroPool (NewLoadContext
->FilePathListLength
);
387 ASSERT (NewLoadContext
->FilePathList
!= NULL
);
389 NewLoadContext
->FilePathList
,
390 (EFI_DEVICE_PATH_PROTOCOL
*) LoadOptionPtr
,
391 NewLoadContext
->FilePathListLength
394 NewMenuEntry
->HelpString
= UiDevicePathToStr (NewLoadContext
->FilePathList
);
395 NewMenuEntry
->HelpStringToken
= HiiSetString (CallbackData
->BmmHiiHandle
, 0, NewMenuEntry
->HelpString
, NULL
);
397 LoadOptionPtr
+= NewLoadContext
->FilePathListLength
;
399 if (LoadOptionPtr
< LoadOptionEnd
) {
400 OptionalDataSize
= BootOptionSize
-
404 NewLoadContext
->FilePathListLength
;
406 NewLoadContext
->OptionalData
= AllocateZeroPool (OptionalDataSize
);
407 ASSERT (NewLoadContext
->OptionalData
!= NULL
);
409 NewLoadContext
->OptionalData
,
415 InsertTailList (&BootOptionMenu
.Head
, &NewMenuEntry
->Link
);
417 FreePool (LoadOptionFromVar
);
419 EfiBootManagerFreeLoadOptions (BootOption
, BootOptionCount
);
421 if (BootNext
!= NULL
) {
424 if (BootOrderList
!= NULL
) {
425 FreePool (BootOrderList
);
428 BootOptionMenu
.MenuNumber
= MenuCount
;
434 Find drivers that will be added as Driver#### variables from handles
435 in current system environment
436 All valid handles in the system except those consume SimpleFs, LoadFile
437 are stored in DriverMenu for future use.
439 @retval EFI_SUCCESS The function complets successfully.
440 @return Other value if failed to build the DriverMenu.
448 UINTN NoDevicePathHandles
;
449 EFI_HANDLE
*DevicePathHandle
;
452 BM_MENU_ENTRY
*NewMenuEntry
;
453 BM_HANDLE_CONTEXT
*NewHandleContext
;
454 EFI_HANDLE CurHandle
;
456 EFI_SIMPLE_FILE_SYSTEM_PROTOCOL
*SimpleFs
;
457 EFI_LOAD_FILE_PROTOCOL
*LoadFile
;
462 InitializeListHead (&DriverMenu
.Head
);
465 // At first, get all handles that support Device Path
466 // protocol which is the basic requirement for
469 Status
= gBS
->LocateHandleBuffer (
471 &gEfiDevicePathProtocolGuid
,
473 &NoDevicePathHandles
,
476 if (EFI_ERROR (Status
)) {
481 for (Index
= 0; Index
< NoDevicePathHandles
; Index
++) {
482 CurHandle
= DevicePathHandle
[Index
];
484 Status
= gBS
->HandleProtocol (
486 &gEfiSimpleFileSystemProtocolGuid
,
489 if (Status
== EFI_SUCCESS
) {
493 Status
= gBS
->HandleProtocol (
495 &gEfiLoadFileProtocolGuid
,
498 if (Status
== EFI_SUCCESS
) {
502 NewMenuEntry
= BOpt_CreateMenuEntry (BM_HANDLE_CONTEXT_SELECT
);
503 if (NULL
== NewMenuEntry
) {
504 FreePool (DevicePathHandle
);
505 return EFI_OUT_OF_RESOURCES
;
508 NewHandleContext
= (BM_HANDLE_CONTEXT
*) NewMenuEntry
->VariableContext
;
509 NewHandleContext
->Handle
= CurHandle
;
510 NewHandleContext
->DevicePath
= DevicePathFromHandle (CurHandle
);
511 NewMenuEntry
->DisplayString
= UiDevicePathToStr (NewHandleContext
->DevicePath
);
512 NewMenuEntry
->DisplayStringToken
= HiiSetString (mBmmCallbackInfo
->BmmHiiHandle
,0,NewMenuEntry
->DisplayString
,NULL
);
513 NewMenuEntry
->HelpString
= NULL
;
514 NewMenuEntry
->HelpStringToken
= NewMenuEntry
->DisplayStringToken
;
515 NewMenuEntry
->OptionNumber
= OptionNumber
;
517 InsertTailList (&DriverMenu
.Head
, &NewMenuEntry
->Link
);
521 if (DevicePathHandle
!= NULL
) {
522 FreePool (DevicePathHandle
);
525 DriverMenu
.MenuNumber
= OptionNumber
;
531 Get the Option Number that has not been allocated for use.
533 @param Type The type of Option.
535 @return The available Option Number.
539 BOpt_GetOptionNumber (
547 UINT16
*OptionBuffer
;
556 UnicodeSPrint (StrTemp
, sizeof (StrTemp
), L
"%sOrder", Type
);
558 GetEfiGlobalVariable2 (StrTemp
, (VOID
**) &OrderList
, &OrderListSize
);
559 for (OptionNumber
= 0; ; OptionNumber
++) {
560 if (OrderList
!= NULL
) {
561 for (Index
= 0; Index
< OrderListSize
/ sizeof (UINT16
); Index
++) {
562 if (OptionNumber
== OrderList
[Index
]) {
568 if (Index
< OrderListSize
/ sizeof (UINT16
)) {
570 // The OptionNumber occurs in the OrderList, continue to use next one
574 UnicodeSPrint (StrTemp
, sizeof (StrTemp
), L
"%s%04x", Type
, (UINTN
) OptionNumber
);
575 DEBUG((EFI_D_ERROR
,"Option = %s\n", StrTemp
));
576 GetEfiGlobalVariable2 (StrTemp
, (VOID
**) &OptionBuffer
, &OptionSize
);
577 if (NULL
== OptionBuffer
) {
579 // The Boot[OptionNumber] / Driver[OptionNumber] NOT occurs, we found it
590 Get the Option Number for Boot#### that does not used.
592 @return The available Option Number.
596 BOpt_GetBootOptionNumber (
600 return BOpt_GetOptionNumber (L
"Boot");
605 Get the Option Number for Driver#### that does not used.
607 @return The unused Option Number.
611 BOpt_GetDriverOptionNumber (
615 return BOpt_GetOptionNumber (L
"Driver");
620 Build up all DriverOptionMenu
622 @param CallbackData The BMM context data.
624 @retval EFI_SUCESS The functin completes successfully.
625 @retval EFI_OUT_OF_RESOURCES Not enough memory to compete the operation.
626 @retval EFI_NOT_FOUND Fail to get "DriverOrder" variable.
630 BOpt_GetDriverOptions (
631 IN BMM_CALLBACK_DATA
*CallbackData
635 UINT16 DriverString
[12];
636 UINT8
*LoadOptionFromVar
;
637 UINTN DriverOptionSize
;
639 UINT16
*DriverOrderList
;
640 UINTN DriverOrderListSize
;
641 BM_MENU_ENTRY
*NewMenuEntry
;
642 BM_LOAD_CONTEXT
*NewLoadContext
;
643 UINT8
*LoadOptionPtr
;
645 UINTN OptionalDataSize
;
646 UINT8
*LoadOptionEnd
;
648 DriverOrderListSize
= 0;
649 DriverOrderList
= NULL
;
650 DriverOptionSize
= 0;
651 LoadOptionFromVar
= NULL
;
652 BOpt_FreeMenu (&DriverOptionMenu
);
653 InitializeListHead (&DriverOptionMenu
.Head
);
655 // Get the DriverOrder from the Var
657 GetEfiGlobalVariable2 (L
"DriverOrder", (VOID
**) &DriverOrderList
, &DriverOrderListSize
);
658 if (DriverOrderList
== NULL
) {
659 return EFI_NOT_FOUND
;
662 for (Index
= 0; Index
< DriverOrderListSize
/ sizeof (UINT16
); Index
++) {
665 sizeof (DriverString
),
667 DriverOrderList
[Index
]
670 // Get all loadoptions from the VAR
672 GetEfiGlobalVariable2 (DriverString
, (VOID
**) &LoadOptionFromVar
, &DriverOptionSize
);
673 if (LoadOptionFromVar
== NULL
) {
678 NewMenuEntry
= BOpt_CreateMenuEntry (BM_LOAD_CONTEXT_SELECT
);
679 if (NULL
== NewMenuEntry
) {
680 return EFI_OUT_OF_RESOURCES
;
683 NewLoadContext
= (BM_LOAD_CONTEXT
*) NewMenuEntry
->VariableContext
;
684 LoadOptionPtr
= LoadOptionFromVar
;
685 LoadOptionEnd
= LoadOptionFromVar
+ DriverOptionSize
;
686 NewMenuEntry
->OptionNumber
= DriverOrderList
[Index
];
687 NewLoadContext
->Deleted
= FALSE
;
688 NewLoadContext
->IsLegacy
= FALSE
;
691 // LoadOption is a pointer type of UINT8
692 // for easy use with following LOAD_OPTION
693 // embedded in this struct
696 NewLoadContext
->Attributes
= *(UINT32
*) LoadOptionPtr
;
698 LoadOptionPtr
+= sizeof (UINT32
);
700 NewLoadContext
->FilePathListLength
= *(UINT16
*) LoadOptionPtr
;
701 LoadOptionPtr
+= sizeof (UINT16
);
703 StringSize
= StrSize ((UINT16
*) LoadOptionPtr
);
704 NewLoadContext
->Description
= AllocateZeroPool (StringSize
);
705 ASSERT (NewLoadContext
->Description
!= NULL
);
707 NewLoadContext
->Description
,
708 (UINT16
*) LoadOptionPtr
,
711 NewMenuEntry
->DisplayString
= NewLoadContext
->Description
;
712 NewMenuEntry
->DisplayStringToken
= HiiSetString (CallbackData
->BmmHiiHandle
, 0, NewMenuEntry
->DisplayString
, NULL
);
714 LoadOptionPtr
+= StringSize
;
716 NewLoadContext
->FilePathList
= AllocateZeroPool (NewLoadContext
->FilePathListLength
);
717 ASSERT (NewLoadContext
->FilePathList
!= NULL
);
719 NewLoadContext
->FilePathList
,
720 (EFI_DEVICE_PATH_PROTOCOL
*) LoadOptionPtr
,
721 NewLoadContext
->FilePathListLength
724 NewMenuEntry
->HelpString
= UiDevicePathToStr (NewLoadContext
->FilePathList
);
725 NewMenuEntry
->HelpStringToken
= HiiSetString (CallbackData
->BmmHiiHandle
, 0, NewMenuEntry
->HelpString
, NULL
);
727 LoadOptionPtr
+= NewLoadContext
->FilePathListLength
;
729 if (LoadOptionPtr
< LoadOptionEnd
) {
730 OptionalDataSize
= DriverOptionSize
-
734 NewLoadContext
->FilePathListLength
;
736 NewLoadContext
->OptionalData
= AllocateZeroPool (OptionalDataSize
);
737 ASSERT (NewLoadContext
->OptionalData
!= NULL
);
739 NewLoadContext
->OptionalData
,
746 InsertTailList (&DriverOptionMenu
.Head
, &NewMenuEntry
->Link
);
747 FreePool (LoadOptionFromVar
);
751 if (DriverOrderList
!= NULL
) {
752 FreePool (DriverOrderList
);
755 DriverOptionMenu
.MenuNumber
= Index
;
761 Get option number according to Boot#### and BootOrder variable.
762 The value is saved as #### + 1.
764 @param CallbackData The BMM context data.
768 IN BMM_CALLBACK_DATA
*CallbackData
771 BMM_FAKE_NV_DATA
*BmmConfig
;
773 UINT16 OptionOrderIndex
;
775 BM_MENU_ENTRY
*NewMenuEntry
;
776 BM_LOAD_CONTEXT
*NewLoadContext
;
778 ASSERT (CallbackData
!= NULL
);
780 DeviceType
= (UINTN
) -1;
781 BmmConfig
= &CallbackData
->BmmFakeNvData
;
782 ZeroMem (BmmConfig
->BootOptionOrder
, sizeof (BmmConfig
->BootOptionOrder
));
784 for (Index
= 0, OptionOrderIndex
= 0; ((Index
< BootOptionMenu
.MenuNumber
) &&
785 (OptionOrderIndex
< (sizeof (BmmConfig
->BootOptionOrder
) / sizeof (BmmConfig
->BootOptionOrder
[0]))));
787 NewMenuEntry
= BOpt_GetMenuEntry (&BootOptionMenu
, Index
);
788 NewLoadContext
= (BM_LOAD_CONTEXT
*) NewMenuEntry
->VariableContext
;
790 if (NewLoadContext
->IsLegacy
) {
791 if (((BBS_BBS_DEVICE_PATH
*) NewLoadContext
->FilePathList
)->DeviceType
!= DeviceType
) {
792 DeviceType
= ((BBS_BBS_DEVICE_PATH
*) NewLoadContext
->FilePathList
)->DeviceType
;
795 // Only show one legacy boot option for the same device type
796 // assuming the boot options are grouped by the device type
801 BmmConfig
->BootOptionOrder
[OptionOrderIndex
++] = (UINT32
) (NewMenuEntry
->OptionNumber
+ 1);
806 Get driver option order from globalc DriverOptionMenu.
808 @param CallbackData The BMM context data.
813 IN BMM_CALLBACK_DATA
*CallbackData
816 BMM_FAKE_NV_DATA
*BmmConfig
;
818 UINT16 OptionOrderIndex
;
820 BM_MENU_ENTRY
*NewMenuEntry
;
821 BM_LOAD_CONTEXT
*NewLoadContext
;
824 ASSERT (CallbackData
!= NULL
);
826 DeviceType
= (UINTN
) -1;
827 BmmConfig
= &CallbackData
->BmmFakeNvData
;
828 ZeroMem (BmmConfig
->DriverOptionOrder
, sizeof (BmmConfig
->DriverOptionOrder
));
830 for (Index
= 0, OptionOrderIndex
= 0; ((Index
< DriverOptionMenu
.MenuNumber
) &&
831 (OptionOrderIndex
< (sizeof (BmmConfig
->DriverOptionOrder
) / sizeof (BmmConfig
->DriverOptionOrder
[0]))));
833 NewMenuEntry
= BOpt_GetMenuEntry (&DriverOptionMenu
, Index
);
834 NewLoadContext
= (BM_LOAD_CONTEXT
*) NewMenuEntry
->VariableContext
;
836 if (NewLoadContext
->IsLegacy
) {
837 if (((BBS_BBS_DEVICE_PATH
*) NewLoadContext
->FilePathList
)->DeviceType
!= DeviceType
) {
838 DeviceType
= ((BBS_BBS_DEVICE_PATH
*) NewLoadContext
->FilePathList
)->DeviceType
;
841 // Only show one legacy boot option for the same device type
842 // assuming the boot options are grouped by the device type
847 BmmConfig
->DriverOptionOrder
[OptionOrderIndex
++] = (UINT32
) (NewMenuEntry
->OptionNumber
+ 1);
852 Boot the file specified by the input file path info.
854 @param FilePath Point to the file path.
856 @retval TRUE Exit caller function.
857 @retval FALSE Not exit caller function.
862 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
865 EFI_BOOT_MANAGER_LOAD_OPTION BootOption
;
868 FileName
= ExtractFileNameFromDevicePath(FilePath
);
869 EfiBootManagerInitializeLoadOption (
880 // Since current no boot from removable media directly is allowed */
882 gST
->ConOut
->ClearScreen (gST
->ConOut
);
884 BmmBdsSetConsoleMode (FALSE
);
885 EfiBootManagerBoot (&BootOption
);
886 BmmBdsSetConsoleMode (TRUE
);
890 EfiBootManagerFreeLoadOption (&BootOption
);
896 Display the form base on the selected file.
898 @param FilePath Point to the file path.
899 @param FormId The form need to display.
904 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
,
905 IN EFI_FORM_ID FormId
908 gBootMaintenancePrivate
.LoadContext
->FilePathList
= FilePath
;
910 UpdateOptionPage(&gBootMaintenancePrivate
, FormId
, FilePath
);
912 gBootMaintenancePrivate
.FormBrowser2
->SendForm (
913 gBootMaintenancePrivate
.FormBrowser2
,
914 &gBootMaintenancePrivate
.BmmHiiHandle
,
925 Create boot option base on the input file path info.
927 @param FilePath Point to the file path.
929 @retval TRUE Exit caller function.
930 @retval FALSE Not exit caller function.
934 CreateBootOptionFromFile (
935 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
938 return ReSendForm(FilePath
, FORM_BOOT_ADD_ID
);
942 Create driver option base on the input file path info.
944 @param FilePath Point to the file path.
946 @retval TRUE Exit caller function.
947 @retval FALSE Not exit caller function.
952 CreateDriverOptionFromFile (
953 IN EFI_DEVICE_PATH_PROTOCOL
*FilePath
956 return ReSendForm(FilePath
, FORM_DRV_ADD_FILE_ID
);