public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [patch 0/3] Add HII Popup Protocol
@ 2017-08-15  3:07 Dandan Bi
  2017-08-15  3:07 ` [patch 1/3] MdePkg/HiiPopup: Add HII Popup Protocol definitions Dandan Bi
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Dandan Bi @ 2017-08-15  3:07 UTC (permalink / raw)
  To: edk2-devel; +Cc: Eric Dong, Liming Gao

Patch 1: Add the definition of HII Popup Protocol.
Patch 2: Add the implementation of HII Popup Protocol.
Patch 3: Add one sample use case of HII Popup Protocol.

Cc: Eric Dong <eric.dong@intel.com>
Cc: Liming Gao <liming.gao@intel.com>
Dandan Bi (3):
  MdePkg/HiiPopup: Add HII Popup Protocol definitions
  MdeModulePkg/DisplayEngine: Add implementation of HiiPopup protocol
  MdeModulePkg/DriverSample: Add sample case for popup protocol

 .../DisplayEngineDxe/DisplayEngineDxe.inf          |   4 +-
 .../Universal/DisplayEngineDxe/FormDisplay.c       |  33 ++
 .../Universal/DisplayEngineDxe/FormDisplay.h       |  76 ++-
 .../Universal/DisplayEngineDxe/FormDisplayStr.uni  |  14 +-
 MdeModulePkg/Universal/DisplayEngineDxe/Popup.c    | 610 +++++++++++++++++++++
 .../Universal/DriverSampleDxe/DriverSample.c       |  29 +
 .../Universal/DriverSampleDxe/DriverSample.h       |   2 +
 .../Universal/DriverSampleDxe/DriverSampleDxe.inf  |   1 +
 MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr     |   8 +-
 .../Universal/DriverSampleDxe/VfrStrings.uni       |   6 +
 MdePkg/Include/Protocol/HiiPopup.h                 |  81 +++
 MdePkg/MdePkg.dec                                  |   3 +
 12 files changed, 863 insertions(+), 4 deletions(-)
 create mode 100644 MdeModulePkg/Universal/DisplayEngineDxe/Popup.c
 create mode 100644 MdePkg/Include/Protocol/HiiPopup.h

-- 
1.9.5.msysgit.1



^ permalink raw reply	[flat|nested] 4+ messages in thread

* [patch 1/3] MdePkg/HiiPopup: Add HII Popup Protocol definitions
  2017-08-15  3:07 [patch 0/3] Add HII Popup Protocol Dandan Bi
@ 2017-08-15  3:07 ` Dandan Bi
  2017-08-15  3:07 ` [patch 2/3] MdeModulePkg/DisplayEngine: Add implementation of HiiPopup protocol Dandan Bi
  2017-08-15  3:08 ` [patch 3/3] MdeModulePkg/DriverSample: Add sample case for popup protocol Dandan Bi
  2 siblings, 0 replies; 4+ messages in thread
From: Dandan Bi @ 2017-08-15  3:07 UTC (permalink / raw)
  To: edk2-devel; +Cc: Eric Dong, Liming Gao

Add definitions for HII Popup Protocol according to UEFI2.7.

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>
---
 MdePkg/Include/Protocol/HiiPopup.h | 81 ++++++++++++++++++++++++++++++++++++++
 MdePkg/MdePkg.dec                  |  3 ++
 2 files changed, 84 insertions(+)
 create mode 100644 MdePkg/Include/Protocol/HiiPopup.h

diff --git a/MdePkg/Include/Protocol/HiiPopup.h b/MdePkg/Include/Protocol/HiiPopup.h
new file mode 100644
index 0000000..57e36c6
--- /dev/null
+++ b/MdePkg/Include/Protocol/HiiPopup.h
@@ -0,0 +1,81 @@
+/** @file
+  This protocol provides services to display a popup window.
+  The protocol is typically produced by the forms browser and consumed by a driver callback handler.
+
+  Copyright (c) 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.
+
+  THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+  WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#ifndef __HII_POPUP_H__
+#define __HII_POPUP_H__
+
+#define EFI_HII_POPUP_PROTOCOL_GUID \
+  {0x4311edc0, 0x6054, 0x46d4, {0x9e, 0x40, 0x89, 0x3e, 0xa9, 0x52, 0xfc, 0xcc}}
+
+#define EFI_HII_POPUP_PROTOCOL_REVISION 1
+
+typedef struct _EFI_HII_POPUP_PROTOCOL EFI_HII_POPUP_PROTOCOL;
+
+typedef enum {
+  EfiHiiPopupStyleInfo,
+  EfiHiiPopupStyleWarning,
+  EfiHiiPopupStyleError
+} EFI_HII_POPUP_STYLE;
+
+typedef enum {
+  EfiHiiPopupTypeOk,
+  EfiHiiPopupTypeOkCancel,
+  EfiHiiPopupTypeYesNo,
+  EfiHiiPopupTypeYesNoCancel
+} EFI_HII_POPUP_TYPE;
+
+typedef enum {
+  EfiHiiPopupSelectionOk,
+  EfiHiiPopupSelectionCancel,
+  EfiHiiPopupSelectionYes,
+  EfiHiiPopupSelectionNo
+} EFI_HII_POPUP_SELECTION;
+
+/**
+  Displays a popup window.
+
+  @param  This           A pointer to the EFI_HII_POPUP_PROTOCOL instance.
+  @param  PopupStyle     Popup style to use.
+  @param  PopupType      Type of the popup to display.
+  @param  HiiHandle      HII handle of the string pack containing Message
+  @param  Message        A message to display in the popup box.
+  @param  UserSelection  User selection.
+
+  @retval EFI_SUCCESS            The popup box was successfully displayed.
+  @retval EFI_INVALID_PARAMETER  HiiHandle and Message do not define a valid HII string.
+  @retval EFI_INVALID_PARAMETER  PopupType is not one of the values defined by this specification.
+  @retval EFI_OUT_OF_RESOURCES   There are not enough resources available to display the popup box.
+
+**/
+typedef
+EFI_STATUS
+(EFIAPI * EFI_HII_CREATE_POPUP) (
+  IN  EFI_HII_POPUP_PROTOCOL  *This,
+  IN  EFI_HII_POPUP_STYLE     PopupStyle,
+  IN  EFI_HII_POPUP_TYPE      PopupType,
+  IN  EFI_HII_HANDLE          HiiHandle,
+  IN  EFI_STRING_ID           Message,
+  OUT EFI_HII_POPUP_SELECTION *UserSelection OPTIONAL
+);
+
+typedef struct _EFI_HII_POPUP_PROTOCOL {
+  UINT64 Revision;
+  EFI_HII_CREATE_POPUP CreatePopup;
+} EFI_HII_POPUP_PROTOCOL;
+
+extern EFI_GUID gEfiHiiPopupProtocolGuid;
+
+#endif
+
diff --git a/MdePkg/MdePkg.dec b/MdePkg/MdePkg.dec
index d6928b3..6403002 100644
--- a/MdePkg/MdePkg.dec
+++ b/MdePkg/MdePkg.dec
@@ -1409,10 +1409,13 @@
   gEfiTcg2FinalEventsTableGuid   = {0x1e2ed096, 0x30e2, 0x4254, { 0xbd, 0x89, 0x86, 0x3b, 0xbe, 0xf8, 0x23, 0x25 }}
 
   ## Include/Protocol/FormBrowser2.h
   gEfiFormBrowser2ProtocolGuid   =   {0xb9d4c360, 0xbcfb, 0x4f9b, {0x92, 0x98, 0x53, 0xc1, 0x36, 0x98, 0x22, 0x58}}
 
+  ## Include/Protocol/HiiPopup.h
+  gEfiHiiPopupProtocolGuid       =   {0x4311edc0, 0x6054, 0x46d4, {0x9e, 0x40, 0x89, 0x3e, 0xa9, 0x52, 0xfc, 0xcc}}
+
   ## Include/Protocol/HiiString.h
   gEfiHiiStringProtocolGuid      =   {0x0fd96974, 0x23aa, 0x4cdc, {0xb9, 0xcb, 0x98, 0xd1, 0x77, 0x50, 0x32, 0x2a}}
 
   ## Include/Protocol/HiiImage.h
   gEfiHiiImageProtocolGuid       =   {0x31a6406a, 0x6bdf, 0x4e46, {0xb2, 0xa2, 0xeb, 0xaa, 0x89, 0xc4, 0x09, 0x20}}
-- 
1.9.5.msysgit.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [patch 2/3] MdeModulePkg/DisplayEngine: Add implementation of HiiPopup protocol
  2017-08-15  3:07 [patch 0/3] Add HII Popup Protocol Dandan Bi
  2017-08-15  3:07 ` [patch 1/3] MdePkg/HiiPopup: Add HII Popup Protocol definitions Dandan Bi
@ 2017-08-15  3:07 ` Dandan Bi
  2017-08-15  3:08 ` [patch 3/3] MdeModulePkg/DriverSample: Add sample case for popup protocol Dandan Bi
  2 siblings, 0 replies; 4+ messages in thread
From: Dandan Bi @ 2017-08-15  3:07 UTC (permalink / raw)
  To: edk2-devel; +Cc: Eric Dong, Liming Gao

Add the implementation of HiiPopup protocol in DisplayEngineDxe,
since DisplayEngineDxe is responsible for drawing tasks.

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>
---
 .../DisplayEngineDxe/DisplayEngineDxe.inf          |   4 +-
 .../Universal/DisplayEngineDxe/FormDisplay.c       |  33 ++
 .../Universal/DisplayEngineDxe/FormDisplay.h       |  76 ++-
 .../Universal/DisplayEngineDxe/FormDisplayStr.uni  |  14 +-
 MdeModulePkg/Universal/DisplayEngineDxe/Popup.c    | 610 +++++++++++++++++++++
 5 files changed, 734 insertions(+), 3 deletions(-)
 create mode 100644 MdeModulePkg/Universal/DisplayEngineDxe/Popup.c

diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf b/MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
index bf5e8e5..fa7b2ca 100644
--- a/MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
+++ b/MdeModulePkg/Universal/DisplayEngineDxe/DisplayEngineDxe.inf
@@ -1,9 +1,9 @@
 ## @file
 # The DXE driver produces FORM DISPLAY ENGIEN protocol.
 #
-# Copyright (c) 2007 - 2014, Intel Corporation. All rights reserved.<BR>
+# Copyright (c) 2007 - 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
 #  which accompanies this distribution. The full text of the license may be found at
 #  http://opensource.org/licenses/bsd-license.php
@@ -33,10 +33,11 @@
   FormDisplayStr.uni
   FormDisplay.c
   FormDisplay.h
   ProcessOptions.c
   InputHandler.c
+  Popup.c
   
 [Packages]
   MdePkg/MdePkg.dec
   MdeModulePkg/MdeModulePkg.dec
   
@@ -52,10 +53,11 @@
   CustomizedDisplayLib
 
 [Protocols]
   gEdkiiFormDisplayEngineProtocolGuid   ## PRODUCES
   gEdkiiFormBrowserEx2ProtocolGuid      ## CONSUMES
+  gEfiHiiPopupProtocolGuid              ## PRODUCES
 
 [Depex]
   gEfiHiiDatabaseProtocolGuid AND gEfiHiiConfigRoutingProtocolGuid AND gEdkiiFormBrowserEx2ProtocolGuid
   
 [FeaturePcd]
diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
index dc4ae4b..8d48ed1 100644
--- a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
+++ b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.c
@@ -149,10 +149,16 @@ CHAR16            *gConfirmDefaultMsg2nd;
 CHAR16            *gConfirmResetMsg2nd;
 CHAR16            *gConfirmExitMsg2nd;
 CHAR16            *gConfirmOpt;
 CHAR16            *gConfirmOptYes;
 CHAR16            *gConfirmOptNo;
+CHAR16            *gConfirmOptOk;
+CHAR16            *gConfirmOptCancel;
+CHAR16            *gYesOption;
+CHAR16            *gNoOption;
+CHAR16            *gOkOption;
+CHAR16            *gCancelOption;
 CHAR16            *gConfirmMsgConnect;
 CHAR16            *gConfirmMsgEnd;
 CHAR16            *gPasswordUnsupported;
 CHAR16            gModalSkipColumn;
 CHAR16            gPromptBlockWidth;
@@ -165,10 +171,14 @@ FORM_DISPLAY_DRIVER_PRIVATE_DATA  mPrivateData = {
   NULL,
   {
     FormDisplay,
     DriverClearDisplayPage,
     ConfirmDataChange
+  },
+  {
+    EFI_HII_POPUP_PROTOCOL_REVISION,
+    CreatePopup
   }
 };
 
 
 /**
@@ -245,10 +255,16 @@ InitializeDisplayStrings (
   gConfirmResetMsg2nd   = GetToken (STRING_TOKEN (CONFIRM_RESET_MESSAGE_2ND), gHiiHandle);
   gConfirmExitMsg2nd    = GetToken (STRING_TOKEN (CONFIRM_EXIT_MESSAGE_2ND), gHiiHandle);
   gConfirmOpt           = GetToken (STRING_TOKEN (CONFIRM_OPTION), gHiiHandle);
   gConfirmOptYes        = GetToken (STRING_TOKEN (CONFIRM_OPTION_YES), gHiiHandle);
   gConfirmOptNo         = GetToken (STRING_TOKEN (CONFIRM_OPTION_NO), gHiiHandle);
+  gConfirmOptOk         = GetToken (STRING_TOKEN (CONFIRM_OPTION_OK), gHiiHandle);
+  gConfirmOptCancel     = GetToken (STRING_TOKEN (CONFIRM_OPTION_CANCEL), gHiiHandle);
+  gYesOption            = GetToken (STRING_TOKEN (YES_SELECTABLE_OPTION), gHiiHandle);
+  gNoOption             = GetToken (STRING_TOKEN (NO_SELECTABLE_OPTION), gHiiHandle);
+  gOkOption             = GetToken (STRING_TOKEN (OK_SELECTABLE_OPTION), gHiiHandle);
+  gCancelOption         = GetToken (STRING_TOKEN (CANCEL_SELECTABLE_OPTION), gHiiHandle);
   gConfirmMsgConnect    = GetToken (STRING_TOKEN (CONFIRM_OPTION_CONNECT), gHiiHandle);
   gConfirmMsgEnd        = GetToken (STRING_TOKEN (CONFIRM_OPTION_END), gHiiHandle);
   gPasswordUnsupported  = GetToken (STRING_TOKEN (PASSWORD_NOT_SUPPORTED ), gHiiHandle);
 }
 
@@ -299,10 +315,16 @@ FreeDisplayStrings (
   FreePool (gConfirmResetMsg2nd);
   FreePool (gConfirmExitMsg2nd);
   FreePool (gConfirmOpt);
   FreePool (gConfirmOptYes);
   FreePool (gConfirmOptNo);
+  FreePool (gConfirmOptOk);
+  FreePool (gConfirmOptCancel);
+  FreePool (gYesOption);
+  FreePool (gNoOption);
+  FreePool (gOkOption);
+  FreePool (gCancelOption);
   FreePool (gConfirmMsgConnect);
   FreePool (gConfirmMsgEnd);
   FreePool (gPasswordUnsupported);
 }
 
@@ -4117,10 +4139,21 @@ InitializeDisplayEngine (
                   EFI_NATIVE_INTERFACE,
                   &mPrivateData.FromDisplayProt
                   );
   ASSERT_EFI_ERROR (Status);
 
+  //
+  // Install HII Popup Protocol.
+  //
+  Status = gBS->InstallProtocolInterface (
+                 &mPrivateData.Handle,
+                 &gEfiHiiPopupProtocolGuid,
+                 EFI_NATIVE_INTERFACE,
+                 &mPrivateData.HiiPopup
+                );
+  ASSERT_EFI_ERROR (Status);
+
   InitializeDisplayStrings();
   
   ZeroMem (&gHighligthMenuInfo, sizeof (gHighligthMenuInfo));
   ZeroMem (&gOldFormEntry, sizeof (gOldFormEntry));
 
diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.h b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.h
index 45532ab..658528a 100644
--- a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.h
+++ b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplay.h
@@ -1,9 +1,9 @@
 /** @file
   FormDiplay protocol to show Form
 
-Copyright (c) 2013 - 2016, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2013 - 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.                                            
 
@@ -26,10 +26,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
 #include <Library/CustomizedDisplayLib.h>
 
 #include <Protocol/FormBrowserEx2.h>
 #include <Protocol/SimpleTextIn.h>
 #include <Protocol/DisplayProtocol.h>
+#include <Protocol/HiiPopup.h>
 
 #include <Guid/MdeModuleHii.h>
 
 //
 // This is the generated header file which includes whatever needs to be exported (strings + IFR)
@@ -39,10 +40,18 @@ extern EFI_SCREEN_DESCRIPTOR         gStatementDimensions;
 extern USER_INPUT                    *gUserInput;
 extern FORM_DISPLAY_ENGINE_FORM      *gFormData;
 extern EFI_HII_HANDLE                gHiiHandle;
 extern UINT16                        gDirection;
 extern LIST_ENTRY                    gMenuOption;
+extern CHAR16                        *gConfirmOptYes;
+extern CHAR16                        *gConfirmOptNo;
+extern CHAR16                        *gConfirmOptOk;
+extern CHAR16                        *gConfirmOptCancel;
+extern CHAR16                        *gYesOption;
+extern CHAR16                        *gNoOption;
+extern CHAR16                        *gOkOption;
+extern CHAR16                        *gCancelOption;
 
 //
 // Browser Global Strings
 //
 extern CHAR16            *gSaveFailed;
@@ -137,10 +146,11 @@ typedef struct {
 
   //
   // Produced protocol
   //
   EDKII_FORM_DISPLAY_ENGINE_PROTOCOL FromDisplayProt;
+  EFI_HII_POPUP_PROTOCOL             HiiPopup;
 } FORM_DISPLAY_DRIVER_PRIVATE_DATA;
 
 
 typedef enum {
   UiNoOperation,
@@ -270,10 +280,47 @@ typedef struct {
   BOOLEAN                 NestInStatement;
 } UI_MENU_OPTION;
 
 #define MENU_OPTION_FROM_LINK(a)  CR (a, UI_MENU_OPTION, Link, UI_MENU_OPTION_SIGNATURE)
 
+#define USER_SELECTABLE_OPTION_OK_WIDTH           StrLen (gOkOption)
+#define USER_SELECTABLE_OPTION_OK_CAL_WIDTH       (StrLen (gOkOption) + StrLen (gCancelOption))
+#define USER_SELECTABLE_OPTION_YES_NO_WIDTH       (StrLen (gYesOption) + StrLen (gNoOption))
+#define USER_SELECTABLE_OPTION_YES_NO_CAL_WIDTH   (StrLen (gYesOption) + StrLen (gNoOption) + StrLen (gCancelOption))
+
+#define USER_SELECTABLE_OPTION_SKIP_WIDTH  2
+
+#define USER_SELECTABLE_OPTION_SIGNATURE  SIGNATURE_32 ('u', 's', 's', 'o')
+
+typedef struct {
+  UINTN                   Signature;
+  LIST_ENTRY              Link;
+  EFI_HII_POPUP_SELECTION OptionType;
+  CHAR16                  *OptionString;
+  //
+  // Display item sequence for user select options
+  //  Ok:        Ok
+  //  Sequence:  0
+  //
+  //  Ok/Cancel:   Ok : Cancel
+  //  Sequence:    0      1
+  //
+  //  Yes/No:      Ok : Cancel
+  //  Sequence:    0      1
+  //
+  //  Yes/No/Cancel: Yes : No: Cancel
+  //  Sequence:         0      1     2
+  //
+  UINTN                   Sequence;
+  UINTN                   OptionRow;
+  UINTN                   OptionCol;
+  UINTN                   MaxSequence;
+  UINTN                   MinSequence;
+} USER_SELECTABLE_OPTION;
+
+#define SELECTABLE_OPTION_FROM_LINK(a)  CR (a, USER_SELECTABLE_OPTION, Link, USER_SELECTABLE_OPTION_SIGNATURE)
+
 /**
   Print Question Value according to it's storage width and display attributes.
 
   @param  Question               The Question to be printed.
   @param  FormattedNumber        Buffer for output string.
@@ -648,6 +695,33 @@ UpdateHighlightMenuInfo (
   IN  LIST_ENTRY                      *Highlight,
   IN  LIST_ENTRY                      *TopOfScreen,
   IN  UINTN                           SkipValue
   );
 
+/**
+  Displays a popup window.
+
+  @param  This           A pointer to the EFI_HII_POPUP_PROTOCOL instance.
+  @param  PopupStyle     Popup style to use.
+  @param  PopupType      Type of the popup to display.
+  @param  HiiHandle      HII handle of the string pack containing Message
+  @param  Message        A message to display in the popup box.
+  @param  UserSelection  User selection.
+
+  @retval EFI_SUCCESS            The popup box was successfully displayed.
+  @retval EFI_INVALID_PARAMETER  HiiHandle and Message do not define a valid HII string.
+  @retval EFI_INVALID_PARAMETER  PopupType is not one of the values defined by this specification.
+  @retval EFI_OUT_OF_RESOURCES   There are not enough resources available to display the popup box.
+
+**/
+EFI_STATUS
+EFIAPI
+CreatePopup (
+  IN  EFI_HII_POPUP_PROTOCOL  *This,
+  IN  EFI_HII_POPUP_STYLE     PopupStyle,
+  IN  EFI_HII_POPUP_TYPE      PopupType,
+  IN  EFI_HII_HANDLE          HiiHandle,
+  IN  EFI_STRING_ID           Message,
+  OUT EFI_HII_POPUP_SELECTION *UserSelection OPTIONAL
+  );
+
 #endif
diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplayStr.uni b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplayStr.uni
index bd9c8b4..534890e 100644
--- a/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplayStr.uni
+++ b/MdeModulePkg/Universal/DisplayEngineDxe/FormDisplayStr.uni
@@ -1,8 +1,8 @@
 // *++
 //
-// Copyright (c) 2004 - 2016, Intel Corporation. All rights reserved.<BR>
+// Copyright (c) 2004 - 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
 // which accompanies this distribution.  The full text of the license may be found at
 // http://opensource.org/licenses/bsd-license.php
 //
@@ -101,10 +101,14 @@
                                        #language fr-FR  "Press 'Y' to confirm, 'N'/'ESC' to ignore."
 #string CONFIRM_OPTION_YES             #language en-US  "Y (y)"
                                        #language fr-FR  "Y (y)"
 #string CONFIRM_OPTION_NO              #language en-US  "N (n)"
                                        #language fr-FR  "N (n)"
+#string CONFIRM_OPTION_OK              #language en-US  "O (o)"
+                                       #language fr-FR  "O (o)"
+#string CONFIRM_OPTION_CANCEL          #language en-US  "C (c)"
+                                       #language fr-FR  "C (c)"
 #string CONFIRM_OPTION_CONNECT         #language en-US  " and "
                                        #language fr-FR  " and "
 #string CONFIRM_OPTION_END             #language en-US  "?"
                                        #language fr-FR  "?"
 #string RECONNECT_FAILED               #language en-US  "Reconnect the controller failed!"
@@ -117,6 +121,14 @@
                                        #language fr-FR  "Reconnect is required, exit and reconnect"
 #string GET_TIME_FAIL                  #language en-US  " Get date/time fail, display ??."
                                        #language fr-FR  " Get data/time fail, display ??."
 #string PASSWORD_NOT_SUPPORTED         #language en-US  "Unsupported! Because no interactieve flag or no ConfigAccess protocol!"
                                        #language fr-FR  "Unsupported! Because no interactieve flag or no ConfigAccess protocol!"
+#string OK_SELECTABLE_OPTION           #language en-US  "[ Ok ]"
+                                       #language fr-FR  "[ Ok ]"
+#string CANCEL_SELECTABLE_OPTION       #language en-US  "[Cancel]"
+                                       #language fr-FR  "[Cancel]"
+#string YES_SELECTABLE_OPTION          #language en-US  "[ Yes ]"
+                                       #language fr-FR  "[ Yes ]"
+#string NO_SELECTABLE_OPTION           #language en-US  "[ No ]"
+                                       #language fr-FR  "[ No ]"
 
diff --git a/MdeModulePkg/Universal/DisplayEngineDxe/Popup.c b/MdeModulePkg/Universal/DisplayEngineDxe/Popup.c
new file mode 100644
index 0000000..42ea092
--- /dev/null
+++ b/MdeModulePkg/Universal/DisplayEngineDxe/Popup.c
@@ -0,0 +1,610 @@
+/** @file
+Implementation for Hii Popup Protocol.
+
+Copyright (c) 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
+which accompanies this distribution.  The full text of the license may be found at
+http://opensource.org/licenses/bsd-license.php
+
+THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
+WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
+
+**/
+
+#include "FormDisplay.h"
+
+LIST_ENTRY  gUserSelectableOptions;
+
+/**
+  Free the user selectable option structure data.
+
+  @param  OptionList    Point to the selectable option list which need to be freed.
+
+**/
+VOID
+FreeSelectableOptions(
+  LIST_ENTRY           *OptionList
+  )
+{
+  LIST_ENTRY              *Link;
+  USER_SELECTABLE_OPTION  *SelectableOption;
+
+  while (!IsListEmpty (OptionList)) {
+    Link = GetFirstNode (OptionList);
+    SelectableOption = SELECTABLE_OPTION_FROM_LINK (Link);
+    RemoveEntryList (&SelectableOption->Link);
+    FreePool (SelectableOption);
+  }
+}
+
+/**
+  Display one selectable option.
+
+  @param  SelectableOption    The selectable option need to be drew.
+  @param  Highlight           Whether the option need to be highlighted.
+
+**/
+VOID
+DisplayOneSelectableOption(
+  IN USER_SELECTABLE_OPTION    *SelectableOption,
+  IN BOOLEAN                   Highlight
+  )
+{
+  if (Highlight) {
+    gST->ConOut->SetAttribute (gST->ConOut, GetHighlightTextColor ());
+  }
+  PrintStringAt (SelectableOption->OptionCol, SelectableOption->OptionRow, SelectableOption->OptionString);
+  gST->ConOut->SetAttribute (gST->ConOut, GetPopupColor ());
+}
+
+/**
+  Add one selectable option to option list. This is the work function for AddUserSelectableOptions.
+
+  @param  PopupType     The option need to be drew.
+  @param  OptionType    The type of this selection option.
+  @param  OptionString  Point to the option string that to be shown.
+  @param  OptionCol     The column that the option need to be drew at.
+  @param  OptionRow     The row that the option need to be drew at.
+
+**/
+EFI_STATUS
+AddOneSelectableOption (
+  IN EFI_HII_POPUP_TYPE           PopupType,
+  IN EFI_HII_POPUP_SELECTION      OptionType,
+  IN CHAR16                       *OptionString,
+  IN UINTN                        OptionCol,
+  IN UINTN                        OptionRow
+  )
+{
+  USER_SELECTABLE_OPTION  *UserSelectableOption;
+
+  UserSelectableOption = AllocateZeroPool (sizeof (USER_SELECTABLE_OPTION));
+  if (UserSelectableOption == NULL) {
+    return EFI_OUT_OF_RESOURCES;
+  }
+  //
+  // Initialize the user selectable option based on the PopupType and OptionType.
+  // And then add the option to the option list gUserSelectableOptions.
+  //
+  UserSelectableOption->Signature = USER_SELECTABLE_OPTION_SIGNATURE;
+  UserSelectableOption->OptionString = OptionString;
+  UserSelectableOption->OptionType = OptionType;
+  UserSelectableOption->OptionCol = OptionCol;
+  UserSelectableOption->OptionRow = OptionRow;
+  UserSelectableOption->MinSequence = 0;
+
+  switch (PopupType) {
+  case EfiHiiPopupTypeOk:
+    UserSelectableOption->MaxSequence = 0;
+    UserSelectableOption->Sequence= 0;
+    break;
+  case EfiHiiPopupTypeOkCancel:
+    UserSelectableOption->MaxSequence = 1;
+    if (OptionType == EfiHiiPopupSelectionOk) {
+      UserSelectableOption->Sequence= 0;
+    } else {
+      UserSelectableOption->Sequence= 1;
+    }
+    break;
+  case EfiHiiPopupTypeYesNo:
+    UserSelectableOption->MaxSequence = 1;
+    if (OptionType == EfiHiiPopupSelectionYes) {
+      UserSelectableOption->Sequence = 0;
+    } else {
+      UserSelectableOption->Sequence = 1;
+    }
+    break;
+  case EfiHiiPopupTypeYesNoCancel:
+    UserSelectableOption->MaxSequence = 2;
+    if (OptionType == EfiHiiPopupSelectionYes) {
+      UserSelectableOption->Sequence = 0;
+    } else if (OptionType == EfiHiiPopupSelectionNo){
+      UserSelectableOption->Sequence = 1;
+    } else {
+      UserSelectableOption->Sequence = 2;
+    }
+    break;
+  default:
+    break;
+  }
+  InsertTailList (&gUserSelectableOptions, &UserSelectableOption->Link);
+
+  return EFI_SUCCESS;
+}
+
+/**
+  Add user selectable options to option list for different types of Popup.
+
+  @param   PopupType    Type of the popup to display.
+  @param   OptionRow    The Row that the options need to be drew at.
+  @param   StartCol     The sart column of the popup, used to calculate the column that the options need to be drew at.
+  @param   EndCol       The end column of the popup, used to calculate the column that the options need to be drew at.
+
+**/
+EFI_STATUS
+AddUserSelectableOptions (
+  IN  EFI_HII_POPUP_TYPE  PopupType,
+  IN  UINTN               OptionRow,
+  IN  UINTN               StartCol,
+  IN  UINTN               EndCol
+  )
+{
+  UINTN        OptionCol;
+  EFI_STATUS   Status;
+
+  Status = EFI_SUCCESS;
+
+  switch (PopupType) {
+  case EfiHiiPopupTypeOk:
+    //
+    // Add [Ok] option to the option list.
+    //
+    OptionCol = StartCol + (EndCol - StartCol - USER_SELECTABLE_OPTION_OK_WIDTH) / 2;
+    Status = AddOneSelectableOption (PopupType, EfiHiiPopupSelectionOk, gOkOption, OptionCol, OptionRow);
+    break;
+  case EfiHiiPopupTypeOkCancel:
+    //
+    // Add [Ok] and [Cancel] options to the option list.
+    //
+    OptionCol = StartCol + (EndCol - StartCol - USER_SELECTABLE_OPTION_OK_CAL_WIDTH) / 3;
+    Status = AddOneSelectableOption (PopupType, EfiHiiPopupSelectionOk, gOkOption, OptionCol, OptionRow);
+    OptionCol = EndCol - (EndCol - StartCol - USER_SELECTABLE_OPTION_OK_CAL_WIDTH) / 3 - StrLen (gCancelOption);
+    Status = AddOneSelectableOption (PopupType, EfiHiiPopupSelectionCancel, gCancelOption, OptionCol, OptionRow);
+    break;
+  case EfiHiiPopupTypeYesNo:
+    //
+    // Add [Yes] and [No] options to the option list.
+    //
+    OptionCol = StartCol + (EndCol - StartCol - USER_SELECTABLE_OPTION_YES_NO_WIDTH) / 3;
+    Status = AddOneSelectableOption (PopupType, EfiHiiPopupSelectionYes, gYesOption, OptionCol, OptionRow);
+    OptionCol = EndCol - (EndCol - StartCol - USER_SELECTABLE_OPTION_YES_NO_WIDTH) / 3 - StrLen (gNoOption);
+    Status = AddOneSelectableOption (PopupType, EfiHiiPopupSelectionNo, gNoOption, OptionCol, OptionRow);
+    break;
+  case EfiHiiPopupTypeYesNoCancel:
+    //
+    // Add [Yes], [No] and [Cancel] options to the option list.
+    //
+    OptionCol = StartCol + (EndCol - StartCol - USER_SELECTABLE_OPTION_YES_NO_CAL_WIDTH) / 4;
+    Status = AddOneSelectableOption (PopupType, EfiHiiPopupSelectionYes, gYesOption, OptionCol, OptionRow);
+    OptionCol = StartCol + (EndCol - StartCol - StrLen (gNoOption)) / 2;
+    Status = AddOneSelectableOption (PopupType, EfiHiiPopupSelectionNo, gNoOption, OptionCol, OptionRow);
+    OptionCol = EndCol - (EndCol - StartCol - USER_SELECTABLE_OPTION_YES_NO_CAL_WIDTH) / 4 - StrLen (gCancelOption);
+    Status = AddOneSelectableOption (PopupType, EfiHiiPopupSelectionCancel, gCancelOption, OptionCol, OptionRow);
+    break;
+  default:
+    break;
+  }
+  return Status;
+}
+
+/**
+  Parse the message to check if it contains line break characters.
+  For once call, caller can get the string for one line and the width of the string.
+  This function call be called recursively to parse the whole InputString.
+
+  (Notice: current implementation, it only checks \r, \n characters, it deals \r,\n,\n\r same as \r\n.)
+
+  @param  InputString       String description for this option.
+  @param  Index             Where in InputString to start the copy process
+  @param  OutputString      Buffer to copy the string into, caller is responsible for freeing the buffer.
+  @param  OutputStrWidth    The width of OutputString.
+
+  @return Returns the number of CHAR16 characters that were copied into the OutputString buffer, include the '\0' info.
+
+**/
+UINTN
+ParseMessageString (
+  IN      CHAR16                      *InputString,
+  IN OUT  UINTN                       *Index,
+  OUT     CHAR16                      **OutputString,
+  OUT     UINTN                       *OutputStrWidth
+  )
+{
+  UINTN          StrOffset;
+
+  if (InputString == NULL || Index == NULL || OutputString == NULL) {
+    return 0;
+  }
+
+  *OutputStrWidth = 0;
+
+  //
+  //Check the string to see if there are line break characters in the string
+  //
+  for (StrOffset = 0; InputString[StrOffset] != CHAR_NULL; StrOffset++) {
+    if (InputString[*Index + StrOffset] == CHAR_CARRIAGE_RETURN || InputString[*Index + StrOffset] == CHAR_LINEFEED || InputString[*Index + StrOffset] == CHAR_NULL) {
+      break;
+    }
+  }
+
+  //
+  // The CHAR_NULL has process last time, this time just return 0 to stand for finishing parsing the InputString.
+  //
+  if (StrOffset == 0 && (InputString[*Index + StrOffset] == CHAR_NULL)) {
+    return 0;
+  }
+
+  //
+  // Copy the string to OutputString buffer and calculate the width of OutputString.
+  //
+  *OutputString = AllocateZeroPool ((StrOffset + 1) * sizeof(CHAR16));
+  if (*OutputString == NULL) {
+    return 0;
+  }
+  CopyMem ((*OutputString), &InputString[*Index], StrOffset * sizeof(CHAR16));
+  *OutputStrWidth = GetStringWidth (*OutputString) / 2;
+
+  //
+  // Update the value of Index, can be used for marking where to check the input string for next call.
+  //
+  if (InputString[*Index + StrOffset] == CHAR_LINEFEED) {
+    //
+    // Skip the /n or /n/r info.
+    //
+    if (InputString[*Index + StrOffset + 1] == CHAR_CARRIAGE_RETURN) {
+      *Index = (*Index + StrOffset + 2);
+    } else {
+      *Index = (*Index + StrOffset + 1);
+    }
+  } else if (InputString[*Index + StrOffset] == CHAR_CARRIAGE_RETURN) {
+    //
+    // Skip the /r or /r/n info.
+    //
+    if (InputString[*Index + StrOffset + 1] == CHAR_LINEFEED) {
+      *Index = (*Index + StrOffset + 2);
+    } else {
+      *Index = (*Index + StrOffset + 1);
+    }
+  } else {
+    *Index = (*Index + StrOffset);
+  }
+
+  return StrOffset + 1;
+}
+
+/**
+  This is the main implementation function of CreatePopup API, to draw the message box.
+
+  @param  MessageString      A message to display in the message box.
+  @param  PopupStyle         Popup style to use.
+  @param  PopupType          Type of the popup to display.
+  @param  UserSelection      User selection.
+
+  @retval EFI_SUCCESS            The popup box was successfully displayed.
+  @retval EFI_INVALID_PARAMETER  HiiHandle and Message do not define a valid HII string.
+  @retval EFI_INVALID_PARAMETER  PopupType is not one of the values defined by this specification.
+  @retval EFI_OUT_OF_RESOURCES   There are not enough resources available to display the popup box.
+
+**/
+EFI_STATUS
+DrawMessageBox (
+  IN  EFI_STRING              MessageString,
+  IN  EFI_HII_POPUP_STYLE     PopupStyle,
+  IN  EFI_HII_POPUP_TYPE      PopupType,
+  OUT EFI_HII_POPUP_SELECTION *UserSelection
+  )
+{
+  EFI_SIMPLE_TEXT_OUTPUT_PROTOCOL  *ConOut;
+  EFI_SIMPLE_TEXT_OUTPUT_MODE      SavedConsoleMode;
+  USER_SELECTABLE_OPTION           *HighlightOption;
+  USER_SELECTABLE_OPTION           *SelectableOption;
+  EFI_INPUT_KEY                    KeyValue;
+  LIST_ENTRY                       *HighlightPos;
+  LIST_ENTRY                       *Link;
+  EFI_STATUS                       Status;
+  CHAR16                           *OutputString;
+  CHAR16                           *TempString;
+  CHAR16                           Character;
+  UINTN                            OutputStrWidth;
+  UINTN                            MaxMesStrWidth;
+  UINTN                            MesStrRowNum;
+  UINTN                            DrawMesStrNum;
+  UINTN                            OptionRowWidth;
+  UINTN                            StringIndex;
+  UINTN                            Index;
+  UINTN                            Columns;
+  UINTN                            Rows;
+  UINTN                            StartCol;
+  UINTN                            EndCol;
+  UINTN                            TopRow;
+  UINTN                            BottomRow;
+  UINTN                            SelectableOptionRow;
+
+  ConOut         = gST->ConOut;
+  MesStrRowNum   = 0;
+  DrawMesStrNum  = 0;
+  MaxMesStrWidth = 0;
+  OptionRowWidth = 0;
+
+  CopyMem (&SavedConsoleMode, ConOut->Mode, sizeof (SavedConsoleMode));
+  ConOut->QueryMode (ConOut, ConOut->Mode->Mode, &Columns, &Rows);
+  ConOut->EnableCursor (ConOut, FALSE);
+  ConOut->SetAttribute (ConOut, GetPopupColor ());
+
+  //
+  // Calculate the row number of message string and the max width of the string in one row.
+  //
+  for (StringIndex = 0; ParseMessageString (MessageString, &StringIndex, &OutputString, &OutputStrWidth) != 0;) {
+    MesStrRowNum ++;
+    if (MaxMesStrWidth < OutputStrWidth) {
+      MaxMesStrWidth = OutputStrWidth;
+    }
+    FreePool (OutputString);
+  }
+
+  //
+  // Calculate the row width for the selectable options.(OptionRowWidth = Number * SkipWidth + OptionWidth)
+  //
+  if (PopupType == EfiHiiPopupTypeOk) {
+    OptionRowWidth = USER_SELECTABLE_OPTION_SKIP_WIDTH *2 + USER_SELECTABLE_OPTION_OK_WIDTH;
+  } else if (PopupType == EfiHiiPopupTypeOkCancel) {
+    OptionRowWidth = USER_SELECTABLE_OPTION_SKIP_WIDTH *3 + USER_SELECTABLE_OPTION_OK_CAL_WIDTH;
+  } else if (PopupType == EfiHiiPopupTypeYesNo) {
+    OptionRowWidth = USER_SELECTABLE_OPTION_SKIP_WIDTH *3 + USER_SELECTABLE_OPTION_YES_NO_WIDTH;
+  } else if (PopupType == EfiHiiPopupTypeYesNoCancel) {
+    OptionRowWidth = USER_SELECTABLE_OPTION_SKIP_WIDTH *4 + USER_SELECTABLE_OPTION_YES_NO_CAL_WIDTH;
+  }
+  if (OptionRowWidth > MaxMesStrWidth) {
+    MaxMesStrWidth = OptionRowWidth;
+  }
+
+  //
+  //Columns -2 : 2 for the message box itself.
+  //(Rows -1) -5: 4 for message box itself (empty line, border) and 1 for user selectable options.
+  //
+  MaxMesStrWidth = MIN (MaxMesStrWidth, Columns - 2);
+  MesStrRowNum = MIN (MesStrRowNum, Rows -1 - 5);
+
+  //
+  // Calculate the starting row, starting column, ending row and ending column for the popup.
+  //
+  StartCol     = (Columns -2 - MaxMesStrWidth) / 2;
+  EndCol       = StartCol + MaxMesStrWidth + 2;
+  TopRow       = (Rows - 1 - 5 - MesStrRowNum) / 2;
+  BottomRow    = TopRow + MesStrRowNum + 5;
+
+  //
+  // 1. Draw the top of the message box.
+  //
+  Character = BOXDRAW_DOWN_RIGHT;
+  PrintCharAt (StartCol, TopRow, Character);
+  Character = BOXDRAW_HORIZONTAL;
+  for (Index = StartCol; Index + 2 < EndCol; Index++) {
+    PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
+  }
+  Character = BOXDRAW_DOWN_LEFT;
+  PrintCharAt ((UINTN)-1, (UINTN)-1, Character);
+
+  //
+  // 2. Draw an empty line before message string.
+  //
+  Character = BOXDRAW_VERTICAL;
+  ClearLines (StartCol,  EndCol, TopRow + 1, TopRow + 1, GetPopupColor ());
+  PrintCharAt (StartCol, TopRow + 1, Character);
+  PrintCharAt (EndCol - 1, TopRow + 1, Character);
+
+  //
+  // 3. Draw the mesage string
+  //
+  for (Index = TopRow + 2,StringIndex = 0; ParseMessageString (MessageString, &StringIndex, &OutputString, &OutputStrWidth) != 0 && DrawMesStrNum < MesStrRowNum;) {
+    ClearLines (StartCol,  EndCol, Index, Index, GetPopupColor ());
+    PrintCharAt (StartCol, Index, Character);
+    PrintCharAt (EndCol - 1, Index, Character);
+    if (OutputStrWidth > MaxMesStrWidth) {
+      //
+      //OutputStrWidth > MaxMesStrWidth, cut off the string and print print ... instead.
+      //
+      TempString = AllocateZeroPool ((MaxMesStrWidth + 1) * sizeof (CHAR16));
+      if (TempString == NULL) {
+        FreePool (OutputString);
+        Status = EFI_OUT_OF_RESOURCES;
+        goto Done;
+      }
+      StrnCpyS (TempString, MaxMesStrWidth + 1, OutputString, MaxMesStrWidth - 3);
+      StrCatS (TempString, MaxMesStrWidth + 1, L"...");
+      PrintStringAt ((Columns - MaxMesStrWidth) / 2, Index, TempString);
+      FreePool (TempString);
+    } else {
+      PrintStringAt ((Columns - OutputStrWidth) / 2, Index, OutputString);
+    }
+    Index ++;
+    DrawMesStrNum ++;
+    FreePool (OutputString);
+  }
+
+  //
+  // 4. Draw an empty line after message string.
+  //
+  ClearLines (StartCol,  EndCol, Index, Index, GetPopupColor ());
+  PrintCharAt (StartCol, Index, Character);
+  PrintCharAt (EndCol - 1, Index, Character);
+
+  //
+  // Check whether the actual string row number beyond the MesStrRowNum, if yes, print the ...... in the row.
+  //
+  if (OutputStrWidth > 0 && DrawMesStrNum >= MesStrRowNum) {
+    PrintStringAt ((Columns - StrLen (L"......")) / 2, Index, L"......");
+  }
+  SelectableOptionRow = Index + 1;
+
+  //
+  // 5. Draw an empty line which is used to show user selectable options, will draw concrete  string options later.
+  //
+  Character = BOXDRAW_VERTICAL;
+  ClearLines (StartCol,  EndCol, Index + 1, Index + 1, GetPopupColor ());
+  PrintCharAt (StartCol, Index + 1, Character);
+  PrintCharAt (EndCol - 1, Index + 1, Character);
+
+  //
+  // 6.Draw the bottom of the message box
+  //
+  Character = BOXDRAW_UP_RIGHT;
+  PrintCharAt (StartCol, BottomRow - 1, Character);
+  Character = BOXDRAW_HORIZONTAL;
+  for (Index = StartCol; Index + 2 < EndCol; Index++) {
+    PrintCharAt ((UINTN)-1, (UINTN) -1, Character);
+  }
+  Character = BOXDRAW_UP_LEFT;
+  PrintCharAt ((UINTN)-1, (UINTN) -1, Character);
+
+  //
+  // Add user selectable options to option list.
+  //
+  Status = AddUserSelectableOptions (PopupType, SelectableOptionRow, StartCol, EndCol);
+  if (EFI_ERROR (Status)) {
+    goto Done;
+  }
+
+  //
+  // 7. Draw selectable options and wait for user's selection.
+  //
+  HighlightPos = gUserSelectableOptions.ForwardLink;
+  do {
+    for (Link = gUserSelectableOptions.ForwardLink; Link != &gUserSelectableOptions; Link = Link->ForwardLink) {
+      SelectableOption          = SELECTABLE_OPTION_FROM_LINK (Link);
+      DisplayOneSelectableOption (SelectableOption, (BOOLEAN)(Link == HighlightPos));
+    }
+    //
+    //If UserSelection is NULL, so there is no need to handle the key user input, just return.
+    //
+    if (UserSelection == NULL) {
+      goto Done;
+    }
+
+    Status = WaitForKeyStroke (&KeyValue);
+    if (EFI_ERROR (Status)) {
+      goto Done;
+    }
+    HighlightOption = SELECTABLE_OPTION_FROM_LINK (HighlightPos);
+    switch (KeyValue.UnicodeChar) {
+    case CHAR_NULL:
+      switch (KeyValue.ScanCode) {
+      case SCAN_RIGHT:
+        if (HighlightOption->Sequence < HighlightOption->MaxSequence) {
+          HighlightPos = HighlightPos->ForwardLink;
+        } else {
+          HighlightPos = gUserSelectableOptions.ForwardLink;
+        }
+        break;
+      case SCAN_LEFT:
+        if (HighlightOption->Sequence > HighlightOption->MinSequence) {
+          HighlightPos = HighlightPos->BackLink;
+        } else {
+          HighlightPos = gUserSelectableOptions.BackLink;
+        }
+        break;
+      default:
+        break;
+      }
+      break;
+
+    case CHAR_CARRIAGE_RETURN:
+      *UserSelection = HighlightOption->OptionType;
+      goto Done;
+    default:
+      if (((KeyValue.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (*gConfirmOptYes | UPPER_LOWER_CASE_OFFSET)) &&
+        (PopupType == EfiHiiPopupTypeYesNo || PopupType == EfiHiiPopupTypeYesNoCancel)) {
+        *UserSelection = EfiHiiPopupSelectionYes;
+        goto Done;
+      } else if ((KeyValue.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (*gConfirmOptNo| UPPER_LOWER_CASE_OFFSET) &&
+        (PopupType == EfiHiiPopupTypeYesNo || PopupType == EfiHiiPopupTypeYesNoCancel)){
+        *UserSelection = EfiHiiPopupSelectionNo;
+        goto Done;
+      } else if ((KeyValue.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (*gConfirmOptOk | UPPER_LOWER_CASE_OFFSET) &&
+        (PopupType == EfiHiiPopupTypeOk|| PopupType == EfiHiiPopupTypeOkCancel)){
+        *UserSelection = EfiHiiPopupSelectionOk;
+        goto Done;
+      } else if ((KeyValue.UnicodeChar | UPPER_LOWER_CASE_OFFSET) == (*gConfirmOptCancel| UPPER_LOWER_CASE_OFFSET) &&
+        (PopupType == EfiHiiPopupTypeOkCancel|| PopupType == EfiHiiPopupTypeYesNoCancel)){
+        *UserSelection = EfiHiiPopupSelectionCancel;
+        goto Done;
+      }
+      break;
+    }
+  } while (TRUE);
+
+  //
+  // Restore the cursor visibility, position, and attributes
+  //
+Done:
+  ConOut->EnableCursor      (ConOut, SavedConsoleMode.CursorVisible);
+  ConOut->SetCursorPosition (ConOut, SavedConsoleMode.CursorColumn, SavedConsoleMode.CursorRow);
+  ConOut->SetAttribute      (ConOut, SavedConsoleMode.Attribute);
+
+  return Status;
+}
+
+/**
+  Displays a popup window.
+
+  @param  This           A pointer to the EFI_HII_POPUP_PROTOCOL instance.
+  @param  PopupStyle     Popup style to use.
+  @param  PopupType      Type of the popup to display.
+  @param  HiiHandle      HII handle of the string pack containing Message
+  @param  Message        A message to display in the popup box.
+  @param  UserSelection  User selection.
+
+  @retval EFI_SUCCESS            The popup box was successfully displayed.
+  @retval EFI_INVALID_PARAMETER  HiiHandle and Message do not define a valid HII string.
+  @retval EFI_INVALID_PARAMETER  PopupType is not one of the values defined by this specification.
+  @retval EFI_OUT_OF_RESOURCES   There are not enough resources available to display the popup box.
+
+**/
+EFI_STATUS
+EFIAPI
+CreatePopup (
+  IN  EFI_HII_POPUP_PROTOCOL  *This,
+  IN  EFI_HII_POPUP_STYLE     PopupStyle,
+  IN  EFI_HII_POPUP_TYPE      PopupType,
+  IN  EFI_HII_HANDLE          HiiHandle,
+  IN  EFI_STRING_ID           Message,
+  OUT EFI_HII_POPUP_SELECTION *UserSelection OPTIONAL
+  )
+{
+  EFI_STRING              MessageString;
+  EFI_STATUS              Status;
+
+  if((HiiHandle == NULL) || (Message ==0)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  MessageString = HiiGetString (HiiHandle, Message, NULL);
+
+  if((MessageString == NULL)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  if ((PopupType != EfiHiiPopupTypeOk) && (PopupType != EfiHiiPopupTypeOkCancel)&& (PopupType != EfiHiiPopupTypeYesNo)&& (PopupType != EfiHiiPopupTypeYesNoCancel)) {
+    return EFI_INVALID_PARAMETER;
+  }
+
+  InitializeListHead (&gUserSelectableOptions);
+
+  Status = DrawMessageBox (MessageString, PopupStyle, PopupType, UserSelection);
+
+  FreeSelectableOptions (&gUserSelectableOptions);
+
+  return Status;
+}
+
-- 
1.9.5.msysgit.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [patch 3/3] MdeModulePkg/DriverSample: Add sample case for popup protocol
  2017-08-15  3:07 [patch 0/3] Add HII Popup Protocol Dandan Bi
  2017-08-15  3:07 ` [patch 1/3] MdePkg/HiiPopup: Add HII Popup Protocol definitions Dandan Bi
  2017-08-15  3:07 ` [patch 2/3] MdeModulePkg/DisplayEngine: Add implementation of HiiPopup protocol Dandan Bi
@ 2017-08-15  3:08 ` Dandan Bi
  2 siblings, 0 replies; 4+ messages in thread
From: Dandan Bi @ 2017-08-15  3:08 UTC (permalink / raw)
  To: edk2-devel; +Cc: Eric Dong, Liming Gao

Add one sample case about how to use HiiPopup protocol
to draw message box.

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>
---
 .../Universal/DriverSampleDxe/DriverSample.c       | 29 ++++++++++++++++++++++
 .../Universal/DriverSampleDxe/DriverSample.h       |  2 ++
 .../Universal/DriverSampleDxe/DriverSampleDxe.inf  |  1 +
 MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr     |  8 +++++-
 .../Universal/DriverSampleDxe/VfrStrings.uni       |  6 +++++
 5 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
index f103b9c..bbd9713 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
+++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.c
@@ -1098,10 +1098,13 @@ DriverCallback (
   EFI_STRING                      Results;
   UINT32                          ProgressErr;
   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)) {
     return EFI_INVALID_PARAMETER;
   }
@@ -1617,10 +1620,26 @@ DriverCallback (
           Status = EFI_SUCCESS;
           break;
         }
         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;
     }
   break;
 
@@ -1676,10 +1695,11 @@ DriverSampleInit (
   EFI_HII_DATABASE_PROTOCOL       *HiiDatabase;
   EFI_HII_STRING_PROTOCOL         *HiiString;
   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;
   BOOLEAN                         ActionFlag;
   EFI_STRING                      ConfigRequestHdr;
@@ -1761,10 +1781,19 @@ DriverSampleInit (
   if (EFI_ERROR (Status)) {
     return Status;
   }
   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,
                   &mHiiVendorDevicePath0,
                   &gEfiHiiConfigAccessProtocolGuid,
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h
index 6c97239..94c1534 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h
+++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSample.h
@@ -31,10 +31,11 @@ Revision History
 #include <Protocol/HiiConfigAccess.h>
 #include <Protocol/HiiDatabase.h>
 #include <Protocol/HiiString.h>
 #include <Protocol/FormBrowserEx.h>
 #include <Protocol/HiiConfigKeyword.h>
+#include <Protocol/HiiPopup.h>
 
 #include <Guid/MdeModuleHii.h>
 #include <Library/DebugLib.h>
 #include <Library/BaseLib.h>
 #include <Library/BaseMemoryLib.h>
@@ -96,10 +97,11 @@ typedef struct {
   //
   EFI_HII_DATABASE_PROTOCOL        *HiiDatabase;
   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;
 
   //
   // Produced protocol
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf b/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf
index 4233e63..c741089 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf
+++ b/MdeModulePkg/Universal/DriverSampleDxe/DriverSampleDxe.inf
@@ -91,10 +91,11 @@
   gEfiFormBrowser2ProtocolGuid                  ## CONSUMES
   gEfiHiiDatabaseProtocolGuid                   ## CONSUMES
   gEfiSimpleTextInputExProtocolGuid             ## SOMETIMES_CONSUMES
   gEdkiiFormBrowserExProtocolGuid               ## CONSUMES
   gEfiConfigKeywordHandlerProtocolGuid          ## CONSUMES
+  gEfiHiiPopupProtocolGuid                      ## CONSUMES
 
 [Depex]
   gEfiSimpleTextOutProtocolGuid AND gEfiHiiDatabaseProtocolGuid AND gEfiVariableArchProtocolGuid AND gEfiVariableWriteArchProtocolGuid
 
 [UserExtensions.TianoCore."ExtraFiles"]
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr
index 4bdaf76..1024d4a 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr
+++ b/MdeModulePkg/Universal/DriverSampleDxe/Vfr.vfr
@@ -474,11 +474,17 @@ formset
             flags   = INTERACTIVE,
             minimum = 0,
             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);
 
     goto 3,
diff --git a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni
index 8d24a47..c6ff8fa 100644
--- a/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni
+++ b/MdeModulePkg/Universal/DriverSampleDxe/VfrStrings.uni
@@ -265,10 +265,16 @@
                                                      #language fr-FR ""                                                                                                           
 #string STR_SUBMITTED_CALLBACK_TEST_PROMPT           #language en-US "Submitted callback test"
                                                      #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 "Exit current form now?"
+                                                     #language fr-FR "Exit current form now?"
 // Boot Order
 #string STR_BOOT_TITLE                 #language en-US "Boot"
 #string STR_BOOT_OPTIONS               #language en-US "Boot Order"
 #string STR_BOOT_OPTION1               #language en-US "IDE HDD"
 #string STR_BOOT_OPTION2               #language en-US "ATAPI CD"
-- 
1.9.5.msysgit.1



^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2017-08-15  3:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-15  3:07 [patch 0/3] Add HII Popup Protocol Dandan Bi
2017-08-15  3:07 ` [patch 1/3] MdePkg/HiiPopup: Add HII Popup Protocol definitions Dandan Bi
2017-08-15  3:07 ` [patch 2/3] MdeModulePkg/DisplayEngine: Add implementation of HiiPopup protocol Dandan Bi
2017-08-15  3:08 ` [patch 3/3] MdeModulePkg/DriverSample: Add sample case for popup protocol Dandan Bi

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox