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