summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c40
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c79
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h13
3 files changed, 110 insertions, 22 deletions
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c
index b3e9bdd..d84eade 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c
@@ -259,7 +259,9 @@ UefiRegisterPackageList(
UINTN IfrPackageCount;
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
HII_THUNK_CONTEXT *ThunkContext;
+ HII_THUNK_CONTEXT *ThunkContextToRemove;
EFI_GUID GuidId;
+ EFI_HII_PACKAGE_HEADER *IfrPackage;
PackageListHeader = NULL;
@@ -274,6 +276,12 @@ UefiRegisterPackageList(
return EFI_UNSUPPORTED;
}
+ ThunkContext = CreateThunkContext (Private, StringPackageCount, IfrPackageCount);
+ if (ThunkContext == NULL) {
+ return EFI_OUT_OF_RESOURCES;
+ }
+ ThunkContext->ByFrameworkHiiNewPack = TRUE;
+
if (Packages->GuidId == NULL) {
//
// UEFI HII Database require Package List GUID must be unique.
@@ -284,39 +292,27 @@ UefiRegisterPackageList(
// GUID.
//
ASSERT (StringPackageCount >=1 && IfrPackageCount == 1);
- GenerateRandomGuid (&GuidId);
+ IfrPackage = GetIfrPackage (Packages);
+ GetFormSetGuid (IfrPackage, &ThunkContext->TagGuid);
} else {
- ThunkContext = TagGuidToIfrPackThunkContext (Private, Packages->GuidId);
+ ThunkContextToRemove = TagGuidToIfrPackThunkContext (Private, Packages->GuidId);
if (IfrPackageCount > 0 &&
StringPackageCount > 0 &&
- (ThunkContext!= NULL)) {
+ (ThunkContextToRemove!= NULL)) {
DEBUG((EFI_D_WARN, "Framework code registers HII package list with the same GUID more than once.\n"));
DEBUG((EFI_D_WARN, "This package list should be already registered. Just return successfully.\n"));
- HiiRemovePack (This, ThunkContext->FwHiiHandle);
+ HiiRemovePack (This, ThunkContextToRemove->FwHiiHandle);
}
- CopyGuid (&GuidId, Packages->GuidId);
+ CopyGuid (&ThunkContext->TagGuid, Packages->GuidId);
}
- ThunkContext = CreateThunkContext (Private, StringPackageCount, IfrPackageCount);
- if (ThunkContext == NULL) {
- return EFI_OUT_OF_RESOURCES;
- }
- ThunkContext->ByFrameworkHiiNewPack = TRUE;
-
//
- // Record the Package List GUID, it is used as a name for the package list by Framework HII.
+ // UEFI HII database does not allow two package list with the same GUID.
+ // In Framework HII implementation, Packages->GuidId is used as an identifier to associate
+ // a PackageList with only IFR to a Package list the with String package.
//
- CopyGuid (&ThunkContext->TagGuid, &GuidId);
-
- if ((StringPackageCount == 0) && (IfrPackageCount != 0)) {
- //
- // UEFI HII database does not allow two package list with the same GUID.
- // In Framework HII implementation, Packages->GuidId is used as an identifier to associate
- // a PackageList with only IFR to a Package list the with String package.
- //
- GenerateRandomGuid (&GuidId);
- }
+ GenerateRandomGuid (&GuidId);
//
// UEFI HII require EFI_HII_CONFIG_ACCESS_PROTOCOL to be installed on a EFI_HANDLE, so
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c
index e015f83..b053789 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c
@@ -216,6 +216,85 @@ GetOneOfOptionMapEntryListHead (
return NULL;
}
+EFI_HII_PACKAGE_HEADER *
+GetIfrPackage (
+ IN CONST EFI_HII_PACKAGES *Packages
+ )
+{
+ UINTN Index;
+ TIANO_AUTOGEN_PACKAGES_HEADER **TianoAutogenPackageHdrArray;
+
+ ASSERT (Packages != NULL);
+
+ TianoAutogenPackageHdrArray = (TIANO_AUTOGEN_PACKAGES_HEADER **) (((UINT8 *) &Packages->GuidId) + sizeof (Packages->GuidId));
+
+ for (Index = 0; Index < Packages->NumberOfPackages; Index++) {
+ //
+ // The current UEFI HII build tool generate a binary in the format defined by
+ // TIANO_AUTOGEN_PACKAGES_HEADER. We assume that all packages generated in
+ // this binary is with same package type. So the returned IfrPackageCount and StringPackageCount
+ // may not be the exact number of valid package number in the binary generated
+ // by HII Build tool.
+ //
+ switch (TianoAutogenPackageHdrArray[Index]->PackageHeader.Type) {
+ case EFI_HII_PACKAGE_FORM:
+ return &TianoAutogenPackageHdrArray[Index]->PackageHeader;
+ break;
+ case EFI_HII_PACKAGE_STRINGS:
+ case EFI_HII_PACKAGE_SIMPLE_FONTS:
+ break;
+
+ //
+ // 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);
+ return NULL;
+ break;
+ }
+ }
+
+ return NULL;
+}
+
+VOID
+GetFormSetGuid (
+ IN EFI_HII_PACKAGE_HEADER *Package,
+ OUT EFI_GUID *FormSetGuid
+ )
+{
+ UINTN Offset;
+ EFI_IFR_OP_HEADER *OpCode;
+ EFI_IFR_FORM_SET *FormSet;
+
+ 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;
+ CopyGuid (FormSetGuid, &FormSet->Guid);
+ return;
+
+ default:
+ break;
+
+ }
+ Offset += OpCode->Length;
+ }
+
+ //
+ // A proper IFR must have a formset opcode.
+ //
+ ASSERT (FALSE);
+
+}
+
+
VOID
GetAttributesOfFirstFormSet (
IN OUT HII_THUNK_CONTEXT *ThunkContext
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h
index 5d93c70..90b4784 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h
@@ -107,4 +107,17 @@ DestoryOneOfOptionMap (
IN LIST_ENTRY *OneOfOptionMapListHead
);
+VOID
+GetFormSetGuid (
+ IN EFI_HII_PACKAGE_HEADER *Package,
+ OUT EFI_GUID *FormSetGuid
+ )
+;
+
+EFI_HII_PACKAGE_HEADER *
+GetIfrPackage (
+ IN CONST EFI_HII_PACKAGES *Packages
+ )
+;
+
#endif