X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=MdeModulePkg%2FLibrary%2FBootManagerUiLib%2FBootManager.c;h=7f3edc3d3dfd0d0bb3b93d55fea7adfa779a586f;hb=d1102dba7210b95e41d06c2338a22ba6af248645;hp=d2494d8a374e10f1464a47b240265a4be99d3e71;hpb=d513b3ddcc62969c611e95b2afab2698f87241ff;p=mirror_edk2.git diff --git a/MdeModulePkg/Library/BootManagerUiLib/BootManager.c b/MdeModulePkg/Library/BootManagerUiLib/BootManager.c index d2494d8a37..7f3edc3d3d 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 - 2018, 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", @@ -60,7 +62,7 @@ HII_VENDOR_DEVICE_PATH mBootManagerHiiVendorDevicePath = { { END_DEVICE_PATH_TYPE, END_ENTIRE_DEVICE_PATH_SUBTYPE, - { + { (UINT8) (END_DEVICE_PATH_LENGTH), (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8) } @@ -80,17 +82,16 @@ BOOT_MANAGER_CALLBACK_DATA gBootManagerPrivate = { /** This function will change video resolution and text mode - according to defined setup mode or defined boot mode + according to defined setup mode or defined boot mode - @param IsSetupMode Indicate mode is changed to setup mode or boot mode. + @param IsSetupMode Indicate mode is changed to setup mode or boot mode. @retval EFI_SUCCESS Mode is changed successfully. @retval Others Mode failed to be changed. **/ EFI_STATUS -EFIAPI -BmBdsSetConsoleMode ( +BmSetConsoleMode ( BOOLEAN IsSetupMode ) { @@ -110,13 +111,13 @@ BmBdsSetConsoleMode ( EFI_STATUS Status; UINTN Index; UINTN CurrentColumn; - UINTN CurrentRow; + UINTN CurrentRow; MaxGopMode = 0; MaxTextMode = 0; // - // Get current video resolution and text mode + // Get current video resolution and text mode // Status = gBS->HandleProtocol ( gST->ConsoleOutHandle, @@ -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; @@ -155,7 +156,7 @@ BmBdsSetConsoleMode ( NewHorizontalResolution = mBmBootHorizontalResolution; NewVerticalResolution = mBmBootVerticalResolution; NewColumns = mBmBootTextModeColumn; - NewRows = mBmBootTextModeRow; + NewRows = mBmBootTextModeRow; } if (GraphicsOutput != NULL) { @@ -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; @@ -292,10 +293,54 @@ BmBdsSetConsoleMode ( return EFI_SUCCESS; } +/** + + Check whether a reset is needed,if reset is needed, Popup a menu to notice user. + +**/ +VOID +BmSetupResetReminder ( + VOID + ) +{ + EFI_INPUT_KEY Key; + CHAR16 *StringBuffer1; + CHAR16 *StringBuffer2; + EFI_STATUS Status; + EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL *FormBrowserEx2; + + // + // Use BrowserEx2 protocol to check whether reset is required. + // + Status = gBS->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid, NULL, (VOID **) &FormBrowserEx2); + // + //check any reset required change is applied? if yes, reset system + // + if (!EFI_ERROR(Status) && FormBrowserEx2->IsResetRequired ()) { + StringBuffer1 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16)); + ASSERT (StringBuffer1 != NULL); + StringBuffer2 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16)); + ASSERT (StringBuffer2 != NULL); + StrCpyS (StringBuffer1, MAX_STRING_LEN, L"Configuration changed. Reset to apply it Now."); + StrCpyS (StringBuffer2, MAX_STRING_LEN, L"Press ENTER to reset"); + // + // Popup a menu to notice user + // + do { + CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuffer1, StringBuffer2, NULL); + } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN); + + FreePool (StringBuffer1); + FreePool (StringBuffer2); + + gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL); + } +} + /** Group the legacy boot options in the BootOption. - The routine assumes the boot options in the beginning that covers all the device + The routine assumes the boot options in the beginning that covers all the device types are ordered properly and re-position the following boot options just after the corresponding boot options with the same device type. For example: @@ -342,7 +387,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 +406,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,11 +463,10 @@ 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. - + **/ VOID UpdateBootManager ( @@ -449,8 +493,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 @@ -517,7 +559,7 @@ UpdateBootManager ( NeedEndOp = FALSE; HiiCreateEndOpCode (StartOpCodeHandle); } - + if (IsLegacyOption && DeviceType != ((BBS_BBS_DEVICE_PATH *) BootOption[Index].FilePath)->DeviceType) { if (NeedEndOp) { HiiCreateEndOpCode (StartOpCodeHandle); @@ -528,7 +570,7 @@ UpdateBootManager ( HiiHandle, 0, mDeviceTypeStr[ - MIN (DeviceType & 0xF, sizeof (mDeviceTypeStr) / sizeof (mDeviceTypeStr[0]) - 1) + MIN (DeviceType & 0xF, ARRAY_SIZE (mDeviceTypeStr) - 1) ], NULL ); @@ -649,6 +691,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 @@ -712,12 +825,17 @@ BootManagerCallback ( gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK)); gST->ConOut->ClearScreen (gST->ConOut); + // + //check any reset required change is applied? if yes, reset system + // + BmSetupResetReminder (); + // // 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 +863,7 @@ BootManagerCallback ( **/ EFI_STATUS EFIAPI -BootManagerLibConstructor ( +BootManagerUiLibConstructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) @@ -773,11 +891,12 @@ BootManagerLibConstructor ( &mBootManagerGuid, gBootManagerPrivate.DriverHandle, BootManagerVfrBin, - BootManagerLibStrings, + BootManagerUiLibStrings, NULL ); ASSERT (gBootManagerPrivate.HiiHandle != NULL); + BmInitialBootModeInfo (); return EFI_SUCCESS; } @@ -792,7 +911,7 @@ BootManagerLibConstructor ( **/ EFI_STATUS EFIAPI -BootManagerLibDestructor ( +BootManagerUiLibDestructor ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable )