X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=EdkCompatibilityPkg%2FCompatibility%2FFrameworkHiiToUefiHiiThunk%2FStrings.c;fp=EdkCompatibilityPkg%2FCompatibility%2FFrameworkHiiToUefiHiiThunk%2FStrings.c;h=318f9ee1be4a006636b83a35b46fdfc76a216c1b;hb=0368663fd609e2e008031a2025693f190d19b0c7;hp=90661d6136c70a0141318ec32901e41169d372ce;hpb=0514e9c3c9b46f74c232942759388c46ed89802a;p=mirror_edk2.git diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Strings.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Strings.c index 90661d6136..318f9ee1be 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Strings.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/Strings.c @@ -1,7 +1,6 @@ /**@file - - This file contains the keyboard processing code to the HII database. - + This file implements the protocol functions related to string package. + 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 @@ -40,80 +39,111 @@ Returns: } EFI_STATUS -GetTagGuidByFrameworkHiiHandle ( - IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private, - IN FRAMEWORK_EFI_HII_HANDLE FrameworkHiiHandle, +GetTagGuidByFwHiiHandle ( + IN CONST HII_THUNK_PRIVATE_DATA *Private, + IN FRAMEWORK_EFI_HII_HANDLE FwHiiHandle, OUT EFI_GUID *TagGuid ) { - LIST_ENTRY *ListEntry; - HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry; + LIST_ENTRY *Link; + HII_THUNK_CONTEXT *ThunkContext; ASSERT (TagGuid != NULL); - for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink; - ListEntry != &Private->HiiThunkHandleMappingDBListHead; - ListEntry = ListEntry->ForwardLink - ) { + Link = GetFirstNode (&Private->ThunkContextListHead); + while (!IsNull (&Private->ThunkContextListHead, Link)) { - HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry); + ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link); - if (FrameworkHiiHandle == HandleMapEntry->FrameworkHiiHandle) { - CopyGuid (TagGuid, &HandleMapEntry->TagGuid); + if (FwHiiHandle == ThunkContext->FwHiiHandle) { + CopyGuid (TagGuid, &ThunkContext->TagGuid); return EFI_SUCCESS; } + + Link = GetNextNode (&Private->ThunkContextListHead, Link); } - + return EFI_NOT_FOUND; } + + EFI_STATUS -HiiThunkNewStringForAllStringPackages ( - IN CONST EFI_HII_THUNK_PRIVATE_DATA *Private, - OUT CONST EFI_GUID *TagGuid, - IN CHAR16 *Language, - IN OUT STRING_REF *Reference, - IN CHAR16 *NewString +EFIAPI +HiiNewString ( + IN EFI_HII_PROTOCOL *This, + IN CHAR16 *Language, + IN FRAMEWORK_EFI_HII_HANDLE Handle, + IN OUT STRING_REF *Reference, + IN CHAR16 *NewString ) +/*++ + +Routine Description: + This function allows a new String to be added to an already existing String Package. + We will make a buffer the size of the package + StrSize of the new string. We will + copy the string package that first gets changed and the following language packages until + we encounter the NULL string package. All this time we will ensure that the offsets have + been adjusted. + +Arguments: + +Returns: + +--*/ { EFI_STATUS Status; - LIST_ENTRY *ListEntry; - HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry; - EFI_STRING_ID StringId1; - EFI_STRING_ID StringId2; + HII_THUNK_PRIVATE_DATA *Private; + EFI_GUID TagGuid; + LIST_ENTRY *Link; + HII_THUNK_CONTEXT *ThunkContext; + EFI_STRING_ID StringId; + EFI_STRING_ID LastStringId; CHAR8 *AsciiLanguage; BOOLEAN Found; - ASSERT (TagGuid != NULL); + // + // BugBug: Conver the language to 3066. + // - StringId1 = (EFI_STRING_ID) 0; - StringId2 = (EFI_STRING_ID) 0; - Found = FALSE; + LastStringId = (EFI_STRING_ID) 0; + StringId = (EFI_STRING_ID) 0; + Found = FALSE; + AsciiLanguage = NULL; - if (Language == NULL) { - AsciiLanguage = NULL; - } else { + Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This); + + Status = GetTagGuidByFwHiiHandle (Private, Handle, &TagGuid); + ASSERT_EFI_ERROR (Status); + + if (Language != NULL) { AsciiLanguage = AllocateZeroPool (StrLen (Language) + 1); UnicodeStrToAsciiStr (Language, AsciiLanguage); } - for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink; - ListEntry != &Private->HiiThunkHandleMappingDBListHead; - ListEntry = ListEntry->ForwardLink - ) { - - HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry); + Link = GetFirstNode (&Private->ThunkContextListHead); + while (!IsNull (&Private->ThunkContextListHead, Link)) { + ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link); - if (CompareGuid (TagGuid, &HandleMapEntry->TagGuid)) { + if (CompareGuid (&TagGuid, &ThunkContext->TagGuid)) { Found = TRUE; if (*Reference == 0) { + // + // Create a new string token. + // if (AsciiLanguage == NULL) { - Status = HiiLibNewString (HandleMapEntry->UefiHiiHandle, &StringId2, NewString); + // + // For all languages in the package list. + // + Status = HiiLibNewString (ThunkContext->UefiHiiHandle, &StringId, NewString); } else { + // + // For specified language. + // Status = mHiiStringProtocol->NewString ( mHiiStringProtocol, - HandleMapEntry->UefiHiiHandle, - &StringId2, + ThunkContext->UefiHiiHandle, + &StringId, AsciiLanguage, NULL, NewString, @@ -121,12 +151,21 @@ HiiThunkNewStringForAllStringPackages ( ); } } else { + // + // Update the existing string token. + // if (AsciiLanguage == NULL) { - Status = HiiLibSetString (HandleMapEntry->UefiHiiHandle, *Reference, NewString); + // + // For all languages in the package list. + // + Status = HiiLibSetString (ThunkContext->UefiHiiHandle, *Reference, NewString); } else { + // + // For specified language. + // Status = mHiiStringProtocol->SetString ( mHiiStringProtocol, - HandleMapEntry->UefiHiiHandle, + ThunkContext->UefiHiiHandle, *Reference, AsciiLanguage, NewString, @@ -135,66 +174,45 @@ HiiThunkNewStringForAllStringPackages ( } } if (EFI_ERROR (Status)) { - return Status; + // + // Only EFI_INVALID_PARAMETER is defined in HII 0.92 specification. + // + return EFI_INVALID_PARAMETER; } + if (*Reference == 0) { - if (StringId1 == (EFI_STRING_ID) 0) { - StringId1 = StringId2; + // + // 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 (StringId1 != StringId2) { + if (LastStringId != StringId) { ASSERT(FALSE); return EFI_INVALID_PARAMETER; } } } } + + Link = GetNextNode (&Private->ThunkContextListHead, Link); } if (Found) { - *Reference = StringId1; + if (*Reference == 0) { + *Reference = StringId; + } Status = EFI_SUCCESS; } else { + DEBUG((EFI_D_ERROR, "Thunk HiiNewString fails to find the String Packages to update\n")); + // + // BUGBUG: Remove ths ASSERT when development is done. + // ASSERT (FALSE); Status = EFI_NOT_FOUND; } - return Status; -} - -EFI_STATUS -EFIAPI -HiiNewString ( - IN EFI_HII_PROTOCOL *This, - IN CHAR16 *Language, - IN FRAMEWORK_EFI_HII_HANDLE Handle, - IN OUT STRING_REF *Reference, - IN CHAR16 *NewString - ) -/*++ - -Routine Description: - This function allows a new String to be added to an already existing String Package. - We will make a buffer the size of the package + StrSize of the new string. We will - copy the string package that first gets changed and the following language packages until - we encounter the NULL string package. All this time we will ensure that the offsets have - been adjusted. - -Arguments: - -Returns: - ---*/ -{ - EFI_STATUS Status; - EFI_HII_THUNK_PRIVATE_DATA *Private; - EFI_GUID TagGuid; - - Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This); - - Status = GetTagGuidByFrameworkHiiHandle (Private, Handle, &TagGuid); - ASSERT_EFI_ERROR (Status); - - Status = HiiThunkNewStringForAllStringPackages (Private, &TagGuid, Language, Reference, NewString); // // For UNI file, some String may not be defined for a language. This has been true for a lot of platform code. // For this case, EFI_NOT_FOUND will be returned. To allow the old code to be run without porting, we don't assert @@ -224,8 +242,7 @@ Returns: --*/ { - ASSERT (FALSE); - return EFI_UNSUPPORTED; + return EFI_SUCCESS; } typedef struct { @@ -293,13 +310,13 @@ Returns: --*/ { - LIST_ENTRY *ListEntry; - HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY *HandleMapEntry; + LIST_ENTRY *Link; + HII_THUNK_CONTEXT *ThunkContext; CHAR8 *AsciiLanguage; - EFI_HII_THUNK_PRIVATE_DATA *Private; + HII_THUNK_PRIVATE_DATA *Private; CHAR8 *Rfc3066AsciiLanguage; - Private = EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This); + Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This); if (LanguageString == NULL) { AsciiLanguage = NULL; @@ -328,21 +345,20 @@ Returns: } - for (ListEntry = Private->HiiThunkHandleMappingDBListHead.ForwardLink; - ListEntry != &Private->HiiThunkHandleMappingDBListHead; - ListEntry = ListEntry->ForwardLink - ) { + Link = GetFirstNode (&Private->ThunkContextListHead); + + while (!IsNull (&Private->ThunkContextListHead, Link)) { - HandleMapEntry = HII_TRHUNK_HANDLE_MAPPING_DATABASE_ENTRY_FROM_LISTENTRY (ListEntry); + ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link); - if (Handle == HandleMapEntry->FrameworkHiiHandle) { + if (Handle == ThunkContext->FwHiiHandle) { if (AsciiLanguage == NULL) { - return HiiLibGetString (HandleMapEntry->UefiHiiHandle, Token, StringBuffer, BufferLengthTemp); + return HiiLibGetString (ThunkContext->UefiHiiHandle, Token, StringBuffer, BufferLengthTemp); } else { return mHiiStringProtocol->GetString ( mHiiStringProtocol, AsciiLanguage, - HandleMapEntry->UefiHiiHandle, + ThunkContext->UefiHiiHandle, Token, StringBuffer, BufferLengthTemp, @@ -350,6 +366,9 @@ Returns: ); } } + + + Link = GetNextNode (&Private->ThunkContextListHead, Link); } return EFI_NOT_FOUND;