2 Public include file for the HII Library
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
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.
19 // Limited buffer size recommended by RFC4646 (4.3. Length Considerations)
20 // (42 characters plus a NULL terminator)
22 #define RFC_3066_ENTRY_SIZE (42 + 1)
24 #define ISO_639_2_ENTRY_SIZE 3
27 Assemble EFI_HII_PACKAGE_LIST according to the passed in packages.
29 If GuidId is NULL, then ASSERT.
30 If not enough resource to complete the operation, then ASSERT.
32 @param NumberOfPackages Number of packages.
33 @param GuidId Package GUID.
34 @param ... Variable argument list for packages to be assembled.
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.
40 EFI_HII_PACKAGE_LIST_HEADER
*
42 HiiLibPreparePackageList (
43 IN UINTN NumberOfPackages
,
44 IN CONST EFI_GUID
*GuidId
,
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.
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.
58 If HiiHandle is NULL, then ASSERT.
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
67 @param ... The variable argument list describing all HII Package.
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.
76 IN UINTN NumberOfPackages
,
77 IN CONST EFI_GUID
*GuidId
,
78 IN EFI_HANDLE DriverHandle
, OPTIONAL
79 OUT EFI_HII_HANDLE
*HiiHandle
,
85 Removes a package list from the default HII database.
87 If HiiHandle is NULL, then ASSERT.
88 If HiiHandle is not a valid EFI_HII_HANDLE in the default HII database, then ASSERT.
90 @param HiiHandle The handle that was previously registered to the data base that is requested for removal.
96 HiiLibRemovePackages (
97 IN EFI_HII_HANDLE HiiHandle
102 This function adds the string into String Package of each language
103 supported by the package list.
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.
109 @param PackageList Handle of the package list where this string will
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.
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.
122 IN EFI_HII_HANDLE PackageList
,
123 OUT EFI_STRING_ID
*StringId
,
124 IN CONST EFI_STRING String
129 This function update the specified string in String Package of each language
130 supported by the package list.
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.
136 @param PackageList Handle of the package list where this string will
138 @param StringId Ths String Id to be updated.
139 @param String Points to the new null-terminated string.
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.
148 IN EFI_HII_HANDLE PackageList
,
149 IN EFI_STRING_ID StringId
,
150 IN CONST EFI_STRING String
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.
158 If String is NULL, then ASSERT.
159 If StringSize is NULL, 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.
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
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.
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
176 @retval EFI_INVALID_PARAMETER The String or StringSize was NULL.
182 IN EFI_HII_HANDLE PackageList
,
183 IN EFI_STRING_ID StringId
,
184 OUT EFI_STRING String
,
185 IN OUT UINTN
*StringSize
190 Get string specified by StringId form the HiiHandle. The caller
191 is responsible to free the *String.
193 If String is NULL, then ASSERT.
194 If HiiHandle could not be found in the default HII database, then ASSERT.
195 If StringId is not found in PackageList, then ASSERT.
197 @param HiiHandle The HII handle of package list.
198 @param StringId The String ID.
199 @param String The output string.
201 @retval EFI_NOT_FOUND String is not found.
202 @retval EFI_SUCCESS Operation is successful.
203 @retval EFI_OUT_OF_RESOURCES There is not enought memory in the system.
204 @retval EFI_INVALID_PARAMETER The String is NULL.
209 HiiLibGetStringFromHandle (
210 IN EFI_HII_HANDLE HiiHandle
,
211 IN EFI_STRING_ID StringId
,
212 OUT EFI_STRING
*String
217 Get the string given the StringId and String package Producer's Guid. The caller
218 is responsible to free the *String.
220 If PackageList with the matching ProducerGuid is not found, then ASSERT.
221 If PackageList with the matching ProducerGuid is found but no String is
222 specified by StringId is found, then ASSERT.
224 @param ProducerGuid The Guid of String package list.
225 @param StringId The String ID.
226 @param String The output string.
228 @retval EFI_SUCCESS Operation is successful.
229 @retval EFI_OUT_OF_RESOURCES There is not enought memory in the system.
234 HiiLibGetStringFromToken (
235 IN EFI_GUID
*ProducerGuid
,
236 IN EFI_STRING_ID StringId
,
237 OUT EFI_STRING
*String
242 Determines the handles that are currently active in the database.
243 It's the caller's responsibility to free handle buffer.
245 If HandleBufferLength is NULL, then ASSERT.
246 If HiiHandleBuffer is NULL, then ASSERT.
248 @param HandleBufferLength On input, a pointer to the length of the handle
249 buffer. On output, the length of the handle buffer
250 that is required for the handles found.
251 @param HiiHandleBuffer Pointer to an array of Hii Handles returned.
253 @retval EFI_SUCCESS Get an array of Hii Handles successfully.
258 HiiLibGetHiiHandles (
259 IN OUT UINTN
*HandleBufferLength
,
260 OUT EFI_HII_HANDLE
**HiiHandleBuffer
265 Extract Hii package list GUID for given HII handle.
267 If HiiHandle could not be found in the default HII database, then ASSERT.
268 If Guid is NULL, then ASSERT.
270 @param Handle Hii handle
271 @param Guid Package list GUID
273 @retval EFI_SUCCESS Successfully extract GUID from Hii database.
278 HiiLibExtractGuidFromHiiHandle (
279 IN EFI_HII_HANDLE Handle
,
285 Find HII Handle in the default HII database associated with given Device Path.
287 If DevicePath is NULL, then ASSERT.
289 @param DevicePath Device Path associated with the HII package list
292 @retval Handle HII package list Handle associated with the Device
294 @retval NULL Hii Package list handle is not found.
299 HiiLibDevicePathToHiiHandle (
300 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
306 Determine what is the current language setting. The space reserved for Lang
307 must be at least RFC_3066_ENTRY_SIZE bytes;
309 If Lang is NULL, then ASSERT.
311 @param Lang Pointer of system language. Lang will always be filled with
312 a valid RFC 3066 language string. If "PlatformLang" is not
313 set in the system, the default language specifed by PcdUefiVariableDefaultPlatformLang
316 @return EFI_SUCCESS If the EFI Variable with "PlatformLang" is set and return in Lang.
317 @return EFI_NOT_FOUND If the EFI Variable with "PlatformLang" is not set, but a valid default language is return in Lang.
322 HiiLibGetCurrentLanguage (
328 Get next language from language code list (with separator ';').
330 If LangCode is NULL, then ASSERT.
331 If Lang is NULL, then ASSERT.
333 @param LangCode On input: point to first language in the list. On
334 output: point to next language in the list, or
335 NULL if no more language in the list.
336 @param Lang The first language in the list.
341 HiiLibGetNextLanguage (
342 IN OUT CHAR8
**LangCode
,
348 This function returns the list of supported languages, in the format specified
349 in UEFI specification Appendix M.
351 If HiiHandle is not a valid Handle in the default HII database, then ASSERT.
353 @param HiiHandle The HII package list handle.
355 @retval !NULL The supported languages.
356 @retval NULL If Supported Languages can not be retrived.
361 HiiLibGetSupportedLanguages (
362 IN EFI_HII_HANDLE HiiHandle
367 This function returns the list of supported 2nd languages, in the format specified
368 in UEFI specification Appendix M.
370 If HiiHandle is not a valid Handle in the default HII database, then ASSERT.
371 If not enough resource to complete the operation, then ASSERT.
373 @param HiiHandle The HII package list handle.
374 @param FirstLanguage Pointer to language name buffer.
376 @return The supported languages.
381 HiiLibGetSupportedSecondaryLanguages (
382 IN EFI_HII_HANDLE HiiHandle
,
383 IN CONST CHAR8
*FirstLanguage
389 This function returns the number of supported languages on HiiHandle.
391 If HiiHandle is not a valid Handle in the default HII database, then ASSERT.
392 If not enough resource to complete the operation, then ASSERT.
394 @param HiiHandle The HII package list handle.
396 @return The number of supported languages.
401 HiiLibGetSupportedLanguageNumber (
402 IN EFI_HII_HANDLE HiiHandle
407 Convert language code from RFC3066 to ISO639-2.
409 LanguageRfc3066 contain a single RFC 3066 code such as
412 The LanguageRfc3066 must be a buffer large enough
413 for ISO_639_2_ENTRY_SIZE characters.
415 If LanguageRfc3066 is NULL, then ASSERT.
416 If LanguageIso639 is NULL, then ASSERT.
418 @param LanguageRfc3066 RFC3066 language code.
419 @param LanguageIso639 ISO639-2 language code.
421 @retval EFI_SUCCESS Language code converted.
422 @retval EFI_NOT_FOUND Language code not found.
427 ConvertRfc3066LanguageToIso639Language (
428 IN CHAR8
*LanguageRfc3066
,
429 OUT CHAR8
*LanguageIso639
434 Convert language code from ISO639-2 to RFC3066.
436 LanguageIso639 contain a single ISO639-2 code such as
439 The LanguageRfc3066 must be a buffer large enough
440 for RFC_3066_ENTRY_SIZE characters.
442 If LanguageIso639 is NULL, then ASSERT.
443 If LanguageRfc3066 is NULL, then ASSERT.
445 @param LanguageIso639 ISO639-2 language code.
446 @param LanguageRfc3066 RFC3066 language code.
448 @retval EFI_SUCCESS Language code converted.
449 @retval EFI_NOT_FOUND Language code not found.
454 ConvertIso639LanguageToRfc3066Language (
455 IN CONST CHAR8
*LanguageIso639
,
456 OUT CHAR8
*LanguageRfc3066
461 Convert language code list from RFC3066 to ISO639-2, e.g. "en-US;fr-FR" will
462 be converted to "engfra".
464 If SupportedLanguages is NULL, then ASSERT.
466 @param SupportedLanguages The RFC3066 language list.
468 @return The ISO639-2 language list.
474 CHAR8
*SupportedLanguages