From 1c03582b070a8feb0b43539cd918a37e3bd5b8da Mon Sep 17 00:00:00 2001 From: Dandan Bi Date: Thu, 7 Jul 2016 10:58:14 +0800 Subject: [PATCH] IntelFrameworkModulePkg/LegacyUi: Get legacy options when open legacy form 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 Cc: Eric Dong Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi Reviewed-by: Eric Dong Reviewed-by: Liming Gao --- .../LegacyBootMaintUiLib/LegacyBootMaintUi.c | 44 ++++++++++++++++--- 1 file changed, 38 insertions(+), 6 deletions(-) diff --git a/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c b/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c index 3a3eeed3e8..740c95ca96 100644 --- a/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c +++ b/IntelFrameworkModulePkg/Library/LegacyBootMaintUiLib/LegacyBootMaintUi.c @@ -19,6 +19,7 @@ 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; /// @@ -95,6 +96,26 @@ HII_VENDOR_DEVICE_PATH mLegacyBootOptionHiiVendorDevicePath = { } }; +/** + + 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. @@ -1094,9 +1115,9 @@ LegacyBootOptionCallback ( 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; } @@ -1105,6 +1126,21 @@ LegacyBootOptionCallback ( return EFI_INVALID_PARAMETER; } + if (Action == EFI_BROWSER_ACTION_FORM_OPEN) { + if (QuestionId == FORM_FLOPPY_BOOT_ID) { + 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: @@ -1426,10 +1462,6 @@ LegacyBootMaintUiLibConstructor ( ASSERT (LegacyBootOptionData->HiiHandle != NULL); mLegacyBootOptionPrivate = LegacyBootOptionData; - - GetLegacyOptions (); - - GetLegacyOptionsOrder(); } return EFI_SUCCESS;