12EFI_GUID mBootManagerGuid = BOOT_MANAGER_FORMSET_GUID;
16UINT32 mBmBootHorizontalResolution = 0;
17UINT32 mBmBootVerticalResolution = 0;
18UINT32 mBmBootTextModeColumn = 0;
19UINT32 mBmBootTextModeRow = 0;
23UINT32 mBmSetupTextModeColumn = 0;
24UINT32 mBmSetupTextModeRow = 0;
25UINT32 mBmSetupHorizontalResolution = 0;
26UINT32 mBmSetupVerticalResolution = 0;
28BOOLEAN mBmModeInitialized =
FALSE;
30CHAR16 *mDeviceTypeStr[] = {
37 L
"Legacy Embedded Network",
38 L
"Legacy Unknown Device"
54 { 0x1dddbe15, 0x481d, 0x4d2b, { 0x82, 0x77, 0xb1, 0x91, 0xea, 0xf6, 0x65, 0x25 }
59 END_ENTIRE_DEVICE_PATH_SUBTYPE,
61 (UINT8)(END_DEVICE_PATH_LENGTH),
62 (UINT8)((END_DEVICE_PATH_LENGTH) >> 8)
68 BOOT_MANAGER_CALLBACK_DATA_SIGNATURE,
100 UINT32 NewHorizontalResolution;
101 UINT32 NewVerticalResolution;
117 Status =
gBS->HandleProtocol (
119 &gEfiGraphicsOutputProtocolGuid,
120 (VOID **)&GraphicsOutput
122 if (EFI_ERROR (Status)) {
123 GraphicsOutput =
NULL;
126 Status =
gBS->HandleProtocol (
128 &gEfiSimpleTextOutProtocolGuid,
129 (VOID **)&SimpleTextOut
131 if (EFI_ERROR (Status)) {
132 SimpleTextOut =
NULL;
135 if ((GraphicsOutput ==
NULL) || (SimpleTextOut ==
NULL)) {
136 return EFI_UNSUPPORTED;
143 NewHorizontalResolution = mBmSetupHorizontalResolution;
144 NewVerticalResolution = mBmSetupVerticalResolution;
145 NewColumns = mBmSetupTextModeColumn;
146 NewRows = mBmSetupTextModeRow;
151 NewHorizontalResolution = mBmBootHorizontalResolution;
152 NewVerticalResolution = mBmBootVerticalResolution;
153 NewColumns = mBmBootTextModeColumn;
154 NewRows = mBmBootTextModeRow;
157 if (GraphicsOutput !=
NULL) {
161 if (SimpleTextOut !=
NULL) {
172 for (ModeNumber = 0; ModeNumber < MaxGopMode; ModeNumber++) {
173 Status = GraphicsOutput->QueryMode (
179 if (!EFI_ERROR (Status)) {
189 Status = SimpleTextOut->QueryMode (SimpleTextOut, SimpleTextOut->
Mode->
Mode, &CurrentColumn, &CurrentRow);
191 if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {
201 for (Index = 0; Index < MaxTextMode; Index++) {
202 Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);
203 if (!EFI_ERROR (Status)) {
204 if ((CurrentColumn == NewColumns) && (CurrentRow == NewRows)) {
208 Status = SimpleTextOut->SetMode (SimpleTextOut, Index);
213 Status =
PcdSet32S (PcdConOutColumn, mBmSetupTextModeColumn);
215 Status =
PcdSet32S (PcdConOutRow, mBmSetupTextModeRow);
223 if (Index == MaxTextMode) {
228 return EFI_UNSUPPORTED;
236 Status = GraphicsOutput->SetMode (GraphicsOutput, ModeNumber);
237 if (!EFI_ERROR (Status)) {
248 if (ModeNumber == MaxGopMode) {
252 return EFI_UNSUPPORTED;
259 Status =
PcdSet32S (PcdVideoHorizontalResolution, NewHorizontalResolution);
261 Status =
PcdSet32S (PcdVideoVerticalResolution, NewVerticalResolution);
263 Status =
PcdSet32S (PcdConOutColumn, NewColumns);
265 Status =
PcdSet32S (PcdConOutRow, NewRows);
273 Status =
gBS->LocateHandleBuffer (
275 &gEfiSimpleTextOutProtocolGuid,
280 if (!EFI_ERROR (Status)) {
281 for (Index = 0; Index < HandleCount; Index++) {
282 gBS->DisconnectController (HandleBuffer[Index],
NULL,
NULL);
285 for (Index = 0; Index < HandleCount; Index++) {
289 if (HandleBuffer !=
NULL) {
308 CHAR16 *StringBuffer1;
309 CHAR16 *StringBuffer2;
316 Status =
gBS->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid,
NULL, (VOID **)&FormBrowserEx2);
320 if (!EFI_ERROR (Status) && FormBrowserEx2->IsResetRequired ()) {
322 ASSERT (StringBuffer1 !=
NULL);
324 ASSERT (StringBuffer2 !=
NULL);
325 StrCpyS (StringBuffer1, MAX_STRING_LEN, L
"Configuration changed. Reset to apply it Now.");
326 StrCpyS (StringBuffer2, MAX_STRING_LEN, L
"Press ENTER to reset");
331 CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuffer1, StringBuffer2,
NULL);
332 }
while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
365 UINTN DeviceTypeIndex[7];
370 CHAR16 OptionName[
sizeof (
"Boot####")];
373 SetMem (DeviceTypeIndex,
sizeof (DeviceTypeIndex), 0xff);
376 if (BootOrder ==
NULL) {
380 for (Index = 0; Index < BootOrderSize /
sizeof (UINT16); Index++) {
381 UnicodeSPrint (OptionName,
sizeof (OptionName), L
"Boot%04x", BootOrder[Index]);
391 DEBUG ((DEBUG_ERROR,
"[BootManagerDxe] ==== Find Legacy Boot Option 0x%x! ==== \n", Index));
393 NextIndex = &DeviceTypeIndex[((
BBS_BBS_DEVICE_PATH *)BootOption.FilePath)->DeviceType & 0xF];
395 if (*NextIndex == (
UINTN)-1) {
399 *NextIndex = Index + 1;
404 OptionNumber = BootOrder[Index];
405 CopyMem (&BootOrder[*NextIndex + 1], &BootOrder[*NextIndex], (Index - *NextIndex) *
sizeof (UINT16));
406 BootOrder[*NextIndex] = OptionNumber;
411 for (DeviceIndex = 0; DeviceIndex <
ARRAY_SIZE (DeviceTypeIndex); DeviceIndex++) {
412 if ((DeviceTypeIndex[DeviceIndex] != (
UINTN)-1) && (DeviceTypeIndex[DeviceIndex] >= *NextIndex)) {
413 DeviceTypeIndex[DeviceIndex]++;
424 &gEfiGlobalVariableGuid,
449 if (DevPath ==
NULL) {
453 Status =
gBS->LocateProtocol (
454 &gEfiDevicePathToTextProtocolGuid,
456 (VOID **)&DevPathToText
459 ToText = DevPathToText->ConvertDevicePathToText (
464 ASSERT (ToText !=
NULL);
481 UINTN BootOptionCount;
484 EFI_STRING_ID HelpToken;
488 VOID *StartOpCodeHandle;
489 VOID *EndOpCodeHandle;
493 BOOLEAN IsLegacyOption;
497 DeviceType = (UINT16)-1;
514 HiiHandle = gBootManagerPrivate.HiiHandle;
520 ASSERT (StartOpCodeHandle !=
NULL);
523 ASSERT (EndOpCodeHandle !=
NULL);
530 StartLabel->
Number = LABEL_BOOT_OPTION;
537 EndLabel->
Number = LABEL_BOOT_OPTION_END;
540 for (Index = 0; Index < BootOptionCount; Index++) {
549 if ((BootOption[Index].Attributes & LOAD_OPTION_HIDDEN) != 0) {
556 IsLegacyOption = (BOOLEAN)(
561 if (!IsLegacyOption && NeedEndOp) {
566 if (IsLegacyOption && (DeviceType != ((
BBS_BBS_DEVICE_PATH *)BootOption[Index].FilePath)->DeviceType)) {
584 ASSERT (BootOption[Index].Description !=
NULL);
591 MaxLen = (TempSize +
StrSize (L
"Device Path : "))/
sizeof (CHAR16);
592 ASSERT (HelpString !=
NULL);
593 StrCatS (HelpString, MaxLen, L
"Device Path : ");
594 StrCatS (HelpString, MaxLen, TempStr);
603 EFI_IFR_FLAG_CALLBACK,
615 BOOT_MANAGER_FORM_ID,
653 OUT EFI_STRING *Progress,
654 OUT EFI_STRING *Results
657 if ((Progress ==
NULL) || (Results ==
NULL)) {
658 return EFI_INVALID_PARAMETER;
662 return EFI_NOT_FOUND;
685 IN CONST EFI_STRING Configuration,
686 OUT EFI_STRING *Progress
689 if ((Configuration ==
NULL) || (Progress ==
NULL)) {
690 return EFI_INVALID_PARAMETER;
693 *Progress = Configuration;
695 return EFI_NOT_FOUND;
710 UINTN BootTextColumn;
713 if (mBmModeInitialized) {
721 Status =
gBS->HandleProtocol (
723 &gEfiGraphicsOutputProtocolGuid,
724 (VOID **)&GraphicsOutput
726 if (EFI_ERROR (Status)) {
727 GraphicsOutput =
NULL;
730 Status =
gBS->HandleProtocol (
732 &gEfiSimpleTextOutProtocolGuid,
733 (VOID **)&SimpleTextOut
735 if (EFI_ERROR (Status)) {
736 SimpleTextOut =
NULL;
739 if (GraphicsOutput !=
NULL) {
747 if (SimpleTextOut !=
NULL) {
748 Status = SimpleTextOut->QueryMode (
754 mBmBootTextModeColumn = (UINT32)BootTextColumn;
755 mBmBootTextModeRow = (UINT32)BootTextRow;
761 mBmSetupHorizontalResolution =
PcdGet32 (PcdSetupVideoHorizontalResolution);
762 mBmSetupVerticalResolution =
PcdGet32 (PcdSetupVideoVerticalResolution);
763 mBmSetupTextModeColumn =
PcdGet32 (PcdSetupConOutColumn);
764 mBmSetupTextModeRow =
PcdGet32 (PcdSetupConOutRow);
766 mBmModeInitialized =
TRUE;
791 IN EFI_BROWSER_ACTION Action,
792 IN EFI_QUESTION_ID QuestionId,
795 OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest
799 UINTN BootOptionCount;
802 if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
807 if (QuestionId == 0x1212) {
814 if (Action != EFI_BROWSER_ACTION_CHANGED) {
818 return EFI_UNSUPPORTED;
821 if ((Value ==
NULL) || (ActionRequest ==
NULL)) {
822 return EFI_INVALID_PARAMETER;
845 if (EFI_ERROR (BootOption[QuestionId - 1].Status)) {
881 gBootManagerPrivate.DriverHandle =
NULL;
882 Status =
gBS->InstallMultipleProtocolInterfaces (
883 &gBootManagerPrivate.DriverHandle,
884 &gEfiDevicePathProtocolGuid,
885 &mBootManagerHiiVendorDevicePath,
886 &gEfiHiiConfigAccessProtocolGuid,
887 &gBootManagerPrivate.ConfigAccess,
897 gBootManagerPrivate.DriverHandle,
899 BootManagerUiLibStrings,
902 ASSERT (gBootManagerPrivate.HiiHandle !=
NULL);
926 Status =
gBS->UninstallMultipleProtocolInterfaces (
927 gBootManagerPrivate.DriverHandle,
928 &gEfiDevicePathProtocolGuid,
929 &mBootManagerHiiVendorDevicePath,
930 &gEfiHiiConfigAccessProtocolGuid,
931 &gBootManagerPrivate.ConfigAccess,
UINTN EFIAPI StrSize(IN CONST CHAR16 *String)
RETURN_STATUS EFIAPI StrCpyS(OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
RETURN_STATUS EFIAPI StrCatS(IN OUT CHAR16 *Destination, IN UINTN DestMax, IN CONST CHAR16 *Source)
VOID *EFIAPI CopyMem(OUT VOID *DestinationBuffer, IN CONST VOID *SourceBuffer, IN UINTN Length)
VOID *EFIAPI SetMem(OUT VOID *Buffer, IN UINTN Length, IN UINT8 Value)
EFI_STATUS EFIAPI BootManagerCallback(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN EFI_BROWSER_ACTION Action, IN EFI_QUESTION_ID QuestionId, IN UINT8 Type, IN EFI_IFR_TYPE_VALUE *Value, OUT EFI_BROWSER_ACTION_REQUEST *ActionRequest)
VOID BmSetupResetReminder(VOID)
EFI_STATUS BmSetConsoleMode(BOOLEAN IsSetupMode)
EFI_STATUS EFIAPI BootManagerRouteConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Configuration, OUT EFI_STRING *Progress)
EFI_STATUS EFIAPI BootManagerUiLibDestructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID UpdateBootManager(VOID)
EFI_STATUS EFIAPI BootManagerExtractConfig(IN CONST EFI_HII_CONFIG_ACCESS_PROTOCOL *This, IN CONST EFI_STRING Request, OUT EFI_STRING *Progress, OUT EFI_STRING *Results)
EFI_STATUS EFIAPI BootManagerUiLibConstructor(IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
VOID BmInitialBootModeInfo(VOID)
CHAR16 * BmDevicePathToStr(IN EFI_DEVICE_PATH_PROTOCOL *DevPath)
VOID GroupMultipleLegacyBootOption4SameType(VOID)
#define HARDWARE_DEVICE_PATH
UINT8 EFIAPI DevicePathType(IN CONST VOID *Node)
UINT8 EFIAPI DevicePathSubType(IN CONST VOID *Node)
VOID *EFIAPI AllocateZeroPool(IN UINTN AllocationSize)
VOID EFIAPI FreePool(IN VOID *Buffer)
UINT8 *EFIAPI HiiCreateSubTitleOpCode(IN VOID *OpCodeHandle, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 Flags, IN UINT8 Scope)
VOID *EFIAPI HiiAllocateOpCodeHandle(VOID)
VOID EFIAPI HiiFreeOpCodeHandle(VOID *OpCodeHandle)
EFI_HII_HANDLE EFIAPI HiiAddPackages(IN CONST EFI_GUID *PackageListGuid, IN EFI_HANDLE DeviceHandle OPTIONAL,...)
UINT8 *EFIAPI HiiCreateGuidOpCode(IN VOID *OpCodeHandle, IN CONST EFI_GUID *Guid, IN CONST VOID *GuidOpCode OPTIONAL, IN UINTN OpCodeSize)
EFI_STRING EFIAPI HiiGetString(IN EFI_HII_HANDLE HiiHandle, IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language OPTIONAL)
UINT8 *EFIAPI HiiCreateEndOpCode(IN VOID *OpCodeHandle)
EFI_STATUS EFIAPI HiiUpdateForm(IN EFI_HII_HANDLE HiiHandle, IN EFI_GUID *FormSetGuid OPTIONAL, IN EFI_FORM_ID FormId, IN VOID *StartOpCodeHandle, IN VOID *EndOpCodeHandle OPTIONAL)
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)
UINT8 *EFIAPI HiiCreateActionOpCode(IN VOID *OpCodeHandle, IN EFI_QUESTION_ID QuestionId, IN EFI_STRING_ID Prompt, IN EFI_STRING_ID Help, IN UINT8 QuestionFlags, IN EFI_STRING_ID QuestionConfig)
VOID EFIAPI HiiRemovePackages(IN EFI_HII_HANDLE HiiHandle)
#define EFI_IFR_EXTEND_OP_LABEL
UINTN EFIAPI UnicodeSPrint(OUT CHAR16 *StartOfBuffer, IN UINTN BufferSize, IN CONST CHAR16 *FormatString,...)
EFI_RUNTIME_SERVICES * gRT
#define ARRAY_SIZE(Array)
#define ASSERT_EFI_ERROR(StatusParameter)
#define DEBUG(Expression)
#define PcdGet32(TokenName)
#define PcdSet32S(TokenName, Value)
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)
VOID EFIAPI EfiBootManagerRefreshAllBootOption(VOID)
EFI_STATUS EFIAPI EfiBootManagerFreeLoadOptions(IN EFI_BOOT_MANAGER_LOAD_OPTION *LoadOptions, IN UINTN LoadOptionCount)
EFI_STATUS EFIAPI EfiBootManagerVariableToLoadOption(IN CHAR16 *VariableName, IN OUT EFI_BOOT_MANAGER_LOAD_OPTION *LoadOption)
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_GRAPHICS_OUTPUT_PROTOCOL_MODE * Mode
EFI_SIMPLE_TEXT_OUTPUT_MODE * Mode
UINT32 VerticalResolution
UINT32 HorizontalResolution
EFI_GRAPHICS_OUTPUT_MODE_INFORMATION * Info
EFI_HANDLE ConsoleOutHandle
EFI_SIMPLE_TEXT_INPUT_PROTOCOL * ConIn
EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL * ConOut