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>
This commit is contained in:
Dandan Bi 2016-03-02 16:53:50 +08:00 committed by Feng Tian
parent 89a77e4051
commit 8a45f80eda
7 changed files with 259 additions and 5 deletions

View File

@ -711,6 +711,14 @@
# @Prompt Enable Serial device Half Hand Shake
gEfiMdeModulePkgTokenSpaceGuid.PcdSerialUseHalfHandshake|FALSE|BOOLEAN|0x00010073
## Indicates if HII data and configuration has been exported.<BR><BR>
# Add this PCD mainly consider the use case of simulator. This PCD maybe set to FALSE for
# simulator platform because the performance cost for this feature.
# TRUE - Export HII data and configuration data.<BR>
# FALSE - Does not export HII data and configuration.<BR>
# @Prompt Enable export HII data and configuration to be used in OS runtime.
gEfiMdeModulePkgTokenSpaceGuid.PcdHiiOsRuntimeSupport|TRUE|BOOLEAN|0x00010074
[PcdsFeatureFlag.IA32, PcdsFeatureFlag.X64]
## Indicates if DxeIpl should switch to long mode to enter DXE phase.
# It is assumed that 64-bit DxeCore is built in firmware if it is true; otherwise 32-bit DxeCore

View File

@ -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;
}
}

View File

@ -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

View File

@ -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

View File

@ -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,
@ -123,6 +124,30 @@ KeyboardLayoutChangeNullEvent (
return;
}
/**
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;
}

View File

@ -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;
}

View File

@ -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;
}
}