1) Add in code to sync Browser Data with the NvMapOverride that may be updated by Framework Callback.

2) Convert lang code to RFC3066 format in Framework HII's GetSring and NewString 
3) Make sure the default ThunkExtractConfig is able to save the data even if it is not present initially.
4) Enable Framework HII's HiiGetGlyph and HiiGlyphToBlt.

git-svn-id: https://edk2.svn.sourceforge.net/svnroot/edk2/trunk/edk2@5689 6f19259b-4bc3-4df7-8a09-765794883524
This commit is contained in:
qwang12 2008-08-19 10:44:50 +00:00
parent d37be74e1a
commit 133a9dfb54
7 changed files with 292 additions and 151 deletions

View File

@ -433,7 +433,7 @@ ThunkExtractConfig (
EFI_STATUS Status; EFI_STATUS Status;
CONFIG_ACCESS_PRIVATE *ConfigAccess; CONFIG_ACCESS_PRIVATE *ConfigAccess;
LIST_ENTRY *Link; LIST_ENTRY *Link;
BUFFER_STORAGE_ENTRY *BufferStorage; BUFFER_STORAGE_ENTRY *BufferStorage;
VOID *Data; VOID *Data;
UINTN DataSize; UINTN DataSize;
@ -451,20 +451,31 @@ ThunkExtractConfig (
BufferStorage = BUFFER_STORAGE_ENTRY_FROM_LINK (Link); BufferStorage = BUFFER_STORAGE_ENTRY_FROM_LINK (Link);
if (ConfigAccess->FormCallbackProtocol == NULL || if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
ConfigAccess->FormCallbackProtocol->NvRead == NULL) { if (ConfigAccess->FormCallbackProtocol == NULL ||
Status = GetUefiVariable ( ConfigAccess->FormCallbackProtocol->NvRead == NULL) {
BufferStorage, Status = GetUefiVariable (
&Data, BufferStorage,
&DataSize &Data,
); &DataSize
);
} else {
Status = CallFormCallBack (
BufferStorage,
ConfigAccess->FormCallbackProtocol,
&Data,
&DataSize
);
}
} else { } else {
Status = CallFormCallBack ( DataSize = BufferStorage->Size;
BufferStorage, Data = AllocateCopyPool (DataSize, ConfigAccess->ThunkContext->NvMapOverride);
ConfigAccess->FormCallbackProtocol,
&Data, if (Data != NULL) {
&DataSize Status = EFI_SUCCESS;
); } else {
Status = EFI_OUT_OF_RESOURCES;
}
} }
if (!EFI_ERROR (Status)) { if (!EFI_ERROR (Status)) {
@ -518,7 +529,6 @@ ThunkRouteConfig (
BOOLEAN DataAllocated; BOOLEAN DataAllocated;
Data = NULL; Data = NULL;
DataAllocated = TRUE;
ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This); ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This);
// //
@ -533,6 +543,7 @@ ThunkRouteConfig (
BufferStorage = BUFFER_STORAGE_ENTRY_FROM_LINK (Link); BufferStorage = BUFFER_STORAGE_ENTRY_FROM_LINK (Link);
DataSize2 = BufferStorage->Size; DataSize2 = BufferStorage->Size;
if (ConfigAccess->ThunkContext->NvMapOverride == NULL) { if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
DataAllocated = TRUE;
if (ConfigAccess->FormCallbackProtocol == NULL || if (ConfigAccess->FormCallbackProtocol == NULL ||
ConfigAccess->FormCallbackProtocol->NvRead == NULL) { ConfigAccess->FormCallbackProtocol->NvRead == NULL) {
Status = GetUefiVariable ( Status = GetUefiVariable (
@ -540,8 +551,6 @@ ThunkRouteConfig (
&Data, &Data,
&DataSize &DataSize
); );
ASSERT (DataSize == DataSize2);
} else { } else {
Status = CallFormCallBack ( Status = CallFormCallBack (
BufferStorage, BufferStorage,
@ -549,17 +558,20 @@ ThunkRouteConfig (
&Data, &Data,
&DataSize &DataSize
); );
ASSERT (DataSize == DataSize2);
} }
} else { } else {
//
// ConfigToBlock will convert the Config String and update the NvMapOverride accordingly.
//
Status = EFI_SUCCESS; Status = EFI_SUCCESS;
Data = ConfigAccess->ThunkContext->NvMapOverride; Data = ConfigAccess->ThunkContext->NvMapOverride;
DataSize = DataSize2; DataSize = DataSize2;
DataAllocated = FALSE; DataAllocated = FALSE;
} }
if (EFI_ERROR (Status)) { if (EFI_ERROR (Status) || (DataSize2 != DataSize)) {
goto Done; if (Data == NULL) {
Data = AllocateZeroPool (DataSize2);
}
} }
Status = mHiiConfigRoutingProtocol->ConfigToBlock ( Status = mHiiConfigRoutingProtocol->ConfigToBlock (
@ -573,26 +585,28 @@ ThunkRouteConfig (
goto Done; goto Done;
} }
if (ConfigAccess->FormCallbackProtocol == NULL || if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
ConfigAccess->FormCallbackProtocol->NvWrite == NULL) { if (ConfigAccess->FormCallbackProtocol == NULL ||
Status = gRT->SetVariable ( ConfigAccess->FormCallbackProtocol->NvWrite == NULL) {
BufferStorage->Name, Status = gRT->SetVariable (
&BufferStorage->Guid, BufferStorage->Name,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, &BufferStorage->Guid,
DataSize, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
Data DataSize2,
); Data
} else { );
Status = ConfigAccess->FormCallbackProtocol->NvWrite ( } else {
ConfigAccess->FormCallbackProtocol, Status = ConfigAccess->FormCallbackProtocol->NvWrite (
BufferStorage->Name, ConfigAccess->FormCallbackProtocol,
&BufferStorage->Guid, BufferStorage->Name,
EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS, &BufferStorage->Guid,
DataSize, EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
Data, DataSize2,
&ResetRequired Data,
); &ResetRequired
);
}
} }
Done: Done:
@ -617,25 +631,27 @@ CreateIfrDataArray (
UINTN BrowserDataSize; UINTN BrowserDataSize;
BUFFER_STORAGE_ENTRY *BufferStorageEntry; BUFFER_STORAGE_ENTRY *BufferStorageEntry;
LIST_ENTRY *Link; LIST_ENTRY *Link;
EFI_STATUS Status;
IfrDataArray = AllocateZeroPool (0x100); IfrDataArray = AllocateZeroPool (0x100);
ASSERT (IfrDataArray != NULL); ASSERT (IfrDataArray != NULL);
Link = GetFirstNode (&ConfigAccess->BufferStorageListHead);
ASSERT (!IsNull (&ConfigAccess->BufferStorageListHead, Link));
BufferStorageEntry = BUFFER_STORAGE_ENTRY_FROM_LINK(Link);
BrowserDataSize = BufferStorageEntry->Size;
if (ConfigAccess->ThunkContext->NvMapOverride == NULL) { if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
Link = GetFirstNode (&ConfigAccess->BufferStorageListHead);
ASSERT (!IsNull (&ConfigAccess->BufferStorageListHead, Link));
BufferStorageEntry = BUFFER_STORAGE_ENTRY_FROM_LINK(Link);
BrowserDataSize = BufferStorageEntry->Size;
*NvMapAllocated = TRUE; *NvMapAllocated = TRUE;
IfrDataArray->NvRamMap = AllocateZeroPool (BrowserDataSize); IfrDataArray->NvRamMap = AllocateZeroPool (BrowserDataSize);
GetBrowserData (NULL, NULL, &BrowserDataSize, IfrDataArray->NvRamMap);
} else { } else {
*NvMapAllocated = FALSE; *NvMapAllocated = FALSE;
IfrDataArray->NvRamMap = ConfigAccess->ThunkContext->NvMapOverride; IfrDataArray->NvRamMap = ConfigAccess->ThunkContext->NvMapOverride;
} }
Status = GetBrowserData (NULL, NULL, &BrowserDataSize, IfrDataArray->NvRamMap);
ASSERT_EFI_ERROR (Status);
IfrDataEntry = (FRAMEWORK_EFI_IFR_DATA_ENTRY *) (IfrDataArray + 1); IfrDataEntry = (FRAMEWORK_EFI_IFR_DATA_ENTRY *) (IfrDataArray + 1);
@ -656,6 +672,30 @@ CreateIfrDataArray (
return IfrDataArray; return IfrDataArray;
} }
VOID
SyncBrowserDataForNvMapOverride (
IN CONFIG_ACCESS_PRIVATE *ConfigAccess
)
{
BUFFER_STORAGE_ENTRY *BufferStorageEntry;
LIST_ENTRY *Link;
EFI_STATUS Status;
UINTN BrowserDataSize;
if (ConfigAccess->ThunkContext->NvMapOverride != NULL) {
Link = GetFirstNode (&ConfigAccess->BufferStorageListHead);
ASSERT (!IsNull (&ConfigAccess->BufferStorageListHead, Link));
BufferStorageEntry = BUFFER_STORAGE_ENTRY_FROM_LINK(Link);
BrowserDataSize = BufferStorageEntry->Size;
Status = SetBrowserData (NULL, NULL, BrowserDataSize, ConfigAccess->ThunkContext->NvMapOverride, NULL);
ASSERT_EFI_ERROR (Status);
}
}
VOID VOID
DestroyIfrDataArray ( DestroyIfrDataArray (
IN FRAMEWORK_EFI_IFR_DATA_ARRAY *Array, IN FRAMEWORK_EFI_IFR_DATA_ARRAY *Array,
@ -850,6 +890,7 @@ ThunkCallback (
Data, Data,
&Packet &Packet
); );
SyncBrowserDataForNvMapOverride (ConfigAccess);
// //
// Callback require browser to perform action // Callback require browser to perform action

View File

@ -16,8 +16,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "HiiDatabase.h" #include "HiiDatabase.h"
EFI_NARROW_GLYPH mNarrowGlyphBuffer = {0, 0, {0}};
BOOLEAN mSysFontColorCached = FALSE;
EFI_GRAPHICS_OUTPUT_BLT_PIXEL mSysFGColor = {0};
UINT8 mGlyphBuffer[EFI_GLYPH_WIDTH * 2 * EFI_GLYPH_HEIGHT];
/** /**
This function is only called by Graphics Console module and GraphicsLib. This function is only called by Graphics Console module and GraphicsLib.
@ -47,8 +50,76 @@ HiiGetGlyph (
IN OUT UINT32 *InternalStatus IN OUT UINT32 *InternalStatus
) )
{ {
ASSERT (FALSE); EFI_STATUS Status;
return EFI_UNSUPPORTED; EFI_IMAGE_OUTPUT *Blt;
EFI_FONT_DISPLAY_INFO *FontInfo;
UINTN Xpos;
UINTN Ypos;
UINTN BaseLine;
if (!mSysFontColorCached) {
//
// Cache the system font's foreground color.
//
Status = mHiiFontProtocol->GetFontInfo (
mHiiFontProtocol,
NULL,
NULL,
&FontInfo,
NULL
);
if (!EFI_ERROR (Status)) {
ASSERT (StrCmp (FontInfo->FontInfo.FontName, L"sysdefault") == 0);
mSysFGColor = FontInfo->ForegroundColor;
FreePool (FontInfo);
mSysFontColorCached = TRUE;
}
}
Blt = NULL;
Status = mHiiFontProtocol->GetGlyph (
mHiiFontProtocol,
Source[*Index],
NULL,
&Blt,
&BaseLine
);
if (!EFI_ERROR (Status)) {
//
// For simplicity, we only handle Narrow Glyph.
//
ASSERT (Blt->Height == EFI_GLYPH_HEIGHT);
ASSERT (Blt->Width == EFI_GLYPH_WIDTH);
if (Blt->Height == EFI_GLYPH_HEIGHT && Blt->Width == EFI_GLYPH_WIDTH) {
ZeroMem (&mNarrowGlyphBuffer, sizeof (mNarrowGlyphBuffer));
mNarrowGlyphBuffer.UnicodeWeight = *Source;
for (Ypos = 0; Ypos < EFI_GLYPH_HEIGHT; Ypos++) {
for (Xpos = 0; Xpos < EFI_GLYPH_WIDTH; Xpos++) {
if (CompareMem (&Blt->Image.Bitmap[Ypos * EFI_GLYPH_WIDTH + Xpos], &mSysFGColor, sizeof (EFI_GRAPHICS_OUTPUT_BLT_PIXEL)) == 0) {
mNarrowGlyphBuffer.GlyphCol1[Ypos] |= 1 << (EFI_GLYPH_WIDTH - 1 - Xpos);
}
}
}
*GlyphBuffer = (UINT8 *) &mNarrowGlyphBuffer;
*BitWidth = EFI_GLYPH_WIDTH;
*Index += 1;
} else {
Status = EFI_NOT_FOUND;
}
}
if (EFI_ERROR (Status)) {
*GlyphBuffer = NULL;
}
return Status;
} }
/** /**
@ -83,6 +154,21 @@ HiiGlyphToBlt (
IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer IN OUT EFI_GRAPHICS_OUTPUT_BLT_PIXEL *BltBuffer
) )
{ {
ASSERT (FALSE); UINTN X;
return EFI_UNSUPPORTED; UINTN Y;
//
// Convert Monochrome bitmap of the Glyph to BltBuffer structure
//
for (Y = 0; Y < Height; Y++) {
for (X = 0; X < Width; X++) {
if ((((EFI_NARROW_GLYPH *) GlyphBuffer)->GlyphCol1[Y] & (1 << X)) != 0) {
BltBuffer[Y * Width * Count + (Width - X - 1)] = Foreground;
} else {
BltBuffer[Y * Width * Count + (Width - X - 1)] = Background;
}
}
}
return EFI_SUCCESS;
} }

View File

@ -97,6 +97,7 @@
[Depex] [Depex]
gEfiHiiDatabaseProtocolGuid AND gEfiHiiDatabaseProtocolGuid AND
gEfiHiiStringProtocolGuid AND gEfiHiiStringProtocolGuid AND
gEfiHiiConfigRoutingProtocolGuid gEfiHiiConfigRoutingProtocolGuid AND
gEfiHiiFontProtocolGuid

View File

@ -76,6 +76,7 @@ EFI_FORMBROWSER_THUNK_PRIVATE_DATA mBrowserThunkPrivateDataTemplate = {
CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabase; CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol; CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol;
CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol; CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol;
CONST EFI_HII_FONT_PROTOCOL *mHiiFontProtocol;
CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol; CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol;
CONST EFI_FORM_BROWSER2_PROTOCOL *mFormBrowser2Protocol; CONST EFI_FORM_BROWSER2_PROTOCOL *mFormBrowser2Protocol;
@ -134,6 +135,13 @@ Returns:
); );
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
Status = gBS->LocateProtocol (
&gEfiHiiFontProtocolGuid,
NULL,
(VOID **) &mHiiFontProtocol
);
ASSERT_EFI_ERROR (Status);
Status = gBS->LocateProtocol ( Status = gBS->LocateProtocol (
&gEfiHiiConfigRoutingProtocolGuid, &gEfiHiiConfigRoutingProtocolGuid,
NULL, NULL,

View File

@ -211,6 +211,7 @@ typedef struct {
extern CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabase; extern CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
extern CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol; extern CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol;
extern CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol; extern CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol;
extern CONST EFI_HII_FONT_PROTOCOL *mHiiFontProtocol;
extern CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol; extern CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol;
extern CONST EFI_FORM_BROWSER2_PROTOCOL *mFormBrowser2Protocol; extern CONST EFI_FORM_BROWSER2_PROTOCOL *mFormBrowser2Protocol;

View File

@ -351,7 +351,9 @@ F2UCreateOneOfOpCode (
UOpcode.Question.Header.Prompt = FwOpcode->Prompt; UOpcode.Question.Header.Prompt = FwOpcode->Prompt;
UOpcode.Question.Header.Help = FwOpcode->Help; UOpcode.Question.Header.Help = FwOpcode->Help;
UOpcode.Question.VarStoreId = VarStoreId;
UOpcode.Question.VarStoreInfo.VarOffset = FwOpcode->QuestionId;
// //
// Go over the Framework IFR binary to get the QuestionId for generated UEFI One Of Option opcode // Go over the Framework IFR binary to get the QuestionId for generated UEFI One Of Option opcode
// //
@ -386,18 +388,18 @@ F2UCreateOneOfOpCode (
} }
InsertTailList (&ThunkContext->OneOfOptionMapListHead, &OneOfOptionMap->Link); InsertTailList (&ThunkContext->OneOfOptionMapListHead, &OneOfOptionMap->Link);
} else {
OneOfOptionMapEntry = AllocateZeroPool (sizeof (ONE_OF_OPTION_MAP_ENTRY));
ASSERT (OneOfOptionMapEntry != NULL);
OneOfOptionMapEntry->FwKey = FwOneOfOp->Key;
OneOfOptionMapEntry->Signature = ONE_OF_OPTION_MAP_ENTRY_SIGNATURE;
CopyMem (&OneOfOptionMapEntry->Value, &FwOneOfOp->Value, FwOpcode->Width);
ASSERT (OneOfOptionMap != NULL);
InsertTailList (&OneOfOptionMap->OneOfOptionMapEntryListHead, &OneOfOptionMapEntry->Link);
} }
OneOfOptionMapEntry = AllocateZeroPool (sizeof (ONE_OF_OPTION_MAP_ENTRY));
ASSERT (OneOfOptionMapEntry != NULL);
OneOfOptionMapEntry->FwKey = FwOneOfOp->Key;
OneOfOptionMapEntry->Signature = ONE_OF_OPTION_MAP_ENTRY_SIGNATURE;
CopyMem (&OneOfOptionMapEntry->Value, &FwOneOfOp->Value, FwOpcode->Width);
ASSERT (OneOfOptionMap != NULL);
InsertTailList (&OneOfOptionMap->OneOfOptionMapEntryListHead, &OneOfOptionMapEntry->Link);
} }
if (FwOneOfOp->Flags & FRAMEWORK_EFI_IFR_FLAG_RESET_REQUIRED) { if (FwOneOfOp->Flags & FRAMEWORK_EFI_IFR_FLAG_RESET_REQUIRED) {
@ -499,6 +501,7 @@ F2UCreateOrderedListOpCode (
UOpcode.Question.Header.Prompt = FwOpcode->Prompt; UOpcode.Question.Header.Prompt = FwOpcode->Prompt;
UOpcode.Question.Header.Help = FwOpcode->Help; UOpcode.Question.Header.Help = FwOpcode->Help;
UOpcode.Question.VarStoreId = VarStoreId; UOpcode.Question.VarStoreId = VarStoreId;
UOpcode.Question.VarStoreInfo.VarOffset = FwOpcode->QuestionId;
UOpcode.MaxContainers = FwOpcode->MaxEntries; UOpcode.MaxContainers = FwOpcode->MaxEntries;

View File

@ -15,6 +15,33 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#include "HiiDatabase.h" #include "HiiDatabase.h"
typedef struct {
CHAR8 *Iso639;
CHAR8 *Rfc3066;
} ISO639TORFC3066MAP;
ISO639TORFC3066MAP Iso639ToRfc3066Map [] = {
{"eng", "en-US"},
{"fra", "fr-FR"},
};
CHAR8 *
ConvertIso639ToRfc3066 (
CHAR8 *Iso638Lang
)
{
UINTN Index;
for (Index = 0; Index < sizeof (Iso639ToRfc3066Map) / sizeof (Iso639ToRfc3066Map[0]); Index++) {
if (AsciiStrnCmp (Iso638Lang, Iso639ToRfc3066Map[Index].Iso639, AsciiStrSize (Iso638Lang)) == 0) {
return Iso639ToRfc3066Map[Index].Rfc3066;
}
}
return (CHAR8 *) NULL;
}
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
HiiTestString ( HiiTestString (
@ -38,6 +65,8 @@ Returns:
return EFI_SUCCESS; return EFI_SUCCESS;
} }
EFI_STATUS EFI_STATUS
GetTagGuidByFwHiiHandle ( GetTagGuidByFwHiiHandle (
IN CONST HII_THUNK_PRIVATE_DATA *Private, IN CONST HII_THUNK_PRIVATE_DATA *Private,
@ -99,8 +128,9 @@ Returns:
HII_THUNK_CONTEXT *ThunkContext; HII_THUNK_CONTEXT *ThunkContext;
EFI_STRING_ID StringId; EFI_STRING_ID StringId;
EFI_STRING_ID LastStringId; EFI_STRING_ID LastStringId;
CHAR8 *AsciiLanguage; CHAR8 AsciiLanguage[ISO_639_2_ENTRY_SIZE + 1];
BOOLEAN Found; BOOLEAN Found;
CHAR8 *Rfc3066AsciiLanguage;
// //
// BugBug: Conver the language to 3066. // BugBug: Conver the language to 3066.
@ -109,7 +139,7 @@ Returns:
LastStringId = (EFI_STRING_ID) 0; LastStringId = (EFI_STRING_ID) 0;
StringId = (EFI_STRING_ID) 0; StringId = (EFI_STRING_ID) 0;
Found = FALSE; Found = FALSE;
AsciiLanguage = NULL; Rfc3066AsciiLanguage = NULL;
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This); Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
@ -117,8 +147,11 @@ Returns:
ASSERT_EFI_ERROR (Status); ASSERT_EFI_ERROR (Status);
if (Language != NULL) { if (Language != NULL) {
AsciiLanguage = AllocateZeroPool (StrLen (Language) + 1); ZeroMem (AsciiLanguage, sizeof (AsciiLanguage));;
UnicodeStrToAsciiStr (Language, AsciiLanguage); UnicodeStrToAsciiStr (Language, AsciiLanguage);
Rfc3066AsciiLanguage = ConvertIso639ToRfc3066 (AsciiLanguage);
ASSERT (Rfc3066AsciiLanguage != NULL);
} }
Link = GetFirstNode (&Private->ThunkContextListHead); Link = GetFirstNode (&Private->ThunkContextListHead);
@ -131,7 +164,7 @@ Returns:
// //
// Create a new string token. // Create a new string token.
// //
if (AsciiLanguage == NULL) { if (Rfc3066AsciiLanguage == NULL) {
// //
// For all languages in the package list. // For all languages in the package list.
// //
@ -144,7 +177,7 @@ Returns:
mHiiStringProtocol, mHiiStringProtocol,
ThunkContext->UefiHiiHandle, ThunkContext->UefiHiiHandle,
&StringId, &StringId,
AsciiLanguage, Rfc3066AsciiLanguage,
NULL, NULL,
NewString, NewString,
NULL NULL
@ -154,7 +187,7 @@ Returns:
// //
// Update the existing string token. // Update the existing string token.
// //
if (AsciiLanguage == NULL) { if (Rfc3066AsciiLanguage == NULL) {
// //
// For all languages in the package list. // For all languages in the package list.
// //
@ -167,7 +200,7 @@ Returns:
mHiiStringProtocol, mHiiStringProtocol,
ThunkContext->UefiHiiHandle, ThunkContext->UefiHiiHandle,
*Reference, *Reference,
AsciiLanguage, Rfc3066AsciiLanguage,
NewString, NewString,
NULL NULL
); );
@ -245,42 +278,16 @@ Returns:
return EFI_SUCCESS; return EFI_SUCCESS;
} }
typedef struct {
CHAR8 *Iso639;
CHAR8 *Rfc3066;
} ISO639TORFC3066MAP;
ISO639TORFC3066MAP Iso639ToRfc3066Map [] = {
{"eng", "en-US"},
{"fra", "fr-FR"},
};
CHAR8 *
ConvertIso639ToRfc3066 (
CHAR8 *Iso638Lang
)
{
UINTN Index;
for (Index = 0; Index < sizeof (Iso639ToRfc3066Map) / sizeof (Iso639ToRfc3066Map[0]); Index++) {
if (AsciiStrnCmp (Iso638Lang, Iso639ToRfc3066Map[Index].Iso639, AsciiStrSize (Iso638Lang)) == 0) {
return Iso639ToRfc3066Map[Index].Rfc3066;
}
}
return (CHAR8 *) NULL;
}
EFI_STATUS EFI_STATUS
EFIAPI EFIAPI
HiiGetString ( HiiGetString (
IN EFI_HII_PROTOCOL *This, IN EFI_HII_PROTOCOL *This,
IN FRAMEWORK_EFI_HII_HANDLE Handle, IN FRAMEWORK_EFI_HII_HANDLE Handle,
IN STRING_REF Token, IN STRING_REF Token,
IN BOOLEAN Raw, IN BOOLEAN Raw,
IN CHAR16 *LanguageString, IN CHAR16 *LanguageString,
IN OUT UINTN *BufferLengthTemp, IN OUT UINTN *BufferLengthTemp,
OUT EFI_STRING StringBuffer OUT EFI_STRING StringBuffer
) )
/*++ /*++
@ -310,68 +317,62 @@ Returns:
--*/ --*/
{ {
LIST_ENTRY *Link; CHAR8 *Iso639AsciiLanguage;
HII_THUNK_CONTEXT *ThunkContext;
CHAR8 *AsciiLanguage;
HII_THUNK_PRIVATE_DATA *Private; HII_THUNK_PRIVATE_DATA *Private;
CHAR8 *Rfc3066AsciiLanguage; CHAR8 *Rfc3066AsciiLanguage;
EFI_HII_HANDLE UefiHiiHandle;
EFI_STATUS Status;
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This); Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
if (LanguageString == NULL) { Iso639AsciiLanguage = NULL;
AsciiLanguage = NULL; Rfc3066AsciiLanguage = NULL;
} else {
AsciiLanguage = AllocateZeroPool (StrLen (LanguageString) + 1); if (LanguageString != NULL) {
if (AsciiLanguage == NULL) { Iso639AsciiLanguage = AllocateZeroPool (StrLen (LanguageString) + 1);
if (Iso639AsciiLanguage == NULL) {
return EFI_OUT_OF_RESOURCES; return EFI_OUT_OF_RESOURCES;
} }
UnicodeStrToAsciiStr (LanguageString, AsciiLanguage); UnicodeStrToAsciiStr (LanguageString, Iso639AsciiLanguage);
Rfc3066AsciiLanguage = ConvertIso639ToRfc3066 (AsciiLanguage); //
// Caller of Framework HII Interface uses the Language Identification String defined
// in Iso639. So map it to the Language Identifier defined in RFC3066.
//
Rfc3066AsciiLanguage = ConvertIso639ToRfc3066 (Iso639AsciiLanguage);
// //
// If Rfc3066AsciiLanguage is NULL, more language mapping must be added to // If Rfc3066AsciiLanguage is NULL, more language mapping must be added to
// Iso639ToRfc3066Map. // Iso639ToRfc3066Map.
// //
ASSERT (Rfc3066AsciiLanguage != NULL); ASSERT (Rfc3066AsciiLanguage != NULL);
//
// Caller of Framework HII Interface uses the Language Identification String defined
// in Iso639. So map it to the Language Identifier defined in RFC3066.
//
if (Rfc3066AsciiLanguage != NULL) {
FreePool (AsciiLanguage);
AsciiLanguage = AllocateCopyPool (AsciiStrSize (Rfc3066AsciiLanguage), Rfc3066AsciiLanguage);
}
} }
Link = GetFirstNode (&Private->ThunkContextListHead); UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);
if (UefiHiiHandle == NULL) {
while (!IsNull (&Private->ThunkContextListHead, Link)) { Status = EFI_NOT_FOUND;
goto Done;
ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
if (Handle == ThunkContext->FwHiiHandle) {
if (AsciiLanguage == NULL) {
return HiiLibGetString (ThunkContext->UefiHiiHandle, Token, StringBuffer, BufferLengthTemp);
} else {
return mHiiStringProtocol->GetString (
mHiiStringProtocol,
AsciiLanguage,
ThunkContext->UefiHiiHandle,
Token,
StringBuffer,
BufferLengthTemp,
NULL
);
}
}
Link = GetNextNode (&Private->ThunkContextListHead, Link);
} }
return EFI_NOT_FOUND; if (Rfc3066AsciiLanguage == NULL) {
Status = HiiLibGetString (UefiHiiHandle, Token, StringBuffer, BufferLengthTemp);
} else {
Status = mHiiStringProtocol->GetString (
mHiiStringProtocol,
Rfc3066AsciiLanguage,
UefiHiiHandle,
Token,
StringBuffer,
BufferLengthTemp,
NULL
);
}
Done:
SafeFreePool (Iso639AsciiLanguage);
return Status;
} }
EFI_STATUS EFI_STATUS