summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-08-18 05:56:23 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-08-18 05:56:23 +0000
commit0368663fd609e2e008031a2025693f190d19b0c7 (patch)
treec6bc48d410d8f397b9dc8749bf19aede404cc13f /EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c
parent0514e9c3c9b46f74c232942759388c46ed89802a (diff)
downloadedk2-platforms-0368663fd609e2e008031a2025693f190d19b0c7.tar.xz
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
Diffstat (limited to 'EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c')
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c712
1 files changed, 489 insertions, 223 deletions
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c
index bac07de530..88565d128c 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c
@@ -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;
}
-/**
+VOID
+DestroyBufferStorageList (
+ IN LIST_ENTRY *ListHead
+ )
+{
+ LIST_ENTRY *Link;
+ BUFFER_STORAGE_ENTRY *Entry;
- 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
+ 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;
- BOOLEAN ResetRequired;
+ 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);
- 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;
}
+
/**
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;
}