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.
Notes: v1->v2: - Modify the subject. - Close the ReadyToBoot event. - Add the check (whether need to export ConfigResp) in HiiGetConfigurationSetting(), doesn't update the caller logic. Cc: Liming Gao <liming....@intel.com> Cc: Eric Dong <eric.d...@intel.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi <dandan...@intel.com> Reviewed-by: Eric Dong <eric.d...@intel.com> --- MdeModulePkg/Universal/HiiDatabaseDxe/Database.c | 64 +++++++++++++++++++--- .../Universal/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 def1eb7..d1eb881 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c @@ -17,10 +17,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. 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. This is a internal function. @@ -737,11 +738,20 @@ RemoveFormPackages ( RemoveEntryList (&Package->IfrEntry); 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; } @@ -2484,10 +2494,20 @@ AddPackages ( NotifyType, (VOID *) FormPackage, (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 ( PackageHdrPtr, NotifyType, @@ -2779,20 +2799,20 @@ ExportPackageList ( return EFI_SUCCESS; } /** -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. @retval EFI_SUCCESS Get the information successfully. @retval EFI_OUT_OF_RESOURCES Not enough memory to store the Configuration Setting data. **/ EFI_STATUS -HiiGetConfigurationSetting( +HiiGetConfigRespInfo( IN CONST EFI_HII_DATABASE_PROTOCOL *This ) { EFI_STATUS Status; HII_DATABASE_PRIVATE_DATA *Private; @@ -2803,15 +2823,10 @@ HiiGetConfigurationSetting( ConfigSize = 0; Private = HII_DATABASE_DATABASE_PRIVATE_DATA_FROM_THIS (This); // - // Get the HiiDatabase info. - // - HiiGetDatabaseInfo(This); - - // // Get ConfigResp string // Status = HiiConfigRoutingExportConfig(&Private->ConfigRouting,&ConfigAltResp); if (!EFI_ERROR (Status)){ @@ -2887,10 +2902,43 @@ HiiGetDatabaseInfo( return EFI_SUCCESS; } /** +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 create a package of type EFI_PACKAGE_TYPE_DEVICE_PATH and add it to the package list. @param This A pointer to the EFI_HII_DATABASE_PROTOCOL diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c index 63f8793..03a4184 100644 --- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c +++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c @@ -144,10 +144,12 @@ OnReadyToBoot ( // When ready to boot, we begin to export the HiiDatabase date. // And hook all the possible HiiDatabase change actions to export data. // HiiGetConfigurationSetting(&mPrivate.HiiDatabase); gExportAfterReadyToBoot = TRUE; + + gBS->CloseEvent (Event); } /** Initialize HII Database. -- 1.9.5.msysgit.1 _______________________________________________ edk2-devel mailing list edk2-devel@lists.01.org https://lists.01.org/mailman/listinfo/edk2-devel