From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga03.intel.com (mga03.intel.com [134.134.136.65]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 5E2E221D0DE6A for ; Thu, 20 Jul 2017 22:37:33 -0700 (PDT) Received: from fmsmga006.fm.intel.com ([10.253.24.20]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 20 Jul 2017 22:39:29 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.40,388,1496127600"; d="scan'208";a="130029677" Received: from shwdeopenpsi114.ccr.corp.intel.com ([10.239.157.135]) by fmsmga006.fm.intel.com with ESMTP; 20 Jul 2017 22:39:28 -0700 From: Dandan Bi To: edk2-devel@lists.01.org Cc: Eric Dong , Liming Gao Date: Fri, 21 Jul 2017 13:39:01 +0800 Message-Id: <1500615542-168644-3-git-send-email-dandan.bi@intel.com> X-Mailer: git-send-email 1.9.5.msysgit.1 In-Reply-To: <1500615542-168644-1-git-send-email-dandan.bi@intel.com> References: <1500615542-168644-1-git-send-email-dandan.bi@intel.com> Subject: [patch 2/3] MdeModulePkg/BMUiLib: Check reset requirement before exiting UiApp X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 21 Jul 2017 05:37:33 -0000 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 Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi --- .../Library/BootManagerUiLib/BootManager.c | 52 +++++++++++++++++++++- .../Library/BootManagerUiLib/BootManager.h | 4 +- .../Library/BootManagerUiLib/BootManagerUiLib.inf | 3 +- 3 files changed, 56 insertions(+), 3 deletions(-) diff --git a/MdeModulePkg/Library/BootManagerUiLib/BootManager.c b/MdeModulePkg/Library/BootManagerUiLib/BootManager.c index bf872f8..30d947a 100644 --- a/MdeModulePkg/Library/BootManagerUiLib/BootManager.c +++ b/MdeModulePkg/Library/BootManagerUiLib/BootManager.c @@ -1,9 +1,9 @@ /** @file The boot manager reference implementation -Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, 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 http://opensource.org/licenses/bsd-license.php. @@ -292,10 +292,55 @@ BmSetConsoleMode ( return EFI_SUCCESS; } /** + 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 +BmSetupResetReminder ( + 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_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 types are ordered properly and re-position the following boot options just after the corresponding boot options with the same device type. @@ -780,10 +825,15 @@ 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 // BmSetConsoleMode (FALSE); EfiBootManagerBoot (&BootOption[QuestionId - 1]); BmSetConsoleMode (TRUE); diff --git a/MdeModulePkg/Library/BootManagerUiLib/BootManager.h b/MdeModulePkg/Library/BootManagerUiLib/BootManager.h index 1bedff4..3adddf6 100644 --- a/MdeModulePkg/Library/BootManagerUiLib/BootManager.h +++ b/MdeModulePkg/Library/BootManagerUiLib/BootManager.h @@ -1,9 +1,9 @@ /** @file The boot manager reference implementation -Copyright (c) 2004 - 2015, Intel Corporation. All rights reserved.
+Copyright (c) 2004 - 2017, 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 http://opensource.org/licenses/bsd-license.php. @@ -18,10 +18,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include #include +#include #include #include #include #include @@ -53,10 +54,11 @@ typedef struct { #define BOOT_MANAGER_FORM_ID 0x1000 #define LABEL_BOOT_OPTION 0x00 #define LABEL_BOOT_OPTION_END 0x01 +#define MAX_STRING_LEN 200 // // Variable created with this flag will be "Efi:...." // #define VAR_FLAG EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS | EFI_VARIABLE_NON_VOLATILE diff --git a/MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf b/MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf index d2df24b..7983b07 100644 --- a/MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf +++ b/MdeModulePkg/Library/BootManagerUiLib/BootManagerUiLib.inf @@ -1,9 +1,9 @@ ## @file # Boot Manager Library used by UiApp. # -# Copyright (c) 2011 - 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2011 - 2017, 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 # http://opensource.org/licenses/bsd-license.php. # @@ -54,10 +54,11 @@ gEfiIfrFrontPageGuid ## CONSUMES ## GUID [Protocols] gEfiHiiConfigAccessProtocolGuid ## CONSUMES gEfiDevicePathToTextProtocolGuid ## CONSUMES + gEdkiiFormBrowserEx2ProtocolGuid ## CONSUMES [FeaturePcd] [Pcd] gEfiMdeModulePkgTokenSpaceGuid.PcdConOutRow ## CONSUMES -- 1.9.5.msysgit.1