/** @file\r
The boot manager reference implementation\r
\r
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
-This program and the accompanying materials are licensed and made available under\r
-the terms and conditions of the BSD License that accompanies this distribution.\r
-The full text of the license may be found at\r
-http://opensource.org/licenses/bsd-license.php.\r
-\r
-THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r
-WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r
+Copyright (c) 2004 - 2018, Intel Corporation. All rights reserved.<BR>\r
+SPDX-License-Identifier: BSD-2-Clause-Patent\r
\r
**/\r
\r
UINT32 mBmSetupHorizontalResolution = 0;\r
UINT32 mBmSetupVerticalResolution = 0;\r
\r
+BOOLEAN mBmModeInitialized = FALSE;\r
+\r
CHAR16 *mDeviceTypeStr[] = {\r
L"Legacy BEV",\r
L"Legacy Floppy",\r
{\r
END_DEVICE_PATH_TYPE,\r
END_ENTIRE_DEVICE_PATH_SUBTYPE,\r
- { \r
+ {\r
(UINT8) (END_DEVICE_PATH_LENGTH),\r
(UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)\r
}\r
\r
/**\r
This function will change video resolution and text mode\r
- according to defined setup mode or defined boot mode \r
+ according to defined setup mode or defined boot mode\r
\r
- @param IsSetupMode Indicate mode is changed to setup mode or boot mode. \r
+ @param IsSetupMode Indicate mode is changed to setup mode or boot mode.\r
\r
@retval EFI_SUCCESS Mode is changed successfully.\r
@retval Others Mode failed to be changed.\r
\r
**/\r
EFI_STATUS\r
-EFIAPI\r
-BmBdsSetConsoleMode (\r
+BmSetConsoleMode (\r
BOOLEAN IsSetupMode\r
)\r
{\r
EFI_STATUS Status;\r
UINTN Index;\r
UINTN CurrentColumn;\r
- UINTN CurrentRow; \r
+ UINTN CurrentRow;\r
\r
MaxGopMode = 0;\r
MaxTextMode = 0;\r
\r
//\r
- // Get current video resolution and text mode \r
+ // Get current video resolution and text mode\r
//\r
Status = gBS->HandleProtocol (\r
gST->ConsoleOutHandle,\r
\r
if (IsSetupMode) {\r
//\r
- // The requried resolution and text mode is setup mode.\r
+ // The required resolution and text mode is setup mode.\r
//\r
NewHorizontalResolution = mBmSetupHorizontalResolution;\r
NewVerticalResolution = mBmSetupVerticalResolution;\r
NewHorizontalResolution = mBmBootHorizontalResolution;\r
NewVerticalResolution = mBmBootVerticalResolution;\r
NewColumns = mBmBootTextModeColumn;\r
- NewRows = mBmBootTextModeRow; \r
+ NewRows = mBmBootTextModeRow;\r
}\r
\r
if (GraphicsOutput != NULL) {\r
return EFI_SUCCESS;\r
} else {\r
//\r
- // If current text mode is different from requried text mode. Set new video mode\r
+ // If current text mode is different from required text mode. Set new video mode\r
//\r
for (Index = 0; Index < MaxTextMode; Index++) {\r
Status = SimpleTextOut->QueryMode (SimpleTextOut, Index, &CurrentColumn, &CurrentRow);\r
}\r
if (Index == MaxTextMode) {\r
//\r
- // If requried text mode is not supported, return error.\r
+ // If required text mode is not supported, return error.\r
//\r
FreePool (Info);\r
return EFI_UNSUPPORTED;\r
return EFI_SUCCESS;\r
}\r
\r
+/**\r
+\r
+ Check whether a reset is needed,if reset is needed, Popup a menu to notice user.\r
+\r
+**/\r
+VOID\r
+BmSetupResetReminder (\r
+ VOID\r
+ )\r
+{\r
+ EFI_INPUT_KEY Key;\r
+ CHAR16 *StringBuffer1;\r
+ CHAR16 *StringBuffer2;\r
+ EFI_STATUS Status;\r
+ EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL *FormBrowserEx2;\r
+\r
+ //\r
+ // Use BrowserEx2 protocol to check whether reset is required.\r
+ //\r
+ Status = gBS->LocateProtocol (&gEdkiiFormBrowserEx2ProtocolGuid, NULL, (VOID **) &FormBrowserEx2);\r
+ //\r
+ //check any reset required change is applied? if yes, reset system\r
+ //\r
+ if (!EFI_ERROR(Status) && FormBrowserEx2->IsResetRequired ()) {\r
+ StringBuffer1 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));\r
+ ASSERT (StringBuffer1 != NULL);\r
+ StringBuffer2 = AllocateZeroPool (MAX_STRING_LEN * sizeof (CHAR16));\r
+ ASSERT (StringBuffer2 != NULL);\r
+ StrCpyS (StringBuffer1, MAX_STRING_LEN, L"Configuration changed. Reset to apply it Now.");\r
+ StrCpyS (StringBuffer2, MAX_STRING_LEN, L"Press ENTER to reset");\r
+ //\r
+ // Popup a menu to notice user\r
+ //\r
+ do {\r
+ CreatePopUp (EFI_LIGHTGRAY | EFI_BACKGROUND_BLUE, &Key, StringBuffer1, StringBuffer2, NULL);\r
+ } while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);\r
+\r
+ FreePool (StringBuffer1);\r
+ FreePool (StringBuffer2);\r
+\r
+ gRT->ResetSystem (EfiResetCold, EFI_SUCCESS, 0, NULL);\r
+ }\r
+}\r
+\r
/**\r
Group the legacy boot options in the BootOption.\r
\r
- The routine assumes the boot options in the beginning that covers all the device \r
+ The routine assumes the boot options in the beginning that covers all the device\r
types are ordered properly and re-position the following boot options just after\r
the corresponding boot options with the same device type.\r
For example:\r
// Legacy Boot Option\r
//\r
DEBUG ((EFI_D_ERROR, "[BootManagerDxe] ==== Find Legacy Boot Option 0x%x! ==== \n", Index));\r
- ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption.FilePath)->DeviceType & 0xF) < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0]));\r
+ ASSERT ((((BBS_BBS_DEVICE_PATH *) BootOption.FilePath)->DeviceType & 0xF) < ARRAY_SIZE (DeviceTypeIndex));\r
NextIndex = &DeviceTypeIndex[((BBS_BBS_DEVICE_PATH *) BootOption.FilePath)->DeviceType & 0xF];\r
\r
if (*NextIndex == (UINTN) -1) {\r
//\r
// Update the DeviceTypeIndex array to reflect the right shift operation\r
//\r
- for (DeviceIndex = 0; DeviceIndex < sizeof (DeviceTypeIndex) / sizeof (DeviceTypeIndex[0]); DeviceIndex++) {\r
+ for (DeviceIndex = 0; DeviceIndex < ARRAY_SIZE (DeviceTypeIndex); DeviceIndex++) {\r
if (DeviceTypeIndex[DeviceIndex] != (UINTN) -1 && DeviceTypeIndex[DeviceIndex] >= *NextIndex) {\r
DeviceTypeIndex[DeviceIndex]++;\r
}\r
}\r
\r
/**\r
- This function invokes Boot Manager. If all devices have not a chance to be connected,\r
- the connect all will be triggered. It then enumerate all boot options. If \r
+ This function invokes Boot Manager. It then enumerate all boot options. If\r
a boot option from the Boot Manager page is selected, Boot Manager will boot\r
from this boot option.\r
- \r
+\r
**/\r
VOID\r
UpdateBootManager (\r
\r
DeviceType = (UINT16) -1;\r
\r
- EfiBootManagerConnectAll ();\r
-\r
//\r
// for better user experience\r
// 1. User changes HD configuration (e.g.: unplug HDD), here we have a chance to remove the HDD boot option\r
mKeyInput++;\r
\r
//\r
- // Don't display the hidden/inactive boot option\r
+ // Don't display hidden boot options, but retain inactive ones.\r
//\r
- if (((BootOption[Index].Attributes & LOAD_OPTION_HIDDEN) != 0) || ((BootOption[Index].Attributes & LOAD_OPTION_ACTIVE) == 0)) {\r
+ if ((BootOption[Index].Attributes & LOAD_OPTION_HIDDEN) != 0) {\r
continue;\r
}\r
\r
NeedEndOp = FALSE;\r
HiiCreateEndOpCode (StartOpCodeHandle);\r
}\r
- \r
+\r
if (IsLegacyOption && DeviceType != ((BBS_BBS_DEVICE_PATH *) BootOption[Index].FilePath)->DeviceType) {\r
if (NeedEndOp) {\r
HiiCreateEndOpCode (StartOpCodeHandle);\r
HiiHandle,\r
0,\r
mDeviceTypeStr[\r
- MIN (DeviceType & 0xF, sizeof (mDeviceTypeStr) / sizeof (mDeviceTypeStr[0]) - 1)\r
+ MIN (DeviceType & 0xF, ARRAY_SIZE (mDeviceTypeStr) - 1)\r
],\r
NULL\r
);\r
return EFI_NOT_FOUND;\r
}\r
\r
+/**\r
+ Initial the boot mode related parameters.\r
+\r
+**/\r
+VOID\r
+BmInitialBootModeInfo (\r
+ VOID\r
+ )\r
+{\r
+ EFI_STATUS Status;\r
+ EFI_GRAPHICS_OUTPUT_PROTOCOL *GraphicsOutput;\r
+ EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL *SimpleTextOut;\r
+ UINTN BootTextColumn;\r
+ UINTN BootTextRow;\r
+\r
+ if (mBmModeInitialized) {\r
+ return;\r
+ }\r
+\r
+ //\r
+ // After the console is ready, get current video resolution\r
+ // and text mode before launching setup at first time.\r
+ //\r
+ Status = gBS->HandleProtocol (\r
+ gST->ConsoleOutHandle,\r
+ &gEfiGraphicsOutputProtocolGuid,\r
+ (VOID**)&GraphicsOutput\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ GraphicsOutput = NULL;\r
+ }\r
+\r
+ Status = gBS->HandleProtocol (\r
+ gST->ConsoleOutHandle,\r
+ &gEfiSimpleTextOutProtocolGuid,\r
+ (VOID**)&SimpleTextOut\r
+ );\r
+ if (EFI_ERROR (Status)) {\r
+ SimpleTextOut = NULL;\r
+ }\r
+\r
+ if (GraphicsOutput != NULL) {\r
+ //\r
+ // Get current video resolution and text mode.\r
+ //\r
+ mBmBootHorizontalResolution = GraphicsOutput->Mode->Info->HorizontalResolution;\r
+ mBmBootVerticalResolution = GraphicsOutput->Mode->Info->VerticalResolution;\r
+ }\r
+\r
+ if (SimpleTextOut != NULL) {\r
+ Status = SimpleTextOut->QueryMode (\r
+ SimpleTextOut,\r
+ SimpleTextOut->Mode->Mode,\r
+ &BootTextColumn,\r
+ &BootTextRow\r
+ );\r
+ mBmBootTextModeColumn = (UINT32)BootTextColumn;\r
+ mBmBootTextModeRow = (UINT32)BootTextRow;\r
+ }\r
+\r
+ //\r
+ // Get user defined text mode for setup.\r
+ //\r
+ mBmSetupHorizontalResolution = PcdGet32 (PcdSetupVideoHorizontalResolution);\r
+ mBmSetupVerticalResolution = PcdGet32 (PcdSetupVideoVerticalResolution);\r
+ mBmSetupTextModeColumn = PcdGet32 (PcdSetupConOutColumn);\r
+ mBmSetupTextModeRow = PcdGet32 (PcdSetupConOutRow);\r
+\r
+ mBmModeInitialized = TRUE;\r
+}\r
+\r
/**\r
This call back function is registered with Boot Manager formset.\r
When user selects a boot option, this call back function will\r
gST->ConOut->SetAttribute (gST->ConOut, EFI_TEXT_ATTR (EFI_LIGHTGRAY, EFI_BLACK));\r
gST->ConOut->ClearScreen (gST->ConOut);\r
\r
+ //\r
+ //check any reset required change is applied? if yes, reset system\r
+ //\r
+ BmSetupResetReminder ();\r
+\r
//\r
// parse the selected option\r
//\r
- BmBdsSetConsoleMode (FALSE);\r
+ BmSetConsoleMode (FALSE);\r
EfiBootManagerBoot (&BootOption[QuestionId - 1]);\r
- BmBdsSetConsoleMode (TRUE);\r
+ BmSetConsoleMode (TRUE);\r
\r
if (EFI_ERROR (BootOption[QuestionId - 1].Status)) {\r
gST->ConOut->OutputString (\r
);\r
ASSERT (gBootManagerPrivate.HiiHandle != NULL);\r
\r
+ BmInitialBootModeInfo ();\r
\r
return EFI_SUCCESS;\r
}\r