2 Framework to UEFI 2.1 HII Thunk. The driver consume UEFI HII protocols
3 to produce a Framework HII protocol.
5 Copyright (c) 2008, Intel Corporation
6 All rights reserved. This program and the accompanying materials
7 are licensed and made available under the terms and conditions of the BSD License
8 which accompanies this distribution. The full text of the license may be found at
9 http://opensource.org/licenses/bsd-license.php
11 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
12 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
16 #include "HiiDatabase.h"
19 EFI_HII_THUNK_PRIVATE_DATA HiiThunkPrivateDataTempate
= {
21 EFI_HII_THUNK_DRIVER_DATA_SIGNATURE
37 HiiGetPrimaryLanguages
,
38 HiiGetSecondaryLanguages
,
49 //The FRAMEWORK_EFI_HII_HANDLE starts from 1
50 // and increase upwords untill reach 2^(sizeof (FRAMEWORK_EFI_HII_HANDLE)) - 1.
51 // The code will assert to prevent overflow.
52 (FRAMEWORK_EFI_HII_HANDLE
) 1
55 NULL
, NULL
//HiiHandleLinkList
59 EFI_HII_DATABASE_PROTOCOL
*mUefiHiiDatabaseProtocol
;
60 EFI_HII_FONT_PROTOCOL
*mUefiHiiFontProtocol
;
61 EFI_HII_IMAGE_PROTOCOL
*mUefiHiiImageProtocol
;
62 EFI_HII_STRING_PROTOCOL
*mUefiStringProtocol
;
66 InitializeHiiDatabase (
67 IN EFI_HANDLE ImageHandle
,
68 IN EFI_SYSTEM_TABLE
*SystemTable
73 Initialize HII Database
76 (Standard EFI Image entry - EFI_IMAGE_ENTRY_POINT)
79 EFI_SUCCESS - Setup loaded.
84 EFI_HII_THUNK_PRIVATE_DATA
*HiiData
;
88 ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL
, &gEfiHiiProtocolGuid
);
90 HiiData
= AllocateCopyPool (sizeof (EFI_HII_THUNK_PRIVATE_DATA
), &HiiThunkPrivateDataTempate
);
91 ASSERT (HiiData
!= NULL
);
92 InitializeListHead (&HiiData
->HiiThunkHandleMappingDBListHead
);
94 Status
= gBS
->LocateProtocol (
95 &gEfiHiiDatabaseProtocolGuid
,
97 (VOID
**) &mUefiHiiDatabaseProtocol
99 ASSERT_EFI_ERROR (Status
);
101 Status
= gBS
->LocateProtocol (
102 &gEfiHiiFontProtocolGuid
,
104 (VOID
**) &mUefiHiiFontProtocol
106 ASSERT_EFI_ERROR (Status
);
108 Status
= gBS
->LocateProtocol (
109 &gEfiHiiImageProtocolGuid
,
111 (VOID
**) &mUefiHiiImageProtocol
113 ASSERT_EFI_ERROR (Status
);
115 Status
= gBS
->LocateProtocol (
116 &gEfiHiiStringProtocolGuid
,
118 (VOID
**) &mUefiStringProtocol
120 ASSERT_EFI_ERROR (Status
);
123 // Install protocol interface
126 Status
= gBS
->InstallProtocolInterface (
128 &gEfiHiiProtocolGuid
,
129 EFI_NATIVE_INTERFACE
,
130 (VOID
*) &HiiData
->Hii
132 ASSERT_EFI_ERROR (Status
);
140 IN EFI_HII_PROTOCOL
*This
,
141 IN OUT UINT16
*HandleBufferLength
,
142 OUT FRAMEWORK_EFI_HII_HANDLE Handle
[1]
147 Determines the handles that are currently active in the database.
161 HiiGetPrimaryLanguages (
162 IN EFI_HII_PROTOCOL
*This
,
163 IN FRAMEWORK_EFI_HII_HANDLE Handle
,
164 OUT EFI_STRING
*LanguageString
170 This function allows a program to determine what the primary languages that are supported on a given handle.
178 EFI_HII_THUNK_PRIVATE_DATA
*Private
;
179 EFI_HII_HANDLE UefiHiiHandle
;
180 CHAR8
*AsciiLanguageCodes
;
181 CHAR16
*UnicodeLanguageCodes
;
183 Private
= EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This
);
187 UefiHiiHandle
= FrameworkHiiHandleToUefiHiiHandle (Private
, Handle
);
188 if (UefiHiiHandle
== NULL
) {
189 return EFI_INVALID_PARAMETER
;
192 AsciiLanguageCodes
= HiiLibGetSupportedLanguages (UefiHiiHandle
);
194 if (AsciiLanguageCodes
== NULL
) {
195 return EFI_INVALID_PARAMETER
;
198 UnicodeLanguageCodes
= AllocateZeroPool (AsciiStrSize (AsciiLanguageCodes
) * sizeof (CHAR16
));
199 if (UnicodeLanguageCodes
== NULL
) {
200 return EFI_OUT_OF_RESOURCES
;
204 // The language returned is in RFC 3066 format.
206 *LanguageString
= AsciiStrToUnicodeStr (AsciiLanguageCodes
, UnicodeLanguageCodes
);
213 HiiGetSecondaryLanguages (
214 IN EFI_HII_PROTOCOL
*This
,
215 IN FRAMEWORK_EFI_HII_HANDLE Handle
,
216 IN CHAR16
*PrimaryLanguage
,
217 OUT EFI_STRING
*LanguageString
223 This function allows a program to determine which secondary languages are supported
224 on a given handle for a given primary language.
232 EFI_HII_THUNK_PRIVATE_DATA
*Private
;
233 EFI_HII_HANDLE UefiHiiHandle
;
234 CHAR8
*AsciiPrimaryLanguage
;
235 CHAR8
*AsciiLanguageCodes
;
236 CHAR16
*UnicodeLanguageCodes
;
238 Private
= EFI_HII_THUNK_PRIVATE_DATA_FROM_THIS(This
);
242 UefiHiiHandle
= FrameworkHiiHandleToUefiHiiHandle (Private
, Handle
);
243 if (UefiHiiHandle
== NULL
) {
244 return EFI_INVALID_PARAMETER
;
247 AsciiPrimaryLanguage
= AllocateZeroPool (StrLen (PrimaryLanguage
) + 1);
249 UnicodeStrToAsciiStr (PrimaryLanguage
, AsciiPrimaryLanguage
);
251 AsciiLanguageCodes
= HiiLibGetSupportedSecondaryLanguages (UefiHiiHandle
, AsciiPrimaryLanguage
);
253 if (AsciiLanguageCodes
== NULL
) {
254 return EFI_INVALID_PARAMETER
;
257 UnicodeLanguageCodes
= AllocateZeroPool (AsciiStrSize (AsciiLanguageCodes
) * sizeof (CHAR16
));
258 if (UnicodeLanguageCodes
== NULL
) {
259 return EFI_OUT_OF_RESOURCES
;
263 // The language returned is in RFC 3066 format.
265 *LanguageString
= AsciiStrToUnicodeStr (AsciiLanguageCodes
, UnicodeLanguageCodes
);