]>
Commit | Line | Data |
---|---|---|
fb3df220 | 1 | /** @file\r |
2 | Public include file for the HII Library\r | |
3 | \r | |
e52c5a9f | 4 | Copyright (c) 2007 - 2008, Intel Corporation \r |
fb3df220 | 5 | All rights reserved. This program and the accompanying materials \r |
6 | are licensed and made available under the terms and conditions of the BSD License \r | |
7 | which accompanies this distribution. The full text of the license may be found at \r | |
8 | http://opensource.org/licenses/bsd-license.php \r | |
9 | \r | |
10 | THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r | |
11 | WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r | |
12 | \r | |
fb3df220 | 13 | **/\r |
14 | \r | |
15 | #ifndef __HII_LIB_H__\r | |
16 | #define __HII_LIB_H__\r | |
17 | \r | |
7d582d6b | 18 | //\r |
19 | // Limited buffer size recommended by RFC4646 (4.3. Length Considerations)\r | |
20 | // (42 characters plus a NULL terminator)\r | |
21 | //\r | |
22 | #define RFC_3066_ENTRY_SIZE (42 + 1)\r | |
fb3df220 | 23 | \r |
e52c5a9f | 24 | #define ISO_639_2_ENTRY_SIZE 3\r |
25 | \r | |
26 | /**\r | |
27 | Assemble EFI_HII_PACKAGE_LIST according to the passed in packages.\r | |
28 | \r | |
29 | If GuidId is NULL, then ASSERT.\r | |
30 | If not enough resource to complete the operation, then ASSERT.\r | |
31 | \r | |
32 | @param NumberOfPackages Number of packages.\r | |
33 | @param GuidId Package GUID.\r | |
34 | @param ... Variable argument list for packages to be assembled.\r | |
35 | \r | |
36 | @return EFI_HII_PACKAGE_LIST_HEADER Pointer of EFI_HII_PACKAGE_LIST_HEADER. The function will ASSERT if system has\r | |
37 | not enough resource to complete the operation.\r | |
38 | \r | |
39 | **/\r | |
40 | EFI_HII_PACKAGE_LIST_HEADER *\r | |
41 | EFIAPI\r | |
42 | HiiLibPreparePackageList (\r | |
43 | IN UINTN NumberOfPackages,\r | |
44 | IN CONST EFI_GUID *GuidId,\r | |
45 | ...\r | |
46 | )\r | |
47 | ;\r | |
48 | \r | |
fb3df220 | 49 | /**\r |
7d582d6b | 50 | This function allocates pool for an EFI_HII_PACKAGE_LIST structure\r |
51 | with additional space that is big enough to host all packages described by the variable \r | |
52 | argument list of package pointers. The allocated structure is initialized using NumberOfPackages, \r | |
53 | GuidId, and the variable length argument list of package pointers.\r | |
fb3df220 | 54 | \r |
7d582d6b | 55 | Then, EFI_HII_PACKAGE_LIST will be register to the default System HII Database. The\r |
56 | Handle to the newly registered Package List is returned throught HiiHandle.\r | |
57 | \r | |
e52c5a9f | 58 | If HiiHandle is NULL, then ASSERT.\r |
59 | \r | |
01aef47b | 60 | @param NumberOfPackages The number of HII packages to register.\r |
61 | @param GuidId Package List GUID ID.\r | |
62 | @param DriverHandle Optional. If not NULL, the DriverHandle on which an instance of DEVICE_PATH_PROTOCOL is installed.\r | |
63 | This DriverHandle uniquely defines the device that the added packages are associated with.\r | |
64 | @param HiiHandle On output, the HiiHandle is update with the handle which can be used to retrieve the Package \r | |
65 | List later. If the functions failed to add the package to the default HII database, this value will\r | |
66 | be set to NULL.\r | |
67 | @param ... The variable argument list describing all HII Package.\r | |
fb3df220 | 68 | \r |
e52c5a9f | 69 | @return EFI_SUCCESS If the packages are successfully added to the default HII database.\r |
70 | @return EFI_OUT_OF_RESOURCE Not enough resource to complete the operation.\r | |
fb3df220 | 71 | \r |
72 | **/\r | |
7d582d6b | 73 | EFI_STATUS\r |
fb3df220 | 74 | EFIAPI\r |
e52c5a9f | 75 | HiiLibAddPackages (\r |
7d582d6b | 76 | IN UINTN NumberOfPackages,\r |
77 | IN CONST EFI_GUID *GuidId,\r | |
78 | IN EFI_HANDLE DriverHandle, OPTIONAL\r | |
e52c5a9f | 79 | OUT EFI_HII_HANDLE *HiiHandle,\r |
fb3df220 | 80 | ...\r |
7d582d6b | 81 | )\r |
82 | ;\r | |
83 | \r | |
e52c5a9f | 84 | /**\r |
85 | Removes a package list from the default HII database.\r | |
86 | \r | |
87 | If HiiHandle is NULL, then ASSERT.\r | |
88 | If HiiHandle is not a valid EFI_HII_HANDLE in the default HII database, then ASSERT.\r | |
89 | \r | |
90 | @param HiiHandle The handle that was previously registered to the data base that is requested for removal.\r | |
91 | List later.\r | |
92 | \r | |
93 | @return VOID\r | |
94 | \r | |
95 | **/\r | |
96 | VOID\r | |
7d582d6b | 97 | EFIAPI\r |
e52c5a9f | 98 | HiiLibRemovePackages (\r |
7d582d6b | 99 | IN EFI_HII_HANDLE HiiHandle\r |
100 | )\r | |
101 | ;\r | |
102 | \r | |
103 | /**\r | |
e52c5a9f | 104 | This function adds the string into String Package of each language\r |
105 | supported by the package list.\r | |
106 | \r | |
107 | If String is NULL, then ASSERT.\r | |
108 | If StringId is NULL, the ASSERT.\r | |
109 | If PackageList could not be found in the default HII database, then ASSERT.\r | |
7d582d6b | 110 | \r |
111 | @param PackageList Handle of the package list where this string will\r | |
e52c5a9f | 112 | be added.\r |
7d582d6b | 113 | @param StringId On return, contains the new strings id, which is\r |
e52c5a9f | 114 | unique within PackageList.\r |
7d582d6b | 115 | @param String Points to the new null-terminated string.\r |
116 | \r | |
e52c5a9f | 117 | @retval EFI_SUCCESS The new string was added successfully.\r |
7d582d6b | 118 | @retval EFI_OUT_OF_RESOURCES Could not add the string due to lack of resources.\r |
7d582d6b | 119 | \r |
120 | **/\r | |
121 | EFI_STATUS\r | |
122 | EFIAPI\r | |
e52c5a9f | 123 | HiiLibNewString (\r |
7d582d6b | 124 | IN EFI_HII_HANDLE PackageList,\r |
125 | OUT EFI_STRING_ID *StringId,\r | |
126 | IN CONST EFI_STRING String\r | |
127 | )\r | |
128 | ;\r | |
129 | \r | |
130 | /**\r | |
e52c5a9f | 131 | This function update the specified string in String Package of each language\r |
132 | supported by the package list.\r | |
133 | \r | |
134 | If String is NULL, then ASSERT.\r | |
135 | If PackageList could not be found in the default HII database, then ASSERT.\r | |
136 | If StringId is not found in PackageList, then ASSERT.\r | |
7d582d6b | 137 | \r |
138 | @param PackageList Handle of the package list where this string will\r | |
e52c5a9f | 139 | be added.\r |
7d582d6b | 140 | @param StringId Ths String Id to be updated.\r |
141 | @param String Points to the new null-terminated string.\r | |
142 | \r | |
143 | @retval EFI_SUCCESS The new string was added successfully.\r | |
7d582d6b | 144 | @retval EFI_OUT_OF_RESOURCES Could not add the string due to lack of resources.\r |
7d582d6b | 145 | \r |
146 | **/\r | |
147 | EFI_STATUS\r | |
148 | EFIAPI\r | |
e52c5a9f | 149 | HiiLibSetString (\r |
7d582d6b | 150 | IN EFI_HII_HANDLE PackageList,\r |
151 | IN EFI_STRING_ID StringId,\r | |
152 | IN CONST EFI_STRING String\r | |
153 | )\r | |
154 | ;\r | |
155 | \r | |
e52c5a9f | 156 | /**\r |
157 | This function try to retrieve string from String package of current language.\r | |
158 | If fails, it try to retrieve string from String package of first language it support.\r | |
159 | \r | |
160 | If String is NULL, then ASSERT.\r | |
161 | If StringSize is NULL, then ASSERT.\r | |
162 | If PackageList could not be found in the default HII database, then ASSERT.\r | |
163 | If StringId is not found in PackageList, then ASSERT.\r | |
164 | \r | |
165 | @param PackageList The package list in the HII database to search for\r | |
166 | the specified string.\r | |
167 | @param StringId The string's id, which is unique within\r | |
168 | PackageList.\r | |
169 | @param String Points to the new null-terminated string.\r | |
170 | @param StringSize On entry, points to the size of the buffer pointed\r | |
171 | to by String, in bytes. On return, points to the\r | |
172 | length of the string, in bytes.\r | |
173 | \r | |
174 | @retval EFI_SUCCESS The string was returned successfully.\r | |
175 | @retval EFI_NOT_FOUND The string specified by StringId is not available.\r | |
176 | @retval EFI_BUFFER_TOO_SMALL The buffer specified by StringLength is too small\r | |
177 | to hold the string.\r | |
178 | @retval EFI_INVALID_PARAMETER The String or StringSize was NULL.\r | |
7d582d6b | 179 | \r |
e52c5a9f | 180 | **/\r |
7d582d6b | 181 | EFI_STATUS\r |
182 | EFIAPI\r | |
e52c5a9f | 183 | HiiLibGetString (\r |
184 | IN EFI_HII_HANDLE PackageList,\r | |
185 | IN EFI_STRING_ID StringId,\r | |
186 | OUT EFI_STRING String,\r | |
187 | IN OUT UINTN *StringSize\r | |
188 | )\r | |
189 | ;\r | |
190 | \r | |
191 | /**\r | |
192 | Get string specified by StringId form the HiiHandle. The caller\r | |
193 | is responsible to free the *String.\r | |
194 | \r | |
195 | If String is NULL, then ASSERT.\r | |
196 | If HiiHandle could not be found in the default HII database, then ASSERT.\r | |
197 | If StringId is not found in PackageList, then ASSERT.\r | |
198 | \r | |
199 | @param HiiHandle The HII handle of package list.\r | |
200 | @param StringId The String ID.\r | |
201 | @param String The output string.\r | |
202 | \r | |
203 | @retval EFI_NOT_FOUND String is not found.\r | |
204 | @retval EFI_SUCCESS Operation is successful.\r | |
205 | @retval EFI_OUT_OF_RESOURCES There is not enought memory in the system.\r | |
206 | @retval EFI_INVALID_PARAMETER The String is NULL.\r | |
207 | \r | |
208 | **/\r | |
209 | EFI_STATUS\r | |
210 | EFIAPI\r | |
211 | HiiLibGetStringFromHandle (\r | |
212 | IN EFI_HII_HANDLE HiiHandle,\r | |
7d582d6b | 213 | IN EFI_STRING_ID StringId,\r |
214 | OUT EFI_STRING *String\r | |
215 | )\r | |
216 | ;\r | |
217 | \r | |
e52c5a9f | 218 | /**\r |
219 | Get the string given the StringId and String package Producer's Guid. The caller\r | |
220 | is responsible to free the *String.\r | |
221 | \r | |
222 | If PackageList with the matching ProducerGuid is not found, then ASSERT.\r | |
223 | If PackageList with the matching ProducerGuid is found but no String is\r | |
224 | specified by StringId is found, then ASSERT.\r | |
225 | \r | |
226 | @param ProducerGuid The Guid of String package list.\r | |
227 | @param StringId The String ID.\r | |
228 | @param String The output string.\r | |
229 | \r | |
230 | @retval EFI_SUCCESS Operation is successful.\r | |
231 | @retval EFI_OUT_OF_RESOURCES There is not enought memory in the system.\r | |
232 | \r | |
233 | **/\r | |
7d582d6b | 234 | EFI_STATUS\r |
235 | EFIAPI\r | |
e52c5a9f | 236 | HiiLibGetStringFromToken (\r |
237 | IN EFI_GUID *ProducerGuid,\r | |
238 | IN EFI_STRING_ID StringId,\r | |
239 | OUT EFI_STRING *String\r | |
7d582d6b | 240 | )\r |
241 | ;\r | |
242 | \r | |
e52c5a9f | 243 | /**\r |
244 | Determines the handles that are currently active in the database.\r | |
245 | It's the caller's responsibility to free handle buffer.\r | |
246 | \r | |
247 | If HandleBufferLength is NULL, then ASSERT.\r | |
248 | If HiiHandleBuffer is NULL, then ASSERT.\r | |
249 | \r | |
e52c5a9f | 250 | @param HandleBufferLength On input, a pointer to the length of the handle\r |
251 | buffer. On output, the length of the handle buffer\r | |
252 | that is required for the handles found.\r | |
253 | @param HiiHandleBuffer Pointer to an array of Hii Handles returned.\r | |
254 | \r | |
255 | @retval EFI_SUCCESS Get an array of Hii Handles successfully.\r | |
256 | \r | |
257 | **/\r | |
7d582d6b | 258 | EFI_STATUS\r |
259 | EFIAPI\r | |
e52c5a9f | 260 | HiiLibGetHiiHandles (\r |
261 | IN OUT UINTN *HandleBufferLength,\r | |
262 | OUT EFI_HII_HANDLE **HiiHandleBuffer\r | |
7d582d6b | 263 | )\r |
264 | ;\r | |
265 | \r | |
e52c5a9f | 266 | /**\r |
267 | Extract Hii package list GUID for given HII handle.\r | |
268 | \r | |
269 | If HiiHandle could not be found in the default HII database, then ASSERT.\r | |
270 | If Guid is NULL, then ASSERT.\r | |
271 | \r | |
01aef47b | 272 | @param Handle Hii handle\r |
273 | @param Guid Package list GUID\r | |
7d582d6b | 274 | \r |
e52c5a9f | 275 | @retval EFI_SUCCESS Successfully extract GUID from Hii database.\r |
276 | \r | |
277 | **/\r | |
7d582d6b | 278 | EFI_STATUS\r |
e52c5a9f | 279 | EFIAPI\r |
280 | HiiLibExtractGuidFromHiiHandle (\r | |
7d582d6b | 281 | IN EFI_HII_HANDLE Handle,\r |
e52c5a9f | 282 | OUT EFI_GUID *Guid\r |
283 | )\r | |
284 | ;\r | |
285 | \r | |
286 | /**\r | |
287 | Find HII Handle in the default HII database associated with given Device Path.\r | |
288 | \r | |
289 | If DevicePath is NULL, then ASSERT.\r | |
290 | \r | |
291 | @param DevicePath Device Path associated with the HII package list\r | |
292 | handle.\r | |
293 | \r | |
294 | @retval Handle HII package list Handle associated with the Device\r | |
295 | Path.\r | |
296 | @retval NULL Hii Package list handle is not found.\r | |
297 | \r | |
298 | **/\r | |
299 | EFI_HII_HANDLE\r | |
300 | EFIAPI\r | |
301 | HiiLibDevicePathToHiiHandle (\r | |
302 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
303 | )\r | |
304 | ;\r | |
305 | \r | |
306 | \r | |
307 | /**\r | |
308 | Determine what is the current language setting. The space reserved for Lang\r | |
309 | must be at least RFC_3066_ENTRY_SIZE bytes;\r | |
310 | \r | |
311 | If Lang is NULL, then ASSERT.\r | |
312 | \r | |
313 | @param Lang Pointer of system language. Lang will always be filled with \r | |
314 | a valid RFC 3066 language string. If "PlatformLang" is not\r | |
315 | set in the system, the default language specifed by PcdUefiVariableDefaultPlatformLang\r | |
316 | is returned.\r | |
317 | \r | |
318 | @return EFI_SUCCESS If the EFI Variable with "PlatformLang" is set and return in Lang.\r | |
319 | @return EFI_NOT_FOUND If the EFI Variable with "PlatformLang" is not set, but a valid default language is return in Lang.\r | |
320 | \r | |
321 | **/\r | |
322 | EFI_STATUS\r | |
323 | EFIAPI\r | |
324 | HiiLibGetCurrentLanguage (\r | |
325 | OUT CHAR8 *Lang\r | |
7d582d6b | 326 | )\r |
e52c5a9f | 327 | ;\r |
7d582d6b | 328 | \r |
e52c5a9f | 329 | /**\r |
330 | Get next language from language code list (with separator ';').\r | |
7d582d6b | 331 | \r |
e52c5a9f | 332 | If LangCode is NULL, then ASSERT.\r |
333 | If Lang is NULL, then ASSERT.\r | |
7d582d6b | 334 | \r |
e52c5a9f | 335 | @param LangCode On input: point to first language in the list. On\r |
336 | output: point to next language in the list, or\r | |
337 | NULL if no more language in the list.\r | |
338 | @param Lang The first language in the list.\r | |
7d582d6b | 339 | \r |
e52c5a9f | 340 | **/\r |
341 | VOID\r | |
342 | EFIAPI\r | |
343 | HiiLibGetNextLanguage (\r | |
344 | IN OUT CHAR8 **LangCode,\r | |
345 | OUT CHAR8 *Lang\r | |
346 | )\r | |
347 | ;\r | |
348 | \r | |
349 | /**\r | |
350 | This function returns the list of supported languages, in the format specified\r | |
351 | in UEFI specification Appendix M.\r | |
352 | \r | |
353 | If HiiHandle is not a valid Handle in the default HII database, then ASSERT.\r | |
e52c5a9f | 354 | \r |
355 | @param HiiHandle The HII package list handle.\r | |
356 | \r | |
33b3b832 | 357 | @retval !NULL The supported languages.\r |
358 | @retval NULL If Supported Languages can not be retrived.\r | |
e52c5a9f | 359 | \r |
360 | **/\r | |
361 | CHAR8 *\r | |
362 | EFIAPI\r | |
363 | HiiLibGetSupportedLanguages (\r | |
364 | IN EFI_HII_HANDLE HiiHandle\r | |
365 | )\r | |
366 | ;\r | |
367 | \r | |
33b3b832 | 368 | /**\r |
369 | This function returns the list of supported 2nd languages, in the format specified\r | |
370 | in UEFI specification Appendix M.\r | |
371 | \r | |
372 | If HiiHandle is not a valid Handle in the default HII database, then ASSERT.\r | |
373 | If not enough resource to complete the operation, then ASSERT.\r | |
374 | \r | |
375 | @param HiiHandle The HII package list handle.\r | |
01aef47b | 376 | @param FirstLanguage Pointer to language name buffer.\r |
377 | \r | |
33b3b832 | 378 | @return The supported languages.\r |
379 | \r | |
380 | **/\r | |
381 | CHAR8 *\r | |
382 | EFIAPI\r | |
383 | HiiLibGetSupportedSecondaryLanguages (\r | |
384 | IN EFI_HII_HANDLE HiiHandle,\r | |
385 | IN CONST CHAR8 *FirstLanguage\r | |
386 | )\r | |
387 | ;\r | |
388 | \r | |
389 | \r | |
e52c5a9f | 390 | /**\r |
391 | This function returns the number of supported languages on HiiHandle.\r | |
392 | \r | |
393 | If HiiHandle is not a valid Handle in the default HII database, then ASSERT.\r | |
394 | If not enough resource to complete the operation, then ASSERT.\r | |
395 | \r | |
396 | @param HiiHandle The HII package list handle.\r | |
397 | \r | |
398 | @return The number of supported languages.\r | |
399 | \r | |
400 | **/\r | |
401 | UINT16\r | |
402 | EFIAPI\r | |
403 | HiiLibGetSupportedLanguageNumber (\r | |
404 | IN EFI_HII_HANDLE HiiHandle\r | |
405 | )\r | |
406 | ;\r | |
407 | \r | |
408 | /**\r | |
409 | Convert language code from RFC3066 to ISO639-2.\r | |
410 | \r | |
6fd5fbe3 | 411 | LanguageRfc3066 contain a single RFC 3066 code such as\r |
412 | "en-US" or "fr-FR".\r | |
413 | \r | |
414 | The LanguageRfc3066 must be a buffer large enough\r | |
415 | for ISO_639_2_ENTRY_SIZE characters.\r | |
416 | \r | |
e52c5a9f | 417 | If LanguageRfc3066 is NULL, then ASSERT.\r |
418 | If LanguageIso639 is NULL, then ASSERT.\r | |
419 | \r | |
420 | @param LanguageRfc3066 RFC3066 language code.\r | |
421 | @param LanguageIso639 ISO639-2 language code.\r | |
422 | \r | |
423 | @retval EFI_SUCCESS Language code converted.\r | |
424 | @retval EFI_NOT_FOUND Language code not found.\r | |
425 | \r | |
426 | **/\r | |
427 | EFI_STATUS\r | |
428 | EFIAPI\r | |
429 | ConvertRfc3066LanguageToIso639Language (\r | |
6fd5fbe3 | 430 | IN CHAR8 *LanguageRfc3066,\r |
431 | OUT CHAR8 *LanguageIso639\r | |
432 | )\r | |
433 | ;\r | |
434 | \r | |
435 | /**\r | |
436 | Convert language code from ISO639-2 to RFC3066.\r | |
437 | \r | |
438 | LanguageIso639 contain a single ISO639-2 code such as\r | |
439 | "eng" or "fra".\r | |
440 | \r | |
441 | The LanguageRfc3066 must be a buffer large enough\r | |
442 | for RFC_3066_ENTRY_SIZE characters.\r | |
443 | \r | |
444 | If LanguageIso639 is NULL, then ASSERT.\r | |
445 | If LanguageRfc3066 is NULL, then ASSERT.\r | |
446 | \r | |
447 | @param LanguageIso639 ISO639-2 language code.\r | |
448 | @param LanguageRfc3066 RFC3066 language code.\r | |
449 | \r | |
450 | @retval EFI_SUCCESS Language code converted.\r | |
451 | @retval EFI_NOT_FOUND Language code not found.\r | |
452 | \r | |
453 | **/\r | |
454 | EFI_STATUS\r | |
455 | EFIAPI\r | |
456 | ConvertIso639LanguageToRfc3066Language (\r | |
457 | IN CONST CHAR8 *LanguageIso639,\r | |
458 | OUT CHAR8 *LanguageRfc3066\r | |
e52c5a9f | 459 | )\r |
460 | ;\r | |
461 | \r | |
462 | /**\r | |
463 | Convert language code list from RFC3066 to ISO639-2, e.g. "en-US;fr-FR" will\r | |
464 | be converted to "engfra".\r | |
465 | \r | |
466 | If SupportedLanguages is NULL, then ASSERT.\r | |
467 | \r | |
468 | @param SupportedLanguages The RFC3066 language list.\r | |
469 | \r | |
470 | @return The ISO639-2 language list.\r | |
471 | \r | |
472 | **/\r | |
473 | CHAR8 *\r | |
474 | EFIAPI\r | |
475 | Rfc3066ToIso639 (\r | |
476 | CHAR8 *SupportedLanguages\r | |
477 | )\r | |
7d582d6b | 478 | ;\r |
fb3df220 | 479 | \r |
480 | #endif\r |