From c87b13cdb572a1b91e16104dd62cc6250ed57c1d Mon Sep 17 00:00:00 2001 From: Dandan Bi Date: Wed, 20 Apr 2016 12:59:47 +0800 Subject: [PATCH] MdeModulePkg: Export ConfigResp only for form Package after ReadyToBoot The Hii runtime support feature will export the content of HiiDatabase and the ConfigResp string to runtime buffer after ReadyToBoot event is triggered. If some drivers add/update/remove packages from Hiidatabase after ReadyToBoot: Originally we will both export the content of HiiDatabase and the ConfigResp string for all packages. But now after investigation, we found only for form packages need to export the content of HiiDatabase and the ConfigResp string, for other packages just need to export the content of HiiDatabase. Now to enhance this logic. 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 Reviewed-by: Samer El-Haj-Mahmoud --- .../Universal/HiiDatabaseDxe/Database.c | 64 ++++++++++++++++--- .../HiiDatabaseDxe/HiiDatabaseEntry.c | 2 + 2 files changed, 58 insertions(+), 8 deletions(-) diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c index def1eb74a4..d1eb881884 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c @@ -19,6 +19,7 @@ EFI_HII_PACKAGE_LIST_HEADER *gRTDatabaseInfoBuffer = NULL; EFI_STRING gRTConfigRespBuffer = NULL; UINTN gDatabaseInfoSize = 0; UINTN gConfigRespSize = 0; +BOOLEAN gExportConfigResp = TRUE; /** This function generates a HII_DATABASE_RECORD node and adds into hii database. @@ -739,7 +740,16 @@ RemoveFormPackages ( PackageList->PackageListHdr.PackageLength -= Package->FormPkgHdr.Length; FreePool (Package->IfrData); FreePool (Package); - + // + // If Hii runtime support feature is enabled, + // will export Hii info for runtime use after ReadyToBoot event triggered. + // If some driver add/update/remove packages from HiiDatabase after ReadyToBoot, + // will need to export the content of HiiDatabase. + // But if form packages removed, also need to export the ConfigResp string + // + if (gExportAfterReadyToBoot) { + gExportConfigResp = TRUE; + } } return EFI_SUCCESS; @@ -2486,6 +2496,16 @@ AddPackages ( (UINT8) (PackageHeader.Type), DatabaseRecord->Handle ); + // + // If Hii runtime support feature is enabled, + // will export Hii info for runtime use after ReadyToBoot event triggered. + // If some driver add/update/remove packages from HiiDatabase after ReadyToBoot, + // will need to export the content of HiiDatabase. + // But if form packages added/updated, also need to export the ConfigResp string. + // + if (gExportAfterReadyToBoot) { + gExportConfigResp = TRUE; + } break; case EFI_HII_PACKAGE_KEYBOARD_LAYOUT: Status = InsertKeyboardLayoutPackage ( @@ -2781,7 +2801,7 @@ ExportPackageList ( } /** -This is an internal function,mainly use to get and update configuration settings information. +This function mainly use to get and update ConfigResp string. @param This A pointer to the EFI_HII_DATABASE_PROTOCOL instance. @@ -2790,7 +2810,7 @@ This is an internal function,mainly use to get and update configuration settings **/ EFI_STATUS -HiiGetConfigurationSetting( +HiiGetConfigRespInfo( IN CONST EFI_HII_DATABASE_PROTOCOL *This ) { @@ -2804,11 +2824,6 @@ HiiGetConfigurationSetting( Private = HII_DATABASE_DATABASE_PRIVATE_DATA_FROM_THIS (This); - // - // Get the HiiDatabase info. - // - HiiGetDatabaseInfo(This); - // // Get ConfigResp string // @@ -2888,6 +2903,39 @@ HiiGetDatabaseInfo( } +/** +This function mainly use to get and update configuration settings information. + +@param This A pointer to the EFI_HII_DATABASE_PROTOCOL instance. + +@retval EFI_SUCCESS Get the information successfully. +@retval EFI_OUT_OF_RESOURCES Not enough memory to store the Configuration Setting data. + +**/ +EFI_STATUS +HiiGetConfigurationSetting( + IN CONST EFI_HII_DATABASE_PROTOCOL *This + ) +{ + EFI_STATUS Status; + + // + // Get the HiiDatabase info. + // + Status = HiiGetDatabaseInfo(This); + + // + // Get ConfigResp string + // + if (gExportConfigResp) { + Status = HiiGetConfigRespInfo (This); + gExportConfigResp = FALSE; + } + return Status; + +} + + /** This function adds the packages in the package list to the database and returns a handle. If there is a EFI_DEVICE_PATH_PROTOCOL associated with the DriverHandle, then this function will diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c index 63f8793821..03a4184c45 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c @@ -146,6 +146,8 @@ OnReadyToBoot ( // HiiGetConfigurationSetting(&mPrivate.HiiDatabase); gExportAfterReadyToBoot = TRUE; + + gBS->CloseEvent (Event); } /** -- 2.39.2