public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: Dandan Bi <dandan.bi@intel.com>
To: edk2-devel@lists.01.org
Cc: Eric Dong <eric.dong@intel.com>, Liming Gao <liming.gao@intel.com>
Subject: [patch 3/3] MdeModulePkg/BMMUiLib: Check reset requirement before exiting UiApp
Date: Fri, 21 Jul 2017 13:39:02 +0800	[thread overview]
Message-ID: <1500615542-168644-4-git-send-email-dandan.bi@intel.com> (raw)
In-Reply-To: <1500615542-168644-1-git-send-email-dandan.bi@intel.com>

In UI page, some configuration change may require system reset.
BootMaintenanceManagerUiLib 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>
---
 .../BootMaintenanceManager.h                       |  1 +
 .../BootMaintenanceManagerUiLib.inf                |  3 +-
 .../BootMaintenanceManagerUiLib/BootOption.c       | 50 ++++++++++++++++++++++
 3 files changed, 53 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h
index a8d7a0f..99d1656 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManager.h
@@ -26,10 +26,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Protocol/LoadFile.h>
 #include <Protocol/HiiConfigAccess.h>
 #include <Protocol/SimpleFileSystem.h>
 #include <Protocol/SerialIo.h>
 #include <Protocol/DevicePathToText.h>
+#include <Protocol/FormBrowserEx2.h>
 
 #include <Library/PrintLib.h>
 #include <Library/DebugLib.h>
 #include <Library/BaseMemoryLib.h>
 #include <Library/UefiBootServicesTableLib.h>
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf
index 6f2cda3..1c0c0e1 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootMaintenanceManagerUiLib.inf
@@ -1,9 +1,9 @@
 ## @file
 #  Boot Maintenance Manager Library used by UiApp.
 #
-#  Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.<BR>
+#  Copyright (c) 2011 - 2017, Intel Corporation. All rights reserved.<BR>
 #  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
 #  http://opensource.org/licenses/bsd-license.php.
 #  
@@ -89,10 +89,11 @@
   gEfiSimpleFileSystemProtocolGuid              ## CONSUMES
   gEfiLoadFileProtocolGuid                      ## CONSUMES
   gEfiHiiConfigAccessProtocolGuid               ## CONSUMES
   gEfiSerialIoProtocolGuid                      ## CONSUMES
   gEfiDevicePathToTextProtocolGuid              ## CONSUMES
+  gEdkiiFormBrowserEx2ProtocolGuid              ## CONSUMES
 
 [FeaturePcd]
 
 [Pcd]
   gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow                  ## CONSUMES
diff --git a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c
index 890728a..0a08573 100644
--- a/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c
+++ b/MdeModulePkg/Library/BootMaintenanceManagerUiLib/BootOption.c
@@ -22,10 +22,56 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 /// Define the maximum characters that will be accepted.
 ///
 #define MAX_CHAR            480
 
 /**
+  Check whether a reset is needed, and finish the reset reminder feature.
+  If a reset is needed, Popup a menu to notice user, and finish the feature
+  according to the user selection.
+
+**/
+VOID
+BmmSetupResetReminder (
+  VOID
+  )
+{
+  EFI_INPUT_KEY                 Key;
+  CHAR16                        *StringBuffer1;
+  CHAR16                        *StringBuffer2;
+  EFI_STATUS                    Status;
+  EDKII_FORM_BROWSER_EXTENSION2_PROTOCOL *FormBrowserEx2;
+
+  //
+  // Use BrowserEx2 protocol to register HotKey.
+  //
+  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_CHAR * sizeof (CHAR16));
+    ASSERT (StringBuffer1 != NULL);
+    StringBuffer2 = AllocateZeroPool (MAX_CHAR * sizeof (CHAR16));
+    ASSERT (StringBuffer2 != NULL);
+    StrCpyS (StringBuffer1, MAX_CHAR, L"Configuration changed. Reset to apply it Now.");
+    StrCpyS (StringBuffer2, MAX_CHAR, 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);
+  }
+}
+
+/**
   Create a menu entry by given menu type.
 
   @param MenuType        The Menu type to be created.
 
   @retval NULL           If failed to create the menu.
@@ -881,10 +927,14 @@ BootFromFile (
       );
     //
     // Since current no boot from removable media directly is allowed */
     //
     gST->ConOut->ClearScreen (gST->ConOut);
+    //
+    // Check whether need to reset system.
+    //
+    BmmSetupResetReminder ();
 
     BmmSetConsoleMode (FALSE);
     EfiBootManagerBoot (&BootOption);
     BmmSetConsoleMode (TRUE);
 
-- 
1.9.5.msysgit.1



      parent reply	other threads:[~2017-07-21  5:37 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-07-21  5:38 [patch 0/3] Check reset requirement before exiting UiApp Dandan Bi
2017-07-21  5:39 ` [patch 1/3] MdeModulePkg/SetupBrowser: Record the reset status in all SendForm Dandan Bi
2017-07-21  5:39 ` [patch 2/3] MdeModulePkg/BMUiLib: Check reset requirement before exiting UiApp Dandan Bi
2017-07-21  5:39 ` Dandan Bi [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1500615542-168644-4-git-send-email-dandan.bi@intel.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox