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