X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FLibrary%2FBootManagerUiLib%2FBootManager.c;h=bf872f867e0800bcfee8ad925e53ea9a1c2eeb2d;hb=54127af53d43c143ee4da734f5472acd085c5b58;hp=d2494d8a374e10f1464a47b240265a4be99d3e71;hpb=d513b3ddcc62969c611e95b2afab2698f87241ff;p=mirror_edk2.git diff --git a/MdeModulePkg/Library/BootManagerUiLib/BootManager.c b/MdeModulePkg/Library/BootManagerUiLib/BootManager.c index d2494d8a37..bf872f867e 100644 --- a/MdeModulePkg/Library/BootManagerUiLib/BootManager.c +++ b/MdeModulePkg/Library/BootManagerUiLib/BootManager.c @@ -1,7 +1,7 @@ /** @file The boot manager reference implementation -Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
This program and the accompanying materials are licensed and made available under the terms and conditions of the BSD License that accompanies this distribution. The full text of the license may be found at @@ -31,6 +31,8 @@ UINT32 mBmSetupTextModeRow = 0; UINT32 mBmSetupHorizontalResolution = 0; UINT32 mBmSetupVerticalResolution = 0; +BOOLEAN mBmModeInitialized = FALSE; + CHAR16 *mDeviceTypeStr[] = { L"Legacy BEV", L"Legacy Floppy", @@ -89,8 +91,7 @@ BOOT_MANAGER_CALLBACK_DATA gBootManagerPrivate = { **/ EFI_STATUS -EFIAPI -BmBdsSetConsoleMode ( +BmSetConsoleMode ( BOOLEAN IsSetupMode ) { @@ -142,7 +143,7 @@ BmBdsSetConsoleMode ( if (IsSetupMode) { // - // The requried resolution and text mode is setup mode. + // The required resolution and text mode is setup mode. // NewHorizontalResolution = mBmSetupHorizontalResolution; NewVerticalResolution = mBmSetupVerticalResolution; @@ -198,7 +199,7 @@ BmBdsSetConsoleMode ( return EFI_SUCCESS; } else { // - // If current text mode is different from requried text mode. Set new video mode + // If current text mode is different from required text mode. Set new video mode // for (Index = 0; Index < MaxTextMode; Index++) { Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow); @@ -223,7 +224,7 @@ BmBdsSetConsoleMode ( } if (Index == MaxTextMode) { // - // If requried text mode is not supported, return error. + // If required text mode is not supported, return error. // FreePool (Info); return EFI_UNSUPPORTED; @@ -342,7 +343,7 @@ GroupMultipleLegacyBootOption4SameType ( // Legacy Boot Option // DEBUG ((EFI_D_ERROR, "[BootManagerDxe] ==== Find Legacy Boot Option 0x%x! ==== \n", Index)); - ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption.FilePath)->DeviceType & 0xF) < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0])); + ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption.FilePath)->DeviceType & 0xF) < ARRAY_SIZE (DeviceTypeIndex)); NextIndex = &DeviceTypeIndex[((BBS_BBS_DEVICE_PATH *) BootOption.FilePath)->DeviceType & 0xF]; if (*NextIndex == (UINTN) -1) { @@ -361,7 +362,7 @@ GroupMultipleLegacyBootOption4SameType ( // // Update the DeviceTypeIndex array to reflect the right shift operation // - for (DeviceIndex = 0; DeviceIndex < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0]); DeviceIndex++) { + for (DeviceIndex = 0; DeviceIndex < ARRAY_SIZE (DeviceTypeIndex); DeviceIndex++) { if (DeviceTypeIndex[DeviceIndex] != (UINTN) -1 && DeviceTypeIndex[DeviceIndex] >= *NextIndex) { DeviceTypeIndex[DeviceIndex]++; } @@ -418,8 +419,7 @@ BmDevicePathToStr ( } /** - This function invokes Boot Manager. If all devices have not a chance to be connected, - the connect all will be triggered. It then enumerate all boot options. If + This function invokes Boot Manager. It then enumerate all boot options. If a boot option from the Boot Manager page is selected, Boot Manager will boot from this boot option. @@ -449,8 +449,6 @@ UpdateBootManager ( DeviceType = (UINT16) -1; - EfiBootManagerConnectAll (); - // // for better user experience // 1. User changes HD configuration (e.g.: unplug HDD), here we have a chance to remove the HDD boot option @@ -528,7 +526,7 @@ UpdateBootManager ( HiiHandle, 0, mDeviceTypeStr[ - MIN (DeviceType & 0xF, sizeof (mDeviceTypeStr) / sizeof (mDeviceTypeStr[0]) - 1) + MIN (DeviceType & 0xF, ARRAY_SIZE (mDeviceTypeStr) - 1) ], NULL ); @@ -649,6 +647,77 @@ BootManagerRouteConfig ( return EFI_NOT_FOUND; } +/** + Initial the boot mode related parameters. + +**/ +VOID +BmInitialBootModeInfo ( + VOID + ) +{ + EFI_STATUS Status; + EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput; + EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut; + UINTN BootTextColumn; + UINTN BootTextRow; + + if (mBmModeInitialized) { + return; + } + + // + // After the console is ready, get current video resolution + // and text mode before launching setup at first time. + // + Status = gBS->HandleProtocol ( + gST->ConsoleOutHandle, + &gEfiGraphicsOutputProtocolGuid, + (VOID**)&GraphicsOutput + ); + if (EFI_ERROR (Status)) { + GraphicsOutput = NULL; + } + + Status = gBS->HandleProtocol ( + gST->ConsoleOutHandle, + &gEfiSimpleTextOutProtocolGuid, + (VOID**)&SimpleTextOut + ); + if (EFI_ERROR (Status)) { + SimpleTextOut = NULL; + } + + if (GraphicsOutput != NULL) { + // + // Get current video resolution and text mode. + // + mBmBootHorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution; + mBmBootVerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution; + } + + if (SimpleTextOut != NULL) { + Status = SimpleTextOut->QueryMode ( + SimpleTextOut, + SimpleTextOut->Mode->Mode, + &BootTextColumn, + &BootTextRow + ); + mBmBootTextModeColumn = (UINT32)BootTextColumn; + mBmBootTextModeRow = (UINT32)BootTextRow; + } + + // + // Get user defined text mode for setup. + // + mBmSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution); + mBmSetupVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution); + mBmSetupTextModeColumn = PcdGet32 (PcdSetupConOutColumn); + mBmSetupTextModeRow = PcdGet32 (PcdSetupConOutRow); + + mBmModeInitialized = TRUE; +} + /** This call back function is registered with Boot Manager formset. When user selects a boot option, this call back function will @@ -715,9 +784,9 @@ BootManagerCallback ( // // parse the selected option // - BmBdsSetConsoleMode (FALSE); + BmSetConsoleMode (FALSE); EfiBootManagerBoot (&BootOption[QuestionId - 1]); - BmBdsSetConsoleMode (TRUE); + BmSetConsoleMode (TRUE); if (EFI_ERROR (BootOption[QuestionId - 1].Status)) { gST->ConOut->OutputString ( @@ -745,7 +814,7 @@ BootManagerCallback ( **/ EFI_STATUS EFIAPI -BootManagerLibConstructor ( +BootManagerUiLibConstructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) @@ -773,11 +842,12 @@ BootManagerLibConstructor ( &mBootManagerGuid, gBootManagerPrivate.DriverHandle, BootManagerVfrBin, - BootManagerLibStrings, + BootManagerUiLibStrings, NULL ); ASSERT (gBootManagerPrivate.HiiHandle != NULL); + BmInitialBootModeInfo (); return EFI_SUCCESS; } @@ -792,7 +862,7 @@ BootManagerLibConstructor ( **/ EFI_STATUS EFIAPI -BootManagerLibDestructor ( +BootManagerUiLibDestructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable )