mirror of https://github.com/acidanthera/audk.git
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:
parent
d37be74e1a
commit
133a9dfb54
|
@ -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);
|
||||
|
||||
Link = GetFirstNode (&ConfigAccess->BufferStorageListHead);
|
||||
ASSERT (!IsNull (&ConfigAccess->BufferStorageListHead, Link));
|
||||
|
||||
BufferStorageEntry = BUFFER_STORAGE_ENTRY_FROM_LINK(Link);
|
||||
BrowserDataSize = BufferStorageEntry->Size;
|
||||
|
||||
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;
|
||||
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);
|
||||
|
||||
|
@ -656,6 +672,30 @@ CreateIfrDataArray (
|
|||
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
|
||||
DestroyIfrDataArray (
|
||||
IN FRAMEWORK_EFI_IFR_DATA_ARRAY *Array,
|
||||
|
@ -850,6 +890,7 @@ ThunkCallback (
|
|||
Data,
|
||||
&Packet
|
||||
);
|
||||
SyncBrowserDataForNvMapOverride (ConfigAccess);
|
||||
|
||||
//
|
||||
// Callback require browser to perform action
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -97,6 +97,7 @@
|
|||
[Depex]
|
||||
gEfiHiiDatabaseProtocolGuid AND
|
||||
gEfiHiiStringProtocolGuid AND
|
||||
gEfiHiiConfigRoutingProtocolGuid
|
||||
gEfiHiiConfigRoutingProtocolGuid AND
|
||||
gEfiHiiFontProtocolGuid
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
@ -134,6 +135,13 @@ Returns:
|
|||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = gBS->LocateProtocol (
|
||||
&gEfiHiiFontProtocolGuid,
|
||||
NULL,
|
||||
(VOID **) &mHiiFontProtocol
|
||||
);
|
||||
ASSERT_EFI_ERROR (Status);
|
||||
|
||||
Status = gBS->LocateProtocol (
|
||||
&gEfiHiiConfigRoutingProtocolGuid,
|
||||
NULL,
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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->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) {
|
||||
|
@ -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;
|
||||
|
||||
|
|
|
@ -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);
|
||||
|
||||
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);
|
||||
UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);
|
||||
if (UefiHiiHandle == NULL) {
|
||||
Status = EFI_NOT_FOUND;
|
||||
goto Done;
|
||||
}
|
||||
|
||||
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
|
||||
|
|
Loading…
Reference in New Issue