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 RFC3066
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 Pointer of EFI_HII_PACKAGE_LIST_HEADER.
39 EFI_HII_PACKAGE_LIST_HEADER
*
41 HiiLibPreparePackageList (
42 IN UINTN NumberOfPackages
,
43 IN CONST EFI_GUID
*GuidId
,
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.
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.
56 If HiiHandle is NULL, then ASSERT.
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
65 @param ... The variable argument list describing all HII Package.
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.
74 IN UINTN NumberOfPackages
,
75 IN CONST EFI_GUID
*GuidId
,
76 IN EFI_HANDLE DriverHandle
, OPTIONAL
77 OUT EFI_HII_HANDLE
*HiiHandle
,
82 Removes a package list from the default HII database.
84 If HiiHandle is NULL, then ASSERT.
85 If HiiHandle is not a valid EFI_HII_HANDLE in the default HII database, then ASSERT.
87 @param HiiHandle The handle that was previously registered to the data base that is requested for removal.
93 HiiLibRemovePackages (
94 IN EFI_HII_HANDLE HiiHandle
98 This function adds the string into String Package of each language
99 supported by the package list.
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.
105 @param PackageList Handle of the package list where this string will
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.
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.
118 IN EFI_HII_HANDLE PackageList
,
119 OUT EFI_STRING_ID
*StringId
,
120 IN CONST EFI_STRING String
124 This function update the specified string in String Package of each language
125 supported by the package list.
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.
131 @param PackageList Handle of the package list where this string will
133 @param StringId Ths String Id to be updated.
134 @param String Points to the new null-terminated string.
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.
143 IN EFI_HII_HANDLE PackageList
,
144 IN EFI_STRING_ID StringId
,
145 IN CONST EFI_STRING String
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.
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.
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
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.
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
175 IN EFI_HII_HANDLE PackageList
,
176 IN EFI_STRING_ID StringId
,
177 OUT EFI_STRING String
,
178 IN OUT UINTN
*StringSize
182 Get string specified by StringId form the HiiHandle. The caller
183 is responsible to free the *String.
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.
189 @param HiiHandle The HII handle of package list.
190 @param StringId The String ID.
191 @param String The output string.
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.
200 HiiLibGetStringFromHandle (
201 IN EFI_HII_HANDLE HiiHandle
,
202 IN EFI_STRING_ID StringId
,
203 OUT EFI_STRING
*String
207 Get the string given the StringId and String package Producer's Guid. The caller
208 is responsible to free the *String.
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.
214 @param ProducerGuid The Guid of String package list.
215 @param StringId The String ID.
216 @param String The output string.
218 @retval EFI_SUCCESS Operation is successful.
219 @retval EFI_OUT_OF_RESOURCES There is not enought memory in the system.
224 HiiLibGetStringFromToken (
225 IN EFI_GUID
*ProducerGuid
,
226 IN EFI_STRING_ID StringId
,
227 OUT EFI_STRING
*String
231 Determines the handles that are currently active in the database.
232 It's the caller's responsibility to free handle buffer.
234 If HandleBufferLength is NULL, then ASSERT.
235 If HiiHandleBuffer is NULL, then ASSERT.
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.
242 @retval EFI_SUCCESS Get an array of Hii Handles successfully.
247 HiiLibGetHiiHandles (
248 IN OUT UINTN
*HandleBufferLength
,
249 OUT EFI_HII_HANDLE
**HiiHandleBuffer
253 Extract Hii package list GUID for given HII handle.
255 If HiiHandle could not be found in the default HII database, then ASSERT.
256 If Guid is NULL, then ASSERT.
258 @param Handle Hii handle
259 @param Guid Package list GUID
261 @retval EFI_SUCCESS Successfully extract GUID from Hii database.
266 HiiLibExtractGuidFromHiiHandle (
267 IN EFI_HII_HANDLE Handle
,
272 Find HII Handle in the default HII database associated with given Device Path.
274 If DevicePath is NULL, then ASSERT.
276 @param DevicePath Device Path associated with the HII package list
279 @retval Handle HII package list Handle associated with the Device
281 @retval NULL Hii Package list handle is not found.
286 HiiLibDevicePathToHiiHandle (
287 IN EFI_DEVICE_PATH_PROTOCOL
*DevicePath
292 Determine what is the current language setting. The space reserved for Lang
293 must be at least RFC_3066_ENTRY_SIZE bytes;
295 If Lang is NULL, then ASSERT.
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
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.
308 HiiLibGetCurrentLanguage (
313 Get next language from language code list (with separator ';').
315 If LangCode is NULL, then ASSERT.
316 If Lang is NULL, then ASSERT.
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.
326 HiiLibGetNextLanguage (
327 IN OUT CHAR8
**LangCode
,
332 This function returns the list of supported languages, in the format specified
333 in UEFI specification Appendix M.
335 If HiiHandle is not a valid Handle in the default HII database, then ASSERT.
337 @param HiiHandle The HII package list handle.
339 @retval !NULL The supported languages.
340 @retval NULL If Supported Languages can not be retrived.
345 HiiLibGetSupportedLanguages (
346 IN EFI_HII_HANDLE HiiHandle
350 This function returns the list of supported 2nd languages, in the format specified
351 in UEFI specification Appendix M.
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.
356 @param HiiHandle The HII package list handle.
357 @param FirstLanguage Pointer to language name buffer.
359 @return The supported languages.
364 HiiLibGetSupportedSecondaryLanguages (
365 IN EFI_HII_HANDLE HiiHandle
,
366 IN CONST CHAR8
*FirstLanguage
371 This function returns the number of supported languages on HiiHandle.
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.
376 @param HiiHandle The HII package list handle.
378 @return The number of supported languages.
383 HiiLibGetSupportedLanguageNumber (
384 IN EFI_HII_HANDLE HiiHandle
388 Exports the contents of one or all package lists in the HII database into a buffer.
390 If Handle is not NULL and not a valid EFI_HII_HANDLE registered in the database,
392 If PackageListHeader is NULL, then ASSERT.
393 If PackageListSize is NULL, then ASSERT.
395 @param Handle The HII Handle.
396 @param PackageListHeader A pointer to a buffer that will contain the results of
398 @param PackageListSize On output, the length of the buffer that is required for the exported data.
400 @retval EFI_SUCCESS Package exported.
402 @retval EFI_OUT_OF_RESOURCES Not enought memory to complete the operations.
407 HiiLibExportPackageLists (
408 IN EFI_HII_HANDLE Handle
,
409 OUT EFI_HII_PACKAGE_LIST_HEADER
**PackageListHeader
,
410 OUT UINTN
*PackageListSize
415 HiiLibListPackageLists (
416 IN UINT8 PackageType
,
417 IN CONST EFI_GUID
*PackageGuid
,
418 IN OUT UINTN
*HandleBufferLength
,
419 OUT EFI_HII_HANDLE
**Handle
423 Convert language code from RFC3066 to ISO639-2.
425 LanguageRfc3066 contain a single RFC 3066 code such as
428 The LanguageRfc3066 must be a buffer large enough
429 for ISO_639_2_ENTRY_SIZE characters.
431 If LanguageRfc3066 is NULL, then ASSERT.
432 If LanguageIso639 is NULL, then ASSERT.
434 @param LanguageRfc3066 RFC3066 language code.
435 @param LanguageIso639 ISO639-2 language code.
437 @retval EFI_SUCCESS Language code converted.
438 @retval EFI_NOT_FOUND Language code not found.
443 ConvertRfc3066LanguageToIso639Language (
444 IN CHAR8
*LanguageRfc3066
,
445 OUT CHAR8
*LanguageIso639
449 Convert language code from ISO639-2 to RFC3066.
451 LanguageIso639 contain a single ISO639-2 code such as
454 The LanguageRfc3066 must be a buffer large enough
455 for RFC_3066_ENTRY_SIZE characters.
457 If LanguageIso639 is NULL, then ASSERT.
458 If LanguageRfc3066 is NULL, then ASSERT.
460 @param LanguageIso639 ISO639-2 language code.
461 @param LanguageRfc3066 RFC3066 language code.
463 @retval EFI_SUCCESS Language code converted.
464 @retval EFI_NOT_FOUND Language code not found.
469 ConvertIso639LanguageToRfc3066Language (
470 IN CONST CHAR8
*LanguageIso639
,
471 OUT CHAR8
*LanguageRfc3066
475 Convert language code list from RFC3066 to ISO639-2, e.g. "en-US;fr-FR" will
476 be converted to "engfra".
478 If SupportedLanguages is NULL, then ASSERT.
480 @param SupportedLanguages The RFC3066 language list.
482 @return The ISO639-2 language list.
488 CHAR8
*SupportedLanguages