summaryrefslogtreecommitdiffstats
path: root/MdeModulePkg/Universal
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
parent89a77e4051f23675ebc1638ad47c91f5c85312d2 (diff)
downloadedk2-8a45f80edad4e2e1e23118833f92df4320b123ab.tar.gz
edk2-8a45f80edad4e2e1e23118833f92df4320b123ab.tar.bz2
edk2-8a45f80edad4e2e1e23118833f92df4320b123ab.zip
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')
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/Database.c144
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h30
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf3
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c42
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/Image.c16
-rw-r--r--MdeModulePkg/Universal/HiiDatabaseDxe/String.c21
6 files changed, 251 insertions, 5 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;
}
}
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
index 6e28df7f45..d90bc0290d 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabase.h
@@ -2017,8 +2017,38 @@ GetSupportedLanguages (
IN EFI_HII_HANDLE HiiHandle
);
+/**
+This 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
+ );
+
+/**
+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
+ );
+
//
// Global variables
//
extern EFI_EVENT gHiiKeyboardLayoutChanged;
+extern BOOLEAN gExportAfterReadyToBoot;
+
#endif
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
index 7892503b47..2fb619e05a 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseDxe.inf
@@ -4,7 +4,7 @@
# This driver produces all required HII serivces that includes HiiDataBase, HiiString,
# HiiFont, HiiConfigRouting. To support UEFI HII, this driver is required.
#
-# 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
@@ -72,6 +72,7 @@
[FeaturePcd]
gEfiMdeModulePkgTokenSpaceGuid.PcdSupportHiiImageProtocol ## CONSUMES
+ gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport ## CONSUMES
[Pcd]
gEfiMdePkgTokenSpaceGuid.PcdUefiVariableDefaultPlatformLang ## CONSUMES
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
index 6448c97256..63f8793821 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/HiiDatabaseEntry.c
@@ -2,7 +2,7 @@
This file contains the entry code to the HII database, which is defined by
UEFI 2.1 specification.
-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
@@ -20,6 +20,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// Global variables
//
EFI_EVENT gHiiKeyboardLayoutChanged;
+BOOLEAN gExportAfterReadyToBoot = FALSE;
HII_DATABASE_PRIVATE_DATA mPrivate = {
HII_DATABASE_PRIVATE_DATA_SIGNATURE,
@@ -124,6 +125,30 @@ KeyboardLayoutChangeNullEvent (
}
/**
+ On Ready To Boot Services Event notification handler.
+
+ To trigger the function that to export the Hii Configuration setting.
+
+ @param[in] Event Event whose notification function is being invoked
+ @param[in] Context Pointer to the notification function's context
+
+**/
+VOID
+EFIAPI
+OnReadyToBoot (
+ IN EFI_EVENT Event,
+ IN VOID *Context
+ )
+{
+ //
+ // 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;
+}
+
+/**
Initialize HII Database.
@@ -135,6 +160,8 @@ KeyboardLayoutChangeNullEvent (
gHiiKeyboardLayoutChanged. Check gBS->CreateEventEx for
details. Or failed to insatll the protocols.
Check gBS->InstallMultipleProtocolInterfaces for details.
+ Or failed to create Ready To Boot Event.
+ Check EfiCreateEventReadyToBootEx for details.
**/
EFI_STATUS
@@ -146,6 +173,7 @@ InitializeHiiDatabase (
{
EFI_STATUS Status;
EFI_HANDLE Handle;
+ EFI_EVENT ReadyToBootEvent;
//
// There will be only one HII Database in the system
@@ -211,6 +239,18 @@ InitializeHiiDatabase (
}
+ if (FeaturePcdGet(PcdHiiOsRuntimeSupport)) {
+ Status = EfiCreateEventReadyToBootEx (
+ TPL_CALLBACK,
+ OnReadyToBoot,
+ NULL,
+ &ReadyToBootEvent
+ );
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
+ }
+
return Status;
}
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
index c46c96545e..612d57a615 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/Image.c
@@ -790,6 +790,14 @@ HiiNewImage (
ImageBlock += NewBlockSize;
((EFI_HII_IIBT_END_BLOCK *) (ImageBlock))->Header.BlockType = EFI_HII_IIBT_END;
+ //
+ // Check whether need to get the contents of HiiDataBase.
+ // Only after ReadyToBoot to do the export.
+ //
+ if (gExportAfterReadyToBoot) {
+ HiiGetDatabaseInfo(&Private->HiiDatabase);
+ }
+
return EFI_SUCCESS;
}
@@ -1178,6 +1186,14 @@ HiiSetImage (
ImagePackage->ImagePkgHdr.Header.Length += NewBlockSize - OldBlockSize;
PackageListNode->PackageListHdr.PackageLength += NewBlockSize - OldBlockSize;
+ //
+ // Check whether need to get the contents of HiiDataBase.
+ // Only after ReadyToBoot to do the export.
+ //
+ if (gExportAfterReadyToBoot) {
+ HiiGetDatabaseInfo(&Private->HiiDatabase);
+ }
+
return EFI_SUCCESS;
}
diff --git a/MdeModulePkg/Universal/HiiDatabaseDxe/String.c b/MdeModulePkg/Universal/HiiDatabaseDxe/String.c
index 756f19c7c3..e55aa293cb 100644
--- a/MdeModulePkg/Universal/HiiDatabaseDxe/String.c
+++ b/MdeModulePkg/Universal/HiiDatabaseDxe/String.c
@@ -2,7 +2,7 @@
Implementation for EFI_HII_STRING_PROTOCOL.
-Copyright (c) 2007 - 2015, Intel Corporation. All rights reserved.<BR>
+Copyright (c) 2007 - 2016, Intel Corporation. All rights reserved.<BR>
(C) Copyright 2016 Hewlett Packard Enterprise Development LP<BR>
This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@@ -1560,6 +1560,18 @@ Done:
FreePool (StringPackage->StringPkgHdr);
FreePool (StringPackage);
}
+ //
+ // The contents of HiiDataBase may updated,need to check.
+ //
+ //
+ // Check whether need to get the contents of HiiDataBase.
+ // Only after ReadyToBoot to do the export.
+ //
+ if (gExportAfterReadyToBoot) {
+ if (!EFI_ERROR (Status)) {
+ HiiGetDatabaseInfo(&Private->HiiDatabase);
+ }
+ }
return Status;
}
@@ -1755,6 +1767,13 @@ HiiSetString (
return Status;
}
PackageListNode->PackageListHdr.PackageLength += StringPackage->StringPkgHdr->Header.Length - OldPackageLen;
+ //
+ // Check whether need to get the contents of HiiDataBase.
+ // Only after ReadyToBoot to do the export.
+ //
+ if (gExportAfterReadyToBoot) {
+ HiiGetDatabaseInfo(&Private->HiiDatabase);
+ }
return EFI_SUCCESS;
}
}