summaryrefslogtreecommitdiff
path: root/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
diff options
context:
space:
mode:
authorDandan Bi <dandan.bi@intel.com>2016-03-02 16:53:50 +0800
committerFeng Tian <feng.tian@intel.com>2016-03-04 14:04:43 +0800
commit8a45f80edad4e2e1e23118833f92df4320b123ab (patch)
treec23313249c4b14e036bf5950e6cfaa02da966135 /MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
parent89a77e4051f23675ebc1638ad47c91f5c85312d2 (diff)
downloadedk2-platforms-8a45f80edad4e2e1e23118833f92df4320b123ab.tar.xz
MdeModulePkg: Make HII configuration settings available to OS runtime
This feature is aimed to allow OS make use of the HII database during runtime. In this case, the contents of the HII Database is exported to a buffer. The pointer to the buffer is placed in the EFI System Configuration Table, where it can be retrieved by an OS application. Cc: Liming Gao <liming.gao@intel.com> Cc: Eric Dong <eric.dong@intel.com> Cc: Brian J. Johnson <bjohnson@sgi.com> Cc: Andrew Fish <afish@apple.com> Cc: El-Haj-Mahmoud Samer <samer.el-haj-mahmoud@hpe.com> Contributed-under: TianoCore Contribution Agreement 1.0 Signed-off-by: Dandan Bi <dandan.bi@intel.com> Reviewed-by: Liming Gao <liming.gao@intel.com> Reviewed-by: Eric Dong <eric.dong@intel.com>
Diffstat (limited to 'MdeModulePkg/Universal/HiiDatabaseDxe/Database.c')
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/Database.c144
1 files changed, 142 insertions, 2 deletions
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
index ec56795ebb..def1eb74a4 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Database.c
@@ -1,7 +1,7 @@
/** @file
Implementation for EFI_HII_DATABASE_PROTOCOL.
-Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
which accompanies this distribution. The full text of the license may be found at
@@ -15,6 +15,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "HiiDatabase.h"
+EFI_HII_PACKAGE_LIST_HEADER *gRTDatabaseInfoBuffer = NULL;
+EFI_STRING gRTConfigRespBuffer = NULL;
+UINTN gDatabaseInfoSize = 0;
+UINTN gConfigRespSize = 0;
+
/**
This function generates a HII_DATABASE_RECORD node and adds into hii database.
This is a internal function.
@@ -2775,6 +2780,113 @@ ExportPackageList (
return EFI_SUCCESS;
}
+/**
+This is an internal 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;
+ HII_DATABASE_PRIVATE_DATA *Private;
+ EFI_STRING ConfigAltResp;
+ UINTN ConfigSize;
+
+ ConfigAltResp = NULL;
+ 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)){
+ ConfigSize = StrSize(ConfigAltResp);
+ if (ConfigSize > gConfigRespSize){
+ gConfigRespSize = ConfigSize;
+ if (gRTConfigRespBuffer != NULL){
+ FreePool(gRTConfigRespBuffer);
+ }
+ gRTConfigRespBuffer = (EFI_STRING)AllocateRuntimeZeroPool(ConfigSize);
+ if (gRTConfigRespBuffer == NULL){
+ FreePool(ConfigAltResp);
+ DEBUG ((DEBUG_ERROR, "Not enough memory resource to get the ConfigResp string.\n"));
+ return EFI_OUT_OF_RESOURCES;
+ }
+ } else {
+ ZeroMem(gRTConfigRespBuffer,gConfigRespSize);
+ }
+ CopyMem(gRTConfigRespBuffer,ConfigAltResp,ConfigSize);
+ gBS->InstallConfigurationTable (&gEfiHiiConfigRoutingProtocolGuid, gRTConfigRespBuffer);
+ FreePool(ConfigAltResp);
+ }
+
+ return EFI_SUCCESS;
+
+}
+
+/**
+This is an internal function,mainly use to get HiiDatabase 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 Hiidatabase data.
+
+**/
+EFI_STATUS
+HiiGetDatabaseInfo(
+ IN CONST EFI_HII_DATABASE_PROTOCOL *This
+ )
+{
+ EFI_STATUS Status;
+ EFI_HII_PACKAGE_LIST_HEADER *DatabaseInfo;
+ UINTN DatabaseInfoSize;
+
+ DatabaseInfo = NULL;
+ DatabaseInfoSize = 0;
+
+ //
+ // Get HiiDatabase information.
+ //
+ Status = HiiExportPackageLists(This, NULL, &DatabaseInfoSize, DatabaseInfo);
+
+ ASSERT(Status == EFI_BUFFER_TOO_SMALL);
+
+ if(DatabaseInfoSize > gDatabaseInfoSize ) {
+ gDatabaseInfoSize = DatabaseInfoSize;
+ if (gRTDatabaseInfoBuffer != NULL){
+ FreePool(gRTDatabaseInfoBuffer);
+ }
+ gRTDatabaseInfoBuffer = AllocateRuntimeZeroPool(DatabaseInfoSize);
+ if (gRTDatabaseInfoBuffer == NULL){
+ DEBUG ((DEBUG_ERROR, "Not enough memory resource to get the HiiDatabase info.\n"));
+ return EFI_OUT_OF_RESOURCES;
+ }
+ } else {
+ ZeroMem(gRTDatabaseInfoBuffer,gDatabaseInfoSize);
+ }
+ Status = HiiExportPackageLists(This, NULL, &DatabaseInfoSize, gRTDatabaseInfoBuffer);
+ ASSERT_EFI_ERROR (Status);
+ gBS->InstallConfigurationTable (&gEfiHiiDatabaseProtocolGuid, gRTDatabaseInfoBuffer);
+
+ return EFI_SUCCESS;
+
+}
/**
This function adds the packages in the package list to the database and returns a handle. If there is a
@@ -2867,6 +2979,15 @@ HiiNewPackageList (
}
*Handle = DatabaseRecord->Handle;
+
+ //
+ // Check whether need to get the Database and configuration setting info.
+ // Only after ReadyToBoot, need to do the export.
+ //
+ if (gExportAfterReadyToBoot) {
+ HiiGetConfigurationSetting(This);
+ }
+
return EFI_SUCCESS;
}
@@ -2972,6 +3093,13 @@ HiiRemovePackageList (
FreePool (Node->PackageList);
FreePool (Node);
+ //
+ // Check whether need to get the Database and configuration setting info.
+ // Only after ReadyToBoot, need to do the export.
+ //
+ if (gExportAfterReadyToBoot) {
+ HiiGetConfigurationSetting(This);
+ }
return EFI_SUCCESS;
}
}
@@ -3079,7 +3207,19 @@ HiiUpdatePackageList (
//
// Add all of the packages within the new package list
//
- return AddPackages (Private, EFI_HII_DATABASE_NOTIFY_ADD_PACK, PackageList, Node);
+ Status = AddPackages (Private, EFI_HII_DATABASE_NOTIFY_ADD_PACK, PackageList, Node);
+
+ //
+ // Check whether need to get the Database and configuration setting info.
+ // Only after ReadyToBoot, need to do the export.
+ //
+ if (gExportAfterReadyToBoot) {
+ if (Status == EFI_SUCCESS){
+ HiiGetConfigurationSetting(This);
+ }
+ }
+
+ return Status;
}
}