summaryrefslogtreecommitdiff
path: root/EdkCompatibilityPkg
diff options
context:
space:
mode:
authorqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-08-19 10:44:50 +0000
committerqwang12 <qwang12@6f19259b-4bc3-4df7-8a09-765794883524>2008-08-19 10:44:50 +0000
commit133a9dfb54bee02bf76aeb158da42594ffbc8a73 (patch)
treef7e2ccd8216c2cd4af7edab37c2b69fc16d666d7 /EdkCompatibilityPkg
parentd37be74e1ab4655a387032027f478031b4bafa48 (diff)
downloadedk2-platforms-133a9dfb54bee02bf76aeb158da42594ffbc8a73.tar.xz
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
Diffstat (limited to 'EdkCompatibilityPkg')
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c139
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Fonts.c96
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/FrameworkHiiToUefiHiiThunk.inf3
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.c8
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h1
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.c25
-rw-r--r--EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Strings.c167
7 files changed, 290 insertions, 149 deletions
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c
index 88565d128c..c537a47b1c 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/ConfigAccess.c
@@ -433,7 +433,7 @@ ThunkExtractConfig (
EFI_STATUS Status;
CONFIG_ACCESS_PRIVATE *ConfigAccess;
LIST_ENTRY *Link;
- BUFFER_STORAGE_ENTRY *BufferStorage;
+ BUFFER_STORAGE_ENTRY *BufferStorage;
VOID *Data;
UINTN DataSize;
@@ -451,20 +451,31 @@ ThunkExtractConfig (
BufferStorage = BUFFER_STORAGE_ENTRY_FROM_LINK (Link);
- if (ConfigAccess->FormCallbackProtocol == NULL ||
- ConfigAccess->FormCallbackProtocol->NvRead == NULL) {
- Status = GetUefiVariable (
- BufferStorage,
- &Data,
- &DataSize
- );
+ if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
+ if (ConfigAccess->FormCallbackProtocol == NULL ||
+ ConfigAccess->FormCallbackProtocol->NvRead == NULL) {
+ Status = GetUefiVariable (
+ BufferStorage,
+ &Data,
+ &DataSize
+ );
+ } else {
+ Status = CallFormCallBack (
+ BufferStorage,
+ ConfigAccess->FormCallbackProtocol,
+ &Data,
+ &DataSize
+ );
+ }
} else {
- Status = CallFormCallBack (
- BufferStorage,
- ConfigAccess->FormCallbackProtocol,
- &Data,
- &DataSize
- );
+ DataSize = BufferStorage->Size;
+ Data = AllocateCopyPool (DataSize, ConfigAccess->ThunkContext->NvMapOverride);
+
+ if (Data != NULL) {
+ Status = EFI_SUCCESS;
+ } else {
+ Status = EFI_OUT_OF_RESOURCES;
+ }
}
if (!EFI_ERROR (Status)) {
@@ -518,7 +529,6 @@ ThunkRouteConfig (
BOOLEAN DataAllocated;
Data = NULL;
- DataAllocated = TRUE;
ConfigAccess = CONFIG_ACCESS_PRIVATE_FROM_PROTOCOL (This);
//
@@ -533,6 +543,7 @@ ThunkRouteConfig (
BufferStorage = BUFFER_STORAGE_ENTRY_FROM_LINK (Link);
DataSize2 = BufferStorage->Size;
if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
+ DataAllocated = TRUE;
if (ConfigAccess->FormCallbackProtocol == NULL ||
ConfigAccess->FormCallbackProtocol->NvRead == NULL) {
Status = GetUefiVariable (
@@ -540,8 +551,6 @@ ThunkRouteConfig (
&Data,
&DataSize
);
- ASSERT (DataSize == DataSize2);
-
} else {
Status = CallFormCallBack (
BufferStorage,
@@ -549,17 +558,20 @@ ThunkRouteConfig (
&Data,
&DataSize
);
- ASSERT (DataSize == DataSize2);
-
}
} else {
+ //
+ // ConfigToBlock will convert the Config String and update the NvMapOverride accordingly.
+ //
Status = EFI_SUCCESS;
Data = ConfigAccess->ThunkContext->NvMapOverride;
DataSize = DataSize2;
DataAllocated = FALSE;
}
- if (EFI_ERROR (Status)) {
- goto Done;
+ if (EFI_ERROR (Status) || (DataSize2 != DataSize)) {
+ if (Data == NULL) {
+ Data = AllocateZeroPool (DataSize2);
+ }
}
Status = mHiiConfigRoutingProtocol->ConfigToBlock (
@@ -573,26 +585,28 @@ ThunkRouteConfig (
goto Done;
}
- if (ConfigAccess->FormCallbackProtocol == NULL ||
- ConfigAccess->FormCallbackProtocol->NvWrite == NULL) {
- Status = gRT->SetVariable (
- BufferStorage->Name,
- &BufferStorage->Guid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- DataSize,
- Data
- );
- } else {
- Status = ConfigAccess->FormCallbackProtocol->NvWrite (
- ConfigAccess->FormCallbackProtocol,
- BufferStorage->Name,
- &BufferStorage->Guid,
- EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
- DataSize,
- Data,
- &ResetRequired
- );
-
+ if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
+ if (ConfigAccess->FormCallbackProtocol == NULL ||
+ ConfigAccess->FormCallbackProtocol->NvWrite == NULL) {
+ Status = gRT->SetVariable (
+ BufferStorage->Name,
+ &BufferStorage->Guid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ DataSize2,
+ Data
+ );
+ } else {
+ Status = ConfigAccess->FormCallbackProtocol->NvWrite (
+ ConfigAccess->FormCallbackProtocol,
+ BufferStorage->Name,
+ &BufferStorage->Guid,
+ EFI_VARIABLE_NON_VOLATILE | EFI_VARIABLE_BOOTSERVICE_ACCESS | EFI_VARIABLE_RUNTIME_ACCESS,
+ DataSize2,
+ Data,
+ &ResetRequired
+ );
+
+ }
}
Done:
@@ -617,25 +631,27 @@ CreateIfrDataArray (
UINTN BrowserDataSize;
BUFFER_STORAGE_ENTRY *BufferStorageEntry;
LIST_ENTRY *Link;
+ EFI_STATUS Status;
IfrDataArray = AllocateZeroPool (0x100);
ASSERT (IfrDataArray != NULL);
- if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
- Link = GetFirstNode (&ConfigAccess->BufferStorageListHead);
-
- ASSERT (!IsNull (&ConfigAccess->BufferStorageListHead, Link));
-
- BufferStorageEntry = BUFFER_STORAGE_ENTRY_FROM_LINK(Link);
+ Link = GetFirstNode (&ConfigAccess->BufferStorageListHead);
+ ASSERT (!IsNull (&ConfigAccess->BufferStorageListHead, Link));
+
+ BufferStorageEntry = BUFFER_STORAGE_ENTRY_FROM_LINK(Link);
+ BrowserDataSize = BufferStorageEntry->Size;
- BrowserDataSize = BufferStorageEntry->Size;
+ if (ConfigAccess->ThunkContext->NvMapOverride == NULL) {
*NvMapAllocated = TRUE;
IfrDataArray->NvRamMap = AllocateZeroPool (BrowserDataSize);
- GetBrowserData (NULL, NULL, &BrowserDataSize, IfrDataArray->NvRamMap);
} else {
*NvMapAllocated = FALSE;
IfrDataArray->NvRamMap = ConfigAccess->ThunkContext->NvMapOverride;
}
+
+ Status = GetBrowserData (NULL, NULL, &BrowserDataSize, IfrDataArray->NvRamMap);
+ ASSERT_EFI_ERROR (Status);
IfrDataEntry = (FRAMEWORK_EFI_IFR_DATA_ENTRY *) (IfrDataArray + 1);
@@ -657,6 +673,30 @@ CreateIfrDataArray (
}
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
DestroyIfrDataArray (
IN FRAMEWORK_EFI_IFR_DATA_ARRAY *Array,
IN BOOLEAN NvMapAllocated
@@ -850,6 +890,7 @@ ThunkCallback (
Data,
&Packet
);
+ SyncBrowserDataForNvMapOverride (ConfigAccess);
//
// Callback require browser to perform action
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Fonts.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Fonts.c
index 1d58dcd908..34a89b1b08 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Fonts.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Fonts.c
@@ -16,8 +16,11 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#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.
@@ -47,8 +50,76 @@ HiiGetGlyph (
IN OUT UINT32 *InternalStatus
)
{
- ASSERT (FALSE);
- return EFI_UNSUPPORTED;
+ EFI_STATUS Status;
+ 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
)
{
- ASSERT (FALSE);
- return EFI_UNSUPPORTED;
+ UINTN X;
+ 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;
}
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/FrameworkHiiToUefiHiiThunk.inf b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/FrameworkHiiToUefiHiiThunk.inf
index 88f05ad3a1..ea83bdf66e 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/FrameworkHiiToUefiHiiThunk.inf
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/FrameworkHiiToUefiHiiThunk.inf
@@ -97,6 +97,7 @@
[Depex]
gEfiHiiDatabaseProtocolGuid AND
gEfiHiiStringProtocolGuid AND
- gEfiHiiConfigRoutingProtocolGuid
+ gEfiHiiConfigRoutingProtocolGuid AND
+ gEfiHiiFontProtocolGuid
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.c
index 50b902a952..c9428a2328 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.c
@@ -76,6 +76,7 @@ EFI_FORMBROWSER_THUNK_PRIVATE_DATA mBrowserThunkPrivateDataTemplate = {
CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol;
CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol;
+CONST EFI_HII_FONT_PROTOCOL *mHiiFontProtocol;
CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol;
CONST EFI_FORM_BROWSER2_PROTOCOL *mFormBrowser2Protocol;
@@ -135,6 +136,13 @@ Returns:
ASSERT_EFI_ERROR (Status);
Status = gBS->LocateProtocol (
+ &gEfiHiiFontProtocolGuid,
+ NULL,
+ (VOID **) &mHiiFontProtocol
+ );
+ ASSERT_EFI_ERROR (Status);
+
+ Status = gBS->LocateProtocol (
&gEfiHiiConfigRoutingProtocolGuid,
NULL,
(VOID **) &mHiiConfigRoutingProtocol
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h
index 3a0f09f0c8..55362ea7bf 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h
@@ -211,6 +211,7 @@ typedef struct {
extern CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
extern CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol;
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_FORM_BROWSER2_PROTOCOL *mFormBrowser2Protocol;
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.c
index 8776385375..cf43572ab7 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/OpcodeCreation.c
@@ -351,7 +351,9 @@ F2UCreateOneOfOpCode (
UOpcode.Question.Header.Prompt = FwOpcode->Prompt;
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
//
@@ -386,18 +388,18 @@ F2UCreateOneOfOpCode (
}
InsertTailList (&ThunkContext->OneOfOptionMapListHead, &OneOfOptionMap->Link);
- } else {
- OneOfOptionMapEntry = AllocateZeroPool (sizeof (ONE_OF_OPTION_MAP_ENTRY));
- ASSERT (OneOfOptionMapEntry != NULL);
+ }
+
+ 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);
+ 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);
- }
+ ASSERT (OneOfOptionMap != NULL);
+ InsertTailList (&OneOfOptionMap->OneOfOptionMapEntryListHead, &OneOfOptionMapEntry->Link);
}
if (FwOneOfOp->Flags & FRAMEWORK_EFI_IFR_FLAG_RESET_REQUIRED) {
@@ -499,6 +501,7 @@ F2UCreateOrderedListOpCode (
UOpcode.Question.Header.Prompt = FwOpcode->Prompt;
UOpcode.Question.Header.Help = FwOpcode->Help;
UOpcode.Question.VarStoreId = VarStoreId;
+ UOpcode.Question.VarStoreInfo.VarOffset = FwOpcode->QuestionId;
UOpcode.MaxContainers = FwOpcode->MaxEntries;
diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Strings.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Strings.c
index 318f9ee1be..9a38060522 100644
--- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Strings.c
+++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Strings.c
@@ -15,6 +15,33 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
#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
EFIAPI
HiiTestString (
@@ -38,6 +65,8 @@ Returns:
return EFI_SUCCESS;
}
+
+
EFI_STATUS
GetTagGuidByFwHiiHandle (
IN CONST HII_THUNK_PRIVATE_DATA *Private,
@@ -99,8 +128,9 @@ Returns:
HII_THUNK_CONTEXT *ThunkContext;
EFI_STRING_ID StringId;
EFI_STRING_ID LastStringId;
- CHAR8 *AsciiLanguage;
+ CHAR8 AsciiLanguage[ISO_639_2_ENTRY_SIZE + 1];
BOOLEAN Found;
+ CHAR8 *Rfc3066AsciiLanguage;
//
// BugBug: Conver the language to 3066.
@@ -109,7 +139,7 @@ Returns:
LastStringId = (EFI_STRING_ID) 0;
StringId = (EFI_STRING_ID) 0;
Found = FALSE;
- AsciiLanguage = NULL;
+ Rfc3066AsciiLanguage = NULL;
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
@@ -117,8 +147,11 @@ Returns:
ASSERT_EFI_ERROR (Status);
if (Language != NULL) {
- AsciiLanguage = AllocateZeroPool (StrLen (Language) + 1);
+ ZeroMem (AsciiLanguage, sizeof (AsciiLanguage));;
+
UnicodeStrToAsciiStr (Language, AsciiLanguage);
+ Rfc3066AsciiLanguage = ConvertIso639ToRfc3066 (AsciiLanguage);
+ ASSERT (Rfc3066AsciiLanguage != NULL);
}
Link = GetFirstNode (&Private->ThunkContextListHead);
@@ -131,7 +164,7 @@ Returns:
//
// Create a new string token.
//
- if (AsciiLanguage == NULL) {
+ if (Rfc3066AsciiLanguage == NULL) {
//
// For all languages in the package list.
//
@@ -144,7 +177,7 @@ Returns:
mHiiStringProtocol,
ThunkContext->UefiHiiHandle,
&StringId,
- AsciiLanguage,
+ Rfc3066AsciiLanguage,
NULL,
NewString,
NULL
@@ -154,7 +187,7 @@ Returns:
//
// Update the existing string token.
//
- if (AsciiLanguage == NULL) {
+ if (Rfc3066AsciiLanguage == NULL) {
//
// For all languages in the package list.
//
@@ -167,7 +200,7 @@ Returns:
mHiiStringProtocol,
ThunkContext->UefiHiiHandle,
*Reference,
- AsciiLanguage,
+ Rfc3066AsciiLanguage,
NewString,
NULL
);
@@ -245,42 +278,16 @@ Returns:
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
EFIAPI
HiiGetString (
- 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
+ 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
)
/*++
@@ -310,68 +317,62 @@ Returns:
--*/
{
- LIST_ENTRY *Link;
- HII_THUNK_CONTEXT *ThunkContext;
- CHAR8 *AsciiLanguage;
+ CHAR8 *Iso639AsciiLanguage;
HII_THUNK_PRIVATE_DATA *Private;
- CHAR8 *Rfc3066AsciiLanguage;
+ CHAR8 *Rfc3066AsciiLanguage;
+ EFI_HII_HANDLE UefiHiiHandle;
+ EFI_STATUS Status;
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
- if (LanguageString == NULL) {
- AsciiLanguage = NULL;
- } else {
- AsciiLanguage = AllocateZeroPool (StrLen (LanguageString) + 1);
- if (AsciiLanguage == NULL) {
+ Iso639AsciiLanguage = NULL;
+ Rfc3066AsciiLanguage = NULL;
+
+ if (LanguageString != NULL) {
+ Iso639AsciiLanguage = AllocateZeroPool (StrLen (LanguageString) + 1);
+ if (Iso639AsciiLanguage == NULL) {
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
// Iso639ToRfc3066Map.
//
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);
-
- while (!IsNull (&Private->ThunkContextListHead, Link)) {
-
- ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
+ UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);
+ if (UefiHiiHandle == NULL) {
+ Status = EFI_NOT_FOUND;
+ goto Done;
+ }
- 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);
+ if (Rfc3066AsciiLanguage == NULL) {
+ Status = HiiLibGetString (UefiHiiHandle, Token, StringBuffer, BufferLengthTemp);
+ } else {
+ Status = mHiiStringProtocol->GetString (
+ mHiiStringProtocol,
+ Rfc3066AsciiLanguage,
+ UefiHiiHandle,
+ Token,
+ StringBuffer,
+ BufferLengthTemp,
+ NULL
+ );
}
- return EFI_NOT_FOUND;
+Done:
+ SafeFreePool (Iso639AsciiLanguage);
+
+ return Status;
}
EFI_STATUS