]> git.proxmox.com Git - mirror_edk2.git/commitdiff
MdeModulePkg/BMUiLib: Check reset requirement before exiting UiApp
authorBi, Dandan <dandan.bi@intel.com>
Fri, 21 Jul 2017 08:56:02 +0000 (16:56 +0800)
committerLiming Gao <liming.gao@intel.com>
Thu, 27 Jul 2017 02:47:15 +0000 (10:47 +0800)
V2: Refine the comments.

In UI page, some configuration change may require system reset.
BootManagerUiLib misses this check before exiting UiApp to boot
other boot options. Now add the check.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <dandan.bi@intel.com>
Reviewed-by: Liming Gao <liming.gao@intel.com>
MdeModulePkg/Library/BootManagerUiLib/BootManager.c
MdeModulePkg/Library/BootManagerUiLib/BootManager.h
MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf

index bf872f867e0800bcfee8ad925e53ea9a1c2eeb2d..8e776327883a9ae732255eba3bd44809af7a9364 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 - 2017, 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
@@ -293,6 +293,50 @@ 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
@@ -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
index 1bedff412bb89968bc07a2aa1d723568c1a95807..3adddf637f048921c7a9b0d932c5f3c1bed661b3 100644 (file)
@@ -1,7 +1,7 @@
 /** @file\r
   The boot manager reference implementation\r
 \r
-Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.<BR>\r
+Copyright (c) 2004 - 2017, 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
@@ -20,6 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 \r
 #include <Protocol/HiiConfigAccess.h>\r
 #include <Protocol/DevicePathToText.h>\r
+#include <Protocol/FormBrowserEx2.h>\r
 \r
 #include <Library/PrintLib.h>\r
 #include <Library/DebugLib.h>\r
@@ -55,6 +56,7 @@ typedef struct {
 \r
 #define LABEL_BOOT_OPTION        0x00\r
 #define LABEL_BOOT_OPTION_END    0x01\r
+#define MAX_STRING_LEN           200\r
 \r
 //\r
 // Variable created with this flag will be "Efi:...."\r
index d2df24b4bdae247f29d11cba3e57a8cfce7affcd..7983b0794938d4628ec4d20ef86aa4fa8e125414 100644 (file)
@@ -1,7 +1,7 @@
 ## @file\r
 #  Boot Manager Library used by UiApp.\r
 #\r
-#  Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>\r
+#  Copyright (c) 2011 - 2017, 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
@@ -56,6 +56,7 @@
 [Protocols]\r
   gEfiHiiConfigAccessProtocolGuid               ## CONSUMES\r
   gEfiDevicePathToTextProtocolGuid              ## CONSUMES\r
+  gEdkiiFormBrowserEx2ProtocolGuid              ## CONSUMES\r
 \r
 [FeaturePcd]\r
 \r