]> git.proxmox.com Git - mirror_edk2.git/blobdiff - MdeModulePkg/Library/BootManagerUiLib/BootManager.c
MdeModulePkg: Clean up source files
[mirror_edk2.git] / MdeModulePkg / Library / BootManagerUiLib / BootManager.c
index cab38ca28087c1a79feea91233e5db753e8543a1..7f3edc3d3dfd0d0bb3b93d55fea7adfa779a586f 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The boot manager reference implementation\r
 \r
-Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2018, 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
@@ -62,7 +62,7 @@ HII_VENDOR_DEVICE_PATH  mBootManagerHiiVendorDevicePath = {
   {\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
@@ -82,9 +82,9 @@ BOOT_MANAGER_CALLBACK_DATA  gBootManagerPrivate = {
 \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
@@ -111,13 +111,13 @@ BmSetConsoleMode (
   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
@@ -156,7 +156,7 @@ BmSetConsoleMode (
     NewHorizontalResolution = mBmBootHorizontalResolution;\r
     NewVerticalResolution   = mBmBootVerticalResolution;\r
     NewColumns              = mBmBootTextModeColumn;\r
-    NewRows                 = mBmBootTextModeRow;   \r
+    NewRows                 = mBmBootTextModeRow;\r
   }\r
 \r
   if (GraphicsOutput != NULL) {\r
@@ -293,10 +293,54 @@ BmSetConsoleMode (
   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
@@ -343,7 +387,7 @@ GroupMultipleLegacyBootOption4SameType (
       // 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
@@ -362,7 +406,7 @@ GroupMultipleLegacyBootOption4SameType (
         //\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
@@ -422,7 +466,7 @@ BmDevicePathToStr (
   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
@@ -515,7 +559,7 @@ UpdateBootManager (
       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
@@ -526,7 +570,7 @@ UpdateBootManager (
                      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
@@ -781,6 +825,11 @@ BootManagerCallback (
   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