diff options
author | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-11-21 15:07:50 +0000 |
---|---|---|
committer | qwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524> | 2008-11-21 15:07:50 +0000 |
commit | 70d72ba978a756c27f2f6f657a156285ecaeeb45 (patch) | |
tree | ff751271e8df716a1d345196606001bcdce38cf1 /EdkCompatibilityPkg/Compatibility | |
parent | 1459f3cd48ff0da6788542f859216020e6c7e865 (diff) | |
download | edk2-platforms-70d72ba978a756c27f2f6f657a156285ecaeeb45.tar.xz |
1) StrGather (Build.exe) in compatible mode add a Framework Package Header to replace the original “ArrayLength” generated in the output.
2) VfrCompiler in compatible mode add a Framework Package Header to replace the original “ArrayLength” generated in the output.
3) HII Thunk module nows support Narrow Font registered using Framework New Pack HII interface.
4) Fix a bug in IfrLibCreatePopUp2 by updating the prototype. The previous way of using VA_START to get the address of parameter in the argument list and expecting the parameters that follows will be found using VA_ARG macro is wrong.
git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@6672 6f19259b-4bc3-4df7-8a09-765794883524
Diffstat (limited to 'EdkCompatibilityPkg/Compatibility')
4 files changed, 166 insertions, 38 deletions
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h index 0ea1b5a359..6c3741511c 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h @@ -66,7 +66,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #pragma pack (push, 1)
typedef struct {
- UINT32 BinaryLength;
+ EFI_HII_PACK_HEADER FrameworkPackageHeader;
EFI_HII_PACKAGE_HEADER PackageHeader;
} TIANO_AUTOGEN_PACKAGES_HEADER;
#pragma pack (pop)
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c index c88ad767b9..0aa4773abe 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Package.c @@ -39,8 +39,9 @@ UINT64 mGuidCount = 0; EFI_STATUS
GetPackageCount (
IN CONST EFI_HII_PACKAGES *Packages,
- UINTN *IfrPackageCount,
- UINTN *StringPackageCount
+ OUT UINTN *IfrPackageCount,
+ OUT UINTN *StringPackageCount,
+ OUT UINTN *FontPackageCount
)
{
UINTN Index;
@@ -49,9 +50,11 @@ GetPackageCount ( ASSERT (Packages != NULL);
ASSERT (IfrPackageCount != NULL);
ASSERT (StringPackageCount != NULL);
+ ASSERT (FontPackageCount != NULL);
*IfrPackageCount = 0;
*StringPackageCount = 0;
+ *FontPackageCount = 0;
TianoAutogenPackageHdrArray = (TIANO_AUTOGEN_PACKAGES_HEADER **) (((UINT8 *) &Packages->GuidId) + sizeof (Packages->GuidId));
@@ -63,23 +66,21 @@ GetPackageCount ( // 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:
+ switch (TianoAutogenPackageHdrArray[Index]->FrameworkPackageHeader.Type) {
+ case EFI_HII_IFR:
*IfrPackageCount += 1;
break;
- case EFI_HII_PACKAGE_STRINGS:
+ case EFI_HII_STRING:
*StringPackageCount += 1;
break;
- case EFI_HII_PACKAGE_SIMPLE_FONTS:
+ case EFI_HII_FONT:
+ *FontPackageCount += 1;
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 EFI_INVALID_PARAMETER;
@@ -144,6 +145,98 @@ UpdatePackListWithOnlyIfrPack ( }
+/**
+ Caculate the size of UEFI Simple Font Package that is needed to
+ convert all the font a Framework Font Paackage.
+
+ ONLY Narrow Font is supported. Wide Font is discarded.
+
+ If the Package Header is not of EFI_HII_FONT type, then ASSERT.
+
+ @param The Package header of the Framework Font Package.
+
+ @return The size of the UEFI Simple Font Package.
+
+**/
+UINTN
+GetUefiSimpleFontPackSize (
+ IN CONST EFI_HII_PACK_HEADER * PackHeader
+ )
+{
+ UINTN Size;
+ EFI_HII_FONT_PACK *FwFontPack;
+
+ FwFontPack = (EFI_HII_FONT_PACK *) PackHeader;
+
+ ASSERT (FwFontPack->Header.Type == EFI_HII_FONT);
+
+ Size = sizeof (EFI_HII_SIMPLE_FONT_PACKAGE_HDR)
+ + (FwFontPack->NumberOfNarrowGlyphs * sizeof (EFI_NARROW_GLYPH));
+
+ return Size;
+}
+
+
+/**
+ Convert Font Package in Framework format to a newly allocated UEFI
+ Simple Font Package.
+
+ ONLY Narrow Font is supported. Wide Font is discarded.
+
+ If memory allocation fails, then ASSERT.
+
+ @param FwFontPack Framework Font Package.
+
+ @reture UEFI Simple Font Package.
+**/
+EFI_HII_SIMPLE_FONT_PACKAGE_HDR *
+FrameworkFontPackToUefiSimpliedFont (
+ IN CONST EFI_HII_PACK_HEADER * PackHeader
+ )
+{
+ EFI_HII_SIMPLE_FONT_PACKAGE_HDR *FontPack;
+ UINTN Size;
+ EFI_NARROW_GLYPH *FwNarrowGlyph;
+ EFI_NARROW_GLYPH *NarrowGlyph;
+ UINTN Idx;
+ EFI_HII_FONT_PACK *FwFontPack;
+
+ Size = GetUefiSimpleFontPackSize (PackHeader);
+
+ FwFontPack = (EFI_HII_FONT_PACK *) PackHeader;
+
+ FontPack = AllocateZeroPool (Size);
+ ASSERT (FontPack != NULL);
+
+ //
+ // Prepare the Header information.
+ //
+ FontPack->Header.Length = (UINT32) Size;
+ FontPack->Header.Type = EFI_HII_PACKAGE_SIMPLE_FONTS;
+
+ FontPack->NumberOfNarrowGlyphs = FwFontPack->NumberOfNarrowGlyphs;
+
+ //
+ // ONLY Narrow Font is supported. Wide Font is discarded.
+ //
+ FontPack->NumberOfWideGlyphs = 0;
+
+ //
+ // Copy Narrow Glyph
+ //
+ NarrowGlyph = (EFI_NARROW_GLYPH *) (FontPack + 1);
+ FwNarrowGlyph = (EFI_NARROW_GLYPH *) (FwFontPack + 1);
+ CopyMem (NarrowGlyph, FwNarrowGlyph, sizeof (EFI_NARROW_GLYPH) * FwFontPack->NumberOfNarrowGlyphs);
+ for (Idx = 0; Idx < FwFontPack->NumberOfNarrowGlyphs; Idx++) {
+ //
+ // Clear the GLYPH_NON_BREAKING (EFI_GLYPH_WIDE is used here as they are all 0x02)
+ // attribute which is not defined in UEFI EFI_NARROW_GLYPH
+ //
+ NarrowGlyph[Idx].Attributes = (UINT8) (NarrowGlyph[Idx].Attributes & ~(EFI_GLYPH_WIDE));
+ }
+
+ return FontPack;
+}
/**
Prepare a UEFI Package List from a Framework HII package list registered
@@ -170,7 +263,9 @@ PrepareUefiPackageListFromFrameworkHiiPackages ( UINT32 PackageLength;
EFI_HII_PACKAGE_HEADER PackageHeader;
UINTN Index;
- TIANO_AUTOGEN_PACKAGES_HEADER **TianoAutogenPackageHdrArray;
+ TIANO_AUTOGEN_PACKAGES_HEADER **TianoAutogenPackageHdrArray;
+ EFI_HII_SIMPLE_FONT_PACKAGE_HDR *FontPack;
+
ASSERT (Packages != NULL);
ASSERT (PackageListGuid != NULL);
@@ -181,11 +276,29 @@ PrepareUefiPackageListFromFrameworkHiiPackages ( PackageListLength = sizeof (EFI_HII_PACKAGE_LIST_HEADER);
for (Index = 0; Index < NumberOfPackages; Index++) {
- CopyMem (&PackageLength, &TianoAutogenPackageHdrArray[Index]->BinaryLength, sizeof (UINT32));
- //
- //TIANO_AUTOGEN_PACKAGES_HEADER.BinaryLength include the BinaryLength itself.
- //
- PackageListLength += (PackageLength - sizeof(UINT32));
+ if (TianoAutogenPackageHdrArray[Index]->FrameworkPackageHeader.Type == EFI_HII_FONT) {
+ //
+ // There is no tool to generate Font package in Framework HII's implementation.
+ // Therefore, Font Package be a C structure defined in Framework HII code.
+ // Therefore, Font Package will be in Framework HII format defined by EFI_HII_FONT_PACK.
+ // We need to create a UEFI Simple Font Package and copy over all data. Hence, EFI_HII_FONT
+ // is handled differently than EFI_HII_IFR and EFI_HII_STRING.
+ //
+ PackageListLength = (UINT32) (PackageListLength + GetUefiSimpleFontPackSize (&TianoAutogenPackageHdrArray[Index]->FrameworkPackageHeader));
+
+ } else {
+ //
+ // For EFI_HII_IFR and EFI_HII_STRING, EDK II's VFR Compiler and Build.exe will generate a binary in a format
+ // defined by TIANO_AUTOGEN_PACKAGES_HEADER. A Framework HII's EFI_HII_PACK_HEADER is inserted before
+ // the UEFI package data.
+ //
+ CopyMem (&PackageLength, &TianoAutogenPackageHdrArray[Index]->FrameworkPackageHeader.Length, sizeof (UINT32));
+ //
+ // EFI_HII_PACK_HEADER.FrameworkPackageHeader.Length include the sizeof FrameworkPackageHeader itself.
+ //
+ PackageListLength += (PackageLength - sizeof(EFI_HII_PACK_HEADER));
+
+ }
}
//
@@ -200,10 +313,22 @@ PrepareUefiPackageListFromFrameworkHiiPackages ( PackageListData = ((UINT8 *) PackageListHeader) + sizeof (EFI_HII_PACKAGE_LIST_HEADER);
+ //
+ // Build the UEFI Package List.
+ //
for (Index = 0; Index < NumberOfPackages; Index++) {
- CopyMem (&PackageLength, &(TianoAutogenPackageHdrArray[Index]->BinaryLength), sizeof (UINT32));
- PackageLength -= sizeof (UINT32);
- CopyMem (PackageListData, &(TianoAutogenPackageHdrArray[Index]->PackageHeader), PackageLength);
+ if (TianoAutogenPackageHdrArray[Index]->FrameworkPackageHeader.Type == EFI_HII_FONT) {
+ PackageLength = (UINT32) GetUefiSimpleFontPackSize (&TianoAutogenPackageHdrArray[Index]->FrameworkPackageHeader);
+ FontPack = FrameworkFontPackToUefiSimpliedFont (&TianoAutogenPackageHdrArray[Index]->FrameworkPackageHeader);
+ CopyMem (PackageListData, FontPack, PackageLength);
+ FreePool (FontPack);
+
+ } else {
+ CopyMem (&PackageLength, &(TianoAutogenPackageHdrArray[Index]->FrameworkPackageHeader.Length), sizeof (UINT32));
+ PackageLength -= sizeof (EFI_HII_PACK_HEADER);
+ CopyMem (PackageListData, &(TianoAutogenPackageHdrArray[Index]->PackageHeader), PackageLength);
+
+ }
PackageListData += PackageLength;
}
@@ -331,6 +456,7 @@ UefiRegisterPackageList ( EFI_STATUS Status;
UINTN StringPackageCount;
UINTN IfrPackageCount;
+ UINTN FontPackageCount;
EFI_HII_PACKAGE_LIST_HEADER *PackageListHeader;
HII_THUNK_CONTEXT *ThunkContext;
HII_THUNK_CONTEXT *ThunkContextToRemove;
@@ -339,7 +465,7 @@ UefiRegisterPackageList ( PackageListHeader = NULL;
- Status = GetPackageCount (Packages, &IfrPackageCount, &StringPackageCount);
+ Status = GetPackageCount (Packages, &IfrPackageCount, &StringPackageCount, &FontPackageCount);
ASSERT_EFI_ERROR (Status);
if (IfrPackageCount > 1) {
@@ -363,22 +489,29 @@ 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. Formset GUID is used as the Package List
- // GUID.
+ // GUID instead.
//
- ASSERT (StringPackageCount >=1 && IfrPackageCount == 1);
- IfrPackage = GetIfrPackage (Packages);
- GetFormSetGuid (IfrPackage, &ThunkContext->TagGuid);
+ ASSERT ((StringPackageCount >=1 && IfrPackageCount == 1) || (FontPackageCount > 0));
+ if (IfrPackageCount > 0) {
+ IfrPackage = GetIfrPackage (Packages);
+ GetFormSetGuid (IfrPackage, &ThunkContext->TagGuid);
+ } else {
+ ASSERT (FontPackageCount > 0);
+ GenerateRandomGuid (&ThunkContext->TagGuid);
+ }
+
} else {
ThunkContextToRemove = TagGuidToIfrPackThunkContext (Private, Packages->GuidId);
if (IfrPackageCount > 0 &&
StringPackageCount > 0 &&
- (ThunkContextToRemove!= 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"));
+ DEBUG((EFI_D_WARN, "Remove the previously registered package list and register the new one.\n"));
HiiRemovePack (This, ThunkContextToRemove->FwHiiHandle);
}
CopyGuid (&ThunkContext->TagGuid, Packages->GuidId);
+
}
//
@@ -390,6 +523,7 @@ UefiRegisterPackageList ( if (IfrPackageCount != 0) {
InstallDefaultConfigAccessProtocol (Packages, ThunkContext);
}
+
PackageListHeader = PrepareUefiPackageListFromFrameworkHiiPackages (Packages, &ThunkContext->TagGuid);
Status = mHiiDatabase->NewPackageList (
mHiiDatabase,
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/SetupBrowser.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/SetupBrowser.c index ebfbdeceb1..ca7bbe810a 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/SetupBrowser.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/SetupBrowser.c @@ -134,9 +134,9 @@ ThunkCreatePopUp ( return EFI_UNSUPPORTED;
}
- VA_START (Marker, KeyValue);
+ VA_START (Marker, String);
- Status = IfrLibCreatePopUp2 (NumberOfLines, KeyValue, Marker);
+ Status = IfrLibCreatePopUp2 (NumberOfLines, KeyValue, String, Marker);
VA_END (Marker);
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c index 48a133da63..ca870990e1 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c @@ -267,20 +267,14 @@ GetIfrPackage ( // 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:
+ switch (TianoAutogenPackageHdrArray[Index]->FrameworkPackageHeader.Type) {
+ case EFI_HII_IFR:
return &TianoAutogenPackageHdrArray[Index]->PackageHeader;
break;
- case EFI_HII_PACKAGE_STRINGS:
- case EFI_HII_PACKAGE_SIMPLE_FONTS:
+ case EFI_HII_STRING:
+ case EFI_HII_FONT:
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;
|