]>
Commit | Line | Data |
---|---|---|
26a76fbc | 1 | /** @file\r |
ee3428bb | 2 | Framework to UEFI 2.1 HII Thunk. The driver consume UEFI HII protocols\r |
3 | to produce a Framework HII protocol.\r | |
4259256b | 4 | \r |
b5f8b5b0 | 5 | Copyright (c) 2008 - 2014, Intel Corporation. All rights reserved.<BR>\r |
584d5652 | 6 | This program and the accompanying materials\r |
4259256b | 7 | are licensed and made available under the terms and conditions of the BSD License\r |
8 | which accompanies this distribution. The full text of the license may be found at\r | |
9 | http://opensource.org/licenses/bsd-license.php\r | |
10 | \r | |
11 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,\r | |
12 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.\r | |
13 | \r | |
14 | **/\r | |
15 | \r | |
16 | #include "HiiDatabase.h"\r | |
d4775f2a | 17 | #include "HiiHandle.h"\r |
4259256b | 18 | \r |
0368663f | 19 | HII_THUNK_PRIVATE_DATA *mHiiThunkPrivateData;\r |
20 | \r | |
21 | HII_THUNK_PRIVATE_DATA mHiiThunkPrivateDataTempate = {\r | |
22 | HII_THUNK_PRIVATE_DATA_SIGNATURE,\r | |
23 | (EFI_HANDLE) NULL,\r | |
24 | {\r | |
4259256b | 25 | HiiNewPack,\r |
26 | HiiRemovePack,\r | |
27 | HiiFindHandles,\r | |
28 | HiiExportDatabase,\r | |
29 | \r | |
30 | HiiTestString,\r | |
31 | HiiGetGlyph,\r | |
32 | HiiGlyphToBlt,\r | |
33 | \r | |
34 | HiiNewString,\r | |
35 | HiiGetPrimaryLanguages,\r | |
36 | HiiGetSecondaryLanguages,\r | |
cdaf7905 | 37 | HiiThunkGetString,\r |
4259256b | 38 | HiiResetStrings,\r |
39 | HiiGetLine,\r | |
40 | HiiGetForms,\r | |
41 | HiiGetDefaultImage,\r | |
cdaf7905 | 42 | HiiThunkUpdateForm,\r |
4259256b | 43 | \r |
44 | HiiGetKeyboardLayout\r | |
45 | },\r | |
0368663f | 46 | \r |
4259256b | 47 | {\r |
a3318eaf | 48 | ///\r |
49 | /// HiiHandleLinkList\r | |
50 | ///\r | |
51 | NULL, NULL \r | |
4259256b | 52 | },\r |
53 | };\r | |
54 | \r | |
137c54ac | 55 | EFI_FORMBROWSER_THUNK_PRIVATE_DATA mBrowserThunkPrivateDataTemplate = {\r |
56 | EFI_FORMBROWSER_THUNK_PRIVATE_DATA_SIGNATURE,\r | |
57 | (EFI_HANDLE) NULL,\r | |
0368663f | 58 | (HII_THUNK_PRIVATE_DATA *) NULL,\r |
137c54ac | 59 | {\r |
60 | ThunkSendForm,\r | |
61 | ThunkCreatePopUp\r | |
62 | }\r | |
63 | };\r | |
64 | \r | |
65 | \r | |
59336178 | 66 | CONST EFI_HII_DATABASE_PROTOCOL *mHiiDatabase;\r |
59336178 | 67 | CONST EFI_HII_IMAGE_PROTOCOL *mHiiImageProtocol;\r |
68 | CONST EFI_HII_STRING_PROTOCOL *mHiiStringProtocol;\r | |
133a9dfb | 69 | CONST EFI_HII_FONT_PROTOCOL *mHiiFontProtocol;\r |
59336178 | 70 | CONST EFI_HII_CONFIG_ROUTING_PROTOCOL *mHiiConfigRoutingProtocol;\r |
0368663f | 71 | CONST EFI_FORM_BROWSER2_PROTOCOL *mFormBrowser2Protocol;\r |
ebbd2793 | 72 | \r |
ea58467b | 73 | \r |
3321fa09 | 74 | /**\r |
75 | This routine initializes the HII Database.\r | |
76 | \r | |
77 | @param ImageHandle Image handle for PCD DXE driver.\r | |
78 | @param SystemTable Pointer to SystemTable.\r | |
ea58467b | 79 | \r |
3321fa09 | 80 | @retval EFI_SUCCESS The entry point alwasy return successfully.\r |
81 | **/\r | |
4259256b | 82 | EFI_STATUS\r |
83 | EFIAPI\r | |
84 | InitializeHiiDatabase (\r | |
85 | IN EFI_HANDLE ImageHandle,\r | |
86 | IN EFI_SYSTEM_TABLE *SystemTable\r | |
87 | )\r | |
4259256b | 88 | {\r |
0368663f | 89 | HII_THUNK_PRIVATE_DATA *Private;\r |
90 | EFI_HANDLE Handle;\r | |
91 | EFI_STATUS Status;\r | |
92 | UINTN BufferLength;\r | |
93 | EFI_HII_HANDLE *Buffer;\r | |
94 | UINTN Index;\r | |
d4775f2a | 95 | HII_THUNK_CONTEXT *ThunkContext;\r |
0368663f | 96 | \r |
4259256b | 97 | \r |
962045a2 | 98 | ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiHiiCompatibilityProtocolGuid);\r |
99 | ASSERT_PROTOCOL_ALREADY_INSTALLED (NULL, &gEfiFormBrowserCompatibilityProtocolGuid);\r | |
4259256b | 100 | \r |
0368663f | 101 | Private = AllocateCopyPool (sizeof (HII_THUNK_PRIVATE_DATA), &mHiiThunkPrivateDataTempate);\r |
102 | ASSERT (Private != NULL);\r | |
103 | InitializeListHead (&Private->ThunkContextListHead);\r | |
4259256b | 104 | \r |
d4775f2a | 105 | InitHiiHandleDatabase ();\r |
106 | \r | |
0368663f | 107 | mHiiThunkPrivateData = Private;\r |
ea58467b | 108 | \r |
4259256b | 109 | Status = gBS->LocateProtocol (\r |
110 | &gEfiHiiDatabaseProtocolGuid,\r | |
111 | NULL,\r | |
59336178 | 112 | (VOID **) &mHiiDatabase\r |
4259256b | 113 | );\r |
114 | ASSERT_EFI_ERROR (Status);\r | |
115 | \r | |
116 | Status = gBS->LocateProtocol (\r | |
0368663f | 117 | &gEfiHiiStringProtocolGuid,\r |
4259256b | 118 | NULL,\r |
0368663f | 119 | (VOID **) &mHiiStringProtocol\r |
4259256b | 120 | );\r |
121 | ASSERT_EFI_ERROR (Status);\r | |
122 | \r | |
133a9dfb | 123 | Status = gBS->LocateProtocol (\r |
124 | &gEfiHiiFontProtocolGuid,\r | |
125 | NULL,\r | |
126 | (VOID **) &mHiiFontProtocol\r | |
127 | );\r | |
128 | ASSERT_EFI_ERROR (Status);\r | |
129 | \r | |
4259256b | 130 | Status = gBS->LocateProtocol (\r |
0368663f | 131 | &gEfiHiiConfigRoutingProtocolGuid,\r |
4259256b | 132 | NULL,\r |
0368663f | 133 | (VOID **) &mHiiConfigRoutingProtocol\r |
4259256b | 134 | );\r |
135 | ASSERT_EFI_ERROR (Status);\r | |
136 | \r | |
4259256b | 137 | \r |
ebbd2793 | 138 | Status = gBS->LocateProtocol (\r |
0368663f | 139 | &gEfiFormBrowser2ProtocolGuid,\r |
ebbd2793 | 140 | NULL,\r |
0368663f | 141 | (VOID **) &mFormBrowser2Protocol\r |
ebbd2793 | 142 | );\r |
143 | ASSERT_EFI_ERROR (Status);\r | |
144 | \r | |
0368663f | 145 | \r |
146 | \r | |
147 | \r | |
4259256b | 148 | //\r |
149 | // Install protocol interface\r | |
150 | //\r | |
4259256b | 151 | Status = gBS->InstallProtocolInterface (\r |
0368663f | 152 | &Private->Handle,\r |
962045a2 | 153 | &gEfiHiiCompatibilityProtocolGuid,\r |
4259256b | 154 | EFI_NATIVE_INTERFACE,\r |
0368663f | 155 | (VOID *) &Private->Hii\r |
4259256b | 156 | );\r |
157 | ASSERT_EFI_ERROR (Status);\r | |
158 | \r | |
cb7d01c0 | 159 | Status = ListPackageLists (EFI_HII_PACKAGE_STRINGS, NULL, &BufferLength, &Buffer);\r |
0368663f | 160 | if (Status == EFI_SUCCESS) {\r |
b5f8b5b0 | 161 | ASSERT (Buffer != NULL);\r |
0368663f | 162 | for (Index = 0; Index < BufferLength / sizeof (EFI_HII_HANDLE); Index++) {\r |
d4775f2a | 163 | ThunkContext = CreateThunkContextForUefiHiiHandle (Buffer[Index]);\r |
164 | ASSERT (ThunkContext!= NULL);\r | |
165 | \r | |
166 | InsertTailList (&Private->ThunkContextListHead, &ThunkContext->Link);\r | |
0368663f | 167 | }\r |
168 | \r | |
169 | FreePool (Buffer);\r | |
170 | }\r | |
ea58467b | 171 | \r |
172 | Status = mHiiDatabase->RegisterPackageNotify (\r | |
173 | mHiiDatabase,\r | |
174 | EFI_HII_PACKAGE_STRINGS,\r | |
175 | NULL,\r | |
0368663f | 176 | NewOrAddPackNotify,\r |
ea58467b | 177 | EFI_HII_DATABASE_NOTIFY_NEW_PACK,\r |
0368663f | 178 | &Handle\r |
ea58467b | 179 | );\r |
180 | ASSERT_EFI_ERROR (Status);\r | |
181 | \r | |
182 | Status = mHiiDatabase->RegisterPackageNotify (\r | |
183 | mHiiDatabase,\r | |
184 | EFI_HII_PACKAGE_STRINGS,\r | |
185 | NULL,\r | |
0368663f | 186 | NewOrAddPackNotify,\r |
187 | EFI_HII_DATABASE_NOTIFY_ADD_PACK,\r | |
188 | &Handle\r | |
189 | );\r | |
190 | ASSERT_EFI_ERROR (Status);\r | |
191 | \r | |
192 | Status = mHiiDatabase->RegisterPackageNotify (\r | |
193 | mHiiDatabase,\r | |
4dd76ade | 194 | EFI_HII_PACKAGE_FORMS,\r |
0368663f | 195 | NULL,\r |
196 | NewOrAddPackNotify,\r | |
197 | EFI_HII_DATABASE_NOTIFY_NEW_PACK,\r | |
198 | &Handle\r | |
199 | );\r | |
200 | ASSERT_EFI_ERROR (Status);\r | |
201 | \r | |
202 | Status = mHiiDatabase->RegisterPackageNotify (\r | |
203 | mHiiDatabase,\r | |
4dd76ade | 204 | EFI_HII_PACKAGE_FORMS,\r |
0368663f | 205 | NULL,\r |
206 | NewOrAddPackNotify,\r | |
ea58467b | 207 | EFI_HII_DATABASE_NOTIFY_ADD_PACK,\r |
0368663f | 208 | &Handle\r |
ea58467b | 209 | );\r |
210 | ASSERT_EFI_ERROR (Status);\r | |
211 | \r | |
212 | Status = mHiiDatabase->RegisterPackageNotify (\r | |
213 | mHiiDatabase,\r | |
214 | EFI_HII_PACKAGE_STRINGS,\r | |
215 | NULL,\r | |
216 | RemovePackNotify,\r | |
217 | EFI_HII_DATABASE_NOTIFY_REMOVE_PACK,\r | |
0368663f | 218 | &Handle\r |
ea58467b | 219 | );\r |
220 | ASSERT_EFI_ERROR (Status);\r | |
221 | \r | |
a235abd2 | 222 | InitSetBrowserStrings ();\r |
223 | \r | |
0368663f | 224 | mBrowserThunkPrivateDataTemplate.ThunkPrivate = Private;\r |
137c54ac | 225 | Status = gBS->InstallProtocolInterface (\r |
226 | &mBrowserThunkPrivateDataTemplate.Handle,\r | |
962045a2 | 227 | &gEfiFormBrowserCompatibilityProtocolGuid,\r |
137c54ac | 228 | EFI_NATIVE_INTERFACE,\r |
229 | (VOID *) &mBrowserThunkPrivateDataTemplate.FormBrowser\r | |
230 | );\r | |
231 | ASSERT_EFI_ERROR (Status);\r | |
232 | \r | |
4259256b | 233 | return Status;\r |
234 | }\r | |
235 | \r | |
3321fa09 | 236 | /**\r |
237 | Determines the handles that are currently active in the database.\r | |
238 | \r | |
239 | This function determines the handles that are currently active in the database. \r | |
240 | For example, a program wishing to create a Setup-like configuration utility would use this call \r | |
241 | to determine the handles that are available. It would then use calls defined in the forms section \r | |
242 | below to extract forms and then interpret them.\r | |
243 | \r | |
244 | @param This A pointer to the EFI_HII_PROTOCOL instance.\r | |
245 | @param HandleBufferLength On input, a pointer to the length of the handle buffer. \r | |
246 | On output, the length of the handle buffer that is required for the handles found.\r | |
234980f6 | 247 | @param Handle Pointer to an array of EFI_HII_HANDLE instances returned. \r |
3321fa09 | 248 | Type EFI_HII_HANDLE is defined in EFI_HII_PROTOCOL.NewPack() in the Packages section.\r |
249 | \r | |
250 | @retval EFI_SUCCESS Handle was updated successfully.\r | |
251 | \r | |
252 | @retval EFI_BUFFER_TOO_SMALL The HandleBufferLength parameter indicates that Handle is too small \r | |
253 | to support the number of handles. HandleBufferLength is updated with a value that \r | |
254 | will enable the data to fit.\r | |
255 | **/\r | |
4259256b | 256 | EFI_STATUS\r |
257 | EFIAPI\r | |
258 | HiiFindHandles (\r | |
259 | IN EFI_HII_PROTOCOL *This,\r | |
260 | IN OUT UINT16 *HandleBufferLength,\r | |
234980f6 | 261 | OUT FRAMEWORK_EFI_HII_HANDLE *Handle\r |
4259256b | 262 | )\r |
4259256b | 263 | {\r |
234980f6 LG |
264 | UINT16 Count;\r |
265 | LIST_ENTRY *Link;\r | |
266 | HII_THUNK_CONTEXT *ThunkContext;\r | |
267 | HII_THUNK_PRIVATE_DATA *Private;\r | |
ea58467b | 268 | \r |
269 | if (HandleBufferLength == NULL) {\r | |
270 | return EFI_INVALID_PARAMETER;\r | |
271 | }\r | |
272 | \r | |
0368663f | 273 | Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This); \r |
ea58467b | 274 | \r |
0368663f | 275 | //\r |
276 | // Count the number of handles.\r | |
277 | //\r | |
ea58467b | 278 | Count = 0;\r |
0368663f | 279 | Link = GetFirstNode (&Private->ThunkContextListHead);\r |
280 | while (!IsNull (&Private->ThunkContextListHead, Link)) {\r | |
ea58467b | 281 | Count++;\r |
0368663f | 282 | Link = GetNextNode (&Private->ThunkContextListHead, Link);\r |
ea58467b | 283 | }\r |
284 | \r | |
285 | if (Count > *HandleBufferLength) {\r | |
5990ace9 | 286 | *HandleBufferLength = (UINT16) (Count * sizeof (FRAMEWORK_EFI_HII_HANDLE));\r |
ea58467b | 287 | return EFI_BUFFER_TOO_SMALL;\r |
288 | }\r | |
289 | \r | |
0368663f | 290 | //\r |
291 | // Output the handles.\r | |
292 | //\r | |
ea58467b | 293 | Count = 0;\r |
0368663f | 294 | Link = GetFirstNode (&Private->ThunkContextListHead);\r |
295 | while (!IsNull (&Private->ThunkContextListHead, Link)) {\r | |
296 | \r | |
297 | ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);\r | |
298 | Handle[Count] = ThunkContext->FwHiiHandle;\r | |
ea58467b | 299 | \r |
ea58467b | 300 | Count++;\r |
0368663f | 301 | Link = GetNextNode (&Private->ThunkContextListHead, Link);\r |
302 | \r | |
303 | }\r | |
ea58467b | 304 | \r |
5990ace9 | 305 | *HandleBufferLength = (UINT16) (Count * sizeof (FRAMEWORK_EFI_HII_HANDLE));\r |
4259256b | 306 | return EFI_SUCCESS;\r |
307 | }\r | |
308 | \r | |
3321fa09 | 309 | /**\r |
310 | Allows a program to determine the primary languages that are supported on a given handle.\r | |
311 | \r | |
312 | This routine is intended to be used by drivers to query the interface database for supported languages. \r | |
313 | This routine returns a string of concatenated 3-byte language identifiers, one per string package associated with the handle.\r | |
314 | \r | |
315 | @param This A pointer to the EFI_HII_PROTOCOL instance.\r | |
316 | @param Handle The handle on which the strings reside. Type EFI_HII_HANDLE is defined in EFI_HII_PROTOCOL.NewPack() \r | |
317 | in the Packages section.\r | |
318 | @param LanguageString A string allocated by GetPrimaryLanguages() that contains a list of all primary languages \r | |
319 | registered on the handle. The routine will not return the three-spaces language identifier used in \r | |
320 | other functions to indicate non-language-specific strings.\r | |
321 | \r | |
26a76fbc | 322 | @retval EFI_SUCCESS LanguageString was correctly returned.\r |
3321fa09 | 323 | \r |
26a76fbc | 324 | @retval EFI_INVALID_PARAMETER The Handle was unknown.\r |
3321fa09 | 325 | **/\r |
4259256b | 326 | EFI_STATUS\r |
327 | EFIAPI\r | |
328 | HiiGetPrimaryLanguages (\r | |
3321fa09 | 329 | IN EFI_HII_PROTOCOL *This,\r |
330 | IN FRAMEWORK_EFI_HII_HANDLE Handle,\r | |
331 | OUT EFI_STRING *LanguageString\r | |
4259256b | 332 | )\r |
4259256b | 333 | {\r |
0368663f | 334 | HII_THUNK_PRIVATE_DATA *Private;\r |
ee3428bb | 335 | EFI_HII_HANDLE UefiHiiHandle;\r |
8cf6dad8 | 336 | CHAR8 *LangCodes4646;\r |
0368663f | 337 | CHAR16 *UnicodeLangCodes639;\r |
338 | CHAR8 *LangCodes639;\r | |
339 | EFI_STATUS Status;\r | |
ee3428bb | 340 | \r |
0368663f | 341 | Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);\r |
ee3428bb | 342 | \r |
0368663f | 343 | UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);\r |
ee3428bb | 344 | if (UefiHiiHandle == NULL) {\r |
345 | return EFI_INVALID_PARAMETER;\r | |
346 | }\r | |
347 | \r | |
8cf6dad8 | 348 | LangCodes4646 = HiiGetSupportedLanguages (UefiHiiHandle);\r |
ee3428bb | 349 | \r |
8cf6dad8 | 350 | if (LangCodes4646 == NULL) {\r |
ee3428bb | 351 | return EFI_INVALID_PARAMETER;\r |
352 | }\r | |
353 | \r | |
7c9d25ae | 354 | LangCodes639 = ConvertLanguagesRfc4646ToIso639 (LangCodes4646);\r |
355 | if (LangCodes639 == NULL) {\r | |
356 | Status = EFI_INVALID_PARAMETER;\r | |
0368663f | 357 | goto Done;\r |
358 | }\r | |
359 | \r | |
360 | UnicodeLangCodes639 = AllocateZeroPool (AsciiStrSize (LangCodes639) * sizeof (CHAR16));\r | |
361 | if (UnicodeLangCodes639 == NULL) {\r | |
362 | Status = EFI_OUT_OF_RESOURCES;\r | |
363 | goto Done;\r | |
ee3428bb | 364 | }\r |
365 | \r | |
366 | //\r | |
0368663f | 367 | // The language returned is in RFC 639-2 format.\r |
ee3428bb | 368 | //\r |
0368663f | 369 | AsciiStrToUnicodeStr (LangCodes639, UnicodeLangCodes639);\r |
370 | *LanguageString = UnicodeLangCodes639;\r | |
7c9d25ae | 371 | Status = EFI_SUCCESS;\r |
ee3428bb | 372 | \r |
0368663f | 373 | Done:\r |
8cf6dad8 | 374 | FreePool (LangCodes4646);\r |
7001eaf8 | 375 | if (LangCodes639 != NULL) {\r |
376 | FreePool (LangCodes639);\r | |
377 | }\r | |
0368663f | 378 | \r |
379 | return Status;\r | |
4259256b | 380 | }\r |
381 | \r | |
cb7d01c0 | 382 | /**\r |
383 | This function returns the list of supported 2nd languages, in the format specified\r | |
384 | in UEFI specification Appendix M.\r | |
385 | \r | |
386 | If HiiHandle is not a valid Handle in the HII database, then ASSERT.\r | |
387 | If not enough resource to complete the operation, then ASSERT.\r | |
388 | \r | |
389 | @param HiiHandle The HII package list handle.\r | |
4f077902 | 390 | @param PrimaryLanguage Pointer to language name buffer.\r |
cb7d01c0 | 391 | \r |
392 | @return The supported languages.\r | |
393 | \r | |
394 | **/\r | |
395 | CHAR8 *\r | |
396 | EFIAPI\r | |
397 | HiiGetSupportedSecondaryLanguages (\r | |
398 | IN EFI_HII_HANDLE HiiHandle,\r | |
4f077902 | 399 | IN CONST CHAR8 *PrimaryLanguage\r |
cb7d01c0 | 400 | )\r |
401 | {\r | |
402 | EFI_STATUS Status;\r | |
403 | UINTN BufferSize;\r | |
404 | CHAR8 *LanguageString;\r | |
405 | \r | |
406 | ASSERT (HiiHandle != NULL);\r | |
407 | \r | |
408 | //\r | |
409 | // Collect current supported 2nd Languages for given HII handle\r | |
410 | // First try allocate 4K buffer to store the current supported 2nd languages.\r | |
411 | //\r | |
412 | BufferSize = 0x1000;\r | |
413 | LanguageString = AllocateZeroPool (BufferSize);\r | |
414 | if (LanguageString == NULL) {\r | |
415 | return NULL;\r | |
416 | }\r | |
417 | \r | |
4f077902 | 418 | Status = mHiiStringProtocol->GetSecondaryLanguages (mHiiStringProtocol, HiiHandle, PrimaryLanguage, LanguageString, &BufferSize);\r |
cb7d01c0 | 419 | ASSERT (Status != EFI_NOT_FOUND);\r |
420 | \r | |
421 | if (Status == EFI_BUFFER_TOO_SMALL) {\r | |
422 | FreePool (LanguageString);\r | |
423 | LanguageString = AllocateZeroPool (BufferSize);\r | |
424 | if (LanguageString == NULL) {\r | |
425 | return NULL;\r | |
426 | }\r | |
427 | \r | |
4f077902 | 428 | Status = mHiiStringProtocol->GetSecondaryLanguages (mHiiStringProtocol, HiiHandle, PrimaryLanguage, LanguageString, &BufferSize);\r |
cb7d01c0 | 429 | }\r |
430 | \r | |
431 | if (EFI_ERROR (Status)) {\r | |
432 | LanguageString = NULL;\r | |
433 | }\r | |
434 | \r | |
435 | return LanguageString;\r | |
436 | }\r | |
0368663f | 437 | \r |
3321fa09 | 438 | /**\r |
439 | Allows a program to determine which secondary languages are supported on a given handle for a given primary language\r | |
0368663f | 440 | \r |
3321fa09 | 441 | This routine is intended to be used by drivers to query the interface database for supported languages. \r |
442 | This routine returns a string of concatenated 3-byte language identifiers, one per string package associated with the handle.\r | |
443 | \r | |
444 | @param This A pointer to the EFI_HII_PROTOCOL instance.\r | |
445 | @param Handle The handle on which the strings reside. Type EFI_HII_HANDLE is defined in EFI_HII_PROTOCOL.NewPack() \r | |
446 | in the Packages section.\r | |
447 | @param PrimaryLanguage Pointer to a NULL-terminated string containing a single ISO 639-2 language identifier, indicating \r | |
448 | the primary language.\r | |
449 | @param LanguageString A string allocated by GetSecondaryLanguages() containing a list of all secondary languages registered \r | |
450 | on the handle. The routine will not return the three-spaces language identifier used in other functions \r | |
451 | to indicate non-language-specific strings, nor will it return the primary language. This function succeeds \r | |
452 | but returns a NULL LanguageString if there are no secondary languages associated with the input Handle and \r | |
453 | PrimaryLanguage pair. Type EFI_STRING is defined in String.\r | |
454 | \r | |
26a76fbc LG |
455 | @retval EFI_SUCCESS LanguageString was correctly returned.\r |
456 | @retval EFI_INVALID_PARAMETER The Handle was unknown.\r | |
3321fa09 | 457 | **/\r |
4259256b | 458 | EFI_STATUS\r |
459 | EFIAPI\r | |
460 | HiiGetSecondaryLanguages (\r | |
0368663f | 461 | IN EFI_HII_PROTOCOL *This,\r |
462 | IN FRAMEWORK_EFI_HII_HANDLE Handle,\r | |
463 | IN CHAR16 *PrimaryLanguage,\r | |
464 | OUT EFI_STRING *LanguageString\r | |
4259256b | 465 | )\r |
4259256b | 466 | {\r |
0b09813f | 467 | HII_THUNK_PRIVATE_DATA *Private;\r |
ee3428bb | 468 | EFI_HII_HANDLE UefiHiiHandle;\r |
8cf6dad8 | 469 | CHAR8 *PrimaryLang4646;\r |
0368663f | 470 | CHAR8 *PrimaryLang639;\r |
8cf6dad8 | 471 | CHAR8 *SecLangCodes4646;\r |
0368663f | 472 | CHAR8 *SecLangCodes639;\r |
473 | CHAR16 *UnicodeSecLangCodes639;\r | |
474 | EFI_STATUS Status;\r | |
ee3428bb | 475 | \r |
0368663f | 476 | Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);\r |
ee3428bb | 477 | \r |
0b09813f | 478 | SecLangCodes639 = NULL;\r |
8cf6dad8 | 479 | SecLangCodes4646 = NULL;\r |
480 | PrimaryLang4646 = NULL;\r | |
0368663f | 481 | UnicodeSecLangCodes639 = NULL;\r |
482 | \r | |
483 | UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);\r | |
ee3428bb | 484 | if (UefiHiiHandle == NULL) {\r |
485 | return EFI_INVALID_PARAMETER;\r | |
486 | }\r | |
487 | \r | |
0368663f | 488 | PrimaryLang639 = AllocateZeroPool (StrLen (PrimaryLanguage) + 1);\r |
489 | if (PrimaryLang639 == NULL) {\r | |
490 | Status = EFI_OUT_OF_RESOURCES;\r | |
491 | goto Done;\r | |
492 | }\r | |
ee3428bb | 493 | \r |
0368663f | 494 | UnicodeStrToAsciiStr (PrimaryLanguage, PrimaryLang639);\r |
ee3428bb | 495 | \r |
7c9d25ae | 496 | PrimaryLang4646 = ConvertLanguagesIso639ToRfc4646 (PrimaryLang639);\r |
8cf6dad8 | 497 | ASSERT_EFI_ERROR (PrimaryLang4646 != NULL);\r |
ee3428bb | 498 | \r |
8cf6dad8 | 499 | SecLangCodes4646 = HiiGetSupportedSecondaryLanguages (UefiHiiHandle, PrimaryLang4646);\r |
0368663f | 500 | \r |
8cf6dad8 | 501 | if (SecLangCodes4646 == NULL) {\r |
0368663f | 502 | Status = EFI_INVALID_PARAMETER;\r |
503 | goto Done;\r | |
ee3428bb | 504 | }\r |
505 | \r | |
7c9d25ae | 506 | SecLangCodes639 = ConvertLanguagesIso639ToRfc4646 (SecLangCodes4646);\r |
507 | if (SecLangCodes639 == NULL) {\r | |
508 | Status = EFI_INVALID_PARAMETER;\r | |
0368663f | 509 | goto Done;\r |
510 | }\r | |
511 | \r | |
512 | UnicodeSecLangCodes639 = AllocateZeroPool (AsciiStrSize (SecLangCodes639) * sizeof (CHAR16));\r | |
513 | if (UnicodeSecLangCodes639 == NULL) {\r | |
514 | Status = EFI_OUT_OF_RESOURCES;\r | |
515 | goto Done;\r | |
ee3428bb | 516 | }\r |
517 | \r | |
518 | //\r | |
8cf6dad8 | 519 | // The language returned is in RFC 4646 format.\r |
ee3428bb | 520 | //\r |
0368663f | 521 | *LanguageString = AsciiStrToUnicodeStr (SecLangCodes639, UnicodeSecLangCodes639);\r |
7c9d25ae | 522 | Status = EFI_SUCCESS;\r |
ee3428bb | 523 | \r |
0368663f | 524 | Done:\r |
7001eaf8 | 525 | if (PrimaryLang639 != NULL) {\r |
526 | FreePool (PrimaryLang639);\r | |
527 | }\r | |
0b09813f | 528 | \r |
7001eaf8 | 529 | if (SecLangCodes639 != NULL) {\r |
530 | FreePool (SecLangCodes639);\r | |
531 | }\r | |
0b09813f | 532 | \r |
8cf6dad8 | 533 | if (PrimaryLang4646 != NULL) {\r |
534 | FreePool (PrimaryLang4646);\r | |
0b09813f | 535 | }\r |
536 | \r | |
8cf6dad8 | 537 | if (SecLangCodes4646 != NULL) {\r |
538 | FreePool (SecLangCodes4646);\r | |
7001eaf8 | 539 | }\r |
540 | if (UnicodeSecLangCodes639 != NULL) {\r | |
541 | FreePool (UnicodeSecLangCodes639);\r | |
542 | }\r | |
0368663f | 543 | \r |
544 | return Status;\r | |
137c54ac | 545 | }\r |
4259256b | 546 | \r |