]> git.proxmox.com Git - mirror_edk2.git/blame - MdeModulePkg/Include/Library/HiiLib.h
Add FvbServiceLib, HiiLib & IfrSupportLib.h
[mirror_edk2.git] / MdeModulePkg / Include / Library / HiiLib.h
CommitLineData
4c76e9cc 1/** @file\r
2 Public include file for the HII Library\r
3\r
4 Copyright (c) 2007 - 2008, Intel Corporation \r
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
13**/\r
14\r
15#ifndef __HII_LIB_H__\r
16#define __HII_LIB_H__\r
17\r
18\r
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
26 @param GuidId Package GUID.\r
27 @param ... Variable argument list for packages to be assembled.\r
28\r
29 @return Pointer of EFI_HII_PACKAGE_LIST_HEADER.\r
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
38 );\r
39\r
40/**\r
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
45\r
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
49 If HiiHandle is NULL, then ASSERT.\r
50\r
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
59\r
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
62\r
63**/\r
64EFI_STATUS\r
65EFIAPI\r
66HiiLibAddPackages (\r
67 IN UINTN NumberOfPackages,\r
68 IN CONST EFI_GUID *GuidId,\r
69 IN EFI_HANDLE DriverHandle, OPTIONAL\r
70 OUT EFI_HII_HANDLE *HiiHandle,\r
71 ...\r
72 );\r
73\r
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
83**/\r
84VOID\r
85EFIAPI\r
86HiiLibRemovePackages (\r
87 IN EFI_HII_HANDLE HiiHandle\r
88 );\r
89\r
90/**\r
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
97\r
98 @param PackageList Handle of the package list where this string will\r
99 be added.\r
100 @param StringId On return, contains the new strings id, which is\r
101 unique within PackageList.\r
102 @param String Points to the new null-terminated string.\r
103\r
104 @retval EFI_SUCCESS The new string was added successfully.\r
105 @retval EFI_OUT_OF_RESOURCES Could not add the string due to lack of resources.\r
106\r
107**/\r
108EFI_STATUS\r
109EFIAPI\r
110HiiLibNewString (\r
111 IN EFI_HII_HANDLE PackageList,\r
112 OUT EFI_STRING_ID *StringId,\r
113 IN CONST EFI_STRING String\r
114 );\r
115\r
116/**\r
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
123\r
124 @param PackageList Handle of the package list where this string will\r
125 be added.\r
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
130 @retval EFI_OUT_OF_RESOURCES Could not add the string due to lack of resources.\r
131\r
132**/\r
133EFI_STATUS\r
134EFIAPI\r
135HiiLibSetString (\r
136 IN EFI_HII_HANDLE PackageList,\r
137 IN EFI_STRING_ID StringId,\r
138 IN CONST EFI_STRING String\r
139 );\r
140\r
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
145 If StringSize is NULL, then ASSERT.\r
146 If String is NULL and *StringSize is not 0, then ASSERT.\r
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
163\r
164**/\r
165EFI_STATUS\r
166EFIAPI\r
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
172 );\r
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
189\r
190**/\r
191EFI_STATUS\r
192EFIAPI\r
193HiiLibGetStringFromHandle (\r
194 IN EFI_HII_HANDLE HiiHandle,\r
195 IN EFI_STRING_ID StringId,\r
196 OUT EFI_STRING *String\r
197 );\r
198\r
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
215EFI_STATUS\r
216EFIAPI\r
217HiiLibGetStringFromToken (\r
218 IN EFI_GUID *ProducerGuid,\r
219 IN EFI_STRING_ID StringId,\r
220 OUT EFI_STRING *String\r
221 );\r
222\r
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
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
238EFI_STATUS\r
239EFIAPI\r
240HiiLibGetHiiHandles (\r
241 IN OUT UINTN *HandleBufferLength,\r
242 OUT EFI_HII_HANDLE **HiiHandleBuffer\r
243 );\r
244\r
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
251 @param Handle Hii handle\r
252 @param Guid Package list GUID\r
253\r
254 @retval EFI_SUCCESS Successfully extract GUID from Hii database.\r
255\r
256**/\r
257EFI_STATUS\r
258EFIAPI\r
259HiiLibExtractGuidFromHiiHandle (\r
260 IN EFI_HII_HANDLE Handle,\r
261 OUT EFI_GUID *Guid\r
262 );\r
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
281 );\r
282\r
283\r
284/**\r
285 Get next language from language code list (with separator ';').\r
286\r
287 If LangCode is NULL, then ASSERT.\r
288 If Lang is NULL, then ASSERT.\r
289\r
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
294\r
295**/\r
296VOID\r
297EFIAPI\r
298HiiLibGetNextLanguage (\r
299 IN OUT CHAR8 **LangCode,\r
300 OUT CHAR8 *Lang\r
301 );\r
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
308\r
309 @param HiiHandle The HII package list handle.\r
310\r
311 @retval !NULL The supported languages.\r
312 @retval NULL If Supported Languages can not be retrived.\r
313\r
314**/\r
315CHAR8 *\r
316EFIAPI\r
317HiiLibGetSupportedLanguages (\r
318 IN EFI_HII_HANDLE HiiHandle\r
319 );\r
320\r
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
329 @param FirstLanguage Pointer to language name buffer.\r
330 \r
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
339 );\r
340\r
341\r
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
357 );\r
358\r
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
383 );\r
384\r
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
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
429 );\r
430\r
431/**\r
432 Convert language code from RFC3066 to ISO639-2.\r
433\r
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
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
453 IN CHAR8 *LanguageRfc3066,\r
454 OUT CHAR8 *LanguageIso639\r
455 );\r
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
481 );\r
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
498 );\r
499\r
500#endif\r