From dfc55275908142e41293911bbda9be49365fb2a1 Mon Sep 17 00:00:00 2001 From: Dandan Bi Date: Tue, 22 Aug 2017 15:06:21 +0800 Subject: [PATCH] MdeModulePkg/DriverSample: Add sample case for popup protocol Add one sample case about how to use HiiPopup protocol to draw message box. Cc: Eric Dong Cc: Liming Gao Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi Reviewed-by: Liming Gao --- .../Universal/DriverSampleDxe/DriverSample.c | 29 +++++++++++++++++++ .../Universal/DriverSampleDxe/DriverSample.h | 4 ++- .../DriverSampleDxe/DriverSampleDxe.inf | 3 +- .../Universal/DriverSampleDxe/Vfr.vfr | 10 +++++-- .../Universal/DriverSampleDxe/VfrStrings.uni | 8 ++++- 5 files changed, 49 insertions(+), 5 deletions(-) diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c index f103b9ca21..bbd9713eea 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c @@ -1100,6 +1100,9 @@ DriverCallback ( CHAR16 *TmpStr; UINTN Index; UINT64 BufferValue; + EFI_HII_POPUP_SELECTION UserSelection; + + UserSelection = 0xFF; if (((Value == NULL) && (Action != EFI_BROWSER_ACTION_FORM_OPEN) && (Action != EFI_BROWSER_ACTION_FORM_CLOSE))|| (ActionRequest == NULL)) { @@ -1619,6 +1622,22 @@ DriverCallback ( } break; + case 0x1330: + Status = mPrivateData->HiiPopup->CreatePopup ( + mPrivateData->HiiPopup, + EfiHiiPopupStyleInfo, + EfiHiiPopupTypeYesNo, + mPrivateData->HiiHandle[0], + STRING_TOKEN (STR_POPUP_STRING), + &UserSelection + ); + if (!EFI_ERROR (Status)) { + if (UserSelection == EfiHiiPopupSelectionYes) { + *ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT; + } + } + break; + default: break; } @@ -1678,6 +1697,7 @@ DriverSampleInit ( EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2; EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL *HiiKeywordHandler; + EFI_HII_POPUP_PROTOCOL *PopupHandler; CHAR16 *NewString; UINTN BufferSize; DRIVER_SAMPLE_CONFIGURATION *Configuration; @@ -1763,6 +1783,15 @@ DriverSampleInit ( } mPrivateData->HiiKeywordHandler = HiiKeywordHandler; + // + // Locate HiiPopup protocol + // + Status = gBS->LocateProtocol (&gEfiHiiPopupProtocolGuid, NULL, (VOID **) &PopupHandler); + if (EFI_ERROR (Status)) { + return Status; + } + mPrivateData->HiiPopup = PopupHandler; + Status = gBS->InstallMultipleProtocolInterfaces ( &DriverHandle[0], &gEfiDevicePathProtocolGuid, diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h index 6c97239cf3..507cff6ec9 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h @@ -1,6 +1,6 @@ /** @file -Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+Copyright (c) 2007 - 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 which accompanies this distribution. The full text of the license may be found at @@ -33,6 +33,7 @@ Revision History #include #include #include +#include #include #include @@ -98,6 +99,7 @@ typedef struct { EFI_HII_STRING_PROTOCOL *HiiString; EFI_HII_CONFIG_ROUTING_PROTOCOL *HiiConfigRouting; EFI_CONFIG_KEYWORD_HANDLER_PROTOCOL *HiiKeywordHandler; + EFI_HII_POPUP_PROTOCOL *HiiPopup; EFI_FORM_BROWSER2_PROTOCOL *FormBrowser2; diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf b/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf index 4233e635bc..bfd7484518 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf +++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf @@ -4,7 +4,7 @@ # This driver shows how HII protocol, VFR and UNI files are used to create a HII # driver which can be dipslayed and configured by a UEFI HII Form Browser. # -# Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.
+# Copyright (c) 2007 - 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 @@ -93,6 +93,7 @@ gEfiSimpleTextInputExProtocolGuid ## SOMETIMES_CONSUMES gEdkiiFormBrowserExProtocolGuid ## CONSUMES gEfiConfigKeywordHandlerProtocolGuid ## CONSUMES + gEfiHiiPopupProtocolGuid ## CONSUMES [Depex] gEfiSimpleTextOutProtocolGuid AND gEfiHiiDatabaseProtocolGuid AND gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid diff --git a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr index 4bdaf765bc..d547ec809b 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr +++ b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr @@ -2,7 +2,7 @@ // // Sample Setup formset. // -// 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 // which accompanies this distribution. The full text of the license may be found at @@ -476,7 +476,13 @@ formset maximum = 255, default = 18, endnumeric; - + + text + help = STRING_TOKEN(STR_POPUP_TEST_HELP), + text = STRING_TOKEN(STR_POPUP_TEST_PROMPT), + flags = INTERACTIVE, + key = 0x1330; + goto 2, prompt = STRING_TOKEN(STR_GOTO_FORM2), //SecondSetupPage // this too has no end-op and basically it's a jump to a form ONLY help = STRING_TOKEN(STR_GOTO_HELP); diff --git a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni index 8d24a476f3..6a268d1236 100644 --- a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni +++ b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni @@ -1,6 +1,6 @@ // *++ // -// Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.
+// Copyright (c) 2007 - 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 // which accompanies this distribution. The full text of the license may be found at @@ -267,6 +267,12 @@ #language fr-FR "Submitted callback test" #string STR_SUBMITTED_CALLBACK_TEST_HELP #language en-US "Change the value and press F10 to submmit will pop up a dialogue to show SUBMITTED Callback has been triggered" #language fr-FR "Change the value and press F10 to submmit will pop up a dialogue to show SUBMITTED Callback has been triggered" +#string STR_POPUP_TEST_PROMPT #language en-US "Select it to invoke Hii Popup Protocol" + #language fr-FR "Select it to invoke Hii Popup Protocol" +#string STR_POPUP_TEST_HELP #language en-US "Select this question will pop up a message box, then user can decide whether exit curret form or not" + #language fr-FR "Select this question will pop up a message box, then user can decide whether exit curret form or not" +#string STR_POPUP_STRING #language en-US "Are you sure to exit current form?" + #language fr-FR "Are you sure to exit current form?" // Boot Order #string STR_BOOT_TITLE #language en-US "Boot" #string STR_BOOT_OPTIONS #language en-US "Boot Order" -- 2.39.2