Framework code may call PreparePacckage with NULL GUID and both IFR and String Packages.

PackageList = PreparePackages (2, NULL, IfrPack, StringPack);

    mHii->NewPack( mHii, PackageList, &HiiHandle );

Framework HII database make use of the formset GUID as ID to retrieve String using 

EFI_STATUS
GetStringFromToken (
  IN  EFI_GUID                  *ProducerGuid,
  IN  STRING_REF                Token,
  OUT CHAR16                    **String
  )

Update the code to cache the Formset GUID too.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5896 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qwang12 2008-09-16 06:47:08 +00:00
parent 8335866b0b
commit bc22641609
3 changed files with 110 additions and 22 deletions

View File

@ -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.
//
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);
}
//
// UEFI HII require EFI_HII_CONFIG_ACCESS_PROTOCOL to be installed on a EFI_HANDLE, so

View File

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

View File

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