public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
* [edk2-devel] [PATCH v2] SecurityPkg/OpalPasswordDxe: Update UI according to UEFI spec
@ 2024-03-20 10:33 Tina Chen
  0 siblings, 0 replies; 2+ messages in thread
From: Tina Chen @ 2024-03-20 10:33 UTC (permalink / raw)
  To: devel
  Cc: Tina Chen, Jiewen Yao, Rahul Kumar, Dandan Bi, Ming Tan,
	Arthur Chen, Xiao X Chen, CindyX Kuo

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4735

Should not call HiiGetBrowserData() and HiiSetBrowserData() in FORM_OPEN
call back function.
Those APIs are called within OpalHiiSetBrowserData/OpalHiiGetBrowserData
which have been used by OpalHii.c.

1. Move HiiPopulateMainMenuForm() into ExtracConfig()
   for the Opal main formset initialize.
2. Move HiiPopulateDiskInfoForm() to HiiSelectDisk().
3. Remove HiiGetBrowserData() and HiiSetBrowserData() redundant usage.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Ming Tan <ming.tan@intel.com>
Cc: Arthur Chen <arthur.g.chen@intel.com>
Cc: Xiao X Chen <xiao.x.chen@intel.com>
Cc: CindyX Kuo <cindyx.kuo@intel.com>
Signed-off-by: Tina Chen <tina.chen@intel.com>
---
 SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c | 23 ++++----------------
 1 file changed, 4 insertions(+), 19 deletions(-)

diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c
index 8035f44ebe..de58ab7df3 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c
@@ -494,7 +494,6 @@ HiiPopulateMainMenuForm (
     }
   }
 
-  OpalHiiSetBrowserData ();
   return EFI_SUCCESS;
 }
 
@@ -632,17 +631,7 @@ DriverCallback (
   HiiKey.Raw = QuestionId;
   HiiKeyId   = (UINT8)HiiKey.KeyBits.Id;
 
-  if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
-    switch (HiiKeyId) {
-      case HII_KEY_ID_VAR_SUPPORTED_DISKS:
-        DEBUG ((DEBUG_INFO, "HII_KEY_ID_VAR_SUPPORTED_DISKS\n"));
-        return HiiPopulateMainMenuForm ();
-
-      case HII_KEY_ID_VAR_SELECTED_DISK_AVAILABLE_ACTIONS:
-        DEBUG ((DEBUG_INFO, "HII_KEY_ID_VAR_SELECTED_DISK_AVAILABLE_ACTIONS\n"));
-        return HiiPopulateDiskInfoForm ();
-    }
-  } else if (Action == EFI_BROWSER_ACTION_CHANGING) {
+  if (Action == EFI_BROWSER_ACTION_CHANGING) {
     switch (HiiKeyId) {
       case HII_KEY_ID_GOTO_DISK_INFO:
         return HiiSelectDisk ((UINT8)HiiKey.KeyBits.Index);
@@ -819,6 +808,7 @@ HiiSelectDisk (
 {
   OpalHiiGetBrowserData ();
   gHiiConfiguration.SelectedDiskIndex = Index;
+  HiiPopulateDiskInfoForm ();
   OpalHiiSetBrowserData ();
 
   return EFI_SUCCESS;
@@ -840,8 +830,6 @@ HiiPopulateDiskInfoForm (
   TCG_RESULT         Ret;
   CHAR8              *DiskName;
 
-  OpalHiiGetBrowserData ();
-
   DiskName = HiiDiskGetNameCB (gHiiConfiguration.SelectedDiskIndex);
   if (DiskName == NULL) {
     return EFI_UNSUPPORTED;
@@ -903,11 +891,6 @@ HiiPopulateDiskInfoForm (
     GetSavedOpalRequest (OpalDisk, &gHiiConfiguration.OpalRequest);
   }
 
-  //
-  // Pass the current configuration to the BIOS
-  //
-  OpalHiiSetBrowserData ();
-
   return EFI_SUCCESS;
 }
 
@@ -1061,6 +1044,8 @@ ExtractConfig (
     FreePool (ConfigRequestHdr);
   }
 
+  HiiPopulateMainMenuForm ();
+
   //
   // Convert Buffer Data to <ConfigResp> by helper function BlockToConfig( )
   //
-- 
2.43.0.windows.1



--
Tina Chen


-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#116934): https://edk2.groups.io/g/devel/message/116934
Mute This Topic: https://groups.io/mt/105041945/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



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

* [edk2-devel] [PATCH v2] SecurityPkg/OpalPasswordDxe: Update UI according to UEFI spec
@ 2024-04-09  9:33 Cindy Kuo
  0 siblings, 0 replies; 2+ messages in thread
From: Cindy Kuo @ 2024-04-09  9:33 UTC (permalink / raw)
  To: devel
  Cc: Cindy Kuo, Jiewen Yao, Rahul Kumar, Dandan Bi, Ming Tan,
	Arthur Chen, Xiao X Chen, Tina Chen

REF: https://bugzilla.tianocore.org/show_bug.cgi?id=4735

Should not call HiiGetBrowserData() and HiiSetBrowserData() in FORM_OPEN
call back function.
Those APIs are called within OpalHiiSetBrowserData/OpalHiiGetBrowserData
which have been used by OpalHii.c.

1. Change callback action from FORM_OPEN to RETRIEVE.
2. Create dummy label with suppressif statement in VFR for form update
usage.
3. Add HiiUpdateForm() to force reparsing the IFR binary.

Cc: Jiewen Yao <jiewen.yao@intel.com>
Cc: Rahul Kumar <rahul1.kumar@intel.com>
Cc: Dandan Bi <dandan.bi@intel.com>
Cc: Ming Tan <ming.tan@intel.com>
Cc: Arthur Chen <arthur.g.chen@intel.com>
Cc: Xiao X Chen <xiao.x.chen@intel.com>
Cc: Tina Chen <tina.chen@intel.com>
Signed-off-by: CindyX Kuo <cindyx.kuo@intel.com>
---
 .../Tcg/Opal/OpalPassword/OpalDriver.h        |  1 +
 SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c   | 76 +++++++++++++++++--
 .../Tcg/Opal/OpalPassword/OpalHiiFormValues.h |  6 ++
 .../Tcg/Opal/OpalPassword/OpalPasswordDxe.inf |  1 +
 .../Opal/OpalPassword/OpalPasswordForm.vfr    | 10 +++
 5 files changed, 87 insertions(+), 7 deletions(-)

diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.h b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.h
index 2089bd81b6..1a4671c602 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.h
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalDriver.h
@@ -23,6 +23,7 @@ SPDX-License-Identifier: BSD-2-Clause-Patent
 
 #include <Guid/EventGroup.h>
 #include <Guid/S3StorageDeviceInitList.h>
+#include <Guid/MdeModuleHii.h>
 
 #include <Library/UefiLib.h>
 #include <Library/UefiBootServicesTableLib.h>
diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c
index 8035f44ebe..9c9d700645 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHii.c
@@ -40,6 +40,7 @@ EFI_HII_HANDLE  gHiiPackageListHandle = NULL;
 //
 const EFI_GUID  gHiiPackageListGuid   = PACKAGE_LIST_GUID;
 const EFI_GUID  gHiiSetupVariableGuid = SETUP_VARIABLE_GUID;
+const EFI_GUID  gOpalSetupFormSetGuid = SETUP_FORMSET_GUID;
 
 //
 // Structure that contains state of the HII
@@ -611,10 +612,15 @@ DriverCallback (
   EFI_BROWSER_ACTION_REQUEST            *ActionRequest
   )
 {
-  HII_KEY    HiiKey;
-  UINT8      HiiKeyId;
-  UINT32     PpRequest;
-  OPAL_DISK  *OpalDisk;
+  HII_KEY             HiiKey;
+  UINT8               HiiKeyId;
+  UINT32              PpRequest;
+  OPAL_DISK           *OpalDisk;
+  EFI_STATUS          Status;
+  VOID                *StartOpCodeHandle;
+  VOID                *EndOpCodeHandle;
+  EFI_IFR_GUID_LABEL  *StartLabel;
+  EFI_IFR_GUID_LABEL  *EndLabel;
 
   if (ActionRequest != NULL) {
     *ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
@@ -632,16 +638,72 @@ DriverCallback (
   HiiKey.Raw = QuestionId;
   HiiKeyId   = (UINT8)HiiKey.KeyBits.Id;
 
-  if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
+  if (Action == EFI_BROWSER_ACTION_RETRIEVE) {
+    //
+    // Allocate space for creation of UpdateData Buffer
+    //
+    StartOpCodeHandle = HiiAllocateOpCodeHandle ();
+    if (StartOpCodeHandle == NULL) {
+      return EFI_OUT_OF_RESOURCES;
+    }
+
+    EndOpCodeHandle = HiiAllocateOpCodeHandle ();
+    if (EndOpCodeHandle == NULL) {
+      return EFI_OUT_OF_RESOURCES;
+    }
+
+    //
+    // Create Hii Extend Label OpCode as the start opcode
+    //
+    StartLabel               = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (StartOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
+    StartLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
+
+    //
+    // Create Hii Extend Label OpCode as the end opcode
+    //
+    EndLabel               = (EFI_IFR_GUID_LABEL *)HiiCreateGuidOpCode (EndOpCodeHandle, &gEfiIfrTianoGuid, NULL, sizeof (EFI_IFR_GUID_LABEL));
+    EndLabel->ExtendOpCode = EFI_IFR_EXTEND_OP_LABEL;
+
     switch (HiiKeyId) {
       case HII_KEY_ID_VAR_SUPPORTED_DISKS:
         DEBUG ((DEBUG_INFO, "HII_KEY_ID_VAR_SUPPORTED_DISKS\n"));
-        return HiiPopulateMainMenuForm ();
+        Status = HiiPopulateMainMenuForm ();
+
+        StartLabel->Number = OPAL_MAIN_MENU_LABEL_START;
+        EndLabel->Number   = OPAL_MAIN_MENU_LABEL_END;
+        HiiUpdateForm (
+          gHiiPackageListHandle,
+          (EFI_GUID *)&gOpalSetupFormSetGuid,
+          FORMID_VALUE_MAIN_MENU,
+          StartOpCodeHandle,
+          EndOpCodeHandle
+          );
+        break;
 
       case HII_KEY_ID_VAR_SELECTED_DISK_AVAILABLE_ACTIONS:
         DEBUG ((DEBUG_INFO, "HII_KEY_ID_VAR_SELECTED_DISK_AVAILABLE_ACTIONS\n"));
-        return HiiPopulateDiskInfoForm ();
+        Status = HiiPopulateDiskInfoForm ();
+
+        StartLabel->Number = OPAL_DISK_INFO_LABEL_START;
+        EndLabel->Number   = OPAL_DISK_INFO_LABEL_END;
+        HiiUpdateForm (
+          gHiiPackageListHandle,
+          (EFI_GUID *)&gOpalSetupFormSetGuid,
+          FORMID_VALUE_DISK_INFO_FORM_MAIN,
+          StartOpCodeHandle,
+          EndOpCodeHandle
+          );
+        break;
+
+      default:
+        Status = EFI_UNSUPPORTED;
+        break;
     }
+
+    HiiFreeOpCodeHandle (StartOpCodeHandle);
+    HiiFreeOpCodeHandle (EndOpCodeHandle);
+
+    return Status;
   } else if (Action == EFI_BROWSER_ACTION_CHANGING) {
     switch (HiiKeyId) {
       case HII_KEY_ID_GOTO_DISK_INFO:
diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHiiFormValues.h b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHiiFormValues.h
index ab6957fc6f..0e098854ba 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalHiiFormValues.h
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalHiiFormValues.h
@@ -96,6 +96,12 @@ typedef struct {
 
 #define HII_KEY(id)  HII_KEY_WITH_INDEX(id, 0)
 
+/* Label */
+#define OPAL_MAIN_MENU_LABEL_START  0x6100
+#define OPAL_MAIN_MENU_LABEL_END    0x6101
+#define OPAL_DISK_INFO_LABEL_START  0x6200
+#define OPAL_DISK_INFO_LABEL_END    0x6201
+
 #define PACKAGE_LIST_GUID  { 0xf0308176, 0x9058, 0x4153, { 0x93, 0x3d, 0xda, 0x2f, 0xdc, 0xc8, 0x3e, 0x44 } }
 
 /* {410483CF-F4F9-4ece-848A-1958FD31CEB7} */
diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordDxe.inf b/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordDxe.inf
index 87519198c0..89e72a74bc 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordDxe.inf
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordDxe.inf
@@ -69,6 +69,7 @@
 [Guids]
   gEfiEndOfDxeEventGroupGuid                    ## CONSUMES ## Event
   gS3StorageDeviceInitListGuid                  ## SOMETIMES_PRODUCES ## UNDEFINED
+  gEfiIfrTianoGuid                              ## CONSUMES
 
 [Pcd]
   gEfiSecurityPkgTokenSpaceGuid.PcdSkipOpalPasswordPrompt  ## CONSUMES
diff --git a/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordForm.vfr b/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordForm.vfr
index f0d3e220b2..a03c19af11 100644
--- a/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordForm.vfr
+++ b/SecurityPkg/Tcg/Opal/OpalPassword/OpalPasswordForm.vfr
@@ -25,6 +25,11 @@ formset
 form formid = FORMID_VALUE_MAIN_MENU,
     title  = STRING_TOKEN(STR_OPAL);
 
+    suppressif TRUE;
+        label OPAL_MAIN_MENU_LABEL_START;
+        label OPAL_MAIN_MENU_LABEL_END;
+    endif;
+
     //CONFIG_VARIABLE(HII_KEY(HII_KEY_ID_VAR_SUPPORTED_DISKS), SupportedDisks, 0x0, 0xFFFF);
     suppressif TRUE;
         numeric
@@ -148,6 +153,11 @@ endform;  // MAIN MENU FORM
 form formid = FORMID_VALUE_DISK_INFO_FORM_MAIN,
     title  = STRING_TOKEN(STR_OPAL);
 
+    suppressif TRUE;
+        label OPAL_DISK_INFO_LABEL_START;
+        label OPAL_DISK_INFO_LABEL_END;
+    endif;
+
     suppressif TRUE;
         numeric
             name    = SelectedDiskAvailableActions,
-- 
2.39.1.windows.1



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#117563): https://edk2.groups.io/g/devel/message/117563
Mute This Topic: https://groups.io/mt/105434775/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/unsub [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



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

end of thread, other threads:[~2024-04-10  1:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-09  9:33 [edk2-devel] [PATCH v2] SecurityPkg/OpalPasswordDxe: Update UI according to UEFI spec Cindy Kuo
  -- strict thread matches above, loose matches on Subject: below --
2024-03-20 10:33 Tina Chen

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