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