]>
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 | |
fc30687f | 18 | ///\r |
19 | /// Limited buffer size recommended by RFC4646 (4.3. Length Considerations)\r | |
20 | /// (42 characters plus a NULL terminator)\r | |
21 | ///\r | |
7d582d6b | 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 | |
e52c5a9f | 93 | **/\r |
94 | VOID\r | |
7d582d6b | 95 | EFIAPI\r |
e52c5a9f | 96 | HiiLibRemovePackages (\r |
7d582d6b | 97 | IN EFI_HII_HANDLE HiiHandle\r |
98 | )\r | |
99 | ;\r | |
100 | \r | |
101 | /**\r | |
e52c5a9f | 102 | This function adds the string into String Package of each language\r |
103 | supported by the package list.\r | |
104 | \r | |
105 | If String is NULL, then ASSERT.\r | |
106 | If StringId is NULL, the ASSERT.\r | |
107 | If PackageList could not be found in the default HII database, then ASSERT.\r | |
7d582d6b | 108 | \r |
109 | @param PackageList Handle of the package list where this string will\r | |
e52c5a9f | 110 | be added.\r |
7d582d6b | 111 | @param StringId On return, contains the new strings id, which is\r |
e52c5a9f | 112 | unique within PackageList.\r |
7d582d6b | 113 | @param String Points to the new null-terminated string.\r |
114 | \r | |
e52c5a9f | 115 | @retval EFI_SUCCESS The new string was added successfully.\r |
7d582d6b | 116 | @retval EFI_OUT_OF_RESOURCES Could not add the string due to lack of resources.\r |
7d582d6b | 117 | \r |
118 | **/\r | |
119 | EFI_STATUS\r | |
120 | EFIAPI\r | |
e52c5a9f | 121 | HiiLibNewString (\r |
7d582d6b | 122 | IN EFI_HII_HANDLE PackageList,\r |
123 | OUT EFI_STRING_ID *StringId,\r | |
124 | IN CONST EFI_STRING String\r | |
125 | )\r | |
126 | ;\r | |
127 | \r | |
128 | /**\r | |
e52c5a9f | 129 | This function update the specified string in String Package of each language\r |
130 | supported by the package list.\r | |
131 | \r | |
132 | If String is NULL, then ASSERT.\r | |
133 | If PackageList could not be found in the default HII database, then ASSERT.\r | |
134 | If StringId is not found in PackageList, then ASSERT.\r | |
7d582d6b | 135 | \r |
136 | @param PackageList Handle of the package list where this string will\r | |
e52c5a9f | 137 | be added.\r |
7d582d6b | 138 | @param StringId Ths String Id to be updated.\r |
139 | @param String Points to the new null-terminated string.\r | |
140 | \r | |
141 | @retval EFI_SUCCESS The new string was added successfully.\r | |
7d582d6b | 142 | @retval EFI_OUT_OF_RESOURCES Could not add the string due to lack of resources.\r |
7d582d6b | 143 | \r |
144 | **/\r | |
145 | EFI_STATUS\r | |
146 | EFIAPI\r | |
e52c5a9f | 147 | HiiLibSetString (\r |
7d582d6b | 148 | IN EFI_HII_HANDLE PackageList,\r |
149 | IN EFI_STRING_ID StringId,\r | |
150 | IN CONST EFI_STRING String\r | |
151 | )\r | |
152 | ;\r | |
153 | \r | |
e52c5a9f | 154 | /**\r |
155 | This function try to retrieve string from String package of current language.\r | |
156 | If fails, it try to retrieve string from String package of first language it support.\r | |
157 | \r | |
158 | If String is NULL, then ASSERT.\r | |
159 | If StringSize is NULL, then ASSERT.\r | |
160 | If PackageList could not be found in the default HII database, then ASSERT.\r | |
161 | If StringId is not found in PackageList, then ASSERT.\r | |
162 | \r | |
163 | @param PackageList The package list in the HII database to search for\r | |
164 | the specified string.\r | |
165 | @param StringId The string's id, which is unique within\r | |
166 | PackageList.\r | |
167 | @param String Points to the new null-terminated string.\r | |
168 | @param StringSize On entry, points to the size of the buffer pointed\r | |
169 | to by String, in bytes. On return, points to the\r | |
170 | length of the string, in bytes.\r | |
171 | \r | |
172 | @retval EFI_SUCCESS The string was returned successfully.\r | |
173 | @retval EFI_NOT_FOUND The string specified by StringId is not available.\r | |
174 | @retval EFI_BUFFER_TOO_SMALL The buffer specified by StringLength is too small\r | |
175 | to hold the string.\r | |
7d582d6b | 176 | \r |
e52c5a9f | 177 | **/\r |
7d582d6b | 178 | EFI_STATUS\r |
179 | EFIAPI\r | |
e52c5a9f | 180 | HiiLibGetString (\r |
181 | IN EFI_HII_HANDLE PackageList,\r | |
182 | IN EFI_STRING_ID StringId,\r | |
183 | OUT EFI_STRING String,\r | |
184 | IN OUT UINTN *StringSize\r | |
185 | )\r | |
186 | ;\r | |
187 | \r | |
188 | /**\r | |
189 | Get string specified by StringId form the HiiHandle. The caller\r | |
190 | is responsible to free the *String.\r | |
191 | \r | |
192 | If String is NULL, then ASSERT.\r | |
193 | If HiiHandle could not be found in the default HII database, then ASSERT.\r | |
194 | If StringId is not found in PackageList, then ASSERT.\r | |
195 | \r | |
196 | @param HiiHandle The HII handle of package list.\r | |
197 | @param StringId The String ID.\r | |
198 | @param String The output string.\r | |
199 | \r | |
200 | @retval EFI_NOT_FOUND String is not found.\r | |
201 | @retval EFI_SUCCESS Operation is successful.\r | |
202 | @retval EFI_OUT_OF_RESOURCES There is not enought memory in the system.\r | |
203 | @retval EFI_INVALID_PARAMETER The String is NULL.\r | |
204 | \r | |
205 | **/\r | |
206 | EFI_STATUS\r | |
207 | EFIAPI\r | |
208 | HiiLibGetStringFromHandle (\r | |
209 | IN EFI_HII_HANDLE HiiHandle,\r | |
7d582d6b | 210 | IN EFI_STRING_ID StringId,\r |
211 | OUT EFI_STRING *String\r | |
212 | )\r | |
213 | ;\r | |
214 | \r | |
e52c5a9f | 215 | /**\r |
216 | Get the string given the StringId and String package Producer's Guid. The caller\r | |
217 | is responsible to free the *String.\r | |
218 | \r | |
219 | If PackageList with the matching ProducerGuid is not found, then ASSERT.\r | |
220 | If PackageList with the matching ProducerGuid is found but no String is\r | |
221 | specified by StringId is found, then ASSERT.\r | |
222 | \r | |
223 | @param ProducerGuid The Guid of String package list.\r | |
224 | @param StringId The String ID.\r | |
225 | @param String The output string.\r | |
226 | \r | |
227 | @retval EFI_SUCCESS Operation is successful.\r | |
228 | @retval EFI_OUT_OF_RESOURCES There is not enought memory in the system.\r | |
229 | \r | |
230 | **/\r | |
7d582d6b | 231 | EFI_STATUS\r |
232 | EFIAPI\r | |
e52c5a9f | 233 | HiiLibGetStringFromToken (\r |
234 | IN EFI_GUID *ProducerGuid,\r | |
235 | IN EFI_STRING_ID StringId,\r | |
236 | OUT EFI_STRING *String\r | |
7d582d6b | 237 | )\r |
238 | ;\r | |
239 | \r | |
e52c5a9f | 240 | /**\r |
241 | Determines the handles that are currently active in the database.\r | |
242 | It's the caller's responsibility to free handle buffer.\r | |
243 | \r | |
244 | If HandleBufferLength is NULL, then ASSERT.\r | |
245 | If HiiHandleBuffer is NULL, then ASSERT.\r | |
246 | \r | |
e52c5a9f | 247 | @param HandleBufferLength On input, a pointer to the length of the handle\r |
248 | buffer. On output, the length of the handle buffer\r | |
249 | that is required for the handles found.\r | |
250 | @param HiiHandleBuffer Pointer to an array of Hii Handles returned.\r | |
251 | \r | |
252 | @retval EFI_SUCCESS Get an array of Hii Handles successfully.\r | |
253 | \r | |
254 | **/\r | |
7d582d6b | 255 | EFI_STATUS\r |
256 | EFIAPI\r | |
e52c5a9f | 257 | HiiLibGetHiiHandles (\r |
258 | IN OUT UINTN *HandleBufferLength,\r | |
259 | OUT EFI_HII_HANDLE **HiiHandleBuffer\r | |
7d582d6b | 260 | )\r |
261 | ;\r | |
262 | \r | |
e52c5a9f | 263 | /**\r |
264 | Extract Hii package list GUID for given HII handle.\r | |
265 | \r | |
266 | If HiiHandle could not be found in the default HII database, then ASSERT.\r | |
267 | If Guid is NULL, then ASSERT.\r | |
268 | \r | |
01aef47b | 269 | @param Handle Hii handle\r |
270 | @param Guid Package list GUID\r | |
7d582d6b | 271 | \r |
e52c5a9f | 272 | @retval EFI_SUCCESS Successfully extract GUID from Hii database.\r |
273 | \r | |
274 | **/\r | |
7d582d6b | 275 | EFI_STATUS\r |
e52c5a9f | 276 | EFIAPI\r |
277 | HiiLibExtractGuidFromHiiHandle (\r | |
7d582d6b | 278 | IN EFI_HII_HANDLE Handle,\r |
e52c5a9f | 279 | OUT EFI_GUID *Guid\r |
280 | )\r | |
281 | ;\r | |
282 | \r | |
283 | /**\r | |
284 | Find HII Handle in the default HII database associated with given Device Path.\r | |
285 | \r | |
286 | If DevicePath is NULL, then ASSERT.\r | |
287 | \r | |
288 | @param DevicePath Device Path associated with the HII package list\r | |
289 | handle.\r | |
290 | \r | |
291 | @retval Handle HII package list Handle associated with the Device\r | |
292 | Path.\r | |
293 | @retval NULL Hii Package list handle is not found.\r | |
294 | \r | |
295 | **/\r | |
296 | EFI_HII_HANDLE\r | |
297 | EFIAPI\r | |
298 | HiiLibDevicePathToHiiHandle (\r | |
299 | IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r | |
300 | )\r | |
301 | ;\r | |
302 | \r | |
303 | \r | |
304 | /**\r | |
305 | Determine what is the current language setting. The space reserved for Lang\r | |
306 | must be at least RFC_3066_ENTRY_SIZE bytes;\r | |
307 | \r | |
308 | If Lang is NULL, then ASSERT.\r | |
309 | \r | |
310 | @param Lang Pointer of system language. Lang will always be filled with \r | |
311 | a valid RFC 3066 language string. If "PlatformLang" is not\r | |
312 | set in the system, the default language specifed by PcdUefiVariableDefaultPlatformLang\r | |
313 | is returned.\r | |
314 | \r | |
315 | @return EFI_SUCCESS If the EFI Variable with "PlatformLang" is set and return in Lang.\r | |
316 | @return EFI_NOT_FOUND If the EFI Variable with "PlatformLang" is not set, but a valid default language is return in Lang.\r | |
317 | \r | |
318 | **/\r | |
319 | EFI_STATUS\r | |
320 | EFIAPI\r | |
321 | HiiLibGetCurrentLanguage (\r | |
322 | OUT CHAR8 *Lang\r | |
7d582d6b | 323 | )\r |
e52c5a9f | 324 | ;\r |
7d582d6b | 325 | \r |
e52c5a9f | 326 | /**\r |
327 | Get next language from language code list (with separator ';').\r | |
7d582d6b | 328 | \r |
e52c5a9f | 329 | If LangCode is NULL, then ASSERT.\r |
330 | If Lang is NULL, then ASSERT.\r | |
7d582d6b | 331 | \r |
e52c5a9f | 332 | @param LangCode On input: point to first language in the list. On\r |
333 | output: point to next language in the list, or\r | |
334 | NULL if no more language in the list.\r | |
335 | @param Lang The first language in the list.\r | |
7d582d6b | 336 | \r |
e52c5a9f | 337 | **/\r |
338 | VOID\r | |
339 | EFIAPI\r | |
340 | HiiLibGetNextLanguage (\r | |
341 | IN OUT CHAR8 **LangCode,\r | |
342 | OUT CHAR8 *Lang\r | |
343 | )\r | |
344 | ;\r | |
345 | \r | |
346 | /**\r | |
347 | This function returns the list of supported languages, in the format specified\r | |
348 | in UEFI specification Appendix M.\r | |
349 | \r | |
350 | If HiiHandle is not a valid Handle in the default HII database, then ASSERT.\r | |
e52c5a9f | 351 | \r |
352 | @param HiiHandle The HII package list handle.\r | |
353 | \r | |
33b3b832 | 354 | @retval !NULL The supported languages.\r |
355 | @retval NULL If Supported Languages can not be retrived.\r | |
e52c5a9f | 356 | \r |
357 | **/\r | |
358 | CHAR8 *\r | |
359 | EFIAPI\r | |
360 | HiiLibGetSupportedLanguages (\r | |
361 | IN EFI_HII_HANDLE HiiHandle\r | |
362 | )\r | |
363 | ;\r | |
364 | \r | |
33b3b832 | 365 | /**\r |
366 | This function returns the list of supported 2nd languages, in the format specified\r | |
367 | in UEFI specification Appendix M.\r | |
368 | \r | |
369 | If HiiHandle is not a valid Handle in the default HII database, then ASSERT.\r | |
370 | If not enough resource to complete the operation, then ASSERT.\r | |
371 | \r | |
372 | @param HiiHandle The HII package list handle.\r | |
01aef47b | 373 | @param FirstLanguage Pointer to language name buffer.\r |
374 | \r | |
33b3b832 | 375 | @return The supported languages.\r |
376 | \r | |
377 | **/\r | |
378 | CHAR8 *\r | |
379 | EFIAPI\r | |
380 | HiiLibGetSupportedSecondaryLanguages (\r | |
381 | IN EFI_HII_HANDLE HiiHandle,\r | |
382 | IN CONST CHAR8 *FirstLanguage\r | |
383 | )\r | |
384 | ;\r | |
385 | \r | |
386 | \r | |
e52c5a9f | 387 | /**\r |
388 | This function returns the number of supported languages on HiiHandle.\r | |
389 | \r | |
390 | If HiiHandle is not a valid Handle in the default HII database, then ASSERT.\r | |
391 | If not enough resource to complete the operation, then ASSERT.\r | |
392 | \r | |
393 | @param HiiHandle The HII package list handle.\r | |
394 | \r | |
395 | @return The number of supported languages.\r | |
396 | \r | |
397 | **/\r | |
398 | UINT16\r | |
399 | EFIAPI\r | |
400 | HiiLibGetSupportedLanguageNumber (\r | |
401 | IN EFI_HII_HANDLE HiiHandle\r | |
402 | )\r | |
403 | ;\r | |
404 | \r | |
405 | /**\r | |
406 | Convert language code from RFC3066 to ISO639-2.\r | |
407 | \r | |
6fd5fbe3 | 408 | LanguageRfc3066 contain a single RFC 3066 code such as\r |
409 | "en-US" or "fr-FR".\r | |
410 | \r | |
411 | The LanguageRfc3066 must be a buffer large enough\r | |
412 | for ISO_639_2_ENTRY_SIZE characters.\r | |
413 | \r | |
e52c5a9f | 414 | If LanguageRfc3066 is NULL, then ASSERT.\r |
415 | If LanguageIso639 is NULL, then ASSERT.\r | |
416 | \r | |
417 | @param LanguageRfc3066 RFC3066 language code.\r | |
418 | @param LanguageIso639 ISO639-2 language code.\r | |
419 | \r | |
420 | @retval EFI_SUCCESS Language code converted.\r | |
421 | @retval EFI_NOT_FOUND Language code not found.\r | |
422 | \r | |
423 | **/\r | |
424 | EFI_STATUS\r | |
425 | EFIAPI\r | |
426 | ConvertRfc3066LanguageToIso639Language (\r | |
6fd5fbe3 | 427 | IN CHAR8 *LanguageRfc3066,\r |
428 | OUT CHAR8 *LanguageIso639\r | |
429 | )\r | |
430 | ;\r | |
431 | \r | |
432 | /**\r | |
433 | Convert language code from ISO639-2 to RFC3066.\r | |
434 | \r | |
435 | LanguageIso639 contain a single ISO639-2 code such as\r | |
436 | "eng" or "fra".\r | |
437 | \r | |
438 | The LanguageRfc3066 must be a buffer large enough\r | |
439 | for RFC_3066_ENTRY_SIZE characters.\r | |
440 | \r | |
441 | If LanguageIso639 is NULL, then ASSERT.\r | |
442 | If LanguageRfc3066 is NULL, then ASSERT.\r | |
443 | \r | |
444 | @param LanguageIso639 ISO639-2 language code.\r | |
445 | @param LanguageRfc3066 RFC3066 language code.\r | |
446 | \r | |
447 | @retval EFI_SUCCESS Language code converted.\r | |
448 | @retval EFI_NOT_FOUND Language code not found.\r | |
449 | \r | |
450 | **/\r | |
451 | EFI_STATUS\r | |
452 | EFIAPI\r | |
453 | ConvertIso639LanguageToRfc3066Language (\r | |
454 | IN CONST CHAR8 *LanguageIso639,\r | |
455 | OUT CHAR8 *LanguageRfc3066\r | |
e52c5a9f | 456 | )\r |
457 | ;\r | |
458 | \r | |
459 | /**\r | |
460 | Convert language code list from RFC3066 to ISO639-2, e.g. "en-US;fr-FR" will\r | |
461 | be converted to "engfra".\r | |
462 | \r | |
463 | If SupportedLanguages is NULL, then ASSERT.\r | |
464 | \r | |
465 | @param SupportedLanguages The RFC3066 language list.\r | |
466 | \r | |
467 | @return The ISO639-2 language list.\r | |
468 | \r | |
469 | **/\r | |
470 | CHAR8 *\r | |
471 | EFIAPI\r | |
472 | Rfc3066ToIso639 (\r | |
473 | CHAR8 *SupportedLanguages\r | |
474 | )\r | |
7d582d6b | 475 | ;\r |
fb3df220 | 476 | \r |
477 | #endif\r |