Bug fixes for FrameworkHiiToUefiHiiThunk;

1) Update variable name to better names.
2) Change List Entry in all data structure to "Link".
3) Update to use proper list manipulation functions in BaseLib.
4) Add in more comments and clean up HiiNewString.
5) Clean up for HiiNewPack, HiiRemovePack and the notify functions.
6) Create better name such as GetPackageCount and AssignFrameworkHiiHandle
7) Clean up the InitializeHiiDatabase entry point.
8) Remove the confusing data field in the HII_THUNK_ENTRY HiiDatabase.h.
9) Add in cleanup code for DestoryThunkContext
10) Add in code to handle the save of browser data after invoke callback 
11) Map the UEFI One Of Option code to Framework One Of Option code before calling Framework Callback.
12) Add in CreatePopUp support.
13) Add in SendForm support.
14) HiiGetPrimaryLanguages and HiiGetSecondaryLanguages should support language code in RFC639 format from Caller. Then, they should conver them to 3066 format before calling UEFI HII interfaces.
15) Make ResetStrings a NOP.
16) Remove the unnecessary dependency.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5659 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qwang12 2008-08-18 05:56:23 +00:00
parent 0514e9c3c9
commit 0368663fd6
19 changed files with 2503 additions and 1405 deletions

View File

@ -16,15 +16,18 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "HiiDatabase.h"
HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE ConfigAccessProtocolInstanceTempate = {
HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE_SIGNATURE,
BOOLEAN mHiiPackageListUpdated;
CONFIG_ACCESS_PRIVATE gConfigAccessPrivateTempate = {
CONFIG_ACCESS_PRIVATE_SIGNATURE,
{
ThunkExtractConfig,
ThunkRouteConfig,
ThunkCallback
}, //ConfigAccessProtocol
NULL, //FrameworkFormCallbackProtocol
{NULL, NULL} //ConfigAccessStorageListHead
NULL, //FormCallbackProtocol
{NULL, NULL}, //ConfigAccessStorageListHead
NULL
};
/**
@ -40,11 +43,10 @@ HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE ConfigAccessProtocolInstanceTempate =
Framework Module which does not include packages introduced by UEFI Specification
or packages that is not supported by Thunk layer.
@param Packages The Framework Package List
@param Packages The Framework Package List
@retval EFI_HII_PACKAGE_HEADER* Return the Package Header of
Form Package.
@retval NULL If no Form Package is found.
@retval EFI_HII_PACKAGE_HEADER* Return the Package Header of Form Package.
@retval NULL If no Form Package is found.
**/
EFI_HII_PACKAGE_HEADER *
GetIfrFormSet (
@ -100,11 +102,10 @@ GetIfrFormSet (
If FormSetPackage is not EFI_HII_PACKAGE_FORM, then ASSERT.
If there is no linear buffer storage in this formset, then ASSERT.
@param FormSetPackage The Form Package header.
@param FormSetPackage The Form Package header.
@param BufferStorageListHead The link list for the VARSTORE found in the form package.
@retval EFI_SUCCESS The function scan the form set and find one or more
VARSTOREs.
@retval EFI_SUCCESS The function scan the form set and find one or more VARSTOREs.
@retval EFI_OUT_OF_RESOURCES There is not enough memory to complete the function.
**/
EFI_STATUS
@ -118,11 +119,15 @@ GetBufferStorage (
UINT8 *OpCodeData;
UINT8 Operand;
EFI_IFR_VARSTORE *VarStoreOpCode;
HII_TRHUNK_BUFFER_STORAGE_KEY *BufferStorageKey;
BUFFER_STORAGE_ENTRY *BufferStorage;
ASSERT (FormSetPackage->Type == EFI_HII_PACKAGE_FORM);
OpCodeOffset = sizeof (EFI_HII_PACKAGE_HEADER);
//
// Scan all opcode for the FormSet Package for
// EFI_IFR_VARSTORE_OP opcode.
//
while (OpCodeOffset < FormSetPackage->Length) {
OpCodeData = (UINT8 *) FormSetPackage + OpCodeOffset;
@ -132,27 +137,31 @@ GetBufferStorage (
if (Operand == EFI_IFR_VARSTORE_OP) {
VarStoreOpCode = (EFI_IFR_VARSTORE *)OpCodeData;
BufferStorageKey = AllocateZeroPool (sizeof (*BufferStorageKey));
if (BufferStorageKey == NULL) {
BufferStorage = AllocateZeroPool (sizeof (*BufferStorage));
if (BufferStorage == NULL) {
return EFI_OUT_OF_RESOURCES;
}
CopyMem (&BufferStorageKey->Guid, &VarStoreOpCode->Guid, sizeof (EFI_GUID));
//
// Record the attributes: GUID, Name, VarStoreId and Size.
//
CopyMem (&BufferStorage->Guid, &VarStoreOpCode->Guid, sizeof (EFI_GUID));
BufferStorageKey->Name = AllocateZeroPool (AsciiStrSize (VarStoreOpCode->Name) * 2);
AsciiStrToUnicodeStr (VarStoreOpCode->Name, BufferStorageKey->Name);
BufferStorage->Name = AllocateZeroPool (AsciiStrSize (VarStoreOpCode->Name) * 2);
AsciiStrToUnicodeStr (VarStoreOpCode->Name, BufferStorage->Name);
BufferStorageKey->VarStoreId = VarStoreOpCode->VarStoreId;
BufferStorage->VarStoreId = VarStoreOpCode->VarStoreId;
BufferStorageKey->Size = VarStoreOpCode->Size;
BufferStorageKey->Signature = HII_TRHUNK_BUFFER_STORAGE_KEY_SIGNATURE;
BufferStorage->Size = VarStoreOpCode->Size;
BufferStorage->Signature = BUFFER_STORAGE_ENTRY_SIGNATURE;
InsertTailList (BufferStorageListHead, &BufferStorageKey->List);
InsertTailList (BufferStorageListHead, &BufferStorage->Link);
}
}
return EFI_SUCCESS;
}
/**
This function installs a EFI_CONFIG_ACCESS_PROTOCOL instance for a form package registered
by a module using Framework HII Protocol Interfaces.
@ -160,30 +169,31 @@ GetBufferStorage (
UEFI HII require EFI_HII_CONFIG_ACCESS_PROTOCOL to be installed on a EFI_HANDLE, so
that Setup Utility can load the Buffer Storage using this protocol.
@param Packages The framework package list.
@param MapEntry The Thunk Layer Handle Mapping Database Entry.
@param Packages The framework package list.
@param ThunkContext The Thunk Layer Handle Mapping Database Entry.
@retval EFI_SUCCESS The Config Access Protocol is installed successfully.
@retval EFI_OUT_RESOURCE There is not enough memory.
@retval EFI_SUCCESS The Config Access Protocol is installed successfully.
@retval EFI_OUT_RESOURCE There is not enough memory.
**/
EFI_STATUS
InstallDefaultUefiConfigAccessProtocol (
IN CONST EFI_HII_PACKAGES *Packages,
IN OUT HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *MapEntry
InstallDefaultConfigAccessProtocol (
IN CONST EFI_HII_PACKAGES *Packages,
IN OUT HII_THUNK_CONTEXT *ThunkContext
)
{
EFI_HII_PACKAGE_HEADER *FormSetPackage;
EFI_STATUS Status;
HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE *ConfigAccessInstance;
CONFIG_ACCESS_PRIVATE *ConfigAccessInstance;
Status = HiiLibCreateHiiDriverHandle (&MapEntry->UefiHiiDriverHandle);
Status = HiiLibCreateHiiDriverHandle (&ThunkContext->UefiHiiDriverHandle);
ConfigAccessInstance = AllocateCopyPool (
sizeof (HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE),
&ConfigAccessProtocolInstanceTempate
sizeof (CONFIG_ACCESS_PRIVATE),
&gConfigAccessPrivateTempate
);
ASSERT (ConfigAccessInstance != NULL);
InitializeListHead (&ConfigAccessInstance->ConfigAccessBufferStorageListHead);
InitializeListHead (&ConfigAccessInstance->BufferStorageListHead);
//
// We assume there is only one formset package in each Forms Package
@ -191,7 +201,7 @@ InstallDefaultUefiConfigAccessProtocol (
FormSetPackage = GetIfrFormSet (Packages);
ASSERT (FormSetPackage != NULL);
Status = GetBufferStorage (FormSetPackage, &ConfigAccessInstance->ConfigAccessBufferStorageListHead);
Status = GetBufferStorage (FormSetPackage, &ConfigAccessInstance->BufferStorageListHead);
if (EFI_ERROR (Status)) {
FreePool (ConfigAccessInstance);
ASSERT (FALSE);
@ -199,70 +209,95 @@ InstallDefaultUefiConfigAccessProtocol (
}
Status = gBS->InstallMultipleProtocolInterfaces (
&MapEntry->UefiHiiDriverHandle,
&ThunkContext->UefiHiiDriverHandle,
&gEfiHiiConfigAccessProtocolGuid,
&ConfigAccessInstance->ConfigAccessProtocol,
NULL
);
//
//BUGBUG: Remove when done.
//
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
FreePool (ConfigAccessInstance);
return Status;
}
ConfigAccessInstance->ThunkContext = ThunkContext;
return EFI_SUCCESS;
}
/**
Wrap EFI_HII_CONFIG_ACCESS_PROTOCOL.RouteConfig to a call to EFI_FORM_CALLBACK_PROTOCOL.NvWrite.
@param BufferStorageKey The key with all attributes needed to call EFI_FORM_CALLBACK_PROTOCOL.NvWrite.
@param FrameworkFormCallBack The EFI_FORM_CALLBACK_PROTOCOL registered by Framework HII module.
@param Data The data to be saved.
@param DataSize The size of data.
@retval EFI_STATUS The status returned by the EFI_FORM_CALLBACK_PROTOCOL.NvWrite.
**/
EFI_STATUS
RouteConfigToFrameworkFormCallBack (
IN HII_TRHUNK_BUFFER_STORAGE_KEY *BufferStorageKey,
IN EFI_FORM_CALLBACK_PROTOCOL *FrameworkFormCallBack,
IN VOID *Data,
IN UINTN DataSize
VOID
DestroyBufferStorageList (
IN LIST_ENTRY *ListHead
)
{
EFI_STATUS Status;
BOOLEAN ResetRequired;
LIST_ENTRY *Link;
BUFFER_STORAGE_ENTRY *Entry;
Status = FrameworkFormCallBack->NvWrite (
FrameworkFormCallBack,
BufferStorageKey->Name,
&BufferStorageKey->Guid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
DataSize,
Data,
&ResetRequired
);
return Status;
while (!IsListEmpty (ListHead)) {
Link = GetFirstNode (ListHead);
Entry = BUFFER_STORAGE_ENTRY_FROM_LINK(Link);
FreePool (Entry->Name);
Link = RemoveEntryList (Link);
FreePool (Entry);
}
}
VOID
UninstallDefaultConfigAccessProtocol (
IN HII_THUNK_CONTEXT *ThunkContext
)
{
EFI_STATUS Status;
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
CONFIG_ACCESS_PRIVATE *ConfigAccessInstance;
HiiLibDestroyHiiDriverHandle (ThunkContext->UefiHiiDriverHandle);
Status = gBS->HandleProtocol (
ThunkContext->UefiHiiDriverHandle,
&gEfiHiiConfigAccessProtocolGuid,
(VOID **) &ConfigAccess
);
ASSERT_EFI_ERROR (Status);
Status = gBS->UninstallProtocolInterface (
ThunkContext->UefiHiiDriverHandle,
&gEfiHiiConfigAccessProtocolGuid,
ConfigAccess
);
ASSERT_EFI_ERROR (Status);
ConfigAccessInstance = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (ConfigAccess);
DestroyBufferStorageList (&ConfigAccessInstance->BufferStorageListHead);
}
/**
Wrap the EFI_HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig to a call to EFI_FORM_CALLBACK_PROTOCOL.NvRead.
@param BufferStorageKey The key with all attributes needed to call EFI_FORM_CALLBACK_PROTOCOL.NvRead.
@param FrameworkFormCallBack The EFI_FORM_CALLBACK_PROTOCOL registered by Framework HII module.
@param Data The data read.
@param DataSize The size of data.
@param BufferStorage The key with all attributes needed to call EFI_FORM_CALLBACK_PROTOCOL.NvRead.
@param FwFormCallBack The EFI_FORM_CALLBACK_PROTOCOL registered by Framework HII module.
@param Data The data read.
@param DataSize The size of data.
@retval EFI_STATUS The status returned by the EFI_FORM_CALLBACK_PROTOCOL.NvWrite.
@retval EFI_STATUS The status returned by the EFI_FORM_CALLBACK_PROTOCOL.NvWrite.
@retval EFI_INVALID_PARAMETER If the EFI_FORM_CALLBACK_PROTOCOL.NvRead return the size information of the data
does not match what has been recorded early in he HII_TRHUNK_BUFFER_STORAGE_KEY.
does not match what has been recorded early in he BUFFER_STORAGE_ENTRY.
**/
EFI_STATUS
ExtractConfigFromFrameworkFormCallBack (
IN HII_TRHUNK_BUFFER_STORAGE_KEY *BufferStorageKey,
IN EFI_FORM_CALLBACK_PROTOCOL *FrameworkFormCallBack,
CallFormCallBack (
IN BUFFER_STORAGE_ENTRY *BufferStorage,
IN EFI_FORM_CALLBACK_PROTOCOL *FwFormCallBack,
OUT VOID **Data,
OUT UINTN *DataSize
)
@ -272,16 +307,16 @@ ExtractConfigFromFrameworkFormCallBack (
*DataSize = 0;
*Data = NULL;
Status = FrameworkFormCallBack->NvRead (
FrameworkFormCallBack,
BufferStorageKey->Name,
&BufferStorageKey->Guid,
Status = FwFormCallBack->NvRead (
FwFormCallBack,
BufferStorage->Name,
&BufferStorage->Guid,
NULL,
DataSize,
*Data
);
if (Status == EFI_BUFFER_TOO_SMALL) {
if (BufferStorageKey->Size != *DataSize) {
if (BufferStorage->Size != *DataSize) {
ASSERT (FALSE);
return EFI_INVALID_PARAMETER;
}
@ -291,10 +326,10 @@ ExtractConfigFromFrameworkFormCallBack (
return EFI_OUT_OF_RESOURCES;
}
FrameworkFormCallBack->NvRead (
FrameworkFormCallBack,
BufferStorageKey->Name,
&BufferStorageKey->Guid,
FwFormCallBack->NvRead (
FwFormCallBack,
BufferStorage->Name,
&BufferStorage->Guid,
NULL,
DataSize,
*Data
@ -304,52 +339,26 @@ ExtractConfigFromFrameworkFormCallBack (
return Status;
}
/**
Wrap the EFI_HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig to a call to UEFI Variable Set Service.
@param BufferStorageKey The key with all attributes needed to call a UEFI Variable Get Service.
@param Data The data read.
@param DataSize The size of data.
@retval EFI_STATUS The status returned by the UEFI Variable Set Service.
**/
EFI_STATUS
RouteConfigToUefiVariable (
IN HII_TRHUNK_BUFFER_STORAGE_KEY *BufferStorageKey,
IN VOID *Data,
IN UINTN DataSize
)
{
return gRT->SetVariable (
BufferStorageKey->Name,
&BufferStorageKey->Guid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
DataSize,
Data
);
}
/**
Wrap the EFI_HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig to a call to UEFI Variable Get Service.
@param BufferStorageKey The key with all attributes needed to call a UEFI Variable Get Service.
@param Data The data read.
@param DataSize The size of data.
@param BufferStorage The key with all attributes needed to call a UEFI Variable Get Service.
@param Data The data read.
@param DataSize The size of data.
If the UEFI Variable Get Service return the size information of the data
does not match what has been recorded early in he HII_TRHUNK_BUFFER_STORAGE_KEY.
does not match what has been recorded early in he BUFFER_STORAGE_ENTRY.
then ASSERT.
@retval EFI_STATUS The status returned by the UEFI Variable Get Service.
@retval EFI_STATUS The status returned by the UEFI Variable Get Service.
@retval EFI_INVALID_PARAMETER If the UEFI Variable Get Service return the size information of the data
does not match what has been recorded early in he HII_TRHUNK_BUFFER_STORAGE_KEY.
does not match what has been recorded early in he BUFFER_STORAGE_ENTRY.
**/
EFI_STATUS
ExtractConfigFromUefiVariable (
IN HII_TRHUNK_BUFFER_STORAGE_KEY *BufferStorageKey,
GetUefiVariable (
IN BUFFER_STORAGE_ENTRY *BufferStorage,
OUT VOID **Data,
OUT UINTN *DataSize
)
@ -359,15 +368,15 @@ ExtractConfigFromUefiVariable (
*DataSize = 0;
*Data = NULL;
Status = gRT->GetVariable (
BufferStorageKey->Name,
&BufferStorageKey->Guid,
BufferStorage->Name,
&BufferStorage->Guid,
NULL,
DataSize,
*Data
);
if (Status == EFI_BUFFER_TOO_SMALL) {
if (BufferStorageKey->Size != *DataSize) {
if (BufferStorage->Size != *DataSize) {
ASSERT (FALSE);
return EFI_INVALID_PARAMETER;
}
@ -378,8 +387,8 @@ ExtractConfigFromUefiVariable (
}
Status = gRT->GetVariable (
BufferStorageKey->Name,
&BufferStorageKey->Guid,
BufferStorage->Name,
&BufferStorage->Guid,
NULL,
DataSize,
*Data
@ -395,22 +404,22 @@ ExtractConfigFromUefiVariable (
so that data can be read from the data storage such as UEFI Variable or module's
customized storage exposed by EFI_FRAMEWORK_CALLBACK.
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL
@param Request A null-terminated Unicode string in <ConfigRequest> format. Note that this
includes the routing information as well as the configurable name / value pairs. It is
invalid for this string to be in <MultiConfigRequest> format.
includes the routing information as well as the configurable name / value pairs. It is
invalid for this string to be in <MultiConfigRequest> format.
@param Progress On return, points to a character in the Request string. Points to the string's null
terminator if request was successful. Points to the most recent '&' before the first
failing name / value pair (or the beginning of the string if the failure is in the first
name / value pair) if the request was not successful
@param Progress On return, points to a character in the Request string. Points to the string's null
terminator if request was successful. Points to the most recent '&' before the first
failing name / value pair (or the beginning of the string if the failure is in the first
name / value pair) if the request was not successful
@param Results A null-terminated Unicode string in <ConfigAltResp> format which has all
values filled in for the names in the Request string. String to be allocated by the called
function.
values filled in for the names in the Request string. String to be allocated by the called
function.
@retval EFI_INVALID_PARAMETER If there is no Buffer Storage for this Config Access instance.
@retval EFI_SUCCESS The setting is retrived successfully.
@retval !EFI_SUCCESS The error returned by UEFI Get Variable or Framework Form Callback Nvread.
@retval EFI_SUCCESS The setting is retrived successfully.
@retval !EFI_SUCCESS The error returned by UEFI Get Variable or Framework Form Callback Nvread.
**/
EFI_STATUS
EFIAPI
@ -422,37 +431,37 @@ ThunkExtractConfig (
)
{
EFI_STATUS Status;
HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE *ConfigaAccessInstance;
LIST_ENTRY *ListEntry;
HII_TRHUNK_BUFFER_STORAGE_KEY *BufferStorageKey;
CONFIG_ACCESS_PRIVATE *ConfigAccess;
LIST_ENTRY *Link;
BUFFER_STORAGE_ENTRY *BufferStorage;
VOID *Data;
UINTN DataSize;
Data = NULL;
ConfigaAccessInstance = HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE_FROM_PROTOCOL (This);
ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This);
//
// For now, only one var varstore is supported so that we don't need to parse the Configuration string.
//
ListEntry = GetFirstNode (&ConfigaAccessInstance->ConfigAccessBufferStorageListHead);
if (ListEntry == NULL) {
Link = GetFirstNode (&ConfigAccess->BufferStorageListHead);
if (Link == NULL) {
ASSERT (FALSE);
return EFI_INVALID_PARAMETER;
}
BufferStorageKey = HII_TRHUNK_BUFFER_STORAGE_KEY_FROM_LIST_ENTRY (ListEntry);
BufferStorage = BUFFER_STORAGE_ENTRY_FROM_LINK (Link);
if (ConfigaAccessInstance->FrameworkFormCallbackProtocol == NULL ||
ConfigaAccessInstance->FrameworkFormCallbackProtocol->NvRead == NULL) {
Status = ExtractConfigFromUefiVariable (
BufferStorageKey,
if (ConfigAccess->FormCallbackProtocol == NULL ||
ConfigAccess->FormCallbackProtocol->NvRead == NULL) {
Status = GetUefiVariable (
BufferStorage,
&Data,
&DataSize
);
} else {
Status = ExtractConfigFromFrameworkFormCallBack (
BufferStorageKey,
ConfigaAccessInstance->FrameworkFormCallbackProtocol,
Status = CallFormCallBack (
BufferStorage,
ConfigAccess->FormCallbackProtocol,
&Data,
&DataSize
);
@ -479,15 +488,15 @@ ThunkExtractConfig (
so that data can be written to the data storage such as UEFI Variable or module's
customized storage exposed by EFI_FRAMEWORK_CALLBACK.
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL
@param Configuration A null-terminated Unicode string in <ConfigResp> format.
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL
@param Configuration A null-terminated Unicode string in <ConfigResp> format.
@param Progress A pointer to a string filled in with the offset of the most recent '&' before the first
failing name / value pair (or the beginning of the string if the failure is in the first
name / value pair) or the terminating NULL if all was successful.
failing name / value pair (or the beginning of the string if the failure is in the first
name / value pair) or the terminating NULL if all was successful.
@retval EFI_INVALID_PARAMETER If there is no Buffer Storage for this Config Access instance.
@retval EFI_SUCCESS The setting is saved successfully.
@retval !EFI_SUCCESS The error returned by UEFI Set Variable or Framework Form Callback Nvwrite.
@retval EFI_SUCCESS The setting is saved successfully.
@retval !EFI_SUCCESS The error returned by UEFI Set Variable or Framework Form Callback Nvwrite.
**/
EFI_STATUS
EFIAPI
@ -498,31 +507,61 @@ ThunkRouteConfig (
)
{
EFI_STATUS Status;
HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE *ConfigaAccessInstance;
LIST_ENTRY *ListEntry;
HII_TRHUNK_BUFFER_STORAGE_KEY *BufferStorageKey;
VOID *Data;
CONFIG_ACCESS_PRIVATE *ConfigAccess;
LIST_ENTRY *Link;
BUFFER_STORAGE_ENTRY *BufferStorage;
UINT8 *Data;
UINTN DataSize;
UINTN DataSize2;
UINTN LastModifiedByteIndex;
BOOLEAN ResetRequired;
BOOLEAN DataAllocated;
Data = NULL;
ConfigaAccessInstance = HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE_FROM_PROTOCOL (This);
DataAllocated = TRUE;
ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This);
//
// For now, only one var varstore is supported so that we don't need to parse the Configuration string.
//
ListEntry = GetFirstNode (&ConfigaAccessInstance->ConfigAccessBufferStorageListHead);
if (ListEntry == NULL) {
Link = GetFirstNode (&ConfigAccess->BufferStorageListHead);
if (Link == NULL) {
ASSERT (FALSE);
return EFI_INVALID_PARAMETER;
}
BufferStorageKey = HII_TRHUNK_BUFFER_STORAGE_KEY_FROM_LIST_ENTRY (ListEntry);
Data = AllocateZeroPool (BufferStorageKey->Size);
if (Data == NULL) {
return EFI_OUT_OF_RESOURCES;
BufferStorage = BUFFER_STORAGE_ENTRY_FROM_LINK (Link);
DataSize2 = BufferStorage->Size;
if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
if (ConfigAccess->FormCallbackProtocol == NULL ||
ConfigAccess->FormCallbackProtocol->NvRead == NULL) {
Status = GetUefiVariable (
BufferStorage,
&Data,
&DataSize
);
ASSERT (DataSize == DataSize2);
} else {
Status = CallFormCallBack (
BufferStorage,
ConfigAccess->FormCallbackProtocol,
&Data,
&DataSize
);
ASSERT (DataSize == DataSize2);
}
} else {
Status = EFI_SUCCESS;
Data = ConfigAccess->ThunkContext->NvMapOverride;
DataSize = DataSize2;
DataAllocated = FALSE;
}
if (EFI_ERROR (Status)) {
goto Done;
}
Status = mHiiConfigRoutingProtocol->ConfigToBlock (
mHiiConfigRoutingProtocol,
Configuration,
@ -530,54 +569,209 @@ ThunkRouteConfig (
&LastModifiedByteIndex,
Progress
);
if (EFI_ERROR (Status)) {
goto Done;
}
DataSize = BufferStorageKey->Size;
if (ConfigaAccessInstance->FrameworkFormCallbackProtocol == NULL ||
ConfigaAccessInstance->FrameworkFormCallbackProtocol->NvRead == NULL) {
Status = RouteConfigToUefiVariable (
BufferStorageKey,
Data,
DataSize
);
if (ConfigAccess->FormCallbackProtocol == NULL ||
ConfigAccess->FormCallbackProtocol->NvWrite == NULL) {
Status = gRT->SetVariable (
BufferStorage->Name,
&BufferStorage->Guid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
DataSize,
Data
);
} else {
Status = RouteConfigToFrameworkFormCallBack (
BufferStorageKey,
ConfigaAccessInstance->FrameworkFormCallbackProtocol,
Data,
DataSize
);
Status = ConfigAccess->FormCallbackProtocol->NvWrite (
ConfigAccess->FormCallbackProtocol,
BufferStorage->Name,
&BufferStorage->Guid,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
DataSize,
Data,
&ResetRequired
);
}
Done:
SafeFreePool (Data);
Done:
if (DataAllocated && (Data != NULL)) {
FreePool (Data);
}
return Status;
}
FRAMEWORK_EFI_IFR_DATA_ARRAY *
CreateIfrDataArray (
IN CONFIG_ACCESS_PRIVATE *ConfigAccess,
IN EFI_QUESTION_ID QuestionId,
IN UINT8 Type,
IN EFI_IFR_TYPE_VALUE *Value,
OUT BOOLEAN *NvMapAllocated
)
{
FRAMEWORK_EFI_IFR_DATA_ARRAY *IfrDataArray;
FRAMEWORK_EFI_IFR_DATA_ENTRY *IfrDataEntry;
UINTN BrowserDataSize;
BUFFER_STORAGE_ENTRY *BufferStorageEntry;
LIST_ENTRY *Link;
IfrDataArray = AllocateZeroPool (0x100);
ASSERT (IfrDataArray != NULL);
if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
Link = GetFirstNode (&ConfigAccess->BufferStorageListHead);
ASSERT (!IsNull (&ConfigAccess->BufferStorageListHead, Link));
BufferStorageEntry = BUFFER_STORAGE_ENTRY_FROM_LINK(Link);
BrowserDataSize = BufferStorageEntry->Size;
*NvMapAllocated = TRUE;
IfrDataArray->NvRamMap = AllocateZeroPool (BrowserDataSize);
GetBrowserData (NULL, NULL, &BrowserDataSize, IfrDataArray->NvRamMap);
} else {
*NvMapAllocated = FALSE;
IfrDataArray->NvRamMap = ConfigAccess->ThunkContext->NvMapOverride;
}
IfrDataEntry = (FRAMEWORK_EFI_IFR_DATA_ENTRY *) (IfrDataArray + 1);
switch (Type) {
case EFI_IFR_TYPE_NUM_SIZE_8:
case EFI_IFR_TYPE_NUM_SIZE_16:
case EFI_IFR_TYPE_NUM_SIZE_32:
case EFI_IFR_TYPE_NUM_SIZE_64:
case EFI_IFR_TYPE_BOOLEAN:
CopyMem (&IfrDataEntry->Data, &(Value->u8), sizeof (*Value));
break;
default:
ASSERT (FALSE);
break;
}
return IfrDataArray;
}
VOID
DestroyIfrDataArray (
IN FRAMEWORK_EFI_IFR_DATA_ARRAY *Array,
IN BOOLEAN NvMapAllocated
)
{
if (NvMapAllocated) {
FreePool (Array->NvRamMap);
}
FreePool (Array);
}
ONE_OF_OPTION_MAP_ENTRY *
GetOneOfOptionMapEntry (
IN HII_THUNK_CONTEXT *ThunkContext,
IN EFI_QUESTION_ID QuestionId,
IN UINT8 Type,
IN EFI_IFR_TYPE_VALUE *Value
)
{
LIST_ENTRY *Link;
LIST_ENTRY *Link2;
ONE_OF_OPTION_MAP_ENTRY *OneOfOptionMapEntry;
ONE_OF_OPTION_MAP *OneOfOptionMap;
Link = GetFirstNode (&ThunkContext->OneOfOptionMapListHead);
while (!IsNull (&ThunkContext->OneOfOptionMapListHead, Link)) {
OneOfOptionMap = ONE_OF_OPTION_MAP_FROM_LINK(Link);
if (OneOfOptionMap->QuestionId == QuestionId) {
ASSERT (OneOfOptionMap->ValueType == Type);
Link2 = GetFirstNode (&OneOfOptionMap->OneOfOptionMapEntryListHead);
while (!IsNull (&OneOfOptionMap->OneOfOptionMapEntryListHead, Link2)) {
OneOfOptionMapEntry = ONE_OF_OPTION_MAP_ENTRY_FROM_LINK (Link2);
if (CompareMem (Value, &OneOfOptionMapEntry->Value, sizeof (EFI_IFR_TYPE_VALUE)) == 0) {
return OneOfOptionMapEntry;
}
Link2 = GetNextNode (&OneOfOptionMap->OneOfOptionMapEntryListHead, Link2);
}
}
Link = GetNextNode (&ThunkContext->OneOfOptionMapListHead, Link);
}
return NULL;
}
/**
Functions which are registered to receive notification of
database events have this prototype. The actual event is encoded
in NotifyType. The following table describes how PackageType,
PackageGuid, Handle, and Package are used for each of the
notification types.
@param PackageType Package type of the notification.
@param PackageGuid If PackageType is
EFI_HII_PACKAGE_TYPE_GUID, then this is
the pointer to the GUID from the Guid
field of EFI_HII_PACKAGE_GUID_HEADER.
Otherwise, it must be NULL.
@param Package Points to the package referred to by the
notification Handle The handle of the package
list which contains the specified package.
@param Handle The HII handle.
@param NotifyType The type of change concerning the
database. See
EFI_HII_DATABASE_NOTIFY_TYPE.
**/
EFI_STATUS
EFIAPI
FormUpdateNotify (
IN UINT8 PackageType,
IN CONST EFI_GUID *PackageGuid,
IN CONST EFI_HII_PACKAGE_HEADER *Package,
IN EFI_HII_HANDLE Handle,
IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
)
{
mHiiPackageListUpdated = TRUE;
return EFI_SUCCESS;
}
/**
Wrap the EFI_HII_CONFIG_ACCESS_PROTOCOL.CallBack to EFI_FORM_CALLBACK_PROTOCOL.Callback. Therefor,
the framework HII module willl do no porting (except some porting works needed for callback for EFI_ONE_OF_OPTION opcode)
and still work with a UEFI HII SetupBrowser.
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
@param Action Specifies the type of action taken by the browser. See EFI_BROWSER_ACTION_x.
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
@param Action Specifies the type of action taken by the browser. See EFI_BROWSER_ACTION_x.
@param QuestionId A unique value which is sent to the original exporting driver so that it can identify the
type of data to expect. The format of the data tends to vary based on the opcode that
generated the callback.
@param Type The type of value for the question. See EFI_IFR_TYPE_x in
EFI_IFR_ONE_OF_OPTION.
@param Value A pointer to the data being sent to the original exporting driver. The type is specified
by Type. Type EFI_IFR_TYPE_VALUE is defined in
EFI_IFR_ONE_OF_OPTION.
type of data to expect. The format of the data tends to vary based on the opcode that
generated the callback.
@param Type The type of value for the question. See EFI_IFR_TYPE_x in
EFI_IFR_ONE_OF_OPTION.
@param Value A pointer to the data being sent to the original exporting driver. The type is specified
by Type. Type EFI_IFR_TYPE_VALUE is defined in
EFI_IFR_ONE_OF_OPTION.
@param ActionRequest On return, points to the action requested by the callback function. Type
EFI_BROWSER_ACTION_REQUEST is specified in SendForm() in the Form
Browser Protocol.
EFI_BROWSER_ACTION_REQUEST is specified in SendForm() in the Form
Browser Protocol.
@retval EFI_UNSUPPORTED If the Framework HII module does not register Callback although it specify the opcode under
focuse to be INTERRACTIVE.
@retval EFI_UNSUPPORTED If the Framework HII module does not register Callback although it specify the opcode under
focuse to be INTERRACTIVE.
@retval EFI_SUCCESS The callback complete successfully.
@retval !EFI_SUCCESS The error code returned by EFI_FORM_CALLBACK_PROTOCOL.Callback.
@ -594,12 +788,16 @@ ThunkCallback (
)
{
EFI_STATUS Status;
HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE *ConfigaAccessInstance;
EFI_FORM_CALLBACK_PROTOCOL *FrameworkFormCallbackProtocol;
CONFIG_ACCESS_PRIVATE *ConfigAccess;
EFI_FORM_CALLBACK_PROTOCOL *FormCallbackProtocol;
EFI_HII_CALLBACK_PACKET *Packet;
FRAMEWORK_EFI_IFR_DATA_ARRAY Data;
FRAMEWORK_EFI_IFR_DATA_ARRAY *Data;
FRAMEWORK_EFI_IFR_DATA_ENTRY *DataEntry;
EFI_FORM_CALLBACK Callback;
UINT16 KeyValue;
ONE_OF_OPTION_MAP_ENTRY *OneOfOptionMapEntry;
EFI_HANDLE NotifyHandle;
EFI_INPUT_KEY Key;
BOOLEAN NvMapAllocated;
ASSERT (This != NULL);
ASSERT (Value != NULL);
@ -607,43 +805,111 @@ ThunkCallback (
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
ConfigaAccessInstance = HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE_FROM_PROTOCOL (This);
ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This);
FrameworkFormCallbackProtocol = ConfigaAccessInstance->FrameworkFormCallbackProtocol;
if (FrameworkFormCallbackProtocol == NULL) {
FormCallbackProtocol = ConfigAccess->FormCallbackProtocol;
if (FormCallbackProtocol == NULL) {
ASSERT (FALSE);
return EFI_UNSUPPORTED;
}
Callback = FrameworkFormCallbackProtocol->Callback;
Status = Callback (
FrameworkFormCallbackProtocol,
QuestionId,
&Data,
//
// Check if the QuestionId match a OneOfOption.
//
OneOfOptionMapEntry = GetOneOfOptionMapEntry (ConfigAccess->ThunkContext, QuestionId, Type, Value);
if (OneOfOptionMapEntry == NULL) {
//
// This is not a One-Of-Option opcode. QuestionId is the KeyValue
//
KeyValue = QuestionId;
} else {
KeyValue = OneOfOptionMapEntry->FwKey;
}
//
// Build the FRAMEWORK_EFI_IFR_DATA_ARRAY
//
Data = CreateIfrDataArray (ConfigAccess, QuestionId, Type, Value, &NvMapAllocated);
Status = mHiiDatabase->RegisterPackageNotify (
mHiiDatabase,
EFI_HII_PACKAGE_FORM,
NULL,
FormUpdateNotify,
EFI_HII_DATABASE_NOTIFY_REMOVE_PACK,
&NotifyHandle
);
//
//
//
Packet = NULL;
Status = FormCallbackProtocol->Callback (
FormCallbackProtocol,
KeyValue,
Data,
&Packet
);
//
// Callback require browser to perform action
//
if (Packet != NULL) {
if (Packet->DataArray.EntryCount == 1 && Packet->DataArray.NvRamMap == NULL) {
DataEntry = (FRAMEWORK_EFI_IFR_DATA_ENTRY *) ((UINT8 *) Packet + sizeof (FRAMEWORK_EFI_IFR_DATA_ARRAY));
switch (DataEntry->Flags) {
case EXIT_REQUIRED:
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;
break;
case SAVE_REQUIRED:
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;
break;
case RESET_REQUIRED:
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_RESET;
break;
default:
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_NONE;
break;
}
if (EFI_ERROR (Status)) {
if (Packet != NULL) {
//
// BUGBUG: need to restore the changing question to default value
//
do {
IfrLibCreatePopUp (1, &Key, Packet->String);
} while (Key.UnicodeChar != CHAR_CARRIAGE_RETURN);
}
//
// Error Code in Status is discarded.
//
} else {
if (Packet != NULL) {
if (Packet->DataArray.EntryCount == 1 && Packet->DataArray.NvRamMap == NULL) {
DataEntry = (FRAMEWORK_EFI_IFR_DATA_ENTRY *) ((UINT8 *) Packet + sizeof (FRAMEWORK_EFI_IFR_DATA_ARRAY));
if ((DataEntry->Flags & EXIT_REQUIRED) == EXIT_REQUIRED) {
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;
}
if ((DataEntry->Flags & SAVE_REQUIRED) == SAVE_REQUIRED) {
Status = ConfigAccess->ConfigAccessProtocol.RouteConfig (
&ConfigAccess->ConfigAccessProtocol,
NULL,
NULL
);
}
}
FreePool (Packet);
}
}
//
// Unregister notify for Form package update
//
Status = mHiiDatabase->UnregisterPackageNotify (
mHiiDatabase,
NotifyHandle
);
//
// UEFI SetupBrowser handles scenario differently with Framework SetupBrowser when call back function
// update any forms in HII database. UEFI SetupBrowser will re-parse the displaying form package and load
// the values from variable storages. Framework SetupBrowser will only re-parse the displaying form packages.
// To make sure customer's previous changes is saved and the changing question behaves as expected, we
// issue a EFI_BROWSER_ACTION_REQUEST_SUBMIT to ask UEFI SetupBrowser to save the changes proceed to re-parse
// the form and load all the variable storages.
//
if (*ActionRequest == EFI_BROWSER_ACTION_REQUEST_NONE && mHiiPackageListUpdated) {
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;
}
DestroyIfrDataArray (Data, NvMapAllocated);
return Status;
}

View File

@ -25,16 +25,22 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
that Setup Utility can load the Buffer Storage using this protocol.
@param Packages The framework package list.
@param MapEntry The Thunk Layer Handle Mapping Database Entry.
@param ThunkContext The Thunk Layer Handle Mapping Database Entry.
@retval EFI_SUCCESS The Config Access Protocol is installed successfully.
@retval EFI_SUCCESS The Config Access Protocol is installed successfully.
@retval EFI_OUT_RESOURCE There is not enough memory.
**/
EFI_STATUS
InstallDefaultUefiConfigAccessProtocol (
InstallDefaultConfigAccessProtocol (
IN CONST EFI_HII_PACKAGES *Packages,
IN OUT HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *MapEntry
IN OUT HII_THUNK_CONTEXT *ThunkContext
)
;
VOID
UninstallDefaultConfigAccessProtocol (
IN HII_THUNK_CONTEXT *ThunkContext
)
;
@ -44,22 +50,22 @@ InstallDefaultUefiConfigAccessProtocol (
so that data can be read from the data storage such as UEFI Variable or module's
customized storage exposed by EFI_FRAMEWORK_CALLBACK.
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL
@param Request A null-terminated Unicode string in <ConfigRequest> format. Note that this
includes the routing information as well as the configurable name / value pairs. It is
invalid for this string to be in <MultiConfigRequest> format.
includes the routing information as well as the configurable name / value pairs. It is
invalid for this string to be in <MultiConfigRequest> format.
@param Progress On return, points to a character in the Request string. Points to the string's null
terminator if request was successful. Points to the most recent '&' before the first
failing name / value pair (or the beginning of the string if the failure is in the first
name / value pair) if the request was not successful
@param Progress On return, points to a character in the Request string. Points to the string's null
terminator if request was successful. Points to the most recent '&' before the first
failing name / value pair (or the beginning of the string if the failure is in the first
name / value pair) if the request was not successful
@param Results A null-terminated Unicode string in <ConfigAltResp> format which has all
values filled in for the names in the Request string. String to be allocated by the called
function.
values filled in for the names in the Request string. String to be allocated by the called
function.
@retval EFI_INVALID_PARAMETER If there is no Buffer Storage for this Config Access instance.
@retval EFI_SUCCESS The setting is retrived successfully.
@retval !EFI_SUCCESS The error returned by UEFI Get Variable or Framework Form Callback Nvread.
@retval EFI_SUCCESS The setting is retrived successfully.
@retval !EFI_SUCCESS The error returned by UEFI Get Variable or Framework Form Callback Nvread.
**/
EFI_STATUS
EFIAPI
@ -79,14 +85,14 @@ ThunkExtractConfig (
customized storage exposed by EFI_FRAMEWORK_CALLBACK.
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL
@param Configuration A null-terminated Unicode string in <ConfigResp> format.
@param Progress A pointer to a string filled in with the offset of the most recent '&' before the first
failing name / value pair (or the beginning of the string if the failure is in the first
name / value pair) or the terminating NULL if all was successful.
@param Configuration A null-terminated Unicode string in <ConfigResp> format.
@param Progress A pointer to a string filled in with the offset of the most recent '&' before the first
failing name / value pair (or the beginning of the string if the failure is in the first
name / value pair) or the terminating NULL if all was successful.
@retval EFI_INVALID_PARAMETER If there is no Buffer Storage for this Config Access instance.
@retval EFI_SUCCESS The setting is saved successfully.
@retval !EFI_SUCCESS The error returned by UEFI Set Variable or Framework Form Callback Nvwrite.
@retval EFI_SUCCESS The setting is saved successfully.
@retval !EFI_SUCCESS The error returned by UEFI Set Variable or Framework Form Callback Nvwrite.
**/
EFI_STATUS
EFIAPI
@ -102,24 +108,24 @@ ThunkRouteConfig (
the framework HII module willl do no porting (except some porting works needed for callback for EFI_ONE_OF_OPTION opcode)
and still work with a UEFI HII SetupBrowser.
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
@param Action Specifies the type of action taken by the browser. See EFI_BROWSER_ACTION_x.
@param QuestionId A unique value which is sent to the original exporting driver so that it can identify the
type of data to expect. The format of the data tends to vary based on the opcode that
generated the callback.
@param Type The type of value for the question. See EFI_IFR_TYPE_x in
EFI_IFR_ONE_OF_OPTION.
@param Value A pointer to the data being sent to the original exporting driver. The type is specified
by Type. Type EFI_IFR_TYPE_VALUE is defined in
EFI_IFR_ONE_OF_OPTION.
@param ActionRequest On return, points to the action requested by the callback function. Type
EFI_BROWSER_ACTION_REQUEST is specified in SendForm() in the Form
Browser Protocol.
@param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL.
@param Action Specifies the type of action taken by the browser. See EFI_BROWSER_ACTION_x.
@param QuestionId A unique value which is sent to the original exporting driver so that it can identify the
type of data to expect. The format of the data tends to vary based on the opcode that
generated the callback.
@param Type The type of value for the question. See EFI_IFR_TYPE_x in
EFI_IFR_ONE_OF_OPTION.
@param Value A pointer to the data being sent to the original exporting driver. The type is specified
by Type. Type EFI_IFR_TYPE_VALUE is defined in
EFI_IFR_ONE_OF_OPTION.
@param ActionRequest On return, points to the action requested by the callback function. Type
EFI_BROWSER_ACTION_REQUEST is specified in SendForm() in the Form
Browser Protocol.
@retval EFI_UNSUPPORTED If the Framework HII module does not register Callback although it specify the opcode under
focuse to be INTERRACTIVE.
@retval EFI_SUCCESS The callback complete successfully.
@retval !EFI_SUCCESS The error code returned by EFI_FORM_CALLBACK_PROTOCOL.Callback.
focuse to be INTERRACTIVE.
@retval EFI_SUCCESS The callback complete successfully.
@retval !EFI_SUCCESS The error code returned by EFI_FORM_CALLBACK_PROTOCOL.Callback.
**/
EFI_STATUS

View File

@ -19,6 +19,23 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
UINT8 mGlyphBuffer[EFI_GLYPH_WIDTH * 2 * EFI_GLYPH_HEIGHT];
/**
This function is only called by Graphics Console module and GraphicsLib.
EDK II provides a UEFI Graphics Console module. ECP provides a GraphicsLib
complying to UEFI HII.
This function will ASSERT and return EFI_UNSUPPORTED.
@param This N.A.
@param Source N.A.
@param Index N.A.
@param GlyphBuffer N.A.
@param BitWidth N.A.
@param InternalStatus N.A.
@return EFI_UNSUPPORTED N.A.
**/
EFI_STATUS
EFIAPI
HiiGetGlyph (
@ -29,30 +46,30 @@ HiiGetGlyph (
OUT UINT16 *BitWidth,
IN OUT UINT32 *InternalStatus
)
/*++
Routine Description:
Translates a Unicode character into the corresponding font glyph.
If the Source was pointing to a non-spacing character, the next Source[*Index]
character will be parsed and OR'd to the GlyphBuffer until a spacing character
is found in the Source. Since non-spacing characters are considered to be the
same pixel width as a regular character their BitWidth will be reflected correctly
however due to their special attribute, they are considered to be zero advancing width.
This basically means that the cursor would not advance, thus the character that follows
it would overlay the non-spacing character. The Index is modified to reflect both the
incoming array entry into the Source string but also the outgoing array entry after having
parsed the equivalent of a single Glyph's worth of data.
Arguments:
Returns:
--*/
{
ASSERT (FALSE);
return EFI_UNSUPPORTED;
}
/**
This function is only called by Graphics Console module and GraphicsLib.
EDK II provides a UEFI Graphics Console module. ECP provides a GraphicsLib
complying to UEFI HII.
This function will ASSERT and return EFI_UNSUPPORTED.
@param This N.A.
@param GlyphBuffer N.A.
@param Foreground N.A.
@param Background N.A.
@param Count N.A.
@param Width N.A.
@param Height N.A.
@param BltBuffer N.A.
@return EFI_UNSUPPORTED N.A.
**/
EFI_STATUS
EFIAPI
HiiGlyphToBlt (

View File

@ -17,42 +17,20 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "UefiIfrDefault.h"
#include "OpcodeCreation.h"
EFI_STATUS
EFIAPI
HiiExportDatabase (
IN EFI_HII_PROTOCOL *This,
IN FRAMEWORK_EFI_HII_HANDLE Handle,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer
)
/*++
Routine Description:
This function allows a program to extract a form or form package that has
previously been registered with the EFI HII database.
Arguments:
Returns:
--*/
{
ASSERT (FALSE);
return EFI_UNSUPPORTED;
}
//
// This structure is only intended to be used in this file.
//
#pragma pack(push, 1)
typedef struct {
EFI_HII_PACK_HEADER PackageHeader;
FRAMEWORK_EFI_IFR_FORM_SET FormSet;
FRAMEWORK_EFI_IFR_END_FORM_SET EndFormSet;
} FRAMEWORK_HII_FORMSET_TEMPLATE;
} FW_HII_FORMSET_TEMPLATE;
#pragma pack(pop)
FRAMEWORK_HII_FORMSET_TEMPLATE FormSetTemplate = {
FW_HII_FORMSET_TEMPLATE FormSetTemplate = {
{
sizeof (FRAMEWORK_HII_FORMSET_TEMPLATE),
sizeof (FW_HII_FORMSET_TEMPLATE),
EFI_HII_IFR
},
{
@ -77,6 +55,64 @@ FRAMEWORK_HII_FORMSET_TEMPLATE FormSetTemplate = {
}
};
/**
This thunk module only handles UEFI HII packages. The caller of this function
won¡¯t be able to parse the content. Therefore, it is not supported.
This function will ASSERT and return EFI_UNSUPPORTED.
@param This N.A.
@param Handle N.A.
@param BufferSize N.A.
@param Buffer N.A.
@retval EFI_UNSUPPORTED
**/
EFI_STATUS
EFIAPI
HiiExportDatabase (
IN EFI_HII_PROTOCOL *This,
IN FRAMEWORK_EFI_HII_HANDLE Handle,
IN OUT UINTN *BufferSize,
OUT VOID *Buffer
)
{
ASSERT (FALSE);
return EFI_UNSUPPORTED;
}
/**
This function allows a program to extract a form or form package that has
previously been registered with the EFI HII database.
In this thunk module, this function will create a IFR Package with only
one Formset. Effectively, only the GUID of the Formset is updated and return
in this IFR package to caller. This is enable the Framework modules which call
a API named GetStringFromToken. GetStringFromToken retieves a String based on
a String Token from a Package List known only by the Formset GUID.
@param This A pointer to the EFI_HII_PROTOCOL instance.
@param Handle Handle on which the form resides. Type FRAMEWORK_EFI_HII_HANDLE is defined in
EFI_HII_PROTOCOL.NewPack() in the Packages section.
@param FormId Ignored by this implementation.
@param BufferLengthTemp On input, the size of input buffer. On output, it
is the size of FW_HII_FORMSET_TEMPLATE.
@param Buffer The buffer designed to receive the form(s).
@retval EFI_SUCCESS Buffer filled with the requested forms. BufferLength
was updated.
@retval EFI_INVALID_PARAMETER The handle is unknown.
@retval EFI_NOT_FOUND A form on the requested handle cannot be found with the
requested FormId.
@retval EFI_BUFFER_TOO_SMALL The buffer provided was not large enough to allow the form to be stored.
**/
EFI_STATUS
EFIAPI
HiiGetForms (
@ -86,68 +122,57 @@ HiiGetForms (
IN OUT UINTN *BufferLengthTemp,
OUT UINT8 *Buffer
)
/*++
Routine Description:
This function allows a program to extract a form or form package that has
previously been registered with the EFI HII database.
Arguments:
This - A pointer to the EFI_HII_PROTOCOL instance.
Handle - Handle on which the form resides. Type FRAMEWORK_EFI_HII_HANDLE is defined in
EFI_HII_PROTOCOL.NewPack() in the Packages section.
FormId - The ID of the form to return. If the ID is zero, the entire form package is returned.
Type EFI_FORM_ID is defined in "Related Definitions" below.
BufferLength - On input, the length of the Buffer. On output, the length of the returned buffer, if
the length was sufficient and, if it was not, the length that is required to fit the
requested form(s).
Buffer - The buffer designed to receive the form(s).
Returns:
EFI_SUCCESS - Buffer filled with the requested forms. BufferLength
was updated.
EFI_INVALID_PARAMETER - The handle is unknown.
EFI_NOT_FOUND - A form on the requested handle cannot be found with the
requested FormId.
EFI_BUFFER_TOO_SMALL - The buffer provided was not large enough to allow the form to be stored.
--*/
{
EFI_HII_THUNK_PRIVATE_DATA *Private;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *MapEntry;
FRAMEWORK_HII_FORMSET_TEMPLATE *OutputFormSet;
HII_THUNK_PRIVATE_DATA *Private;
HII_THUNK_CONTEXT *ThunkContext;
FW_HII_FORMSET_TEMPLATE *OutputFormSet;
if (*BufferLengthTemp < sizeof(FRAMEWORK_HII_FORMSET_TEMPLATE)) {
*BufferLengthTemp = sizeof(FRAMEWORK_HII_FORMSET_TEMPLATE);
if (*BufferLengthTemp < sizeof(FW_HII_FORMSET_TEMPLATE)) {
*BufferLengthTemp = sizeof(FW_HII_FORMSET_TEMPLATE);
return EFI_BUFFER_TOO_SMALL;
}
Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
MapEntry = FrameworkHiiHandleToMapDatabaseEntry (Private, Handle);
ThunkContext = FwHiiHandleToThunkContext (Private, Handle);
if (MapEntry == NULL) {
if (ThunkContext == NULL) {
return EFI_NOT_FOUND;
}
OutputFormSet = (FRAMEWORK_HII_FORMSET_TEMPLATE *) Buffer;
CopyMem (OutputFormSet, &FormSetTemplate, sizeof (FRAMEWORK_HII_FORMSET_TEMPLATE));
CopyMem (&OutputFormSet->FormSet.Guid, &MapEntry->TagGuid, sizeof (EFI_GUID));
OutputFormSet = (FW_HII_FORMSET_TEMPLATE *) Buffer;
CopyMem (OutputFormSet, &FormSetTemplate, sizeof (FW_HII_FORMSET_TEMPLATE));
CopyMem (&OutputFormSet->FormSet.Guid, &ThunkContext->TagGuid, sizeof (EFI_GUID));
OutputFormSet->FormSet.Class = ThunkContext->FormSetClass;
OutputFormSet->FormSet.SubClass = ThunkContext->FormSetSubClass;
OutputFormSet->FormSet.Help = ThunkContext->FormSetHelp;
OutputFormSet->FormSet.FormSetTitle = ThunkContext->FormSetTitle;
return EFI_SUCCESS;
}
/**
This function allows a program to extract the NV Image
that represents the default storage image
@param This A pointer to the EFI_HII_PROTOCOL instance.
@param Handle The HII handle from which will have default data retrieved.
UINTN - Mask used to retrieve the default image.
@param DefaultMask EDES_TODO: Add parameter description
@param VariablePackList Callee allocated, tightly-packed, link list data
structure that contain all default varaible packs
from the Hii Database.
@retval EFI_NOT_FOUND If Hii database does not contain any default images.
@retval EFI_INVALID_PARAMETER Invalid input parameter.
@retval EFI_SUCCESS Operation successful.
**/
EFI_STATUS
EFIAPI
HiiGetDefaultImage (
@ -156,36 +181,15 @@ HiiGetDefaultImage (
IN UINTN DefaultMask,
OUT EFI_HII_VARIABLE_PACK_LIST **VariablePackList
)
/*++
Routine Description:
This function allows a program to extract the NV Image
that represents the default storage image
Arguments:
This - A pointer to the EFI_HII_PROTOCOL instance.
Handle - The HII handle from which will have default data retrieved.
UINTN - Mask used to retrieve the default image.
VariablePackList - Callee allocated, tightly-packed, link list data
structure that contain all default varaible packs
from the Hii Database.
Returns:
EFI_NOT_FOUND - If Hii database does not contain any default images.
EFI_INVALID_PARAMETER - Invalid input parameter.
EFI_SUCCESS - Operation successful.
--*/
{
LIST_ENTRY *UefiDefaults;
EFI_HII_HANDLE UefiHiiHandle;
EFI_STATUS Status;
EFI_HII_THUNK_PRIVATE_DATA *Private;
HII_THUNK_PRIVATE_DATA *Private;
Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
UefiHiiHandle = FrameworkHiiHandleToUefiHiiHandle (Private, Handle);
UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);
if (UefiHiiHandle == NULL) {
ASSERT (FALSE);
return EFI_INVALID_PARAMETER;
@ -197,7 +201,7 @@ HiiGetDefaultImage (
goto Done;
}
Status = UefiDefaultsToFrameworkDefaults (UefiDefaults, DefaultMask, VariablePackList);
Status = UefiDefaultsToFwDefaults (UefiDefaults, DefaultMask, VariablePackList);
Done:
FreeDefaultList (UefiDefaults);
@ -205,22 +209,31 @@ Done:
return Status;
}
/**
EDES_TODO: Add function description.
@param CallbackHandle EDES_TODO: Add parameter description
@param ThunkContext EDES_TODO: Add parameter description
@return EDES_TODO: Add description for return value
**/
EFI_STATUS
ThunkUpdateFormCallBack (
UpdateFormCallBack (
IN EFI_HANDLE CallbackHandle,
IN CONST HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry
IN CONST HII_THUNK_CONTEXT *ThunkContext
)
{
EFI_STATUS Status;
EFI_FORM_CALLBACK_PROTOCOL *FrameworkFormCallbackProtocol;
EFI_FORM_CALLBACK_PROTOCOL *FormCallbackProtocol;
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccessProtocol;
EFI_HANDLE UefiDriverHandle;
HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE *ConfigAccessProtocolInstance;
CONFIG_ACCESS_PRIVATE *ConfigAccessPrivate;
Status = gBS->HandleProtocol (
CallbackHandle,
&gEfiFormCallbackProtocolGuid,
(VOID **) &FrameworkFormCallbackProtocol
(VOID **) &FormCallbackProtocol
);
if (EFI_ERROR (Status)) {
return EFI_INVALID_PARAMETER;
@ -228,7 +241,7 @@ ThunkUpdateFormCallBack (
Status = mHiiDatabase->GetPackageListHandle (
mHiiDatabase,
HandleMapEntry->UefiHiiHandle,
ThunkContext->UefiHiiHandle,
&UefiDriverHandle
);
ASSERT_EFI_ERROR (Status);
@ -239,17 +252,28 @@ ThunkUpdateFormCallBack (
);
ASSERT_EFI_ERROR (Status);
ConfigAccessProtocolInstance = HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE_FROM_PROTOCOL (ConfigAccessProtocol);
ConfigAccessPrivate = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (ConfigAccessProtocol);
ConfigAccessProtocolInstance->FrameworkFormCallbackProtocol = FrameworkFormCallbackProtocol;
ConfigAccessPrivate->FormCallbackProtocol = FormCallbackProtocol;
return EFI_SUCCESS;
}
/**
EDES_TODO: Add function description.
@param HiiPackageList EDES_TODO: Add parameter description
@param PackageIndex EDES_TODO: Add parameter description
@param BufferLen EDES_TODO: Add parameter description
@param Buffer EDES_TODO: Add parameter description
@return EDES_TODO: Add description for return value
**/
STATIC
EFI_STATUS
GetPackageDataFromPackageList (
GetPackageData (
IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList,
IN UINT32 PackageIndex,
OUT UINT32 *BufferLen,
@ -390,7 +414,7 @@ LocateLabel (
@retval EFI_SUCCESS The first found Form ID is returned in FormId.
**/
EFI_STATUS
ThunkLocateFormId (
LocateFormId (
IN EFI_HII_HANDLE Handle,
IN EFI_FORM_LABEL Label,
OUT EFI_GUID *FormsetGuid,
@ -419,7 +443,7 @@ ThunkLocateFormId (
}
for (Index = 0; ; Index++) {
Status = GetPackageDataFromPackageList (HiiPackageList, Index, &PackageLength, &Package);
Status = GetPackageData (HiiPackageList, Index, &PackageLength, &Package);
if (!EFI_ERROR (Status)) {
CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
if (PackageHeader.Type == EFI_HII_PACKAGE_FORM) {
@ -439,77 +463,87 @@ Done:
return Status;
}
EFI_STATUS
EFIAPI
HiiUpdateForm (
IN EFI_HII_PROTOCOL *This,
IN FRAMEWORK_EFI_HII_HANDLE Handle,
IN EFI_FORM_LABEL Label,
IN BOOLEAN AddData,
IN FRAMEWORK_EFI_HII_UPDATE_DATA *Data
)
/*++
Routine Description:
/**
This function allows the caller to update a form that has
previously been registered with the EFI HII database.
Arguments:
Handle - Hii Handle associated with the Formset to modify
Label - Update information starting immediately after this label in the IFR
AddData - If TRUE, add data. If FALSE, remove data
Data - If adding data, this is the pointer to the data to add
Returns:
EFI_SUCCESS - Update success.
Other - Update fail.
@param This EDES_TODO: Add parameter description
@param Handle Hii Handle associated with the Formset to modify
@param Label Update information starting immediately after this label in the IFR
@param AddData If TRUE, add data. If FALSE, remove data
@param Data If adding data, this is the pointer to the data to add
--*/
@retval EFI_SUCCESS Update success.
@retval Other Update fail.
**/
EFI_STATUS
EFIAPI
HiiUpdateForm (
IN EFI_HII_PROTOCOL *This,
IN FRAMEWORK_EFI_HII_HANDLE Handle,
IN EFI_FORM_LABEL Label,
IN BOOLEAN AddData,
IN FRAMEWORK_EFI_HII_UPDATE_DATA *Data
)
{
EFI_STATUS Status;
EFI_HII_THUNK_PRIVATE_DATA *Private;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
HII_THUNK_PRIVATE_DATA *Private;
HII_THUNK_CONTEXT *ThunkContext;
EFI_HII_UPDATE_DATA *UefiHiiUpdateData;
EFI_HII_HANDLE UefiHiiHandle;
EFI_GUID FormsetGuid;
EFI_FORM_ID FormId;
EFI_TPL OldTpl;
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
mInFrameworkUpdatePakcage = TRUE;
Status = EFI_SUCCESS;
UefiHiiUpdateData = NULL;
Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
HandleMapEntry = FrameworkHiiHandleToMapDatabaseEntry (Private, Handle);
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
if (HandleMapEntry == NULL) {
return EFI_NOT_FOUND;
ThunkContext = FwHiiHandleToThunkContext (Private, Handle);
if (ThunkContext == NULL) {
Status = EFI_NOT_FOUND;
goto Done;
}
if (Data->FormSetUpdate) {
Status = ThunkUpdateFormCallBack ((EFI_HANDLE) (UINTN) Data->FormCallbackHandle, HandleMapEntry);
Status = UpdateFormCallBack ((EFI_HANDLE) (UINTN) Data->FormCallbackHandle, ThunkContext);
if (EFI_ERROR (Status)) {
return Status;
goto Done;
}
}
if (HandleMapEntry->IsPackageListWithOnlyStringPackages) {
UefiHiiHandle = TagGuidToUefiIfrHiiHandle (Private, &HandleMapEntry->TagGuid);
if ((ThunkContext->IfrPackageCount == 0) && (ThunkContext->StringPackageCount != 0)) {
UefiHiiHandle = TagGuidToUefiHiiHandle (Private, &ThunkContext->TagGuid);
if (UefiHiiHandle == NULL) {
return EFI_INVALID_PARAMETER;
Status = EFI_INVALID_PARAMETER;
goto Done;
}
} else {
UefiHiiHandle = HandleMapEntry->UefiHiiHandle;
UefiHiiHandle = ThunkContext->UefiHiiHandle;
}
UefiHiiUpdateData = NULL;
Status = LocateFormId (UefiHiiHandle, Label, &FormsetGuid, &FormId);
if (EFI_ERROR (Status)) {
//
// Can't find the label.
//
goto Done;
}
if (AddData) {
if (Data->DataCount != 0) {
Status = ThunkFrameworkUpdateDataToUefiUpdateData (Data, AddData, &UefiHiiUpdateData);
ASSERT_EFI_ERROR (Status);
Status = ThunkLocateFormId (UefiHiiHandle, Label, &FormsetGuid, &FormId);
ThunkContext = UefiHiiHandleToThunkContext (Private, UefiHiiHandle);
Status = FwUpdateDataToUefiUpdateData (ThunkContext, Data, AddData, &UefiHiiUpdateData);
ASSERT_EFI_ERROR (Status);
Status = IfrLibUpdateForm (UefiHiiHandle, &FormsetGuid, FormId, Label, AddData, UefiHiiUpdateData);
@ -517,9 +551,6 @@ Returns:
}
} else {
Status = ThunkLocateFormId (UefiHiiHandle, Label, &FormsetGuid, &FormId);
ASSERT_EFI_ERROR (Status);
//
// Delete Opcode starting from Labe in FormId found
//
@ -529,10 +560,15 @@ Returns:
ASSERT_EFI_ERROR (Status);
}
Done:
if (UefiHiiUpdateData != NULL) {
SafeFreePool (UefiHiiUpdateData->Data);
SafeFreePool (UefiHiiUpdateData);
}
mInFrameworkUpdatePakcage = FALSE;
gBS->RestoreTPL (OldTpl);
return Status;
}

View File

@ -37,6 +37,8 @@
#
[Sources.common]
ConfigAccess.c
ConfigAccess.h
OpcodeCreation.c
OpcodeCreation.h
UefiIfrParserInternal.h
@ -55,10 +57,10 @@
Forms.c
HiiDatabase.h
HiiDatabase.c
ConfigAccess.c
ConfigAccess.h
Utility.c
Utility.h
SetupBrowser.c
[Packages]
@ -93,10 +95,8 @@
gEfiFormBrowserProtocolGuid
[Depex]
gEfiHiiImageProtocolGuid AND
gEfiHiiDatabaseProtocolGuid AND
gEfiHiiStringProtocolGuid AND
gEfiHiiFontProtocolGuid AND
gEfiHiiConfigRoutingProtocolGuid

View File

@ -15,16 +15,12 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "HiiDatabase.h"
EFI_HII_THUNK_PRIVATE_DATA *mHiiThunkPrivateData;
HII_THUNK_PRIVATE_DATA *mHiiThunkPrivateData;
EFI_HII_THUNK_PRIVATE_DATA mHiiThunkPrivateDataTempate = {
//Signature
EFI_HII_THUNK_DRIVER_DATA_SIGNATURE
,
//Handle
(EFI_HANDLE) NULL
,
{ //Hii
HII_THUNK_PRIVATE_DATA mHiiThunkPrivateDataTempate = {
HII_THUNK_PRIVATE_DATA_SIGNATURE,
(EFI_HANDLE) NULL,
{
HiiNewPack,
HiiRemovePack,
HiiFindHandles,
@ -46,18 +42,21 @@ EFI_HII_THUNK_PRIVATE_DATA mHiiThunkPrivateDataTempate = {
HiiGetKeyboardLayout
},
//
//StaticHiiHandle
//The FRAMEWORK_EFI_HII_HANDLE starts from 1
// and increase upwords untill reach the value of StaticPureUefiHiiHandle.
// The code will assert to prevent overflow.
(FRAMEWORK_EFI_HII_HANDLE) 1
,
(FRAMEWORK_EFI_HII_HANDLE) 1,
//
//StaticPureUefiHiiHandle
//The Static FRAMEWORK_EFI_HII_HANDLE starts from 0xFFFF
// and decrease downwords untill reach the value of StaticHiiHandle.
// The code will assert to prevent overflow.
(FRAMEWORK_EFI_HII_HANDLE) 0xFFFF
,
//
(FRAMEWORK_EFI_HII_HANDLE) 0xFFFF,
{
NULL, NULL //HiiHandleLinkList
},
@ -66,6 +65,7 @@ EFI_HII_THUNK_PRIVATE_DATA mHiiThunkPrivateDataTempate = {
EFI_FORMBROWSER_THUNK_PRIVATE_DATA mBrowserThunkPrivateDataTemplate = {
EFI_FORMBROWSER_THUNK_PRIVATE_DATA_SIGNATURE,
(EFI_HANDLE) NULL,
(HII_THUNK_PRIVATE_DATA *) NULL,
{
ThunkSendForm,
ThunkCreatePopUp
@ -74,276 +74,15 @@ EFI_FORMBROWSER_THUNK_PRIVATE_DATA mBrowserThunkPrivateDataTemplate = {
CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
CONST EFI_HII_FONT_PROTOCOL *mHiiFontProtocol;
CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol;
CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol;
CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol;
EFI_STATUS
RegisterUefiHiiHandle (
EFI_HII_THUNK_PRIVATE_DATA *Private,
EFI_HII_HANDLE UefiHiiHandle
)
{
EFI_STATUS Status;
EFI_GUID PackageGuid;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMappingEntry;
HandleMappingEntry = AllocateZeroPool (sizeof (*HandleMappingEntry));
HandleMappingEntry->Signature = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_SIGNATURE;
Status = AssignPureUefiHiiHandle (Private, &HandleMappingEntry->FrameworkHiiHandle);
if (EFI_ERROR (Status)) {
return Status;
}
HandleMappingEntry->UefiHiiHandle = UefiHiiHandle;
Status = HiiLibExtractGuidFromHiiHandle (UefiHiiHandle, &PackageGuid);
ASSERT_EFI_ERROR (Status);
CopyGuid(&HandleMappingEntry->TagGuid, &PackageGuid);
InsertTailList (&Private->HiiThunkHandleMappingDBListHead, &HandleMappingEntry->List);
return EFI_SUCCESS;
}
CONST EFI_FORM_BROWSER2_PROTOCOL *mFormBrowser2Protocol;
EFI_STATUS
UnRegisterUefiHiiHandle (
EFI_HII_THUNK_PRIVATE_DATA *Private,
EFI_HII_HANDLE UefiHiiHandle
)
{
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *MapEntry;
MapEntry = UefiHiiHandleToMapDatabaseEntry (Private, UefiHiiHandle);
ASSERT (MapEntry != NULL);
RemoveEntryList (&MapEntry->List);
FreePool (MapEntry);
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
AddPackNotify (
IN UINT8 PackageType,
IN CONST EFI_GUID *PackageGuid,
IN CONST EFI_HII_PACKAGE_HEADER *Package,
IN EFI_HII_HANDLE Handle,
IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
)
{
EFI_STATUS Status;
EFI_HII_THUNK_PRIVATE_DATA *Private;
ASSERT (PackageType == EFI_HII_PACKAGE_STRINGS);
ASSERT (NotifyType == EFI_HII_DATABASE_NOTIFY_ADD_PACK);
Status = EFI_SUCCESS;
Private = mHiiThunkPrivateData;
if (mInFrameworkHiiNewPack) {
return EFI_SUCCESS;
}
//
// We only create a MapEntry if the Uefi Hii Handle is only already registered
// by the HII Thunk Layer.
//
if (UefiHiiHandleToMapDatabaseEntry (Private, Handle) == NULL) {
Status = RegisterUefiHiiHandle (Private, Handle);
}
return Status;
}
EFI_STATUS
EFIAPI
NewPackNotify (
IN UINT8 PackageType,
IN CONST EFI_GUID *PackageGuid,
IN CONST EFI_HII_PACKAGE_HEADER *Package,
IN EFI_HII_HANDLE Handle,
IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
)
{
EFI_STATUS Status;
EFI_HII_THUNK_PRIVATE_DATA *Private;
ASSERT (PackageType == EFI_HII_PACKAGE_STRINGS);
ASSERT (NotifyType == EFI_HII_DATABASE_NOTIFY_NEW_PACK);
if (mInFrameworkHiiNewPack) {
return EFI_SUCCESS;
}
Status = EFI_SUCCESS;
Private = mHiiThunkPrivateData;
//
// We only
//
if (UefiHiiHandleToMapDatabaseEntry (Private, Handle) == NULL) {
Status = RegisterUefiHiiHandle (Private, Handle);
}
return Status;
}
BOOLEAN
IsLastStringPack (
IN CONST EFI_HII_PACKAGE_HEADER *Package,
IN EFI_HII_HANDLE Handle
)
{
EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
UINTN BufferSize;
EFI_STATUS Status;
EFI_HII_PACKAGE_HEADER *PackageHdrPtr;
EFI_HII_PACKAGE_HEADER PackageHeader;
BOOLEAN Match;
Match = FALSE;
HiiPackageList = NULL;
BufferSize = 0;
Status = mHiiDatabase->ExportPackageLists (mHiiDatabase, Handle, &BufferSize, HiiPackageList);
ASSERT (Status != EFI_NOT_FOUND);
if (Status == EFI_BUFFER_TOO_SMALL) {
HiiPackageList = AllocateZeroPool (BufferSize);
ASSERT (HiiPackageList != NULL);
Status = mHiiDatabase->ExportPackageLists (mHiiDatabase, Handle, &BufferSize, HiiPackageList);
}
PackageHdrPtr = (EFI_HII_PACKAGE_HEADER *) ((UINT8 *) HiiPackageList + sizeof (EFI_HII_PACKAGE_LIST_HEADER));
CopyMem (&PackageHeader, PackageHdrPtr, sizeof (EFI_HII_PACKAGE_HEADER));
Status = EFI_SUCCESS;
while (PackageHeader.Type != EFI_HII_PACKAGE_END) {
switch (PackageHeader.Type) {
case EFI_HII_PACKAGE_STRINGS:
if (CompareMem (Package, PackageHdrPtr, Package->Length) != 0) {
FreePool (HiiPackageList);
return FALSE;
}
break;
default:
break;
}
//
// goto header of next package
//
PackageHdrPtr = (EFI_HII_PACKAGE_HEADER *) ((UINT8 *) PackageHdrPtr + PackageHeader.Length);
CopyMem (&PackageHeader, PackageHdrPtr, sizeof (EFI_HII_PACKAGE_HEADER));
}
FreePool (HiiPackageList);
return TRUE;
}
EFI_STATUS
EFIAPI
RemovePackNotify (
IN UINT8 PackageType,
IN CONST EFI_GUID *PackageGuid,
IN CONST EFI_HII_PACKAGE_HEADER *Package,
IN EFI_HII_HANDLE Handle,
IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
)
{
EFI_STATUS Status;
EFI_HII_THUNK_PRIVATE_DATA *Private;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY * MapEntry;
Status = EFI_SUCCESS;
ASSERT (PackageType == EFI_HII_PACKAGE_STRINGS);
ASSERT (NotifyType == EFI_HII_DATABASE_NOTIFY_REMOVE_PACK);
if (mInFrameworkHiiRemovePack) {
return EFI_SUCCESS;
}
Private = mHiiThunkPrivateData;
MapEntry = UefiHiiHandleToMapDatabaseEntry (Private, Handle);
if (MapEntry->FrameworkHiiHandle > Private->StaticHiiHandle) {
//
// This is a PackageList registered using UEFI HII Protocol Instance.
// The MapEntry->TagGuid for this type of PackageList is a auto generated GUID
// to link StringPack with IfrPack.
// RemovePackNotify is only used to remove PackageList when it is removed by
// calling mHiiDatabase->RemovePackageList interface.
if (IsLastStringPack (Package, Handle)) {
Status = UnRegisterUefiHiiHandle (Private, Handle);
}
}
return Status;
}
EFI_STATUS
EFIAPI
MapUefiHiiHandles (
EFI_HII_THUNK_PRIVATE_DATA *Private
)
{
UINTN HandleBufferLength;
EFI_HII_HANDLE *HandleBuffer;
EFI_STATUS Status;
UINTN Index;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY * MapEntry;
HandleBufferLength = 0;
HandleBuffer = NULL;
Status = mHiiDatabase->ListPackageLists (
mHiiDatabase,
EFI_HII_PACKAGE_TYPE_ALL,
NULL,
&HandleBufferLength,
HandleBuffer
);
if (EFI_ERROR (Status) && (Status != EFI_BUFFER_TOO_SMALL)) {
//
// As no package is registered to UEFI HII Database, EFI_SUCCESS is returned.
//
//
if (Status == EFI_NOT_FOUND) {
return EFI_SUCCESS;
} else {
return Status;
}
}
HandleBuffer = AllocateZeroPool (HandleBufferLength);
Status = mHiiDatabase->ListPackageLists (
mHiiDatabase,
EFI_HII_PACKAGE_TYPE_ALL,
NULL,
&HandleBufferLength,
HandleBuffer
);
for (Index = 0; Index < HandleBufferLength / sizeof (EFI_HII_HANDLE); Index++) {
MapEntry = UefiHiiHandleToMapDatabaseEntry (Private, HandleBuffer[Index]);
//
// Only register those UEFI HII Handles that are registered using the UEFI HII database interface.
//
if (MapEntry == NULL) {
Status = RegisterUefiHiiHandle (Private, HandleBuffer[Index]);
ASSERT_EFI_ERROR (Status);
}
}
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
@ -365,17 +104,21 @@ Returns:
--*/
{
EFI_HII_THUNK_PRIVATE_DATA *HiiData;
EFI_HANDLE Handle;
EFI_STATUS Status;
HII_THUNK_PRIVATE_DATA *Private;
EFI_HANDLE Handle;
EFI_STATUS Status;
UINTN BufferLength;
EFI_HII_HANDLE *Buffer;
UINTN Index;
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiProtocolGuid);
HiiData = AllocateCopyPool (sizeof (EFI_HII_THUNK_PRIVATE_DATA), &mHiiThunkPrivateDataTempate);
ASSERT (HiiData != NULL);
InitializeListHead (&HiiData->HiiThunkHandleMappingDBListHead);
Private = AllocateCopyPool (sizeof (HII_THUNK_PRIVATE_DATA), &mHiiThunkPrivateDataTempate);
ASSERT (Private != NULL);
InitializeListHead (&Private->ThunkContextListHead);
mHiiThunkPrivateData = HiiData;
mHiiThunkPrivateData = Private;
Status = gBS->LocateProtocol (
&gEfiHiiDatabaseProtocolGuid,
@ -384,20 +127,6 @@ Returns:
);
ASSERT_EFI_ERROR (Status);
Status = gBS->LocateProtocol (
&gEfiHiiFontProtocolGuid,
NULL,
(VOID **) &mHiiFontProtocol
);
ASSERT_EFI_ERROR (Status);
Status = gBS->LocateProtocol (
&gEfiHiiImageProtocolGuid,
NULL,
(VOID **) &mHiiImageProtocol
);
ASSERT_EFI_ERROR (Status);
Status = gBS->LocateProtocol (
&gEfiHiiStringProtocolGuid,
NULL,
@ -412,28 +141,45 @@ Returns:
);
ASSERT_EFI_ERROR (Status);
//
// Install protocol interface
//
Handle = NULL;
Status = gBS->InstallProtocolInterface (
&HiiData->Handle,
&gEfiHiiProtocolGuid,
EFI_NATIVE_INTERFACE,
(VOID *) &HiiData->Hii
Status = gBS->LocateProtocol (
&gEfiFormBrowser2ProtocolGuid,
NULL,
(VOID **) &mFormBrowser2Protocol
);
ASSERT_EFI_ERROR (Status);
Status = MapUefiHiiHandles (HiiData);
//
// Install protocol interface
//
Status = gBS->InstallProtocolInterface (
&Private->Handle,
&gEfiHiiProtocolGuid,
EFI_NATIVE_INTERFACE,
(VOID *) &Private->Hii
);
ASSERT_EFI_ERROR (Status);
Status = HiiLibListPackageLists (EFI_HII_PACKAGE_STRINGS, NULL, &BufferLength, &Buffer);
if (Status == EFI_SUCCESS) {
for (Index = 0; Index < BufferLength / sizeof (EFI_HII_HANDLE); Index++) {
CreateThunkContextForUefiHiiHandle (Private, Buffer[Index]);
ASSERT_EFI_ERROR (Status);
}
FreePool (Buffer);
}
Status = mHiiDatabase->RegisterPackageNotify (
mHiiDatabase,
EFI_HII_PACKAGE_STRINGS,
NULL,
NewPackNotify,
NewOrAddPackNotify,
EFI_HII_DATABASE_NOTIFY_NEW_PACK,
&HiiData->NewPackNotifyHandle
&Handle
);
ASSERT_EFI_ERROR (Status);
@ -441,9 +187,29 @@ Returns:
mHiiDatabase,
EFI_HII_PACKAGE_STRINGS,
NULL,
AddPackNotify,
NewOrAddPackNotify,
EFI_HII_DATABASE_NOTIFY_ADD_PACK,
&HiiData->AddPackNotifyHandle
&Handle
);
ASSERT_EFI_ERROR (Status);
Status = mHiiDatabase->RegisterPackageNotify (
mHiiDatabase,
EFI_HII_PACKAGE_FORM,
NULL,
NewOrAddPackNotify,
EFI_HII_DATABASE_NOTIFY_NEW_PACK,
&Handle
);
ASSERT_EFI_ERROR (Status);
Status = mHiiDatabase->RegisterPackageNotify (
mHiiDatabase,
EFI_HII_PACKAGE_FORM,
NULL,
NewOrAddPackNotify,
EFI_HII_DATABASE_NOTIFY_ADD_PACK,
&Handle
);
ASSERT_EFI_ERROR (Status);
@ -453,10 +219,11 @@ Returns:
NULL,
RemovePackNotify,
EFI_HII_DATABASE_NOTIFY_REMOVE_PACK,
&HiiData->RemovePackNotifyHandle
&Handle
);
ASSERT_EFI_ERROR (Status);
mBrowserThunkPrivateDataTemplate.ThunkPrivate = Private;
Status = gBS->InstallProtocolInterface (
&mBrowserThunkPrivateDataTemplate.Handle,
&gEfiFormBrowserProtocolGuid,
@ -487,22 +254,24 @@ Returns:
--*/
{
UINT16 Count;
LIST_ENTRY *ListEntry;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
EFI_HII_THUNK_PRIVATE_DATA *Private;
LIST_ENTRY *Link;
HII_THUNK_CONTEXT *ThunkContext;
HII_THUNK_PRIVATE_DATA *Private;
if (HandleBufferLength == NULL) {
return EFI_INVALID_PARAMETER;
}
Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
//
// Count the number of handles.
//
Count = 0;
for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;
ListEntry != &Private->HiiThunkHandleMappingDBListHead;
ListEntry = ListEntry->ForwardLink
) {
Link = GetFirstNode (&Private->ThunkContextListHead);
while (!IsNull (&Private->ThunkContextListHead, Link)) {
Count++;
Link = GetNextNode (&Private->ThunkContextListHead, Link);
}
if (Count > *HandleBufferLength) {
@ -510,22 +279,71 @@ Returns:
return EFI_BUFFER_TOO_SMALL;
}
//
// Output the handles.
//
Count = 0;
for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;
ListEntry != &Private->HiiThunkHandleMappingDBListHead;
ListEntry = ListEntry->ForwardLink
) {
HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry);
Link = GetFirstNode (&Private->ThunkContextListHead);
while (!IsNull (&Private->ThunkContextListHead, Link)) {
ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
Handle[Count] = ThunkContext->FwHiiHandle;
Handle[Count] = HandleMapEntry->FrameworkHiiHandle;
Count++;
}
Link = GetNextNode (&Private->ThunkContextListHead, Link);
}
*HandleBufferLength = (Count * sizeof (FRAMEWORK_EFI_HII_HANDLE));
return EFI_SUCCESS;
}
EFI_STATUS
LangCodes3066To639 (
IN CHAR8 *LangCodes3066,
IN CHAR8 **LangCodes639
)
{
CHAR8 *AsciiLangCodes;
CHAR8 Lang[RFC_3066_ENTRY_SIZE];
UINTN Index;
UINTN Count;
EFI_STATUS Status;
ASSERT (LangCodes3066 != NULL);
ASSERT (LangCodes639 != NULL);
//
// Count the number of RFC 3066 language codes.
//
Index = 0;
AsciiLangCodes = LangCodes3066;
while (AsciiStrLen (AsciiLangCodes) != 0) {
HiiLibGetNextLanguage (&AsciiLangCodes, Lang);
Index++;
}
Count = Index;
//
//
//
*LangCodes639 = AllocateZeroPool (ISO_639_2_ENTRY_SIZE * Count + 1);
if (*LangCodes639 == NULL) {
return EFI_OUT_OF_RESOURCES;
}
AsciiLangCodes = LangCodes3066;
for (Index = 0; Index < Count; Index++) {
HiiLibGetNextLanguage (&AsciiLangCodes, Lang);
Status = ConvertRfc3066LanguageToIso639Language (Lang, *LangCodes639 + Index * ISO_639_2_ENTRY_SIZE);
ASSERT_EFI_ERROR (Status);
}
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
HiiGetPrimaryLanguages (
@ -545,46 +363,61 @@ Returns:
--*/
{
EFI_HII_THUNK_PRIVATE_DATA *Private;
HII_THUNK_PRIVATE_DATA *Private;
EFI_HII_HANDLE UefiHiiHandle;
CHAR8 *AsciiLanguageCodes;
CHAR16 *UnicodeLanguageCodes;
CHAR8 *LangCodes3066;
CHAR16 *UnicodeLangCodes639;
CHAR8 *LangCodes639;
EFI_STATUS Status;
Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
UefiHiiHandle = FrameworkHiiHandleToUefiHiiHandle (Private, Handle);
UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);
if (UefiHiiHandle == NULL) {
return EFI_INVALID_PARAMETER;
}
AsciiLanguageCodes = HiiLibGetSupportedLanguages (UefiHiiHandle);
LangCodes3066 = HiiLibGetSupportedLanguages (UefiHiiHandle);
if (AsciiLanguageCodes == NULL) {
if (LangCodes3066 == NULL) {
return EFI_INVALID_PARAMETER;
}
UnicodeLanguageCodes = AllocateZeroPool (AsciiStrSize (AsciiLanguageCodes) * sizeof (CHAR16));
if (UnicodeLanguageCodes == NULL) {
return EFI_OUT_OF_RESOURCES;
LangCodes639 = NULL;
Status = LangCodes3066To639 (LangCodes3066, &LangCodes639);
if (EFI_ERROR (Status)) {
goto Done;
}
UnicodeLangCodes639 = AllocateZeroPool (AsciiStrSize (LangCodes639) * sizeof (CHAR16));
if (UnicodeLangCodes639 == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
//
// The language returned is in RFC 3066 format.
// The language returned is in RFC 639-2 format.
//
*LanguageString = AsciiStrToUnicodeStr (AsciiLanguageCodes, UnicodeLanguageCodes);
AsciiStrToUnicodeStr (LangCodes639, UnicodeLangCodes639);
*LanguageString = UnicodeLangCodes639;
return EFI_SUCCESS;
Done:
FreePool (LangCodes3066);
SafeFreePool (LangCodes639);
return Status;
}
EFI_STATUS
EFIAPI
HiiGetSecondaryLanguages (
IN EFI_HII_PROTOCOL *This,
IN FRAMEWORK_EFI_HII_HANDLE Handle,
IN CHAR16 *PrimaryLanguage,
OUT EFI_STRING *LanguageString
IN EFI_HII_PROTOCOL *This,
IN FRAMEWORK_EFI_HII_HANDLE Handle,
IN CHAR16 *PrimaryLanguage,
OUT EFI_STRING *LanguageString
)
/*++
@ -599,75 +432,68 @@ Returns:
--*/
{
EFI_HII_THUNK_PRIVATE_DATA *Private;
HII_THUNK_PRIVATE_DATA *Private;
EFI_HII_HANDLE UefiHiiHandle;
CHAR8 *AsciiPrimaryLanguage;
CHAR8 *AsciiLanguageCodes;
CHAR16 *UnicodeLanguageCodes;
CHAR8 PrimaryLang3066[RFC_3066_ENTRY_SIZE];
CHAR8 *PrimaryLang639;
CHAR8 *SecLangCodes3066;
CHAR8 *SecLangCodes639;
CHAR16 *UnicodeSecLangCodes639;
EFI_STATUS Status;
Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
UefiHiiHandle = FrameworkHiiHandleToUefiHiiHandle (Private, Handle);
SecLangCodes639 = NULL;
SecLangCodes3066 = NULL;
UnicodeSecLangCodes639 = NULL;
UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);
if (UefiHiiHandle == NULL) {
return EFI_INVALID_PARAMETER;
}
AsciiPrimaryLanguage = AllocateZeroPool (StrLen (PrimaryLanguage) + 1);
UnicodeStrToAsciiStr (PrimaryLanguage, AsciiPrimaryLanguage);
AsciiLanguageCodes = HiiLibGetSupportedSecondaryLanguages (UefiHiiHandle, AsciiPrimaryLanguage);
if (AsciiLanguageCodes == NULL) {
return EFI_INVALID_PARAMETER;
PrimaryLang639 = AllocateZeroPool (StrLen (PrimaryLanguage) + 1);
if (PrimaryLang639 == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
UnicodeLanguageCodes = AllocateZeroPool (AsciiStrSize (AsciiLanguageCodes) * sizeof (CHAR16));
if (UnicodeLanguageCodes == NULL) {
return EFI_OUT_OF_RESOURCES;
UnicodeStrToAsciiStr (PrimaryLanguage, PrimaryLang639);
Status = ConvertIso639LanguageToRfc3066Language (PrimaryLang639, PrimaryLang3066);
ASSERT_EFI_ERROR (Status);
SecLangCodes3066 = HiiLibGetSupportedSecondaryLanguages (UefiHiiHandle, PrimaryLang3066);
if (SecLangCodes3066 == NULL) {
Status = EFI_INVALID_PARAMETER;
goto Done;
}
Status = LangCodes3066To639 (SecLangCodes3066, &SecLangCodes639);
if (EFI_ERROR (Status)) {
goto Done;
}
UnicodeSecLangCodes639 = AllocateZeroPool (AsciiStrSize (SecLangCodes639) * sizeof (CHAR16));
if (UnicodeSecLangCodes639 == NULL) {
Status = EFI_OUT_OF_RESOURCES;
goto Done;
}
//
// The language returned is in RFC 3066 format.
//
*LanguageString = AsciiStrToUnicodeStr (AsciiLanguageCodes, UnicodeLanguageCodes);
*LanguageString = AsciiStrToUnicodeStr (SecLangCodes639, UnicodeSecLangCodes639);
return EFI_SUCCESS;
}
EFI_STATUS
EFIAPI
ThunkSendForm (
IN EFI_FORM_BROWSER_PROTOCOL *This,
IN BOOLEAN UseDatabase,
IN FRAMEWORK_EFI_HII_HANDLE *Handle,
IN UINTN HandleCount,
IN FRAMEWORK_EFI_IFR_PACKET *Packet, OPTIONAL
IN EFI_HANDLE CallbackHandle, OPTIONAL
IN UINT8 *NvMapOverride, OPTIONAL
IN FRAMEWORK_EFI_SCREEN_DESCRIPTOR *ScreenDimensions, OPTIONAL
OUT BOOLEAN *ResetRequired OPTIONAL
)
{
ASSERT (FALSE);
return EFI_UNSUPPORTED;
}
EFI_STATUS
EFIAPI
ThunkCreatePopUp (
IN UINTN NumberOfLines,
IN BOOLEAN HotKey,
IN UINTN MaximumStringSize,
OUT CHAR16 *StringBuffer,
OUT EFI_INPUT_KEY *KeyValue,
IN CHAR16 *String,
...
)
{
ASSERT (FALSE);
return EFI_UNSUPPORTED;
Done:
SafeFreePool (PrimaryLang639);
SafeFreePool (SecLangCodes639);
SafeFreePool (SecLangCodes3066);
SafeFreePool (UnicodeSecLangCodes639);
return Status;
}

View File

@ -43,7 +43,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <Library/BaseMemoryLib.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/UefiRuntimeServicesTableLib.h>
//#include <Library/FrameworkIfrSupportLib.h>
#include <Library/HiiLib.h>
#include <Library/ExtendedHiiLib.h>
@ -52,15 +51,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <MdeModuleHii.h>
//
// Macros
//
//
// Typedef
//
#pragma pack (push, 1)
typedef struct {
UINT32 BinaryLength;
@ -68,8 +58,8 @@ typedef struct {
} TIANO_AUTOGEN_PACKAGES_HEADER;
#pragma pack (pop)
#define EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(Record) CR(Record, EFI_HII_THUNK_PRIVATE_DATA, Hii, EFI_HII_THUNK_DRIVER_DATA_SIGNATURE)
#define EFI_HII_THUNK_DRIVER_DATA_SIGNATURE EFI_SIGNATURE_32 ('H', 'i', 'I', 'T')
#define HII_THUNK_PRIVATE_DATA_FROM_THIS(Record) CR(Record, HII_THUNK_PRIVATE_DATA, Hii, HII_THUNK_PRIVATE_DATA_SIGNATURE)
#define HII_THUNK_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('H', 'i', 'I', 'T')
typedef struct {
UINTN Signature;
EFI_HANDLE Handle;
@ -78,75 +68,139 @@ typedef struct {
FRAMEWORK_EFI_HII_HANDLE StaticPureUefiHiiHandle;
//
// This LIST_ENTRY is the list head which has HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY type
// as list entry.
// The head of link list for all HII_THUNK_CONTEXT.
//
LIST_ENTRY HiiThunkHandleMappingDBListHead;
LIST_ENTRY ThunkContextListHead;
EFI_HANDLE NewPackNotifyHandle;
EFI_HANDLE RemovePackNotifyHandle;
EFI_HANDLE AddPackNotifyHandle;
} EFI_HII_THUNK_PRIVATE_DATA;
} HII_THUNK_PRIVATE_DATA;
#define HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY(Record) CR(Record, HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY, List, HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_SIGNATURE)
#define HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_SIGNATURE EFI_SIGNATURE_32 ('H', 'T', 'H', 'M')
#define ONE_OF_OPTION_MAP_ENTRY_FROM_LINK(Record) CR(Record, ONE_OF_OPTION_MAP_ENTRY, Link, ONE_OF_OPTION_MAP_ENTRY_SIGNATURE)
#define ONE_OF_OPTION_MAP_ENTRY_SIGNATURE EFI_SIGNATURE_32 ('O', 'O', 'M', 'E')
typedef struct {
LIST_ENTRY List;
UINT32 Signature;
LIST_ENTRY Link;
UINT16 FwKey;
EFI_IFR_TYPE_VALUE Value;
} ONE_OF_OPTION_MAP_ENTRY;
#define ONE_OF_OPTION_MAP_FROM_LINK(Record) CR(Record, ONE_OF_OPTION_MAP, Link, ONE_OF_OPTION_MAP_SIGNATURE)
#define ONE_OF_OPTION_MAP_SIGNATURE EFI_SIGNATURE_32 ('O', 'O', 'O', 'M')
typedef struct {
UINT32 Signature;
LIST_ENTRY Link;
UINT8 ValueType; //EFI_IFR_TYPE_NUM_*
EFI_QUESTION_ID QuestionId;
LIST_ENTRY OneOfOptionMapEntryListHead; //ONE_OF_OPTION_MAP_ENTRY
} ONE_OF_OPTION_MAP;
#define QUESTION_ID_MAP_ENTRY_FROM_LINK(Record) CR(Record, QUESTION_ID_MAP_ENTRY, Link, QUESTION_ID_MAP_ENTRY_SIGNATURE)
#define QUESTION_ID_MAP_ENTRY_SIGNATURE EFI_SIGNATURE_32 ('Q', 'I', 'M', 'E')
typedef struct {
UINT32 Signature;
LIST_ENTRY Link;
UINT16 FwQId;
EFI_QUESTION_ID UefiQid;
} QUESTION_ID_MAP_ENTRY;
#define QUESTION_ID_MAP_FROM_LINK(Record) CR(Record, QUESTION_ID_MAP, Link, QUESTION_ID_MAP_SIGNATURE)
#define QUESTION_ID_MAP_SIGNATURE EFI_SIGNATURE_32 ('Q', 'I', 'M', 'P')
typedef struct {
UINT32 Signature;
LIST_ENTRY Link;
UINT16 VarStoreId;
UINTN VarSize;
LIST_ENTRY MapEntryListHead;
} QUESTION_ID_MAP;
#define HII_THUNK_CONTEXT_FROM_LINK(Record) CR(Record, HII_THUNK_CONTEXT, Link, HII_THUNK_CONTEXT_SIGNATURE)
#define HII_THUNK_CONTEXT_SIGNATURE EFI_SIGNATURE_32 ('H', 'T', 'H', 'M')
typedef struct {
LIST_ENTRY Link;
UINT32 Signature;
FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle;
FRAMEWORK_EFI_HII_HANDLE FwHiiHandle;
EFI_HII_HANDLE UefiHiiHandle;
EFI_HANDLE UefiHiiDriverHandle;
BOOLEAN IsPackageListWithOnlyStringPackages;
UINTN IfrPackageCount;
UINTN StringPackageCount;
//
// The field below is only valid if IsPackageListWithOnlyStringPack is TRUE.
// The HII 0.92 version of HII data implementation in EDK 1.03 and 1.04 make an the following assumption
// in both HII Database implementation and all modules that registering packages:
// If a Package List has only IFR package and no String Package, the String Package containing the strings
// referenced by this IFR package is in another Package List
// registered with the HII database with the same EFI_HII_PACKAGES.GuidId.
//
//
// Only valid if IsPackageListWithSingleStringPack is TRUE.
// UEFI Package List Head Pointer, pointing to a allocated buffer containing the package
//
EFI_HII_PACKAGE_LIST_HEADER *UefiStringPackageListHeader; //Only valid if IsStringPack is TRUE.
//This UEFI Package list only consists of a list of string packages.
// If a Package List has only IFR package and no String Package, the IFR package will reference
// String in another Package List registered with the HII database with the same EFI_HII_PACKAGES.GuidId.
// TagGuid is the used to record this GuidId.
EFI_GUID TagGuid;
//
// TRUE if the package list identified by UefiHiiHandle imports String Packages from
// other package list with IsPackageListWithOnlyStringPackages is TRUE.
//
BOOLEAN DoesPackageListImportStringPackages;
} HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY;
#define HII_TRHUNK_BUFFER_STORAGE_KEY_SIGNATURE EFI_SIGNATURE_32 ('H', 'T', 's', 'k')
#define HII_TRHUNK_BUFFER_STORAGE_KEY_FROM_LIST_ENTRY(Record) CR(Record, HII_TRHUNK_BUFFER_STORAGE_KEY, List, HII_TRHUNK_BUFFER_STORAGE_KEY_SIGNATURE)
LIST_ENTRY QuestionIdMapListHead; //QUESTION_ID_MAP
LIST_ENTRY OneOfOptionMapListHead; //ONE_OF_OPTION_MAP
UINT8 *NvMapOverride;
UINT16 FormSetClass;
UINT16 FormSetSubClass;
STRING_REF FormSetTitle;
STRING_REF FormSetHelp;
} HII_THUNK_CONTEXT;
#define BUFFER_STORAGE_ENTRY_SIGNATURE EFI_SIGNATURE_32 ('H', 'T', 's', 'k')
#define BUFFER_STORAGE_ENTRY_FROM_LINK(Record) CR(Record, BUFFER_STORAGE_ENTRY, Link, BUFFER_STORAGE_ENTRY_SIGNATURE)
typedef struct {
LIST_ENTRY List;
LIST_ENTRY Link;
UINT32 Signature;
EFI_GUID Guid;
CHAR16 *Name;
UINTN Size;
UINT16 VarStoreId;
} HII_TRHUNK_BUFFER_STORAGE_KEY;
} BUFFER_STORAGE_ENTRY;
#define HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE_SIGNATURE EFI_SIGNATURE_32 ('H', 'T', 'c', 'a')
#define HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE_FROM_PROTOCOL(Record) CR(Record, HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE, ConfigAccessProtocol, HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE_SIGNATURE)
#define CONFIG_ACCESS_PRIVATE_SIGNATURE EFI_SIGNATURE_32 ('H', 'T', 'c', 'a')
#define CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL(Record) CR(Record, CONFIG_ACCESS_PRIVATE, ConfigAccessProtocol, CONFIG_ACCESS_PRIVATE_SIGNATURE)
typedef struct {
UINT32 Signature;
EFI_HII_CONFIG_ACCESS_PROTOCOL ConfigAccessProtocol;
EFI_FORM_CALLBACK_PROTOCOL *FrameworkFormCallbackProtocol;
LIST_ENTRY ConfigAccessBufferStorageListHead;
} HII_TRHUNK_CONFIG_ACCESS_PROTOCOL_INSTANCE;
//
// Framework's callback
//
EFI_FORM_CALLBACK_PROTOCOL *FormCallbackProtocol;
LIST_ENTRY BufferStorageListHead;
HII_THUNK_CONTEXT *ThunkContext;
} CONFIG_ACCESS_PRIVATE;
#define EFI_FORMBROWSER_THUNK_PRIVATE_DATA_SIGNATURE EFI_SIGNATURE_32 ('F', 'B', 'T', 'd')
#define EFI_FORMBROWSER_THUNK_PRIVATE_DATA_FROM_THIS(Record) CR(Record, EFI_FORMBROWSER_THUNK_PRIVATE_DATA, FormBrowser, EFI_FORMBROWSER_THUNK_PRIVATE_DATA_SIGNATURE)
typedef struct {
UINTN Signature;
EFI_HANDLE Handle;
HII_THUNK_PRIVATE_DATA *ThunkPrivate;
EFI_FORM_BROWSER_PROTOCOL FormBrowser;
} EFI_FORMBROWSER_THUNK_PRIVATE_DATA;
@ -155,13 +209,14 @@ typedef struct {
// Extern Variables
//
extern CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
extern CONST EFI_HII_FONT_PROTOCOL *mHiiFontProtocol;
extern CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol;
extern CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol;
extern CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol;
extern CONST EFI_FORM_BROWSER2_PROTOCOL *mFormBrowser2Protocol;
extern BOOLEAN mInFrameworkHiiNewPack;
extern BOOLEAN mInFrameworkHiiRemovePack;
extern HII_THUNK_PRIVATE_DATA *mHiiThunkPrivateData;
extern BOOLEAN mInFrameworkUpdatePakcage;
//
@ -392,6 +447,28 @@ ThunkCreatePopUp (
...
);
EFI_STATUS
EFIAPI
RemovePackNotify (
IN UINT8 PackageType,
IN CONST EFI_GUID *PackageGuid,
IN CONST EFI_HII_PACKAGE_HEADER *Package,
IN EFI_HII_HANDLE Handle,
IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
)
;
EFI_STATUS
EFIAPI
NewOrAddPackNotify (
IN UINT8 PackageType,
IN CONST EFI_GUID *PackageGuid,
IN CONST EFI_HII_PACKAGE_HEADER *Package,
IN EFI_HII_HANDLE Handle,
IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
)
;
#include "Utility.h"
#include "ConfigAccess.h"

View File

@ -44,6 +44,41 @@ AppendToUpdateBuffer (
return EFI_SUCCESS;
}
EFI_STATUS
FwQuestionIdToUefiQuestionId (
IN HII_THUNK_CONTEXT *ThunkContext,
IN UINT16 VarStoreId,
IN UINT16 FwId,
OUT EFI_QUESTION_ID *UefiQId
)
{
LIST_ENTRY *MapEntryListHead;
LIST_ENTRY *Link;
QUESTION_ID_MAP_ENTRY *MapEntry;
MapEntryListHead = GetMapEntryListHead (ThunkContext, VarStoreId);
ASSERT (MapEntryListHead != NULL);
Link = GetFirstNode (MapEntryListHead);
while (!IsNull (MapEntryListHead, Link)) {
MapEntry = QUESTION_ID_MAP_ENTRY_FROM_LINK (Link);
if (MapEntry->FwQId == FwId) {
*UefiQId = MapEntry->UefiQid;
return EFI_SUCCESS;
}
Link = GetNextNode (MapEntryListHead, Link);
}
return EFI_NOT_FOUND;
}
EFI_STATUS
UCreateEndOfOpcode (
OUT EFI_HII_UPDATE_DATA *UefiData
@ -83,19 +118,39 @@ F2UCreateTextOpCode (
OUT EFI_HII_UPDATE_DATA *UefiData
)
{
EFI_IFR_TEXT UOpcode;
EFI_IFR_TEXT UTextOpCode;
EFI_IFR_ACTION UActionOpCode;
ZeroMem (&UOpcode, sizeof(UOpcode));
UOpcode.Header.OpCode = EFI_IFR_TEXT_OP;
UOpcode.Header.Length = sizeof (EFI_IFR_TEXT);
if ((FwText->Flags & FRAMEWORK_EFI_IFR_FLAG_INTERACTIVE) == 0) {
ZeroMem (&UTextOpCode, sizeof(UTextOpCode));
UTextOpCode.Header.OpCode = EFI_IFR_TEXT_OP;
UTextOpCode.Header.Length = sizeof (EFI_IFR_TEXT);
UOpcode.Statement.Help = FwText->Help;
UTextOpCode.Statement.Help = FwText->Help;
UOpcode.Statement.Prompt = FwText->Text;
UOpcode.TextTwo = FwText->TextTwo;
return AppendToUpdateBuffer ((UINT8 *) &UOpcode, sizeof(UOpcode), UefiData);
UTextOpCode.Statement.Prompt = FwText->Text;
UTextOpCode.TextTwo = FwText->TextTwo;
return AppendToUpdateBuffer ((UINT8 *) &UTextOpCode, sizeof(UTextOpCode), UefiData);
} else {
//
// Iteractive Text Opcode is EFI_IFR_ACTION
//
ZeroMem (&UActionOpCode, sizeof (UActionOpCode));
UActionOpCode.Header.OpCode = EFI_IFR_ACTION_OP;
UActionOpCode.Header.Length = sizeof (EFI_IFR_ACTION);
UActionOpCode.Question.Header.Prompt = FwText->Text;
UActionOpCode.Question.Header.Help = FwText->Help;
UActionOpCode.Question.Flags = EFI_IFR_FLAG_CALLBACK;
UActionOpCode.Question.QuestionId = FwText->Key;
return AppendToUpdateBuffer ((UINT8 *) &UActionOpCode, sizeof(UActionOpCode), UefiData);
}
}
/*
@ -267,21 +322,26 @@ typedef struct {
EFI_STATUS
F2UCreateOneOfOpCode (
IN HII_THUNK_CONTEXT *ThunkContext,
IN UINT16 VarStoreId,
IN CONST FRAMEWORK_EFI_IFR_ONE_OF *FwOpcode,
OUT EFI_HII_UPDATE_DATA *UefiData,
OUT FRAMEWORK_EFI_IFR_OP_HEADER **NextFwOpcode,
OUT UINTN *DataCount
)
{
EFI_STATUS Status;
EFI_IFR_ONE_OF UOpcode;
FRAMEWORK_EFI_IFR_OP_HEADER *FwOpHeader;
FRAMEWORK_EFI_IFR_ONE_OF_OPTION *FwOneOfOp;
BOOLEAN HasQuestionId;
EFI_STATUS Status;
EFI_IFR_ONE_OF UOpcode;
FRAMEWORK_EFI_IFR_OP_HEADER *FwOpHeader;
FRAMEWORK_EFI_IFR_ONE_OF_OPTION *FwOneOfOp;
ONE_OF_OPTION_MAP *OneOfOptionMap;
ONE_OF_OPTION_MAP_ENTRY *OneOfOptionMapEntry;
ASSERT (NextFwOpcode != NULL);
ASSERT (DataCount != NULL);
OneOfOptionMap = NULL;
ZeroMem (&UOpcode, sizeof(UOpcode));
*DataCount = 0;
@ -292,29 +352,78 @@ F2UCreateOneOfOpCode (
UOpcode.Question.Header.Prompt = FwOpcode->Prompt;
UOpcode.Question.Header.Help = FwOpcode->Help;
Status = AppendToUpdateBuffer ((UINT8 *) &UOpcode, sizeof(UOpcode), UefiData);
if (EFI_ERROR (Status)) {
return Status;
}
*DataCount += 1;
//
// Go over the Framework IFR binary to get the QuestionId for generated UEFI One Of Option opcode
//
HasQuestionId = FALSE;
FwOpHeader = (FRAMEWORK_EFI_IFR_OP_HEADER *) ((UINT8 *) FwOpcode + FwOpcode->Header.Length);
while (FwOpHeader->OpCode != FRAMEWORK_EFI_IFR_END_ONE_OF_OP) {
ASSERT (FwOpHeader->OpCode == FRAMEWORK_EFI_IFR_ONE_OF_OPTION_OP);
FwOneOfOp = (FRAMEWORK_EFI_IFR_ONE_OF_OPTION *) FwOpHeader;
if (((FwOneOfOp->Key & FRAMEWORK_EFI_IFR_FLAG_INTERACTIVE) == 0) & !HasQuestionId) {
HasQuestionId = TRUE;
UOpcode.Question.QuestionId = FwOneOfOp->Key;
if ((FwOneOfOp->Flags & FRAMEWORK_EFI_IFR_FLAG_INTERACTIVE) != 0) {
UOpcode.Question.Flags |= EFI_IFR_FLAG_CALLBACK;
if (UOpcode.Question.QuestionId == 0) {
Status = FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
if (EFI_ERROR (Status)) {
UOpcode.Question.QuestionId = FwOneOfOp->Key;
}
OneOfOptionMap = AllocateZeroPool (sizeof (ONE_OF_OPTION_MAP));
ASSERT (OneOfOptionMap != NULL);
OneOfOptionMap->Signature = ONE_OF_OPTION_MAP_SIGNATURE;
OneOfOptionMap->QuestionId = UOpcode.Question.QuestionId;
InitializeListHead (&OneOfOptionMap->OneOfOptionMapEntryListHead);
switch (FwOpcode->Width) {
case 1:
OneOfOptionMap->ValueType = EFI_IFR_TYPE_NUM_SIZE_8;
break;
case 2:
OneOfOptionMap->ValueType = EFI_IFR_TYPE_NUM_SIZE_16;
default:
ASSERT (FALSE);
break;
}
InsertTailList (&ThunkContext->OneOfOptionMapListHead, &OneOfOptionMap->Link);
} else {
OneOfOptionMapEntry = AllocateZeroPool (sizeof (ONE_OF_OPTION_MAP_ENTRY));
ASSERT (OneOfOptionMapEntry != NULL);
OneOfOptionMapEntry->FwKey = FwOneOfOp->Key;
OneOfOptionMapEntry->Signature = ONE_OF_OPTION_MAP_ENTRY_SIGNATURE;
CopyMem (&OneOfOptionMapEntry->Value, &FwOneOfOp->Value, FwOpcode->Width);
ASSERT (OneOfOptionMap != NULL);
InsertTailList (&OneOfOptionMap->OneOfOptionMapEntryListHead, &OneOfOptionMapEntry->Link);
}
}
if (FwOneOfOp->Flags & FRAMEWORK_EFI_IFR_FLAG_RESET_REQUIRED) {
UOpcode.Question.Flags |= EFI_IFR_FLAG_RESET_REQUIRED;
}
FwOpHeader = (FRAMEWORK_EFI_IFR_OP_HEADER *) ((UINT8 *) FwOpHeader + FwOpHeader->Length);
}
if (UOpcode.Question.QuestionId == 0) {
//
// Assign QuestionId if still not assigned.
//
Status = FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
if (EFI_ERROR (Status)) {
UOpcode.Question.QuestionId = FwOpcode->QuestionId;
}
}
Status = AppendToUpdateBuffer ((UINT8 *) &UOpcode, sizeof (UOpcode), UefiData);
if (EFI_ERROR (Status)) {
return Status;
}
*DataCount += 1;
//
// Go over again the Framework IFR binary to build the UEFI One Of Option opcodes.
//
@ -367,6 +476,8 @@ typedef struct {
*/
EFI_STATUS
F2UCreateOrderedListOpCode (
IN HII_THUNK_CONTEXT *ThunkContext,
IN UINT16 VarStoreId,
IN CONST FRAMEWORK_EFI_IFR_ORDERED_LIST *FwOpcode,
OUT EFI_HII_UPDATE_DATA *UefiData,
OUT FRAMEWORK_EFI_IFR_OP_HEADER **NextFwOpcode,
@ -376,6 +487,7 @@ F2UCreateOrderedListOpCode (
EFI_IFR_ORDERED_LIST UOpcode;
EFI_STATUS Status;
FRAMEWORK_EFI_IFR_OP_HEADER *FwOpHeader;
FRAMEWORK_EFI_IFR_ONE_OF_OPTION *FwOneOfOp;
ZeroMem (&UOpcode, sizeof(UOpcode));
*DataCount = 0;
@ -386,8 +498,43 @@ F2UCreateOrderedListOpCode (
UOpcode.Question.Header.Prompt = FwOpcode->Prompt;
UOpcode.Question.Header.Help = FwOpcode->Help;
UOpcode.Question.VarStoreId = VarStoreId;
UOpcode.MaxContainers = FwOpcode->MaxEntries;
//
// Go over the Framework IFR binary to get the QuestionId for generated UEFI One Of Option opcode
//
FwOpHeader = (FRAMEWORK_EFI_IFR_OP_HEADER *) ((UINT8 *) FwOpcode + FwOpcode->Header.Length);
while (FwOpHeader->OpCode != FRAMEWORK_EFI_IFR_END_ONE_OF_OP) {
ASSERT (FwOpHeader->OpCode == FRAMEWORK_EFI_IFR_ONE_OF_OPTION_OP);
FwOneOfOp = (FRAMEWORK_EFI_IFR_ONE_OF_OPTION *) FwOpHeader;
if ((FwOneOfOp->Flags & FRAMEWORK_EFI_IFR_FLAG_INTERACTIVE) != 0) {
UOpcode.Question.Flags |= EFI_IFR_FLAG_CALLBACK;
if (UOpcode.Question.QuestionId == 0) {
Status = FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
if (EFI_ERROR (Status)) {
UOpcode.Question.QuestionId = FwOneOfOp->Key;
}
}
}
if (FwOneOfOp->Flags & FRAMEWORK_EFI_IFR_FLAG_RESET_REQUIRED) {
UOpcode.Question.Flags |= EFI_IFR_FLAG_RESET_REQUIRED;
}
FwOpHeader = (FRAMEWORK_EFI_IFR_OP_HEADER *) ((UINT8 *) FwOpHeader + FwOpHeader->Length);
}
if (UOpcode.Question.QuestionId == 0) {
Status = FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
if (EFI_ERROR (Status)) {
UOpcode.Question.QuestionId = FwOpcode->QuestionId;
}
}
Status = AppendToUpdateBuffer ((UINT8 *) &UOpcode, sizeof(UOpcode), UefiData);
if (EFI_ERROR (Status)) {
@ -397,7 +544,10 @@ F2UCreateOrderedListOpCode (
FwOpHeader = (FRAMEWORK_EFI_IFR_OP_HEADER *) ((UINT8 *) FwOpcode + FwOpcode->Header.Length);
while (FwOpHeader->OpCode != FRAMEWORK_EFI_IFR_END_ONE_OF_OP) {
Status = F2UCreateOneOfOptionOpCode ((CONST FRAMEWORK_EFI_IFR_ONE_OF_OPTION *) FwOpHeader, FwOpcode->MaxEntries, UefiData);
//
// Each entry of Order List in Framework HII is always 1 byte in size
//
Status = F2UCreateOneOfOptionOpCode ((CONST FRAMEWORK_EFI_IFR_ONE_OF_OPTION *) FwOpHeader, 1, UefiData);
if (EFI_ERROR (Status)) {
return Status;
}
@ -450,10 +600,13 @@ typedef struct {
EFI_STATUS
F2UCreateCheckBoxOpCode (
IN HII_THUNK_CONTEXT *ThunkContext,
IN UINT16 VarStoreId,
IN CONST FRAMEWORK_EFI_IFR_CHECKBOX *FwOpcode,
OUT EFI_HII_UPDATE_DATA *UefiData
)
{
EFI_STATUS Status;
EFI_IFR_CHECKBOX UOpcode;
ZeroMem (&UOpcode, sizeof(UOpcode));
@ -464,7 +617,18 @@ F2UCreateCheckBoxOpCode (
UOpcode.Question.Header.Prompt = FwOpcode->Prompt;
UOpcode.Question.Header.Help = FwOpcode->Help;
UOpcode.Question.QuestionId = FwOpcode->Key;
if (FwOpcode->Key == 0) {
Status = FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
if (EFI_ERROR (Status)) {
//
// Add a new opcode and it will not trigger call back. So we just reuse the FW QuestionId.
//
UOpcode.Question.QuestionId = FwOpcode->QuestionId;
}
} else {
UOpcode.Question.QuestionId = FwOpcode->Key;
}
UOpcode.Question.VarStoreId = RESERVED_VARSTORE_ID;
UOpcode.Question.VarStoreInfo.VarOffset = FwOpcode->QuestionId;
@ -478,8 +642,8 @@ F2UCreateCheckBoxOpCode (
//
// We also map 2 flags:
// FRAMEWORK_EFI_IFR_FLAG_INTERACTIVE,
// FRAMEWORK_EFI_IFR_FLAG_RESET_REQUIRED,
// FRAMEWORK_EFI_IFR_FLAG_DEFAULT,
// FRAMEWORK_EFI_IFR_FLAG_MANUFACTURING,
// to UEFI IFR CheckBox Opcode default flags.
//
UOpcode.Flags = (FwOpcode->Flags & (FRAMEWORK_EFI_IFR_FLAG_DEFAULT | FRAMEWORK_EFI_IFR_FLAG_MANUFACTURING));
@ -550,6 +714,8 @@ typedef struct {
EFI_STATUS
F2UCreateNumericOpCode (
IN HII_THUNK_CONTEXT *ThunkContext,
IN UINT16 VarStoreId,
IN CONST FRAMEWORK_EFI_IFR_NUMERIC *FwOpcode,
OUT EFI_HII_UPDATE_DATA *UefiData
)
@ -560,6 +726,18 @@ F2UCreateNumericOpCode (
ZeroMem (&UOpcode, sizeof(UOpcode));
if (FwOpcode->Key == 0) {
Status = FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
if (EFI_ERROR (Status)) {
//
// Add a new opcode and it will not trigger call back. So we just reuse the FW QuestionId.
//
UOpcode.Question.QuestionId = FwOpcode->QuestionId;
}
} else {
UOpcode.Question.QuestionId = FwOpcode->Key;
}
UOpcode.Header.Length = sizeof(UOpcode);
UOpcode.Header.OpCode = EFI_IFR_NUMERIC_OP;
//
@ -574,6 +752,9 @@ F2UCreateNumericOpCode (
UOpcode.Question.Header.Help = FwOpcode->Help;
UOpcode.Question.QuestionId = FwOpcode->Key;
//
// BUGBUG RESERVED_VARSTORE_ID should be passed in.
//
UOpcode.Question.VarStoreId = RESERVED_VARSTORE_ID;
UOpcode.Question.VarStoreInfo.VarOffset = FwOpcode->QuestionId;
@ -684,6 +865,8 @@ typedef struct {
EFI_STATUS
F2UCreateStringOpCode (
IN HII_THUNK_CONTEXT *ThunkContext,
IN UINT16 VarStoreId,
IN CONST FRAMEWORK_EFI_IFR_STRING *FwOpcode,
OUT EFI_HII_UPDATE_DATA *UefiData
)
@ -692,6 +875,12 @@ F2UCreateStringOpCode (
ZeroMem (&UOpcode, sizeof(UOpcode));
if (FwOpcode->Key == 0) {
FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
} else {
UOpcode.Question.QuestionId = FwOpcode->Key;
}
UOpcode.Header.Length = sizeof(UOpcode);
UOpcode.Header.OpCode = EFI_IFR_STRING_OP;
@ -753,113 +942,116 @@ F2UCreateBannerOpCode (
}
EFI_STATUS
ThunkFrameworkUpdateDataToUefiUpdateData (
FwUpdateDataToUefiUpdateData (
IN HII_THUNK_CONTEXT *ThunkContext,
IN CONST FRAMEWORK_EFI_HII_UPDATE_DATA *Data,
IN BOOLEAN AddData,
OUT EFI_HII_UPDATE_DATA **UefiData
)
{
FRAMEWORK_EFI_IFR_OP_HEADER *FrameworkOpcodeBuffer;
FRAMEWORK_EFI_IFR_OP_HEADER *NextFrameworkOpcodeBuffer;
EFI_HII_UPDATE_DATA *UefiUpdateDataBuffer;
FRAMEWORK_EFI_IFR_OP_HEADER *FwOpCode;
FRAMEWORK_EFI_IFR_OP_HEADER *NextFwOpCode;
EFI_HII_UPDATE_DATA *UefiOpCode;
UINTN Index;
EFI_STATUS Status;
UINTN DataCount;
static UINTN mOneOfOptionWidth;
UINT16 VarStoreId;
mOneOfOptionWidth = 0;
//
// Assume all dynamic opcode created is using active variable with VarStoreId of 1.
//
VarStoreId = 1;
UefiUpdateDataBuffer = AllocateZeroPool (sizeof (EFI_HII_UPDATE_DATA));
if (UefiUpdateDataBuffer == NULL) {
UefiOpCode = AllocateZeroPool (sizeof (EFI_HII_UPDATE_DATA));
if (UefiOpCode == NULL) {
return EFI_OUT_OF_RESOURCES;
}
UefiUpdateDataBuffer->Data = AllocateZeroPool (LOCAL_UPDATE_DATA_BUFFER_INCREMENTAL);
if (UefiUpdateDataBuffer->Data == NULL) {
UefiOpCode->Data = AllocateZeroPool (LOCAL_UPDATE_DATA_BUFFER_INCREMENTAL);
if (UefiOpCode->Data == NULL) {
return EFI_OUT_OF_RESOURCES;
}
UefiUpdateDataBuffer->BufferSize = LOCAL_UPDATE_DATA_BUFFER_INCREMENTAL;
UefiUpdateDataBuffer->Offset = 0;
UefiOpCode->BufferSize = LOCAL_UPDATE_DATA_BUFFER_INCREMENTAL;
UefiOpCode->Offset = 0;
FrameworkOpcodeBuffer = (FRAMEWORK_EFI_IFR_OP_HEADER *) &Data->Data;
FwOpCode = (FRAMEWORK_EFI_IFR_OP_HEADER *) &Data->Data;
for (Index = 0; Index < Data->DataCount; Index += DataCount) {
//
// By default Datacount is 1. For FRAMEWORK_EFI_IFR_ONE_OF_OP and FRAMEWORK_EFI_IFR_ORDERED_LIST_OP,
// DataCount maybe more than 1.
//
DataCount = 1;
switch (FrameworkOpcodeBuffer->OpCode) {
switch (FwOpCode->OpCode) {
case FRAMEWORK_EFI_IFR_SUBTITLE_OP:
Status = F2UCreateSubtitleOpCode ((FRAMEWORK_EFI_IFR_SUBTITLE *) FrameworkOpcodeBuffer, UefiUpdateDataBuffer);
Status = F2UCreateSubtitleOpCode ((FRAMEWORK_EFI_IFR_SUBTITLE *) FwOpCode, UefiOpCode);
DataCount = 1;
break;
case FRAMEWORK_EFI_IFR_TEXT_OP:
Status = F2UCreateTextOpCode ((FRAMEWORK_EFI_IFR_TEXT *) FrameworkOpcodeBuffer, UefiUpdateDataBuffer);
Status = F2UCreateTextOpCode ((FRAMEWORK_EFI_IFR_TEXT *) FwOpCode, UefiOpCode);
DataCount = 1;
break;
case FRAMEWORK_EFI_IFR_REF_OP:
Status = F2UCreateGotoOpCode ((FRAMEWORK_EFI_IFR_REF *) FrameworkOpcodeBuffer, UefiUpdateDataBuffer);
Status = F2UCreateGotoOpCode ((FRAMEWORK_EFI_IFR_REF *) FwOpCode, UefiOpCode);
DataCount = 1;
break;
case FRAMEWORK_EFI_IFR_ONE_OF_OP:
Status = F2UCreateOneOfOpCode ((FRAMEWORK_EFI_IFR_ONE_OF *) FrameworkOpcodeBuffer, UefiUpdateDataBuffer, &NextFrameworkOpcodeBuffer, &DataCount);
Status = F2UCreateOneOfOpCode (ThunkContext, VarStoreId, (FRAMEWORK_EFI_IFR_ONE_OF *) FwOpCode, UefiOpCode, &NextFwOpCode, &DataCount);
if (!EFI_ERROR (Status)) {
FrameworkOpcodeBuffer = NextFrameworkOpcodeBuffer;
FwOpCode = NextFwOpCode;
//
// F2UCreateOneOfOpCode has updated FrameworkOpcodeBuffer to point to the next opcode.
// FwOpCode is already updated to point to the next opcode.
//
continue;
}
break;
case FRAMEWORK_EFI_IFR_ORDERED_LIST_OP:
Status = F2UCreateOrderedListOpCode ((FRAMEWORK_EFI_IFR_ORDERED_LIST *) FrameworkOpcodeBuffer, UefiUpdateDataBuffer, &NextFrameworkOpcodeBuffer, &DataCount);
Status = F2UCreateOrderedListOpCode (ThunkContext, VarStoreId, (FRAMEWORK_EFI_IFR_ORDERED_LIST *) FwOpCode, UefiOpCode, &NextFwOpCode, &DataCount);
if (!EFI_ERROR (Status)) {
FrameworkOpcodeBuffer = NextFrameworkOpcodeBuffer;
FwOpCode = NextFwOpCode;
//
// F2UCreateOrderedListOpCode has updated FrameworkOpcodeBuffer to point to the next opcode.
// FwOpCode is already updated to point to the next opcode.
//
continue;
}
break;
case FRAMEWORK_EFI_IFR_CHECKBOX_OP:
Status = F2UCreateCheckBoxOpCode ((FRAMEWORK_EFI_IFR_CHECKBOX *) FrameworkOpcodeBuffer, UefiUpdateDataBuffer);
Status = F2UCreateCheckBoxOpCode (ThunkContext, VarStoreId, (FRAMEWORK_EFI_IFR_CHECKBOX *) FwOpCode, UefiOpCode);
DataCount = 1;
break;
case FRAMEWORK_EFI_IFR_STRING_OP:
Status = F2UCreateStringOpCode ((FRAMEWORK_EFI_IFR_STRING *) FrameworkOpcodeBuffer, UefiUpdateDataBuffer);
Status = F2UCreateStringOpCode (ThunkContext, VarStoreId, (FRAMEWORK_EFI_IFR_STRING *) FwOpCode, UefiOpCode);
DataCount = 1;
break;
case FRAMEWORK_EFI_IFR_BANNER_OP:
Status = F2UCreateBannerOpCode ((FRAMEWORK_EFI_IFR_BANNER *) FrameworkOpcodeBuffer, UefiUpdateDataBuffer);
Status = F2UCreateBannerOpCode ((FRAMEWORK_EFI_IFR_BANNER *) FwOpCode, UefiOpCode);
DataCount = 1;
break;
case FRAMEWORK_EFI_IFR_END_ONE_OF_OP:
Status = UCreateEndOfOpcode (UefiUpdateDataBuffer);
mOneOfOptionWidth = 0;
Status = UCreateEndOfOpcode (UefiOpCode);
DataCount = 1;
break;
default:
ASSERT (FALSE);
return EFI_UNSUPPORTED;
}
if (EFI_ERROR (Status)) {
FreePool (UefiUpdateDataBuffer->Data);
FreePool (UefiUpdateDataBuffer);
FreePool (UefiOpCode->Data);
FreePool (UefiOpCode);
return Status;
}
FrameworkOpcodeBuffer = (FRAMEWORK_EFI_IFR_OP_HEADER *)((UINT8 *) FrameworkOpcodeBuffer + FrameworkOpcodeBuffer->Length);
FwOpCode = (FRAMEWORK_EFI_IFR_OP_HEADER *)((UINT8 *) FwOpCode + FwOpCode->Length);
}
*UefiData = UefiUpdateDataBuffer;
*UefiData = UefiOpCode;
return EFI_SUCCESS;
}

View File

@ -54,6 +54,8 @@ F2UCreateOneOfOptionOpCode (
EFI_STATUS
F2UCreateOneOfOpCode (
IN HII_THUNK_CONTEXT *ThunkContext,
IN UINT16 VarStoreId,
IN CONST FRAMEWORK_EFI_IFR_ONE_OF *FwOpcode,
OUT EFI_HII_UPDATE_DATA *UefiData,
OUT FRAMEWORK_EFI_IFR_OP_HEADER **NextFwOpcode,
@ -63,6 +65,8 @@ F2UCreateOneOfOpCode (
EFI_STATUS
F2UCreateOrderedListOpCode (
IN HII_THUNK_CONTEXT *ThunkContext,
IN UINT16 VarStoreId,
IN CONST FRAMEWORK_EFI_IFR_ORDERED_LIST *FwOpcode,
OUT EFI_HII_UPDATE_DATA *UefiData,
OUT FRAMEWORK_EFI_IFR_OP_HEADER **NextFwOpcode,
@ -73,6 +77,8 @@ F2UCreateOrderedListOpCode (
EFI_STATUS
F2UCreateCheckBoxOpCode (
IN HII_THUNK_CONTEXT *ThunkContext,
IN UINT16 VarStoreId,
IN CONST FRAMEWORK_EFI_IFR_CHECKBOX *FwOpcode,
OUT EFI_HII_UPDATE_DATA *UefiData
)
@ -81,6 +87,8 @@ F2UCreateCheckBoxOpCode (
EFI_STATUS
F2UCreateNumericOpCode (
IN HII_THUNK_CONTEXT *ThunkContext,
IN UINT16 VarStoreId,
IN CONST FRAMEWORK_EFI_IFR_NUMERIC *FwOpcode,
OUT EFI_HII_UPDATE_DATA *UefiData
)
@ -89,6 +97,8 @@ F2UCreateNumericOpCode (
EFI_STATUS
F2UCreateStringOpCode (
IN HII_THUNK_CONTEXT *ThunkContext,
IN UINT16 VarStoreId,
IN CONST FRAMEWORK_EFI_IFR_STRING *FwOpcode,
OUT EFI_HII_UPDATE_DATA *UefiData
)
@ -103,7 +113,8 @@ F2UCreateBannerOpCode (
;
EFI_STATUS
ThunkFrameworkUpdateDataToUefiUpdateData (
FwUpdateDataToUefiUpdateData (
IN HII_THUNK_CONTEXT *ThunkContext,
IN CONST FRAMEWORK_EFI_HII_UPDATE_DATA *Data,
IN BOOLEAN AddData,
OUT EFI_HII_UPDATE_DATA **UefiData

View File

@ -1,6 +1,5 @@
/**@file
This file contains the keyboard processing code to the HII database.
Implement protocol interface related to package registrations.
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
@ -17,42 +16,44 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "HiiDatabase.h"
BOOLEAN mInFrameworkHiiNewPack = FALSE;
BOOLEAN mInFrameworkHiiRemovePack = FALSE;
STATIC BOOLEAN mInFrameworkHiiNewPack = FALSE;
STATIC BOOLEAN mInFrameworkHiiRemovePack = FALSE;
BOOLEAN mInFrameworkUpdatePakcage = FALSE;
EFI_STATUS
GetIfrAndStringPackNum (
GetPackageCount (
IN CONST EFI_HII_PACKAGES *Packages,
UINTN *IfrPackNum,
UINTN *StringPackNum
UINTN *IfrPackageCount,
UINTN *StringPackageCount
)
{
UINTN Index;
TIANO_AUTOGEN_PACKAGES_HEADER **TianoAutogenPackageHdrArray;
ASSERT (Packages != NULL);
ASSERT (IfrPackNum != NULL);
ASSERT (StringPackNum != NULL);
ASSERT (IfrPackageCount != NULL);
ASSERT (StringPackageCount != NULL);
*IfrPackNum = 0;
*StringPackNum = 0;
*IfrPackageCount = 0;
*StringPackageCount = 0;
TianoAutogenPackageHdrArray = (TIANO_AUTOGEN_PACKAGES_HEADER **) (((UINT8 *) &Packages->GuidId) + sizeof (Packages->GuidId));
for (Index = 0; Index < Packages->NumberOfPackages; Index++) {
//
// BugBug: The current UEFI HII build tool generate a binary in the format defined in:
// TIANO_AUTOGEN_PACKAGES_HEADER. We assume that all packages generated in
// this binary is with same package type. So the returned IfrPackNum and StringPackNum
// this binary is with same package type. So the returned IfrPackageCount and StringPackageCount
// may not be the exact number of valid package number in the binary generated
// by HII Build tool.
//
switch (TianoAutogenPackageHdrArray[Index]->PackageHeader.Type) {
case EFI_HII_PACKAGE_FORM:
*IfrPackNum += 1;
*IfrPackageCount += 1;
break;
case EFI_HII_PACKAGE_STRINGS:
*StringPackNum += 1;
*StringPackageCount += 1;
break;
case EFI_HII_PACKAGE_SIMPLE_FONTS:
@ -74,71 +75,6 @@ GetIfrAndStringPackNum (
return EFI_SUCCESS;
}
EFI_STATUS
LibExportPackageLists (
IN EFI_HII_HANDLE UefiHiiHandle,
OUT EFI_HII_PACKAGE_LIST_HEADER **PackageListHeader,
OUT UINTN *PackageListSize
)
{
EFI_STATUS Status;
UINTN Size;
EFI_HII_PACKAGE_LIST_HEADER *PackageListHdr;
ASSERT (PackageListSize != NULL);
ASSERT (PackageListHeader != NULL);
Size = 0;
PackageListHdr = NULL;
Status = mHiiDatabase->ExportPackageLists (
mHiiDatabase,
UefiHiiHandle,
&Size,
PackageListHdr
);
ASSERT_EFI_ERROR (Status == EFI_BUFFER_TOO_SMALL);
if (Status == EFI_BUFFER_TOO_SMALL) {
PackageListHdr = AllocateZeroPool (Size);
ASSERT (PackageListHdr != NULL);
if (PackageListHeader == NULL) {
return EFI_OUT_OF_RESOURCES;
} else {
Status = mHiiDatabase->ExportPackageLists (
mHiiDatabase,
UefiHiiHandle,
&Size,
PackageListHdr
);
ASSERT_EFI_ERROR (Status);
}
}
if (!EFI_ERROR (Status)) {
*PackageListHeader = PackageListHdr;
*PackageListSize = Size;
}
return Status;
}
EFI_STATUS
InsertStringPackagesToIfrPackageList (
IN CONST EFI_HII_PACKAGE_LIST_HEADER *StringPackageListHeader,
IN EFI_HII_HANDLE UefiHiiHandle
)
{
EFI_STATUS Status;
Status = mHiiDatabase->UpdatePackageList (
mHiiDatabase,
UefiHiiHandle,
StringPackageListHeader
);
return Status;
}
/**
Removes a node from a doubly linked list, and returns the node that follows
the removed node.
@ -161,27 +97,53 @@ InsertStringPackagesToIfrPackageList (
**/
EFI_STATUS
AddStringPackagesToMatchingIfrPackageList (
IN EFI_HII_THUNK_PRIVATE_DATA *Private,
FindPackListWithOnlyIfrPackAndAddStringPack (
IN HII_THUNK_PRIVATE_DATA *Private,
IN HII_THUNK_CONTEXT *StringPackageThunkContext,
IN CONST EFI_HII_PACKAGE_LIST_HEADER *StringPackageListHeader
)
{
EFI_STATUS Status;
LIST_ENTRY *ListEntry;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
LIST_ENTRY *Link;
HII_THUNK_CONTEXT *ThunkContext;
for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;
ListEntry != &Private->HiiThunkHandleMappingDBListHead;
ListEntry = ListEntry->ForwardLink
) {
HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry);
if (CompareGuid (&StringPackageListHeader->PackageListGuid, &HandleMapEntry->TagGuid)) {
Status = InsertStringPackagesToIfrPackageList (StringPackageListHeader, HandleMapEntry->UefiHiiHandle);
Link = GetFirstNode (&Private->ThunkContextListHead);
while (!IsNull (&Private->ThunkContextListHead, Link)) {
ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
if (StringPackageThunkContext != ThunkContext) {
//
// Skip the String Package Thunk Entry itself.
//
if (CompareGuid (&StringPackageListHeader->PackageListGuid, &ThunkContext->TagGuid)) {
ASSERT (ThunkContext->StringPackageCount == 0 && ThunkContext->IfrPackageCount == 1);
ThunkContext->StringPackageCount = GetPackageCountByType (StringPackageListHeader, EFI_HII_PACKAGE_STRINGS);
Status = mHiiDatabase->UpdatePackageList (
mHiiDatabase,
ThunkContext->UefiHiiHandle,
StringPackageListHeader
);
ASSERT (Status != EFI_NOT_FOUND);
if (EFI_ERROR (Status)) {
return Status;
}
}
}
Link = GetNextNode (&Private->ThunkContextListHead, Link);
}
return EFI_NOT_FOUND;
}
EFI_HII_PACKAGE_LIST_HEADER *
PrepareUefiPackageListFromFrameworkHiiPackages (
IN CONST EFI_HII_PACKAGES *Packages,
@ -260,95 +222,229 @@ GenerateGuidId (
}
EFI_STATUS
FindAndAddStringPackageToIfrPackageList(
EFI_HII_THUNK_PRIVATE_DATA *Private,
EFI_GUID *GuidId,
EFI_HII_HANDLE UefiIfrHiiHandle
FindStringPackAndAddToPackListWithOnlyIfrPack(
IN HII_THUNK_PRIVATE_DATA *Private,
IN HII_THUNK_CONTEXT *IfrThunkContext
)
{
EFI_STATUS Status;
LIST_ENTRY *ListEntry;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
EFI_HII_PACKAGE_LIST_HEADER *StringPackageListHeader;
UINTN Size;
EFI_STATUS Status;
LIST_ENTRY *Link;
EFI_HII_PACKAGE_LIST_HEADER *StringPackageListHeader;
UINTN Size;
HII_THUNK_CONTEXT *ThunkContext;
for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;
ListEntry != &Private->HiiThunkHandleMappingDBListHead;
ListEntry = ListEntry->ForwardLink
) {
HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry);
if (CompareGuid (GuidId, &HandleMapEntry->TagGuid) && (!HandleMapEntry->DoesPackageListImportStringPackages)) {
Status = LibExportPackageLists (HandleMapEntry->UefiHiiHandle, &StringPackageListHeader, &Size);
ASSERT_EFI_ERROR (Status);
Link = GetFirstNode (&Private->ThunkContextListHead);
//
// Add Function to only get only String Packages from the Package List
//
while (!IsNull (&Private->ThunkContextListHead, Link)) {
Status = InsertStringPackagesToIfrPackageList (StringPackageListHeader, UefiIfrHiiHandle);
ASSERT_EFI_ERROR (Status);
FreePool (StringPackageListHeader);
return EFI_SUCCESS;
ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
if (ThunkContext != IfrThunkContext) {
if (CompareGuid (&IfrThunkContext->TagGuid, &ThunkContext->TagGuid) && (ThunkContext->IfrPackageCount == 0)) {
Status = HiiLibExportPackageLists (ThunkContext->UefiHiiHandle, &StringPackageListHeader, &Size);
ASSERT_EFI_ERROR (Status);
IfrThunkContext->StringPackageCount = GetPackageCountByType (StringPackageListHeader, EFI_HII_PACKAGE_STRINGS);
//
// Add Function to only get only String Packages from the Package List
//
Status = mHiiDatabase->UpdatePackageList (
mHiiDatabase,
IfrThunkContext->UefiHiiHandle,
StringPackageListHeader
);
ASSERT_EFI_ERROR (Status);
FreePool (StringPackageListHeader);
return EFI_SUCCESS;
}
}
Link = GetNextNode (&Private->ThunkContextListHead, Link);
}
return EFI_NOT_FOUND;
}
HII_THUNK_CONTEXT *
CreateThunkContext (
IN HII_THUNK_PRIVATE_DATA *Private,
IN UINTN StringPackageCount,
IN UINTN IfrPackageCount
)
{
EFI_STATUS Status;
HII_THUNK_CONTEXT *ThunkContext;
ThunkContext = AllocateZeroPool (sizeof (HII_THUNK_CONTEXT));
ASSERT (ThunkContext != NULL);
ThunkContext->Signature = HII_THUNK_CONTEXT_SIGNATURE;
ThunkContext->IfrPackageCount = IfrPackageCount;
ThunkContext->StringPackageCount = StringPackageCount;
Status = AssignFrameworkHiiHandle (Private, TRUE, &ThunkContext->FwHiiHandle);
if (EFI_ERROR (Status)) {
return NULL;
}
InitializeListHead (&ThunkContext->QuestionIdMapListHead);
InitializeListHead (&ThunkContext->OneOfOptionMapListHead);
return ThunkContext;
}
VOID
FreeFrameworkHiiHandle (
IN HII_THUNK_PRIVATE_DATA *Private,
IN FRAMEWORK_EFI_HII_HANDLE FwHandle
)
{
//
// TODO:
//
return;
}
VOID
DestoryOneOfOptionMap (
IN LIST_ENTRY *OneOfOptionMapListHead
)
{
ONE_OF_OPTION_MAP *Map;
ONE_OF_OPTION_MAP_ENTRY *MapEntry;
LIST_ENTRY *Link;
LIST_ENTRY *Link2;
while (!IsListEmpty (OneOfOptionMapListHead)) {
Link = GetFirstNode (OneOfOptionMapListHead);
Map = ONE_OF_OPTION_MAP_FROM_LINK (Link);
while (!IsListEmpty (&Map->OneOfOptionMapEntryListHead)) {
Link2 = GetFirstNode (&Map->OneOfOptionMapEntryListHead);
MapEntry = ONE_OF_OPTION_MAP_ENTRY_FROM_LINK (Link);
RemoveEntryList (Link2);
FreePool (MapEntry);
}
RemoveEntryList (Link);
FreePool (Map);
}
}
VOID
DestroyQuestionIdMap (
IN LIST_ENTRY *QuestionIdMapListHead
)
{
QUESTION_ID_MAP *IdMap;
QUESTION_ID_MAP_ENTRY *IdMapEntry;
LIST_ENTRY *Link;
LIST_ENTRY *Link2;
while (!IsListEmpty (QuestionIdMapListHead)) {
Link = GetFirstNode (QuestionIdMapListHead);
IdMap = QUESTION_ID_MAP_FROM_LINK (Link);
while (!IsListEmpty (&IdMap->MapEntryListHead)) {
Link2 = GetFirstNode (&IdMap->MapEntryListHead);
IdMapEntry = QUESTION_ID_MAP_ENTRY_FROM_LINK (Link);
RemoveEntryList (Link2);
FreePool (IdMapEntry);
}
RemoveEntryList (Link);
FreePool (IdMap);
}
}
VOID
DestroyThunkContext (
IN HII_THUNK_PRIVATE_DATA *Private,
IN HII_THUNK_CONTEXT *ThunkContext
)
{
ASSERT (ThunkContext != NULL);
FreeFrameworkHiiHandle (Private, ThunkContext->FwHiiHandle);
DestroyQuestionIdMap (&ThunkContext->QuestionIdMapListHead);
DestoryOneOfOptionMap (&ThunkContext->OneOfOptionMapListHead);
FreePool (ThunkContext);
}
CONST EFI_GUID mAGuid =
{ 0x14f95e01, 0xd562, 0x432e, { 0x84, 0x4a, 0x95, 0xa4, 0x39, 0x5, 0x10, 0x7e } };
EFI_STATUS
UefiRegisterPackageList(
EFI_HII_THUNK_PRIVATE_DATA *Private,
EFI_HII_PACKAGES *Packages,
FRAMEWORK_EFI_HII_HANDLE *Handle
IN HII_THUNK_PRIVATE_DATA *Private,
IN EFI_HII_PACKAGES *Packages,
OUT FRAMEWORK_EFI_HII_HANDLE *Handle
)
{
EFI_STATUS Status;
UINTN StringPackNum;
UINTN IfrPackNum;
EFI_HII_PACKAGE_LIST_HEADER *UefiPackageListHeader;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMappingEntry;
UINTN StringPackageCount;
UINTN IfrPackageCount;
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
HII_THUNK_CONTEXT *ThunkContext;
EFI_GUID GuidId;
UefiPackageListHeader = NULL;
PackageListHeader = NULL;
Status = GetIfrAndStringPackNum (Packages, &IfrPackNum, &StringPackNum);
Status = GetPackageCount (Packages, &IfrPackageCount, &StringPackageCount);
ASSERT_EFI_ERROR (Status);
//
// Thunk Layer only handle the following combinations of IfrPack, StringPkg and FontPack.
// Thunk Layer only allow zero or one IfrPack in the Package List.
//
if (IfrPackNum > 1) {
if (IfrPackageCount > 1) {
//
// HII Thunk only handle package with 0 or 1 IFR package.
//
return EFI_UNSUPPORTED;
}
HandleMappingEntry = AllocateZeroPool (sizeof (*HandleMappingEntry));
ASSERT (HandleMappingEntry != NULL);
HandleMappingEntry->Signature = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_SIGNATURE;
Status = AssignHiiHandle (Private, &HandleMappingEntry->FrameworkHiiHandle);
if (EFI_ERROR (Status)) {
goto Done;
ThunkContext = CreateThunkContext (Private, StringPackageCount, IfrPackageCount);
if (ThunkContext == NULL) {
return EFI_OUT_OF_RESOURCES;
}
//
// Packages->GuidId may be NULL. In such case, caller of FramworkHii->NewPack is registering
// package with StringPack and IfrPack.
//
if (Packages->GuidId == NULL) {
//
// UEFI HII Database require Package List GUID must be unique.
//
// If Packages->GuidId is NULL, the caller of FramworkHii->NewPack is registering
// packages with at least 1 StringPack and 1 IfrPack. Therefore, Packages->GuidId is
// not used as the name of the package list. A GUID is generated as a Package List
// GUID.
//
ASSERT (StringPackageCount >=1 && IfrPackageCount == 1);
Packages->GuidId = &GuidId;
GenerateGuidId (&mAGuid, Packages->GuidId);
} else {
//BugBug We need fix this.
//ASSERT (StringPackageCount == 0 || IfrPackageCount == 0);
CopyGuid (&GuidId, Packages->GuidId);
}
CopyGuid (&HandleMappingEntry->TagGuid, Packages->GuidId);
if ((StringPackNum == 0) && (IfrPackNum != 0)) {
//
// Record the Package List GUID, it is used as a name for the package list by Framework HII.
//
CopyGuid (&ThunkContext->TagGuid, Packages->GuidId);
if ((StringPackageCount == 0) && (IfrPackageCount != 0)) {
//
// UEFI HII database does not allow two package list with the same GUID.
// In Framework HII implementation, Packages->GuidId is used as an identifier to associate
@ -361,68 +457,65 @@ UefiRegisterPackageList(
// UEFI HII require EFI_HII_CONFIG_ACCESS_PROTOCOL to be installed on a EFI_HANDLE, so
// that Setup Utility can load the Buffer Storage using this protocol.
//
if (IfrPackNum != 0) {
InstallDefaultUefiConfigAccessProtocol (Packages, HandleMappingEntry);
if (IfrPackageCount != 0) {
InstallDefaultConfigAccessProtocol (Packages, ThunkContext);
}
UefiPackageListHeader = PrepareUefiPackageListFromFrameworkHiiPackages (Packages, &GuidId);
PackageListHeader = PrepareUefiPackageListFromFrameworkHiiPackages (Packages, &GuidId);
Status = mHiiDatabase->NewPackageList (
mHiiDatabase,
UefiPackageListHeader,
HandleMappingEntry->UefiHiiDriverHandle,
&HandleMappingEntry->UefiHiiHandle
PackageListHeader,
ThunkContext->UefiHiiDriverHandle,
&ThunkContext->UefiHiiHandle
);
//
// BUGBUG: Remove when development is done
//
ASSERT_EFI_ERROR (Status);
if (EFI_ERROR (Status)) {
goto Done;
}
if (IfrPackNum == 0) {
if (StringPackNum != 0) {
if (IfrPackageCount == 0) {
if (StringPackageCount != 0) {
//
// Look for a package list with IFR Pack which has already registed with HII Database
// Find if there is Package List with only IFR Package in the databasee with the same
// tag. If found, add the String Package to this Package List.
//
HandleMappingEntry->IsPackageListWithOnlyStringPackages = TRUE;
Status = AddStringPackagesToMatchingIfrPackageList (
Status = FindPackListWithOnlyIfrPackAndAddStringPack (
Private,
UefiPackageListHeader
ThunkContext,
PackageListHeader
);
if (!EFI_ERROR (Status) || Status == EFI_NOT_FOUND) {
if (Status == EFI_NOT_FOUND) {
Status = EFI_SUCCESS;
}
if (Status == EFI_NOT_FOUND) {
Status = EFI_SUCCESS;
}
}
} else {
if (StringPackNum == 0) {
CreateQuestionIdMap (ThunkContext);
if (StringPackageCount == 0) {
//
// Register the Package List to UEFI HII first.
//
Status = FindAndAddStringPackageToIfrPackageList (
Status = FindStringPackAndAddToPackListWithOnlyIfrPack (
Private,
Packages->GuidId,
HandleMappingEntry->UefiHiiHandle
ThunkContext
);
ASSERT_EFI_ERROR (Status);
if (!EFI_ERROR (Status)) {
HandleMappingEntry->DoesPackageListImportStringPackages = TRUE;
}
}
}
if (!EFI_ERROR (Status)) {
InsertTailList (&Private->HiiThunkHandleMappingDBListHead, &HandleMappingEntry->List);
}
Done:
if (EFI_ERROR (Status)) {
FreePool (HandleMappingEntry);
DestroyThunkContext (Private, ThunkContext);
} else {
*Handle = HandleMappingEntry->FrameworkHiiHandle;
InsertTailList (&Private->ThunkContextListHead, &ThunkContext->Link);
*Handle = ThunkContext->FwHiiHandle;
}
SafeFreePool (UefiPackageListHeader);
SafeFreePool (PackageListHeader);
return Status;
}
@ -455,7 +548,7 @@ Returns:
--*/
{
EFI_STATUS Status;
EFI_HII_THUNK_PRIVATE_DATA *Private;
HII_THUNK_PRIVATE_DATA *Private;
EFI_TPL OldTpl;
if (Handle == NULL) {
@ -476,7 +569,7 @@ Returns:
//
mInFrameworkHiiNewPack = TRUE;
Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
Status = UefiRegisterPackageList (
Private,
@ -509,49 +602,32 @@ Returns:
--*/
{
EFI_STATUS Status;
EFI_HII_THUNK_PRIVATE_DATA *Private;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
HII_THUNK_PRIVATE_DATA *Private;
HII_THUNK_CONTEXT *ThunkContext;
EFI_TPL OldTpl;
EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
mInFrameworkHiiRemovePack = TRUE;
Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
HandleMapEntry = FrameworkHiiHandleToMapDatabaseEntry (Private, Handle);
ThunkContext = FwHiiHandleToThunkContext (Private, Handle);
if (HandleMapEntry != NULL) {
if (ThunkContext != NULL) {
Status = mHiiDatabase->RemovePackageList (
mHiiDatabase,
HandleMapEntry->UefiHiiHandle
ThunkContext->UefiHiiHandle
);
ASSERT_EFI_ERROR (Status);
HiiLibDestroyHiiDriverHandle (HandleMapEntry->UefiHiiHandle);
Status = gBS->HandleProtocol (
HandleMapEntry->UefiHiiDriverHandle,
&gEfiHiiConfigAccessProtocolGuid,
(VOID **) &ConfigAccess
);
if (!EFI_ERROR (Status)) {
Status = gBS->UninstallProtocolInterface (
HandleMapEntry->UefiHiiDriverHandle,
&gEfiHiiConfigAccessProtocolGuid,
ConfigAccess
);
ASSERT_EFI_ERROR (Status);
} else {
Status = EFI_SUCCESS;
if (ThunkContext->IfrPackageCount != 0) {
UninstallDefaultConfigAccessProtocol (ThunkContext);
}
RemoveEntryList (&HandleMapEntry->List);
FreePool (HandleMapEntry);
RemoveEntryList (&ThunkContext->Link);
DestroyThunkContext (Private, ThunkContext);
}else {
Status = EFI_NOT_FOUND;
}
@ -562,3 +638,150 @@ Returns:
return Status;
}
EFI_STATUS
EFIAPI
NewOrAddPackNotify (
IN UINT8 PackageType,
IN CONST EFI_GUID *PackageGuid,
IN CONST EFI_HII_PACKAGE_HEADER *Package,
IN EFI_HII_HANDLE Handle,
IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
)
{
EFI_STATUS Status;
HII_THUNK_PRIVATE_DATA *Private;
HII_THUNK_CONTEXT *ThunkContext;
ASSERT (PackageType == EFI_HII_PACKAGE_STRINGS || PackageType == EFI_HII_PACKAGE_FORM);
ASSERT (NotifyType == EFI_HII_DATABASE_NOTIFY_ADD_PACK || NotifyType == EFI_HII_DATABASE_NOTIFY_NEW_PACK);
Status = EFI_SUCCESS;
Private = mHiiThunkPrivateData;
if (mInFrameworkHiiNewPack || mInFrameworkUpdatePakcage) {
return EFI_SUCCESS;
}
//
// We only create a ThunkContext if the Uefi Hii Handle is only already registered
// by the HII Thunk Layer.
//
ThunkContext = UefiHiiHandleToThunkContext (Private, Handle);
if (ThunkContext == NULL) {
ThunkContext = CreateThunkContextForUefiHiiHandle (Private, Handle);
ASSERT (ThunkContext != NULL);
}
if (PackageType == EFI_HII_PACKAGE_FORM) {
Status = CreateQuestionIdMap (ThunkContext);
}
return Status;
}
BOOLEAN
IsRemovingLastStringPack (
IN EFI_HII_HANDLE Handle
)
{
EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
UINTN BufferSize;
EFI_STATUS Status;
EFI_HII_PACKAGE_HEADER *PackageHeader;
UINTN StringPackageCount;
HiiPackageList = NULL;
BufferSize = 0;
StringPackageCount = 0;
Status = HiiLibExportPackageLists (Handle, &HiiPackageList, &BufferSize);
ASSERT_EFI_ERROR (Status);
PackageHeader = (EFI_HII_PACKAGE_HEADER *) ((UINT8 *) HiiPackageList + sizeof (EFI_HII_PACKAGE_LIST_HEADER));
while (PackageHeader->Type != EFI_HII_PACKAGE_END) {
switch (PackageHeader->Type) {
case EFI_HII_PACKAGE_STRINGS:
StringPackageCount++;
if (StringPackageCount > 1) {
//
// More than one String Pack in the package list
//
FreePool (HiiPackageList);
return FALSE;
}
break;
default:
break;
}
//
// goto header of next package
//
PackageHeader = (EFI_HII_PACKAGE_HEADER *) ((UINT8 *) PackageHeader + PackageHeader->Length);
}
//
// We will always be notified for the removal of String Pack from a package list.
// So StringPackageCount must be one at this point.
//
ASSERT (StringPackageCount == 1);
FreePool (HiiPackageList);
return TRUE;
}
// Framework HII module may cache a GUID as the name of the package list.
// Then search for the Framework HII handle database for the handle matching
// this GUID
EFI_STATUS
EFIAPI
RemovePackNotify (
IN UINT8 PackageType,
IN CONST EFI_GUID *PackageGuid,
IN CONST EFI_HII_PACKAGE_HEADER *Package,
IN EFI_HII_HANDLE Handle,
IN EFI_HII_DATABASE_NOTIFY_TYPE NotifyType
)
{
EFI_STATUS Status;
HII_THUNK_PRIVATE_DATA *Private;
HII_THUNK_CONTEXT * ThunkContext;
Status = EFI_SUCCESS;
ASSERT (PackageType == EFI_HII_PACKAGE_STRINGS);
ASSERT (NotifyType == EFI_HII_DATABASE_NOTIFY_REMOVE_PACK);
if (mInFrameworkHiiRemovePack || mInFrameworkUpdatePakcage) {
return EFI_SUCCESS;
}
Private = mHiiThunkPrivateData;
ThunkContext = UefiHiiHandleToThunkContext (Private, Handle);
if (ThunkContext->FwHiiHandle > Private->StaticHiiHandle) {
if (IsRemovingLastStringPack (Handle)) {
//
// If the string package will be removed is the last string package
// in the package list, we will remove the HII Thunk entry from the
// database.
//
Status = DestroyThunkContextForUefiHiiHandle (Private, Handle);
}
}
return Status;
}

View File

@ -0,0 +1,105 @@
/**@file
Framework to UEFI 2.1 Setup Browser Thunk. The file consume EFI_FORM_BROWSER2_PROTOCOL
to produce a EFI_FORM_BROWSER_PROTOCOL.
Copyright (c) 2008, Intel Corporation
All rights reserved. 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
http://opensource.org/licenses/bsd-license.php
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "HiiDatabase.h"
EFI_STATUS
EFIAPI
ThunkSendForm (
IN EFI_FORM_BROWSER_PROTOCOL *This,
IN BOOLEAN UseDatabase,
IN FRAMEWORK_EFI_HII_HANDLE *Handle,
IN UINTN HandleCount,
IN FRAMEWORK_EFI_IFR_PACKET *Packet, OPTIONAL
IN EFI_HANDLE CallbackHandle, OPTIONAL
IN UINT8 *NvMapOverride, OPTIONAL
IN FRAMEWORK_EFI_SCREEN_DESCRIPTOR *ScreenDimensions, OPTIONAL
OUT BOOLEAN *ResetRequired OPTIONAL
)
{
EFI_STATUS Status;
EFI_BROWSER_ACTION_REQUEST ActionRequest;
HII_THUNK_CONTEXT *ThunkContext;
HII_THUNK_PRIVATE_DATA *Private;
EFI_FORMBROWSER_THUNK_PRIVATE_DATA *BrowserPrivate;
if (!UseDatabase) {
//
// Packet, CallbackHandle.
//
return EFI_UNSUPPORTED;
}
if (HandleCount != 1 ) {
return EFI_UNSUPPORTED;
}
BrowserPrivate = EFI_FORMBROWSER_THUNK_PRIVATE_DATA_FROM_THIS (This);
Private = BrowserPrivate->ThunkPrivate;
ThunkContext = FwHiiHandleToThunkContext (Private, *Handle);
if (ThunkContext == NULL) {
return EFI_INVALID_PARAMETER;
}
if (NvMapOverride != NULL) {
ThunkContext->NvMapOverride = NvMapOverride;
}
Status = mFormBrowser2Protocol->SendForm (
mFormBrowser2Protocol,
&ThunkContext->UefiHiiHandle,
1,
NULL,
0,
(EFI_SCREEN_DESCRIPTOR *) ScreenDimensions,
&ActionRequest
);
if (ActionRequest == EFI_BROWSER_ACTION_REQUEST_RESET) {
*ResetRequired = TRUE;
}
return Status;
}
EFI_STATUS
EFIAPI
ThunkCreatePopUp (
IN UINTN NumberOfLines,
IN BOOLEAN HotKey,
IN UINTN MaximumStringSize,
OUT CHAR16 *StringBuffer,
OUT EFI_INPUT_KEY *KeyValue,
IN CHAR16 *String,
...
)
{
EFI_STATUS Status;
VA_LIST Marker;
if (HotKey != TRUE) {
return EFI_UNSUPPORTED;
}
VA_START (Marker, KeyValue);
Status = IfrLibCreatePopUp2 (NumberOfLines, KeyValue, Marker);
VA_END (Marker);
return Status;
}

View File

@ -1,7 +1,6 @@
/**@file
This file contains the keyboard processing code to the HII database.
This file implements the protocol functions related to string package.
Copyright (c) 2006 - 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
are licensed and made available under the terms and conditions of the BSD License
@ -40,126 +39,34 @@ Returns:
}
EFI_STATUS
GetTagGuidByFrameworkHiiHandle (
IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private,
IN FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle,
GetTagGuidByFwHiiHandle (
IN CONST HII_THUNK_PRIVATE_DATA *Private,
IN FRAMEWORK_EFI_HII_HANDLE FwHiiHandle,
OUT EFI_GUID *TagGuid
)
{
LIST_ENTRY *ListEntry;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
LIST_ENTRY *Link;
HII_THUNK_CONTEXT *ThunkContext;
ASSERT (TagGuid != NULL);
for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;
ListEntry != &Private->HiiThunkHandleMappingDBListHead;
ListEntry = ListEntry->ForwardLink
) {
Link = GetFirstNode (&Private->ThunkContextListHead);
while (!IsNull (&Private->ThunkContextListHead, Link)) {
HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry);
ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
if (FrameworkHiiHandle == HandleMapEntry->FrameworkHiiHandle) {
CopyGuid (TagGuid, &HandleMapEntry->TagGuid);
if (FwHiiHandle == ThunkContext->FwHiiHandle) {
CopyGuid (TagGuid, &ThunkContext->TagGuid);
return EFI_SUCCESS;
}
Link = GetNextNode (&Private->ThunkContextListHead, Link);
}
return EFI_NOT_FOUND;
}
EFI_STATUS
HiiThunkNewStringForAllStringPackages (
IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private,
OUT CONST EFI_GUID *TagGuid,
IN CHAR16 *Language,
IN OUT STRING_REF *Reference,
IN CHAR16 *NewString
)
{
EFI_STATUS Status;
LIST_ENTRY *ListEntry;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
EFI_STRING_ID StringId1;
EFI_STRING_ID StringId2;
CHAR8 *AsciiLanguage;
BOOLEAN Found;
ASSERT (TagGuid != NULL);
StringId1 = (EFI_STRING_ID) 0;
StringId2 = (EFI_STRING_ID) 0;
Found = FALSE;
if (Language == NULL) {
AsciiLanguage = NULL;
} else {
AsciiLanguage = AllocateZeroPool (StrLen (Language) + 1);
UnicodeStrToAsciiStr (Language, AsciiLanguage);
}
for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;
ListEntry != &Private->HiiThunkHandleMappingDBListHead;
ListEntry = ListEntry->ForwardLink
) {
HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry);
if (CompareGuid (TagGuid, &HandleMapEntry->TagGuid)) {
Found = TRUE;
if (*Reference == 0) {
if (AsciiLanguage == NULL) {
Status = HiiLibNewString (HandleMapEntry->UefiHiiHandle, &StringId2, NewString);
} else {
Status = mHiiStringProtocol->NewString (
mHiiStringProtocol,
HandleMapEntry->UefiHiiHandle,
&StringId2,
AsciiLanguage,
NULL,
NewString,
NULL
);
}
} else {
if (AsciiLanguage == NULL) {
Status = HiiLibSetString (HandleMapEntry->UefiHiiHandle, *Reference, NewString);
} else {
Status = mHiiStringProtocol->SetString (
mHiiStringProtocol,
HandleMapEntry->UefiHiiHandle,
*Reference,
AsciiLanguage,
NewString,
NULL
);
}
}
if (EFI_ERROR (Status)) {
return Status;
}
if (*Reference == 0) {
if (StringId1 == (EFI_STRING_ID) 0) {
StringId1 = StringId2;
} else {
if (StringId1 != StringId2) {
ASSERT(FALSE);
return EFI_INVALID_PARAMETER;
}
}
}
}
}
if (Found) {
*Reference = StringId1;
Status = EFI_SUCCESS;
} else {
ASSERT (FALSE);
Status = EFI_NOT_FOUND;
}
return Status;
}
EFI_STATUS
EFIAPI
@ -185,16 +92,127 @@ Returns:
--*/
{
EFI_STATUS Status;
EFI_HII_THUNK_PRIVATE_DATA *Private;
EFI_GUID TagGuid;
EFI_STATUS Status;
HII_THUNK_PRIVATE_DATA *Private;
EFI_GUID TagGuid;
LIST_ENTRY *Link;
HII_THUNK_CONTEXT *ThunkContext;
EFI_STRING_ID StringId;
EFI_STRING_ID LastStringId;
CHAR8 *AsciiLanguage;
BOOLEAN Found;
Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
//
// BugBug: Conver the language to 3066.
//
Status = GetTagGuidByFrameworkHiiHandle (Private, Handle, &TagGuid);
LastStringId = (EFI_STRING_ID) 0;
StringId = (EFI_STRING_ID) 0;
Found = FALSE;
AsciiLanguage = NULL;
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
Status = GetTagGuidByFwHiiHandle (Private, Handle, &TagGuid);
ASSERT_EFI_ERROR (Status);
Status = HiiThunkNewStringForAllStringPackages (Private, &TagGuid, Language, Reference, NewString);
if (Language != NULL) {
AsciiLanguage = AllocateZeroPool (StrLen (Language) + 1);
UnicodeStrToAsciiStr (Language, AsciiLanguage);
}
Link = GetFirstNode (&Private->ThunkContextListHead);
while (!IsNull (&Private->ThunkContextListHead, Link)) {
ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
if (CompareGuid (&TagGuid, &ThunkContext->TagGuid)) {
Found = TRUE;
if (*Reference == 0) {
//
// Create a new string token.
//
if (AsciiLanguage == NULL) {
//
// For all languages in the package list.
//
Status = HiiLibNewString (ThunkContext->UefiHiiHandle, &StringId, NewString);
} else {
//
// For specified language.
//
Status = mHiiStringProtocol->NewString (
mHiiStringProtocol,
ThunkContext->UefiHiiHandle,
&StringId,
AsciiLanguage,
NULL,
NewString,
NULL
);
}
} else {
//
// Update the existing string token.
//
if (AsciiLanguage == NULL) {
//
// For all languages in the package list.
//
Status = HiiLibSetString (ThunkContext->UefiHiiHandle, *Reference, NewString);
} else {
//
// For specified language.
//
Status = mHiiStringProtocol->SetString (
mHiiStringProtocol,
ThunkContext->UefiHiiHandle,
*Reference,
AsciiLanguage,
NewString,
NULL
);
}
}
if (EFI_ERROR (Status)) {
//
// Only EFI_INVALID_PARAMETER is defined in HII 0.92 specification.
//
return EFI_INVALID_PARAMETER;
}
if (*Reference == 0) {
//
// When creating new string token, make sure all created token is the same
// for all string packages registered using FW HII interface.
//
if (LastStringId == (EFI_STRING_ID) 0) {
LastStringId = StringId;
} else {
if (LastStringId != StringId) {
ASSERT(FALSE);
return EFI_INVALID_PARAMETER;
}
}
}
}
Link = GetNextNode (&Private->ThunkContextListHead, Link);
}
if (Found) {
if (*Reference == 0) {
*Reference = StringId;
}
Status = EFI_SUCCESS;
} else {
DEBUG((EFI_D_ERROR, "Thunk HiiNewString fails to find the String Packages to update\n"));
//
// BUGBUG: Remove ths ASSERT when development is done.
//
ASSERT (FALSE);
Status = EFI_NOT_FOUND;
}
//
// For UNI file, some String may not be defined for a language. This has been true for a lot of platform code.
// For this case, EFI_NOT_FOUND will be returned. To allow the old code to be run without porting, we don't assert
@ -224,8 +242,7 @@ Returns:
--*/
{
ASSERT (FALSE);
return EFI_UNSUPPORTED;
return EFI_SUCCESS;
}
typedef struct {
@ -293,13 +310,13 @@ Returns:
--*/
{
LIST_ENTRY *ListEntry;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
LIST_ENTRY *Link;
HII_THUNK_CONTEXT *ThunkContext;
CHAR8 *AsciiLanguage;
EFI_HII_THUNK_PRIVATE_DATA *Private;
HII_THUNK_PRIVATE_DATA *Private;
CHAR8 *Rfc3066AsciiLanguage;
Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
if (LanguageString == NULL) {
AsciiLanguage = NULL;
@ -328,21 +345,20 @@ Returns:
}
for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;
ListEntry != &Private->HiiThunkHandleMappingDBListHead;
ListEntry = ListEntry->ForwardLink
) {
Link = GetFirstNode (&Private->ThunkContextListHead);
HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry);
while (!IsNull (&Private->ThunkContextListHead, Link)) {
if (Handle == HandleMapEntry->FrameworkHiiHandle) {
ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
if (Handle == ThunkContext->FwHiiHandle) {
if (AsciiLanguage == NULL) {
return HiiLibGetString (HandleMapEntry->UefiHiiHandle, Token, StringBuffer, BufferLengthTemp);
return HiiLibGetString (ThunkContext->UefiHiiHandle, Token, StringBuffer, BufferLengthTemp);
} else {
return mHiiStringProtocol->GetString (
mHiiStringProtocol,
AsciiLanguage,
HandleMapEntry->UefiHiiHandle,
ThunkContext->UefiHiiHandle,
Token,
StringBuffer,
BufferLengthTemp,
@ -350,6 +366,9 @@ Returns:
);
}
}
Link = GetNextNode (&Private->ThunkContextListHead, Link);
}
return EFI_NOT_FOUND;

View File

@ -31,7 +31,6 @@
// Extern Variables
//
extern CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
extern CONST EFI_HII_FONT_PROTOCOL *mHiiFontProtocol;
extern CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol;
extern CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol;
extern CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol;
@ -432,8 +431,6 @@ ExtractFormDefault (
Link = GetFirstNode (&Form->StatementListHead);
while (!IsNull (&Form->StatementListHead, Link)) {
Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
Link = GetNextNode (&Form->StatementListHead, Link);
//
// Reset Question to its default value
//
@ -442,6 +439,7 @@ ExtractFormDefault (
continue;
}
Link = GetNextNode (&Form->StatementListHead, Link);
}
return EFI_SUCCESS;
}
@ -546,20 +544,20 @@ GetBufferTypeDefaultId (
OUT LIST_ENTRY *UefiDefaultsListHead
)
{
LIST_ENTRY *StorageListEntry;
LIST_ENTRY *StorageLink;
FORMSET_STORAGE *Storage;
EFI_STATUS Status;
StorageListEntry = GetFirstNode (&FormSet->StorageListHead);
StorageLink = GetFirstNode (&FormSet->StorageListHead);
while (!IsNull (&FormSet->StorageListHead, StorageListEntry)) {
Storage = FORMSET_STORAGE_FROM_LINK(StorageListEntry);
while (!IsNull (&FormSet->StorageListHead, StorageLink)) {
Storage = FORMSET_STORAGE_FROM_LINK(StorageLink);
if (Storage->Type == EFI_HII_VARSTORE_BUFFER) {
Status = GetBufferTypeDefaultIdAndStorageId (DefaultStore, Storage, FormSet, UefiDefaultsListHead);
}
StorageListEntry = GetNextNode (&FormSet->StorageListHead, StorageListEntry);
StorageLink = GetNextNode (&FormSet->StorageListHead, StorageLink);
}
return EFI_SUCCESS;
@ -587,7 +585,7 @@ UefiIfrGetBufferTypeDefaults (
{
FORM_BROWSER_FORMSET *FormSet;
EFI_GUID FormSetGuid;
LIST_ENTRY *DefaultListEntry;
LIST_ENTRY *DefaultLink;
FORMSET_DEFAULTSTORE *DefaultStore;
EFI_STATUS Status;
@ -604,14 +602,14 @@ UefiIfrGetBufferTypeDefaults (
ASSERT (UefiDefaults != NULL);
InitializeListHead (*UefiDefaults);
DefaultListEntry = GetFirstNode (&FormSet->DefaultStoreListHead);
while (!IsNull (&FormSet->DefaultStoreListHead, DefaultListEntry)) {
DefaultStore = FORMSET_DEFAULTSTORE_FROM_LINK(DefaultListEntry);
DefaultLink = GetFirstNode (&FormSet->DefaultStoreListHead);
while (!IsNull (&FormSet->DefaultStoreListHead, DefaultLink)) {
DefaultStore = FORMSET_DEFAULTSTORE_FROM_LINK(DefaultLink);
Status = GetBufferTypeDefaultId (DefaultStore, FormSet, *UefiDefaults);
ASSERT_EFI_ERROR (Status);
DefaultListEntry = GetNextNode (&FormSet->DefaultStoreListHead, DefaultListEntry);
DefaultLink = GetNextNode (&FormSet->DefaultStoreListHead, DefaultLink);
}
DestroyFormSet (FormSet);
@ -640,7 +638,7 @@ UefiIfrGetBufferTypeDefaults (
FRAMEWORK_EFI_IFR_FLAG_MANUFACTURING.
**/
EFI_STATUS
UefiDefaultsToFrameworkDefaults (
UefiDefaultsToFwDefaults (
IN LIST_ENTRY *ListHead,
IN UINTN DefaultMask,
OUT EFI_HII_VARIABLE_PACK_LIST **VariablePackList
@ -758,19 +756,19 @@ FreeDefaultList (
IN LIST_ENTRY *ListHead
)
{
LIST_ENTRY *Node;
LIST_ENTRY *Link;
UEFI_IFR_BUFFER_STORAGE_NODE *Default;
Node = GetFirstNode (ListHead);
Link = GetFirstNode (ListHead);
while (!IsNull (ListHead, Node)) {
Default = UEFI_IFR_BUFFER_STORAGE_NODE_FROM_LIST(Node);
while (!IsNull (ListHead, Link)) {
Default = UEFI_IFR_BUFFER_STORAGE_NODE_FROM_LIST(Link);
RemoveEntryList (Node);
RemoveEntryList (Link);
DestroyDefaultNode (Default);
Node = GetFirstNode (ListHead);
Link = GetNextNode (ListHead, Link);
}
FreePool (ListHead);

View File

@ -18,11 +18,12 @@
//
// VARSTORE ID of 0 for Buffer Storage Type Storage is reserved in UEFI IFR form. But VARSTORE ID
// 0 in Framework IFR is the default VarStore ID for storage without explicit declaration. So we have
// to reseved 0xFFEE in UEFI VARSTORE ID to represetn default storage id in Framework IFR.
// to reseved 0x0001 in UEFI VARSTORE ID to represetn default storage id in Framework IFR.
// Framework VFR has to be ported or pre-processed to change the default VARSTORE to a VARSTORE
// with ID equal to 0xFFEE.
// with ID equal to 0x0001.
//
#define RESERVED_VARSTORE_ID 0xFFEE
#define RESERVED_VARSTORE_ID 0x0001
#define RESERVED_QUESTION_ID 0xf000
#define UEFI_IFR_BUFFER_STORAGE_NODE_FROM_LIST(a) CR(a, UEFI_IFR_BUFFER_STORAGE_NODE, List, UEFI_IFR_BUFFER_STORAGE_NODE_SIGNATURE)
#define UEFI_IFR_BUFFER_STORAGE_NODE_SIGNATURE EFI_SIGNATURE_32 ('I', 'b', 'S', 'n')
@ -79,7 +80,7 @@ UefiIfrGetBufferTypeDefaults (
**/
EFI_STATUS
UefiDefaultsToFrameworkDefaults (
UefiDefaultsToFwDefaults (
IN LIST_ENTRY *UefiIfrDefaults,
IN UINTN DefaultMask,
OUT EFI_HII_VARIABLE_PACK_LIST **VariablePackList

View File

@ -28,7 +28,6 @@ FORM_EXPRESSION *mSuppressExpression;
FORM_EXPRESSION *mGrayOutExpression;
EFI_GUID gZeroGuid = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
EFI_GUID gTianoHiiIfrGuid = EFI_IFR_TIANO_GUID;
/**
Initialize Statement header members.

View File

@ -19,10 +19,6 @@
#include <PiDxe.h>
#include <Protocol/Print.h>
//#include <Protocol/SimpleTextOut.h>
//#include <Protocol/SimpleTextIn.h>
//#include <Protocol/FormBrowser2.h>
//#include <Protocol/DevicePath.h>
#include <Protocol/HiiConfigAccess.h>
#include <Protocol/HiiConfigRouting.h>
#include <Protocol/HiiDatabase.h>
@ -46,6 +42,8 @@
#define FORM_INCONSISTENT_VALIDATION 0
#define FORM_NO_SUBMIT_VALIDATION 1
extern EFI_GUID gTianoHiiIfrGuid;
typedef struct {
UINT8 Type;

View File

@ -33,7 +33,6 @@
// Extern Variables
//
extern CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
extern CONST EFI_HII_FONT_PROTOCOL *mHiiFontProtocol;
extern CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol;
extern CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol;
extern CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol;

View File

@ -16,13 +16,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "HiiDatabase.h"
EFI_GUID gFrameworkHiiCompatbilityGuid = EFI_IFR_FRAMEWORK_GUID;
EFI_GUID gTianoHiiIfrGuid = EFI_IFR_TIANO_GUID;
EFI_GUID *
GetGuidOfFirstFormset (
CONST EFI_HII_FORM_PACKAGE * FormPackage
)
{
UINT8 *StartOfNextPackage;
EFI_IFR_OP_HEADER *OpCodeData;
UINT8 *StartOfNextPackage;
EFI_IFR_OP_HEADER *OpCodeData;
StartOfNextPackage = (UINT8 *) FormPackage + FormPackage->Header.Length;
OpCodeData = (EFI_IFR_OP_HEADER *) (FormPackage + 1);
@ -40,138 +44,430 @@ GetGuidOfFirstFormset (
}
EFI_HII_HANDLE
FrameworkHiiHandleToUefiHiiHandle (
IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private,
IN FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle
FwHiiHandleToUefiHiiHandle (
IN CONST HII_THUNK_PRIVATE_DATA *Private,
IN FRAMEWORK_EFI_HII_HANDLE FwHiiHandle
)
{
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
HII_THUNK_CONTEXT *ThunkContext;
ASSERT (FrameworkHiiHandle != (FRAMEWORK_EFI_HII_HANDLE) 0);
ASSERT (FwHiiHandle != (FRAMEWORK_EFI_HII_HANDLE) 0);
ASSERT (Private != NULL);
HandleMapEntry = FrameworkHiiHandleToMapDatabaseEntry (Private, FrameworkHiiHandle);
ThunkContext = FwHiiHandleToThunkContext (Private, FwHiiHandle);
if (HandleMapEntry != NULL) {
return HandleMapEntry->UefiHiiHandle;
if (ThunkContext != NULL) {
return ThunkContext->UefiHiiHandle;
}
return (EFI_HII_HANDLE) NULL;
}
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *
FrameworkHiiHandleToMapDatabaseEntry (
IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private,
IN FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle
HII_THUNK_CONTEXT *
FwHiiHandleToThunkContext (
IN CONST HII_THUNK_PRIVATE_DATA *Private,
IN FRAMEWORK_EFI_HII_HANDLE FwHiiHandle
)
{
LIST_ENTRY *ListEntry;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
LIST_ENTRY *Link;
HII_THUNK_CONTEXT *ThunkContext;
for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;
ListEntry != &Private->HiiThunkHandleMappingDBListHead;
ListEntry = ListEntry->ForwardLink
) {
HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry);
if (FrameworkHiiHandle == HandleMapEntry->FrameworkHiiHandle) {
return HandleMapEntry;
Link = GetFirstNode (&Private->ThunkContextListHead);
while (!IsNull (&Private->ThunkContextListHead, Link)) {
ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
if (FwHiiHandle == ThunkContext->FwHiiHandle) {
return ThunkContext;
}
Link = GetNextNode (&Private->ThunkContextListHead, Link);
}
return (HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *) NULL;
return NULL;
}
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *
UefiHiiHandleToMapDatabaseEntry (
IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private,
HII_THUNK_CONTEXT *
UefiHiiHandleToThunkContext (
IN CONST HII_THUNK_PRIVATE_DATA *Private,
IN EFI_HII_HANDLE UefiHiiHandle
)
{
LIST_ENTRY *ListEntry;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
LIST_ENTRY *Link;
HII_THUNK_CONTEXT *ThunkContext;
for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;
ListEntry != &Private->HiiThunkHandleMappingDBListHead;
ListEntry = ListEntry->ForwardLink
) {
HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry);
Link = GetFirstNode (&Private->ThunkContextListHead);
if (UefiHiiHandle == HandleMapEntry->UefiHiiHandle) {
return HandleMapEntry;
while (!IsNull (&Private->ThunkContextListHead, Link)) {
ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
if (UefiHiiHandle == ThunkContext->UefiHiiHandle) {
return ThunkContext;
}
Link = GetNextNode (&Private->ThunkContextListHead, Link);
}
return (HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *) NULL;
return NULL;
}
EFI_HII_HANDLE *
TagGuidToUefiIfrHiiHandle (
IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private,
TagGuidToUefiHiiHandle (
IN CONST HII_THUNK_PRIVATE_DATA *Private,
IN CONST EFI_GUID *Guid
)
{
LIST_ENTRY *ListEntry;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry;
LIST_ENTRY *Link;
HII_THUNK_CONTEXT *ThunkContext;
for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink;
ListEntry != &Private->HiiThunkHandleMappingDBListHead;
ListEntry = ListEntry->ForwardLink
) {
HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry);
Link = GetFirstNode (&Private->ThunkContextListHead);
if (CompareGuid (Guid, &HandleMapEntry->TagGuid) && HandleMapEntry->DoesPackageListImportStringPackages) {
return HandleMapEntry->UefiHiiHandle;
while (!IsNull (&Private->ThunkContextListHead, Link)) {
ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
if (CompareGuid (Guid, &ThunkContext->TagGuid) && (ThunkContext->IfrPackageCount != 0)) {
return ThunkContext->UefiHiiHandle;
}
Link = GetNextNode (&Private->ThunkContextListHead, Link);
}
return (EFI_HII_HANDLE *) NULL;
return NULL;
}
BOOLEAN
IsFrameworkHiiDatabaseHandleDepleted (
IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private
IN CONST HII_THUNK_PRIVATE_DATA *Private
)
{
return (BOOLEAN) (Private->StaticHiiHandle == (UINTN) Private->StaticPureUefiHiiHandle);
}
EFI_STATUS
AssignHiiHandle (
IN OUT EFI_HII_THUNK_PRIVATE_DATA *Private,
AssignFrameworkHiiHandle (
IN OUT HII_THUNK_PRIVATE_DATA *Private,
IN BOOLEAN FromFwHiiNewPack,
OUT FRAMEWORK_EFI_HII_HANDLE *Handle
)
{
ASSERT (Handle != NULL);
*Handle = Private->StaticHiiHandle;
Private->StaticHiiHandle += 1;
if (FromFwHiiNewPack) {
*Handle = Private->StaticHiiHandle;
Private->StaticHiiHandle += 1;
if (IsFrameworkHiiDatabaseHandleDepleted (Private)) {
return EFI_OUT_OF_RESOURCES;
}
} else {
*Handle = Private->StaticPureUefiHiiHandle;
Private->StaticPureUefiHiiHandle -= 1;
if (IsFrameworkHiiDatabaseHandleDepleted (Private)) {
return EFI_OUT_OF_RESOURCES;
}
if (IsFrameworkHiiDatabaseHandleDepleted (Private)) {
return EFI_OUT_OF_RESOURCES;
}
return EFI_SUCCESS;
}
EFI_STATUS
AssignPureUefiHiiHandle (
IN OUT EFI_HII_THUNK_PRIVATE_DATA *Private,
OUT FRAMEWORK_EFI_HII_HANDLE *Handle
)
DestroyThunkContextForUefiHiiHandle (
IN HII_THUNK_PRIVATE_DATA *Private,
IN EFI_HII_HANDLE UefiHiiHandle
)
{
ASSERT (Handle != NULL);
HII_THUNK_CONTEXT *ThunkContext;
*Handle = Private->StaticPureUefiHiiHandle;
Private->StaticPureUefiHiiHandle -= 1;
ThunkContext = UefiHiiHandleToThunkContext (Private, UefiHiiHandle);
ASSERT (ThunkContext != NULL);
if (IsFrameworkHiiDatabaseHandleDepleted (Private)) {
return EFI_OUT_OF_RESOURCES;
}
ASSERT (IsListEmpty (&ThunkContext->OneOfOptionMapListHead));
ASSERT (IsListEmpty (&ThunkContext->QuestionIdMapListHead));
RemoveEntryList (&ThunkContext->Link);
FreePool (ThunkContext);
return EFI_SUCCESS;
}
/**
This function create a HII_THUNK_CONTEXT for a package list registered
by a module calling EFI_HII_DATABASE_PROTOCOL.NewPackageList. It records
the PackageListGuid in EFI_HII_PACKAGE_LIST_HEADER in the TagGuid in
HII_THUNK_CONTEXT created. This TagGuid will be used as a key to s
**/
HII_THUNK_CONTEXT *
CreateThunkContextForUefiHiiHandle (
IN HII_THUNK_PRIVATE_DATA *Private,
IN EFI_HII_HANDLE UefiHiiHandle
)
{
EFI_STATUS Status;
EFI_GUID PackageGuid;
HII_THUNK_CONTEXT *ThunkContext;
ThunkContext = AllocateZeroPool (sizeof (*ThunkContext));
ASSERT (ThunkContext != NULL);
ThunkContext->Signature = HII_THUNK_CONTEXT_SIGNATURE;
Status = AssignFrameworkHiiHandle (Private, FALSE, &ThunkContext->FwHiiHandle);
if (EFI_ERROR (Status)) {
return NULL;
}
ThunkContext->UefiHiiHandle = UefiHiiHandle;
Status = HiiLibExtractGuidFromHiiHandle (UefiHiiHandle, &PackageGuid);
ASSERT_EFI_ERROR (Status);
CopyGuid(&ThunkContext->TagGuid, &PackageGuid);
InitializeListHead (&ThunkContext->QuestionIdMapListHead);
InitializeListHead (&ThunkContext->OneOfOptionMapListHead);
InsertTailList (&Private->ThunkContextListHead, &ThunkContext->Link);
return ThunkContext;
}
UINTN
GetPackageCountByType (
IN CONST EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader,
IN UINT8 PackageType
)
{
UINTN Count;
EFI_HII_PACKAGE_HEADER *PackageHeader;
PackageHeader = (EFI_HII_PACKAGE_HEADER *) ((UINT8 *) PackageListHeader + sizeof (EFI_HII_PACKAGE_LIST_HEADER));
Count = 0;
while (PackageHeader->Type != EFI_HII_PACKAGE_END) {
if (PackageHeader->Type == PackageType ) {
Count++;
}
PackageHeader = (EFI_HII_PACKAGE_HEADER *) ((UINT8 *) PackageHeader + PackageHeader->Length);
}
return Count;
}
LIST_ENTRY *
GetOneOfOptionMapEntryListHead (
IN CONST HII_THUNK_CONTEXT *ThunkContext,
IN UINT16 QuestionId
)
{
LIST_ENTRY *Link;
ONE_OF_OPTION_MAP *Map;
Link = GetFirstNode (&ThunkContext->OneOfOptionMapListHead);
while (!IsNull (&ThunkContext->OneOfOptionMapListHead, Link)) {
Map = ONE_OF_OPTION_MAP_FROM_LINK (Link);
if (QuestionId == Map->QuestionId) {
return &Map->OneOfOptionMapEntryListHead;
}
Link = GetNextNode (&ThunkContext->OneOfOptionMapListHead, Link);
}
return NULL;
}
EFI_STATUS
CreateQuestionIdMap (
IN OUT HII_THUNK_CONTEXT *ThunkContext
)
{
EFI_STATUS Status;
EFI_HII_PACKAGE_LIST_HEADER *List;
EFI_HII_PACKAGE_HEADER *Package;
UINTN Size;
EFI_IFR_OP_HEADER *OpCode;
UINTN Offset;
QUESTION_ID_MAP *IdMap;
EFI_IFR_VARSTORE *VarStore;
EFI_IFR_FORM_SET *FormSet;
EFI_IFR_QUESTION_HEADER *Question;
LIST_ENTRY *QuestionIdMapEntryListHead;
LIST_ENTRY *OneOfOptinMapEntryListHead;
QUESTION_ID_MAP_ENTRY *IdMapEntry;
EFI_IFR_GUID_OPTIONKEY *OptionMap;
ONE_OF_OPTION_MAP *OneOfOptionMap;
ONE_OF_OPTION_MAP_ENTRY *OneOfOptionMapEntry;
EFI_IFR_GUID_CLASS *Class;
Status = HiiLibExportPackageLists (ThunkContext->UefiHiiHandle, &List, &Size);
if (EFI_ERROR (Status)) {
return Status;
}
//
// Get all VarStoreId and build the the QuestionId map.
// EFI_IFR_QUESTION_HEADER.VarStoreInfo.VarOffset -> Framework Question ID
// EFI_IFR_QUESTION_HEADER.QuestionId -> UEFI Question ID
//
//
// Skip the package list header.
//
Package = (EFI_HII_PACKAGE_HEADER *) (List + 1);
while (Package->Type != EFI_HII_PACKAGE_END) {
if (Package->Type == EFI_HII_PACKAGE_FORM) {
//
// Skip the package header
//
Offset = sizeof (EFI_HII_PACKAGE_HEADER);
while (Offset < Package->Length) {
OpCode = (EFI_IFR_OP_HEADER *)((UINT8 *) Package + Offset);
switch (OpCode->OpCode) {
case EFI_IFR_FORM_SET_OP:
FormSet = (EFI_IFR_FORM_SET *) OpCode;
ThunkContext->FormSetTitle = FormSet->FormSetTitle;
ThunkContext->FormSetHelp = FormSet->Help;
break;
case EFI_IFR_VARSTORE_OP:
//
// IFR built from Framework VFR only has UEFI Buffer Type Storage
//
VarStore = (EFI_IFR_VARSTORE *) OpCode;
IdMap = AllocateZeroPool (sizeof (QUESTION_ID_MAP));
ASSERT (IdMap != NULL);
IdMap->Signature = QUESTION_ID_MAP_SIGNATURE;
IdMap->VarStoreId = VarStore->VarStoreId;
IdMap->VarSize = VarStore->Size;
InitializeListHead (&IdMap->MapEntryListHead);
InsertTailList (&ThunkContext->QuestionIdMapListHead, &IdMap->Link);
break;
case EFI_IFR_NUMERIC_OP:
case EFI_IFR_CHECKBOX_OP:
case EFI_IFR_ONE_OF_OP:
case EFI_IFR_ORDERED_LIST_OP:
case EFI_IFR_STRING_OP:
//case EFI_IFR_PASSWORD_OP:
Question = (EFI_IFR_QUESTION_HEADER *)(OpCode + 1);
QuestionIdMapEntryListHead = GetMapEntryListHead (ThunkContext, Question->VarStoreId);
if (QuestionIdMapEntryListHead != NULL) {
//
// If the Question is using Buffer (EFI_IFR_VARSTORE_OP) type VarStore.
//
IdMapEntry = AllocateZeroPool (sizeof (QUESTION_ID_MAP_ENTRY));
ASSERT (IdMapEntry != NULL);
IdMapEntry->FwQId = Question->VarStoreInfo.VarOffset;
IdMapEntry->UefiQid = Question->QuestionId;
IdMapEntry->Signature = QUESTION_ID_MAP_ENTRY_SIGNATURE;
InsertTailList (QuestionIdMapEntryListHead, &IdMapEntry->Link);
}
break;
case EFI_IFR_GUID_OP:
OptionMap = (EFI_IFR_GUID_OPTIONKEY *) OpCode;
if (CompareGuid (&OptionMap->Guid, &gFrameworkHiiCompatbilityGuid)) {
if (OptionMap->ExtendOpCode == EFI_IFR_EXTEND_OP_OPTIONKEY) {
OneOfOptinMapEntryListHead = GetOneOfOptionMapEntryListHead (ThunkContext, OptionMap->QuestionId);
if (OneOfOptinMapEntryListHead == NULL) {
OneOfOptionMap = AllocateZeroPool (sizeof (ONE_OF_OPTION_MAP));
ASSERT (OneOfOptionMap != NULL);
OneOfOptionMap->Signature = ONE_OF_OPTION_MAP_SIGNATURE;
OneOfOptionMap->QuestionId = OptionMap->QuestionId;
OneOfOptionMap->ValueType = EFI_IFR_TYPE_NUM_SIZE_8;
InitializeListHead (&OneOfOptionMap->OneOfOptionMapEntryListHead);
OneOfOptinMapEntryListHead = &OneOfOptionMap->OneOfOptionMapEntryListHead;
InsertTailList (&ThunkContext->OneOfOptionMapListHead, &OneOfOptionMap->Link);
}
OneOfOptionMapEntry = AllocateZeroPool (sizeof (ONE_OF_OPTION_MAP_ENTRY));
ASSERT (OneOfOptionMapEntry != NULL);
OneOfOptionMapEntry->Signature = ONE_OF_OPTION_MAP_ENTRY_SIGNATURE;
OneOfOptionMapEntry->FwKey = OptionMap->KeyValue;
CopyMem (&OneOfOptionMapEntry->Value, &OptionMap->OptionValue, sizeof (EFI_IFR_TYPE_VALUE));
InsertTailList (OneOfOptinMapEntryListHead, &OneOfOptionMapEntry->Link);
}
}else if (CompareGuid (&OptionMap->Guid, &gTianoHiiIfrGuid)) {
Class = (EFI_IFR_GUID_CLASS *) OpCode;
switch (Class->ExtendOpCode) {
case EFI_IFR_EXTEND_OP_CLASS:
ThunkContext->FormSetClass = Class->Class;
break;
case EFI_IFR_EXTEND_OP_SUBCLASS:
ThunkContext->FormSetSubClass = ((EFI_IFR_GUID_SUBCLASS *) Class)->SubClass;
break;
default:
break;
}
}
break;
default:
break;
}
Offset += OpCode->Length;
}
//
// Only Form Package is in a Package List.
//
break;
}
Package = (EFI_HII_PACKAGE_HEADER *) (UINT8 *) Package + Package->Length;
}
FreePool (List);
return EFI_SUCCESS;
}
LIST_ENTRY *
GetMapEntryListHead (
IN CONST HII_THUNK_CONTEXT *ThunkContext,
IN UINT16 VarStoreId
)
{
LIST_ENTRY *Link;
QUESTION_ID_MAP *Map;
Link = GetFirstNode (&ThunkContext->QuestionIdMapListHead);
while (!IsNull (&ThunkContext->QuestionIdMapListHead, Link)) {
Map = QUESTION_ID_MAP_FROM_LINK (Link);
if (VarStoreId == Map->VarStoreId) {
return &Map->MapEntryListHead;
}
Link = GetNextNode (&ThunkContext->QuestionIdMapListHead, Link);
}
return NULL;
}

View File

@ -26,51 +26,80 @@ GetGuidOfFirstFormset (
the HII Thunk to Framework HII code.
@param Private The pointer to the private data of Hii Thunk.
@param FrameworkHiiHandle Framework HII Handle returned by the HII Thunk to Framework HII code.
@param FwHiiHandle Framework HII Handle returned by the HII Thunk to Framework HII code.
@retval NULL If Framework HII Handle passed in does not have matching UEFI HII handle.
@retval !NULL If the match is found.
**/
EFI_HII_HANDLE
FrameworkHiiHandleToUefiHiiHandle (
IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private,
IN FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle
FwHiiHandleToUefiHiiHandle (
IN CONST HII_THUNK_PRIVATE_DATA *Private,
IN FRAMEWORK_EFI_HII_HANDLE FwHiiHandle
)
;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *
FrameworkHiiHandleToMapDatabaseEntry (
IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private,
IN FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle
HII_THUNK_CONTEXT *
FwHiiHandleToThunkContext (
IN CONST HII_THUNK_PRIVATE_DATA *Private,
IN FRAMEWORK_EFI_HII_HANDLE FwHiiHandle
)
;
HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *
UefiHiiHandleToMapDatabaseEntry (
IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private,
HII_THUNK_CONTEXT *
UefiHiiHandleToThunkContext (
IN CONST HII_THUNK_PRIVATE_DATA *Private,
IN EFI_HII_HANDLE UefiHiiHandle
)
;
EFI_HII_HANDLE *
TagGuidToUefiIfrHiiHandle (
IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private,
TagGuidToUefiHiiHandle (
IN CONST HII_THUNK_PRIVATE_DATA *Private,
IN CONST EFI_GUID *Guid
)
;
EFI_STATUS
AssignHiiHandle (
IN OUT EFI_HII_THUNK_PRIVATE_DATA *Private,
AssignFrameworkHiiHandle (
IN OUT HII_THUNK_PRIVATE_DATA *Private,
IN BOOLEAN FromFwHiiNewPack,
OUT FRAMEWORK_EFI_HII_HANDLE *Handle
)
;
HII_THUNK_CONTEXT *
CreateThunkContextForUefiHiiHandle (
IN HII_THUNK_PRIVATE_DATA *Private,
IN EFI_HII_HANDLE UefiHiiHandle
)
;
EFI_STATUS
AssignPureUefiHiiHandle (
IN OUT EFI_HII_THUNK_PRIVATE_DATA *Private,
OUT FRAMEWORK_EFI_HII_HANDLE *Handle
DestroyThunkContextForUefiHiiHandle (
IN HII_THUNK_PRIVATE_DATA *Private,
IN EFI_HII_HANDLE UefiHiiHandle
)
;
UINTN
GetPackageCountByType (
IN CONST EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader,
IN UINT8 PackageType
)
;
EFI_STATUS
CreateQuestionIdMap (
IN OUT HII_THUNK_CONTEXT *ThunkContext
)
;
LIST_ENTRY *
GetMapEntryListHead (
IN CONST HII_THUNK_CONTEXT *ThunkContext,
IN UINT16 VarStoreId
)
;
#endif