The LegacyBootMaintUiLib depends on the LegacyBootManagerLib to realize its
functionality, the LegacyBootManagerLib may initialize after 
LegacyBootMaintUiLib, so the functionality of LegacyBootMaintUiLib may 
be incorrect. Now we fix this issue by executing the related codes when 
opening the legacy forminstead in its the constructor function. Because 
when opening the legacy form, the LegacyBootManagerLib must have been 
initialized.

Cc: Liming Gao <[email protected]>
Cc: Eric Dong <[email protected]>
Contributed-under: TianoCore Contribution Agreement 1.0
Signed-off-by: Dandan Bi <[email protected]>
Reviewed-by: Eric Dong <[email protected]>
---
 .../LegacyBootMaintUiLib/LegacyBootMaintUi.c       | 42 ++++++++++++++++++----
 1 file changed, 36 insertions(+), 6 deletions(-)

diff --git 
a/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c 
b/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c
index 3a3eeed..5e1ad54 100644
--- a/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c
+++ b/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c
@@ -17,10 +17,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER 
EXPRESS OR IMPLIED.
 
 LEGACY_BOOT_OPTION_CALLBACK_DATA  *mLegacyBootOptionPrivate;
 EFI_GUID  mLegacyBootOptionGuid     = LEGACY_BOOT_OPTION_FORMSET_GUID;
 CHAR16    mLegacyBootStorageName[]  = L"LegacyBootData";
 BBS_TYPE  mBbsType[] = {BBS_FLOPPY, BBS_HARDDISK, BBS_CDROM, 
BBS_EMBED_NETWORK, BBS_BEV_DEVICE, BBS_UNKNOWN};
+BOOLEAN   mFirstEnterLegacyForm = FALSE;
 
 
 ///
 /// Legacy FD Info from LegacyBios.GetBbsInfo()
 ///
@@ -93,10 +94,30 @@ HII_VENDOR_DEVICE_PATH  
mLegacyBootOptionHiiVendorDevicePath = {
       (UINT8) ((END_DEVICE_PATH_LENGTH) >> 8)
     }
   }
 };
 
+/**
+
+  Build the LegacyFDMenu LegacyHDMenu LegacyCDMenu according to 
LegacyBios.GetBbsInfo().
+
+**/
+VOID
+GetLegacyOptions (
+  VOID
+  );
+
+
+/**
+
+  Base on the L"LegacyDevOrder" variable to build the current order data.
+
+**/
+VOID
+GetLegacyOptionsOrder (
+  VOID
+  );
 
 /**
   Re-order the Boot Option according to the DevOrder.
 
   The routine re-orders the Boot Option in BootOption array according to
@@ -1092,21 +1113,34 @@ LegacyBootOptionCallback (
   IN  UINT8                                  Type,
   IN  EFI_IFR_TYPE_VALUE                     *Value,
   OUT EFI_BROWSER_ACTION_REQUEST             *ActionRequest
   )
 {
-  if (Action != EFI_BROWSER_ACTION_CHANGED && Action != 
EFI_BROWSER_ACTION_CHANGING) {
+  if (Action != EFI_BROWSER_ACTION_CHANGED && Action != 
EFI_BROWSER_ACTION_CHANGING && Action != EFI_BROWSER_ACTION_FORM_OPEN) {
     //
-    // Do nothing for other UEFI Action. Only do call back when data is 
changed.
+    // Do nothing for other UEFI Action. Only do call back when data is 
changed or the form is open.
     //
     return EFI_UNSUPPORTED;
   }
 
   if ((Value == NULL) || (ActionRequest == NULL)) {
     return EFI_INVALID_PARAMETER;
   }
 
+  if (Action == EFI_BROWSER_ACTION_FORM_OPEN) {
+    if (!mFirstEnterLegacyForm) {
+      //
+      // The leagcyBootMaintUiLib depends on the LegacyBootManagerLib to 
realize its functionality.
+      // We need to do the leagcy boot options related actions after the 
LegacyBootManagerLib has been initialized.
+      // Opening the legacy menus is the appropriate time that the 
LegacyBootManagerLib has already been initialized.
+      //
+      mFirstEnterLegacyForm = TRUE;
+      GetLegacyOptions ();
+      GetLegacyOptionsOrder ();
+    }
+  }
+
   if (Action == EFI_BROWSER_ACTION_CHANGING) {
     switch (QuestionId) {
     case FORM_FLOPPY_BOOT_ID:
     case FORM_HARDDISK_BOOT_ID:
     case FORM_CDROM_BOOT_ID:
@@ -1424,14 +1458,10 @@ LegacyBootMaintUiLibConstructor (
                                       NULL
                                       );
     ASSERT (LegacyBootOptionData->HiiHandle != NULL);
 
     mLegacyBootOptionPrivate = LegacyBootOptionData;
-
-    GetLegacyOptions ();
-
-    GetLegacyOptionsOrder();
   }
 
   return EFI_SUCCESS;
 }
 
-- 
1.9.5.msysgit.1

_______________________________________________
edk2-devel mailing list
[email protected]
https://lists.01.org/mailman/listinfo/edk2-devel

Reply via email to