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