31 CHAR16 *StringBuffer1;
32 CHAR16 *StringBuffer2;
39 Status =
gBS->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid,
NULL, (VOID **)&FormBrowserEx2);
44 if (!EFI_ERROR (Status) && FormBrowserEx2->IsResetRequired ()) {
46 ASSERT (StringBuffer1 !=
NULL);
48 ASSERT (StringBuffer2 !=
NULL);
49 StrCpyS (StringBuffer1,
MAX_CHAR, L
"Configuration changed. Reset to apply it Now.");
55 CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuffer1, StringBuffer2,
NULL);
56 }
while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
86 case BM_LOAD_CONTEXT_SELECT:
90 case BM_FILE_CONTEXT_SELECT:
94 case BM_CONSOLE_CONTEXT_SELECT:
98 case BM_TERMINAL_CONTEXT_SELECT:
102 case BM_HANDLE_CONTEXT_SELECT:
111 if (ContextSize == 0) {
119 if (MenuEntry ==
NULL) {
124 if (MenuEntry->VariableContext ==
NULL) {
129 MenuEntry->Signature = BM_MENU_ENTRY_SIGNATURE;
130 MenuEntry->ContextSelection = MenuType;
154 switch (MenuEntry->ContextSelection) {
155 case BM_LOAD_CONTEXT_SELECT:
157 FreePool (LoadContext->FilePathList);
158 if (LoadContext->OptionalData !=
NULL) {
159 FreePool (LoadContext->OptionalData);
165 case BM_FILE_CONTEXT_SELECT:
168 if (!FileContext->IsRoot) {
171 if (FileContext->FHandle !=
NULL) {
172 FileContext->FHandle->Close (FileContext->FHandle);
176 if (FileContext->FileName !=
NULL) {
180 if (FileContext->Info !=
NULL) {
187 case BM_CONSOLE_CONTEXT_SELECT:
189 FreePool (ConsoleContext->DevicePath);
193 case BM_TERMINAL_CONTEXT_SELECT:
195 FreePool (TerminalContext->DevicePath);
199 case BM_HANDLE_CONTEXT_SELECT:
208 FreePool (MenuEntry->DisplayString);
209 if (MenuEntry->HelpString !=
NULL) {
238 ASSERT (MenuNumber < MenuOption->MenuNumber);
240 List = MenuOption->Head.ForwardLink;
241 for (Index = 0; Index < MenuNumber; Index++) {
242 List = List->ForwardLink;
245 NewMenuEntry =
CR (List,
BM_MENU_ENTRY, Link, BM_MENU_ENTRY_SIGNATURE);
264 FreeMenu->Head.ForwardLink,
267 BM_MENU_ENTRY_SIGNATURE
273 FreeMenu->MenuNumber = 0;
293 UINT16 BootString[10];
294 UINT8 *LoadOptionFromVar;
295 UINTN BootOptionSize;
296 BOOLEAN BootNextFlag;
297 UINT16 *BootOrderList;
298 UINTN BootOrderListSize;
303 UINT8 *LoadOptionPtr;
305 UINTN OptionalDataSize;
306 UINT8 *LoadOptionEnd;
311 UINTN BootOptionCount;
314 BootOrderListSize = 0;
316 BootOrderList =
NULL;
318 LoadOptionFromVar =
NULL;
326 if (BootOrderList ==
NULL) {
327 return EFI_NOT_FOUND;
334 if (BootNext !=
NULL) {
335 if (BootNextSize !=
sizeof (UINT16)) {
342 for (Index = 0; Index < BootOrderListSize /
sizeof (UINT16); Index++) {
346 if (((BootOption[Index].Attributes & LOAD_OPTION_HIDDEN) != 0) || ((BootOption[Index].Attributes & LOAD_OPTION_ACTIVE) == 0)) {
350 UnicodeSPrint (BootString,
sizeof (BootString), L
"Boot%04x", BootOrderList[Index]);
355 if (LoadOptionFromVar ==
NULL) {
359 if (BootNext !=
NULL) {
360 BootNextFlag = (BOOLEAN)(*BootNext == BootOrderList[Index]);
362 BootNextFlag =
FALSE;
366 ASSERT (
NULL != NewMenuEntry);
370 LoadOptionPtr = LoadOptionFromVar;
371 LoadOptionEnd = LoadOptionFromVar + BootOptionSize;
373 NewMenuEntry->OptionNumber = BootOrderList[Index];
374 NewLoadContext->Deleted =
FALSE;
375 NewLoadContext->IsBootNext = BootNextFlag;
380 Ptr = (UINT8 *)LoadOptionFromVar;
385 Ptr +=
sizeof (UINT32);
390 Ptr +=
sizeof (UINT16);
395 Ptr +=
StrSize ((CHAR16 *)Ptr);
402 NewLoadContext->IsLegacy =
TRUE;
404 NewLoadContext->IsLegacy =
FALSE;
413 NewLoadContext->Attributes = *(UINT32 *)LoadOptionPtr;
415 LoadOptionPtr +=
sizeof (UINT32);
417 NewLoadContext->FilePathListLength = *(UINT16 *)LoadOptionPtr;
418 LoadOptionPtr +=
sizeof (UINT16);
420 StringSize =
StrSize ((UINT16 *)LoadOptionPtr);
423 ASSERT (NewLoadContext->Description !=
NULL);
424 StrCpyS (NewLoadContext->Description,
StrSize ((UINT16 *)LoadOptionPtr) /
sizeof (UINT16), (UINT16 *)LoadOptionPtr);
426 ASSERT (NewLoadContext->Description !=
NULL);
427 NewMenuEntry->DisplayString = NewLoadContext->Description;
428 NewMenuEntry->DisplayStringToken =
HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->DisplayString,
NULL);
430 LoadOptionPtr += StringSize;
432 NewLoadContext->FilePathList =
AllocateZeroPool (NewLoadContext->FilePathListLength);
433 ASSERT (NewLoadContext->FilePathList !=
NULL);
435 NewLoadContext->FilePathList,
437 NewLoadContext->FilePathListLength
441 NewMenuEntry->HelpStringToken =
HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->HelpString,
NULL);
443 LoadOptionPtr += NewLoadContext->FilePathListLength;
445 if (LoadOptionPtr < LoadOptionEnd) {
446 OptionalDataSize = BootOptionSize -
450 NewLoadContext->FilePathListLength;
453 ASSERT (NewLoadContext->OptionalData !=
NULL);
455 NewLoadContext->OptionalData,
468 if (BootNext !=
NULL) {
472 if (BootOrderList !=
NULL) {
496 UINTN NoDevicePathHandles;
517 Status =
gBS->LocateHandleBuffer (
519 &gEfiDevicePathProtocolGuid,
521 &NoDevicePathHandles,
524 if (EFI_ERROR (Status)) {
529 for (Index = 0; Index < NoDevicePathHandles; Index++) {
530 CurHandle = DevicePathHandle[Index];
532 Status =
gBS->HandleProtocol (
534 &gEfiSimpleFileSystemProtocolGuid,
541 Status =
gBS->HandleProtocol (
543 &gEfiLoadFileProtocolGuid,
551 if (
NULL == NewMenuEntry) {
553 return EFI_OUT_OF_RESOURCES;
557 NewHandleContext->Handle = CurHandle;
560 NewMenuEntry->DisplayStringToken =
HiiSetString (mBmmCallbackInfo->BmmHiiHandle, 0, NewMenuEntry->DisplayString,
NULL);
561 NewMenuEntry->HelpString =
NULL;
562 NewMenuEntry->HelpStringToken = NewMenuEntry->DisplayStringToken;
563 NewMenuEntry->OptionNumber = OptionNumber;
568 if (DevicePathHandle !=
NULL) {
594 UINT16 *OptionBuffer;
606 for (OptionNumber = 0; ; OptionNumber++) {
607 if (OrderList !=
NULL) {
608 for (Index = 0; Index < OrderListSize /
sizeof (UINT16); Index++) {
609 if (OptionNumber == OrderList[Index]) {
615 if (Index < OrderListSize /
sizeof (UINT16)) {
623 DEBUG ((DEBUG_ERROR,
"Option = %s\n", StrTemp));
625 if (
NULL == OptionBuffer) {
683 UINT16 DriverString[12];
684 UINT8 *LoadOptionFromVar;
685 UINTN DriverOptionSize;
687 UINT16 *DriverOrderList;
688 UINTN DriverOrderListSize;
691 UINT8 *LoadOptionPtr;
693 UINTN OptionalDataSize;
694 UINT8 *LoadOptionEnd;
696 DriverOrderListSize = 0;
697 DriverOrderList =
NULL;
698 DriverOptionSize = 0;
699 LoadOptionFromVar =
NULL;
706 if (DriverOrderList ==
NULL) {
707 return EFI_NOT_FOUND;
710 for (Index = 0; Index < DriverOrderListSize /
sizeof (UINT16); Index++) {
713 sizeof (DriverString),
715 DriverOrderList[Index]
721 if (LoadOptionFromVar ==
NULL) {
726 if (
NULL == NewMenuEntry) {
727 return EFI_OUT_OF_RESOURCES;
731 LoadOptionPtr = LoadOptionFromVar;
732 LoadOptionEnd = LoadOptionFromVar + DriverOptionSize;
733 NewMenuEntry->OptionNumber = DriverOrderList[Index];
734 NewLoadContext->Deleted =
FALSE;
735 NewLoadContext->IsLegacy =
FALSE;
743 NewLoadContext->Attributes = *(UINT32 *)LoadOptionPtr;
745 LoadOptionPtr +=
sizeof (UINT32);
747 NewLoadContext->FilePathListLength = *(UINT16 *)LoadOptionPtr;
748 LoadOptionPtr +=
sizeof (UINT16);
750 StringSize =
StrSize ((UINT16 *)LoadOptionPtr);
752 ASSERT (NewLoadContext->Description !=
NULL);
754 NewLoadContext->Description,
755 (UINT16 *)LoadOptionPtr,
758 NewMenuEntry->DisplayString = NewLoadContext->Description;
759 NewMenuEntry->DisplayStringToken =
HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->DisplayString,
NULL);
761 LoadOptionPtr += StringSize;
763 NewLoadContext->FilePathList =
AllocateZeroPool (NewLoadContext->FilePathListLength);
764 ASSERT (NewLoadContext->FilePathList !=
NULL);
766 NewLoadContext->FilePathList,
768 NewLoadContext->FilePathListLength
772 NewMenuEntry->HelpStringToken =
HiiSetString (CallbackData->BmmHiiHandle, 0, NewMenuEntry->HelpString,
NULL);
774 LoadOptionPtr += NewLoadContext->FilePathListLength;
776 if (LoadOptionPtr < LoadOptionEnd) {
777 OptionalDataSize = DriverOptionSize -
781 NewLoadContext->FilePathListLength;
784 ASSERT (NewLoadContext->OptionalData !=
NULL);
786 NewLoadContext->OptionalData,
796 if (DriverOrderList !=
NULL) {
817 UINT16 OptionOrderIndex;
822 ASSERT (CallbackData !=
NULL);
824 DeviceType = (
UINTN)-1;
825 BmmConfig = &CallbackData->BmmFakeNvData;
826 ZeroMem (BmmConfig->BootOptionOrder, sizeof (BmmConfig->BootOptionOrder));
828 for (Index = 0, OptionOrderIndex = 0; ((Index <
BootOptionMenu.MenuNumber) &&
829 (OptionOrderIndex < (
sizeof (BmmConfig->BootOptionOrder) / sizeof (BmmConfig->BootOptionOrder[0]))));
835 if (NewLoadContext->IsLegacy) {
847 BmmConfig->BootOptionOrder[OptionOrderIndex++] = (UINT32)(NewMenuEntry->OptionNumber + 1);
864 UINT16 OptionOrderIndex;
869 ASSERT (CallbackData !=
NULL);
871 DeviceType = (
UINTN)-1;
872 BmmConfig = &CallbackData->BmmFakeNvData;
873 ZeroMem (BmmConfig->DriverOptionOrder, sizeof (BmmConfig->DriverOptionOrder));
875 for (Index = 0, OptionOrderIndex = 0; ((Index <
DriverOptionMenu.MenuNumber) &&
876 (OptionOrderIndex < (
sizeof (BmmConfig->DriverOptionOrder) / sizeof (BmmConfig->DriverOptionOrder[0]))));
882 if (NewLoadContext->IsLegacy) {
894 BmmConfig->DriverOptionOrder[OptionOrderIndex++] = (UINT32)(NewMenuEntry->OptionNumber + 1);
916 Status = EFI_NOT_STARTED;
920 if (FileName !=
NULL) {
933 if (!EFI_ERROR (Status)) {
965 IN EFI_FORM_ID FormId
968 gBootMaintenancePrivate.LoadContext->FilePathList = FilePath;
972 gBootMaintenancePrivate.FormBrowser2->SendForm (
973 gBootMaintenancePrivate.FormBrowser2,
974 &gBootMaintenancePrivate.BmmHiiHandle,
998 return ReSendForm (FilePath, FORM_BOOT_ADD_ID);
1016 return ReSendForm (FilePath, FORM_DRV_ADD_FILE_ID);
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
BOOLEAN EFIAPI IsListEmpty(IN CONST LIST_ENTRY *ListHead)
RETURN_STATUS EFIAPI StrCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
LIST_ENTRY *EFIAPI RemoveEntryList(IN CONST LIST_ENTRY *Entry)
LIST_ENTRY *EFIAPI InitializeListHead(IN OUT LIST_ENTRY *ListHead)
LIST_ENTRY *EFIAPI InsertTailList(IN OUT LIST_ENTRY *ListHead, IN OUT LIST_ENTRY *Entry)
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
BM_MENU_OPTION DriverOptionMenu
BM_MENU_OPTION BootOptionMenu
VOID UpdateOptionPage(IN BMM_CALLBACK_DATA *CallbackData, IN EFI_FORM_ID FormId, IN EFI_DEVICE_PATH_PROTOCOL *DevicePath)
VOID BOpt_FreeMenu(BM_MENU_OPTION *FreeMenu)
UINT16 BOpt_GetOptionNumber(CHAR16 *Type)
BM_MENU_ENTRY * BOpt_GetMenuEntry(BM_MENU_OPTION *MenuOption, UINTN MenuNumber)
UINT16 BOpt_GetDriverOptionNumber(VOID)
VOID BmmSetupResetReminder(VOID)
BOOLEAN ReSendForm(IN EFI_DEVICE_PATH_PROTOCOL *FilePath, IN EFI_FORM_ID FormId)
VOID BOpt_DestroyMenuEntry(BM_MENU_ENTRY *MenuEntry)
BM_MENU_ENTRY * BOpt_CreateMenuEntry(UINTN MenuType)
EFI_STATUS BOpt_GetDriverOptions(IN BMM_CALLBACK_DATA *CallbackData)
BOOLEAN EFIAPI CreateDriverOptionFromFile(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
UINT16 BOpt_GetBootOptionNumber(VOID)
BOOLEAN EFIAPI CreateBootOptionFromFile(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
EFI_STATUS BOpt_FindDrivers(VOID)
VOID GetBootOrder(IN BMM_CALLBACK_DATA *CallbackData)
VOID GetDriverOrder(IN BMM_CALLBACK_DATA *CallbackData)
BOOLEAN EFIAPI BootFromFile(IN EFI_DEVICE_PATH_PROTOCOL *FilePath)
EFI_STATUS BOpt_GetBootOptions(IN BMM_CALLBACK_DATA *CallbackData)
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)
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
EFI_RUNTIME_SERVICES * gRT
#define DEBUG(Expression)
#define CR(Record, TYPE, Field, TestSignature)
VOID EFIAPI EfiBootManagerBoot(IN EFI_BOOT_MANAGER_LOAD_OPTION *BootOption)
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_STATUS EFIAPI GetEfiGlobalVariable2(IN CONST CHAR16 *Name, OUT VOID **Value, OUT UINTN *Size OPTIONAL)
VOID EFIAPI CreatePopUp(IN UINTN Attribute, OUT EFI_INPUT_KEY *Key OPTIONAL,...)
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut