diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.c index c7d339e107..d5ef19c356 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.c @@ -1,8 +1,8 @@ /**@file +Framework to UEFI 2.1 HII Thunk. The driver consume UEFI HII protocols +to produce a Framework HII protocol. -Framework to UEFI 2.1 HII Thunk - -Copyright (c) 2003, Intel Corporation +Copyright (c) 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 @@ -175,7 +175,36 @@ Returns: --*/ { - ASSERT (FALSE); + EFI_HII_THUNK_PRIVATE_DATA *Private; + EFI_HII_HANDLE UefiHiiHandle; + CHAR8 *AsciiLanguageCodes; + CHAR16 *UnicodeLanguageCodes; + + Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This); + + + + UefiHiiHandle = FrameworkHiiHandleToUefiHiiHandle (Private, Handle); + if (UefiHiiHandle == NULL) { + return EFI_INVALID_PARAMETER; + } + + AsciiLanguageCodes = HiiLibGetSupportedLanguages (UefiHiiHandle); + + if (AsciiLanguageCodes == NULL) { + return EFI_INVALID_PARAMETER; + } + + UnicodeLanguageCodes = AllocateZeroPool (AsciiStrSize (AsciiLanguageCodes) * sizeof (CHAR16)); + if (UnicodeLanguageCodes == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // The language returned is in RFC 3066 format. + // + *LanguageString = AsciiStrToUnicodeStr (AsciiLanguageCodes, UnicodeLanguageCodes); + return EFI_SUCCESS; } @@ -200,7 +229,41 @@ Returns: --*/ { - ASSERT (FALSE); + EFI_HII_THUNK_PRIVATE_DATA *Private; + EFI_HII_HANDLE UefiHiiHandle; + CHAR8 *AsciiPrimaryLanguage; + CHAR8 *AsciiLanguageCodes; + CHAR16 *UnicodeLanguageCodes; + + Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This); + + + + UefiHiiHandle = FrameworkHiiHandleToUefiHiiHandle (Private, Handle); + if (UefiHiiHandle == NULL) { + return EFI_INVALID_PARAMETER; + } + + AsciiPrimaryLanguage = AllocateZeroPool (StrLen (PrimaryLanguage) + 1); + + UnicodeStrToAsciiStr (PrimaryLanguage, AsciiPrimaryLanguage); + + AsciiLanguageCodes = HiiLibGetSupportedSecondaryLanguages (UefiHiiHandle, AsciiPrimaryLanguage); + + if (AsciiLanguageCodes == NULL) { + return EFI_INVALID_PARAMETER; + } + + UnicodeLanguageCodes = AllocateZeroPool (AsciiStrSize (AsciiLanguageCodes) * sizeof (CHAR16)); + if (UnicodeLanguageCodes == NULL) { + return EFI_OUT_OF_RESOURCES; + } + + // + // The language returned is in RFC 3066 format. + // + *LanguageString = AsciiStrToUnicodeStr (AsciiLanguageCodes, UnicodeLanguageCodes); + return EFI_SUCCESS; } diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h index f0ef02e2dd..dd07afd06a 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.h @@ -44,7 +44,6 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. #include #include #include -#include "Utility.h" // // Macros @@ -319,4 +318,6 @@ HiiCompareLanguage ( ) ; +#include "Utility.h" + #endif diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Keyboard.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Keyboard.c index d54c9b9d29..9a49ee5761 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Keyboard.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Keyboard.c @@ -33,5 +33,10 @@ Returns: --*/ { - return EFI_SUCCESS; + ASSERT (FALSE); + // + // In previous Framewok HII implementation, GetKeyBoardLayout is defined in HII 0.92 specification, + // but it is not implemented. We ASSERT and return UNSUPPORTED here. + // + return EFI_UNSUPPORTED; } diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c index 30b743e19e..001efa2e14 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.c @@ -39,3 +39,30 @@ GetGuidOfFirstFormset ( return NULL; } +EFI_HII_HANDLE +FrameworkHiiHandleToUefiHiiHandle ( + IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private, + IN FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle + ) +{ + LIST_ENTRY *ListEntry; + HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry; + + ASSERT (FrameworkHiiHandle != (FRAMEWORK_EFI_HII_HANDLE) 0); + ASSERT (Private != NULL); + + for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink; + ListEntry != &Private->HiiThunkHandleMappingDBListHead; + ListEntry = ListEntry->ForwardLink + ) { + + HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry); + + if (FrameworkHiiHandle == HandleMapEntry->FrameworkHiiHandle) { + return HandleMapEntry->UefiHiiHandle; + } + } + + return (EFI_HII_HANDLE) NULL; +} + diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h index 5edde947ad..a0a3be3934 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Utility.h @@ -21,4 +21,21 @@ GetGuidOfFirstFormset ( CONST EFI_HII_FORM_PACKAGE * FormPackage ); +/** + Find the UefiHiiHandle based on a Framework HII Handle returned by + the HII Thunk to Framework HII code. + + @param Private The pointer to the private data of Hii Thunk. + @param FrameworkHiiHandle Framework HII Handle returned by the HII Thunk to Framework HII code. + + @retval NULL If Framework HII Handle passed in does not have matching UEFI HII handle. + @retval !NULL If the match is found. + +**/ +EFI_HII_HANDLE +FrameworkHiiHandleToUefiHiiHandle ( + IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private, + IN FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle + ) +; #endif