summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-11-10 12:40:07 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-11-10 12:40:07 +0000
commita9d853203d836fcfca399660fdb0c17e3d1f4052 (patch)
tree6b699b5562f2ad565f5fbdcfd01baa742ba9972a /EdkCompatibilityPkg
parent4f1afaacb283542ee1fdf14602c5d2f44a79de5c (diff)
downloadedk2-platforms-a9d853203d836fcfca399660fdb0c17e3d1f4052.tar.xz
1) Add in support for Framework VFR file which specify all VAR Store correctly. This patch enable the ThunkExtractConfig and ThunkRounteConfig to handle more than one VAR Storage based on the VARSTORE ID specified.
2) Remove the unnecessary data structure defined for IFR Parser. 1) All data structure definition that have nothing to do with IFR Default value scanning ( required to implement Framework HII's GetDefaultImage ()) is removed. 2) Ignore the IFR opcode which is invalid for Form Package generated using Framework VFR file. 3) Remove unnecessary files. 4) Add in Doxygen function header for all functions. git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6440 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg')
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c546
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Fonts.c64
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Forms.c95
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/FrameworkHiiToUefiHiiThunk.inf6
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h43
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Keyboard.c20
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.c236
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.h1
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c142
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/SetupBrowser.c40
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.c263
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.h5
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrParser.c769
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrParser.h99
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrParserExpression.c1596
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c674
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h12
17 files changed, 1233 insertions, 3378 deletions
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c
index 589b98b2e4..66bd438469 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c
@@ -1,8 +1,7 @@
-
/**@file
- This file contains functions related to Config Access Protocols installed by
- by HII Thunk Modules which is used to thunk UEFI Config Access Callback to
- Framework HII Callback.
+ This file implements functions related to Config Access Protocols installed by
+ by HII Thunk Modules. These Config access Protocols are used to thunk UEFI Config
+ Access Callback to Framework HII Callback and EFI Variable Set/Get operations.
Copyright (c) 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
@@ -16,8 +15,9 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
#include "HiiDatabase.h"
+#include "UefiIfrParser.h"
-BOOLEAN mHiiPackageListUpdated;
+BOOLEAN mHiiPackageListUpdated = FALSE;
CONFIG_ACCESS_PRIVATE gConfigAccessPrivateTempate = {
CONFIG_ACCESS_PRIVATE_SIGNATURE,
@@ -27,154 +27,157 @@ CONFIG_ACCESS_PRIVATE gConfigAccessPrivateTempate = {
ThunkCallback
}, //ConfigAccessProtocol
NULL, //FormCallbackProtocol
- {NULL, NULL}, //ConfigAccessStorageListHead
NULL
};
/**
- Find and return the pointer to Package Header of the Form package
- in the Framework Package List. The Framework Package List is created
- by a module calling the Framework HII interface.
- The Framwork Package List contains package data
- generated by Intel's UEFI VFR Compiler and String gather tool. The data format
- of the package data is defined by TIANO_AUTOGEN_PACKAGES_HEADER.
-
- If the package list contains other type of packages such as KEYBOARD_LAYOUT,
- FONTS and IMAGES, the ASSERT. This is to make sure the caller is a
- Framework Module which does not include packages introduced by UEFI Specification
- or packages that is not supported by Thunk layer.
+ Get the first EFI_IFR_VARSTORE from the FormSet.
+
+ @param FormSet The Form Set.
+
+ @retval FORMSET_STORAGE * Return the first EFI_IFR_VARSTORE.
+ @retval NULL If the Form Set does not have EFI_IFR_VARSTORE.
+**/
+FORMSET_STORAGE *
+GetFirstStorageOfFormSet (
+ IN CONST FORM_BROWSER_FORMSET * FormSet
+ )
+{
+ LIST_ENTRY *StorageList;
+ FORMSET_STORAGE *Storage;
+
+ StorageList = GetFirstNode (&FormSet->StorageListHead);
+
+ if (!IsNull (&FormSet->StorageListHead, StorageList)) {
+ Storage = FORMSET_STORAGE_FROM_LINK (StorageList);
+ return Storage;
+ }
+
+ return NULL;
+}
+
+/**
+ Get the EFI_IFR_VARSTORE where the Question's value is stored.
- @param Packages The Framework Package List
+ @param FormSet The Form Set.
- @retval EFI_HII_PACKAGE_HEADER* Return the Package Header of Form Package.
- @retval NULL If no Form Package is found.
+ @retval FORMSET_STORAGE * The EFI_IFR_VARSTORE where the Question's value is stored.
+ @retval NULL If the Form Set does not have EFI_IFR_VARSTORE.
**/
-EFI_HII_PACKAGE_HEADER *
-GetIfrFormSet (
- IN CONST EFI_HII_PACKAGES *Packages
+FORMSET_STORAGE *
+GetStorageFromQuestionId (
+ IN CONST FORM_BROWSER_FORMSET * FormSet,
+ IN EFI_QUESTION_ID QuestionId
)
{
- TIANO_AUTOGEN_PACKAGES_HEADER **TianoAutogenPackageHdrArray;
- EFI_HII_PACKAGE_HEADER *IfrPackage;
- UINTN Index;
+ LIST_ENTRY *FormList;
+ LIST_ENTRY *StatementList;
+ FORM_BROWSER_FORM *Form;
+ FORM_BROWSER_STATEMENT *Statement;
+
+ FormList = GetFirstNode (&FormSet->FormListHead);
+
+ while (!IsNull (&FormSet->FormListHead, FormList)) {
+ Form = FORM_BROWSER_FORM_FROM_LINK (FormList);
+
+ StatementList = GetFirstNode (&Form->StatementListHead);
+
+ while (!IsNull (&Form->StatementListHead, StatementList)) {
+ Statement = FORM_BROWSER_STATEMENT_FROM_LINK (StatementList);
+ if ((QuestionId == Statement->QuestionId) && (Statement->Storage != NULL)) {
+ //
+ // UEFI Question ID is unique in a FormSet.
+ //
+ ASSERT (Statement->Storage->Type == EFI_HII_VARSTORE_BUFFER);
+ return Statement->Storage;
+ }
+ StatementList = GetNextNode (&Form->StatementListHead, StatementList);
+ }
- ASSERT (Packages != NULL);
+ FormList = GetNextNode (&FormSet->FormListHead, FormList);
+ }
+
+ return NULL;
+}
- IfrPackage = NULL;
+/**
+ Get the EFI_IFR_VARSTORE based the ID.
+
+ @param FormSet The Form Set.
+
+ @retval FORMSET_STORAGE * The EFI_IFR_VARSTORE with the ID.
+ @retval NULL If the Form Set does not have EFI_IFR_VARSTORE with such ID.
+**/
+FORMSET_STORAGE *
+GetStorageFromVarStoreId (
+ IN CONST FORM_BROWSER_FORMSET * FormSet,
+ IN EFI_VARSTORE_ID VarStoreId
+ )
+{
+ LIST_ENTRY *StorageList;
+ FORMSET_STORAGE *Storage;
- 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
- // 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_FORMS:
- return &TianoAutogenPackageHdrArray[Index]->PackageHeader;
- break;
+ StorageList = GetFirstNode (&FormSet->StorageListHead);
- case EFI_HII_PACKAGE_STRINGS:
- case EFI_HII_PACKAGE_SIMPLE_FONTS:
- break;
+ while (!IsNull (&FormSet->StorageListHead, StorageList)) {
+ Storage = FORMSET_STORAGE_FROM_LINK (StorageList);
- //
- // The following fonts are invalid for a module that using Framework to UEFI thunk layer.
- //
- case EFI_HII_PACKAGE_KEYBOARD_LAYOUT:
- case EFI_HII_PACKAGE_FONTS:
- case EFI_HII_PACKAGE_IMAGES:
- default:
- ASSERT (FALSE);
- break;
+ if (VarStoreId == Storage->VarStoreId) {
+ return Storage;
}
- }
- return (EFI_HII_PACKAGE_HEADER *) NULL;
+ StorageList = GetNextNode (&FormSet->StorageListHead, StorageList);
+ }
+
+ return NULL;
}
/**
- This function scan EFI_IFR_VARSTORE_OP in the Form Package.
- It create entries for these VARSTORE found and append the entry
- to a Link List.
-
- 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 BufferStorageListHead The link list for the VARSTORE found in the form package.
+ Get the EFI_IFR_VARSTORE based the <ConfigHdr> string in a <ConfigRequest>
+ or a <ConfigResp> string.
+
+ @param FormSet The Form Set.
+ @param ConfigString The Configuration String which is defined by UEFI HII.
- @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.
+ @retval FORMSET_STORAGE * The EFI_IFR_VARSTORE where the Question's value is stored.
+ @retval NULL If the Form Set does not have EFI_IFR_VARSTORE with such ID.
**/
-EFI_STATUS
-GetBufferStorage (
- IN CONST EFI_HII_PACKAGE_HEADER *FormSetPackage,
- OUT LIST_ENTRY *BufferStorageListHead
+FORMSET_STORAGE *
+GetStorageFromConfigString (
+ IN CONST FORM_BROWSER_FORMSET *FormSet,
+ IN CONST EFI_STRING ConfigString
)
{
- UINTN OpCodeOffset;
- UINTN OpCodeLength;
- UINT8 *OpCodeData;
- UINT8 Operand;
- EFI_IFR_VARSTORE *VarStoreOpCode;
- BUFFER_STORAGE_ENTRY *BufferStorage;
-
- ASSERT (FormSetPackage->Type == EFI_HII_PACKAGE_FORMS);
-
- 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;
-
- OpCodeLength = ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
- OpCodeOffset += OpCodeLength;
- Operand = ((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode;
-
- if (Operand == EFI_IFR_VARSTORE_OP) {
- VarStoreOpCode = (EFI_IFR_VARSTORE *)OpCodeData;
- BufferStorage = AllocateZeroPool (sizeof (*BufferStorage));
- if (BufferStorage == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- //
- // Record the attributes: GUID, Name, VarStoreId and Size.
- //
- CopyMem (&BufferStorage->Guid, &VarStoreOpCode->Guid, sizeof (EFI_GUID));
-
- BufferStorage->Name = AllocateZeroPool (AsciiStrSize (VarStoreOpCode->Name) * 2);
- AsciiStrToUnicodeStr (VarStoreOpCode->Name, BufferStorage->Name);
+ LIST_ENTRY *StorageList;
+ FORMSET_STORAGE *Storage;
- BufferStorage->VarStoreId = VarStoreOpCode->VarStoreId;
+ StorageList = GetFirstNode (&FormSet->StorageListHead);
- BufferStorage->Size = VarStoreOpCode->Size;
- BufferStorage->Signature = BUFFER_STORAGE_ENTRY_SIGNATURE;
+ while (!IsNull (&FormSet->StorageListHead, StorageList)) {
+ Storage = FORMSET_STORAGE_FROM_LINK (StorageList);
- InsertTailList (BufferStorageListHead, &BufferStorage->Link);
+ if (IsConfigHdrMatch (ConfigString, &Storage->Guid, Storage->Name)) {
+ return Storage;
}
+
+ StorageList = GetNextNode (&FormSet->StorageListHead, StorageList);
}
- return EFI_SUCCESS;
+ return NULL;
}
-
/**
This function installs a EFI_CONFIG_ACCESS_PROTOCOL instance for a form package registered
by a module using Framework HII Protocol Interfaces.
- 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.
+ 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 ThunkContext The Thunk Layer Handle Mapping Database Entry.
+ @param Packages The Package List.
+ @param ThunkContext The Thunk Context.
- @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
@@ -183,73 +186,42 @@ InstallDefaultConfigAccessProtocol (
IN OUT HII_THUNK_CONTEXT *ThunkContext
)
{
- EFI_HII_PACKAGE_HEADER *FormSetPackage;
EFI_STATUS Status;
CONFIG_ACCESS_PRIVATE *ConfigAccessInstance;
+ ASSERT (ThunkContext->IfrPackageCount != 0);
+
Status = HiiLibCreateHiiDriverHandle (&ThunkContext->UefiHiiDriverHandle);
+ ASSERT_EFI_ERROR (Status);
+
ConfigAccessInstance = AllocateCopyPool (
sizeof (CONFIG_ACCESS_PRIVATE),
&gConfigAccessPrivateTempate
);
ASSERT (ConfigAccessInstance != NULL);
- InitializeListHead (&ConfigAccessInstance->BufferStorageListHead);
-
- //
- // We assume there is only one formset package in each Forms Package
- //
- FormSetPackage = GetIfrFormSet (Packages);
- ASSERT (FormSetPackage != NULL);
-
- Status = GetBufferStorage (FormSetPackage, &ConfigAccessInstance->BufferStorageListHead);
- if (EFI_ERROR (Status)) {
- FreePool (ConfigAccessInstance);
- ASSERT (FALSE);
- return Status;
- }
-
Status = gBS->InstallMultipleProtocolInterfaces (
&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;
-
- while (!IsListEmpty (ListHead)) {
- Link = GetFirstNode (ListHead);
-
- Entry = BUFFER_STORAGE_ENTRY_FROM_LINK(Link);
-
- FreePool (Entry->Name);
- Link = RemoveEntryList (Link);
+/**
+ This function un-installs the EFI_CONFIG_ACCESS_PROTOCOL instance for a form package registered
+ by a module using Framework HII Protocol Interfaces.
- FreePool (Entry);
- }
-}
+ ASSERT if no Config Access is found for such pakcage list or failed to uninstall the protocol.
+ @param ThunkContext The Thunk Context.
+
+**/
VOID
UninstallDefaultConfigAccessProtocol (
IN HII_THUNK_CONTEXT *ThunkContext
@@ -266,7 +238,6 @@ UninstallDefaultConfigAccessProtocol (
&gEfiHiiConfigAccessProtocolGuid,
(VOID **) &ConfigAccess
);
-
ASSERT_EFI_ERROR (Status);
Status = gBS->UninstallProtocolInterface (
@@ -278,8 +249,6 @@ UninstallDefaultConfigAccessProtocol (
ConfigAccessInstance = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (ConfigAccess);
- DestroyBufferStorageList (&ConfigAccessInstance->BufferStorageListHead);
-
}
@@ -297,7 +266,7 @@ UninstallDefaultConfigAccessProtocol (
**/
EFI_STATUS
CallFormCallBack (
- IN BUFFER_STORAGE_ENTRY *BufferStorage,
+ IN FORMSET_STORAGE *BufferStorage,
IN EFI_FORM_CALLBACK_PROTOCOL *FwFormCallBack,
OUT VOID **Data,
OUT UINTN *DataSize
@@ -359,7 +328,7 @@ CallFormCallBack (
EFI_STATUS
GetUefiVariable (
- IN BUFFER_STORAGE_ENTRY *BufferStorage,
+ IN FORMSET_STORAGE *BufferStorage,
OUT VOID **Data,
OUT UINTN *DataSize
)
@@ -399,31 +368,6 @@ GetUefiVariable (
return Status;
}
-BUFFER_STORAGE_ENTRY *
-GetBufferStorageEntry (
- IN CONFIG_ACCESS_PRIVATE *ConfigAccess,
- IN UINT16 VarStoreId
- )
-{
- LIST_ENTRY *Link;
- BUFFER_STORAGE_ENTRY *BufferStorage;
-
- Link = GetFirstNode (&ConfigAccess->BufferStorageListHead);
-
- while (!IsNull (&ConfigAccess->BufferStorageListHead, Link)) {
- BufferStorage = BUFFER_STORAGE_ENTRY_FROM_LINK (Link);
-
- if (BufferStorage->VarStoreId == VarStoreId) {
- return BufferStorage;
- }
-
- Link = GetNextNode (&ConfigAccess->BufferStorageListHead, Link);
- }
-
- return NULL;
-}
-
-
/**
This function implement the EFI_HII_CONFIG_ACCESS_PROTOCOL.ExtractConfig
@@ -458,19 +402,19 @@ ThunkExtractConfig (
{
EFI_STATUS Status;
CONFIG_ACCESS_PRIVATE *ConfigAccess;
- BUFFER_STORAGE_ENTRY *BufferStorage;
+ FORMSET_STORAGE *BufferStorage;
VOID *Data;
UINTN DataSize;
Data = NULL;
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.
- //
- BufferStorage = GetBufferStorageEntry (ConfigAccess, (UINT16) RESERVED_VARSTORE_ID);
+ BufferStorage = GetStorageFromConfigString (ConfigAccess->ThunkContext->FormSet, Request);
if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
+ //
+ // NvMapOverride is not used. Get the Storage data from EFI Variable or Framework Form Callback.
+ //
if (ConfigAccess->FormCallbackProtocol == NULL ||
ConfigAccess->FormCallbackProtocol->NvRead == NULL) {
Status = GetUefiVariable (
@@ -487,6 +431,9 @@ ThunkExtractConfig (
);
}
} else {
+ //
+ // Use the NvMapOverride.
+ //
DataSize = BufferStorage->Size;
Data = AllocateCopyPool (DataSize, ConfigAccess->ThunkContext->NvMapOverride);
@@ -515,7 +462,6 @@ ThunkExtractConfig (
}
/**
-
This function implement the EFI_HII_CONFIG_ACCESS_PROTOCOL.RouteConfig
so that data can be written to the data storage such as UEFI Variable or module's
customized storage exposed by EFI_FRAMEWORK_CALLBACK.
@@ -540,7 +486,7 @@ ThunkRouteConfig (
{
EFI_STATUS Status;
CONFIG_ACCESS_PRIVATE *ConfigAccess;
- BUFFER_STORAGE_ENTRY *BufferStorage;
+ FORMSET_STORAGE *BufferStorage;
UINT8 *Data;
UINTN DataSize;
UINTN DataSize2;
@@ -551,10 +497,7 @@ ThunkRouteConfig (
Data = NULL;
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.
- //
- BufferStorage = GetBufferStorageEntry (ConfigAccess, (UINT16) RESERVED_VARSTORE_ID);
+ BufferStorage = GetStorageFromConfigString (ConfigAccess->ThunkContext->FormSet, Configuration);
DataSize2 = BufferStorage->Size;
if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
@@ -632,6 +575,21 @@ Done:
return Status;
}
+/**
+ Build the FRAMEWORK_EFI_IFR_DATA_ARRAY which will be used to pass to
+ EFI_FORM_CALLBACK_PROTOCOL.Callback. Check definition of FRAMEWORK_EFI_IFR_DATA_ARRAY
+ for details.
+
+ ASSERT if the Question Type is not EFI_IFR_TYPE_NUM_SIZE_* or EFI_IFR_TYPE_STRING.
+
+ @param This Points to the EFI_HII_CONFIG_ACCESS_PROTOCOL
+ @param QuestionId The Question ID.
+ @param Type The Question Type.
+ @param Value The Question Value.
+ @param NvMapAllocated On output indicates if a buffer is allocated for NvMap.
+
+ @return A pointer to FRAMEWORK_EFI_IFR_DATA_ARRAY. The caller must free this buffer allocated.
+**/
FRAMEWORK_EFI_IFR_DATA_ARRAY *
CreateIfrDataArray (
IN CONFIG_ACCESS_PRIVATE *ConfigAccess,
@@ -644,19 +602,15 @@ CreateIfrDataArray (
FRAMEWORK_EFI_IFR_DATA_ARRAY *IfrDataArray;
FRAMEWORK_EFI_IFR_DATA_ENTRY *IfrDataEntry;
UINTN BrowserDataSize;
- BUFFER_STORAGE_ENTRY *BufferStorageEntry;
- LIST_ENTRY *Link;
+ FORMSET_STORAGE *BufferStorage;
EFI_STATUS Status;
UINTN Size;
UINTN StringSize;
EFI_STRING String;
- String = NULL;
+ *NvMapAllocated = FALSE;
- Link = GetFirstNode (&ConfigAccess->BufferStorageListHead);
- if (IsNull (&ConfigAccess->BufferStorageListHead, Link)) {
- return NULL;
- }
+ String = NULL;
switch (Type) {
case EFI_IFR_TYPE_NUM_SIZE_8:
@@ -690,68 +644,121 @@ CreateIfrDataArray (
IfrDataArray = AllocateZeroPool (sizeof (FRAMEWORK_EFI_IFR_DATA_ARRAY) + sizeof (FRAMEWORK_EFI_IFR_DATA_ENTRY) + Size);
ASSERT (IfrDataArray != NULL);
- BufferStorageEntry = BUFFER_STORAGE_ENTRY_FROM_LINK(Link);
- BrowserDataSize = BufferStorageEntry->Size;
+ BufferStorage = GetStorageFromQuestionId (ConfigAccess->ThunkContext->FormSet, QuestionId);
- if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
- *NvMapAllocated = TRUE;
- IfrDataArray->NvRamMap = AllocateZeroPool (BrowserDataSize);
- } else {
- *NvMapAllocated = FALSE;
- IfrDataArray->NvRamMap = ConfigAccess->ThunkContext->NvMapOverride;
+ if (BufferStorage == NULL) {
+ //
+ // The QuestionId is not associated with a Buffer Storage.
+ // Try to get the first Buffer Storage then.
+ //
+ BufferStorage = GetFirstStorageOfFormSet (ConfigAccess->ThunkContext->FormSet);
}
- Status = GetBrowserData (NULL, NULL, &BrowserDataSize, IfrDataArray->NvRamMap);
- ASSERT_EFI_ERROR (Status);
+ if (BufferStorage != NULL) {
+ BrowserDataSize = BufferStorage->Size;
- IfrDataEntry = (FRAMEWORK_EFI_IFR_DATA_ENTRY *) (IfrDataArray + 1);
+ if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
+ *NvMapAllocated = TRUE;
+ IfrDataArray->NvRamMap = AllocateZeroPool (BrowserDataSize);
+ } else {
+ *NvMapAllocated = FALSE;
+ IfrDataArray->NvRamMap = ConfigAccess->ThunkContext->NvMapOverride;
+ }
+
+ Status = GetBrowserData (&BufferStorage->Guid, BufferStorage->Name, &BrowserDataSize, IfrDataArray->NvRamMap);
+ ASSERT_EFI_ERROR (Status);
- 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;
+ IfrDataEntry = (FRAMEWORK_EFI_IFR_DATA_ENTRY *) (IfrDataArray + 1);
- case EFI_IFR_TYPE_STRING:
- ASSERT (String != NULL);
- StrCpy ((CHAR16 *) &IfrDataEntry->Data, String);
- FreePool (String);
- break;
- default:
- ASSERT (FALSE);
- break;
+ 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;
+
+ case EFI_IFR_TYPE_STRING:
+ ASSERT (String != NULL);
+ StrCpy ((CHAR16 *) &IfrDataEntry->Data, String);
+ FreePool (String);
+ break;
+ default:
+ ASSERT (FALSE);
+ break;
+ }
+
+ //
+ // Need to fiil in the information for the rest of field for FRAMEWORK_EFI_IFR_DATA_ENTRY.
+ // It seems that no implementation is found to use other fields. Leave them uninitialized for now.
+ //
+ //UINT8 OpCode; // Likely a string, numeric, or one-of
+ //UINT8 Length; // Length of the FRAMEWORK_EFI_IFR_DATA_ENTRY packet
+ //UINT16 Flags; // Flags settings to determine what behavior is desired from the browser after the callback
+ //VOID *Data; // The data in the form based on the op-code type - this is not a pointer to the data, the data follows immediately
+ // If the OpCode is a OneOf or Numeric type - Data is a UINT16 value
+ // If the OpCode is a String type - Data is a CHAR16[x] type
+ // If the OpCode is a Checkbox type - Data is a UINT8 value
+ // If the OpCode is a NV Access type - Data is a FRAMEWORK_EFI_IFR_NV_DATA structure
}
return IfrDataArray;
}
+/**
+ If a NvMapOverride is passed in to EFI_FORM_BROWSER_PROTOCOL.SendForm, the Form Browser
+ needs to be informed when data changed in NvMapOverride. This function will invoke
+ SetBrowserData () to set internal data of Form Browser.
+
+ @param ConfigAccess The Config Access Private Context.
+ @param QuestionId The Question Id that invokes the callback.
+
+
+**/
VOID
SyncBrowserDataForNvMapOverride (
- IN CONFIG_ACCESS_PRIVATE *ConfigAccess
+ IN CONST CONFIG_ACCESS_PRIVATE *ConfigAccess,
+ IN EFI_QUESTION_ID QuestionId
)
{
- BUFFER_STORAGE_ENTRY *BufferStorageEntry;
- LIST_ENTRY *Link;
+ FORMSET_STORAGE *BufferStorage;
EFI_STATUS Status;
UINTN BrowserDataSize;
if (ConfigAccess->ThunkContext->NvMapOverride != NULL) {
+
+ BufferStorage = GetStorageFromQuestionId (ConfigAccess->ThunkContext->FormSet, QuestionId);
+
+ if (BufferStorage == NULL) {
+ //
+ // QuestionId is a statement without Storage.
+ // 1) It is a Goto.
+ //
+ //
+ BufferStorage = GetFirstStorageOfFormSet (ConfigAccess->ThunkContext->FormSet);
+ }
+
+ //
+ // If NvMapOverride is not NULL, this Form must have at least one Buffer Type Variable Storage.
+ //
+ ASSERT (BufferStorage != NULL);
- Link = GetFirstNode (&ConfigAccess->BufferStorageListHead);
- ASSERT (!IsNull (&ConfigAccess->BufferStorageListHead, Link));
-
- BufferStorageEntry = BUFFER_STORAGE_ENTRY_FROM_LINK(Link);
- BrowserDataSize = BufferStorageEntry->Size;
+ BrowserDataSize = BufferStorage->Size;
- Status = SetBrowserData (NULL, NULL, BrowserDataSize, ConfigAccess->ThunkContext->NvMapOverride, NULL);
+ Status = SetBrowserData (&BufferStorage->Guid, BufferStorage->Name, BrowserDataSize, ConfigAccess->ThunkContext->NvMapOverride, NULL);
ASSERT_EFI_ERROR (Status);
}
}
+/**
+ Free up resource allocated for a FRAMEWORK_EFI_IFR_DATA_ARRAY by CreateIfrDataArray ().
+
+ @param Array The FRAMEWORK_EFI_IFR_DATA_ARRAY allocated.
+ @param NvMapAllocated If the NvRamMap is allocated for FRAMEWORK_EFI_IFR_DATA_ARRAY.
+
+**/
VOID
DestroyIfrDataArray (
IN FRAMEWORK_EFI_IFR_DATA_ARRAY *Array,
@@ -767,7 +774,21 @@ DestroyIfrDataArray (
}
}
-
+/**
+ Get the ONE_OF_OPTION_MAP_ENTRY for a QuestionId that invokes the
+ EFI_FORM_CALLBACK_PROTOCOL.Callback. The information is needed as
+ the callback mechanism for EFI_IFR_ONE_OF_OPTION is changed from
+ EFI_IFR_ONE_OF_OPTION in Framework IFR. Check EFI_IFR_GUID_OPTIONKEY
+ for detailed information.
+
+ @param ThunkContext The Thunk Context.
+ @param QuestionId The Question Id.
+ @param Type The Question Type.
+ @param Value The One Of Option's value.
+
+ @return The ONE_OF_OPTION_MAP_ENTRY found.
+ @retval NULL If no entry is found.
+**/
ONE_OF_OPTION_MAP_ENTRY *
GetOneOfOptionMapEntry (
IN HII_THUNK_CONTEXT *ThunkContext,
@@ -780,10 +801,13 @@ GetOneOfOptionMapEntry (
LIST_ENTRY *Link2;
ONE_OF_OPTION_MAP_ENTRY *OneOfOptionMapEntry;
ONE_OF_OPTION_MAP *OneOfOptionMap;
+ FORM_BROWSER_FORMSET *FormSet;
- Link = GetFirstNode (&ThunkContext->OneOfOptionMapListHead);
+ FormSet = ThunkContext->FormSet;
- while (!IsNull (&ThunkContext->OneOfOptionMapListHead, Link)) {
+ Link = GetFirstNode (&FormSet->OneOfOptionMapListHead);
+
+ while (!IsNull (&FormSet->OneOfOptionMapListHead, Link)) {
OneOfOptionMap = ONE_OF_OPTION_MAP_FROM_LINK(Link);
if (OneOfOptionMap->QuestionId == QuestionId) {
ASSERT (OneOfOptionMap->ValueType == Type);
@@ -801,7 +825,7 @@ GetOneOfOptionMapEntry (
}
}
- Link = GetNextNode (&ThunkContext->OneOfOptionMapListHead, Link);
+ Link = GetNextNode (&FormSet->OneOfOptionMapListHead, Link);
}
@@ -815,6 +839,18 @@ GetOneOfOptionMapEntry (
PackageGuid, Handle, and Package are used for each of the
notification types.
+ If any Pakcage List in database is updated, mHiiPackageListUpdated
+ will be set. If mHiiPackageListUpdated is set, Framework ThunkCallback()
+ will force the UEFI Setup Browser to save the uncommitted data. This
+ is needed as Framework's Callback function may dynamically update
+ opcode in a Package List. UEFI Setup Browser will quit itself and reparse
+ the Package List's IFR and display it. UEFI Config Access's implementation
+ is required to save the modified (SetBrowserData or directly save the data
+ to NV storage). But Framework HII Modules is not aware of this rule. Therefore,
+ we will enforce the rule in ThunkCallback (). The side effect of force saving
+ of NV data is the NV flag in browser may not flag a update as data has already
+ been saved to NV storage.
+
@param PackageType Package type of the notification.
@param PackageGuid If PackageType is
@@ -851,8 +887,7 @@ FormUpdateNotify (
/**
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.
+ the framework HII module willl do no porting and 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.
@@ -922,6 +957,9 @@ ThunkCallback (
//
KeyValue = QuestionId;
} else {
+ //
+ // Otherwise, use the original Key specified in One Of Option in the Framework VFR syntax.
+ //
KeyValue = OneOfOptionMapEntry->FwKey;
}
@@ -939,7 +977,7 @@ ThunkCallback (
&NotifyHandle
);
//
- //
+ //Call the Framework Callback function.
//
Packet = NULL;
Status = FormCallbackProtocol->Callback (
@@ -948,7 +986,7 @@ ThunkCallback (
Data,
&Packet
);
- SyncBrowserDataForNvMapOverride (ConfigAccess);
+ SyncBrowserDataForNvMapOverride (ConfigAccess, QuestionId);
//
// Callback require browser to perform action
@@ -998,15 +1036,19 @@ ThunkCallback (
// the form and load all the variable storages.
//
if (*ActionRequest == EFI_BROWSER_ACTION_REQUEST_NONE && mHiiPackageListUpdated) {
+ mHiiPackageListUpdated= FALSE;
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_SUBMIT;
} else {
- if (ConfigAccess->ThunkContext->FormSetSubClass == EFI_FRONT_PAGE_SUBCLASS ||
- ConfigAccess->ThunkContext->FormSetSubClass == EFI_SINGLE_USE_SUBCLASS) {
+ if (ConfigAccess->ThunkContext->FormSet->SubClass == EFI_FRONT_PAGE_SUBCLASS ||
+ ConfigAccess->ThunkContext->FormSet->SubClass == EFI_SINGLE_USE_SUBCLASS) {
*ActionRequest = EFI_BROWSER_ACTION_REQUEST_EXIT;
}
}
+ //
+ // Clean up.
+ //
DestroyIfrDataArray (Data, NvMapAllocated);
return Status;
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Fonts.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Fonts.c
index 236029671b..46cb76f06b 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Fonts.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Fonts.c
@@ -22,20 +22,31 @@ EFI_GRAPHICS_OUTPUT_BLT_PIXEL mSysFGColor = {0};
/**
- 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.
+ Translates a Unicode character into the corresponding font glyph.
- 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.
+ Notes:
+ This function is only called by Graphics Console module and GraphicsLib.
+ Wrap the Framework HII GetGlyph function to UEFI Font Protocol.
+
+ EDK II provides a UEFI Graphics Console module. ECP provides a GraphicsLib
+ complying to UEFI HII.
+
+ @param This A pointer to the EFI_HII_PROTOCOL instance.
+ @param Source A pointer to a Unicode string.
+ @param Index On input, the offset into the string from which to fetch the character. On successful completion, the
+ index is updated to the first character past the character(s) making up the just extracted glyph.
+ @param GlyphBuffer Pointer to an array where the glyphs corresponding to the characters in the source may be stored.
+ GlyphBuffer is assumed to be wide enough to accept a wide glyph character.
+ @param BitWidth If EFI_SUCCESS was returned, the UINT16 pointed to by this value is filled with the length of the glyph in pixels.
+ It is unchanged if the call was unsuccessful.
+ @param InternalStatus To save the time required to read the string from the beginning on each glyph extraction
+ (for example, to ensure that the narrow versus wide glyph mode is correct), this value is
+ updated each time the function is called with the status that is local to the call. The cell pointed
+ to by this parameter must be initialized to zero prior to invoking the call the first time for any string.
+
+ @retval EFI_SUCCESS It worked.
+ @retval EFI_NOT_FOUND A glyph for a character was not found.
+
**/
EFI_STATUS
@@ -122,22 +133,25 @@ HiiGetGlyph (
}
/**
+ Translates a glyph into the format required for input to the Universal Graphics Adapter (UGA) Block Transfer (BLT) routines.
+
+ Notes:
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.
+ @param This A pointer to the EFI_HII_PROTOCOL instance.
+ @param GlyphBuffer A pointer to the buffer that contains glyph data.
+ @param Foreground The foreground setting requested to be used for the generated BltBuffer data. Type EFI_UGA_PIXEL is defined in "Related Definitions" below.
+ @param Background The background setting requested to be used for the generated BltBuffer data.
+ @param Count The entry in the BltBuffer upon which to act.
+ @param Width The width in bits of the glyph being converted.
+ @param Height The height in bits of the glyph being converted
+ @param BltBuffer A pointer to the buffer that contains the data that is ready to be used by the UGA BLT routines.
+
+ @retval EFI_SUCCESS It worked.
+ @retval EFI_NOT_FOUND A glyph for a character was not found.
+
**/
EFI_STATUS
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Forms.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Forms.c
index fb0a6900b8..c302cf56f0 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Forms.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Forms.c
@@ -55,6 +55,8 @@ FW_HII_FORMSET_TEMPLATE FormSetTemplate = {
};
+EFI_GUID mTianoHiiIfrGuid = EFI_IFR_TIANO_GUID;
+
/**
This thunk module only handles UEFI HII packages. The caller of this function
@@ -144,10 +146,12 @@ HiiGetForms (
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;
+ if (ThunkContext->FormSet != NULL) {
+ OutputFormSet->FormSet.Class = ThunkContext->FormSet->Class;
+ OutputFormSet->FormSet.SubClass = ThunkContext->FormSet->SubClass;
+ OutputFormSet->FormSet.Help = ThunkContext->FormSet->Help;
+ OutputFormSet->FormSet.FormSetTitle = ThunkContext->FormSet->FormSetTitle;
+ }
return EFI_SUCCESS;
}
@@ -182,25 +186,25 @@ HiiGetDefaultImage (
)
{
LIST_ENTRY *UefiDefaults;
- EFI_HII_HANDLE UefiHiiHandle;
EFI_STATUS Status;
HII_THUNK_PRIVATE_DATA *Private;
+ HII_THUNK_CONTEXT *ThunkContext;
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
- UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);
- if (UefiHiiHandle == NULL) {
+ ThunkContext = FwHiiHandleToThunkContext (Private, Handle);
+ if (ThunkContext == NULL) {
ASSERT (FALSE);
return EFI_INVALID_PARAMETER;
}
UefiDefaults = NULL;
- Status = UefiIfrGetBufferTypeDefaults (UefiHiiHandle, &UefiDefaults);
+ Status = UefiIfrGetBufferTypeDefaults (ThunkContext, &UefiDefaults);
if (EFI_ERROR (Status)) {
goto Done;
}
- Status = UefiDefaultsToFwDefaults (UefiDefaults, DefaultMask, VariablePackList);
+ Status = UefiDefaultsToFwDefaults (UefiDefaults, DefaultMask, ThunkContext->FormSet->DefaultVarStoreId, VariablePackList);
Done:
FreeDefaultList (UefiDefaults);
@@ -209,12 +213,15 @@ Done:
}
/**
- EDES_TODO: Add function description.
+ This function update the FormCallbackProtocol cached in Config Access
+ private context data.
- @param CallbackHandle EDES_TODO: Add parameter description
- @param ThunkContext EDES_TODO: Add parameter description
+ @param CallbackHandle The EFI Handle on which the Framework FormCallbackProtocol is
+ installed.
+ @param ThunkContext The Thunk Context.
- @return EDES_TODO: Add description for return value
+ @retval EFI_SUCCESS The update is successful.
+ @retval EFI_INVALID_PARAMETER If no Framework FormCallbackProtocol is located on CallbackHandle.
**/
EFI_STATUS
@@ -260,17 +267,17 @@ UpdateFormCallBack (
/**
- EDES_TODO: Add function description.
+ Get the package data from the Package List.
- @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
+ @param HiiPackageList Package List.
+ @param PackageIndex The index of the Package in the Package List.
+ @param BufferLen The Length of the Pacage data.
+ @param Buffer On output, the Package data.
- @return EDES_TODO: Add description for return value
+ @return EFI_NOT_FOUND No Package is found for PackageIndex.
+ @return EFI_SUCCESS The package data is returned.
**/
-STATIC
EFI_STATUS
GetPackageData (
IN EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList,
@@ -317,10 +324,16 @@ GetPackageData (
}
/**
- Check if Label exist in the IFR form package.
+ Check if Label exist in the IFR form package and return the FormSet GUID
+ and Form ID.
- @param
+ @param Package The Package Header.
+ @param Label The Label ID.
+ @param FormsetGuid Returns the FormSet GUID.
+ @param FormId Returns the Form ID.
+ @retval EFI_SUCCESS The FORM ID is found.
+ @retval EFI_NOT_FOUND The FORM ID is not found.
**/
EFI_STATUS
LocateLabel (
@@ -332,12 +345,11 @@ LocateLabel (
{
UINTN Offset;
EFI_IFR_OP_HEADER *IfrOpHdr;
- UINT8 ExtendOpCode;
- UINT16 LabelNumber;
EFI_GUID InternalFormSetGuid;
EFI_FORM_ID InternalFormId;
BOOLEAN GetFormSet;
BOOLEAN GetForm;
+ EFI_IFR_GUID_LABEL *LabelOpcode;
IfrOpHdr = (EFI_IFR_OP_HEADER *)((UINT8 *) Package + sizeof (EFI_HII_PACKAGE_HEADER));
Offset = sizeof (EFI_HII_PACKAGE_HEADER);
@@ -360,26 +372,18 @@ LocateLabel (
break;
case EFI_IFR_GUID_OP :
- ExtendOpCode = ((EFI_IFR_GUID_LABEL *) IfrOpHdr)->ExtendOpCode;
-
- if (ExtendOpCode != EFI_IFR_EXTEND_OP_LABEL) {
- //
- // Go to the next Op-Code
- //
- Offset += IfrOpHdr->Length;
- IfrOpHdr = (EFI_IFR_OP_HEADER *) ((CHAR8 *) (IfrOpHdr) + IfrOpHdr->Length);
- continue;
- }
-
- CopyMem (&LabelNumber, &((EFI_IFR_GUID_LABEL *)IfrOpHdr)->Number, sizeof (UINT16));
- if (LabelNumber == Label) {
- ASSERT (GetForm && GetFormSet);
- CopyGuid (FormsetGuid, &InternalFormSetGuid);
- *FormId = InternalFormId;
- return EFI_SUCCESS;
+ LabelOpcode = (EFI_IFR_GUID_LABEL *) IfrOpHdr;
+ //
+ // If it is an Label opcode.
+ //
+ if ((LabelOpcode->ExtendOpCode == EFI_IFR_EXTEND_OP_LABEL) && (CompareMem (&LabelOpcode->Guid, &mTianoHiiIfrGuid, sizeof (EFI_GUID)) == 0)) {
+ if (CompareMem (&Label, &LabelOpcode->Number, sizeof (UINT16)) == 0) {
+ ASSERT (GetForm && GetFormSet);
+ CopyGuid (FormsetGuid, &InternalFormSetGuid);
+ *FormId = InternalFormId;
+ return EFI_SUCCESS;
+ }
}
-
-
break;
default :
break;
@@ -462,6 +466,7 @@ Done:
return Status;
}
+
/**
This function allows the caller to update a form that has
previously been registered with the EFI HII database.
@@ -539,10 +544,10 @@ HiiUpdateForm (
if (Data->DataCount != 0) {
ThunkContext = UefiHiiHandleToThunkContext (Private, UefiHiiHandle);
- Status = FwUpdateDataToUefiUpdateData (ThunkContext, Data, AddData, &UefiHiiUpdateData);
+ Status = FwUpdateDataToUefiUpdateData (ThunkContext, Data, &UefiHiiUpdateData);
ASSERT_EFI_ERROR (Status);
- Status = IfrLibUpdateForm (UefiHiiHandle, &FormsetGuid, FormId, Label, AddData, UefiHiiUpdateData);
+ Status = IfrLibUpdateForm (UefiHiiHandle, &FormsetGuid, FormId, Label, TRUE, UefiHiiUpdateData);
ASSERT_EFI_ERROR (Status);
}
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/FrameworkHiiToUefiHiiThunk.inf b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/FrameworkHiiToUefiHiiThunk.inf
index 2fed1569d1..fcdcabfc56 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/FrameworkHiiToUefiHiiThunk.inf
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/FrameworkHiiToUefiHiiThunk.inf
@@ -43,13 +43,10 @@
ConfigAccess.h
OpcodeCreation.c
OpcodeCreation.h
- UefiIfrParserInternal.h
- UefiIfrParserCommon.c
- UefiIfrParserCommon.h
UefiIfrParser.c
UefiIfrParser.h
UefiIfrParserExpression.c
- UefiIfrParserExpressionInternal.h
+ UefiIfrParserExpression.h
UefiIfrDefault.c
UefiIfrDefault.h
Keyboard.c
@@ -104,3 +101,4 @@
gEfiFormBrowser2ProtocolGuid
+
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h
index 2fc2be81a4..0ea1b5a359 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h
@@ -51,6 +51,8 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include <MdeModuleHii.h>
+#include "UefiIfrParser.h"
+
//
// VARSTORE ID of 0 for Buffer Storage Type Storage is reserved in UEFI IFR form. But VARSTORE ID
@@ -59,7 +61,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
// Framework VFR has to be ported or pre-processed to change the default VARSTORE to a VARSTORE
// with ID equal to 0x0001.
//
-#define RESERVED_VARSTORE_ID 0x0001
+#define FRAMEWORK_RESERVED_VARSTORE_ID 0x0001
#pragma pack (push, 1)
@@ -87,32 +89,6 @@ typedef struct {
-#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 {
- 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)
@@ -161,17 +137,10 @@ typedef struct {
// TagGuid is the used to record this GuidId.
EFI_GUID TagGuid;
- 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;
-
+ FORM_BROWSER_FORMSET *FormSet;
+
} HII_THUNK_CONTEXT;
@@ -199,8 +168,6 @@ typedef struct {
//
EFI_FORM_CALLBACK_PROTOCOL *FormCallbackProtocol;
- LIST_ENTRY BufferStorageListHead;
-
HII_THUNK_CONTEXT *ThunkContext;
} CONFIG_ACCESS_PRIVATE;
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Keyboard.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Keyboard.c
index 9a49ee5761..087cd7aedb 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Keyboard.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Keyboard.c
@@ -16,6 +16,17 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "HiiDatabase.h"
+/**
+ Retrieves the current keyboard layout.
+ This function is not implemented by HII Thunk Module.
+
+ @param This A pointer to the EFI_HII_PROTOCOL instance.
+ @param DescriptorCount A pointer to the number of Descriptor entries being described in the keyboard layout being retrieved.
+ @param Descriptor A pointer to a buffer containing an array of EFI_KEY_DESCRIPTOR entries. Each entry will reflect the definition of a specific physical key. Type EFI_KEY_DESCRIPTOR is defined in "Related Definitions" below.
+
+ @retval EFI_SUCCESS The keyboard layout was retrieved successfully.
+
+**/
EFI_STATUS
EFIAPI
HiiGetKeyboardLayout (
@@ -23,15 +34,6 @@ HiiGetKeyboardLayout (
OUT UINT16 *DescriptorCount,
OUT FRAMEWORK_EFI_KEY_DESCRIPTOR *Descriptor
)
-/*++
-
-Routine Description:
-
-Arguments:
-
-Returns:
-
---*/
{
ASSERT (FALSE);
//
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.c
index 0fbe943165..60b2d25c71 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.c
@@ -18,6 +18,108 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
EFI_GUID mTianoExtendedOpcodeGuid = EFI_IFR_TIANO_GUID;
+
+EFI_IFR_GUID_OPTIONKEY mOptionKeyTemplate = {
+ {EFI_IFR_GUID_OP, sizeof (EFI_IFR_GUID_OPTIONKEY), 0},
+ EFI_IFR_FRAMEWORK_GUID,
+ EFI_IFR_EXTEND_OP_OPTIONKEY,
+ 0,
+ 0,
+ 0
+};
+
+typedef struct {
+ UINT8 FrameworkIfrOp;
+ UINT8 UefiIfrOp;
+} IFR_OPCODE_MAP;
+
+IFR_OPCODE_MAP mQuestionOpcodeMap [] = {
+ { FRAMEWORK_EFI_IFR_ONE_OF_OP, EFI_IFR_ONE_OF_OP},
+ { FRAMEWORK_EFI_IFR_CHECKBOX_OP, EFI_IFR_CHECKBOX_OP},
+ { FRAMEWORK_EFI_IFR_NUMERIC_OP, EFI_IFR_NUMERIC_OP},
+ { FRAMEWORK_EFI_IFR_ONE_OF_OPTION_OP, EFI_IFR_ONE_OF_OPTION_OP},
+ { FRAMEWORK_EFI_IFR_ORDERED_LIST_OP, EFI_IFR_ORDERED_LIST_OP}
+};
+
+EFI_STATUS
+QuestionOpFwToUefi (
+ IN UINT8 FwOp,
+ OUT UINT8 *UefiOp
+ )
+{
+ UINTN Index;
+
+ for (Index = 0; Index < sizeof (mQuestionOpcodeMap) / sizeof (mQuestionOpcodeMap[0]); Index++) {
+ if (FwOp == mQuestionOpcodeMap[Index].FrameworkIfrOp) {
+ *UefiOp = mQuestionOpcodeMap[Index].UefiIfrOp;
+ return EFI_SUCCESS;
+ }
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+EFI_STATUS
+FwQIdToUefiQId (
+ IN CONST FORM_BROWSER_FORMSET *FormSet,
+ IN UINT16 VarStoreId,
+ IN UINT8 FwOpCode,
+ IN UINT16 FwQId,
+ OUT UINT16 *UefiQId
+ )
+{
+ LIST_ENTRY *FormList;
+ LIST_ENTRY *StatementList;
+ FORM_BROWSER_FORM *Form;
+ FORM_BROWSER_STATEMENT *Statement;
+ EFI_STATUS Status;
+ UINT8 UefiOp;
+
+ *UefiQId = 0;
+
+ FormList = GetFirstNode (&FormSet->FormListHead);
+
+ while (!IsNull (&FormSet->FormListHead, FormList)) {
+ Form = FORM_BROWSER_FORM_FROM_LINK (FormList);
+
+ StatementList = GetFirstNode (&Form->StatementListHead);
+
+ while (!IsNull (&Form->StatementListHead, StatementList)) {
+ Statement = FORM_BROWSER_STATEMENT_FROM_LINK (StatementList);
+ if (Statement->VarStoreId != 0 && Statement->Storage->Type == EFI_HII_VARSTORE_BUFFER) {
+ if (FwQId == Statement->VarStoreInfo.VarOffset) {
+ Status = QuestionOpFwToUefi (FwOpCode, &UefiOp);
+ ASSERT_EFI_ERROR (Status);
+
+ if (UefiOp == Statement->Operand) {
+ //
+ // If ASSERT here, the Framework VFR file has two IFR Question with the Same Type refering to the
+ // same field in NvMap. This is ambigurity, we don't handle it for now.
+ //
+ //
+ // UEFI Question ID is unique in a FormSet.
+ //
+ ASSERT (VarStoreId == Statement->VarStoreId);
+ *UefiQId = Statement->QuestionId;
+
+ return EFI_SUCCESS;
+
+ }
+ }
+ }
+
+ StatementList = GetNextNode (&Form->StatementListHead, StatementList);
+ }
+
+ FormList = GetNextNode (&FormSet->FormListHead, FormList);
+ }
+
+ return EFI_NOT_FOUND;
+}
+
+
+
#define LOCAL_UPDATE_DATA_BUFFER_INCREMENTAL 0x1000
EFI_STATUS
AppendToUpdateBuffer (
@@ -46,54 +148,18 @@ AppendToUpdateBuffer (
EFI_QUESTION_ID
AssignQuestionId (
- IN UINT16 FwQuestionId
+ IN UINT16 FwQuestionId,
+ IN FORM_BROWSER_FORMSET *FormSet
)
{
if (FwQuestionId == 0) {
- //
- // In UEFI IFR, the Question ID can't be zero. Zero means no storage.
- // So use 0xABBA as a Question ID.
- //
- return 0xABBA;
+ FormSet->MaxQuestionId++;
+ return FormSet->MaxQuestionId;
} else {
return FwQuestionId;
}
}
-
-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
@@ -281,6 +347,24 @@ F2UCreateOneOfOptionOpCode (
return AppendToUpdateBuffer ((UINT8 *) &UOpcode, sizeof(UOpcode), UefiData);
}
+EFI_STATUS
+CreateGuidOptionKeyOpCode (
+ IN EFI_QUESTION_ID QuestionId,
+ IN UINT16 OptionValue,
+ IN EFI_QUESTION_ID KeyValue,
+ OUT EFI_HII_UPDATE_DATA *UefiData
+ )
+{
+ EFI_IFR_GUID_OPTIONKEY UOpcode;
+
+ CopyMem (&UOpcode, &mOptionKeyTemplate, sizeof (EFI_IFR_GUID_OPTIONKEY));
+
+ UOpcode.QuestionId = QuestionId;
+ CopyMem (&UOpcode.OptionValue, &OptionValue, sizeof (OptionValue));
+ UOpcode.KeyValue = KeyValue;
+
+ return AppendToUpdateBuffer ((UINT8 *) &UOpcode, sizeof(UOpcode), UefiData);
+}
/*
typedef struct _EFI_IFR_QUESTION_HEADER {
@@ -349,14 +433,10 @@ F2UCreateOneOfOpCode (
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;
@@ -381,41 +461,12 @@ F2UCreateOneOfOpCode (
UOpcode.Question.Flags |= EFI_IFR_FLAG_CALLBACK;
if (UOpcode.Question.QuestionId == 0) {
- Status = FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
+ Status = FwQIdToUefiQId (ThunkContext->FormSet, VarStoreId, FwOpcode->Header.OpCode, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
if (EFI_ERROR (Status)) {
- UOpcode.Question.QuestionId = AssignQuestionId (FwOneOfOp->Key);
+ UOpcode.Question.QuestionId = AssignQuestionId (FwOneOfOp->Key, ThunkContext->FormSet);
}
-
- 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;
- break;
- default:
- ASSERT (FALSE);
- break;
- }
-
- InsertTailList (&ThunkContext->OneOfOptionMapListHead, &OneOfOptionMap->Link);
}
-
- 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) {
@@ -430,9 +481,9 @@ F2UCreateOneOfOpCode (
//
// Assign QuestionId if still not assigned.
//
- Status = FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
+ Status = FwQIdToUefiQId (ThunkContext->FormSet, VarStoreId, FwOpcode->Header.OpCode, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
if (EFI_ERROR (Status)) {
- UOpcode.Question.QuestionId = AssignQuestionId (FwOpcode->QuestionId);
+ UOpcode.Question.QuestionId = AssignQuestionId (FwOpcode->QuestionId, ThunkContext->FormSet);
}
}
@@ -447,10 +498,18 @@ F2UCreateOneOfOpCode (
//
FwOpHeader = (FRAMEWORK_EFI_IFR_OP_HEADER *) ((UINT8 *) FwOpcode + FwOpcode->Header.Length);
while (FwOpHeader->OpCode != FRAMEWORK_EFI_IFR_END_ONE_OF_OP) {
+
+ FwOneOfOp = (FRAMEWORK_EFI_IFR_ONE_OF_OPTION *) FwOpHeader;
+
Status = F2UCreateOneOfOptionOpCode ((FRAMEWORK_EFI_IFR_ONE_OF_OPTION *) FwOpHeader, FwOpcode->Width, UefiData);
if (EFI_ERROR (Status)) {
return Status;
}
+
+ Status = CreateGuidOptionKeyOpCode (UOpcode.Question.QuestionId, FwOneOfOp->Value, FwOneOfOp->Key, UefiData);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
FwOpHeader = (FRAMEWORK_EFI_IFR_OP_HEADER *) ((UINT8 *) FwOpHeader + FwOpHeader->Length);
*DataCount += 1;
}
@@ -533,9 +592,9 @@ F2UCreateOrderedListOpCode (
UOpcode.Question.Flags |= EFI_IFR_FLAG_CALLBACK;
if (UOpcode.Question.QuestionId == 0) {
- Status = FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
+ Status = FwQIdToUefiQId (ThunkContext->FormSet, VarStoreId, FwOpcode->Header.OpCode, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
if (EFI_ERROR (Status)) {
- UOpcode.Question.QuestionId = AssignQuestionId (FwOneOfOp->Key);
+ UOpcode.Question.QuestionId = AssignQuestionId (FwOneOfOp->Key, ThunkContext->FormSet);
}
}
@@ -549,9 +608,9 @@ F2UCreateOrderedListOpCode (
}
if (UOpcode.Question.QuestionId == 0) {
- Status = FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
+ Status = FwQIdToUefiQId (ThunkContext->FormSet, VarStoreId, FwOpcode->Header.OpCode, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
if (EFI_ERROR (Status)) {
- UOpcode.Question.QuestionId = AssignQuestionId (FwOpcode->QuestionId);
+ UOpcode.Question.QuestionId = AssignQuestionId (FwOpcode->QuestionId, ThunkContext->FormSet);
}
}
@@ -637,18 +696,18 @@ F2UCreateCheckBoxOpCode (
UOpcode.Question.Header.Help = FwOpcode->Help;
if (FwOpcode->Key == 0) {
- Status = FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
+ Status = FwQIdToUefiQId (ThunkContext->FormSet, VarStoreId, FwOpcode->Header.OpCode, 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 = AssignQuestionId (FwOpcode->QuestionId);
+ UOpcode.Question.QuestionId = AssignQuestionId (FwOpcode->QuestionId, ThunkContext->FormSet);
}
} else {
UOpcode.Question.QuestionId = FwOpcode->Key;
}
- UOpcode.Question.VarStoreId = RESERVED_VARSTORE_ID;
+ UOpcode.Question.VarStoreId = FRAMEWORK_RESERVED_VARSTORE_ID;
UOpcode.Question.VarStoreInfo.VarOffset = FwOpcode->QuestionId;
//
@@ -746,12 +805,12 @@ F2UCreateNumericOpCode (
ZeroMem (&UOpcode, sizeof(UOpcode));
if (FwOpcode->Key == 0) {
- Status = FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
+ Status = FwQIdToUefiQId (ThunkContext->FormSet, VarStoreId, FwOpcode->Header.OpCode, 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 = AssignQuestionId (FwOpcode->QuestionId);
+ UOpcode.Question.QuestionId = AssignQuestionId (FwOpcode->QuestionId, ThunkContext->FormSet);
}
} else {
UOpcode.Question.QuestionId = FwOpcode->Key;
@@ -887,7 +946,7 @@ F2UCreateStringOpCode (
ZeroMem (&UOpcode, sizeof(UOpcode));
if (FwOpcode->Key == 0) {
- FwQuestionIdToUefiQuestionId (ThunkContext, VarStoreId, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
+ FwQIdToUefiQId (ThunkContext->FormSet, VarStoreId, FwOpcode->Header.OpCode, FwOpcode->QuestionId, &UOpcode.Question.QuestionId);
} else {
UOpcode.Question.QuestionId = FwOpcode->Key;
}
@@ -899,7 +958,7 @@ F2UCreateStringOpCode (
UOpcode.Question.Header.Help = FwOpcode->Help;
UOpcode.Question.QuestionId = FwOpcode->Key;
- UOpcode.Question.VarStoreId = RESERVED_VARSTORE_ID;
+ UOpcode.Question.VarStoreId = FRAMEWORK_RESERVED_VARSTORE_ID;
UOpcode.Question.VarStoreInfo.VarOffset = FwOpcode->QuestionId;
UOpcode.Question.Flags = (FwOpcode->Flags & (FRAMEWORK_EFI_IFR_FLAG_INTERACTIVE | FRAMEWORK_EFI_IFR_FLAG_RESET_REQUIRED));
@@ -957,7 +1016,6 @@ EFI_STATUS
FwUpdateDataToUefiUpdateData (
IN HII_THUNK_CONTEXT *ThunkContext,
IN CONST FRAMEWORK_EFI_HII_UPDATE_DATA *Data,
- IN BOOLEAN AddData,
OUT EFI_HII_UPDATE_DATA **UefiData
)
{
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.h b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.h
index c56947539d..3cdc33a365 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.h
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.h
@@ -105,7 +105,6 @@ EFI_STATUS
FwUpdateDataToUefiUpdateData (
IN HII_THUNK_CONTEXT *ThunkContext,
IN CONST FRAMEWORK_EFI_HII_UPDATE_DATA *Data,
- IN BOOLEAN AddData,
OUT EFI_HII_UPDATE_DATA **UefiData
);
#endif
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c
index 154b9cfa58..c88ad767b9 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c
@@ -362,7 +362,7 @@ UefiRegisterPackageList (
//
// 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
+ // not used as the name of the package list. Formset GUID is used as the Package List
// GUID.
//
ASSERT (StringPackageCount >=1 && IfrPackageCount == 1);
@@ -383,7 +383,9 @@ 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.
+ // that Setup Utility can load the Buffer Storage using this protocol. An UEFI VFR can only
+ // produce IFR package generated with Buffer Storage type and EFI Variable Storage.
+ // The default EFI_HII_CONFIG_ACCESS_PROTOCOL is used to Get/Set the Buffer Storage.
//
if (IfrPackageCount != 0) {
InstallDefaultConfigAccessProtocol (Packages, ThunkContext);
@@ -425,8 +427,10 @@ UefiRegisterPackageList (
if (IfrPackageCount == 0) {
if (StringPackageCount != 0) {
//
- // Look for a Package List with only IFR Package with the same GUID name.
- // If found one, add the String Packages to it.
+ // Look for a Package List with only IFR Package with the same TAG GUID name.
+ // If found one, add the String Packages to the found Package List.
+ // This is needed because Framework HII Module may not register the String Package
+ // and IFR Package in one NewPack () call.
//
UpdatePackListWithOnlyIfrPack (
Private,
@@ -435,11 +439,12 @@ UefiRegisterPackageList (
);
}
} else {
- CreateQuestionIdMap (ThunkContext);
-
if (StringPackageCount == 0) {
//
- // Register the Package List to UEFI HII first.
+ // Look for the String Package with the same TAG GUID name and add
+ // the found String Package to this Package List.
+ // This is needed because Framework HII Module may not register the String Package
+ // and IFR Package in one NewPack () call.
//
Status = FindStringPackAndUpdatePackListWithOnlyIfrPack (
Private,
@@ -450,6 +455,14 @@ UefiRegisterPackageList (
goto Done;
}
}
+
+ //
+ // Parse the Formset. Must be called after FindStringPackAndUpdatePackListWithOnlyIfrPack is called so
+ // that String Package is ready.
+ //
+ ThunkContext->FormSet = ParseFormSet (ThunkContext->UefiHiiHandle);
+ ASSERT (ThunkContext->FormSet != NULL);
+
}
Done:
@@ -468,6 +481,18 @@ Done:
}
+/**
+
+ Registers the various packages that are passed in a Package List.
+
+ @param This Pointer of Frameowk HII protocol instance.
+ @param Packages Pointer of HII packages.
+ @param Handle Handle value to be returned.
+
+ @retval EFI_SUCCESS Pacakges has added to HII database successfully.
+ @retval EFI_INVALID_PARAMETER If Handle or Packages is NULL.
+
+**/
EFI_STATUS
EFIAPI
HiiNewPack (
@@ -475,24 +500,6 @@ HiiNewPack (
IN EFI_HII_PACKAGES *Packages,
OUT FRAMEWORK_EFI_HII_HANDLE *Handle
)
-/*++
-
-Routine Description:
-
- Extracts the various packs from a package list.
-
-Arguments:
-
- This - Pointer of HII protocol.
- Packages - Pointer of HII packages.
- Handle - Handle value to be returned.
-
-Returns:
-
- EFI_SUCCESS - Pacakges has added to HII database successfully.
- EFI_INVALID_PARAMETER - Invalid parameter.
-
---*/
{
EFI_STATUS Status;
HII_THUNK_PRIVATE_DATA *Private;
@@ -509,10 +516,10 @@ Returns:
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
//
- // We use a simple Global variable to inform NewPackNotify
+ // We use a simple Global variable to inform NewOrAddPackNotify()
// that the package list registered here is already registered
- // in the HII Thunk Layer. So NewPackNotify does not need to
- // call RegisterUefiHiiHandle () to registered it.
+ // in the HII Thunk Layer. So NewOrAddPackNotify () does not need to
+ // call registered the Package List again.
//
mInFrameworkHiiNewPack = TRUE;
@@ -532,26 +539,27 @@ Returns:
return Status;
}
+/**
+
+ Remove a package from the HII database.
+
+ @param This Pointer of Frameowk HII protocol instance.
+ @param Handle Handle value to be removed.
+
+ @retval EFI_SUCCESS Pacakges has added to HII database successfully.
+ @retval EFI_INVALID_PARAMETER If Handle or Packages is NULL.
+
+**/
EFI_STATUS
EFIAPI
HiiRemovePack (
IN EFI_HII_PROTOCOL *This,
IN FRAMEWORK_EFI_HII_HANDLE Handle
)
-/*++
-
-Routine Description:
- Removes the various packs from a Handle
-
-Arguments:
-
-Returns:
-
---*/
{
EFI_STATUS Status;
- HII_THUNK_PRIVATE_DATA *Private;
- HII_THUNK_CONTEXT *ThunkContext;
+ HII_THUNK_PRIVATE_DATA *Private;
+ HII_THUNK_CONTEXT *ThunkContext;
EFI_TPL OldTpl;
OldTpl = gBS->RaiseTPL (TPL_NOTIFY);
@@ -584,6 +592,25 @@ Returns:
return Status;
}
+/**
+ This notification function will be called when a Package List is registered
+ using UEFI HII interface. The Package List registered need to be recorded in
+ Framework Thunk module as Thunk Module may need to look for String Package in
+ the package registered.
+
+ If the Package List registered is not either Sting Package or IFR package,
+ then ASSERT. If the NotifyType is not ADD_PACK or NEW_PACK, then ASSERT.
+ Both cases means UEFI HII Database itself is buggy.
+
+ @param PackageType The Package Type.
+ @param PackageGuid The Package GUID.
+ @param Package The Package Header.
+ @param Handle The HII Handle of this Package List.
+ @param NotifyType The reason of the notification.
+
+ @retval EFI_SUCCESS The notification function is successful.
+
+**/
EFI_STATUS
EFIAPI
NewOrAddPackNotify (
@@ -609,8 +636,8 @@ NewOrAddPackNotify (
}
//
- // We only create a ThunkContext if the Uefi Hii Handle is only already registered
- // by the HII Thunk Layer.
+ // We will create a ThunkContext to log the package list only if the
+ // package is not registered with by Framework HII Thunk module yet.
//
ThunkContext = UefiHiiHandleToThunkContext (Private, Handle);
if (ThunkContext == NULL) {
@@ -621,17 +648,38 @@ NewOrAddPackNotify (
}
if (PackageType == EFI_HII_PACKAGE_FORMS) {
- GetAttributesOfFirstFormSet (ThunkContext);
+ if (ThunkContext->FormSet != NULL) {
+ DestroyFormSet (ThunkContext->FormSet);
+ }
+
+ //
+ // Reparse the FormSet.
+ //
+ ThunkContext->FormSet = ParseFormSet (ThunkContext->UefiHiiHandle);
+ ASSERT (ThunkContext->FormSet != NULL);
}
return Status;
}
-//
-// 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
+/**
+ This notification function will be called when a Package List is removed
+ using UEFI HII interface. The Package List removed need to be removed from
+ Framework Thunk module too.
+
+ If the Package List registered is not Sting Package,
+ then ASSERT. If the NotifyType is not REMOVE_PACK, then ASSERT.
+ Both cases means UEFI HII Database itself is buggy.
+
+ @param PackageType The Package Type.
+ @param PackageGuid The Package GUID.
+ @param Package The Package Header.
+ @param Handle The HII Handle of this Package List.
+ @param NotifyType The reason of the notification.
+ @retval EFI_SUCCESS The notification function is successful.
+
+**/
EFI_STATUS
EFIAPI
RemovePackNotify (
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/SetupBrowser.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/SetupBrowser.c
index 5e391127cf..ebfbdeceb1 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/SetupBrowser.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/SetupBrowser.c
@@ -15,6 +15,26 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "HiiDatabase.h"
+/**
+ This is the Framework Setup Browser interface which displays a FormSet.
+
+ @param This The EFI_FORM_BROWSER_PROTOCOL context.
+ @param UseDatabase TRUE if the FormSet is from HII database. The Thunk implementation
+ only support UseDatabase is TRUE.
+ @param Handle The Handle buffer.
+ @param HandleCount The number of Handle in the Handle Buffer. It must be 1 for this implementation.
+ @param Packet The pointer to data buffer containing IFR and String package. Not supported.
+ @param CallbackHandle Not supported.
+ @param NvMapOverride The buffer is used only when there is no NV variable to define the
+ current settings and the caller needs to provide to the browser the
+ current settings for the the "fake" NV variable. If used, no saving of
+ an NV variable is possbile. This parameter is also ignored if Handle is NULL.
+
+ @retval EFI_SUCCESS If the Formset is displayed correctly.
+ @retval EFI_UNSUPPORTED If UseDatabase is FALSE or HandleCount is not 1.
+ @retval EFI_INVALID_PARAMETER If the *Handle passed in is not found in the database.
+**/
+
EFI_STATUS
EFIAPI
ThunkSendForm (
@@ -75,6 +95,26 @@ ThunkSendForm (
return Status;
}
+/**
+
+ Rountine used to display a generic dialog interface and return
+ the Key or Input from user input.
+
+ @param NumberOfLines The number of lines for the dialog box.
+ @param HotKey Defines if a single character is parsed (TRUE) and returned in KeyValue
+ or if a string is returned in StringBuffer.
+ @param MaximumStringSize The maximum size in bytes of a typed-in string.
+ @param StringBuffer On return contains the typed-in string if HotKey
+ is FALSE.
+ @param KeyValue The EFI_INPUT_KEY value returned if HotKey is TRUE.
+ @param String The pointer to the first string in the list of strings
+ that comprise the dialog box.
+ @param ... A series of NumberOfLines text strings that will be used
+ to construct the dialog box.
+ @retval EFI_SUCCESS The dialog is created successfully and user interaction was received.
+ @retval EFI_DEVICE_ERROR The user typed in an ESC.
+ @retval EFI_INVALID_PARAMETER One of the parameters was invalid.(StringBuffer == NULL && HotKey == FALSE).
+**/
EFI_STATUS
EFIAPI
ThunkCreatePopUp (
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.c
index b46a31e37b..d89b8155e0 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.c
@@ -24,9 +24,9 @@
#include <Library/MemoryAllocationLib.h>
#include <Library/UefiBootServicesTableLib.h>
+#include "HiiDatabase.h"
#include "UefiIfrParser.h"
#include "UefiIfrDefault.h"
-#include "HiiDatabase.h"
//
// Extern Variables
@@ -36,216 +36,6 @@ extern CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol;
extern CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol;
extern CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol;
-extern EFI_GUID gZeroGuid;
-
-/**
- Fetch the Ifr binary data of a FormSet.
-
- @param Handle PackageList Handle
- @param FormSetGuid GUID of a formset. If not specified (NULL or zero
- GUID), take the first FormSet found in package
- list.
- @param BinaryLength The length of the FormSet IFR binary.
- @param BinaryData The buffer designed to receive the FormSet.
-
- @retval EFI_SUCCESS Buffer filled with the requested FormSet.
- BufferLength was updated.
- @retval EFI_INVALID_PARAMETER The handle is unknown.
- @retval EFI_NOT_FOUND A form or FormSet on the requested handle cannot
- be found with the requested FormId.
-
-**/
-EFI_STATUS
-GetIfrBinaryData (
- IN EFI_HII_HANDLE Handle,
- IN OUT EFI_GUID *FormSetGuid,
- OUT UINTN *BinaryLength,
- OUT UINT8 **BinaryData
- )
-{
- EFI_STATUS Status;
- EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
- UINTN BufferSize;
- UINT8 *Package;
- UINT8 *OpCodeData;
- UINT32 Offset;
- UINT32 Offset2;
- BOOLEAN ReturnDefault;
- UINT32 PackageListLength;
- EFI_HII_PACKAGE_HEADER PackageHeader;
-
- OpCodeData = NULL;
- Package = NULL;
- ZeroMem (&PackageHeader, sizeof (EFI_HII_PACKAGE_HEADER));;
-
- //
- // if FormSetGuid is NULL or zero GUID, return first FormSet in the package list
- //
- if (FormSetGuid == NULL || CompareGuid (FormSetGuid, &gZeroGuid)) {
- ReturnDefault = TRUE;
- } else {
- ReturnDefault = FALSE;
- }
-
- //
- // Get HII PackageList
- //
- BufferSize = 0;
- HiiPackageList = NULL;
- Status = mHiiDatabase->ExportPackageLists (mHiiDatabase, Handle, &BufferSize, HiiPackageList);
- if (Status == EFI_BUFFER_TOO_SMALL) {
- HiiPackageList = AllocatePool (BufferSize);
- ASSERT (HiiPackageList != NULL);
-
- Status = mHiiDatabase->ExportPackageLists (mHiiDatabase, Handle, &BufferSize, HiiPackageList);
- }
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Get Form package from this HII package List
- //
- Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
- Offset2 = 0;
- CopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));
-
- while (Offset < PackageListLength) {
- Package = ((UINT8 *) HiiPackageList) + Offset;
- CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
-
- if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {
- //
- // Search FormSet in this Form Package
- //
- Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);
- while (Offset2 < PackageHeader.Length) {
- OpCodeData = Package + Offset2;
-
- if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_FORM_SET_OP) {
- //
- // Check whether return default FormSet
- //
- if (ReturnDefault) {
- break;
- }
-
- //
- // FormSet GUID is specified, check it
- //
- if (CompareGuid (FormSetGuid, (EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER)))) {
- break;
- }
- }
-
- Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
- }
-
- if (Offset2 < PackageHeader.Length) {
- //
- // Target formset found
- //
- break;
- }
- }
-
- Offset += PackageHeader.Length;
- }
-
- if (Offset >= PackageListLength) {
- //
- // Form package not found in this Package List
- //
- gBS->FreePool (HiiPackageList);
- return EFI_NOT_FOUND;
- }
-
- if (ReturnDefault && FormSetGuid != NULL) {
- //
- // Return the default FormSet GUID
- //
- CopyMem (FormSetGuid, &((EFI_IFR_FORM_SET *) OpCodeData)->Guid, sizeof (EFI_GUID));
- }
-
- //
- // To determine the length of a whole FormSet IFR binary, one have to parse all the Opcodes
- // in this FormSet; So, here just simply copy the data from start of a FormSet to the end
- // of the Form Package.
- //
- *BinaryLength = PackageHeader.Length - Offset2;
- *BinaryData = AllocateCopyPool (*BinaryLength, OpCodeData);
-
- gBS->FreePool (HiiPackageList);
-
- if (*BinaryData == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
- return EFI_SUCCESS;
-}
-
-/**
- Initialize the internal data structure of a FormSet.
-
- @param Handle PackageList Handle
- @param FormSetGuid GUID of a formset. If not specified (NULL or zero
- GUID), take the first FormSet found in package
- list.
- @param FormSet FormSet data structure.
-
- @retval EFI_SUCCESS The function completed successfully.
- @retval EFI_NOT_FOUND The specified FormSet could not be found.
-
-**/
-EFI_STATUS
-InitializeFormSet (
- IN EFI_HII_HANDLE Handle,
- IN OUT EFI_GUID *FormSetGuid,
- OUT FORM_BROWSER_FORMSET *FormSet
- )
-{
- EFI_STATUS Status;
- EFI_HANDLE DriverHandle;
-
- Status = GetIfrBinaryData (Handle, FormSetGuid, &FormSet->IfrBinaryLength, &FormSet->IfrBinaryData);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- FormSet->HiiHandle = Handle;
- CopyMem (&FormSet->Guid, FormSetGuid, sizeof (EFI_GUID));
-
- //
- // Retrieve ConfigAccess Protocol associated with this HiiPackageList
- //
- Status = mHiiDatabase->GetPackageListHandle (mHiiDatabase, Handle, &DriverHandle);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- FormSet->DriverHandle = DriverHandle;
- Status = gBS->HandleProtocol (
- DriverHandle,
- &gEfiHiiConfigAccessProtocolGuid,
- (VOID **) &FormSet->ConfigAccess
- );
- if (EFI_ERROR (Status)) {
- //
- // Configuration Driver don't attach ConfigAccess protocol to its HII package
- // list, then there will be no configuration action required
- //
- FormSet->ConfigAccess = NULL;
- }
-
- //
- // Parse the IFR binary OpCodes
- //
- Status = ParseOpCodes (FormSet);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- return Status;
-}
-
/**
Set the data position at Offset with Width in Node->Buffer based
the value passed in.
@@ -276,6 +66,11 @@ SetNodeBuffer (
/**
Reset Question to its default value.
+ Note Framework 0.92's HII Implementation does not support for default value for these opcodes:
+ EFI_IFR_ORDERED_LIST_OP:
+ EFI_IFR_PASSWORD_OP:
+ EFI_IFR_STRING_OP:
+
@param FormSet FormSet data structure.
@param DefaultId The Class of the default.
@@ -330,22 +125,10 @@ GetQuestionDefault (
Default = QUESTION_DEFAULT_FROM_LINK (Link);
if (Default->DefaultId == DefaultId) {
- if (Default->ValueExpression != NULL) {
- //
- // Default is provided by an Expression, evaluate it
- //
- Status = EvaluateExpression (FormSet, Form, Default->ValueExpression);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- CopyMem (HiiValue, &Default->ValueExpression->Result, sizeof (EFI_HII_VALUE));
- } else {
- //
- // Default value is embedded in EFI_IFR_DEFAULT
- //
- CopyMem (HiiValue, &Default->Value, sizeof (EFI_HII_VALUE));
- }
+ //
+ // Default value is embedded in EFI_IFR_DEFAULT
+ //
+ CopyMem (HiiValue, &Default->Value, sizeof (EFI_HII_VALUE));
SetNodeBuffer (Node, HiiValue, Question->VarStoreInfo.VarOffset, Question->StorageWidth);
return EFI_SUCCESS;
@@ -580,41 +363,30 @@ GetBufferTypeDefaultId (
**/
EFI_STATUS
UefiIfrGetBufferTypeDefaults (
- IN EFI_HII_HANDLE UefiHiiHandle,
+ IN HII_THUNK_CONTEXT *ThunkContext,
OUT LIST_ENTRY **UefiDefaults
)
{
- FORM_BROWSER_FORMSET *FormSet;
- EFI_GUID FormSetGuid;
LIST_ENTRY *DefaultLink;
FORMSET_DEFAULTSTORE *DefaultStore;
EFI_STATUS Status;
ASSERT (UefiDefaults != NULL);
- FormSet = AllocateZeroPool (sizeof (FORM_BROWSER_FORMSET));
- ASSERT (FormSet != NULL);
-
- CopyGuid (&FormSetGuid, &gZeroGuid);
- Status = InitializeFormSet (UefiHiiHandle, &FormSetGuid, FormSet);
- ASSERT_EFI_ERROR (Status);
-
*UefiDefaults = AllocateZeroPool (sizeof (LIST_ENTRY));
ASSERT (UefiDefaults != NULL);
InitializeListHead (*UefiDefaults);
- DefaultLink = GetFirstNode (&FormSet->DefaultStoreListHead);
- while (!IsNull (&FormSet->DefaultStoreListHead, DefaultLink)) {
+ DefaultLink = GetFirstNode (&ThunkContext->FormSet->DefaultStoreListHead);
+ while (!IsNull (&ThunkContext->FormSet->DefaultStoreListHead, DefaultLink)) {
DefaultStore = FORMSET_DEFAULTSTORE_FROM_LINK(DefaultLink);
- Status = GetBufferTypeDefaultId (DefaultStore, FormSet, *UefiDefaults);
+ Status = GetBufferTypeDefaultId (DefaultStore, ThunkContext->FormSet, *UefiDefaults);
ASSERT_EFI_ERROR (Status);
- DefaultLink = GetNextNode (&FormSet->DefaultStoreListHead, DefaultLink);
+ DefaultLink = GetNextNode (&ThunkContext->FormSet->DefaultStoreListHead, DefaultLink);
}
- DestroyFormSet (FormSet);
-
return EFI_SUCCESS;
}
@@ -642,6 +414,7 @@ EFI_STATUS
UefiDefaultsToFwDefaults (
IN LIST_ENTRY *ListHead,
IN UINTN DefaultMask,
+ IN EFI_VARSTORE_ID UefiFormSetDefaultVarStoreId,
OUT EFI_HII_VARIABLE_PACK_LIST **VariablePackList
)
{
@@ -713,9 +486,9 @@ UefiDefaultsToFwDefaults (
//
// In UEFI, 0 is defined to be invalid for EFI_IFR_VARSTORE.VarStoreId.
// So the default storage of Var Store in VFR from a Framework module
- // should be translated to 0x0001 (RESERVED_VARSTORE_ID).
+ // should be translated to 0x0001 (FRAMEWORK_RESERVED_VARSTORE_ID).
//
- if (Node->StoreId == RESERVED_VARSTORE_ID) {
+ if (Node->StoreId == UefiFormSetDefaultVarStoreId) {
Pack->VariableId = 0;
} else {
Pack->VariableId = Node->StoreId;
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.h b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.h
index 020c5e5cbc..4b0c61e5fb 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.h
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrDefault.h
@@ -45,8 +45,8 @@ typedef struct {
**/
EFI_STATUS
UefiIfrGetBufferTypeDefaults (
- EFI_HII_HANDLE UefiHiiHandle,
- LIST_ENTRY **UefiDefaults
+ IN HII_THUNK_CONTEXT *ThunkContext,
+ OUT LIST_ENTRY **UefiDefaults
);
/**
@@ -73,6 +73,7 @@ EFI_STATUS
UefiDefaultsToFwDefaults (
IN LIST_ENTRY *UefiIfrDefaults,
IN UINTN DefaultMask,
+ IN EFI_VARSTORE_ID UefiFormSetDefaultVarStoreId,
OUT EFI_HII_VARIABLE_PACK_LIST **VariablePackList
);
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrParser.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrParser.c
index 8b130af45f..aacba8d416 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrParser.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrParser.c
@@ -12,22 +12,90 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
**/
+#include <PiDxe.h>
+
+#include <Protocol/Print.h>
+#include <Protocol/HiiConfigAccess.h>
+#include <Protocol/HiiConfigRouting.h>
+#include <Protocol/HiiDatabase.h>
+#include <Protocol/HiiString.h>
+
+#include <Library/BaseLib.h>
+#include <Library/BaseMemoryLib.h>
+#include <Library/DebugLib.h>
+#include <Library/HiiLib.h>
+#include <Library/IfrSupportLib.h>
+#include <Library/MemoryAllocationLib.h>
+#include <Library/PrintLib.h>
+#include <Library/UefiBootServicesTableLib.h>
+
+#include <MdeModuleHii.h>
+
#include "UefiIfrParser.h"
-#include "UefiIfrParserExpression.h"
-#include "UefiIfrParserInternal.h"
-#include "UefiIfrParserCommon.h"
+#include "UefiIfrParserExpression.h"
UINT16 mStatementIndex;
-UINT16 mExpressionOpCodeIndex;
BOOLEAN mInScopeSubtitle;
BOOLEAN mInScopeSuppress;
BOOLEAN mInScopeGrayOut;
-FORM_EXPRESSION *mSuppressExpression;
-FORM_EXPRESSION *mGrayOutExpression;
-EFI_GUID gZeroGuid = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
+EFI_GUID mFrameworkHiiCompatibilityGuid = EFI_IFR_FRAMEWORK_GUID;
+extern EFI_GUID mTianoHiiIfrGuid;
+
+LIST_ENTRY *
+GetOneOfOptionMapEntryListHead (
+ IN CONST FORM_BROWSER_FORMSET *FormSet,
+ IN UINT16 QuestionId
+ )
+{
+ LIST_ENTRY *Link;
+ ONE_OF_OPTION_MAP *Map;
+
+ Link = GetFirstNode (&FormSet->OneOfOptionMapListHead);
+
+ while (!IsNull (&FormSet->OneOfOptionMapListHead, Link)) {
+ Map = ONE_OF_OPTION_MAP_FROM_LINK (Link);
+ if (QuestionId == Map->QuestionId) {
+ return &Map->OneOfOptionMapEntryListHead;
+ }
+ Link = GetNextNode (&FormSet->OneOfOptionMapListHead, Link);
+ }
+
+ return NULL;
+}
+
+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 (Link2);
+
+ RemoveEntryList (Link2);
+
+ FreePool (MapEntry);
+ }
+
+ RemoveEntryList (Link);
+ FreePool (Map);
+ }
+}
+
/**
Initialize Statement header members.
@@ -61,8 +129,6 @@ CreateStatement (
InitializeListHead (&Statement->DefaultListHead);
InitializeListHead (&Statement->OptionListHead);
- InitializeListHead (&Statement->InconsistentListHead);
- InitializeListHead (&Statement->NoSubmitListHead);
Statement->Signature = FORM_BROWSER_STATEMENT_SIGNATURE;
@@ -72,14 +138,6 @@ CreateStatement (
CopyMem (&Statement->Prompt, &StatementHdr->Prompt, sizeof (EFI_STRING_ID));
CopyMem (&Statement->Help, &StatementHdr->Help, sizeof (EFI_STRING_ID));
- if (mInScopeSuppress) {
- Statement->SuppressExpression = mSuppressExpression;
- }
-
- if (mInScopeGrayOut) {
- Statement->GrayOutExpression = mGrayOutExpression;
- }
-
Statement->InSubtitle = mInScopeSubtitle;
//
@@ -90,7 +148,6 @@ CreateStatement (
return Statement;
}
-
/**
Initialize Question's members.
@@ -112,7 +169,6 @@ CreateQuestion (
EFI_IFR_QUESTION_HEADER *QuestionHdr;
LIST_ENTRY *Link;
FORMSET_STORAGE *Storage;
- NAME_VALUE_NODE *NameValueNode;
Statement = CreateStatement (OpCodeData, FormSet, Form);
if (Statement == NULL) {
@@ -124,6 +180,10 @@ CreateQuestion (
CopyMem (&Statement->VarStoreId, &QuestionHdr->VarStoreId, sizeof (EFI_VARSTORE_ID));
CopyMem (&Statement->VarStoreInfo.VarOffset, &QuestionHdr->VarStoreInfo.VarOffset, sizeof (UINT16));
+ if (FormSet->MaxQuestionId < QuestionHdr->QuestionId) {
+ FormSet->MaxQuestionId = QuestionHdr->QuestionId;
+ }
+
Statement->QuestionFlags = QuestionHdr->Flags;
if (Statement->VarStoreId == 0) {
@@ -149,59 +209,9 @@ CreateQuestion (
}
ASSERT (Statement->Storage != NULL);
- //
- // Initialilze varname for Name/Value or EFI Variable
- //
- if ((Statement->Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) ||
- (Statement->Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE)) {
- Statement->VariableName = GetToken (Statement->VarStoreInfo.VarName, FormSet->HiiHandle);
- ASSERT (Statement->VariableName != NULL);
-
- if (Statement->Storage->Type == EFI_HII_VARSTORE_NAME_VALUE) {
- //
- // Insert to Name/Value varstore list
- //
- NameValueNode = AllocateZeroPool (sizeof (NAME_VALUE_NODE));
- ASSERT (NameValueNode != NULL);
- NameValueNode->Signature = NAME_VALUE_NODE_SIGNATURE;
- NameValueNode->Name = AllocateCopyPool (StrSize (Statement->VariableName), Statement->VariableName);
- ASSERT (NameValueNode->Name != NULL);
- NameValueNode->Value = AllocateZeroPool (0x10);
- ASSERT (NameValueNode->Value != NULL);
- NameValueNode->EditValue = AllocateZeroPool (0x10);
- ASSERT (NameValueNode->EditValue != NULL);
-
- InsertTailList (&Statement->Storage->NameValueListHead, &NameValueNode->Link);
- }
- }
-
return Statement;
}
-
-/**
- Allocate a FORM_EXPRESSION node.
-
- @param Form The Form associated with this Expression
-
- @return Pointer to a FORM_EXPRESSION data structure.
-
-**/
-FORM_EXPRESSION *
-CreateExpression (
- IN OUT FORM_BROWSER_FORM *Form
- )
-{
- FORM_EXPRESSION *Expression;
-
- Expression = AllocateZeroPool (sizeof (FORM_EXPRESSION));
- Expression->Signature = FORM_EXPRESSION_SIGNATURE;
- InitializeListHead (&Expression->OpCodeListHead);
-
- return Expression;
-}
-
-
/**
Allocate a FORMSET_STORAGE data structure and insert to FormSet Storage List.
@@ -219,185 +229,11 @@ CreateStorage (
Storage = AllocateZeroPool (sizeof (FORMSET_STORAGE));
Storage->Signature = FORMSET_STORAGE_SIGNATURE;
- InitializeListHead (&Storage->NameValueListHead);
InsertTailList (&FormSet->StorageListHead, &Storage->Link);
return Storage;
}
-
-/**
- Create ConfigHdr string for a storage.
-
- @param FormSet Pointer of the current FormSet
- @param Storage Pointer of the storage
-
- @retval EFI_SUCCESS Initialize ConfigHdr success
-
-**/
-EFI_STATUS
-InitializeConfigHdr (
- IN FORM_BROWSER_FORMSET *FormSet,
- IN OUT FORMSET_STORAGE *Storage
- )
-{
- EFI_STATUS Status;
- UINTN StrBufferLen;
- CHAR16 *Name;
-
- if (Storage->Type == EFI_HII_VARSTORE_BUFFER) {
- Name = Storage->Name;
- } else {
- Name = NULL;
- }
-
- StrBufferLen = 0;
- Status = ConstructConfigHdr (
- Storage->ConfigHdr,
- &StrBufferLen,
- &Storage->Guid,
- Name,
- FormSet->DriverHandle
- );
- if (Status == EFI_BUFFER_TOO_SMALL) {
- Storage->ConfigHdr = AllocateZeroPool (StrBufferLen);
- Status = ConstructConfigHdr (
- Storage->ConfigHdr,
- &StrBufferLen,
- &Storage->Guid,
- Name,
- FormSet->DriverHandle
- );
- }
-
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Storage->ConfigRequest = AllocateCopyPool (StrBufferLen, Storage->ConfigHdr);
- Storage->SpareStrLen = 0;
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Initialize Request Element of a Question. <RequestElement> ::= '&'<BlockName> | '&'<Label>
-
- @param FormSet Pointer of the current FormSet.
- @param Question The Question to be initialized.
-
- @retval EFI_SUCCESS Function success.
- @retval EFI_INVALID_PARAMETER No storage associated with the Question.
-
-**/
-EFI_STATUS
-InitializeRequestElement (
- IN OUT FORM_BROWSER_FORMSET *FormSet,
- IN OUT FORM_BROWSER_STATEMENT *Question
- )
-{
- FORMSET_STORAGE *Storage;
- UINTN StrLen;
- UINTN StringSize;
- CHAR16 *NewStr;
- CHAR16 RequestElement[30];
-
- Storage = Question->Storage;
- if (Storage == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (Storage->Type == EFI_HII_VARSTORE_EFI_VARIABLE) {
- //
- // <ConfigRequest> is unnecessary for EFI variable storage,
- // GetVariable()/SetVariable() will be used to retrieve/save values
- //
- return EFI_SUCCESS;
- }
-
- //
- // Prepare <RequestElement>
- //
- if (Storage->Type == EFI_HII_VARSTORE_BUFFER) {
- StrLen = UnicodeSPrint (
- RequestElement,
- 30 * sizeof (CHAR16),
- L"&OFFSET=%x&WIDTH=%x",
- Question->VarStoreInfo.VarOffset,
- Question->StorageWidth
- );
- Question->BlockName = AllocateCopyPool ((StrLen + 1) * sizeof (CHAR16), RequestElement);
- } else {
- StrLen = UnicodeSPrint (RequestElement, 30 * sizeof (CHAR16), L"&%s", Question->VariableName);
- }
-
- if ((Question->Operand == EFI_IFR_PASSWORD_OP) && (Question->QuestionFlags & EFI_IFR_FLAG_CALLBACK)) {
- //
- // Password with CALLBACK flag is stored in encoded format,
- // so don't need to append it to <ConfigRequest>
- //
- return EFI_SUCCESS;
- }
-
- //
- // Append <RequestElement> to <ConfigRequest>
- //
- if (StrLen > Storage->SpareStrLen) {
- //
- // Old String buffer is not sufficient for RequestElement, allocate a new one
- //
- StringSize = (Storage->ConfigRequest != NULL) ? StrSize (Storage->ConfigRequest) : sizeof (CHAR16);
- NewStr = AllocateZeroPool (StringSize + CONFIG_REQUEST_STRING_INCREMENTAL * sizeof (CHAR16));
- if (Storage->ConfigRequest != NULL) {
- CopyMem (NewStr, Storage->ConfigRequest, StringSize);
- gBS->FreePool (Storage->ConfigRequest);
- }
- Storage->ConfigRequest = NewStr;
- Storage->SpareStrLen = CONFIG_REQUEST_STRING_INCREMENTAL;
- }
-
- StrCat (Storage->ConfigRequest, RequestElement);
- Storage->ElementCount++;
- Storage->SpareStrLen -= StrLen;
-
- return EFI_SUCCESS;
-}
-
-
-/**
- Free resources of a Expression
-
- @param FormSet Pointer of the Expression
-
- @return None.
-
-**/
-VOID
-DestroyExpression (
- IN FORM_EXPRESSION *Expression
- )
-{
- LIST_ENTRY *Link;
- EXPRESSION_OPCODE *OpCode;
-
- while (!IsListEmpty (&Expression->OpCodeListHead)) {
- Link = GetFirstNode (&Expression->OpCodeListHead);
- OpCode = EXPRESSION_OPCODE_FROM_LINK (Link);
- RemoveEntryList (&OpCode->Link);
-
- if (OpCode->ValueList != NULL) {
- FreePool (OpCode->ValueList);
- }
- }
-
- //
- // Free this Expression
- //
- gBS->FreePool (Expression);
-}
-
-
/**
Free resources of a storage
@@ -411,31 +247,14 @@ DestroyStorage (
IN FORMSET_STORAGE *Storage
)
{
- LIST_ENTRY *Link;
- NAME_VALUE_NODE *NameValueNode;
-
if (Storage == NULL) {
return;
}
- FreePool (Storage->Name);
- FreePool (Storage->Buffer);
- FreePool (Storage->EditBuffer);
-
- while (!IsListEmpty (&Storage->NameValueListHead)) {
- Link = GetFirstNode (&Storage->NameValueListHead);
- NameValueNode = NAME_VALUE_NODE_FROM_LINK (Link);
- RemoveEntryList (&NameValueNode->Link);
-
- FreePool (NameValueNode->Name);
- FreePool (NameValueNode->Value);
- FreePool (NameValueNode->EditValue);
- FreePool (NameValueNode);
+ if (Storage->Name!= NULL) {
+ FreePool (Storage->Name);
}
- FreePool (Storage->ConfigHdr);
- FreePool (Storage->ConfigRequest);
-
FreePool (Storage);
}
@@ -456,7 +275,6 @@ DestroyStatement (
LIST_ENTRY *Link;
QUESTION_DEFAULT *Default;
QUESTION_OPTION *Option;
- FORM_EXPRESSION *Expression;
//
// Free Default value List
@@ -480,34 +298,6 @@ DestroyStatement (
gBS->FreePool (Option);
}
- //
- // Free Inconsistent List
- //
- while (!IsListEmpty (&Statement->InconsistentListHead)) {
- Link = GetFirstNode (&Statement->InconsistentListHead);
- Expression = FORM_EXPRESSION_FROM_LINK (Link);
- RemoveEntryList (&Expression->Link);
-
- DestroyExpression (Expression);
- }
-
- //
- // Free NoSubmit List
- //
- while (!IsListEmpty (&Statement->NoSubmitListHead)) {
- Link = GetFirstNode (&Statement->NoSubmitListHead);
- Expression = FORM_EXPRESSION_FROM_LINK (Link);
- RemoveEntryList (&Expression->Link);
-
- DestroyExpression (Expression);
- }
-
- if (Statement->VariableName != NULL) {
- FreePool (Statement->VariableName);
- }
- if (Statement->BlockName != NULL) {
- FreePool (Statement->BlockName);
- }
}
@@ -526,21 +316,9 @@ DestroyForm (
)
{
LIST_ENTRY *Link;
- FORM_EXPRESSION *Expression;
FORM_BROWSER_STATEMENT *Statement;
//
- // Free Form Expressions
- //
- while (!IsListEmpty (&Form->ExpressionListHead)) {
- Link = GetFirstNode (&Form->ExpressionListHead);
- Expression = FORM_EXPRESSION_FROM_LINK (Link);
- RemoveEntryList (&Expression->Link);
-
- DestroyExpression (Expression);
- }
-
- //
// Free Statements/Questions
//
while (!IsListEmpty (&Form->StatementListHead)) {
@@ -623,10 +401,9 @@ DestroyFormSet (
if (FormSet->StatementBuffer != NULL) {
FreePool (FormSet->StatementBuffer);
}
- if (FormSet->ExpressionBuffer != NULL) {
- FreePool (FormSet->ExpressionBuffer);
- }
+ DestoryOneOfOptionMap (&FormSet->OneOfOptionMapListHead);
+
FreePool (FormSet);
}
@@ -718,8 +495,6 @@ ParseOpCodes (
UINT16 Index;
FORM_BROWSER_FORM *CurrentForm;
FORM_BROWSER_STATEMENT *CurrentStatement;
- EXPRESSION_OPCODE *ExpressionOpCode;
- FORM_EXPRESSION *CurrentExpression;
UINT8 Operand;
UINT8 Scope;
UINTN OpCodeOffset;
@@ -736,13 +511,18 @@ ParseOpCodes (
EFI_IMAGE_ID *ImageId;
BOOLEAN SuppressForOption;
BOOLEAN InScopeOptionSuppress;
- FORM_EXPRESSION *OptionSuppressExpression;
BOOLEAN InScopeDisable;
UINT16 DepthOfDisable;
BOOLEAN OpCodeDisabled;
BOOLEAN SingleOpCodeExpression;
BOOLEAN InScopeDefault;
EFI_HII_VALUE *Value;
+ LIST_ENTRY *OneOfOptinMapEntryListHead;
+ EFI_IFR_GUID_OPTIONKEY *OptionMap;
+ ONE_OF_OPTION_MAP *OneOfOptionMap;
+ ONE_OF_OPTION_MAP_ENTRY *OneOfOptionMapEntry;
+ UINT8 OneOfType;
+ EFI_IFR_ONE_OF *OneOfOpcode;
mInScopeSubtitle = FALSE;
SuppressForOption = FALSE;
@@ -754,15 +534,19 @@ ParseOpCodes (
OpCodeDisabled = FALSE;
SingleOpCodeExpression = FALSE;
InScopeDefault = FALSE;
- CurrentExpression = NULL;
CurrentDefault = NULL;
CurrentOption = NULL;
- OptionSuppressExpression = NULL;
+
+ //
+ // Set to a invalid value.
+ //
+ OneOfType = (UINT8) -1;
//
// Get the number of Statements and Expressions
//
CountOpCodes (FormSet, &NumberOfStatement, &NumberOfExpression);
+ FormSet->NumberOfStatement = NumberOfStatement;
mStatementIndex = 0;
FormSet->StatementBuffer = AllocateZeroPool (NumberOfStatement * sizeof (FORM_BROWSER_STATEMENT));
@@ -770,15 +554,10 @@ ParseOpCodes (
return EFI_OUT_OF_RESOURCES;
}
- mExpressionOpCodeIndex = 0;
- FormSet->ExpressionBuffer = AllocateZeroPool (NumberOfExpression * sizeof (EXPRESSION_OPCODE));
- if (FormSet->ExpressionBuffer == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
-
InitializeListHead (&FormSet->StorageListHead);
InitializeListHead (&FormSet->DefaultStoreListHead);
InitializeListHead (&FormSet->FormListHead);
+ InitializeListHead (&FormSet->OneOfOptionMapListHead);
CurrentForm = NULL;
CurrentStatement = NULL;
@@ -827,157 +606,6 @@ ParseOpCodes (
}
if (IsExpressionOpCode (Operand)) {
- ExpressionOpCode = &FormSet->ExpressionBuffer[mExpressionOpCodeIndex];
- mExpressionOpCodeIndex++;
-
- ExpressionOpCode->Signature = EXPRESSION_OPCODE_SIGNATURE;
- ExpressionOpCode->Operand = Operand;
- Value = &ExpressionOpCode->Value;
-
- switch (Operand) {
- case EFI_IFR_EQ_ID_VAL_OP:
- CopyMem (&ExpressionOpCode->QuestionId, &((EFI_IFR_EQ_ID_VAL *) OpCodeData)->QuestionId, sizeof (EFI_QUESTION_ID));
-
- Value->Type = EFI_IFR_TYPE_NUM_SIZE_16;
- CopyMem (&Value->Value.u16, &((EFI_IFR_EQ_ID_VAL *) OpCodeData)->Value, sizeof (UINT16));
- break;
-
- case EFI_IFR_EQ_ID_ID_OP:
- CopyMem (&ExpressionOpCode->QuestionId, &((EFI_IFR_EQ_ID_ID *) OpCodeData)->QuestionId1, sizeof (EFI_QUESTION_ID));
- CopyMem (&ExpressionOpCode->QuestionId2, &((EFI_IFR_EQ_ID_ID *) OpCodeData)->QuestionId2, sizeof (EFI_QUESTION_ID));
- break;
-
- case EFI_IFR_EQ_ID_LIST_OP:
- CopyMem (&ExpressionOpCode->QuestionId, &((EFI_IFR_EQ_ID_LIST *) OpCodeData)->QuestionId, sizeof (EFI_QUESTION_ID));
- CopyMem (&ExpressionOpCode->ListLength, &((EFI_IFR_EQ_ID_LIST *) OpCodeData)->ListLength, sizeof (UINT16));
- ExpressionOpCode->ValueList = AllocateCopyPool (ExpressionOpCode->ListLength * sizeof (UINT16), &((EFI_IFR_EQ_ID_LIST *) OpCodeData)->ValueList);
- break;
-
- case EFI_IFR_TO_STRING_OP:
- case EFI_IFR_FIND_OP:
- ExpressionOpCode->Format = (( EFI_IFR_TO_STRING *) OpCodeData)->Format;
- break;
-
- case EFI_IFR_STRING_REF1_OP:
- Value->Type = EFI_IFR_TYPE_STRING;
- CopyMem (&Value->Value.string, &(( EFI_IFR_STRING_REF1 *) OpCodeData)->StringId, sizeof (EFI_STRING_ID));
- break;
-
- case EFI_IFR_RULE_REF_OP:
- ExpressionOpCode->RuleId = (( EFI_IFR_RULE_REF *) OpCodeData)->RuleId;
- break;
-
- case EFI_IFR_SPAN_OP:
- ExpressionOpCode->Flags = (( EFI_IFR_SPAN *) OpCodeData)->Flags;
- break;
-
- case EFI_IFR_THIS_OP:
- ExpressionOpCode->QuestionId = CurrentStatement->QuestionId;
- break;
-
- case EFI_IFR_QUESTION_REF1_OP:
- CopyMem (&ExpressionOpCode->QuestionId, &((EFI_IFR_EQ_ID_LIST *) OpCodeData)->QuestionId, sizeof (EFI_QUESTION_ID));
- break;
-
- case EFI_IFR_QUESTION_REF3_OP:
- if (OpCodeLength >= sizeof (EFI_IFR_QUESTION_REF3_2)) {
- CopyMem (&ExpressionOpCode->DevicePath, &(( EFI_IFR_QUESTION_REF3_2 *) OpCodeData)->DevicePath, sizeof (EFI_STRING_ID));
-
- if (OpCodeLength >= sizeof (EFI_IFR_QUESTION_REF3_3)) {
- CopyMem (&ExpressionOpCode->Guid, &(( EFI_IFR_QUESTION_REF3_3 *) OpCodeData)->Guid, sizeof (EFI_GUID));
- }
- }
- break;
-
- //
- // constant
- //
- case EFI_IFR_TRUE_OP:
- Value->Type = EFI_IFR_TYPE_BOOLEAN;
- Value->Value.b = TRUE;
- break;
-
- case EFI_IFR_FALSE_OP:
- Value->Type = EFI_IFR_TYPE_BOOLEAN;
- Value->Value.b = FALSE;
- break;
-
- case EFI_IFR_ONE_OP:
- Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
- Value->Value.u8 = 1;
- break;
-
- case EFI_IFR_ZERO_OP:
- Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
- Value->Value.u8 = 0;
- break;
-
- case EFI_IFR_ONES_OP:
- Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
- Value->Value.u64 = 0xffffffffffffffffULL;
- break;
-
- case EFI_IFR_UINT8_OP:
- Value->Type = EFI_IFR_TYPE_NUM_SIZE_8;
- Value->Value.u8 = (( EFI_IFR_UINT8 *) OpCodeData)->Value;
- break;
-
- case EFI_IFR_UINT16_OP:
- Value->Type = EFI_IFR_TYPE_NUM_SIZE_16;
- CopyMem (&Value->Value.u16, &(( EFI_IFR_UINT16 *) OpCodeData)->Value, sizeof (UINT16));
- break;
-
- case EFI_IFR_UINT32_OP:
- Value->Type = EFI_IFR_TYPE_NUM_SIZE_32;
- CopyMem (&Value->Value.u32, &(( EFI_IFR_UINT32 *) OpCodeData)->Value, sizeof (UINT32));
- break;
-
- case EFI_IFR_UINT64_OP:
- Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
- CopyMem (&Value->Value.u64, &(( EFI_IFR_UINT64 *) OpCodeData)->Value, sizeof (UINT64));
- break;
-
- case EFI_IFR_UNDEFINED_OP:
- Value->Type = EFI_IFR_TYPE_OTHER;
- break;
-
- case EFI_IFR_VERSION_OP:
- Value->Type = EFI_IFR_TYPE_NUM_SIZE_16;
- Value->Value.u16 = EFI_IFR_SPECIFICATION_VERSION;
- break;
-
- default:
- break;
- }
-
- InsertTailList (&CurrentExpression->OpCodeListHead, &ExpressionOpCode->Link);
-
- if (SingleOpCodeExpression) {
- //
- // There are two cases to indicate the end of an Expression:
- // for single OpCode expression: one Expression OpCode
- // for expression consists of more than one OpCode: EFI_IFR_END
- //
- SingleOpCodeExpression = FALSE;
-
- if (InScopeDisable) {
- //
- // Evaluate DisableIf expression
- //
- Status = EvaluateExpression (FormSet, CurrentForm, CurrentExpression);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (CurrentExpression->Result.Type != EFI_IFR_TYPE_BOOLEAN) {
- return EFI_INVALID_PARAMETER;
- }
-
- OpCodeDisabled = CurrentExpression->Result.Value.b;
- }
-
- CurrentExpression = NULL;
- }
-
continue;
}
@@ -1004,7 +632,7 @@ ParseOpCodes (
//
CurrentForm = AllocateZeroPool (sizeof (FORM_BROWSER_FORM));
CurrentForm->Signature = FORM_BROWSER_FORM_SIGNATURE;
- InitializeListHead (&CurrentForm->ExpressionListHead);
+
InitializeListHead (&CurrentForm->StatementListHead);
CopyMem (&CurrentForm->FormId, &((EFI_IFR_FORM *) OpCodeData)->FormId, sizeof (UINT16));
@@ -1030,9 +658,6 @@ ParseOpCodes (
CopyMem (&Storage->Guid, &((EFI_IFR_VARSTORE *) OpCodeData)->Guid, sizeof (EFI_GUID));
CopyMem (&Storage->Size, &((EFI_IFR_VARSTORE *) OpCodeData)->Size, sizeof (UINT16));
- Storage->Buffer = AllocateZeroPool (Storage->Size);
- Storage->EditBuffer = AllocateZeroPool (Storage->Size);
-
AsciiString = (CHAR8 *) ((EFI_IFR_VARSTORE *) OpCodeData)->Name;
Storage->Name = AllocateZeroPool (AsciiStrSize (AsciiString) * 2);
ASSERT (Storage->Name != NULL);
@@ -1040,26 +665,11 @@ ParseOpCodes (
Storage->Name[Index] = (CHAR16) AsciiString[Index];
}
- //
- // Initialize <ConfigHdr>
- //
- InitializeConfigHdr (FormSet, Storage);
break;
case EFI_IFR_VARSTORE_NAME_VALUE_OP:
- //
- // Create a name/value Storage for this FormSet
- //
- Storage = CreateStorage (FormSet);
- Storage->Type = EFI_HII_VARSTORE_NAME_VALUE;
+ ASSERT (FALSE);
- CopyMem (&Storage->VarStoreId, &((EFI_IFR_VARSTORE_NAME_VALUE *) OpCodeData)->VarStoreId, sizeof (EFI_VARSTORE_ID));
- CopyMem (&Storage->Guid, &((EFI_IFR_VARSTORE_NAME_VALUE *) OpCodeData)->Guid, sizeof (EFI_GUID));
-
- //
- // Initialize <ConfigHdr>
- //
- InitializeConfigHdr (FormSet, Storage);
break;
case EFI_IFR_VARSTORE_EFI_OP:
@@ -1191,11 +801,14 @@ ParseOpCodes (
break;
}
- InitializeRequestElement (FormSet, CurrentStatement);
-
if ((Operand == EFI_IFR_ONE_OF_OP) && Scope) {
SuppressForOption = TRUE;
}
+
+ if (Operand == EFI_IFR_ONE_OF_OP) {
+ OneOfOpcode = (EFI_IFR_ONE_OF *) OpCodeData;
+ OneOfType = OneOfOpcode->Flags & EFI_IFR_NUMERIC_SIZE;
+ }
break;
case EFI_IFR_ORDERED_LIST_OP:
@@ -1204,7 +817,6 @@ ParseOpCodes (
CurrentStatement->Flags = ((EFI_IFR_ORDERED_LIST *) OpCodeData)->Flags;
CurrentStatement->MaxContainers = ((EFI_IFR_ORDERED_LIST *) OpCodeData)->MaxContainers;
CurrentStatement->StorageWidth = (UINT16)(CurrentStatement->MaxContainers * sizeof (UINT8));
- InitializeRequestElement (FormSet, CurrentStatement);
//
// No buffer type is defined in EFI_IFR_TYPE_VALUE, so a Configuration Driver
@@ -1226,7 +838,6 @@ ParseOpCodes (
CurrentStatement->StorageWidth = sizeof (BOOLEAN);
CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_BOOLEAN;
- InitializeRequestElement (FormSet, CurrentStatement);
break;
case EFI_IFR_STRING_OP:
@@ -1245,7 +856,6 @@ ParseOpCodes (
CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_STRING;
CurrentStatement->BufferValue = AllocateZeroPool (CurrentStatement->StorageWidth);
- InitializeRequestElement (FormSet, CurrentStatement);
break;
case EFI_IFR_PASSWORD_OP:
@@ -1263,7 +873,6 @@ ParseOpCodes (
CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_STRING;
CurrentStatement->BufferValue = AllocateZeroPool (CurrentStatement->StorageWidth);
- InitializeRequestElement (FormSet, CurrentStatement);
break;
case EFI_IFR_DATE_OP:
@@ -1272,17 +881,6 @@ ParseOpCodes (
CurrentStatement->Flags = ((EFI_IFR_DATE *) OpCodeData)->Flags;
CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_DATE;
- if ((CurrentStatement->Flags & EFI_QF_DATE_STORAGE) == QF_DATE_STORAGE_NORMAL) {
- CurrentStatement->StorageWidth = sizeof (EFI_HII_DATE);
-
- InitializeRequestElement (FormSet, CurrentStatement);
- } else {
- //
- // Don't assign storage for RTC type of date/time
- //
- CurrentStatement->Storage = NULL;
- CurrentStatement->StorageWidth = 0;
- }
break;
case EFI_IFR_TIME_OP:
@@ -1291,17 +889,6 @@ ParseOpCodes (
CurrentStatement->Flags = ((EFI_IFR_TIME *) OpCodeData)->Flags;
CurrentStatement->HiiValue.Type = EFI_IFR_TYPE_TIME;
- if ((CurrentStatement->Flags & QF_TIME_STORAGE) == QF_TIME_STORAGE_NORMAL) {
- CurrentStatement->StorageWidth = sizeof (EFI_IFR_TIME);
-
- InitializeRequestElement (FormSet, CurrentStatement);
- } else {
- //
- // Don't assign storage for RTC type of date/time
- //
- CurrentStatement->Storage = NULL;
- CurrentStatement->StorageWidth = 0;
- }
break;
//
@@ -1348,10 +935,6 @@ ParseOpCodes (
CopyMem (&CurrentOption->Value.Value, &((EFI_IFR_ONE_OF_OPTION *) OpCodeData)->Value, sizeof (EFI_IFR_TYPE_VALUE));
ExtendValueToU64 (&CurrentOption->Value);
- if (InScopeOptionSuppress) {
- CurrentOption->SuppressExpression = OptionSuppressExpression;
- }
-
//
// Insert to Option list of current Question
//
@@ -1363,99 +946,25 @@ ParseOpCodes (
//
case EFI_IFR_NO_SUBMIT_IF_OP:
case EFI_IFR_INCONSISTENT_IF_OP:
- //
- // Create an Expression node
- //
- CurrentExpression = CreateExpression (CurrentForm);
- CopyMem (&CurrentExpression->Error, &((EFI_IFR_INCONSISTENT_IF *) OpCodeData)->Error, sizeof (EFI_STRING_ID));
-
- if (Operand == EFI_IFR_NO_SUBMIT_IF_OP) {
- CurrentExpression->Type = EFI_HII_EXPRESSION_NO_SUBMIT_IF;
- InsertTailList (&CurrentStatement->NoSubmitListHead, &CurrentExpression->Link);
- } else {
- CurrentExpression->Type = EFI_HII_EXPRESSION_INCONSISTENT_IF;
- InsertTailList (&CurrentStatement->InconsistentListHead, &CurrentExpression->Link);
- }
break;
case EFI_IFR_SUPPRESS_IF_OP:
- //
- // Question and Option will appear in scope of this OpCode
- //
- CurrentExpression = CreateExpression (CurrentForm);
- CurrentExpression->Type = EFI_HII_EXPRESSION_SUPPRESS_IF;
- InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link);
-
- if (SuppressForOption) {
- InScopeOptionSuppress = TRUE;
- OptionSuppressExpression = CurrentExpression;
- } else {
- mInScopeSuppress = TRUE;
- mSuppressExpression = CurrentExpression;
- }
break;
case EFI_IFR_GRAY_OUT_IF_OP:
- //
- // Questions will appear in scope of this OpCode
- //
- CurrentExpression = CreateExpression (CurrentForm);
- CurrentExpression->Type = EFI_HII_EXPRESSION_GRAY_OUT_IF;
- InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link);
-
- mInScopeGrayOut = TRUE;
- mGrayOutExpression = CurrentExpression;
break;
case EFI_IFR_DISABLE_IF_OP:
- //
- // The DisableIf expression should only rely on constant, so it could be
- // evaluated at initialization and it will not be queued
- //
- CurrentExpression = AllocateZeroPool (sizeof (FORM_EXPRESSION));
- CurrentExpression->Signature = FORM_EXPRESSION_SIGNATURE;
- CurrentExpression->Type = EFI_HII_EXPRESSION_DISABLE_IF;
- InitializeListHead (&CurrentExpression->OpCodeListHead);
-
- InScopeDisable = TRUE;
- OpCodeDisabled = FALSE;
+ ASSERT (FALSE);
- //
- // Take a look at next OpCode to see whether current expression consists
- // of single OpCode
- //
- if (((EFI_IFR_OP_HEADER *) (OpCodeData + OpCodeLength))->Scope == 0) {
- SingleOpCodeExpression = TRUE;
- }
- break;
//
// Expression
//
case EFI_IFR_VALUE_OP:
- CurrentExpression = CreateExpression (CurrentForm);
- CurrentExpression->Type = EFI_HII_EXPRESSION_VALUE;
- InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link);
-
- if (InScopeDefault) {
- //
- // Used for default (EFI_IFR_DEFAULT)
- //
- CurrentDefault->ValueExpression = CurrentExpression;
- } else {
- //
- // If used for a question, then the question will be read-only
- //
- CurrentStatement->ValueExpression = CurrentExpression;
- }
break;
case EFI_IFR_RULE_OP:
- CurrentExpression = CreateExpression (CurrentForm);
- CurrentExpression->Type = EFI_HII_EXPRESSION_RULE;
-
- CurrentExpression->RuleId = ((EFI_IFR_RULE *) OpCodeData)->RuleId;
- InsertTailList (&CurrentForm->ExpressionListHead, &CurrentExpression->Link);
break;
//
@@ -1500,7 +1009,9 @@ ParseOpCodes (
// Vendor specific
//
case EFI_IFR_GUID_OP:
- if (CompareGuid (&gTianoHiiIfrGuid, (EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER)))) {
+ OptionMap = (EFI_IFR_GUID_OPTIONKEY *) OpCodeData;
+
+ if (CompareGuid (&mTianoHiiIfrGuid, (EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER)))) {
//
// Tiano specific GUIDed opcodes
//
@@ -1511,18 +1022,6 @@ ParseOpCodes (
//
break;
-#if 0
- case EFI_IFR_EXTEND_OP_BANNER:
- if (FormSet->SubClass == EFI_FRONT_PAGE_SUBCLASS) {
- CopyMem (
- &BannerData->Banner[((EFI_IFR_GUID_BANNER *) OpCodeData)->LineNumber][
- ((EFI_IFR_GUID_BANNER *) OpCodeData)->Alignment],
- &((EFI_IFR_GUID_BANNER *) OpCodeData)->Title,
- sizeof (EFI_STRING_ID)
- );
- }
- break;
-#endif
case EFI_IFR_EXTEND_OP_CLASS:
CopyMem (&FormSet->Class, &((EFI_IFR_GUID_CLASS *) OpCodeData)->Class, sizeof (UINT16));
@@ -1535,7 +1034,36 @@ ParseOpCodes (
default:
break;
}
- }
+ }
+ else if (CompareGuid ((EFI_GUID *)(VOID *)&OptionMap->Guid, &mFrameworkHiiCompatibilityGuid)) {
+ if (OptionMap->ExtendOpCode == EFI_IFR_EXTEND_OP_OPTIONKEY) {
+ OneOfOptinMapEntryListHead = GetOneOfOptionMapEntryListHead (FormSet, 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;
+
+ //
+ // Make sure OneOfType is initialized.
+ //
+ ASSERT (OneOfType != (UINT8) -1);
+ OneOfOptionMap->ValueType = OneOfType;
+ InitializeListHead (&OneOfOptionMap->OneOfOptionMapEntryListHead);
+ OneOfOptinMapEntryListHead = &OneOfOptionMap->OneOfOptionMapEntryListHead;
+ InsertTailList (&FormSet->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);
+ }
+ }
break;
//
@@ -1610,29 +1138,6 @@ ParseOpCodes (
default:
if (IsExpressionOpCode (ScopeOpCode)) {
- if (InScopeDisable) {
- //
- // Evaluate DisableIf expression
- //
- Status = EvaluateExpression (FormSet, CurrentForm, CurrentExpression);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (CurrentExpression->Result.Type != EFI_IFR_TYPE_BOOLEAN) {
- return EFI_INVALID_PARAMETER;
- }
-
- OpCodeDisabled = CurrentExpression->Result.Value.b;
- //
- // DisableIf Expression is only used once and not quequed, free it
- //
- DestroyExpression (CurrentExpression);
- }
-
- //
- // End of current Expression
- //
- CurrentExpression = NULL;
}
break;
}
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrParser.h b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrParser.h
index cfc12035cc..7ca232c6e6 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrParser.h
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrParser.h
@@ -1,6 +1,12 @@
/** @file
Function and Macro defintions for IFR parsing. To get the default value from IFR package, the IFR
opcode needs to be parsed. Most of code is taken from MdeModulePkg\Universal\SetupBrowserDxe\IfrParse.c.
+ This parser is simplified from the origianl IfrParser.c in the following way:
+
+ 1) All data structure definition that have nothing to do with IFR Default value scanning (
+ required to implement Framework HII's GetDefaultImage ()) is removed.
+ 2) Ignore the IFR opcode which is invalid for Form Package
+ generated using Framework VFR file.
Copyright (c) 2008, Intel Corporation
All rights reserved. This program and the accompanying materials
@@ -16,13 +22,6 @@
#ifndef _HII_THUNK_UEFI_IFR_PARSER_
#define _HII_THUNK_UEFI_IFR_PARSER_
-#include <PiDxe.h>
-
-#include <Protocol/Print.h>
-#include <Protocol/HiiConfigAccess.h>
-#include <Protocol/HiiConfigRouting.h>
-#include <Protocol/HiiDatabase.h>
-#include <Protocol/HiiString.h>
//
// IFR relative definition
@@ -44,6 +43,34 @@
extern EFI_GUID gTianoHiiIfrGuid;
+#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 {
+ 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;
+
+ UINT16 VarStoreId;
+
+ UINT8 ValueType; //EFI_IFR_TYPE_NUM_*
+
+ EFI_QUESTION_ID QuestionId;
+
+ LIST_ENTRY OneOfOptionMapEntryListHead; //ONE_OF_OPTION_MAP_ENTRY
+} ONE_OF_OPTION_MAP;
+
typedef struct {
UINT8 Type;
@@ -52,16 +79,6 @@ typedef struct {
#define NAME_VALUE_NODE_SIGNATURE EFI_SIGNATURE_32 ('N', 'V', 'S', 'T')
-typedef struct {
- UINTN Signature;
- LIST_ENTRY Link;
- CHAR16 *Name;
- CHAR16 *Value;
- CHAR16 *EditValue;
-} NAME_VALUE_NODE;
-
-#define NAME_VALUE_NODE_FROM_LINK(a) CR (a, NAME_VALUE_NODE, Link, NAME_VALUE_NODE_SIGNATURE)
-
#define FORMSET_STORAGE_SIGNATURE EFI_SIGNATURE_32 ('F', 'S', 'T', 'G')
typedef struct {
@@ -75,21 +92,15 @@ typedef struct {
CHAR16 *Name; // For EFI_IFR_VARSTORE
UINT16 Size;
- UINT8 *Buffer;
- UINT8 *EditBuffer; // Edit copy for Buffer Storage
-
- LIST_ENTRY NameValueListHead; // List of NAME_VALUE_NODE
UINT32 Attributes; // For EFI_IFR_VARSTORE_EFI: EFI Variable attribute
- CHAR16 *ConfigHdr; // <ConfigHdr>
- CHAR16 *ConfigRequest; // <ConfigRequest> = <ConfigHdr> + <RequestElement>
- UINTN ElementCount; // Number of <RequestElement> in the <ConfigRequest>
- UINTN SpareStrLen; // Spare length of ConfigRequest string buffer
} FORMSET_STORAGE;
#define FORMSET_STORAGE_FROM_LINK(a) CR (a, FORMSET_STORAGE, Link, FORMSET_STORAGE_SIGNATURE)
+#if 0
+
#define EXPRESSION_OPCODE_SIGNATURE EFI_SIGNATURE_32 ('E', 'X', 'O', 'P')
typedef struct {
@@ -133,6 +144,7 @@ typedef struct {
} FORM_EXPRESSION;
#define FORM_EXPRESSION_FROM_LINK(a) CR (a, FORM_EXPRESSION, Link, FORM_EXPRESSION_SIGNATURE)
+#endif
#define QUESTION_DEFAULT_SIGNATURE EFI_SIGNATURE_32 ('Q', 'D', 'F', 'T')
@@ -143,7 +155,6 @@ typedef struct {
UINT16 DefaultId;
EFI_HII_VALUE Value; // Default value
- FORM_EXPRESSION *ValueExpression; // Not-NULL indicates default value is provided by EFI_IFR_VALUE
} QUESTION_DEFAULT;
#define QUESTION_DEFAULT_FROM_LINK(a) CR (a, QUESTION_DEFAULT, Link, QUESTION_DEFAULT_SIGNATURE)
@@ -159,7 +170,9 @@ typedef struct {
EFI_HII_VALUE Value;
EFI_IMAGE_ID ImageId;
+#if 0
FORM_EXPRESSION *SuppressExpression; // Non-NULL indicates nested inside of SuppressIf
+#endif
} QUESTION_OPTION;
#define QUESTION_OPTION_FROM_LINK(a) CR (a, QUESTION_OPTION, Link, QUESTION_OPTION_SIGNATURE)
@@ -188,10 +201,17 @@ typedef struct {
EFI_STRING_ID VarName;
UINT16 VarOffset;
} VarStoreInfo;
+#if 0
+ CHAR16 *UnicodeVarName;
+#endif
+
UINT16 StorageWidth;
UINT8 QuestionFlags;
+
+#if 0
CHAR16 *VariableName; // Name/Value or EFI Variable name
CHAR16 *BlockName; // Buffer storage block name: "OFFSET=...WIDTH=..."
+#endif
EFI_HII_VALUE HiiValue; // Edit copy for checkbox, numberic, oneof
UINT8 *BufferValue; // Edit copy for string, password, orderedlist
@@ -219,7 +239,9 @@ typedef struct {
//
// Get from IFR parsing
//
+#if 0
FORM_EXPRESSION *ValueExpression; // nested EFI_IFR_VALUE, provide Question value and indicate Question is ReadOnly
+#endif
LIST_ENTRY DefaultListHead; // nested EFI_IFR_DEFAULT list (QUESTION_DEFAULT), provide default values
LIST_ENTRY OptionListHead; // nested EFI_IFR_ONE_OF_OPTION list (QUESTION_OPTION)
@@ -227,10 +249,12 @@ typedef struct {
UINT8 RefreshInterval; // nested EFI_IFR_REFRESH, refresh interval(in seconds) for Question value, 0 means no refresh
BOOLEAN InSubtitle; // nesting inside of EFI_IFR_SUBTITLE
+#if 0
LIST_ENTRY InconsistentListHead;// nested inconsistent expression list (FORM_EXPRESSION)
LIST_ENTRY NoSubmitListHead; // nested nosubmit expression list (FORM_EXPRESSION)
FORM_EXPRESSION *GrayOutExpression; // nesting inside of GrayOutIf
FORM_EXPRESSION *SuppressExpression; // nesting inside of SuppressIf
+#endif
} FORM_BROWSER_STATEMENT;
@@ -247,7 +271,9 @@ typedef struct {
EFI_IMAGE_ID ImageId;
+#if 0
LIST_ENTRY ExpressionListHead; // List of Expressions (FORM_EXPRESSION)
+#endif
LIST_ENTRY StatementListHead; // List of Statements and Questions (FORM_BROWSER_STATEMENT)
} FORM_BROWSER_FORM;
@@ -267,9 +293,6 @@ typedef struct {
typedef struct {
EFI_HII_HANDLE HiiHandle;
- EFI_HANDLE DriverHandle;
- EFI_HII_CONFIG_ACCESS_PROTOCOL *ConfigAccess;
- EFI_DEVICE_PATH_PROTOCOL *DevicePath;
UINTN IfrBinaryLength;
UINT8 *IfrBinaryData;
@@ -282,20 +305,24 @@ typedef struct {
EFI_IMAGE_ID ImageId;
FORM_BROWSER_STATEMENT *StatementBuffer; // Buffer for all Statements and Questions
+#if 0
EXPRESSION_OPCODE *ExpressionBuffer; // Buffer for all Expression OpCode
+#endif
LIST_ENTRY StorageListHead; // Storage list (FORMSET_STORAGE)
LIST_ENTRY DefaultStoreListHead; // DefaultStore list (FORMSET_DEFAULTSTORE)
LIST_ENTRY FormListHead; // Form list (FORM_BROWSER_FORM)
-} FORM_BROWSER_FORMSET;
+ LIST_ENTRY OneOfOptionMapListHead; //ONE_OF_OPTION_MAP
+
+ UINT16 MaxQuestionId;
+
+ EFI_VARSTORE_ID DefaultVarStoreId;
+
+ UINTN NumberOfStatement;
+
+} FORM_BROWSER_FORMSET;
-EFI_STATUS
-EvaluateExpression (
- IN FORM_BROWSER_FORMSET *FormSet,
- IN FORM_BROWSER_FORM *Form,
- IN OUT FORM_EXPRESSION *Expression
- );
EFI_STATUS
ParseOpCodes (
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrParserExpression.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrParserExpression.c
index 1fc398fed2..236bf5178b 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrParserExpression.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/UefiIfrParserExpression.c
@@ -30,7 +30,6 @@ Abstract:
#include "UefiIfrParser.h"
#include "UefiIfrParserExpressionInternal.h"
-#include "UefiIfrParserCommon.h"
//
// Global stack used to evaluate boolean expresions
@@ -43,10 +42,7 @@ EFI_HII_VALUE *mExpressionEvaluationStack = NULL;
EFI_HII_VALUE *mExpressionEvaluationStackEnd = NULL;
EFI_HII_VALUE *mExpressionEvaluationStackPointer = NULL;
-//
-// Unicode collation protocol interface
-//
-EFI_UNICODE_COLLATION_PROTOCOL *mUnicodeCollation = NULL;
+#define EXPRESSION_STACK_SIZE_INCREMENT 0x100
/**
@@ -190,7 +186,6 @@ PopStack (
return EFI_SUCCESS;
}
-
/**
Reset stack pointer to begin of the stack.
@@ -331,853 +326,6 @@ PopExpression (
);
}
-
-/**
- Get Form given its FormId.
-
- @param FormSet The formset which contains this form.
- @param FormId Id of this form.
-
- @retval Pointer The form.
- @retval NULL Specified Form is not found in the formset.
-
-**/
-FORM_BROWSER_FORM *
-IdToForm (
- IN FORM_BROWSER_FORMSET *FormSet,
- IN UINT16 FormId
-)
-{
- LIST_ENTRY *Link;
- FORM_BROWSER_FORM *Form;
-
- Link = GetFirstNode (&FormSet->FormListHead);
- while (!IsNull (&FormSet->FormListHead, Link)) {
- Form = FORM_BROWSER_FORM_FROM_LINK (Link);
-
- if (Form->FormId == FormId) {
- return Form;
- }
-
- Link = GetNextNode (&FormSet->FormListHead, Link);
- }
-
- return NULL;
-}
-
-
-/**
- Search a Question in Form scope using its QuestionId.
-
- @param Form The form which contains this Question.
- @param QuestionId Id of this Question.
-
- @retval Pointer The Question.
- @retval NULL Specified Question not found in the form.
-
-**/
-FORM_BROWSER_STATEMENT *
-IdToQuestion2 (
- IN FORM_BROWSER_FORM *Form,
- IN UINT16 QuestionId
- )
-{
- LIST_ENTRY *Link;
- FORM_BROWSER_STATEMENT *Question;
-
- if (QuestionId == 0) {
- //
- // The value of zero is reserved
- //
- return NULL;
- }
-
- Link = GetFirstNode (&Form->StatementListHead);
- while (!IsNull (&Form->StatementListHead, Link)) {
- Question = FORM_BROWSER_STATEMENT_FROM_LINK (Link);
-
- if (Question->QuestionId == QuestionId) {
- return Question;
- }
-
- Link = GetNextNode (&Form->StatementListHead, Link);
- }
-
- return NULL;
-}
-
-
-/**
- Search a Question in Formset scope using its QuestionId.
-
- @param FormSet The formset which contains this form.
- @param Form The form which contains this Question.
- @param QuestionId Id of this Question.
-
- @retval Pointer The Question.
- @retval NULL Specified Question not found in the form.
-
-**/
-FORM_BROWSER_STATEMENT *
-IdToQuestion (
- IN FORM_BROWSER_FORMSET *FormSet,
- IN FORM_BROWSER_FORM *Form,
- IN UINT16 QuestionId
- )
-{
- LIST_ENTRY *Link;
- FORM_BROWSER_STATEMENT *Question;
-
- //
- // Search in the form scope first
- //
- Question = IdToQuestion2 (Form, QuestionId);
- if (Question != NULL) {
- return Question;
- }
-
- //
- // Search in the formset scope
- //
- Link = GetFirstNode (&FormSet->FormListHead);
- while (!IsNull (&FormSet->FormListHead, Link)) {
- Form = FORM_BROWSER_FORM_FROM_LINK (Link);
-
- Question = IdToQuestion2 (Form, QuestionId);
- if (Question != NULL) {
- return Question;
- }
-
- Link = GetNextNode (&FormSet->FormListHead, Link);
- }
-
- return NULL;
-}
-
-
-/**
- Get Expression given its RuleId.
-
- @param Form The form which contains this Expression.
- @param RuleId Id of this Expression.
-
- @retval Pointer The Expression.
- @retval NULL Specified Expression not found in the form.
-
-**/
-FORM_EXPRESSION *
-RuleIdToExpression (
- IN FORM_BROWSER_FORM *Form,
- IN UINT8 RuleId
- )
-{
- LIST_ENTRY *Link;
- FORM_EXPRESSION *Expression;
-
- Link = GetFirstNode (&Form->ExpressionListHead);
- while (!IsNull (&Form->ExpressionListHead, Link)) {
- Expression = FORM_EXPRESSION_FROM_LINK (Link);
-
- if (Expression->Type == EFI_HII_EXPRESSION_RULE && Expression->RuleId == RuleId) {
- return Expression;
- }
-
- Link = GetNextNode (&Form->ExpressionListHead, Link);
- }
-
- return NULL;
-}
-
-
-/**
- Locate the Unicode Collation Protocol interface for later use.
-
- None.
-
- @retval EFI_SUCCESS Protocol interface initialize success.
- @retval Other Protocol interface initialize failed.
-
-**/
-EFI_STATUS
-InitializeUnicodeCollationProtocol (
- VOID
- )
-{
- EFI_STATUS Status;
-
- if (mUnicodeCollation != NULL) {
- return EFI_SUCCESS;
- }
-
- //
- // BUGBUG: Proper impelmentation is to locate all Unicode Collation Protocol
- // instances first and then select one which support English language.
- // Current implementation just pick the first instance.
- //
- Status = gBS->LocateProtocol (
- &gEfiUnicodeCollation2ProtocolGuid,
- NULL,
- (VOID **) &mUnicodeCollation
- );
- return Status;
-}
-
-VOID
-IfrStrToUpper (
- CHAR16 *String
- )
-{
- while (*String != 0) {
- if ((*String >= 'a') && (*String <= 'z')) {
- *String = (UINT16) ((*String) & ((UINT16) ~0x20));
- }
- String++;
- }
-}
-
-
-/**
- Evaluate opcode EFI_IFR_TO_STRING.
-
- @param FormSet Formset which contains this opcode.
- @param Format String format in EFI_IFR_TO_STRING.
- @param Result Evaluation result for this opcode.
-
- @retval EFI_SUCCESS Opcode evaluation success.
- @retval Other Opcode evaluation failed.
-
-**/
-EFI_STATUS
-IfrToString (
- IN FORM_BROWSER_FORMSET *FormSet,
- IN UINT8 Format,
- OUT EFI_HII_VALUE *Result
- )
-{
- EFI_STATUS Status;
- EFI_HII_VALUE Value;
- CHAR16 *String;
- CHAR16 *PrintFormat;
- CHAR16 Buffer[MAXIMUM_VALUE_CHARACTERS];
- UINTN BufferSize;
-
- Status = PopExpression (&Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- switch (Value.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:
- BufferSize = MAXIMUM_VALUE_CHARACTERS * sizeof (CHAR16);
- switch (Format) {
- case EFI_IFR_STRING_UNSIGNED_DEC:
- case EFI_IFR_STRING_SIGNED_DEC:
- PrintFormat = L"%ld";
- break;
-
- case EFI_IFR_STRING_LOWERCASE_HEX:
- PrintFormat = L"%lx";
- break;
-
- case EFI_IFR_STRING_UPPERCASE_HEX:
- PrintFormat = L"%lX";
- break;
-
- default:
- return EFI_UNSUPPORTED;
- }
- UnicodeSPrint (Buffer, BufferSize, PrintFormat, Value.Value.u64);
- String = Buffer;
- break;
-
- case EFI_IFR_TYPE_STRING:
- CopyMem (Result, &Value, sizeof (EFI_HII_VALUE));
- return EFI_SUCCESS;
-
- case EFI_IFR_TYPE_BOOLEAN:
- String = (Value.Value.b) ? L"True" : L"False";
- break;
-
- default:
- return EFI_UNSUPPORTED;
- }
-
- Result->Type = EFI_IFR_TYPE_STRING;
- Result->Value.string = NewString (String, FormSet->HiiHandle);
- return EFI_SUCCESS;
-}
-
-
-/**
- Evaluate opcode EFI_IFR_TO_UINT.
-
- @param FormSet Formset which contains this opcode.
- @param Result Evaluation result for this opcode.
-
- @retval EFI_SUCCESS Opcode evaluation success.
- @retval Other Opcode evaluation failed.
-
-**/
-EFI_STATUS
-IfrToUint (
- IN FORM_BROWSER_FORMSET *FormSet,
- OUT EFI_HII_VALUE *Result
- )
-{
- EFI_STATUS Status;
- EFI_HII_VALUE Value;
- CHAR16 *String;
- CHAR16 *StringPtr;
- UINTN BufferSize;
-
- Status = PopExpression (&Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (Value.Type >= EFI_IFR_TYPE_OTHER) {
- return EFI_UNSUPPORTED;
- }
-
- Status = EFI_SUCCESS;
- if (Value.Type == EFI_IFR_TYPE_STRING) {
- String = GetToken (Value.Value.string, FormSet->HiiHandle);
- if (String == NULL) {
- return EFI_NOT_FOUND;
- }
-
- IfrStrToUpper (String);
- StringPtr = StrStr (String, L"0X");
- if (StringPtr != NULL) {
- //
- // Hex string
- //
- BufferSize = sizeof (UINT64);
- Status = HexStringToBuf ((UINT8 *) &Result->Value.u64, &BufferSize, StringPtr + 2, NULL);
- } else {
- //
- // BUGBUG: Need handle decimal string
- //
- }
- gBS->FreePool (String);
- } else {
- CopyMem (Result, &Value, sizeof (EFI_HII_VALUE));
- }
-
- Result->Type = EFI_IFR_TYPE_NUM_SIZE_64;
- return Status;
-}
-
-
-/**
- Evaluate opcode EFI_IFR_CATENATE.
-
- @param FormSet Formset which contains this opcode.
- @param Result Evaluation result for this opcode.
-
- @retval EFI_SUCCESS Opcode evaluation success.
- @retval Other Opcode evaluation failed.
-
-**/
-EFI_STATUS
-IfrCatenate (
- IN FORM_BROWSER_FORMSET *FormSet,
- OUT EFI_HII_VALUE *Result
- )
-{
- EFI_STATUS Status;
- EFI_HII_VALUE Value;
- CHAR16 *String[2];
- UINTN Index;
- CHAR16 *StringPtr;
- UINTN Size;
-
- //
- // String[0] - The second string
- // String[1] - The first string
- //
- String[0] = NULL;
- String[1] = NULL;
- StringPtr = NULL;
- Status = EFI_SUCCESS;
-
- for (Index = 0; Index < 2; Index++) {
- Status = PopExpression (&Value);
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- if (Value.Type != EFI_IFR_TYPE_STRING) {
- Status = EFI_UNSUPPORTED;
- goto Done;
- }
-
- String[Index] = GetToken (Value.Value.string, FormSet->HiiHandle);
- if (String== NULL) {
- Status = EFI_NOT_FOUND;
- goto Done;
- }
- }
-
- Size = StrSize (String[0]);
- StringPtr= AllocatePool (StrSize (String[1]) + Size);
- ASSERT (StringPtr != NULL);
- StrCpy (StringPtr, String[1]);
- StrCat (StringPtr, String[0]);
-
- Result->Type = EFI_IFR_TYPE_STRING;
- Result->Value.string = NewString (StringPtr, FormSet->HiiHandle);
-
-Done:
- if (String[0] != NULL) {
- FreePool (String[0]);
- }
- if (String[1] != NULL) {
- FreePool (String[1]);
- }
- if (StringPtr != NULL) {
- FreePool (StringPtr);
- }
-
- return Status;
-}
-
-
-/**
- Evaluate opcode EFI_IFR_MATCH.
-
- @param FormSet Formset which contains this opcode.
- @param Result Evaluation result for this opcode.
-
- @retval EFI_SUCCESS Opcode evaluation success.
- @retval Other Opcode evaluation failed.
-
-**/
-EFI_STATUS
-IfrMatch (
- IN FORM_BROWSER_FORMSET *FormSet,
- OUT EFI_HII_VALUE *Result
- )
-{
- EFI_STATUS Status;
- EFI_HII_VALUE Value;
- CHAR16 *String[2];
- UINTN Index;
-
- //
- // String[0] - The string to search
- // String[1] - pattern
- //
- String[0] = NULL;
- String[1] = NULL;
- Status = EFI_SUCCESS;
- for (Index = 0; Index < 2; Index++) {
- Status = PopExpression (&Value);
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- if (Value.Type != EFI_IFR_TYPE_STRING) {
- Status = EFI_UNSUPPORTED;
- goto Done;
- }
-
- String[Index] = GetToken (Value.Value.string, FormSet->HiiHandle);
- if (String== NULL) {
- Status = EFI_NOT_FOUND;
- goto Done;
- }
- }
-
- Result->Type = EFI_IFR_TYPE_BOOLEAN;
- Result->Value.b = mUnicodeCollation->MetaiMatch (mUnicodeCollation, String[0], String[1]);
-
-Done:
- if (String[0] != NULL) {
- FreePool (String[0]);
- }
- if (String[1] != NULL) {
- FreePool (String[1]);
- }
-
- return Status;
-}
-
-
-/**
- Evaluate opcode EFI_IFR_FIND.
-
- @param FormSet Formset which contains this opcode.
- @param Format Case sensitive or insensitive.
- @param Result Evaluation result for this opcode.
-
- @retval EFI_SUCCESS Opcode evaluation success.
- @retval Other Opcode evaluation failed.
-
-**/
-EFI_STATUS
-IfrFind (
- IN FORM_BROWSER_FORMSET *FormSet,
- IN UINT8 Format,
- OUT EFI_HII_VALUE *Result
- )
-{
- EFI_STATUS Status;
- EFI_HII_VALUE Value;
- CHAR16 *String[2];
- UINTN Base;
- CHAR16 *StringPtr;
- UINTN Index;
-
- if (Format > EFI_IFR_FF_CASE_INSENSITIVE) {
- return EFI_UNSUPPORTED;
- }
-
- Status = PopExpression (&Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (Value.Type > EFI_IFR_TYPE_NUM_SIZE_64) {
- return EFI_UNSUPPORTED;
- }
- Base = (UINTN) Value.Value.u64;
-
- //
- // String[0] - sub-string
- // String[1] - The string to search
- //
- String[0] = NULL;
- String[1] = NULL;
- for (Index = 0; Index < 2; Index++) {
- Status = PopExpression (&Value);
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- if (Value.Type != EFI_IFR_TYPE_STRING) {
- Status = EFI_UNSUPPORTED;
- goto Done;
- }
-
- String[Index] = GetToken (Value.Value.string, FormSet->HiiHandle);
- if (String== NULL) {
- Status = EFI_NOT_FOUND;
- goto Done;
- }
-
- if (Format == EFI_IFR_FF_CASE_INSENSITIVE) {
- //
- // Case insensitive, convert both string to upper case
- //
- IfrStrToUpper (String[Index]);
- }
- }
-
- Result->Type = EFI_IFR_TYPE_NUM_SIZE_64;
- if (Base >= StrLen (String[1])) {
- Result->Value.u64 = 0xFFFFFFFFFFFFFFFFULL;
- } else {
- StringPtr = StrStr (String[1] + Base, String[0]);
- Result->Value.u64 = (StringPtr == NULL) ? 0xFFFFFFFFFFFFFFFFULL : (StringPtr - String[1]);
- }
-
-Done:
- if (String[0] != NULL) {
- FreePool (String[0]);
- }
- if (String[1] != NULL) {
- FreePool (String[1]);
- }
-
- return Status;
-}
-
-
-/**
- Evaluate opcode EFI_IFR_MID.
-
- @param FormSet Formset which contains this opcode.
- @param Result Evaluation result for this opcode.
-
- @retval EFI_SUCCESS Opcode evaluation success.
- @retval Other Opcode evaluation failed.
-
-**/
-EFI_STATUS
-IfrMid (
- IN FORM_BROWSER_FORMSET *FormSet,
- OUT EFI_HII_VALUE *Result
- )
-{
- EFI_STATUS Status;
- EFI_HII_VALUE Value;
- CHAR16 *String;
- UINTN Base;
- UINTN Length;
- CHAR16 *SubString;
-
- Status = PopExpression (&Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (Value.Type > EFI_IFR_TYPE_NUM_SIZE_64) {
- return EFI_UNSUPPORTED;
- }
- Length = (UINTN) Value.Value.u64;
-
- Status = PopExpression (&Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (Value.Type > EFI_IFR_TYPE_NUM_SIZE_64) {
- return EFI_UNSUPPORTED;
- }
- Base = (UINTN) Value.Value.u64;
-
- Status = PopExpression (&Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (Value.Type != EFI_IFR_TYPE_STRING) {
- return EFI_UNSUPPORTED;
- }
- String = GetToken (Value.Value.string, FormSet->HiiHandle);
- if (String == NULL) {
- return EFI_NOT_FOUND;
- }
-
- if (Length == 0 || Base >= StrLen (String)) {
- SubString = gEmptyString;
- } else {
- SubString = String + Base;
- if ((Base + Length) < StrLen (String)) {
- SubString[Length] = L'\0';
- }
- }
-
- Result->Type = EFI_IFR_TYPE_STRING;
- Result->Value.string = NewString (SubString, FormSet->HiiHandle);
-
- gBS->FreePool (String);
-
- return Status;
-}
-
-
-/**
- Evaluate opcode EFI_IFR_TOKEN.
-
- @param FormSet Formset which contains this opcode.
- @param Result Evaluation result for this opcode.
-
- @retval EFI_SUCCESS Opcode evaluation success.
- @retval Other Opcode evaluation failed.
-
-**/
-EFI_STATUS
-IfrToken (
- IN FORM_BROWSER_FORMSET *FormSet,
- OUT EFI_HII_VALUE *Result
- )
-{
- EFI_STATUS Status;
- EFI_HII_VALUE Value;
- CHAR16 *String[2];
- UINTN Count;
- CHAR16 *Delimiter;
- CHAR16 *SubString;
- CHAR16 *StringPtr;
- UINTN Index;
-
- Status = PopExpression (&Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (Value.Type > EFI_IFR_TYPE_NUM_SIZE_64) {
- return EFI_UNSUPPORTED;
- }
- Count = (UINTN) Value.Value.u64;
-
- //
- // String[0] - Delimiter
- // String[1] - The string to search
- //
- String[0] = NULL;
- String[1] = NULL;
- for (Index = 0; Index < 2; Index++) {
- Status = PopExpression (&Value);
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- if (Value.Type != EFI_IFR_TYPE_STRING) {
- Status = EFI_UNSUPPORTED;
- goto Done;
- }
-
- String[Index] = GetToken (Value.Value.string, FormSet->HiiHandle);
- if (String== NULL) {
- Status = EFI_NOT_FOUND;
- goto Done;
- }
- }
-
- Delimiter = String[0];
- SubString = String[1];
- while (Count > 0) {
- SubString = StrStr (SubString, Delimiter);
- if (SubString != NULL) {
- //
- // Skip over the delimiter
- //
- SubString = SubString + StrLen (Delimiter);
- } else {
- break;
- }
- Count--;
- }
-
- if (SubString == NULL) {
- //
- // nth delimited sub-string not found, push an empty string
- //
- SubString = gEmptyString;
- } else {
- //
- // Put a NULL terminator for nth delimited sub-string
- //
- StringPtr = StrStr (SubString, Delimiter);
- if (StringPtr != NULL) {
- *StringPtr = L'\0';
- }
- }
-
- Result->Type = EFI_IFR_TYPE_STRING;
- Result->Value.string = NewString (SubString, FormSet->HiiHandle);
-
-Done:
- if (String[0] != NULL) {
- FreePool (String[0]);
- }
- if (String[1] != NULL) {
- FreePool (String[1]);
- }
-
- return Status;
-}
-
-
-/**
- Evaluate opcode EFI_IFR_SPAN.
-
- @param FormSet Formset which contains this opcode.
- @param Flags FIRST_MATCHING or FIRST_NON_MATCHING.
- @param Result Evaluation result for this opcode.
-
- @retval EFI_SUCCESS Opcode evaluation success.
- @retval Other Opcode evaluation failed.
-
-**/
-EFI_STATUS
-IfrSpan (
- IN FORM_BROWSER_FORMSET *FormSet,
- IN UINT8 Flags,
- OUT EFI_HII_VALUE *Result
- )
-{
- EFI_STATUS Status;
- EFI_HII_VALUE Value;
- CHAR16 *String[2];
- CHAR16 *Charset;
- UINTN Base;
- UINTN Index;
- CHAR16 *StringPtr;
- BOOLEAN Found;
-
- Status = PopExpression (&Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (Value.Type > EFI_IFR_TYPE_NUM_SIZE_64) {
- return EFI_UNSUPPORTED;
- }
- Base = (UINTN) Value.Value.u64;
-
- //
- // String[0] - Charset
- // String[1] - The string to search
- //
- String[0] = NULL;
- String[1] = NULL;
- for (Index = 0; Index < 2; Index++) {
- Status = PopExpression (&Value);
- if (EFI_ERROR (Status)) {
- goto Done;
- }
-
- if (Value.Type != EFI_IFR_TYPE_STRING) {
- Status = EFI_UNSUPPORTED;
- goto Done;
- }
-
- String[Index] = GetToken (Value.Value.string, FormSet->HiiHandle);
- if (String== NULL) {
- Status = EFI_NOT_FOUND;
- goto Done;
- }
- }
-
- if (Base >= StrLen (String[1])) {
- Status = EFI_UNSUPPORTED;
- goto Done;
- }
-
- Found = FALSE;
- StringPtr = String[1] + Base;
- Charset = String[0];
- while (*StringPtr != 0 && !Found) {
- Index = 0;
- while (Charset[Index] != 0) {
- if (*StringPtr >= Charset[Index] && *StringPtr <= Charset[Index + 1]) {
- if (Flags == EFI_IFR_FLAGS_FIRST_MATCHING) {
- Found = TRUE;
- break;
- }
- } else {
- if (Flags == EFI_IFR_FLAGS_FIRST_NON_MATCHING) {
- Found = TRUE;
- break;
- }
- }
- //
- // Skip characters pair representing low-end of a range and high-end of a range
- //
- Index += 2;
- }
-
- if (!Found) {
- StringPtr++;
- }
- }
-
- Result->Type = EFI_IFR_TYPE_NUM_SIZE_64;
- Result->Value.u64 = StringPtr - String[1];
-
-Done:
- if (String[0] != NULL) {
- FreePool (String[0]);
- }
- if (String[1] != NULL) {
- FreePool (String[1]);
- }
-
- return Status;
-}
-
-
/**
Zero extend integer/boolean/date/time to UINT64 for comparing.
@@ -1225,745 +373,3 @@ ExtendValueToU64 (
Value->Value.u64 = Temp;
}
-
-
-/**
- Compare two Hii value.
-
- @param Value1 Expression value to compare on left-hand
- @param Value2 Expression value to compare on right-hand
- @param HiiHandle Only required for string compare
-
- @retval EFI_INVALID_PARAMETER Could not perform comparation on two values
- @retval 0 Two operators equeal
- @retval 0 Value1 is greater than Value2
- @retval 0 Value1 is less than Value2
-
-**/
-INTN
-CompareHiiValue (
- IN EFI_HII_VALUE *Value1,
- IN EFI_HII_VALUE *Value2,
- IN EFI_HII_HANDLE HiiHandle OPTIONAL
- )
-{
- INTN Result;
- INT64 Temp64;
- CHAR16 *Str1;
- CHAR16 *Str2;
-
- if (Value1->Type >= EFI_IFR_TYPE_OTHER || Value2->Type >= EFI_IFR_TYPE_OTHER ) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (Value1->Type == EFI_IFR_TYPE_STRING || Value2->Type == EFI_IFR_TYPE_STRING ) {
- if (Value1->Type != Value2->Type) {
- //
- // Both Operator should be type of String
- //
- return EFI_INVALID_PARAMETER;
- }
-
- if (Value1->Value.string == 0 || Value2->Value.string == 0) {
- //
- // StringId 0 is reserved
- //
- return EFI_INVALID_PARAMETER;
- }
-
- if (Value1->Value.string == Value2->Value.string) {
- return 0;
- }
-
- Str1 = GetToken (Value1->Value.string, HiiHandle);
- if (Str1 == NULL) {
- //
- // String not found
- //
- return EFI_INVALID_PARAMETER;
- }
-
- Str2 = GetToken (Value2->Value.string, HiiHandle);
- if (Str2 == NULL) {
- gBS->FreePool (Str1);
- return EFI_INVALID_PARAMETER;
- }
-
- Result = StrCmp (Str1, Str2);
-
- gBS->FreePool (Str1);
- gBS->FreePool (Str2);
-
- return Result;
- }
-
- //
- // Take remain types(integer, boolean, date/time) as integer
- //
- Temp64 = (INT64) (Value1->Value.u64 - Value2->Value.u64);
- if (Temp64 > 0) {
- Result = 1;
- } else if (Temp64 < 0) {
- Result = -1;
- } else {
- Result = 0;
- }
-
- return Result;
-}
-
-
-/**
- Evaluate the result of a HII expression
-
- @param FormSet FormSet associated with this expression.
- @param Form Form associated with this expression.
- @param Expression Expression to be evaluated.
-
- @retval EFI_SUCCESS The expression evaluated successfuly
- @retval EFI_NOT_FOUND The Question which referenced by a QuestionId
- could not be found.
- @retval EFI_OUT_OF_RESOURCES There is not enough system memory to grow the
- stack.
- @retval EFI_ACCESS_DENIED The pop operation underflowed the stack
- @retval EFI_INVALID_PARAMETER Syntax error with the Expression
-
-**/
-EFI_STATUS
-EvaluateExpression (
- IN FORM_BROWSER_FORMSET *FormSet,
- IN FORM_BROWSER_FORM *Form,
- IN OUT FORM_EXPRESSION *Expression
- )
-{
- EFI_STATUS Status;
- LIST_ENTRY *Link;
- EXPRESSION_OPCODE *OpCode;
- FORM_BROWSER_STATEMENT *Question;
- FORM_BROWSER_STATEMENT *Question2;
- UINT16 Index;
- EFI_HII_VALUE Data1;
- EFI_HII_VALUE Data2;
- EFI_HII_VALUE Data3;
- FORM_EXPRESSION *RuleExpression;
- EFI_HII_VALUE *Value;
- INTN Result;
- CHAR16 *StrPtr;
- UINT32 TempValue;
-
- //
- // Always reset the stack before evaluating an Expression
- //
- ResetExpressionStack ();
-
- Expression->Result.Type = EFI_IFR_TYPE_OTHER;
-
- Link = GetFirstNode (&Expression->OpCodeListHead);
- while (!IsNull (&Expression->OpCodeListHead, Link)) {
- OpCode = EXPRESSION_OPCODE_FROM_LINK (Link);
-
- Link = GetNextNode (&Expression->OpCodeListHead, Link);
-
- ZeroMem (&Data1, sizeof (EFI_HII_VALUE));
- ZeroMem (&Data2, sizeof (EFI_HII_VALUE));
- ZeroMem (&Data3, sizeof (EFI_HII_VALUE));
-
- Value = &Data3;
- Value->Type = EFI_IFR_TYPE_BOOLEAN;
- Status = EFI_SUCCESS;
-
- switch (OpCode->Operand) {
- //
- // Built-in functions
- //
- case EFI_IFR_EQ_ID_VAL_OP:
- Question = IdToQuestion (FormSet, Form, OpCode->QuestionId);
- if (Question == NULL) {
- return EFI_NOT_FOUND;
- }
-
- Result = CompareHiiValue (&Question->HiiValue, &OpCode->Value, NULL);
- if (Result == EFI_INVALID_PARAMETER) {
- return EFI_INVALID_PARAMETER;
- }
- Value->Value.b = (BOOLEAN) ((Result == 0) ? TRUE : FALSE);
- break;
-
- case EFI_IFR_EQ_ID_ID_OP:
- Question = IdToQuestion (FormSet, Form, OpCode->QuestionId);
- if (Question == NULL) {
- return EFI_NOT_FOUND;
- }
-
- Question2 = IdToQuestion (FormSet, Form, OpCode->QuestionId2);
- if (Question2 == NULL) {
- return EFI_NOT_FOUND;
- }
-
- Result = CompareHiiValue (&Question->HiiValue, &Question2->HiiValue, FormSet->HiiHandle);
- if (Result == EFI_INVALID_PARAMETER) {
- return EFI_INVALID_PARAMETER;
- }
- Value->Value.b = (BOOLEAN) ((Result == 0) ? TRUE : FALSE);
- break;
-
- case EFI_IFR_EQ_ID_LIST_OP:
- Question = IdToQuestion (FormSet, Form, OpCode->QuestionId);
- if (Question == NULL) {
- return EFI_NOT_FOUND;
- }
-
- Value->Value.b = FALSE;
- for (Index =0; Index < OpCode->ListLength; Index++) {
- if (Question->HiiValue.Value.u16 == OpCode->ValueList[Index]) {
- Value->Value.b = TRUE;
- break;
- }
- }
- break;
-
- case EFI_IFR_DUP_OP:
- Status = PopExpression (Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = PushExpression (Value);
- break;
-
- case EFI_IFR_QUESTION_REF1_OP:
- case EFI_IFR_THIS_OP:
- Question = IdToQuestion (FormSet, Form, OpCode->QuestionId);
- if (Question == NULL) {
- return EFI_NOT_FOUND;
- }
-
- Value = &Question->HiiValue;
- break;
-
- case EFI_IFR_QUESTION_REF3_OP:
- if (OpCode->DevicePath == 0) {
- //
- // EFI_IFR_QUESTION_REF3
- // Pop an expression from the expression stack
- //
- Status = PopExpression (Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Validate the expression value
- //
- if ((Value->Type > EFI_IFR_TYPE_NUM_SIZE_64) || (Value->Value.u64 > 0xffff)) {
- return EFI_NOT_FOUND;
- }
-
- Question = IdToQuestion (FormSet, Form, Value->Value.u16);
- if (Question == NULL) {
- return EFI_NOT_FOUND;
- }
-
- //
- // push the questions' value on to the expression stack
- //
- Value = &Question->HiiValue;
- } else {
- //
- // BUGBUG: push 0 for EFI_IFR_QUESTION_REF3_2 and EFI_IFR_QUESTION_REF3_3,
- // since it is impractical to evaluate the value of a Question in another
- // Hii Package list.
- //
- ZeroMem (Value, sizeof (EFI_HII_VALUE));
- }
- break;
-
- case EFI_IFR_RULE_REF_OP:
- //
- // Find expression for this rule
- //
- RuleExpression = RuleIdToExpression (Form, OpCode->RuleId);
- if (RuleExpression == NULL) {
- return EFI_NOT_FOUND;
- }
-
- //
- // Evaluate this rule expression
- //
- Status = EvaluateExpression (FormSet, Form, RuleExpression);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Value = &RuleExpression->Result;
- break;
-
- case EFI_IFR_STRING_REF1_OP:
- Value->Type = EFI_IFR_TYPE_STRING;
- Value->Value.string = OpCode->Value.Value.string;
- break;
-
- //
- // Constant
- //
- case EFI_IFR_TRUE_OP:
- case EFI_IFR_FALSE_OP:
- case EFI_IFR_ONE_OP:
- case EFI_IFR_ONES_OP:
- case EFI_IFR_UINT8_OP:
- case EFI_IFR_UINT16_OP:
- case EFI_IFR_UINT32_OP:
- case EFI_IFR_UINT64_OP:
- case EFI_IFR_UNDEFINED_OP:
- case EFI_IFR_VERSION_OP:
- case EFI_IFR_ZERO_OP:
- Value = &OpCode->Value;
- break;
-
- //
- // unary-op
- //
- case EFI_IFR_LENGTH_OP:
- Status = PopExpression (Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (Value->Type != EFI_IFR_TYPE_STRING) {
- return EFI_INVALID_PARAMETER;
- }
-
- StrPtr = GetToken (Value->Value.string, FormSet->HiiHandle);
- if (StrPtr == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
- Value->Value.u64 = StrLen (StrPtr);
- gBS->FreePool (StrPtr);
- break;
-
- case EFI_IFR_NOT_OP:
- Status = PopExpression (Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (Value->Type != EFI_IFR_TYPE_BOOLEAN) {
- return EFI_INVALID_PARAMETER;
- }
- Value->Value.b = (BOOLEAN) (!Value->Value.b);
- break;
-
- case EFI_IFR_QUESTION_REF2_OP:
- //
- // Pop an expression from the expression stack
- //
- Status = PopExpression (Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Validate the expression value
- //
- if ((Value->Type > EFI_IFR_TYPE_NUM_SIZE_64) || (Value->Value.u64 > 0xffff)) {
- return EFI_NOT_FOUND;
- }
-
- Question = IdToQuestion (FormSet, Form, Value->Value.u16);
- if (Question == NULL) {
- return EFI_NOT_FOUND;
- }
-
- Value = &Question->HiiValue;
- break;
-
- case EFI_IFR_STRING_REF2_OP:
- //
- // Pop an expression from the expression stack
- //
- Status = PopExpression (Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Validate the expression value
- //
- if ((Value->Type > EFI_IFR_TYPE_NUM_SIZE_64) || (Value->Value.u64 > 0xffff)) {
- return EFI_NOT_FOUND;
- }
-
- Value->Type = EFI_IFR_TYPE_STRING;
- StrPtr = GetToken (Value->Value.u16, FormSet->HiiHandle);
- if (StrPtr == NULL) {
- //
- // If String not exit, push an empty string
- //
- Value->Value.string = NewString (gEmptyString, FormSet->HiiHandle);
- } else {
- Index = (UINT16) Value->Value.u64;
- Value->Value.string = Index;
- gBS->FreePool (StrPtr);
- }
- break;
-
- case EFI_IFR_TO_BOOLEAN_OP:
- //
- // Pop an expression from the expression stack
- //
- Status = PopExpression (Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Convert an expression to a Boolean
- //
- if (Value->Type <= EFI_IFR_TYPE_DATE) {
- //
- // When converting from an unsigned integer, zero will be converted to
- // FALSE and any other value will be converted to TRUE.
- //
- Value->Value.b = (BOOLEAN) ((Value->Value.u64) ? TRUE : FALSE);
-
- Value->Type = EFI_IFR_TYPE_BOOLEAN;
- } else if (Value->Type == EFI_IFR_TYPE_STRING) {
- //
- // When converting from a string, if case-insensitive compare
- // with "true" is True, then push True. If a case-insensitive compare
- // with "false" is True, then push False.
- //
- StrPtr = GetToken (Value->Value.string, FormSet->HiiHandle);
- if (StrPtr == NULL) {
- return EFI_INVALID_PARAMETER;
- }
-
- if ((StrCmp (StrPtr, L"true") == 0) || (StrCmp (StrPtr, L"false") == 0)){
- Value->Value.b = TRUE;
- } else {
- Value->Value.b = FALSE;
- }
- gBS->FreePool (StrPtr);
- Value->Type = EFI_IFR_TYPE_BOOLEAN;
- }
- break;
-
- case EFI_IFR_TO_STRING_OP:
- Status = IfrToString (FormSet, OpCode->Format, Value);
- break;
-
- case EFI_IFR_TO_UINT_OP:
- Status = IfrToUint (FormSet, Value);
- break;
-
- case EFI_IFR_TO_LOWER_OP:
- case EFI_IFR_TO_UPPER_OP:
- Status = InitializeUnicodeCollationProtocol ();
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = PopExpression (Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- if (Value->Type != EFI_IFR_TYPE_STRING) {
- return EFI_UNSUPPORTED;
- }
-
- StrPtr = GetToken (Value->Value.string, FormSet->HiiHandle);
- if (StrPtr == NULL) {
- return EFI_NOT_FOUND;
- }
-
- if (OpCode->Operand == EFI_IFR_TO_LOWER_OP) {
- mUnicodeCollation->StrLwr (mUnicodeCollation, StrPtr);
- } else {
- mUnicodeCollation->StrUpr (mUnicodeCollation, StrPtr);
- }
- Value->Value.string = NewString (StrPtr, FormSet->HiiHandle);
- gBS->FreePool (StrPtr);
- break;
-
- case EFI_IFR_BITWISE_NOT_OP:
- //
- // Pop an expression from the expression stack
- //
- Status = PopExpression (Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (Value->Type > EFI_IFR_TYPE_DATE) {
- return EFI_INVALID_PARAMETER;
- }
-
- Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
- Value->Value.u64 = ~Value->Value.u64;
- break;
-
- //
- // binary-op
- //
- case EFI_IFR_ADD_OP:
- case EFI_IFR_SUBTRACT_OP:
- case EFI_IFR_MULTIPLY_OP:
- case EFI_IFR_DIVIDE_OP:
- case EFI_IFR_MODULO_OP:
- case EFI_IFR_BITWISE_AND_OP:
- case EFI_IFR_BITWISE_OR_OP:
- case EFI_IFR_SHIFT_LEFT_OP:
- case EFI_IFR_SHIFT_RIGHT_OP:
- //
- // Pop an expression from the expression stack
- //
- Status = PopExpression (&Data2);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (Data2.Type > EFI_IFR_TYPE_DATE) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Pop another expression from the expression stack
- //
- Status = PopExpression (&Data1);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (Data1.Type > EFI_IFR_TYPE_DATE) {
- return EFI_INVALID_PARAMETER;
- }
-
- Value->Type = EFI_IFR_TYPE_NUM_SIZE_64;
-
- switch (OpCode->Operand) {
- case EFI_IFR_ADD_OP:
- Value->Value.u64 = Data1.Value.u64 + Data2.Value.u64;
- break;
-
- case EFI_IFR_SUBTRACT_OP:
- Value->Value.u64 = Data1.Value.u64 - Data2.Value.u64;
- break;
-
- case EFI_IFR_MULTIPLY_OP:
- Value->Value.u64 = MultU64x32 (Data1.Value.u64, (UINT32) Data2.Value.u64);
- break;
-
- case EFI_IFR_DIVIDE_OP:
- Value->Value.u64 = DivU64x32 (Data1.Value.u64, (UINT32) Data2.Value.u64);
- break;
-
- case EFI_IFR_MODULO_OP:
- DivU64x32Remainder (Data1.Value.u64, (UINT32) Data2.Value.u64, &TempValue);
- Value->Value.u64 = TempValue;
- break;
-
- case EFI_IFR_BITWISE_AND_OP:
- Value->Value.u64 = Data1.Value.u64 & Data2.Value.u64;
- break;
-
- case EFI_IFR_BITWISE_OR_OP:
- Value->Value.u64 = Data1.Value.u64 | Data2.Value.u64;
- break;
-
- case EFI_IFR_SHIFT_LEFT_OP:
- Value->Value.u64 = LShiftU64 (Data1.Value.u64, (UINTN) Data2.Value.u64);
- break;
-
- case EFI_IFR_SHIFT_RIGHT_OP:
- Value->Value.u64 = RShiftU64 (Data1.Value.u64, (UINTN) Data2.Value.u64);
- break;
-
- default:
- break;
- }
- break;
-
- case EFI_IFR_AND_OP:
- case EFI_IFR_OR_OP:
- //
- // Two Boolean operator
- //
- Status = PopExpression (&Data2);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (Data2.Type != EFI_IFR_TYPE_BOOLEAN) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Pop another expression from the expression stack
- //
- Status = PopExpression (&Data1);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (Data1.Type != EFI_IFR_TYPE_BOOLEAN) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (OpCode->Operand == EFI_IFR_AND_OP) {
- Value->Value.b = (BOOLEAN) (Data1.Value.b && Data2.Value.b);
- } else {
- Value->Value.b = (BOOLEAN) (Data1.Value.b || Data2.Value.b);
- }
- break;
-
- case EFI_IFR_EQUAL_OP:
- case EFI_IFR_NOT_EQUAL_OP:
- case EFI_IFR_GREATER_EQUAL_OP:
- case EFI_IFR_GREATER_THAN_OP:
- case EFI_IFR_LESS_EQUAL_OP:
- case EFI_IFR_LESS_THAN_OP:
- //
- // Compare two integer, string, boolean or date/time
- //
- Status = PopExpression (&Data2);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (Data2.Type > EFI_IFR_TYPE_BOOLEAN && Data2.Type != EFI_IFR_TYPE_STRING) {
- return EFI_INVALID_PARAMETER;
- }
-
- //
- // Pop another expression from the expression stack
- //
- Status = PopExpression (&Data1);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Result = CompareHiiValue (&Data1, &Data2, FormSet->HiiHandle);
- if (Result == EFI_INVALID_PARAMETER) {
- return EFI_INVALID_PARAMETER;
- }
-
- switch (OpCode->Operand) {
- case EFI_IFR_EQUAL_OP:
- Value->Value.b = (BOOLEAN) ((Result == 0) ? TRUE : FALSE);
- break;
-
- case EFI_IFR_NOT_EQUAL_OP:
- Value->Value.b = (BOOLEAN) ((Result == 0) ? TRUE : FALSE);
- break;
-
- case EFI_IFR_GREATER_EQUAL_OP:
- Value->Value.b = (BOOLEAN) ((Result >= 0) ? TRUE : FALSE);
- break;
-
- case EFI_IFR_GREATER_THAN_OP:
- Value->Value.b = (BOOLEAN) ((Result > 0) ? TRUE : FALSE);
- break;
-
- case EFI_IFR_LESS_EQUAL_OP:
- Value->Value.b = (BOOLEAN) ((Result <= 0) ? TRUE : FALSE);
- break;
-
- case EFI_IFR_LESS_THAN_OP:
- Value->Value.b = (BOOLEAN) ((Result < 0) ? TRUE : FALSE);
- break;
-
- default:
- break;
- }
- break;
-
- case EFI_IFR_MATCH_OP:
- Status = IfrMatch (FormSet, Value);
- break;
-
- case EFI_IFR_CATENATE_OP:
- Status = IfrCatenate (FormSet, Value);
- break;
-
- //
- // ternary-op
- //
- case EFI_IFR_CONDITIONAL_OP:
- //
- // Pop third expression from the expression stack
- //
- Status = PopExpression (&Data3);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Pop second expression from the expression stack
- //
- Status = PopExpression (&Data2);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // Pop first expression from the expression stack
- //
- Status = PopExpression (&Data1);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- if (Data1.Type != EFI_IFR_TYPE_BOOLEAN) {
- return EFI_INVALID_PARAMETER;
- }
-
- if (Data1.Value.b) {
- Value = &Data3;
- } else {
- Value = &Data2;
- }
- break;
-
- case EFI_IFR_FIND_OP:
- Status = IfrFind (FormSet, OpCode->Format, Value);
- break;
-
- case EFI_IFR_MID_OP:
- Status = IfrMid (FormSet, Value);
- break;
-
- case EFI_IFR_TOKEN_OP:
- Status = IfrToken (FormSet, Value);
- break;
-
- case EFI_IFR_SPAN_OP:
- Status = IfrSpan (FormSet, OpCode->Flags, Value);
- break;
-
- default:
- break;
- }
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- Status = PushExpression (Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
- }
-
- //
- // Pop the final result from expression stack
- //
- Value = &Data1;
- Status = PopExpression (Value);
- if (EFI_ERROR (Status)) {
- return Status;
- }
-
- //
- // After evaluating an expression, there should be only one value left on the expression stack
- //
- if (PopExpression (Value) != EFI_ACCESS_DENIED) {
- return EFI_INVALID_PARAMETER;
- }
-
- CopyMem (&Expression->Result, Value, sizeof (EFI_HII_VALUE));
-
- return EFI_SUCCESS;
-}
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c
index 77143d893a..8220c198df 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c
@@ -16,11 +16,19 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "HiiDatabase.h"
#include "HiiHandle.h"
+#include <Library/DebugLib.h>
-EFI_GUID gFrameworkHiiCompatbilityGuid = EFI_IFR_FRAMEWORK_GUID;
-EFI_GUID gTianoHiiIfrGuid = EFI_IFR_TIANO_GUID;
+CONST EFI_GUID gZeroGuid = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}};
+/**
+ Find the corressponding UEFI HII Handle from a Framework HII Handle given.
+
+ @param Private The HII Thunk Module Private context.
+ @param FwHiiHandle The Framemwork HII Handle.
+ @return NULL If Framework HII Handle is invalid.
+ @return The corresponding UEFI HII Handle.
+**/
EFI_HII_HANDLE
FwHiiHandleToUefiHiiHandle (
IN CONST HII_THUNK_PRIVATE_DATA *Private,
@@ -42,6 +50,15 @@ FwHiiHandleToUefiHiiHandle (
}
+/**
+ Find the corressponding HII Thunk Context from a Framework HII Handle given.
+
+ @param Private The HII Thunk Module Private context.
+ @param FwHiiHandle The Framemwork HII Handle.
+
+ @return NULL If Framework HII Handle is invalid.
+ @return The corresponding HII Thunk Context.
+**/
HII_THUNK_CONTEXT *
FwHiiHandleToThunkContext (
IN CONST HII_THUNK_PRIVATE_DATA *Private,
@@ -67,6 +84,15 @@ FwHiiHandleToThunkContext (
return NULL;
}
+/**
+ Find the corressponding HII Thunk Context from a UEFI HII Handle given.
+
+ @param Private The HII Thunk Module Private context.
+ @param UEFIHiiHandle The UEFI HII Handle.
+
+ @return NULL If UEFI HII Handle is invalid.
+ @return The corresponding HII Thunk Context.
+**/
HII_THUNK_CONTEXT *
UefiHiiHandleToThunkContext (
IN CONST HII_THUNK_PRIVATE_DATA *Private,
@@ -90,6 +116,15 @@ UefiHiiHandleToThunkContext (
return NULL;
}
+/**
+ Find the corressponding HII Thunk Context from a Tag GUID.
+
+ @param Private The HII Thunk Module Private context.
+ @param Guid The Tag GUID.
+
+ @return NULL No HII Thunk Context matched the Tag GUID.
+ @return The corresponding HII Thunk Context.
+**/
HII_THUNK_CONTEXT *
TagGuidToIfrPackThunkContext (
IN CONST HII_THUNK_PRIVATE_DATA *Private,
@@ -115,7 +150,13 @@ TagGuidToIfrPackThunkContext (
}
+/**
+ Clean up the HII Thunk Context for a UEFI HII Handle.
+
+ @param Private The HII Thunk Module Private context.
+ @param UEFIHiiHandle The UEFI HII Handle.
+**/
VOID
DestroyThunkContextForUefiHiiHandle (
IN HII_THUNK_PRIVATE_DATA *Private,
@@ -164,13 +205,18 @@ CreateThunkContextForUefiHiiHandle (
CopyGuid(&ThunkContext->TagGuid, &PackageGuid);
- InitializeListHead (&ThunkContext->QuestionIdMapListHead);
- InitializeListHead (&ThunkContext->OneOfOptionMapListHead);
-
return ThunkContext;
}
+/**
+ Get the number of HII Package for a Package type.
+
+ @param PackageListHeader The Package List.
+ @param PackageType The Package Type.
+
+ @return The number of Package for given type.
+**/
UINTN
GetPackageCountByType (
IN CONST EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader,
@@ -194,28 +240,13 @@ GetPackageCountByType (
return Count;
}
-LIST_ENTRY *
-GetOneOfOptionMapEntryListHead (
- IN CONST HII_THUNK_CONTEXT *ThunkContext,
- IN UINT16 QuestionId
- )
-{
- LIST_ENTRY *Link;
- ONE_OF_OPTION_MAP *Map;
+/**
+ Get the Form Package from a Framework Package List.
- 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;
-}
+ @param Packages Framework Package List.
+ @return The Form Package Header found.
+**/
EFI_HII_PACKAGE_HEADER *
GetIfrPackage (
IN CONST EFI_HII_PACKAGES *Packages
@@ -260,6 +291,15 @@ GetIfrPackage (
return NULL;
}
+/**
+ Get FormSet GUID.
+
+ ASSERT if no FormSet Opcode is found.
+
+ @param Packages Form Framework Package.
+ @param FormSetGuid Return the FormSet Guid.
+
+**/
VOID
GetFormSetGuid (
IN EFI_HII_PACKAGE_HEADER *Package,
@@ -294,406 +334,336 @@ GetFormSetGuid (
}
+/**
+ Creat a Thunk Context.
+
+ ASSERT if no FormSet Opcode is found.
+
+ @param Private The HII Thunk Private Context.
+ @param StringPackageCount The String package count.
+ @param FormSetGuid The IFR Package count.
+
+ @return A newly created Thunk Context.
+ @retval NULL No resource to create a new Thunk Context.
+**/
+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 = AllocateHiiHandle (&ThunkContext->FwHiiHandle);
+ if (EFI_ERROR (Status)) {
+ return NULL;
+ }
+
+ return ThunkContext;
+
+}
+
+/**
+ Destroy the Thunk Context and free up all resource.
+ @param ThunkContext The HII Thunk Private Context to be freed.
+
+**/
VOID
-GetAttributesOfFirstFormSet (
- IN OUT HII_THUNK_CONTEXT *ThunkContext
+DestroyThunkContext (
+ IN 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;
- EFI_IFR_GUID_CLASS *Class;
- EFI_IFR_FORM_SET *FormSet;
- EFI_IFR_GUID_SUBCLASS *SubClass;
+ ASSERT (ThunkContext != NULL);
- Status = HiiLibExportPackageLists (ThunkContext->UefiHiiHandle, &List, &Size);
- ASSERT_EFI_ERROR (Status);
+ FreeHiiHandle (ThunkContext->FwHiiHandle);
- //
- // There must be at least one EFI_HII_PACKAGE_FORMS in the package list.
- //
- ASSERT (GetPackageCountByType (List, EFI_HII_PACKAGE_FORMS) >= 1);
+ RemoveEntryList (&ThunkContext->Link);
+
+ if (ThunkContext->FormSet != NULL) {
+ DestroyFormSet (ThunkContext->FormSet);
+ }
+
+ FreePool (ThunkContext);
+}
+
+/**
+ Get the FormSet's Default Varstore ID based on the rule (Descending Priority):
+
+ 1) Var Store ID of FRAMEWORK_RESERVED_VARSTORE_ID (0x01).
+ 2) First Var Store ID.
+
+ @param FormSet The Form Set.
+
+**/
+VOID
+GetFormsetDefaultVarstoreId (
+ IN OUT FORM_BROWSER_FORMSET * FormSet
+ )
+{
+ LIST_ENTRY *StorageList;
+ FORMSET_STORAGE *Storage;
+ EFI_VARSTORE_ID FirstVarStoreId;
//
- // Skip the package list header.
+ // VarStoreId 0 is invalid in UEFI IFR.
//
- Package = (EFI_HII_PACKAGE_HEADER *) (List + 1);
-
- while (Package->Type != EFI_HII_PACKAGE_END) {
+ FormSet->DefaultVarStoreId = 0;
+ StorageList = GetFirstNode (&FormSet->StorageListHead);
- if (Package->Type == EFI_HII_PACKAGE_FORMS) {
+ while (!IsNull (&FormSet->StorageListHead, StorageList)) {
+ Storage = FORMSET_STORAGE_FROM_LINK (StorageList);
- //
- // 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_GUID_OP:
- Class = (EFI_IFR_GUID_CLASS*) OpCode;
- if (CompareGuid ((EFI_GUID *)(VOID *)&Class->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:
- SubClass = (EFI_IFR_GUID_SUBCLASS *) OpCode;
- ThunkContext->FormSetSubClass = SubClass->SubClass;
- break;
-
- default:
- break;
- }
- }
- break;
-
- default:
- break;
-
- }
+ DEBUG ((EFI_D_INFO, "FormSet %g: Found Varstore ID %x\n", &FormSet->Guid, Storage->VarStoreId));
- Offset += OpCode->Length;
- }
- //
- // The attributes of first FormSet is ready now.
- //
- FreePool (List);
- return;
-
+ if (Storage->VarStoreId == FRAMEWORK_RESERVED_VARSTORE_ID) {
+ FormSet->DefaultVarStoreId = FRAMEWORK_RESERVED_VARSTORE_ID;
break;
}
- Package = (EFI_HII_PACKAGE_HEADER *) ((UINT8 *) Package + Package->Length);
+ StorageList = GetNextNode (&FormSet->StorageListHead, StorageList);
+ }
+
+ if (FormSet->DefaultVarStoreId != FRAMEWORK_RESERVED_VARSTORE_ID) {
+ StorageList = GetFirstNode (&FormSet->StorageListHead);
+ if (!IsNull (&FormSet->StorageListHead, StorageList)) {
+ Storage = FORMSET_STORAGE_FROM_LINK (StorageList);
+ FirstVarStoreId = Storage->VarStoreId;
+ }
+
}
+ DEBUG_CODE_BEGIN ();
+ if (FormSet->DefaultVarStoreId == 0) {
+ DEBUG ((EFI_D_INFO, "FormSet %g: No Varstore Found\n", &FormSet->Guid));
+ } else {
+ DEBUG ((EFI_D_INFO, "FormSet %g: Default Varstore ID is %x\n", &FormSet->Guid, FormSet->DefaultVarStoreId));
+ }
+ DEBUG_CODE_END ();
+
+ return;
}
+/**
+ Fetch the Ifr binary data of a FormSet.
+
+ @param Handle PackageList Handle
+ @param FormSetGuid GUID of a formset. If not specified (NULL or zero
+ GUID), take the first FormSet found in package
+ list.
+ @param BinaryLength The length of the FormSet IFR binary.
+ @param BinaryData The buffer designed to receive the FormSet.
+ @retval EFI_SUCCESS Buffer filled with the requested FormSet.
+ BufferLength was updated.
+ @retval EFI_INVALID_PARAMETER The handle is unknown.
+ @retval EFI_NOT_FOUND A form or FormSet on the requested handle cannot
+ be found with the requested FormId.
+
+**/
EFI_STATUS
-CreateQuestionIdMap (
- IN OUT HII_THUNK_CONTEXT *ThunkContext
+GetIfrBinaryData (
+ IN EFI_HII_HANDLE Handle,
+ IN OUT EFI_GUID *FormSetGuid,
+ OUT UINTN *BinaryLength,
+ OUT UINT8 **BinaryData
)
{
- 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;
- EFI_IFR_GUID_SUBCLASS *SubClass;
- UINT8 OneOfType;
- EFI_IFR_ONE_OF *OneOfOpcode;
+ EFI_STATUS Status;
+ EFI_HII_PACKAGE_LIST_HEADER *HiiPackageList;
+ UINTN BufferSize;
+ UINT8 *Package;
+ UINT8 *OpCodeData;
+ UINT32 Offset;
+ UINT32 Offset2;
+ BOOLEAN ReturnDefault;
+ UINT32 PackageListLength;
+ EFI_HII_PACKAGE_HEADER PackageHeader;
+
+ OpCodeData = NULL;
+ Package = NULL;
+ ZeroMem (&PackageHeader, sizeof (EFI_HII_PACKAGE_HEADER));;
//
- // Set to a invalid value.
+ // if FormSetGuid is NULL or zero GUID, return first FormSet in the package list
//
- OneOfType = (UINT8) -1;
-
-
- Status = HiiLibExportPackageLists (ThunkContext->UefiHiiHandle, &List, &Size);
- if (EFI_ERROR (Status)) {
- return Status;
+ if (FormSetGuid == NULL || CompareGuid (FormSetGuid, &gZeroGuid)) {
+ ReturnDefault = TRUE;
+ } else {
+ ReturnDefault = FALSE;
}
//
- // 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
+ // Get HII PackageList
//
+ BufferSize = 0;
+ HiiPackageList = NULL;
+ Status = mHiiDatabase->ExportPackageLists (mHiiDatabase, Handle, &BufferSize, HiiPackageList);
+ if (Status == EFI_BUFFER_TOO_SMALL) {
+ HiiPackageList = AllocatePool (BufferSize);
+ ASSERT (HiiPackageList != NULL);
+
+ Status = mHiiDatabase->ExportPackageLists (mHiiDatabase, Handle, &BufferSize, HiiPackageList);
+ }
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
//
- // Skip the package list header.
+ // Get Form package from this HII package List
//
- Package = (EFI_HII_PACKAGE_HEADER *) (List + 1);
-
- while (Package->Type != EFI_HII_PACKAGE_END) {
+ Offset = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+ Offset2 = 0;
+ CopyMem (&PackageListLength, &HiiPackageList->PackageLength, sizeof (UINT32));
- if (Package->Type == EFI_HII_PACKAGE_FORMS) {
+ while (Offset < PackageListLength) {
+ Package = ((UINT8 *) HiiPackageList) + Offset;
+ CopyMem (&PackageHeader, Package, sizeof (EFI_HII_PACKAGE_HEADER));
+ if (PackageHeader.Type == EFI_HII_PACKAGE_FORMS) {
//
- // Skip the package header
+ // Search FormSet in this Form Package
//
- 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:
+ Offset2 = sizeof (EFI_HII_PACKAGE_HEADER);
+ while (Offset2 < PackageHeader.Length) {
+ OpCodeData = Package + Offset2;
+
+ if (((EFI_IFR_OP_HEADER *) OpCodeData)->OpCode == EFI_IFR_FORM_SET_OP) {
//
- // IFR built from Framework VFR only has UEFI Buffer Type Storage
+ // Check whether return default FormSet
//
- 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);
- }
-
- if (OpCode->OpCode == EFI_IFR_ONE_OF_OP) {
- OneOfOpcode = (EFI_IFR_ONE_OF *) OpCode;
- OneOfType = OneOfOpcode->Flags & EFI_IFR_NUMERIC_SIZE;
+ if (ReturnDefault) {
+ break;
}
- break;
-
- case EFI_IFR_GUID_OP:
- OptionMap = (EFI_IFR_GUID_OPTIONKEY *) OpCode;
- if (CompareGuid ((EFI_GUID *)(VOID *)&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;
-
- //
- // Make sure OneOfType is initialized.
- //
- ASSERT (OneOfType != (UINT8) -1);
- OneOfOptionMap->ValueType = OneOfType;
- 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 ((EFI_GUID *)(VOID *)&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:
- SubClass = (EFI_IFR_GUID_SUBCLASS *) OpCode;
- ThunkContext->FormSetSubClass = SubClass->SubClass;
- break;
-
- default:
- break;
- }
+ //
+ // FormSet GUID is specified, check it
+ //
+ if (CompareGuid (FormSetGuid, (EFI_GUID *)(OpCodeData + sizeof (EFI_IFR_OP_HEADER)))) {
+ break;
}
- break;
-
- default:
- break;
-
}
- Offset += OpCode->Length;
+ Offset2 += ((EFI_IFR_OP_HEADER *) OpCodeData)->Length;
+ }
+
+ if (Offset2 < PackageHeader.Length) {
+ //
+ // Target formset found
+ //
+ break;
}
- //
- // Only Form Package is in a Package List.
- //
- break;
}
- Package = (EFI_HII_PACKAGE_HEADER *) (UINT8 *) Package + Package->Length;
+ Offset += PackageHeader.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);
+ if (Offset >= PackageListLength) {
+ //
+ // Form package not found in this Package List
+ //
+ gBS->FreePool (HiiPackageList);
+ return EFI_NOT_FOUND;
+ }
- while (!IsNull (&ThunkContext->QuestionIdMapListHead, Link)) {
- Map = QUESTION_ID_MAP_FROM_LINK (Link);
- if (VarStoreId == Map->VarStoreId) {
- return &Map->MapEntryListHead;
- }
- Link = GetNextNode (&ThunkContext->QuestionIdMapListHead, Link);
+ if (ReturnDefault && FormSetGuid != NULL) {
+ //
+ // Return the default FormSet GUID
+ //
+ CopyMem (FormSetGuid, &((EFI_IFR_FORM_SET *) OpCodeData)->Guid, sizeof (EFI_GUID));
}
- return NULL;
-}
+ //
+ // To determine the length of a whole FormSet IFR binary, one have to parse all the Opcodes
+ // in this FormSet; So, here just simply copy the data from start of a FormSet to the end
+ // of the Form Package.
+ //
+ *BinaryLength = PackageHeader.Length - Offset2;
+ *BinaryData = AllocateCopyPool (*BinaryLength, OpCodeData);
-HII_THUNK_CONTEXT *
-CreateThunkContext (
- IN HII_THUNK_PRIVATE_DATA *Private,
- IN UINTN StringPackageCount,
- IN UINTN IfrPackageCount
- )
-{
- EFI_STATUS Status;
- HII_THUNK_CONTEXT *ThunkContext;
+ gBS->FreePool (HiiPackageList);
- ThunkContext = AllocateZeroPool (sizeof (HII_THUNK_CONTEXT));
- ASSERT (ThunkContext != NULL);
-
- ThunkContext->Signature = HII_THUNK_CONTEXT_SIGNATURE;
- ThunkContext->IfrPackageCount = IfrPackageCount;
- ThunkContext->StringPackageCount = StringPackageCount;
- Status = AllocateHiiHandle (&ThunkContext->FwHiiHandle);
- if (EFI_ERROR (Status)) {
- return NULL;
+ if (*BinaryData == NULL) {
+ return EFI_OUT_OF_RESOURCES;
}
- InitializeListHead (&ThunkContext->QuestionIdMapListHead);
- InitializeListHead (&ThunkContext->OneOfOptionMapListHead);
-
-
- return ThunkContext;
-
+ return EFI_SUCCESS;
}
-VOID
-DestroyThunkContext (
- IN HII_THUNK_CONTEXT *ThunkContext
- )
-{
- ASSERT (ThunkContext != NULL);
-
- FreeHiiHandle (ThunkContext->FwHiiHandle);
-
- DestroyQuestionIdMap (&ThunkContext->QuestionIdMapListHead);
-
- DestoryOneOfOptionMap (&ThunkContext->OneOfOptionMapListHead);
-
- RemoveEntryList (&ThunkContext->Link);
+/**
+ Initialize the internal data structure of a FormSet.
- FreePool (ThunkContext);
-}
+ @param Handle PackageList Handle
+ @param FormSetGuid GUID of a formset. If not specified (NULL or zero
+ GUID), take the first FormSet found in package
+ list.
+ @param FormSet FormSet data structure.
+ @retval EFI_SUCCESS The function completed successfully.
+ @retval EFI_NOT_FOUND The specified FormSet could not be found.
-VOID
-DestroyQuestionIdMap (
- IN LIST_ENTRY *QuestionIdMapListHead
+**/
+EFI_STATUS
+InitializeFormSet (
+ IN EFI_HII_HANDLE Handle,
+ IN OUT EFI_GUID *FormSetGuid,
+ OUT FORM_BROWSER_FORMSET *FormSet
)
{
- 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);
+ EFI_STATUS Status;
- while (!IsListEmpty (&IdMap->MapEntryListHead)) {
- Link2 = GetFirstNode (&IdMap->MapEntryListHead);
-
- IdMapEntry = QUESTION_ID_MAP_ENTRY_FROM_LINK (Link2);
-
- RemoveEntryList (Link2);
+ Status = GetIfrBinaryData (Handle, FormSetGuid, &FormSet->IfrBinaryLength, &FormSet->IfrBinaryData);
+ if (EFI_ERROR (Status)) {
+ return Status;
+ }
- FreePool (IdMapEntry);
- }
+ FormSet->HiiHandle = Handle;
+ CopyMem (&FormSet->Guid, FormSetGuid, sizeof (EFI_GUID));
- RemoveEntryList (Link);
- FreePool (IdMap);
+ //
+ // Parse the IFR binary OpCodes
+ //
+ Status = ParseOpCodes (FormSet);
+ if (EFI_ERROR (Status)) {
+ return Status;
}
+
+ GetFormsetDefaultVarstoreId (FormSet);
+ return Status;
}
-VOID
-DestoryOneOfOptionMap (
- IN LIST_ENTRY *OneOfOptionMapListHead
- )
-{
- ONE_OF_OPTION_MAP *Map;
- ONE_OF_OPTION_MAP_ENTRY *MapEntry;
- LIST_ENTRY *Link;
- LIST_ENTRY *Link2;
+/**
+ Parse the Form Package and build a FORM_BROWSER_FORMSET structure.
- while (!IsListEmpty (OneOfOptionMapListHead)) {
- Link = GetFirstNode (OneOfOptionMapListHead);
-
- Map = ONE_OF_OPTION_MAP_FROM_LINK (Link);
+ @param UefiHiiHandle PackageList Handle
- while (!IsListEmpty (&Map->OneOfOptionMapEntryListHead)) {
- Link2 = GetFirstNode (&Map->OneOfOptionMapEntryListHead);
-
- MapEntry = ONE_OF_OPTION_MAP_ENTRY_FROM_LINK (Link2);
+ @return A pointer to FORM_BROWSER_FORMSET.
- RemoveEntryList (Link2);
+**/
+FORM_BROWSER_FORMSET *
+ParseFormSet (
+ IN EFI_HII_HANDLE UefiHiiHandle
+ )
+{
+ FORM_BROWSER_FORMSET *FormSet;
+ EFI_GUID FormSetGuid;
+ EFI_STATUS Status;
+
+ FormSet = AllocateZeroPool (sizeof (FORM_BROWSER_FORMSET));
+ ASSERT (FormSet != NULL);
- FreePool (MapEntry);
- }
+ CopyGuid (&FormSetGuid, &gZeroGuid);
+ Status = InitializeFormSet (UefiHiiHandle, &FormSetGuid, FormSet);
+ ASSERT_EFI_ERROR (Status);
- RemoveEntryList (Link);
- FreePool (Map);
- }
+ return FormSet;
}
-
-
-
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h
index 90b4784bea..99642fd5b9 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h
@@ -97,12 +97,6 @@ DestroyThunkContext (
);
VOID
-DestroyQuestionIdMap (
- IN LIST_ENTRY *QuestionIdMapListHead
- );
-
-
-VOID
DestoryOneOfOptionMap (
IN LIST_ENTRY *OneOfOptionMapListHead
);
@@ -120,4 +114,10 @@ GetIfrPackage (
)
;
+FORM_BROWSER_FORMSET *
+ParseFormSet (
+ IN EFI_HII_HANDLE UefiHiiHandle
+ )
+;
+
#endif