2008-04-03 12:36:52 +02:00
|
|
|
/**@file
|
2008-08-18 07:56:23 +02:00
|
|
|
This file implements the protocol functions related to string package.
|
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
Copyright (c) 2006 - 2008, Intel Corporation
|
|
|
|
All rights reserved. This program and the accompanying materials
|
|
|
|
are licensed and made available under the terms and conditions of the BSD License
|
|
|
|
which accompanies this distribution. The full text of the license may be found at
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
|
|
|
|
#include "HiiDatabase.h"
|
|
|
|
|
2008-08-19 12:44:50 +02:00
|
|
|
typedef struct {
|
|
|
|
CHAR8 *Iso639;
|
2009-04-30 09:01:55 +02:00
|
|
|
CHAR8 *Rfc4646;
|
|
|
|
} ISO639TORFC4646MAP;
|
2008-08-19 12:44:50 +02:00
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
ISO639TORFC4646MAP Iso639ToRfc4646Map [] = {
|
2008-08-19 12:44:50 +02:00
|
|
|
{"eng", "en-US"},
|
|
|
|
{"fra", "fr-FR"},
|
|
|
|
};
|
|
|
|
|
2009-04-16 10:46:28 +02:00
|
|
|
//
|
|
|
|
// Lookup table of ISO639-2 3 character language codes to ISO 639-1 2 character language codes
|
|
|
|
// Each entry is 5 CHAR8 values long. The first 3 CHAR8 values are the ISO 639-2 code.
|
|
|
|
// The last 2 CHAR8 values are the ISO 639-1 code.
|
|
|
|
//
|
2009-04-30 09:01:55 +02:00
|
|
|
GLOBAL_REMOVE_IF_UNREFERENCED CONST CHAR8 Iso639ToRfc4646ConversionTable[] =
|
2009-04-16 10:46:28 +02:00
|
|
|
"\
|
|
|
|
aaraa\
|
|
|
|
abkab\
|
|
|
|
afraf\
|
|
|
|
amham\
|
|
|
|
araar\
|
|
|
|
asmas\
|
|
|
|
aymay\
|
|
|
|
azeaz\
|
|
|
|
bakba\
|
|
|
|
belbe\
|
|
|
|
benbn\
|
|
|
|
bihbh\
|
|
|
|
bisbi\
|
|
|
|
bodbo\
|
|
|
|
brebr\
|
|
|
|
bulbg\
|
|
|
|
catca\
|
|
|
|
cescs\
|
|
|
|
corkw\
|
|
|
|
cosco\
|
|
|
|
cymcy\
|
|
|
|
danda\
|
|
|
|
deude\
|
|
|
|
dzodz\
|
|
|
|
ellel\
|
|
|
|
engen\
|
|
|
|
epoeo\
|
|
|
|
estet\
|
|
|
|
euseu\
|
|
|
|
faofo\
|
|
|
|
fasfa\
|
|
|
|
fijfj\
|
|
|
|
finfi\
|
|
|
|
frafr\
|
|
|
|
fryfy\
|
|
|
|
gaiga\
|
|
|
|
gdhgd\
|
|
|
|
glggl\
|
|
|
|
grngn\
|
|
|
|
gujgu\
|
|
|
|
hauha\
|
|
|
|
hebhe\
|
|
|
|
hinhi\
|
|
|
|
hrvhr\
|
|
|
|
hunhu\
|
|
|
|
hyehy\
|
|
|
|
ikuiu\
|
|
|
|
ileie\
|
|
|
|
inaia\
|
|
|
|
indid\
|
|
|
|
ipkik\
|
|
|
|
islis\
|
|
|
|
itait\
|
|
|
|
jawjw\
|
|
|
|
jpnja\
|
|
|
|
kalkl\
|
|
|
|
kankn\
|
|
|
|
kasks\
|
|
|
|
katka\
|
|
|
|
kazkk\
|
|
|
|
khmkm\
|
|
|
|
kinrw\
|
|
|
|
kirky\
|
|
|
|
korko\
|
|
|
|
kurku\
|
|
|
|
laolo\
|
|
|
|
latla\
|
|
|
|
lavlv\
|
|
|
|
linln\
|
|
|
|
litlt\
|
|
|
|
ltzlb\
|
|
|
|
malml\
|
|
|
|
marmr\
|
|
|
|
mkdmk\
|
|
|
|
mlgmg\
|
|
|
|
mltmt\
|
|
|
|
molmo\
|
|
|
|
monmn\
|
|
|
|
mrimi\
|
|
|
|
msams\
|
|
|
|
myamy\
|
|
|
|
nauna\
|
|
|
|
nepne\
|
|
|
|
nldnl\
|
|
|
|
norno\
|
|
|
|
ocioc\
|
|
|
|
ormom\
|
|
|
|
panpa\
|
|
|
|
polpl\
|
|
|
|
porpt\
|
|
|
|
pusps\
|
|
|
|
quequ\
|
|
|
|
rohrm\
|
|
|
|
ronro\
|
|
|
|
runrn\
|
|
|
|
rusru\
|
|
|
|
sagsg\
|
|
|
|
sansa\
|
|
|
|
sinsi\
|
|
|
|
slksk\
|
|
|
|
slvsl\
|
|
|
|
smise\
|
|
|
|
smosm\
|
|
|
|
snasn\
|
|
|
|
sndsd\
|
|
|
|
somso\
|
|
|
|
sotst\
|
|
|
|
spaes\
|
|
|
|
sqisq\
|
|
|
|
srpsr\
|
|
|
|
sswss\
|
|
|
|
sunsu\
|
|
|
|
swasw\
|
|
|
|
swesv\
|
|
|
|
tamta\
|
|
|
|
tattt\
|
|
|
|
telte\
|
|
|
|
tgktg\
|
|
|
|
tgltl\
|
|
|
|
thath\
|
|
|
|
tsnts\
|
|
|
|
tuktk\
|
|
|
|
twitw\
|
|
|
|
uigug\
|
|
|
|
ukruk\
|
|
|
|
urdur\
|
|
|
|
uzbuz\
|
|
|
|
vievi\
|
|
|
|
volvo\
|
|
|
|
wolwo\
|
|
|
|
xhoxh\
|
|
|
|
yidyi\
|
|
|
|
zhaza\
|
|
|
|
zhozh\
|
|
|
|
zulzu\
|
|
|
|
";
|
|
|
|
|
2008-08-19 12:44:50 +02:00
|
|
|
CHAR8 *
|
2009-04-30 09:01:55 +02:00
|
|
|
ConvertIso639ToRfc4646 (
|
2008-08-19 12:44:50 +02:00
|
|
|
CHAR8 *Iso638Lang
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN Index;
|
2008-09-18 11:14:00 +02:00
|
|
|
CHAR8 AsciiLanguage[ISO_639_2_ENTRY_SIZE + 1];
|
|
|
|
|
|
|
|
AsciiStrnCpy (AsciiLanguage, Iso638Lang, sizeof (AsciiLanguage));
|
|
|
|
for (Index = 0; Index < ISO_639_2_ENTRY_SIZE + 1; Index ++) {
|
|
|
|
if (AsciiLanguage [Index] == 0) {
|
|
|
|
break;
|
|
|
|
} else if (AsciiLanguage [Index] >= 'A' && AsciiLanguage [Index] <= 'Z') {
|
2008-11-10 14:27:09 +01:00
|
|
|
AsciiLanguage [Index] = (CHAR8) (AsciiLanguage [Index] - 'A' + 'a');
|
2008-09-18 11:14:00 +02:00
|
|
|
}
|
|
|
|
}
|
2008-08-19 12:44:50 +02:00
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
for (Index = 0; Index < sizeof (Iso639ToRfc4646Map) / sizeof (Iso639ToRfc4646Map[0]); Index++) {
|
|
|
|
if (AsciiStrnCmp (AsciiLanguage, Iso639ToRfc4646Map[Index].Iso639, AsciiStrSize (AsciiLanguage)) == 0) {
|
|
|
|
return Iso639ToRfc4646Map[Index].Rfc4646;
|
2008-08-19 12:44:50 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return (CHAR8 *) NULL;
|
|
|
|
}
|
|
|
|
|
2009-04-16 10:46:28 +02:00
|
|
|
/**
|
2009-04-30 09:01:55 +02:00
|
|
|
Convert language code from RFC4646 to ISO639-2.
|
2009-04-16 10:46:28 +02:00
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
@param LanguageRfc4646 RFC4646 language code.
|
2009-04-16 10:46:28 +02:00
|
|
|
@param LanguageIso639 ISO639-2 language code.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS Language code converted.
|
|
|
|
@retval EFI_NOT_FOUND Language code not found.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
2009-04-30 09:01:55 +02:00
|
|
|
ConvertRfc4646LanguageToIso639Language (
|
|
|
|
IN CHAR8 *LanguageRfc4646,
|
2009-04-16 10:46:28 +02:00
|
|
|
OUT CHAR8 *LanguageIso639
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN Index;
|
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
if ((LanguageRfc4646[2] != '-') && (LanguageRfc4646[2] != 0)) {
|
|
|
|
CopyMem (LanguageIso639, LanguageRfc4646, 3);
|
2009-04-16 10:46:28 +02:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
for (Index = 0; Iso639ToRfc4646ConversionTable[Index] != 0; Index += 5) {
|
|
|
|
if (CompareMem (LanguageRfc4646, &Iso639ToRfc4646ConversionTable[Index + 3], 2) == 0) {
|
|
|
|
CopyMem (LanguageIso639, &Iso639ToRfc4646ConversionTable[Index], 3);
|
2009-04-16 10:46:28 +02:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
2009-04-30 09:01:55 +02:00
|
|
|
Convert language code from ISO639-2 to RFC4646 and return the converted language.
|
2009-04-16 10:46:28 +02:00
|
|
|
Caller is responsible for freeing the allocated buffer.
|
|
|
|
|
|
|
|
LanguageIso639 contain a single ISO639-2 code such as
|
|
|
|
"eng" or "fra".
|
|
|
|
|
|
|
|
If LanguageIso639 is NULL, then ASSERT.
|
2009-04-30 09:01:55 +02:00
|
|
|
If LanguageRfc4646 is NULL, then ASSERT.
|
2009-04-16 10:46:28 +02:00
|
|
|
|
|
|
|
@param LanguageIso639 ISO639-2 language code.
|
|
|
|
|
|
|
|
@return the allocated buffer or NULL, if the language is not found.
|
|
|
|
|
|
|
|
**/
|
|
|
|
CHAR8*
|
|
|
|
EFIAPI
|
2009-04-30 09:01:55 +02:00
|
|
|
ConvertIso639LanguageToRfc4646Language (
|
2009-04-16 10:46:28 +02:00
|
|
|
IN CONST CHAR8 *LanguageIso639
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN Index;
|
2009-04-30 09:01:55 +02:00
|
|
|
CHAR8 *Rfc4646Language;
|
2009-04-16 10:46:28 +02:00
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
for (Index = 0; Iso639ToRfc4646ConversionTable[Index] != 0; Index += 5) {
|
|
|
|
if (CompareMem (LanguageIso639, &Iso639ToRfc4646ConversionTable[Index], 3) == 0) {
|
|
|
|
Rfc4646Language = AllocateZeroPool (3);
|
|
|
|
if (Rfc4646Language != NULL) {
|
|
|
|
Rfc4646Language = CopyMem (Rfc4646Language, &Iso639ToRfc4646ConversionTable[Index + 3], 2);
|
2009-04-16 10:46:28 +02:00
|
|
|
}
|
2009-04-30 09:01:55 +02:00
|
|
|
return Rfc4646Language;
|
2009-04-16 10:46:28 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2009-04-17 04:38:11 +02:00
|
|
|
/**
|
|
|
|
Get next language from language code list (with separator ';').
|
|
|
|
|
|
|
|
If LangCode is NULL, then ASSERT.
|
|
|
|
If Lang is NULL, then ASSERT.
|
|
|
|
|
|
|
|
@param LangCode On input: point to first language in the list. On
|
|
|
|
output: point to next language in the list, or
|
|
|
|
NULL if no more language in the list.
|
|
|
|
@param Lang The first language in the list.
|
|
|
|
|
|
|
|
**/
|
|
|
|
VOID
|
|
|
|
EFIAPI
|
|
|
|
GetNextLanguage (
|
|
|
|
IN OUT CHAR8 **LangCode,
|
|
|
|
OUT CHAR8 *Lang
|
|
|
|
)
|
|
|
|
{
|
|
|
|
UINTN Index;
|
|
|
|
CHAR8 *StringPtr;
|
|
|
|
|
|
|
|
ASSERT (LangCode != NULL);
|
|
|
|
ASSERT (*LangCode != NULL);
|
|
|
|
ASSERT (Lang != NULL);
|
|
|
|
|
|
|
|
Index = 0;
|
|
|
|
StringPtr = *LangCode;
|
|
|
|
while (StringPtr[Index] != 0 && StringPtr[Index] != ';') {
|
|
|
|
Index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
CopyMem (Lang, StringPtr, Index);
|
|
|
|
Lang[Index] = 0;
|
|
|
|
|
|
|
|
if (StringPtr[Index] == ';') {
|
|
|
|
Index++;
|
|
|
|
}
|
|
|
|
*LangCode = StringPtr + Index;
|
|
|
|
}
|
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
/**
|
|
|
|
Test if all of the characters in a string have corresponding font characters.
|
|
|
|
|
|
|
|
This is a deprecated API. No Framework HII module is calling it. This function will ASSERT and
|
|
|
|
return EFI_UNSUPPORTED.
|
2008-08-19 12:44:50 +02:00
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
@param This A pointer to the EFI_HII_PROTOCOL instance.
|
|
|
|
@param StringToTest A pointer to a Unicode string.
|
|
|
|
@param FirstMissing A pointer to an index into the string. On input, the index of
|
|
|
|
the first character in the StringToTest to examine. On exit, the index
|
|
|
|
of the first character encountered for which a glyph is unavailable.
|
|
|
|
If all glyphs in the string are available, the index is the index of the terminator
|
|
|
|
of the string.
|
|
|
|
@param GlyphBufferSize A pointer to a value. On output, if the function returns EFI_SUCCESS,
|
2009-04-14 12:47:19 +02:00
|
|
|
it contains the amount of memory that is required to store the string? glyph equivalent.
|
2008-11-26 12:02:31 +01:00
|
|
|
|
|
|
|
@retval EFI_UNSUPPORTED The function performs nothing and return EFI_UNSUPPORTED.
|
|
|
|
**/
|
2008-04-03 12:36:52 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
HiiTestString (
|
|
|
|
IN EFI_HII_PROTOCOL *This,
|
|
|
|
IN CHAR16 *StringToTest,
|
|
|
|
IN OUT UINT32 *FirstMissing,
|
|
|
|
OUT UINT32 *GlyphBufferSize
|
|
|
|
)
|
|
|
|
{
|
|
|
|
ASSERT (FALSE);
|
2008-11-26 12:02:31 +01:00
|
|
|
|
|
|
|
return EFI_UNSUPPORTED;
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
|
2008-08-19 12:44:50 +02:00
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
/**
|
|
|
|
Find the corressponding TAG GUID from a Framework HII Handle given.
|
|
|
|
|
|
|
|
@param Private The HII Thunk Module Private context.
|
|
|
|
@param FwHiiHandle The Framemwork HII Handle.
|
|
|
|
@param TagGuid The output of TAG GUID found.
|
2008-08-19 12:44:50 +02:00
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
@return NULL If Framework HII Handle is invalid.
|
|
|
|
@return The corresponding HII Thunk Context.
|
|
|
|
**/
|
2008-04-03 12:36:52 +02:00
|
|
|
EFI_STATUS
|
2008-08-18 07:56:23 +02:00
|
|
|
GetTagGuidByFwHiiHandle (
|
|
|
|
IN CONST HII_THUNK_PRIVATE_DATA *Private,
|
|
|
|
IN FRAMEWORK_EFI_HII_HANDLE FwHiiHandle,
|
2008-04-03 12:36:52 +02:00
|
|
|
OUT EFI_GUID *TagGuid
|
|
|
|
)
|
|
|
|
{
|
2008-08-18 07:56:23 +02:00
|
|
|
LIST_ENTRY *Link;
|
|
|
|
HII_THUNK_CONTEXT *ThunkContext;
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
|
|
ASSERT (TagGuid != NULL);
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
Link = GetFirstNode (&Private->ThunkContextListHead);
|
|
|
|
while (!IsNull (&Private->ThunkContextListHead, Link)) {
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
if (FwHiiHandle == ThunkContext->FwHiiHandle) {
|
|
|
|
CopyGuid (TagGuid, &ThunkContext->TagGuid);
|
2008-04-03 12:36:52 +02:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
Link = GetNextNode (&Private->ThunkContextListHead, Link);
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
return EFI_NOT_FOUND;
|
|
|
|
}
|
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
/**
|
|
|
|
Create or update the String given a new string and String ID.
|
|
|
|
|
|
|
|
@param ThunkContext The Thunk Context.
|
2009-04-30 09:01:55 +02:00
|
|
|
@param Rfc4646AsciiLanguage The RFC 4646 Language code in ASCII string format.
|
2008-11-26 12:02:31 +01:00
|
|
|
@param NewString The new string.
|
|
|
|
@param StringId The String ID. If StringId is 0, a new String Token
|
|
|
|
is created. Otherwise, the String Token StringId is
|
|
|
|
updated.
|
|
|
|
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS The new string is created or updated successfully.
|
|
|
|
The new String Token ID is returned in StringId if
|
|
|
|
*StringId is 0 on input.
|
|
|
|
@return Others The update of string failed.
|
|
|
|
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
UpdateString (
|
|
|
|
IN CONST HII_THUNK_CONTEXT *ThunkContext,
|
2009-04-30 09:01:55 +02:00
|
|
|
IN CONST CHAR8 *Rfc4646AsciiLanguage,
|
2008-11-26 12:02:31 +01:00
|
|
|
IN CHAR16 *NewString,
|
|
|
|
IN OUT STRING_REF *StringId
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STRING_ID NewStringId;
|
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
NewStringId = HiiSetString (ThunkContext->UefiHiiHandle, *StringId, NewString, Rfc4646AsciiLanguage);
|
2009-04-14 12:47:19 +02:00
|
|
|
*StringId = NewStringId;
|
|
|
|
if (NewStringId == 0) {
|
2008-11-26 12:02:31 +01:00
|
|
|
//
|
|
|
|
// Only EFI_INVALID_PARAMETER is defined in HII 0.92 specification.
|
|
|
|
//
|
2009-04-14 12:47:19 +02:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
} else {
|
|
|
|
return EFI_SUCCESS;
|
2008-11-26 12:02:31 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
Create or update a String Token in a String Package.
|
|
|
|
|
|
|
|
If *Reference == 0, a new String Token is created.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_HII_PROTOCOL instance.
|
|
|
|
@param Language Pointer to a NULL-terminated string containing a single ISO 639-2 language
|
|
|
|
identifier, indicating the language to print. A string consisting of
|
|
|
|
all spaces indicates that the string is applicable to all languages.
|
|
|
|
@param Handle The handle of the language pack to which the string is to be added.
|
|
|
|
@param Token The string token assigned to the string.
|
|
|
|
@param NewString The string to be added.
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
@retval EFI_SUCCESS The string was effectively registered.
|
|
|
|
@retval EFI_INVALID_PARAMETER The Handle was unknown. The string is not created or updated in the
|
|
|
|
the string package.
|
|
|
|
**/
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
EFI_STATUS
|
2008-08-18 07:56:23 +02:00
|
|
|
EFIAPI
|
|
|
|
HiiNewString (
|
|
|
|
IN EFI_HII_PROTOCOL *This,
|
|
|
|
IN CHAR16 *Language,
|
|
|
|
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
|
|
IN OUT STRING_REF *Reference,
|
|
|
|
IN CHAR16 *NewString
|
2008-04-03 12:36:52 +02:00
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
2008-08-18 07:56:23 +02:00
|
|
|
HII_THUNK_PRIVATE_DATA *Private;
|
|
|
|
EFI_GUID TagGuid;
|
|
|
|
LIST_ENTRY *Link;
|
|
|
|
HII_THUNK_CONTEXT *ThunkContext;
|
2008-11-26 12:02:31 +01:00
|
|
|
HII_THUNK_CONTEXT *StringPackThunkContext;
|
2008-08-18 07:56:23 +02:00
|
|
|
EFI_STRING_ID StringId;
|
|
|
|
EFI_STRING_ID LastStringId;
|
2008-08-19 12:44:50 +02:00
|
|
|
CHAR8 AsciiLanguage[ISO_639_2_ENTRY_SIZE + 1];
|
2008-09-04 12:15:50 +02:00
|
|
|
CHAR16 LanguageCopy[ISO_639_2_ENTRY_SIZE + 1];
|
2009-04-30 09:01:55 +02:00
|
|
|
CHAR8 *Rfc4646AsciiLanguage;
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
LastStringId = (EFI_STRING_ID) 0;
|
|
|
|
StringId = (EFI_STRING_ID) 0;
|
2009-04-30 09:01:55 +02:00
|
|
|
Rfc4646AsciiLanguage = NULL;
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
if (Language != NULL) {
|
2008-08-19 12:44:50 +02:00
|
|
|
ZeroMem (AsciiLanguage, sizeof (AsciiLanguage));;
|
2008-09-04 12:15:50 +02:00
|
|
|
ZeroMem (LanguageCopy, sizeof (LanguageCopy));
|
|
|
|
CopyMem (LanguageCopy, Language, ISO_639_2_ENTRY_SIZE * sizeof (CHAR16));
|
|
|
|
UnicodeStrToAsciiStr (LanguageCopy, AsciiLanguage);
|
2009-04-30 09:01:55 +02:00
|
|
|
Rfc4646AsciiLanguage = ConvertIso639ToRfc4646 (AsciiLanguage);
|
|
|
|
ASSERT (Rfc4646AsciiLanguage != NULL);
|
2008-05-07 10:49:04 +02:00
|
|
|
}
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
StringPackThunkContext = FwHiiHandleToThunkContext (Private, Handle);
|
|
|
|
if (StringPackThunkContext == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (StringPackThunkContext->SharingStringPack) {
|
|
|
|
Status = GetTagGuidByFwHiiHandle (Private, Handle, &TagGuid);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
Link = GetFirstNode (&Private->ThunkContextListHead);
|
|
|
|
while (!IsNull (&Private->ThunkContextListHead, Link)) {
|
|
|
|
ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
if (CompareGuid (&TagGuid, &ThunkContext->TagGuid)) {
|
|
|
|
if (ThunkContext->SharingStringPack) {
|
|
|
|
StringId = *Reference;
|
2009-04-30 09:01:55 +02:00
|
|
|
Status = UpdateString (ThunkContext, Rfc4646AsciiLanguage, NewString, &StringId);
|
2008-11-26 12:02:31 +01:00
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
break;
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
2008-11-26 12:02:31 +01:00
|
|
|
|
|
|
|
DEBUG_CODE_BEGIN ();
|
|
|
|
if (*Reference == 0) {
|
|
|
|
//
|
|
|
|
// When creating new string token, make sure all created token is the same
|
|
|
|
// for all string packages registered using FW HII interface.
|
|
|
|
//
|
|
|
|
if (LastStringId == (EFI_STRING_ID) 0) {
|
|
|
|
LastStringId = StringId;
|
|
|
|
} else {
|
|
|
|
if (LastStringId != StringId) {
|
|
|
|
ASSERT(FALSE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
DEBUG_CODE_END ();
|
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
Link = GetNextNode (&Private->ThunkContextListHead, Link);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
StringId = *Reference;
|
2009-04-30 09:01:55 +02:00
|
|
|
Status = UpdateString (StringPackThunkContext, Rfc4646AsciiLanguage, NewString, &StringId);
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
if (!EFI_ERROR (Status)) {
|
2008-08-18 07:56:23 +02:00
|
|
|
if (*Reference == 0) {
|
|
|
|
*Reference = StringId;
|
|
|
|
}
|
2008-04-03 12:36:52 +02:00
|
|
|
} else {
|
2008-08-18 07:56:23 +02:00
|
|
|
//
|
2008-11-26 12:02:31 +01:00
|
|
|
// Only EFI_INVALID_PARAMETER is defined in HII 0.92 specification.
|
2008-08-18 07:56:23 +02:00
|
|
|
//
|
2008-11-26 12:02:31 +01:00
|
|
|
Status = EFI_INVALID_PARAMETER;
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
|
2008-04-29 09:06:10 +02:00
|
|
|
return Status;
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
/**
|
|
|
|
This function removes any new strings that were added after the initial string export for this handle.
|
|
|
|
UEFI HII String Protocol does not have Reset String function. This function perform nothing.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_HII_PROTOCOL instance.
|
|
|
|
@param Handle The HII handle on which the string resides.
|
|
|
|
|
|
|
|
@retval EFI_SUCCESS This function is a NOP and always return EFI_SUCCESS.
|
|
|
|
|
|
|
|
**/
|
2008-04-03 12:36:52 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
HiiResetStrings (
|
|
|
|
IN EFI_HII_PROTOCOL *This,
|
|
|
|
IN FRAMEWORK_EFI_HII_HANDLE Handle
|
|
|
|
)
|
|
|
|
{
|
2008-08-18 07:56:23 +02:00
|
|
|
return EFI_SUCCESS;
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
/**
|
|
|
|
This function extracts a string from a package already registered with the EFI HII database.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_HII_PROTOCOL instance.
|
|
|
|
@param Handle The HII handle on which the string resides.
|
|
|
|
@param Token The string token assigned to the string.
|
|
|
|
@param Raw If TRUE, the string is returned unedited in the internal storage format described
|
|
|
|
above. If false, the string returned is edited by replacing <cr> with <space>
|
|
|
|
and by removing special characters such as the <wide> prefix.
|
|
|
|
@param LanguageString Pointer to a NULL-terminated string containing a single ISO 639-2 language
|
|
|
|
identifier, indicating the language to print. If the LanguageString is empty (starts
|
|
|
|
with a NULL), the default system language will be used to determine the language.
|
|
|
|
@param BufferLength Length of the StringBuffer. If the status reports that the buffer width is too
|
|
|
|
small, this parameter is filled with the length of the buffer needed.
|
|
|
|
@param StringBuffer The buffer designed to receive the characters in the string. Type EFI_STRING is
|
|
|
|
defined in String.
|
|
|
|
|
|
|
|
@retval EFI_INVALID_PARAMETER If input parameter is invalid.
|
|
|
|
@retval EFI_BUFFER_TOO_SMALL If the *BufferLength is too small.
|
|
|
|
@retval EFI_SUCCESS Operation is successful.
|
|
|
|
|
|
|
|
**/
|
2008-04-03 12:36:52 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
2009-04-14 03:57:26 +02:00
|
|
|
HiiThunkGetString (
|
2008-08-19 12:44:50 +02:00
|
|
|
IN EFI_HII_PROTOCOL *This,
|
|
|
|
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
|
|
IN STRING_REF Token,
|
|
|
|
IN BOOLEAN Raw,
|
|
|
|
IN CHAR16 *LanguageString,
|
|
|
|
IN OUT UINTN *BufferLengthTemp,
|
|
|
|
OUT EFI_STRING StringBuffer
|
2008-04-03 12:36:52 +02:00
|
|
|
)
|
|
|
|
{
|
2008-08-18 07:56:23 +02:00
|
|
|
HII_THUNK_PRIVATE_DATA *Private;
|
2009-04-14 12:47:19 +02:00
|
|
|
CHAR8 *Iso639AsciiLanguage;
|
2009-04-30 09:01:55 +02:00
|
|
|
CHAR8 *Rfc4646AsciiLanguage;
|
2009-04-14 12:47:19 +02:00
|
|
|
CHAR8 *SupportedLanguages;
|
|
|
|
CHAR8 *PlatformLanguage;
|
|
|
|
CHAR8 *BestLanguage;
|
2008-08-19 12:44:50 +02:00
|
|
|
EFI_HII_HANDLE UefiHiiHandle;
|
|
|
|
EFI_STATUS Status;
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-19 12:44:50 +02:00
|
|
|
Iso639AsciiLanguage = NULL;
|
2009-04-30 09:01:55 +02:00
|
|
|
Rfc4646AsciiLanguage = NULL;
|
2008-08-19 12:44:50 +02:00
|
|
|
|
|
|
|
if (LanguageString != NULL) {
|
|
|
|
Iso639AsciiLanguage = AllocateZeroPool (StrLen (LanguageString) + 1);
|
|
|
|
if (Iso639AsciiLanguage == NULL) {
|
2008-04-03 12:36:52 +02:00
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
2008-08-19 12:44:50 +02:00
|
|
|
UnicodeStrToAsciiStr (LanguageString, Iso639AsciiLanguage);
|
2008-05-07 10:49:04 +02:00
|
|
|
|
2008-08-19 12:44:50 +02:00
|
|
|
//
|
|
|
|
// Caller of Framework HII Interface uses the Language Identification String defined
|
2009-04-30 09:01:55 +02:00
|
|
|
// in Iso639. So map it to the Language Identifier defined in RFC4646.
|
2008-08-19 12:44:50 +02:00
|
|
|
//
|
2009-04-30 09:01:55 +02:00
|
|
|
Rfc4646AsciiLanguage = ConvertIso639ToRfc4646 (Iso639AsciiLanguage);
|
2008-05-23 07:31:39 +02:00
|
|
|
|
|
|
|
//
|
2009-04-30 09:01:55 +02:00
|
|
|
// If Rfc4646AsciiLanguage is NULL, more language mapping must be added to
|
|
|
|
// Iso639ToRfc4646Map.
|
2008-05-23 07:31:39 +02:00
|
|
|
//
|
2009-04-30 09:01:55 +02:00
|
|
|
ASSERT (Rfc4646AsciiLanguage != NULL);
|
2008-05-07 10:49:04 +02:00
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
|
2008-08-19 12:44:50 +02:00
|
|
|
UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);
|
|
|
|
if (UefiHiiHandle == NULL) {
|
|
|
|
Status = EFI_NOT_FOUND;
|
|
|
|
goto Done;
|
|
|
|
}
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
if (Rfc4646AsciiLanguage == NULL) {
|
2009-04-14 12:47:19 +02:00
|
|
|
//
|
|
|
|
// Get the languages that the package specified by HiiHandle supports
|
|
|
|
//
|
|
|
|
SupportedLanguages = HiiGetSupportedLanguages (UefiHiiHandle);
|
|
|
|
if (SupportedLanguages == NULL) {
|
|
|
|
goto Error2;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get the current platform language setting
|
|
|
|
//
|
|
|
|
PlatformLanguage = GetEfiGlobalVariable (L"PlatformLang");
|
|
|
|
if (PlatformLanguage == NULL) {
|
|
|
|
goto Error1;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// Get the best matching language from SupportedLanguages
|
|
|
|
//
|
|
|
|
BestLanguage = GetBestLanguage (
|
|
|
|
SupportedLanguages,
|
|
|
|
FALSE, // RFC 4646 mode
|
|
|
|
PlatformLanguage, // Next highest priority
|
|
|
|
SupportedLanguages, // Lowest priority
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
if (BestLanguage == NULL) {
|
|
|
|
FreePool (PlatformLanguage);
|
|
|
|
Error1:
|
|
|
|
FreePool (SupportedLanguages);
|
|
|
|
Error2:
|
|
|
|
Status = EFI_INVALID_PARAMETER;
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = mHiiStringProtocol->GetString (
|
|
|
|
mHiiStringProtocol,
|
|
|
|
BestLanguage,
|
|
|
|
UefiHiiHandle,
|
|
|
|
Token,
|
|
|
|
StringBuffer,
|
|
|
|
BufferLengthTemp,
|
|
|
|
NULL
|
|
|
|
);
|
|
|
|
FreePool (BestLanguage);
|
2008-08-19 12:44:50 +02:00
|
|
|
} else {
|
|
|
|
Status = mHiiStringProtocol->GetString (
|
|
|
|
mHiiStringProtocol,
|
2009-04-30 09:01:55 +02:00
|
|
|
Rfc4646AsciiLanguage,
|
2008-08-19 12:44:50 +02:00
|
|
|
UefiHiiHandle,
|
|
|
|
Token,
|
|
|
|
StringBuffer,
|
|
|
|
BufferLengthTemp,
|
|
|
|
NULL
|
|
|
|
);
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
|
2008-08-19 12:44:50 +02:00
|
|
|
Done:
|
2008-10-30 09:00:56 +01:00
|
|
|
if (Iso639AsciiLanguage != NULL) {
|
|
|
|
FreePool (Iso639AsciiLanguage);
|
|
|
|
}
|
2008-08-19 12:44:50 +02:00
|
|
|
|
|
|
|
return Status;
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
/**
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
|
|
This function allows a program to extract a part of a string of not more than a given width.
|
|
|
|
With repeated calls, this allows a calling program to extract "lines" of text that fit inside
|
|
|
|
columns. The effort of measuring the fit of strings inside columns is localized to this call.
|
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
This is a deprecated API. No Framework HII module is calling it. This function will ASSERT and
|
|
|
|
return EFI_UNSUPPORTED.
|
|
|
|
|
|
|
|
@param This A pointer to the EFI_HII_PROTOCOL instance.
|
|
|
|
@param Handle The HII handle on which the string resides.
|
|
|
|
@param Token The string token assigned to the string.
|
|
|
|
@param Raw If TRUE, the string is returned unedited in the internal storage format described
|
|
|
|
above. If false, the string returned is edited by replacing <cr> with <space>
|
|
|
|
and by removing special characters such as the <wide> prefix.
|
|
|
|
@param LanguageString Pointer to a NULL-terminated string containing a single ISO 639-2 language
|
|
|
|
identifier, indicating the language to print. If the LanguageString is empty (starts
|
|
|
|
with a NULL), the default system language will be used to determine the language.
|
|
|
|
@param BufferLength Length of the StringBuffer. If the status reports that the buffer width is too
|
|
|
|
small, this parameter is filled with the length of the buffer needed.
|
|
|
|
@param StringBuffer The buffer designed to receive the characters in the string. Type EFI_STRING is
|
|
|
|
defined in String.
|
|
|
|
|
|
|
|
@retval EFI_UNSUPPORTED.
|
|
|
|
**/
|
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
HiiGetLine (
|
|
|
|
IN EFI_HII_PROTOCOL *This,
|
|
|
|
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
|
|
IN STRING_REF Token,
|
|
|
|
IN OUT UINT16 *Index,
|
|
|
|
IN UINT16 LineWidth,
|
|
|
|
IN CHAR16 *LanguageString,
|
|
|
|
IN OUT UINT16 *BufferLength,
|
|
|
|
OUT EFI_STRING StringBuffer
|
|
|
|
)
|
2008-04-03 12:36:52 +02:00
|
|
|
{
|
|
|
|
ASSERT (FALSE);
|
|
|
|
return EFI_UNSUPPORTED;
|
|
|
|
}
|
|
|
|
|
2008-05-23 07:31:39 +02:00
|
|
|
|