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