\r
@param Private Hii database private structure.\r
@param StringPackage HII string package instance.\r
+ @param FontId Font identifer, which must be unique within the string package.\r
@param DuplicateEnable If true, duplicate HII_FONT_INFO which refers to\r
the same EFI_FONT_INFO is permitted. Otherwise it\r
is not allowed.\r
ReferFontInfoLocally (\r
IN HII_DATABASE_PRIVATE_DATA *Private,\r
IN HII_STRING_PACKAGE_INSTANCE *StringPackage,\r
+ IN UINT8 FontId,\r
IN BOOLEAN DuplicateEnable,\r
IN HII_GLOBAL_FONT_INFO *GlobalFontInfo,\r
OUT HII_FONT_INFO **LocalFontInfo\r
}\r
}\r
}\r
- //\r
- // Since string package tool set FontId initially to 0 and increases it\r
- // progressively by one, StringPackage->FondId always represents an unique\r
- // and available FontId.\r
- //\r
// FontId identifies EFI_FONT_INFO in local string package uniquely.\r
// GlobalEntry points to a HII_GLOBAL_FONT_INFO which identifies\r
// EFI_FONT_INFO uniquely in whole hii database.\r
ASSERT (LocalFont != NULL);\r
\r
LocalFont->Signature = HII_FONT_INFO_SIGNATURE;\r
- LocalFont->FontId = StringPackage->FontId;\r
+ LocalFont->FontId = FontId;\r
LocalFont->GlobalEntry = &GlobalFontInfo->Entry;\r
InsertTailList (&StringPackage->FontInfoList, &LocalFont->Entry);\r
\r
- StringPackage->FontId++;\r
-\r
*LocalFontInfo = LocalFont;\r
return FALSE;\r
}\r
StringPtr += sizeof (CHAR16);\r
}\r
\r
+ if (*BufferSize < StringSize) {\r
+ *BufferSize = StringSize;\r
+ return EFI_BUFFER_TOO_SMALL;\r
+ }\r
if (StringDest != NULL) {\r
- if (*BufferSize < StringSize) {\r
- *BufferSize = StringSize;\r
- return EFI_BUFFER_TOO_SMALL;\r
- }\r
CopyMem (StringDest, StringSrc, StringSize);\r
- return EFI_SUCCESS;\r
}\r
\r
*BufferSize = StringSize;\r
UINT16 FontSize;\r
UINT8 Length8;\r
EFI_HII_SIBT_EXT2_BLOCK Ext2;\r
+ UINT8 FontId;\r
UINT32 Length32;\r
UINTN StringSize;\r
CHAR16 Zero;\r
// Find the relationship between global font info and the font info of\r
// this EFI_HII_SIBT_FONT block then backup its information in local package.\r
//\r
- BlockHdr += sizeof (EFI_HII_SIBT_EXT2_BLOCK) + sizeof (UINT8);\r
+ BlockHdr += sizeof (EFI_HII_SIBT_EXT2_BLOCK);\r
+ CopyMem (&FontId, BlockHdr, sizeof (UINT8));\r
+ BlockHdr += sizeof (UINT8);\r
CopyMem (&FontSize, BlockHdr, sizeof (UINT16));\r
BlockHdr += sizeof (UINT16);\r
CopyMem (&FontStyle, BlockHdr, sizeof (EFI_HII_FONT_STYLE));\r
FontInfo->FontSize = FontSize;\r
CopyMem (FontInfo->FontName, BlockHdr, StringSize);\r
\r
+ //\r
+ // If find the corresponding global font info, save the relationship.\r
+ // Otherwise ignore this EFI_HII_SIBT_FONT block.\r
+ //\r
if (IsFontInfoExisted (Private, FontInfo, NULL, NULL, &GlobalFont)) {\r
- //\r
- // If find the corresponding global font info, save the relationship.\r
- //\r
- ReferFontInfoLocally (Private, StringPackage, TRUE, GlobalFont, &LocalFont);\r
+ ReferFontInfoLocally (Private, StringPackage, FontId, TRUE, GlobalFont, &LocalFont);\r
}\r
\r
//\r
- // If can not find, ignore this EFI_HII_SIBT_FONT block.\r
- //\r
+ // Since string package tool set FontId initially to 0 and increases it\r
+ // progressively by one, StringPackage->FondId always represents an unique\r
+ // and available FontId.\r
+ // \r
+ StringPackage->FontId++;\r
+\r
SafeFreePool (FontInfo);\r
}\r
\r
}\r
\r
//\r
- // Get the string font.\r
+ // Get the string font. The FontId 0 is the default font for those string blocks which \r
+ // do not specify a font identifier. If default font is not specified, return NULL.\r
//\r
if (StringFontInfo != NULL) {\r
switch (BlockType) {\r
case EFI_HII_SIBT_STRING_UCS2_FONT:\r
case EFI_HII_SIBT_STRINGS_UCS2_FONT:\r
FontId = *(StringBlockAddr + sizeof (EFI_HII_STRING_BLOCK));\r
- return GetStringFontInfo (StringPackage, FontId, StringFontInfo);\r
break;\r
default:\r
- break;\r
+ FontId = 0;\r
+ }\r
+ Status = GetStringFontInfo (StringPackage, FontId, StringFontInfo);\r
+ if (Status == EFI_NOT_FOUND) {\r
+ *StringFontInfo = NULL;\r
}\r
}\r
\r
Referred = FALSE;\r
\r
//\r
- // Set the string font according to input font information.\r
+ // The input StringFontInfo should exist in current database if specified.\r
//\r
if (StringFontInfo != NULL) {\r
- //\r
- // The input StringFontInfo should exist in current database\r
- //\r
if (!IsFontInfoExisted (Private, StringFontInfo, NULL, NULL, &GlobalFont)) {\r
return EFI_INVALID_PARAMETER;\r
} else {\r
- Referred = ReferFontInfoLocally (Private, StringPackage, FALSE, GlobalFont, &LocalFont);\r
+ Referred = ReferFontInfoLocally (\r
+ Private, \r
+ StringPackage, \r
+ StringPackage->FontId, \r
+ FALSE, \r
+ GlobalFont, \r
+ &LocalFont\r
+ );\r
+ if (!Referred) {\r
+ StringPackage->FontId++;\r
+ }\r
}\r
-\r
//\r
- // Update the FontId of the specified string block\r
+ // Update the FontId of the specified string block to input font info.\r
//\r
switch (BlockType) {\r
- case EFI_HII_SIBT_STRING_SCSU_FONT:\r
+ case EFI_HII_SIBT_STRING_SCSU_FONT: \r
case EFI_HII_SIBT_STRINGS_SCSU_FONT:\r
case EFI_HII_SIBT_STRING_UCS2_FONT:\r
case EFI_HII_SIBT_STRINGS_UCS2_FONT:\r
*(StringBlockAddr + sizeof (EFI_HII_STRING_BLOCK)) = LocalFont->FontId;\r
break;\r
default:\r
- return EFI_NOT_FOUND;\r
+ //\r
+ // When modify the font info of these blocks, the block type should be updated\r
+ // to contain font info thus the whole structure should be revised.\r
+ // It is recommended to use tool to modify the block type not in the code.\r
+ // \r
+ return EFI_UNSUPPORTED;\r
}\r
-\r
}\r
\r
OldBlockSize = StringPackage->StringPkgHdr->Header.Length - StringPackage->StringPkgHdr->HdrSize;\r
\r
//\r
- // Set the string text.\r
+ // Set the string text and font.\r
//\r
StringTextPtr = StringBlockAddr + StringTextOffset;\r
switch (BlockType) {\r
//\r
Ucs2FontBlockSize = (UINT32) (StrSize (String) + sizeof (EFI_HII_SIBT_STRING_UCS2_FONT_BLOCK) -\r
sizeof (CHAR16));\r
- if (ReferFontInfoLocally (Private, StringPackage, FALSE, GlobalFont, &LocalFont)) {\r
+ if (ReferFontInfoLocally (Private, StringPackage, StringPackage->FontId, FALSE, GlobalFont, &LocalFont)) {\r
//\r
// Create a EFI_HII_SIBT_STRING_UCS2_FONT block only.\r
//\r
StringPackage->StringBlock = StringBlock;\r
StringPackage->StringPkgHdr->Header.Length += FontBlockSize + Ucs2FontBlockSize;\r
PackageListNode->PackageListHdr.PackageLength += FontBlockSize + Ucs2FontBlockSize;\r
+\r
+ //\r
+ // Increase the FontId to make it unique since we already add \r
+ // a EFI_HII_SIBT_FONT block to this string package.\r
+ //\r
+ StringPackage->FontId++;\r
}\r
}\r
\r
@retval EFI_SUCCESS The string was returned successfully.\r
@retval EFI_NOT_FOUND The string specified by StringId is not available.\r
@retval EFI_NOT_FOUND The string specified by StringId is available but\r
- not in the specified language.\r
+ not in the specified language.\r
+ The specified PackageList is not in the database.\r
+ @retval EFI_INVALID_LANGUAGE - The string specified by StringId is available but\r
@retval EFI_BUFFER_TOO_SMALL The buffer specified by StringSize is too small to\r
hold the string.\r
@retval EFI_INVALID_PARAMETER The String or Language or StringSize was NULL.\r
}\r
\r
if (PackageListNode != NULL) {\r
+ //\r
+ // First search: to match the StringId in the specified language.\r
+ //\r
for (Link = PackageListNode->StringPkgHdr.ForwardLink;\r
Link != &PackageListNode->StringPkgHdr;\r
Link = Link->ForwardLink\r
) {\r
- StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);\r
- if (R8_EfiLibCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {\r
- Status = GetStringWorker (Private, StringPackage, StringId, String, StringSize, StringFontInfo);\r
- if (Status != EFI_NOT_FOUND) {\r
- return Status;\r
+ StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);\r
+ if (R8_EfiLibCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) Language)) {\r
+ Status = GetStringWorker (Private, StringPackage, StringId, String, StringSize, StringFontInfo);\r
+ if (Status != EFI_NOT_FOUND) {\r
+ return Status;\r
+ }\r
}\r
}\r
- }\r
+ //\r
+ // Second search: to match the StringId in other available languages if exist.\r
+ //\r
+ for (Link = PackageListNode->StringPkgHdr.ForwardLink; \r
+ Link != &PackageListNode->StringPkgHdr;\r
+ Link = Link->ForwardLink\r
+ ) {\r
+ StringPackage = CR (Link, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE); \r
+ Status = GetStringWorker (Private, StringPackage, StringId, String, StringSize, StringFontInfo);\r
+ if (!EFI_ERROR (Status)) {\r
+ return EFI_INVALID_LANGUAGE;\r
+ }\r
+ } \r
}\r
\r
return EFI_NOT_FOUND;\r
too small to hold the returned information.\r
SecondLanguageSize is updated to hold the size of\r
the buffer required.\r
- @retval EFI_NOT_FOUND The language specified by FirstLanguage is not\r
- present in the specified package list.\r
+ @retval EFI_INVALID_LANGUAGE The language specified by FirstLanguage is not\r
+ present in the specified package list.\r
+ @retval EFI_NOT_FOUND The specified PackageList is not in the Database. \r
\r
**/\r
EFI_STATUS\r
}\r
\r
Private = HII_STRING_DATABASE_PRIVATE_DATA_FROM_THIS (This);\r
- Languages = NULL;\r
- ResultSize = 0;\r
\r
+ PackageListNode = NULL; \r
for (Link = Private->DatabaseList.ForwardLink; Link != &Private->DatabaseList; Link = Link->ForwardLink) {\r
DatabaseRecord = CR (Link, HII_DATABASE_RECORD, DatabaseEntry, HII_DATABASE_RECORD_SIGNATURE);\r
if (DatabaseRecord->Handle == PackageList) {\r
PackageListNode = (HII_DATABASE_PACKAGE_LIST_INSTANCE *) (DatabaseRecord->PackageList);\r
- for (Link1 = PackageListNode->StringPkgHdr.ForwardLink;\r
- Link1 != &PackageListNode->StringPkgHdr;\r
- Link1 = Link1->ForwardLink\r
- ) {\r
- StringPackage = CR (Link1, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);\r
- if (R8_EfiLibCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) FirstLanguage)) {\r
- Languages = StringPackage->StringPkgHdr->Language;\r
- //\r
- // Language is a series of ';' terminated strings, first one is primary\r
- // language and following with other secondary languages or NULL if no\r
- // secondary languages any more.\r
- //\r
- Languages = AsciiStrStr (Languages, ";");\r
- if (Languages == NULL) {\r
- break;\r
- }\r
- Languages++;\r
-\r
- ResultSize = AsciiStrSize (Languages);\r
- if (ResultSize <= *SecondLanguagesSize) {\r
- AsciiStrCpy (SecondLanguages, Languages);\r
- } else {\r
- *SecondLanguagesSize = ResultSize;\r
- return EFI_BUFFER_TOO_SMALL;\r
- }\r
+ break;\r
+ }\r
+ }\r
+ if (PackageListNode == NULL) {\r
+ return EFI_NOT_FOUND;\r
+ }\r
+ \r
+ Languages = NULL;\r
+ ResultSize = 0;\r
+ for (Link1 = PackageListNode->StringPkgHdr.ForwardLink;\r
+ Link1 != &PackageListNode->StringPkgHdr;\r
+ Link1 = Link1->ForwardLink\r
+ ) {\r
+ StringPackage = CR (Link1, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);\r
+ if (R8_EfiLibCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) FirstLanguage)) {\r
+ Languages = StringPackage->StringPkgHdr->Language;\r
+ //\r
+ // Language is a series of ';' terminated strings, first one is primary\r
+ // language and following with other secondary languages or NULL if no\r
+ // secondary languages any more.\r
+ //\r
+ Languages = AsciiStrStr (Languages, ";");\r
+ if (Languages == NULL) {\r
+ break;\r
+ }\r
+ Languages++;\r
\r
- return EFI_SUCCESS;\r
- }\r
+ ResultSize = AsciiStrSize (Languages);\r
+ if (ResultSize <= *SecondLanguagesSize) {\r
+ AsciiStrCpy (SecondLanguages, Languages);\r
+ } else {\r
+ *SecondLanguagesSize = ResultSize;\r
+ return EFI_BUFFER_TOO_SMALL;\r
}\r
+\r
+ return EFI_SUCCESS;\r
}\r
}\r
\r
- return EFI_NOT_FOUND;\r
+ return EFI_INVALID_LANGUAGE;\r
}\r
\r