]>
Commit | Line | Data |
---|---|---|
4259256b | 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 |
ee3428bb | 5 | Copyright (c) 2008, Intel Corporation\r |
4259256b | 6 | All rights reserved. This program and the accompanying materials\r |
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 |
161 | for (Index = 0; Index < BufferLength / sizeof (EFI_HII_HANDLE); Index++) {\r | |
d4775f2a | 162 | ThunkContext = CreateThunkContextForUefiHiiHandle (Buffer[Index]);\r |
163 | ASSERT (ThunkContext!= NULL);\r | |
164 | \r | |
165 | InsertTailList (&Private->ThunkContextListHead, &ThunkContext->Link);\r | |
0368663f | 166 | }\r |
167 | \r | |
168 | FreePool (Buffer);\r | |
169 | }\r | |
ea58467b | 170 | \r |
171 | Status = mHiiDatabase->RegisterPackageNotify (\r | |
172 | mHiiDatabase,\r | |
173 | EFI_HII_PACKAGE_STRINGS,\r | |
174 | NULL,\r | |
0368663f | 175 | NewOrAddPackNotify,\r |
ea58467b | 176 | EFI_HII_DATABASE_NOTIFY_NEW_PACK,\r |
0368663f | 177 | &Handle\r |
ea58467b | 178 | );\r |
179 | ASSERT_EFI_ERROR (Status);\r | |
180 | \r | |
181 | Status = mHiiDatabase->RegisterPackageNotify (\r | |
182 | mHiiDatabase,\r | |
183 | EFI_HII_PACKAGE_STRINGS,\r | |
184 | NULL,\r | |
0368663f | 185 | NewOrAddPackNotify,\r |
186 | EFI_HII_DATABASE_NOTIFY_ADD_PACK,\r | |
187 | &Handle\r | |
188 | );\r | |
189 | ASSERT_EFI_ERROR (Status);\r | |
190 | \r | |
191 | Status = mHiiDatabase->RegisterPackageNotify (\r | |
192 | mHiiDatabase,\r | |
4dd76ade | 193 | EFI_HII_PACKAGE_FORMS,\r |
0368663f | 194 | NULL,\r |
195 | NewOrAddPackNotify,\r | |
196 | EFI_HII_DATABASE_NOTIFY_NEW_PACK,\r | |
197 | &Handle\r | |
198 | );\r | |
199 | ASSERT_EFI_ERROR (Status);\r | |
200 | \r | |
201 | Status = mHiiDatabase->RegisterPackageNotify (\r | |
202 | mHiiDatabase,\r | |
4dd76ade | 203 | EFI_HII_PACKAGE_FORMS,\r |
0368663f | 204 | NULL,\r |
205 | NewOrAddPackNotify,\r | |
ea58467b | 206 | EFI_HII_DATABASE_NOTIFY_ADD_PACK,\r |
0368663f | 207 | &Handle\r |
ea58467b | 208 | );\r |
209 | ASSERT_EFI_ERROR (Status);\r | |
210 | \r | |
211 | Status = mHiiDatabase->RegisterPackageNotify (\r | |
212 | mHiiDatabase,\r | |
213 | EFI_HII_PACKAGE_STRINGS,\r | |
214 | NULL,\r | |
215 | RemovePackNotify,\r | |
216 | EFI_HII_DATABASE_NOTIFY_REMOVE_PACK,\r | |
0368663f | 217 | &Handle\r |
ea58467b | 218 | );\r |
219 | ASSERT_EFI_ERROR (Status);\r | |
220 | \r | |
a235abd2 | 221 | InitSetBrowserStrings ();\r |
222 | \r | |
0368663f | 223 | mBrowserThunkPrivateDataTemplate.ThunkPrivate = Private;\r |
137c54ac | 224 | Status = gBS->InstallProtocolInterface (\r |
225 | &mBrowserThunkPrivateDataTemplate.Handle,\r | |
962045a2 | 226 | &gEfiFormBrowserCompatibilityProtocolGuid,\r |
137c54ac | 227 | EFI_NATIVE_INTERFACE,\r |
228 | (VOID *) &mBrowserThunkPrivateDataTemplate.FormBrowser\r | |
229 | );\r | |
230 | ASSERT_EFI_ERROR (Status);\r | |
231 | \r | |
4259256b | 232 | return Status;\r |
233 | }\r | |
234 | \r | |
3321fa09 | 235 | /**\r |
236 | Determines the handles that are currently active in the database.\r | |
237 | \r | |
238 | This function determines the handles that are currently active in the database. \r | |
239 | For example, a program wishing to create a Setup-like configuration utility would use this call \r | |
240 | to determine the handles that are available. It would then use calls defined in the forms section \r | |
241 | below to extract forms and then interpret them.\r | |
242 | \r | |
243 | @param This A pointer to the EFI_HII_PROTOCOL instance.\r | |
244 | @param HandleBufferLength On input, a pointer to the length of the handle buffer. \r | |
245 | On output, the length of the handle buffer that is required for the handles found.\r | |
246 | @param Handle An array of EFI_HII_HANDLE instances returned. \r | |
247 | Type EFI_HII_HANDLE is defined in EFI_HII_PROTOCOL.NewPack() in the Packages section.\r | |
248 | \r | |
249 | @retval EFI_SUCCESS Handle was updated successfully.\r | |
250 | \r | |
251 | @retval EFI_BUFFER_TOO_SMALL The HandleBufferLength parameter indicates that Handle is too small \r | |
252 | to support the number of handles. HandleBufferLength is updated with a value that \r | |
253 | will enable the data to fit.\r | |
254 | **/\r | |
4259256b | 255 | EFI_STATUS\r |
256 | EFIAPI\r | |
257 | HiiFindHandles (\r | |
258 | IN EFI_HII_PROTOCOL *This,\r | |
259 | IN OUT UINT16 *HandleBufferLength,\r | |
260 | OUT FRAMEWORK_EFI_HII_HANDLE Handle[1]\r | |
261 | )\r | |
4259256b | 262 | {\r |
ea58467b | 263 | UINT16 Count;\r |
0368663f | 264 | LIST_ENTRY *Link;\r |
265 | HII_THUNK_CONTEXT *ThunkContext;\r | |
266 | HII_THUNK_PRIVATE_DATA *Private;\r | |
ea58467b | 267 | \r |
268 | if (HandleBufferLength == NULL) {\r | |
269 | return EFI_INVALID_PARAMETER;\r | |
270 | }\r | |
271 | \r | |
0368663f | 272 | Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This); \r |
ea58467b | 273 | \r |
0368663f | 274 | //\r |
275 | // Count the number of handles.\r | |
276 | //\r | |
ea58467b | 277 | Count = 0;\r |
0368663f | 278 | Link = GetFirstNode (&Private->ThunkContextListHead);\r |
279 | while (!IsNull (&Private->ThunkContextListHead, Link)) {\r | |
ea58467b | 280 | Count++;\r |
0368663f | 281 | Link = GetNextNode (&Private->ThunkContextListHead, Link);\r |
ea58467b | 282 | }\r |
283 | \r | |
284 | if (Count > *HandleBufferLength) {\r | |
5990ace9 | 285 | *HandleBufferLength = (UINT16) (Count * sizeof (FRAMEWORK_EFI_HII_HANDLE));\r |
ea58467b | 286 | return EFI_BUFFER_TOO_SMALL;\r |
287 | }\r | |
288 | \r | |
0368663f | 289 | //\r |
290 | // Output the handles.\r | |
291 | //\r | |
ea58467b | 292 | Count = 0;\r |
0368663f | 293 | Link = GetFirstNode (&Private->ThunkContextListHead);\r |
294 | while (!IsNull (&Private->ThunkContextListHead, Link)) {\r | |
295 | \r | |
296 | ThunkContext = HII_THUNK_CONTEXT_FROM_LINK (Link);\r | |
297 | Handle[Count] = ThunkContext->FwHiiHandle;\r | |
ea58467b | 298 | \r |
ea58467b | 299 | Count++;\r |
0368663f | 300 | Link = GetNextNode (&Private->ThunkContextListHead, Link);\r |
301 | \r | |
302 | }\r | |
ea58467b | 303 | \r |
5990ace9 | 304 | *HandleBufferLength = (UINT16) (Count * sizeof (FRAMEWORK_EFI_HII_HANDLE));\r |
4259256b | 305 | return EFI_SUCCESS;\r |
306 | }\r | |
307 | \r | |
3321fa09 | 308 | /**\r |
309 | Allows a program to determine the primary languages that are supported on a given handle.\r | |
310 | \r | |
311 | This routine is intended to be used by drivers to query the interface database for supported languages. \r | |
312 | This routine returns a string of concatenated 3-byte language identifiers, one per string package associated with the handle.\r | |
313 | \r | |
314 | @param This A pointer to the EFI_HII_PROTOCOL instance.\r | |
315 | @param Handle The handle on which the strings reside. Type EFI_HII_HANDLE is defined in EFI_HII_PROTOCOL.NewPack() \r | |
316 | in the Packages section.\r | |
317 | @param LanguageString A string allocated by GetPrimaryLanguages() that contains a list of all primary languages \r | |
318 | registered on the handle. The routine will not return the three-spaces language identifier used in \r | |
319 | other functions to indicate non-language-specific strings.\r | |
320 | \r | |
321 | @reval EFI_SUCCESS LanguageString was correctly returned.\r | |
322 | \r | |
323 | @reval EFI_INVALID_PARAMETER The Handle was unknown.\r | |
324 | **/\r | |
4259256b | 325 | EFI_STATUS\r |
326 | EFIAPI\r | |
327 | HiiGetPrimaryLanguages (\r | |
3321fa09 | 328 | IN EFI_HII_PROTOCOL *This,\r |
329 | IN FRAMEWORK_EFI_HII_HANDLE Handle,\r | |
330 | OUT EFI_STRING *LanguageString\r | |
4259256b | 331 | )\r |
4259256b | 332 | {\r |
0368663f | 333 | HII_THUNK_PRIVATE_DATA *Private;\r |
ee3428bb | 334 | EFI_HII_HANDLE UefiHiiHandle;\r |
8cf6dad8 | 335 | CHAR8 *LangCodes4646;\r |
0368663f | 336 | CHAR16 *UnicodeLangCodes639;\r |
337 | CHAR8 *LangCodes639;\r | |
338 | EFI_STATUS Status;\r | |
ee3428bb | 339 | \r |
0368663f | 340 | Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);\r |
ee3428bb | 341 | \r |
0368663f | 342 | UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);\r |
ee3428bb | 343 | if (UefiHiiHandle == NULL) {\r |
344 | return EFI_INVALID_PARAMETER;\r | |
345 | }\r | |
346 | \r | |
8cf6dad8 | 347 | LangCodes4646 = HiiGetSupportedLanguages (UefiHiiHandle);\r |
ee3428bb | 348 | \r |
8cf6dad8 | 349 | if (LangCodes4646 == NULL) {\r |
ee3428bb | 350 | return EFI_INVALID_PARAMETER;\r |
351 | }\r | |
352 | \r | |
7c9d25ae | 353 | LangCodes639 = ConvertLanguagesRfc4646ToIso639 (LangCodes4646);\r |
354 | if (LangCodes639 == NULL) {\r | |
355 | Status = EFI_INVALID_PARAMETER;\r | |
0368663f | 356 | goto Done;\r |
357 | }\r | |
358 | \r | |
359 | UnicodeLangCodes639 = AllocateZeroPool (AsciiStrSize (LangCodes639) * sizeof (CHAR16));\r | |
360 | if (UnicodeLangCodes639 == NULL) {\r | |
361 | Status = EFI_OUT_OF_RESOURCES;\r | |
362 | goto Done;\r | |
ee3428bb | 363 | }\r |
364 | \r | |
365 | //\r | |
0368663f | 366 | // The language returned is in RFC 639-2 format.\r |
ee3428bb | 367 | //\r |
0368663f | 368 | AsciiStrToUnicodeStr (LangCodes639, UnicodeLangCodes639);\r |
369 | *LanguageString = UnicodeLangCodes639;\r | |
7c9d25ae | 370 | Status = EFI_SUCCESS;\r |
ee3428bb | 371 | \r |
0368663f | 372 | Done:\r |
8cf6dad8 | 373 | FreePool (LangCodes4646);\r |
7001eaf8 | 374 | if (LangCodes639 != NULL) {\r |
375 | FreePool (LangCodes639);\r | |
376 | }\r | |
0368663f | 377 | \r |
378 | return Status;\r | |
4259256b | 379 | }\r |
380 | \r | |
cb7d01c0 | 381 | /**\r |
382 | This function returns the list of supported 2nd languages, in the format specified\r | |
383 | in UEFI specification Appendix M.\r | |
384 | \r | |
385 | If HiiHandle is not a valid Handle in the HII database, then ASSERT.\r | |
386 | If not enough resource to complete the operation, then ASSERT.\r | |
387 | \r | |
388 | @param HiiHandle The HII package list handle.\r | |
389 | @param FirstLanguage Pointer to language name buffer.\r | |
390 | \r | |
391 | @return The supported languages.\r | |
392 | \r | |
393 | **/\r | |
394 | CHAR8 *\r | |
395 | EFIAPI\r | |
396 | HiiGetSupportedSecondaryLanguages (\r | |
397 | IN EFI_HII_HANDLE HiiHandle,\r | |
398 | IN CONST CHAR8 *FirstLanguage\r | |
399 | )\r | |
400 | {\r | |
401 | EFI_STATUS Status;\r | |
402 | UINTN BufferSize;\r | |
403 | CHAR8 *LanguageString;\r | |
404 | \r | |
405 | ASSERT (HiiHandle != NULL);\r | |
406 | \r | |
407 | //\r | |
408 | // Collect current supported 2nd Languages for given HII handle\r | |
409 | // First try allocate 4K buffer to store the current supported 2nd languages.\r | |
410 | //\r | |
411 | BufferSize = 0x1000;\r | |
412 | LanguageString = AllocateZeroPool (BufferSize);\r | |
413 | if (LanguageString == NULL) {\r | |
414 | return NULL;\r | |
415 | }\r | |
416 | \r | |
417 | Status = mHiiStringProtocol->GetSecondaryLanguages (mHiiStringProtocol, HiiHandle, FirstLanguage, LanguageString, &BufferSize);\r | |
418 | ASSERT (Status != EFI_NOT_FOUND);\r | |
419 | \r | |
420 | if (Status == EFI_BUFFER_TOO_SMALL) {\r | |
421 | FreePool (LanguageString);\r | |
422 | LanguageString = AllocateZeroPool (BufferSize);\r | |
423 | if (LanguageString == NULL) {\r | |
424 | return NULL;\r | |
425 | }\r | |
426 | \r | |
427 | Status = mHiiStringProtocol->GetSecondaryLanguages (mHiiStringProtocol, HiiHandle, FirstLanguage, LanguageString, &BufferSize);\r | |
428 | }\r | |
429 | \r | |
430 | if (EFI_ERROR (Status)) {\r | |
431 | LanguageString = NULL;\r | |
432 | }\r | |
433 | \r | |
434 | return LanguageString;\r | |
435 | }\r | |
0368663f | 436 | \r |
3321fa09 | 437 | /**\r |
438 | Allows a program to determine which secondary languages are supported on a given handle for a given primary language\r | |
0368663f | 439 | \r |
3321fa09 | 440 | This routine is intended to be used by drivers to query the interface database for supported languages. \r |
441 | This routine returns a string of concatenated 3-byte language identifiers, one per string package associated with the handle.\r | |
442 | \r | |
443 | @param This A pointer to the EFI_HII_PROTOCOL instance.\r | |
444 | @param Handle The handle on which the strings reside. Type EFI_HII_HANDLE is defined in EFI_HII_PROTOCOL.NewPack() \r | |
445 | in the Packages section.\r | |
446 | @param PrimaryLanguage Pointer to a NULL-terminated string containing a single ISO 639-2 language identifier, indicating \r | |
447 | the primary language.\r | |
448 | @param LanguageString A string allocated by GetSecondaryLanguages() containing a list of all secondary languages registered \r | |
449 | on the handle. The routine will not return the three-spaces language identifier used in other functions \r | |
450 | to indicate non-language-specific strings, nor will it return the primary language. This function succeeds \r | |
451 | but returns a NULL LanguageString if there are no secondary languages associated with the input Handle and \r | |
452 | PrimaryLanguage pair. Type EFI_STRING is defined in String.\r | |
453 | \r | |
454 | @reval EFI_SUCCESS LanguageString was correctly returned.\r | |
455 | @reval EFI_INVALID_PARAMETER The Handle was unknown.\r | |
456 | **/\r | |
4259256b | 457 | EFI_STATUS\r |
458 | EFIAPI\r | |
459 | HiiGetSecondaryLanguages (\r | |
0368663f | 460 | IN EFI_HII_PROTOCOL *This,\r |
461 | IN FRAMEWORK_EFI_HII_HANDLE Handle,\r | |
462 | IN CHAR16 *PrimaryLanguage,\r | |
463 | OUT EFI_STRING *LanguageString\r | |
4259256b | 464 | )\r |
4259256b | 465 | {\r |
0b09813f | 466 | HII_THUNK_PRIVATE_DATA *Private;\r |
ee3428bb | 467 | EFI_HII_HANDLE UefiHiiHandle;\r |
8cf6dad8 | 468 | CHAR8 *PrimaryLang4646;\r |
0368663f | 469 | CHAR8 *PrimaryLang639;\r |
8cf6dad8 | 470 | CHAR8 *SecLangCodes4646;\r |
0368663f | 471 | CHAR8 *SecLangCodes639;\r |
472 | CHAR16 *UnicodeSecLangCodes639;\r | |
473 | EFI_STATUS Status;\r | |
ee3428bb | 474 | \r |
0368663f | 475 | Private = HII_THUNK_PRIVATE_DATA_FROM_THIS(This);\r |
ee3428bb | 476 | \r |
0b09813f | 477 | SecLangCodes639 = NULL;\r |
8cf6dad8 | 478 | SecLangCodes4646 = NULL;\r |
479 | PrimaryLang4646 = NULL;\r | |
0368663f | 480 | UnicodeSecLangCodes639 = NULL;\r |
481 | \r | |
482 | UefiHiiHandle = FwHiiHandleToUefiHiiHandle (Private, Handle);\r | |
ee3428bb | 483 | if (UefiHiiHandle == NULL) {\r |
484 | return EFI_INVALID_PARAMETER;\r | |
485 | }\r | |
486 | \r | |
0368663f | 487 | PrimaryLang639 = AllocateZeroPool (StrLen (PrimaryLanguage) + 1);\r |
488 | if (PrimaryLang639 == NULL) {\r | |
489 | Status = EFI_OUT_OF_RESOURCES;\r | |
490 | goto Done;\r | |
491 | }\r | |
ee3428bb | 492 | \r |
0368663f | 493 | UnicodeStrToAsciiStr (PrimaryLanguage, PrimaryLang639);\r |
ee3428bb | 494 | \r |
7c9d25ae | 495 | PrimaryLang4646 = ConvertLanguagesIso639ToRfc4646 (PrimaryLang639);\r |
8cf6dad8 | 496 | ASSERT_EFI_ERROR (PrimaryLang4646 != NULL);\r |
ee3428bb | 497 | \r |
8cf6dad8 | 498 | SecLangCodes4646 = HiiGetSupportedSecondaryLanguages (UefiHiiHandle, PrimaryLang4646);\r |
0368663f | 499 | \r |
8cf6dad8 | 500 | if (SecLangCodes4646 == NULL) {\r |
0368663f | 501 | Status = EFI_INVALID_PARAMETER;\r |
502 | goto Done;\r | |
ee3428bb | 503 | }\r |
504 | \r | |
7c9d25ae | 505 | SecLangCodes639 = ConvertLanguagesIso639ToRfc4646 (SecLangCodes4646);\r |
506 | if (SecLangCodes639 == NULL) {\r | |
507 | Status = EFI_INVALID_PARAMETER;\r | |
0368663f | 508 | goto Done;\r |
509 | }\r | |
510 | \r | |
511 | UnicodeSecLangCodes639 = AllocateZeroPool (AsciiStrSize (SecLangCodes639) * sizeof (CHAR16));\r | |
512 | if (UnicodeSecLangCodes639 == NULL) {\r | |
513 | Status = EFI_OUT_OF_RESOURCES;\r | |
514 | goto Done;\r | |
ee3428bb | 515 | }\r |
516 | \r | |
517 | //\r | |
8cf6dad8 | 518 | // The language returned is in RFC 4646 format.\r |
ee3428bb | 519 | //\r |
0368663f | 520 | *LanguageString = AsciiStrToUnicodeStr (SecLangCodes639, UnicodeSecLangCodes639);\r |
7c9d25ae | 521 | Status = EFI_SUCCESS;\r |
ee3428bb | 522 | \r |
0368663f | 523 | Done:\r |
7001eaf8 | 524 | if (PrimaryLang639 != NULL) {\r |
525 | FreePool (PrimaryLang639);\r | |
526 | }\r | |
0b09813f | 527 | \r |
7001eaf8 | 528 | if (SecLangCodes639 != NULL) {\r |
529 | FreePool (SecLangCodes639);\r | |
530 | }\r | |
0b09813f | 531 | \r |
8cf6dad8 | 532 | if (PrimaryLang4646 != NULL) {\r |
533 | FreePool (PrimaryLang4646);\r | |
0b09813f | 534 | }\r |
535 | \r | |
8cf6dad8 | 536 | if (SecLangCodes4646 != NULL) {\r |
537 | FreePool (SecLangCodes4646);\r | |
7001eaf8 | 538 | }\r |
539 | if (UnicodeSecLangCodes639 != NULL) {\r | |
540 | FreePool (UnicodeSecLangCodes639);\r | |
541 | }\r | |
0368663f | 542 | \r |
543 | return Status;\r | |
137c54ac | 544 | }\r |
4259256b | 545 | \r |
0368663f | 546 | \r |