X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=EdkCompatibilityPkg%2FCompatibility%2FFrameworkHiiToUefiHiiThunk%2FHiiDatabase.c;h=1994f893ec9092ea34af47cfc188cf34be6f5094;hb=3321fa09f0a8e7007b0949abfa69a612cd74e7fe;hp=50b902a952cd08b01b8cb3eb79c2a36b06df983b;hpb=0368663fd609e2e008031a2025693f190d19b0c7;p=mirror_edk2.git diff --git a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.c b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.c index 50b902a952..1994f893ec 100644 --- a/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.c +++ b/EdkCompatibilityPkg/Compatibility/FrameworkHiiToUefiHiiThunk/HiiDatabase.c @@ -14,6 +14,7 @@ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. **/ #include "HiiDatabase.h" +#include "HiiHandle.h" HII_THUNK_PRIVATE_DATA *mHiiThunkPrivateData; @@ -43,22 +44,11 @@ HII_THUNK_PRIVATE_DATA mHiiThunkPrivateDataTempate = { HiiGetKeyboardLayout }, - // - //StaticHiiHandle - //The FRAMEWORK_EFI_HII_HANDLE starts from 1 - // and increase upwords untill reach the value of StaticPureUefiHiiHandle. - // The code will assert to prevent overflow. - (FRAMEWORK_EFI_HII_HANDLE) 1, - - // - //StaticPureUefiHiiHandle - //The Static FRAMEWORK_EFI_HII_HANDLE starts from 0xFFFF - // and decrease downwords untill reach the value of StaticHiiHandle. - // The code will assert to prevent overflow. - // - (FRAMEWORK_EFI_HII_HANDLE) 0xFFFF, { - NULL, NULL //HiiHandleLinkList + /// + /// HiiHandleLinkList + /// + NULL, NULL }, }; @@ -76,33 +66,25 @@ 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; +/** + This routine initializes the HII Database. + + @param ImageHandle Image handle for PCD DXE driver. + @param SystemTable Pointer to SystemTable. - - - + @retval EFI_SUCCESS The entry point alwasy return successfully. +**/ EFI_STATUS EFIAPI InitializeHiiDatabase ( IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable ) -/*++ - -Routine Description: - Initialize HII Database - -Arguments: - (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT) - -Returns: - EFI_SUCCESS - Setup loaded. - other - Setup Error - ---*/ { HII_THUNK_PRIVATE_DATA *Private; EFI_HANDLE Handle; @@ -110,14 +92,18 @@ Returns: UINTN BufferLength; EFI_HII_HANDLE *Buffer; UINTN Index; + HII_THUNK_CONTEXT *ThunkContext; - ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiProtocolGuid); + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiCompatibilityProtocolGuid); + ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiFormBrowserCompatibilityProtocolGuid); Private = AllocateCopyPool (sizeof (HII_THUNK_PRIVATE_DATA), &mHiiThunkPrivateDataTempate); ASSERT (Private != NULL); InitializeListHead (&Private->ThunkContextListHead); + InitHiiHandleDatabase (); + mHiiThunkPrivateData = Private; Status = gBS->LocateProtocol ( @@ -134,6 +120,13 @@ Returns: ); ASSERT_EFI_ERROR (Status); + Status = gBS->LocateProtocol ( + &gEfiHiiFontProtocolGuid, + NULL, + (VOID **) &mHiiFontProtocol + ); + ASSERT_EFI_ERROR (Status); + Status = gBS->LocateProtocol ( &gEfiHiiConfigRoutingProtocolGuid, NULL, @@ -157,7 +150,7 @@ Returns: // Status = gBS->InstallProtocolInterface ( &Private->Handle, - &gEfiHiiProtocolGuid, + &gEfiHiiCompatibilityProtocolGuid, EFI_NATIVE_INTERFACE, (VOID *) &Private->Hii ); @@ -166,8 +159,10 @@ Returns: Status = HiiLibListPackageLists (EFI_HII_PACKAGE_STRINGS, NULL, &BufferLength, &Buffer); if (Status == EFI_SUCCESS) { for (Index = 0; Index < BufferLength / sizeof (EFI_HII_HANDLE); Index++) { - CreateThunkContextForUefiHiiHandle (Private, Buffer[Index]); - ASSERT_EFI_ERROR (Status); + ThunkContext = CreateThunkContextForUefiHiiHandle (Buffer[Index]); + ASSERT (ThunkContext!= NULL); + + InsertTailList (&Private->ThunkContextListHead, &ThunkContext->Link); } FreePool (Buffer); @@ -195,7 +190,7 @@ Returns: Status = mHiiDatabase->RegisterPackageNotify ( mHiiDatabase, - EFI_HII_PACKAGE_FORM, + EFI_HII_PACKAGE_FORMS, NULL, NewOrAddPackNotify, EFI_HII_DATABASE_NOTIFY_NEW_PACK, @@ -205,7 +200,7 @@ Returns: Status = mHiiDatabase->RegisterPackageNotify ( mHiiDatabase, - EFI_HII_PACKAGE_FORM, + EFI_HII_PACKAGE_FORMS, NULL, NewOrAddPackNotify, EFI_HII_DATABASE_NOTIFY_ADD_PACK, @@ -226,7 +221,7 @@ Returns: mBrowserThunkPrivateDataTemplate.ThunkPrivate = Private; Status = gBS->InstallProtocolInterface ( &mBrowserThunkPrivateDataTemplate.Handle, - &gEfiFormBrowserProtocolGuid, + &gEfiFormBrowserCompatibilityProtocolGuid, EFI_NATIVE_INTERFACE, (VOID *) &mBrowserThunkPrivateDataTemplate.FormBrowser ); @@ -235,6 +230,26 @@ Returns: return Status; } +/** + Determines the handles that are currently active in the database. + + This function determines the handles that are currently active in the database. + For example, a program wishing to create a Setup-like configuration utility would use this call + to determine the handles that are available. It would then use calls defined in the forms section + below to extract forms and then interpret them. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param HandleBufferLength On input, a pointer to the length of the handle buffer. + On output, the length of the handle buffer that is required for the handles found. + @param Handle An array of EFI_HII_HANDLE instances returned. + Type EFI_HII_HANDLE is defined in EFI_HII_PROTOCOL.NewPack() in the Packages section. + + @retval EFI_SUCCESS Handle was updated successfully. + + @retval EFI_BUFFER_TOO_SMALL The HandleBufferLength parameter indicates that Handle is too small + to support the number of handles. HandleBufferLength is updated with a value that + will enable the data to fit. +**/ EFI_STATUS EFIAPI HiiFindHandles ( @@ -242,16 +257,6 @@ HiiFindHandles ( IN OUT UINT16 *HandleBufferLength, OUT FRAMEWORK_EFI_HII_HANDLE Handle[1] ) -/*++ - -Routine Description: - Determines the handles that are currently active in the database. - -Arguments: - -Returns: - ---*/ { UINT16 Count; LIST_ENTRY *Link; @@ -344,24 +349,30 @@ LangCodes3066To639 ( return EFI_SUCCESS; } +/** + Allows a program to determine the primary languages that are supported on a given handle. + + This routine is intended to be used by drivers to query the interface database for supported languages. + This routine returns a string of concatenated 3-byte language identifiers, one per string package associated with the handle. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param Handle The handle on which the strings reside. Type EFI_HII_HANDLE is defined in EFI_HII_PROTOCOL.NewPack() + in the Packages section. + @param LanguageString A string allocated by GetPrimaryLanguages() that contains a list of all primary languages + registered on the handle. The routine will not return the three-spaces language identifier used in + other functions to indicate non-language-specific strings. + + @reval EFI_SUCCESS LanguageString was correctly returned. + + @reval EFI_INVALID_PARAMETER The Handle was unknown. +**/ EFI_STATUS EFIAPI HiiGetPrimaryLanguages ( - IN EFI_HII_PROTOCOL *This, - IN FRAMEWORK_EFI_HII_HANDLE Handle, - OUT EFI_STRING *LanguageString + IN EFI_HII_PROTOCOL *This, + IN FRAMEWORK_EFI_HII_HANDLE Handle, + OUT EFI_STRING *LanguageString ) -/*++ - -Routine Description: - - This function allows a program to determine what the primary languages that are supported on a given handle. - -Arguments: - -Returns: - ---*/ { HII_THUNK_PRIVATE_DATA *Private; EFI_HII_HANDLE UefiHiiHandle; @@ -404,13 +415,34 @@ Returns: Done: FreePool (LangCodes3066); - SafeFreePool (LangCodes639); + if (LangCodes639 != NULL) { + FreePool (LangCodes639); + } return Status; } +/** + Allows a program to determine which secondary languages are supported on a given handle for a given primary language + This routine is intended to be used by drivers to query the interface database for supported languages. + This routine returns a string of concatenated 3-byte language identifiers, one per string package associated with the handle. + + @param This A pointer to the EFI_HII_PROTOCOL instance. + @param Handle The handle on which the strings reside. Type EFI_HII_HANDLE is defined in EFI_HII_PROTOCOL.NewPack() + in the Packages section. + @param PrimaryLanguage Pointer to a NULL-terminated string containing a single ISO 639-2 language identifier, indicating + the primary language. + @param LanguageString A string allocated by GetSecondaryLanguages() containing a list of all secondary languages registered + on the handle. The routine will not return the three-spaces language identifier used in other functions + to indicate non-language-specific strings, nor will it return the primary language. This function succeeds + but returns a NULL LanguageString if there are no secondary languages associated with the input Handle and + PrimaryLanguage pair. Type EFI_STRING is defined in String. + + @reval EFI_SUCCESS LanguageString was correctly returned. + @reval EFI_INVALID_PARAMETER The Handle was unknown. +**/ EFI_STATUS EFIAPI HiiGetSecondaryLanguages ( @@ -419,18 +451,6 @@ HiiGetSecondaryLanguages ( IN CHAR16 *PrimaryLanguage, OUT EFI_STRING *LanguageString ) -/*++ - -Routine Description: - - This function allows a program to determine which secondary languages are supported - on a given handle for a given primary language. - - Arguments: - -Returns: - ---*/ { HII_THUNK_PRIVATE_DATA *Private; EFI_HII_HANDLE UefiHiiHandle; @@ -487,11 +507,18 @@ Returns: *LanguageString = AsciiStrToUnicodeStr (SecLangCodes639, UnicodeSecLangCodes639); Done: - - SafeFreePool (PrimaryLang639); - SafeFreePool (SecLangCodes639); - SafeFreePool (SecLangCodes3066); - SafeFreePool (UnicodeSecLangCodes639); + if (PrimaryLang639 != NULL) { + FreePool (PrimaryLang639); + } + if (SecLangCodes639 != NULL) { + FreePool (SecLangCodes639); + } + if (SecLangCodes3066 != NULL) { + FreePool (SecLangCodes3066); + } + if (UnicodeSecLangCodes639 != NULL) { + FreePool (UnicodeSecLangCodes639); + } return Status; }