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