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