for (Index = 0; Index < StringCount; Index++) {\r
BlockSize += AsciiStrSize ((CHAR8 *) StringTextPtr);\r
if (CurrentStringId == StringId) {\r
+ ASSERT (BlockType != NULL && StringBlockAddr != NULL && StringTextOffset != NULL);\r
*BlockType = *BlockHdr;\r
*StringBlockAddr = BlockHdr;\r
*StringTextOffset = StringTextPtr - BlockHdr;\r
for (Index = 0; Index < StringCount; Index++) {\r
BlockSize += AsciiStrSize ((CHAR8 *) StringTextPtr);\r
if (CurrentStringId == StringId) {\r
+ ASSERT (BlockType != NULL && StringBlockAddr != NULL && StringTextOffset != NULL);\r
*BlockType = *BlockHdr;\r
*StringBlockAddr = BlockHdr;\r
*StringTextOffset = StringTextPtr - BlockHdr;\r
GetUnicodeStringTextOrSize (NULL, StringTextPtr, &StringSize);\r
BlockSize += StringSize;\r
if (CurrentStringId == StringId) {\r
+ ASSERT (BlockType != NULL && StringBlockAddr != NULL && StringTextOffset != NULL);\r
*BlockType = *BlockHdr;\r
*StringBlockAddr = BlockHdr;\r
*StringTextOffset = StringTextPtr - BlockHdr;\r
GetUnicodeStringTextOrSize (NULL, StringTextPtr, &StringSize);\r
BlockSize += StringSize;\r
if (CurrentStringId == StringId) {\r
+ ASSERT (BlockType != NULL && StringBlockAddr != NULL && StringTextOffset != NULL);\r
*BlockType = *BlockHdr;\r
*StringBlockAddr = BlockHdr;\r
*StringTextOffset = StringTextPtr - BlockHdr;\r
//\r
// Get last string ID\r
//\r
- if (StringId == (EFI_STRING_ID) (-1)) {\r
+ if (StringId == (EFI_STRING_ID) (-1) && LastStringId != NULL) {\r
*LastStringId = (EFI_STRING_ID) (CurrentStringId - 1);\r
return EFI_SUCCESS;\r
}\r
\r
@param This A pointer to the EFI_HII_STRING_PROTOCOL instance.\r
@param PackageList The package list to examine.\r
- @param Languages Points to the buffer to hold the returned string.\r
+ @param Languages Points to the buffer to hold the returned\r
+ null-terminated ASCII string.\r
@param LanguagesSize On entry, points to the size of the buffer pointed\r
to by Languages, in bytes. On return, points to\r
the length of Languages, in bytes.\r
\r
@param This A pointer to the EFI_HII_STRING_PROTOCOL instance.\r
@param PackageList The package list to examine.\r
- @param FirstLanguage Points to the primary language.\r
- @param SecondaryLanguages Points to the buffer to hold the returned list of\r
+ @param PrimaryLanguage Points to the null-terminated ASCII string that specifies\r
+ the primary language. Languages are specified in the\r
+ format specified in Appendix M of the UEFI 2.0 specification.\r
+ @param SecondaryLanguages Points to the buffer to hold the returned null-terminated\r
+ ASCII string that describes the list of\r
secondary languages for the specified\r
- FirstLanguage. If there are no secondary\r
- languages, the function returns successfully, but\r
+ PrimaryLanguage. If there are no secondary\r
+ languages, the function returns successfully, but\r
this is set to NULL.\r
@param SecondaryLanguagesSize On entry, points to the size of the buffer pointed\r
- to by SecondaryLanguages, in bytes. On return,\r
+ to by SecondaryLanguages, in bytes. On return,\r
points to the length of SecondaryLanguages in bytes.\r
\r
@retval EFI_SUCCESS Secondary languages were correctly returned.\r
- @retval EFI_INVALID_PARAMETER FirstLanguage or SecondaryLanguages or\r
+ @retval EFI_INVALID_PARAMETER PrimaryLanguage or SecondaryLanguages or\r
SecondaryLanguagesSize was NULL.\r
@retval EFI_BUFFER_TOO_SMALL The buffer specified by SecondaryLanguagesSize is\r
too small to hold the returned information.\r
- SecondLanguageSize is updated to hold the size of\r
+ SecondaryLanguageSize is updated to hold the size of\r
the buffer required.\r
- @retval EFI_INVALID_LANGUAGE The language specified by FirstLanguage is not\r
- present in the specified package list.\r
+ @retval EFI_INVALID_LANGUAGE The language specified by PrimaryLanguage 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
HiiGetSecondaryLanguages (\r
IN CONST EFI_HII_STRING_PROTOCOL *This,\r
IN EFI_HII_HANDLE PackageList,\r
- IN CONST CHAR8 *FirstLanguage,\r
+ IN CONST CHAR8 *PrimaryLanguage,\r
IN OUT CHAR8 *SecondaryLanguages,\r
IN OUT UINTN *SecondaryLanguagesSize\r
)\r
CHAR8 *Languages;\r
UINTN ResultSize;\r
\r
- if (This == NULL || PackageList == NULL || FirstLanguage == NULL) {\r
+ if (This == NULL || PackageList == NULL || PrimaryLanguage == NULL) {\r
return EFI_INVALID_PARAMETER;\r
}\r
if (SecondaryLanguages == NULL || SecondaryLanguagesSize == NULL) {\r
Link1 = Link1->ForwardLink\r
) {\r
StringPackage = CR (Link1, HII_STRING_PACKAGE_INSTANCE, StringEntry, HII_STRING_PACKAGE_SIGNATURE);\r
- if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) FirstLanguage)) {\r
+ if (HiiCompareLanguage (StringPackage->StringPkgHdr->Language, (CHAR8 *) PrimaryLanguage)) {\r
Languages = StringPackage->StringPkgHdr->Language;\r
//\r
// Language is a series of ';' terminated strings, first one is primary\r
return EFI_INVALID_LANGUAGE;\r
}\r
\r
+/**\r
+ Converts the ascii character of the string from uppercase to lowercase.\r
+ This is a internal function.\r
+\r
+ @param ConfigString String to be converted\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+AsciiHiiToLower (\r
+ IN CHAR8 *ConfigString\r
+ )\r
+{\r
+ ASSERT (ConfigString != NULL);\r
+\r
+ //\r
+ // Convert all hex digits in range [A-F] in the configuration header to [a-f]\r
+ //\r
+ for (; *ConfigString != '\0'; ConfigString++) {\r
+ if ( *ConfigString >= 'A' && *ConfigString <= 'Z') {\r
+ *ConfigString = (CHAR8) (*ConfigString - 'A' + 'a');\r
+ }\r
+ }\r
+}\r
+\r
/**\r
Compare whether two names of languages are identical.\r
\r
- @param Language1 Name of language 1\r
- @param Language2 Name of language 2\r
+ @param Language1 Name of language 1 from StringPackage\r
+ @param Language2 Name of language 2 to be compared with language 1.\r
\r
@retval TRUE same\r
@retval FALSE not same\r
IN CHAR8 *Language2\r
)\r
{\r
- UINTN Language2Len;\r
+ UINTN Index;\r
+ UINTN StrLen;\r
+ CHAR8 *Lan1;\r
+ CHAR8 *Lan2;\r
+\r
+ //\r
+ // Convert to lower to compare.\r
+ //\r
+ StrLen = AsciiStrSize (Language1);\r
+ Lan1 = AllocateZeroPool (StrLen);\r
+ ASSERT (Lan1 != NULL);\r
+ AsciiStrCpy(Lan1, Language1);\r
+ AsciiHiiToLower (Lan1);\r
+\r
+ StrLen = AsciiStrSize (Language2);\r
+ Lan2 = AllocateZeroPool (StrLen);\r
+ ASSERT (Lan2 != NULL);\r
+ AsciiStrCpy(Lan2, Language2);\r
+ AsciiHiiToLower (Lan2);\r
+\r
+ //\r
+ // Compare the Primary Language in Language1 to Language2\r
+ //\r
+ for (Index = 0; Lan1[Index] != 0 && Lan1[Index] != ';'; Index++) {\r
+ if (Lan1[Index] != Lan2[Index]) {\r
+ //\r
+ // Return FALSE if any characters are different.\r
+ //\r
+ FreePool (Lan1);\r
+ FreePool (Lan2);\r
+ return FALSE;\r
+ }\r
+ }\r
\r
- Language2Len = AsciiStrLen (Language2);\r
- return (BOOLEAN) (AsciiStrnCmp (Language1, Language2, Language2Len) == 0);\r
+ FreePool (Lan1);\r
+ FreePool (Lan2);\r
+\r
+ //\r
+ // Only return TRUE if Language2[Index] is a Null-terminator which means\r
+ // the Primary Language in Language1 is the same length as Language2. If\r
+ // Language2[Index] is not a Null-terminator, then Language2 is longer than\r
+ // the Primary Language in Language1, and FALSE must be returned.\r
+ //\r
+ return (BOOLEAN) (Language2[Index] == 0);\r
}\r