2008-04-03 12:36:52 +02:00
|
|
|
/**@file
|
2008-04-14 08:57:09 +02:00
|
|
|
Framework to UEFI 2.1 HII Thunk. The driver consume UEFI HII protocols
|
|
|
|
to produce a Framework HII protocol.
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-04-14 08:57:09 +02:00
|
|
|
Copyright (c) 2008, Intel Corporation
|
2008-04-03 12:36:52 +02:00
|
|
|
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
|
|
|
|
http://opensource.org/licenses/bsd-license.php
|
|
|
|
|
|
|
|
THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
|
|
|
|
|
|
|
|
**/
|
|
|
|
|
|
|
|
#include "HiiDatabase.h"
|
2008-08-20 16:17:24 +02:00
|
|
|
#include "HiiHandle.h"
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
HII_THUNK_PRIVATE_DATA *mHiiThunkPrivateData;
|
|
|
|
|
|
|
|
HII_THUNK_PRIVATE_DATA mHiiThunkPrivateDataTempate = {
|
|
|
|
HII_THUNK_PRIVATE_DATA_SIGNATURE,
|
|
|
|
(EFI_HANDLE) NULL,
|
|
|
|
{
|
2008-04-03 12:36:52 +02:00
|
|
|
HiiNewPack,
|
|
|
|
HiiRemovePack,
|
|
|
|
HiiFindHandles,
|
|
|
|
HiiExportDatabase,
|
|
|
|
|
|
|
|
HiiTestString,
|
|
|
|
HiiGetGlyph,
|
|
|
|
HiiGlyphToBlt,
|
|
|
|
|
|
|
|
HiiNewString,
|
|
|
|
HiiGetPrimaryLanguages,
|
|
|
|
HiiGetSecondaryLanguages,
|
2009-04-14 03:57:26 +02:00
|
|
|
HiiThunkGetString,
|
2008-04-03 12:36:52 +02:00
|
|
|
HiiResetStrings,
|
|
|
|
HiiGetLine,
|
|
|
|
HiiGetForms,
|
|
|
|
HiiGetDefaultImage,
|
2009-04-14 03:57:26 +02:00
|
|
|
HiiThunkUpdateForm,
|
2008-04-03 12:36:52 +02:00
|
|
|
|
|
|
|
HiiGetKeyboardLayout
|
|
|
|
},
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
{
|
2008-08-21 09:56:01 +02:00
|
|
|
///
|
|
|
|
/// HiiHandleLinkList
|
|
|
|
///
|
|
|
|
NULL, NULL
|
2008-04-03 12:36:52 +02:00
|
|
|
},
|
|
|
|
};
|
|
|
|
|
2008-06-05 08:19:12 +02:00
|
|
|
EFI_FORMBROWSER_THUNK_PRIVATE_DATA mBrowserThunkPrivateDataTemplate = {
|
|
|
|
EFI_FORMBROWSER_THUNK_PRIVATE_DATA_SIGNATURE,
|
|
|
|
(EFI_HANDLE) NULL,
|
2008-08-18 07:56:23 +02:00
|
|
|
(HII_THUNK_PRIVATE_DATA *) NULL,
|
2008-06-05 08:19:12 +02:00
|
|
|
{
|
|
|
|
ThunkSendForm,
|
|
|
|
ThunkCreatePopUp
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2008-04-24 09:08:46 +02:00
|
|
|
CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;
|
|
|
|
CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol;
|
|
|
|
CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol;
|
2008-08-19 12:44:50 +02:00
|
|
|
CONST EFI_HII_FONT_PROTOCOL *mHiiFontProtocol;
|
2008-04-24 09:08:46 +02:00
|
|
|
CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol;
|
2008-08-18 07:56:23 +02:00
|
|
|
CONST EFI_FORM_BROWSER2_PROTOCOL *mFormBrowser2Protocol;
|
2008-04-16 09:36:51 +02:00
|
|
|
|
2008-05-07 10:49:04 +02:00
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
/**
|
|
|
|
This routine initializes the HII Database.
|
|
|
|
|
|
|
|
@param ImageHandle Image handle for PCD DXE driver.
|
|
|
|
@param SystemTable Pointer to SystemTable.
|
2008-05-07 10:49:04 +02:00
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
@retval EFI_SUCCESS The entry point alwasy return successfully.
|
|
|
|
**/
|
2008-04-03 12:36:52 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
InitializeHiiDatabase (
|
|
|
|
IN EFI_HANDLE ImageHandle,
|
|
|
|
IN EFI_SYSTEM_TABLE *SystemTable
|
|
|
|
)
|
|
|
|
{
|
2008-08-18 07:56:23 +02:00
|
|
|
HII_THUNK_PRIVATE_DATA *Private;
|
|
|
|
EFI_HANDLE Handle;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
UINTN BufferLength;
|
|
|
|
EFI_HII_HANDLE *Buffer;
|
|
|
|
UINTN Index;
|
2008-08-20 16:17:24 +02:00
|
|
|
HII_THUNK_CONTEXT *ThunkContext;
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-09-03 12:47:00 +02:00
|
|
|
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiCompatibilityProtocolGuid);
|
|
|
|
ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiFormBrowserCompatibilityProtocolGuid);
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
Private = AllocateCopyPool (sizeof (HII_THUNK_PRIVATE_DATA), &mHiiThunkPrivateDataTempate);
|
|
|
|
ASSERT (Private != NULL);
|
|
|
|
InitializeListHead (&Private->ThunkContextListHead);
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-20 16:17:24 +02:00
|
|
|
InitHiiHandleDatabase ();
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
mHiiThunkPrivateData = Private;
|
2008-05-07 10:49:04 +02:00
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
Status = gBS->LocateProtocol (
|
|
|
|
&gEfiHiiDatabaseProtocolGuid,
|
|
|
|
NULL,
|
2008-04-24 09:08:46 +02:00
|
|
|
(VOID **) &mHiiDatabase
|
2008-04-03 12:36:52 +02:00
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
Status = gBS->LocateProtocol (
|
2008-08-18 07:56:23 +02:00
|
|
|
&gEfiHiiStringProtocolGuid,
|
2008-04-03 12:36:52 +02:00
|
|
|
NULL,
|
2008-08-18 07:56:23 +02:00
|
|
|
(VOID **) &mHiiStringProtocol
|
2008-04-03 12:36:52 +02:00
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2008-08-19 12:44:50 +02:00
|
|
|
Status = gBS->LocateProtocol (
|
|
|
|
&gEfiHiiFontProtocolGuid,
|
|
|
|
NULL,
|
|
|
|
(VOID **) &mHiiFontProtocol
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
Status = gBS->LocateProtocol (
|
2008-08-18 07:56:23 +02:00
|
|
|
&gEfiHiiConfigRoutingProtocolGuid,
|
2008-04-03 12:36:52 +02:00
|
|
|
NULL,
|
2008-08-18 07:56:23 +02:00
|
|
|
(VOID **) &mHiiConfigRoutingProtocol
|
2008-04-03 12:36:52 +02:00
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
|
2008-04-16 09:36:51 +02:00
|
|
|
Status = gBS->LocateProtocol (
|
2008-08-18 07:56:23 +02:00
|
|
|
&gEfiFormBrowser2ProtocolGuid,
|
2008-04-16 09:36:51 +02:00
|
|
|
NULL,
|
2008-08-18 07:56:23 +02:00
|
|
|
(VOID **) &mFormBrowser2Protocol
|
2008-04-16 09:36:51 +02:00
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
//
|
|
|
|
// Install protocol interface
|
|
|
|
//
|
|
|
|
Status = gBS->InstallProtocolInterface (
|
2008-08-18 07:56:23 +02:00
|
|
|
&Private->Handle,
|
2008-09-03 12:47:00 +02:00
|
|
|
&gEfiHiiCompatibilityProtocolGuid,
|
2008-04-03 12:36:52 +02:00
|
|
|
EFI_NATIVE_INTERFACE,
|
2008-08-18 07:56:23 +02:00
|
|
|
(VOID *) &Private->Hii
|
2008-04-03 12:36:52 +02:00
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2009-04-14 12:47:19 +02:00
|
|
|
Status = ListPackageLists (EFI_HII_PACKAGE_STRINGS, NULL, &BufferLength, &Buffer);
|
2008-08-18 07:56:23 +02:00
|
|
|
if (Status == EFI_SUCCESS) {
|
|
|
|
for (Index = 0; Index < BufferLength / sizeof (EFI_HII_HANDLE); Index++) {
|
2008-08-20 16:17:24 +02:00
|
|
|
ThunkContext = CreateThunkContextForUefiHiiHandle (Buffer[Index]);
|
|
|
|
ASSERT (ThunkContext!= NULL);
|
|
|
|
|
|
|
|
InsertTailList (&Private->ThunkContextListHead, &ThunkContext->Link);
|
2008-08-18 07:56:23 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
FreePool (Buffer);
|
|
|
|
}
|
2008-05-07 10:49:04 +02:00
|
|
|
|
|
|
|
Status = mHiiDatabase->RegisterPackageNotify (
|
|
|
|
mHiiDatabase,
|
|
|
|
EFI_HII_PACKAGE_STRINGS,
|
|
|
|
NULL,
|
2008-08-18 07:56:23 +02:00
|
|
|
NewOrAddPackNotify,
|
2008-05-07 10:49:04 +02:00
|
|
|
EFI_HII_DATABASE_NOTIFY_NEW_PACK,
|
2008-08-18 07:56:23 +02:00
|
|
|
&Handle
|
2008-05-07 10:49:04 +02:00
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
Status = mHiiDatabase->RegisterPackageNotify (
|
|
|
|
mHiiDatabase,
|
|
|
|
EFI_HII_PACKAGE_STRINGS,
|
|
|
|
NULL,
|
2008-08-18 07:56:23 +02:00
|
|
|
NewOrAddPackNotify,
|
|
|
|
EFI_HII_DATABASE_NOTIFY_ADD_PACK,
|
|
|
|
&Handle
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
Status = mHiiDatabase->RegisterPackageNotify (
|
|
|
|
mHiiDatabase,
|
2008-11-04 15:47:21 +01:00
|
|
|
EFI_HII_PACKAGE_FORMS,
|
2008-08-18 07:56:23 +02:00
|
|
|
NULL,
|
|
|
|
NewOrAddPackNotify,
|
|
|
|
EFI_HII_DATABASE_NOTIFY_NEW_PACK,
|
|
|
|
&Handle
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
Status = mHiiDatabase->RegisterPackageNotify (
|
|
|
|
mHiiDatabase,
|
2008-11-04 15:47:21 +01:00
|
|
|
EFI_HII_PACKAGE_FORMS,
|
2008-08-18 07:56:23 +02:00
|
|
|
NULL,
|
|
|
|
NewOrAddPackNotify,
|
2008-05-07 10:49:04 +02:00
|
|
|
EFI_HII_DATABASE_NOTIFY_ADD_PACK,
|
2008-08-18 07:56:23 +02:00
|
|
|
&Handle
|
2008-05-07 10:49:04 +02:00
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
|
|
|
Status = mHiiDatabase->RegisterPackageNotify (
|
|
|
|
mHiiDatabase,
|
|
|
|
EFI_HII_PACKAGE_STRINGS,
|
|
|
|
NULL,
|
|
|
|
RemovePackNotify,
|
|
|
|
EFI_HII_DATABASE_NOTIFY_REMOVE_PACK,
|
2008-08-18 07:56:23 +02:00
|
|
|
&Handle
|
2008-05-07 10:49:04 +02:00
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2008-12-17 07:41:02 +01:00
|
|
|
InitSetBrowserStrings ();
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
mBrowserThunkPrivateDataTemplate.ThunkPrivate = Private;
|
2008-06-05 08:19:12 +02:00
|
|
|
Status = gBS->InstallProtocolInterface (
|
|
|
|
&mBrowserThunkPrivateDataTemplate.Handle,
|
2008-09-03 12:47:00 +02:00
|
|
|
&gEfiFormBrowserCompatibilityProtocolGuid,
|
2008-06-05 08:19:12 +02:00
|
|
|
EFI_NATIVE_INTERFACE,
|
|
|
|
(VOID *) &mBrowserThunkPrivateDataTemplate.FormBrowser
|
|
|
|
);
|
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
|
2008-04-03 12:36:52 +02:00
|
|
|
return Status;
|
|
|
|
}
|
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
**/
|
2008-04-03 12:36:52 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
HiiFindHandles (
|
|
|
|
IN EFI_HII_PROTOCOL *This,
|
|
|
|
IN OUT UINT16 *HandleBufferLength,
|
|
|
|
OUT FRAMEWORK_EFI_HII_HANDLE Handle[1]
|
|
|
|
)
|
|
|
|
{
|
2008-05-07 10:49:04 +02:00
|
|
|
UINT16 Count;
|
2008-08-18 07:56:23 +02:00
|
|
|
LIST_ENTRY *Link;
|
|
|
|
HII_THUNK_CONTEXT *ThunkContext;
|
|
|
|
HII_THUNK_PRIVATE_DATA *Private;
|
2008-05-07 10:49:04 +02:00
|
|
|
|
|
|
|
if (HandleBufferLength == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
|
2008-05-07 10:49:04 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
//
|
|
|
|
// Count the number of handles.
|
|
|
|
//
|
2008-05-07 10:49:04 +02:00
|
|
|
Count = 0;
|
2008-08-18 07:56:23 +02:00
|
|
|
Link = GetFirstNode (&Private->ThunkContextListHead);
|
|
|
|
while (!IsNull (&Private->ThunkContextListHead, Link)) {
|
2008-05-07 10:49:04 +02:00
|
|
|
Count++;
|
2008-08-18 07:56:23 +02:00
|
|
|
Link = GetNextNode (&Private->ThunkContextListHead, Link);
|
2008-05-07 10:49:04 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (Count > *HandleBufferLength) {
|
2008-11-27 03:22:59 +01:00
|
|
|
*HandleBufferLength = (UINT16) (Count * sizeof (FRAMEWORK_EFI_HII_HANDLE));
|
2008-05-07 10:49:04 +02:00
|
|
|
return EFI_BUFFER_TOO_SMALL;
|
|
|
|
}
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
//
|
|
|
|
// Output the handles.
|
|
|
|
//
|
2008-05-07 10:49:04 +02:00
|
|
|
Count = 0;
|
2008-08-18 07:56:23 +02:00
|
|
|
Link = GetFirstNode (&Private->ThunkContextListHead);
|
|
|
|
while (!IsNull (&Private->ThunkContextListHead, Link)) {
|
|
|
|
|
|
|
|
ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);
|
|
|
|
Handle[Count] = ThunkContext->FwHiiHandle;
|
2008-05-07 10:49:04 +02:00
|
|
|
|
|
|
|
Count++;
|
2008-08-18 07:56:23 +02:00
|
|
|
Link = GetNextNode (&Private->ThunkContextListHead, Link);
|
|
|
|
|
|
|
|
}
|
2008-05-07 10:49:04 +02:00
|
|
|
|
2008-11-27 03:22:59 +01:00
|
|
|
*HandleBufferLength = (UINT16) (Count * sizeof (FRAMEWORK_EFI_HII_HANDLE));
|
2008-04-03 12:36:52 +02:00
|
|
|
return EFI_SUCCESS;
|
|
|
|
}
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
EFI_STATUS
|
2009-04-30 09:01:55 +02:00
|
|
|
LangCodes4646To639 (
|
|
|
|
IN CHAR8 *LangCodes4646,
|
2008-08-18 07:56:23 +02:00
|
|
|
IN CHAR8 **LangCodes639
|
|
|
|
)
|
|
|
|
{
|
|
|
|
CHAR8 *AsciiLangCodes;
|
2009-03-27 04:24:58 +01:00
|
|
|
CHAR8 *Lang;
|
2008-08-18 07:56:23 +02:00
|
|
|
UINTN Index;
|
|
|
|
UINTN Count;
|
|
|
|
EFI_STATUS Status;
|
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
ASSERT (LangCodes4646 != NULL);
|
2008-08-18 07:56:23 +02:00
|
|
|
ASSERT (LangCodes639 != NULL);
|
|
|
|
|
2009-03-27 04:24:58 +01:00
|
|
|
//
|
2009-04-30 09:01:55 +02:00
|
|
|
// Allocate working buffer to contain substring of LangCodes4646.
|
2009-03-27 04:24:58 +01:00
|
|
|
//
|
2009-04-30 09:01:55 +02:00
|
|
|
Lang = AllocatePool (AsciiStrSize (LangCodes4646));
|
2009-04-01 05:04:24 +02:00
|
|
|
if (Lang == NULL) {
|
2009-03-27 04:24:58 +01:00
|
|
|
return EFI_OUT_OF_RESOURCES;
|
|
|
|
}
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
//
|
2009-04-30 09:01:55 +02:00
|
|
|
// Count the number of RFC 4646 language codes.
|
2008-08-18 07:56:23 +02:00
|
|
|
//
|
|
|
|
Index = 0;
|
2009-04-30 09:01:55 +02:00
|
|
|
AsciiLangCodes = LangCodes4646;
|
2008-08-18 07:56:23 +02:00
|
|
|
while (AsciiStrLen (AsciiLangCodes) != 0) {
|
2009-04-17 04:38:11 +02:00
|
|
|
GetNextLanguage (&AsciiLangCodes, Lang);
|
2008-08-18 07:56:23 +02:00
|
|
|
Index++;
|
|
|
|
}
|
|
|
|
|
|
|
|
Count = Index;
|
|
|
|
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//
|
|
|
|
*LangCodes639 = AllocateZeroPool (ISO_639_2_ENTRY_SIZE * Count + 1);
|
|
|
|
if (*LangCodes639 == NULL) {
|
2009-03-27 04:24:58 +01:00
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Done;
|
2008-08-18 07:56:23 +02:00
|
|
|
}
|
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
AsciiLangCodes = LangCodes4646;
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
for (Index = 0; Index < Count; Index++) {
|
2009-04-17 04:38:11 +02:00
|
|
|
GetNextLanguage (&AsciiLangCodes, Lang);
|
2009-04-30 09:01:55 +02:00
|
|
|
Status = ConvertRfc4646LanguageToIso639Language (Lang, *LangCodes639 + Index * ISO_639_2_ENTRY_SIZE);
|
2008-08-18 07:56:23 +02:00
|
|
|
ASSERT_EFI_ERROR (Status);
|
|
|
|
}
|
|
|
|
|
2009-03-27 04:24:58 +01:00
|
|
|
Status = EFI_SUCCESS;
|
|
|
|
|
|
|
|
Done:
|
|
|
|
FreePool (Lang);
|
|
|
|
return Status;
|
2008-08-18 07:56:23 +02:00
|
|
|
}
|
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
/**
|
|
|
|
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.
|
|
|
|
**/
|
2008-04-03 12:36:52 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
HiiGetPrimaryLanguages (
|
2008-11-26 12:02:31 +01:00
|
|
|
IN EFI_HII_PROTOCOL *This,
|
|
|
|
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
|
|
OUT EFI_STRING *LanguageString
|
2008-04-03 12:36:52 +02:00
|
|
|
)
|
|
|
|
{
|
2008-08-18 07:56:23 +02:00
|
|
|
HII_THUNK_PRIVATE_DATA *Private;
|
2008-04-14 08:57:09 +02:00
|
|
|
EFI_HII_HANDLE UefiHiiHandle;
|
2009-04-30 09:01:55 +02:00
|
|
|
CHAR8 *LangCodes4646;
|
2008-08-18 07:56:23 +02:00
|
|
|
CHAR16 *UnicodeLangCodes639;
|
|
|
|
CHAR8 *LangCodes639;
|
|
|
|
EFI_STATUS Status;
|
2008-04-14 08:57:09 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
|
2008-04-14 08:57:09 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);
|
2008-04-14 08:57:09 +02:00
|
|
|
if (UefiHiiHandle == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
LangCodes4646 = HiiGetSupportedLanguages (UefiHiiHandle);
|
2008-04-14 08:57:09 +02:00
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
if (LangCodes4646 == NULL) {
|
2008-04-14 08:57:09 +02:00
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
LangCodes639 = NULL;
|
2009-04-30 09:01:55 +02:00
|
|
|
Status = LangCodes4646To639 (LangCodes4646, &LangCodes639);
|
2008-08-18 07:56:23 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
UnicodeLangCodes639 = AllocateZeroPool (AsciiStrSize (LangCodes639) * sizeof (CHAR16));
|
|
|
|
if (UnicodeLangCodes639 == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Done;
|
2008-04-14 08:57:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2008-08-18 07:56:23 +02:00
|
|
|
// The language returned is in RFC 639-2 format.
|
2008-04-14 08:57:09 +02:00
|
|
|
//
|
2008-08-18 07:56:23 +02:00
|
|
|
AsciiStrToUnicodeStr (LangCodes639, UnicodeLangCodes639);
|
|
|
|
*LanguageString = UnicodeLangCodes639;
|
2008-04-14 08:57:09 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
Done:
|
2009-04-30 09:01:55 +02:00
|
|
|
FreePool (LangCodes4646);
|
2008-10-30 09:00:56 +01:00
|
|
|
if (LangCodes639 != NULL) {
|
|
|
|
FreePool (LangCodes639);
|
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
return Status;
|
2008-04-03 12:36:52 +02:00
|
|
|
}
|
|
|
|
|
2009-04-14 12:47:19 +02:00
|
|
|
/**
|
|
|
|
This function returns the list of supported 2nd languages, in the format specified
|
|
|
|
in UEFI specification Appendix M.
|
|
|
|
|
|
|
|
If HiiHandle is not a valid Handle in the HII database, then ASSERT.
|
|
|
|
If not enough resource to complete the operation, then ASSERT.
|
|
|
|
|
|
|
|
@param HiiHandle The HII package list handle.
|
|
|
|
@param FirstLanguage Pointer to language name buffer.
|
|
|
|
|
|
|
|
@return The supported languages.
|
|
|
|
|
|
|
|
**/
|
|
|
|
CHAR8 *
|
|
|
|
EFIAPI
|
|
|
|
HiiGetSupportedSecondaryLanguages (
|
|
|
|
IN EFI_HII_HANDLE HiiHandle,
|
|
|
|
IN CONST CHAR8 *FirstLanguage
|
|
|
|
)
|
|
|
|
{
|
|
|
|
EFI_STATUS Status;
|
|
|
|
UINTN BufferSize;
|
|
|
|
CHAR8 *LanguageString;
|
|
|
|
|
|
|
|
ASSERT (HiiHandle != NULL);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Collect current supported 2nd Languages for given HII handle
|
|
|
|
// First try allocate 4K buffer to store the current supported 2nd languages.
|
|
|
|
//
|
|
|
|
BufferSize = 0x1000;
|
|
|
|
LanguageString = AllocateZeroPool (BufferSize);
|
|
|
|
if (LanguageString == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = mHiiStringProtocol->GetSecondaryLanguages (mHiiStringProtocol, HiiHandle, FirstLanguage, LanguageString, &BufferSize);
|
|
|
|
ASSERT (Status != EFI_NOT_FOUND);
|
|
|
|
|
|
|
|
if (Status == EFI_BUFFER_TOO_SMALL) {
|
|
|
|
FreePool (LanguageString);
|
|
|
|
LanguageString = AllocateZeroPool (BufferSize);
|
|
|
|
if (LanguageString == NULL) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
Status = mHiiStringProtocol->GetSecondaryLanguages (mHiiStringProtocol, HiiHandle, FirstLanguage, LanguageString, &BufferSize);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
LanguageString = NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
return LanguageString;
|
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
/**
|
|
|
|
Allows a program to determine which secondary languages are supported on a given handle for a given primary language
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2008-11-26 12:02:31 +01:00
|
|
|
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.
|
|
|
|
**/
|
2008-04-03 12:36:52 +02:00
|
|
|
EFI_STATUS
|
|
|
|
EFIAPI
|
|
|
|
HiiGetSecondaryLanguages (
|
2008-08-18 07:56:23 +02:00
|
|
|
IN EFI_HII_PROTOCOL *This,
|
|
|
|
IN FRAMEWORK_EFI_HII_HANDLE Handle,
|
|
|
|
IN CHAR16 *PrimaryLanguage,
|
|
|
|
OUT EFI_STRING *LanguageString
|
2008-04-03 12:36:52 +02:00
|
|
|
)
|
|
|
|
{
|
2009-03-27 04:24:58 +01:00
|
|
|
HII_THUNK_PRIVATE_DATA *Private;
|
2008-04-14 08:57:09 +02:00
|
|
|
EFI_HII_HANDLE UefiHiiHandle;
|
2009-04-30 09:01:55 +02:00
|
|
|
CHAR8 *PrimaryLang4646;
|
2008-08-18 07:56:23 +02:00
|
|
|
CHAR8 *PrimaryLang639;
|
2009-04-30 09:01:55 +02:00
|
|
|
CHAR8 *SecLangCodes4646;
|
2008-08-18 07:56:23 +02:00
|
|
|
CHAR8 *SecLangCodes639;
|
|
|
|
CHAR16 *UnicodeSecLangCodes639;
|
|
|
|
EFI_STATUS Status;
|
2008-04-14 08:57:09 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);
|
2008-04-14 08:57:09 +02:00
|
|
|
|
2009-03-27 04:24:58 +01:00
|
|
|
SecLangCodes639 = NULL;
|
2009-04-30 09:01:55 +02:00
|
|
|
SecLangCodes4646 = NULL;
|
|
|
|
PrimaryLang4646 = NULL;
|
2008-08-18 07:56:23 +02:00
|
|
|
UnicodeSecLangCodes639 = NULL;
|
|
|
|
|
|
|
|
UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);
|
2008-04-14 08:57:09 +02:00
|
|
|
if (UefiHiiHandle == NULL) {
|
|
|
|
return EFI_INVALID_PARAMETER;
|
|
|
|
}
|
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
PrimaryLang639 = AllocateZeroPool (StrLen (PrimaryLanguage) + 1);
|
|
|
|
if (PrimaryLang639 == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Done;
|
|
|
|
}
|
2008-04-14 08:57:09 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
UnicodeStrToAsciiStr (PrimaryLanguage, PrimaryLang639);
|
2008-04-14 08:57:09 +02:00
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
PrimaryLang4646 = ConvertIso639LanguageToRfc4646Language (PrimaryLang639);
|
|
|
|
ASSERT_EFI_ERROR (PrimaryLang4646 != NULL);
|
2008-04-14 08:57:09 +02:00
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
SecLangCodes4646 = HiiGetSupportedSecondaryLanguages (UefiHiiHandle, PrimaryLang4646);
|
2008-08-18 07:56:23 +02:00
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
if (SecLangCodes4646 == NULL) {
|
2008-08-18 07:56:23 +02:00
|
|
|
Status = EFI_INVALID_PARAMETER;
|
|
|
|
goto Done;
|
2008-04-14 08:57:09 +02:00
|
|
|
}
|
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
Status = LangCodes4646To639 (SecLangCodes4646, &SecLangCodes639);
|
2008-08-18 07:56:23 +02:00
|
|
|
if (EFI_ERROR (Status)) {
|
|
|
|
goto Done;
|
|
|
|
}
|
|
|
|
|
|
|
|
UnicodeSecLangCodes639 = AllocateZeroPool (AsciiStrSize (SecLangCodes639) * sizeof (CHAR16));
|
|
|
|
if (UnicodeSecLangCodes639 == NULL) {
|
|
|
|
Status = EFI_OUT_OF_RESOURCES;
|
|
|
|
goto Done;
|
2008-04-14 08:57:09 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
2009-04-30 09:01:55 +02:00
|
|
|
// The language returned is in RFC 4646 format.
|
2008-04-14 08:57:09 +02:00
|
|
|
//
|
2008-08-18 07:56:23 +02:00
|
|
|
*LanguageString = AsciiStrToUnicodeStr (SecLangCodes639, UnicodeSecLangCodes639);
|
2008-04-14 08:57:09 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
Done:
|
2008-10-30 09:00:56 +01:00
|
|
|
if (PrimaryLang639 != NULL) {
|
|
|
|
FreePool (PrimaryLang639);
|
|
|
|
}
|
2009-03-27 04:24:58 +01:00
|
|
|
|
2008-10-30 09:00:56 +01:00
|
|
|
if (SecLangCodes639 != NULL) {
|
|
|
|
FreePool (SecLangCodes639);
|
|
|
|
}
|
2009-03-27 04:24:58 +01:00
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
if (PrimaryLang4646 != NULL) {
|
|
|
|
FreePool (PrimaryLang4646);
|
2009-03-27 04:24:58 +01:00
|
|
|
}
|
|
|
|
|
2009-04-30 09:01:55 +02:00
|
|
|
if (SecLangCodes4646 != NULL) {
|
|
|
|
FreePool (SecLangCodes4646);
|
2008-10-30 09:00:56 +01:00
|
|
|
}
|
|
|
|
if (UnicodeSecLangCodes639 != NULL) {
|
|
|
|
FreePool (UnicodeSecLangCodes639);
|
|
|
|
}
|
2008-08-18 07:56:23 +02:00
|
|
|
|
|
|
|
return Status;
|
2008-06-05 08:19:12 +02:00
|
|
|
}
|
2008-04-03 12:36:52 +02:00
|
|
|
|
2008-08-18 07:56:23 +02:00
|
|
|
|