/** @file\r
- Public include file for the HII Library\r
+ Public include file for the HII Library\r
\r
- Copyright (c) 2006, Intel Corporation \r
- All rights reserved. This program and the accompanying materials \r
- are licensed and made available under the terms and conditions of the BSD License \r
- which accompanies this distribution. The full text of the license may be found at \r
- http://opensource.org/licenses/bsd-license.php \r
+ Copyright (c) 2007 - 2008, Intel Corporation \r
+ All rights reserved. This program and the accompanying materials \r
+ are licensed and made available under the terms and conditions of the BSD License \r
+ which accompanies this distribution. The full text of the license may be found at \r
+ http://opensource.org/licenses/bsd-license.php \r
\r
- THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
- WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
-\r
- Module Name: HiiLib.h\r
+ THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS, \r
+ WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED. \r
\r
**/\r
\r
#ifndef __HII_LIB_H__\r
#define __HII_LIB_H__\r
\r
+///\r
+/// Limited buffer size recommended by RFC4646 (4.3. Length Considerations)\r
+/// (42 characters plus a NULL terminator)\r
+///\r
+#define RFC_3066_ENTRY_SIZE (42 + 1)\r
+\r
+#define ISO_639_2_ENTRY_SIZE 3\r
+\r
+/**\r
+ Assemble EFI_HII_PACKAGE_LIST according to the passed in packages.\r
+\r
+ If GuidId is NULL, then ASSERT.\r
+ If not enough resource to complete the operation, then ASSERT.\r
+\r
+ @param NumberOfPackages Number of packages.\r
+ @param GuidId Package GUID.\r
+ @param ... Variable argument list for packages to be assembled.\r
+\r
+ @return EFI_HII_PACKAGE_LIST_HEADER Pointer of EFI_HII_PACKAGE_LIST_HEADER. The function will ASSERT if system has\r
+ not enough resource to complete the operation.\r
+\r
+**/\r
+EFI_HII_PACKAGE_LIST_HEADER *\r
+EFIAPI\r
+HiiLibPreparePackageList (\r
+ IN UINTN NumberOfPackages,\r
+ IN CONST EFI_GUID *GuidId,\r
+ ...\r
+ )\r
+;\r
+\r
/**\r
- This function allocates pool for an EFI_HII_PACKAGES structure\r
- with enough space for the variable argument list of package pointers.\r
- The allocated structure is initialized using NumberOfPackages, Guid, \r
- and the variable length argument list of package pointers.\r
+ This function allocates pool for an EFI_HII_PACKAGE_LIST structure\r
+ with additional space that is big enough to host all packages described by the variable \r
+ argument list of package pointers. The allocated structure is initialized using NumberOfPackages, \r
+ GuidId, and the variable length argument list of package pointers.\r
+\r
+ Then, EFI_HII_PACKAGE_LIST will be register to the default System HII Database. The\r
+ Handle to the newly registered Package List is returned throught HiiHandle.\r
\r
- @param NumberOfPackages The number of HII packages to prepare.\r
- @param Guid Package GUID.\r
+ If HiiHandle is NULL, then ASSERT.\r
\r
- @return\r
- The allocated and initialized packages.\r
+ @param NumberOfPackages The number of HII packages to register.\r
+ @param GuidId Package List GUID ID.\r
+ @param DriverHandle Optional. If not NULL, the DriverHandle on which an instance of DEVICE_PATH_PROTOCOL is installed.\r
+ This DriverHandle uniquely defines the device that the added packages are associated with.\r
+ @param HiiHandle On output, the HiiHandle is update with the handle which can be used to retrieve the Package \r
+ List later. If the functions failed to add the package to the default HII database, this value will\r
+ be set to NULL.\r
+ @param ... The variable argument list describing all HII Package.\r
+\r
+ @return EFI_SUCCESS If the packages are successfully added to the default HII database.\r
+ @return EFI_OUT_OF_RESOURCE Not enough resource to complete the operation.\r
\r
**/\r
-EFI_HII_PACKAGES *\r
+EFI_STATUS\r
EFIAPI\r
-PreparePackages (\r
- IN UINTN NumberOfPackages,\r
- IN CONST EFI_GUID *Guid OPTIONAL,\r
+HiiLibAddPackages (\r
+ IN UINTN NumberOfPackages,\r
+ IN CONST EFI_GUID *GuidId,\r
+ IN EFI_HANDLE DriverHandle, OPTIONAL\r
+ OUT EFI_HII_HANDLE *HiiHandle,\r
...\r
)\r
;\r
\r
+/**\r
+ Removes a package list from the default HII database.\r
+\r
+ If HiiHandle is NULL, then ASSERT.\r
+ If HiiHandle is not a valid EFI_HII_HANDLE in the default HII database, then ASSERT.\r
+\r
+ @param HiiHandle The handle that was previously registered to the data base that is requested for removal.\r
+ List later.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+HiiLibRemovePackages (\r
+ IN EFI_HII_HANDLE HiiHandle\r
+ )\r
+;\r
+\r
+/**\r
+ This function adds the string into String Package of each language\r
+ supported by the package list.\r
+\r
+ If String is NULL, then ASSERT.\r
+ If StringId is NULL, the ASSERT.\r
+ If PackageList could not be found in the default HII database, then ASSERT.\r
+\r
+ @param PackageList Handle of the package list where this string will\r
+ be added.\r
+ @param StringId On return, contains the new strings id, which is\r
+ unique within PackageList.\r
+ @param String Points to the new null-terminated string.\r
+\r
+ @retval EFI_SUCCESS The new string was added successfully.\r
+ @retval EFI_OUT_OF_RESOURCES Could not add the string due to lack of resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibNewString (\r
+ IN EFI_HII_HANDLE PackageList,\r
+ OUT EFI_STRING_ID *StringId,\r
+ IN CONST EFI_STRING String\r
+ )\r
+;\r
+\r
+/**\r
+ This function update the specified string in String Package of each language\r
+ supported by the package list.\r
+\r
+ If String is NULL, then ASSERT.\r
+ If PackageList could not be found in the default HII database, then ASSERT.\r
+ If StringId is not found in PackageList, then ASSERT.\r
+\r
+ @param PackageList Handle of the package list where this string will\r
+ be added.\r
+ @param StringId Ths String Id to be updated.\r
+ @param String Points to the new null-terminated string.\r
+\r
+ @retval EFI_SUCCESS The new string was added successfully.\r
+ @retval EFI_OUT_OF_RESOURCES Could not add the string due to lack of resources.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibSetString (\r
+ IN EFI_HII_HANDLE PackageList,\r
+ IN EFI_STRING_ID StringId,\r
+ IN CONST EFI_STRING String\r
+ )\r
+;\r
+\r
+/**\r
+ This function try to retrieve string from String package of current language.\r
+ If fails, it try to retrieve string from String package of first language it support.\r
+\r
+ If String is NULL, then ASSERT.\r
+ If StringSize is NULL, then ASSERT.\r
+ If PackageList could not be found in the default HII database, then ASSERT.\r
+ If StringId is not found in PackageList, then ASSERT.\r
+\r
+ @param PackageList The package list in the HII database to search for\r
+ the specified string.\r
+ @param StringId The string's id, which is unique within\r
+ PackageList.\r
+ @param String Points to the new null-terminated string.\r
+ @param StringSize On entry, points to the size of the buffer pointed\r
+ to by String, in bytes. On return, points to the\r
+ length of the string, in bytes.\r
+\r
+ @retval EFI_SUCCESS The string was returned successfully.\r
+ @retval EFI_NOT_FOUND The string specified by StringId is not available.\r
+ @retval EFI_BUFFER_TOO_SMALL The buffer specified by StringLength is too small\r
+ to hold the string.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibGetString (\r
+ IN EFI_HII_HANDLE PackageList,\r
+ IN EFI_STRING_ID StringId,\r
+ OUT EFI_STRING String,\r
+ IN OUT UINTN *StringSize\r
+ )\r
+;\r
+\r
+/**\r
+ Get string specified by StringId form the HiiHandle. The caller\r
+ is responsible to free the *String.\r
+\r
+ If String is NULL, then ASSERT.\r
+ If HiiHandle could not be found in the default HII database, then ASSERT.\r
+ If StringId is not found in PackageList, then ASSERT.\r
+\r
+ @param HiiHandle The HII handle of package list.\r
+ @param StringId The String ID.\r
+ @param String The output string.\r
+\r
+ @retval EFI_NOT_FOUND String is not found.\r
+ @retval EFI_SUCCESS Operation is successful.\r
+ @retval EFI_OUT_OF_RESOURCES There is not enought memory in the system.\r
+ @retval EFI_INVALID_PARAMETER The String is NULL.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibGetStringFromHandle (\r
+ IN EFI_HII_HANDLE HiiHandle,\r
+ IN EFI_STRING_ID StringId,\r
+ OUT EFI_STRING *String\r
+ )\r
+;\r
+\r
+/**\r
+ Get the string given the StringId and String package Producer's Guid. The caller\r
+ is responsible to free the *String.\r
+\r
+ If PackageList with the matching ProducerGuid is not found, then ASSERT.\r
+ If PackageList with the matching ProducerGuid is found but no String is\r
+ specified by StringId is found, then ASSERT.\r
+\r
+ @param ProducerGuid The Guid of String package list.\r
+ @param StringId The String ID.\r
+ @param String The output string.\r
+\r
+ @retval EFI_SUCCESS Operation is successful.\r
+ @retval EFI_OUT_OF_RESOURCES There is not enought memory in the system.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibGetStringFromToken (\r
+ IN EFI_GUID *ProducerGuid,\r
+ IN EFI_STRING_ID StringId,\r
+ OUT EFI_STRING *String\r
+ )\r
+;\r
+\r
+/**\r
+ Determines the handles that are currently active in the database.\r
+ It's the caller's responsibility to free handle buffer.\r
+\r
+ If HandleBufferLength is NULL, then ASSERT.\r
+ If HiiHandleBuffer is NULL, then ASSERT.\r
+\r
+ @param HandleBufferLength On input, a pointer to the length of the handle\r
+ buffer. On output, the length of the handle buffer\r
+ that is required for the handles found.\r
+ @param HiiHandleBuffer Pointer to an array of Hii Handles returned.\r
+\r
+ @retval EFI_SUCCESS Get an array of Hii Handles successfully.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibGetHiiHandles (\r
+ IN OUT UINTN *HandleBufferLength,\r
+ OUT EFI_HII_HANDLE **HiiHandleBuffer\r
+ )\r
+;\r
+\r
+/**\r
+ Extract Hii package list GUID for given HII handle.\r
+\r
+ If HiiHandle could not be found in the default HII database, then ASSERT.\r
+ If Guid is NULL, then ASSERT.\r
+\r
+ @param Handle Hii handle\r
+ @param Guid Package list GUID\r
+\r
+ @retval EFI_SUCCESS Successfully extract GUID from Hii database.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibExtractGuidFromHiiHandle (\r
+ IN EFI_HII_HANDLE Handle,\r
+ OUT EFI_GUID *Guid\r
+ )\r
+;\r
+\r
+/**\r
+ Find HII Handle in the default HII database associated with given Device Path.\r
+\r
+ If DevicePath is NULL, then ASSERT.\r
+\r
+ @param DevicePath Device Path associated with the HII package list\r
+ handle.\r
+\r
+ @retval Handle HII package list Handle associated with the Device\r
+ Path.\r
+ @retval NULL Hii Package list handle is not found.\r
+\r
+**/\r
+EFI_HII_HANDLE\r
+EFIAPI\r
+HiiLibDevicePathToHiiHandle (\r
+ IN EFI_DEVICE_PATH_PROTOCOL *DevicePath\r
+ )\r
+;\r
+\r
+\r
+/**\r
+ Determine what is the current language setting. The space reserved for Lang\r
+ must be at least RFC_3066_ENTRY_SIZE bytes;\r
+\r
+ If Lang is NULL, then ASSERT.\r
+\r
+ @param Lang Pointer of system language. Lang will always be filled with \r
+ a valid RFC 3066 language string. If "PlatformLang" is not\r
+ set in the system, the default language specifed by PcdUefiVariableDefaultPlatformLang\r
+ is returned.\r
+\r
+ @return EFI_SUCCESS If the EFI Variable with "PlatformLang" is set and return in Lang.\r
+ @return EFI_NOT_FOUND If the EFI Variable with "PlatformLang" is not set, but a valid default language is return in Lang.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibGetCurrentLanguage (\r
+ OUT CHAR8 *Lang\r
+ )\r
+;\r
+\r
+/**\r
+ Get next language from language code list (with separator ';').\r
+\r
+ If LangCode is NULL, then ASSERT.\r
+ If Lang is NULL, then ASSERT.\r
+\r
+ @param LangCode On input: point to first language in the list. On\r
+ output: point to next language in the list, or\r
+ NULL if no more language in the list.\r
+ @param Lang The first language in the list.\r
+\r
+**/\r
+VOID\r
+EFIAPI\r
+HiiLibGetNextLanguage (\r
+ IN OUT CHAR8 **LangCode,\r
+ OUT CHAR8 *Lang\r
+ )\r
+;\r
+\r
+/**\r
+ This function returns the list of supported languages, in the format specified\r
+ in UEFI specification Appendix M.\r
+\r
+ If HiiHandle is not a valid Handle in the default HII database, then ASSERT.\r
\r
+ @param HiiHandle The HII package list handle.\r
+\r
+ @retval !NULL The supported languages.\r
+ @retval NULL If Supported Languages can not be retrived.\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+HiiLibGetSupportedLanguages (\r
+ IN EFI_HII_HANDLE HiiHandle\r
+ )\r
+;\r
+\r
+/**\r
+ This function returns the list of supported 2nd languages, in the format specified\r
+ in UEFI specification Appendix M.\r
+\r
+ If HiiHandle is not a valid Handle in the default HII database, then ASSERT.\r
+ If not enough resource to complete the operation, then ASSERT.\r
+\r
+ @param HiiHandle The HII package list handle.\r
+ @param FirstLanguage Pointer to language name buffer.\r
+ \r
+ @return The supported languages.\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+HiiLibGetSupportedSecondaryLanguages (\r
+ IN EFI_HII_HANDLE HiiHandle,\r
+ IN CONST CHAR8 *FirstLanguage\r
+ )\r
+;\r
+\r
+\r
+/**\r
+ This function returns the number of supported languages on HiiHandle.\r
+\r
+ If HiiHandle is not a valid Handle in the default HII database, then ASSERT.\r
+ If not enough resource to complete the operation, then ASSERT.\r
+\r
+ @param HiiHandle The HII package list handle.\r
+\r
+ @return The number of supported languages.\r
+\r
+**/\r
+UINT16\r
+EFIAPI\r
+HiiLibGetSupportedLanguageNumber (\r
+ IN EFI_HII_HANDLE HiiHandle\r
+ )\r
+;\r
+\r
+/**\r
+ Exports the contents of one or all package lists in the HII database into a buffer.\r
+\r
+ If Handle is not NULL and not a valid EFI_HII_HANDLE registered in the database, \r
+ then ASSERT.\r
+ If PackageListHeader is NULL, then ASSERT.\r
+ If PackageListSize is NULL, then ASSERT.\r
+\r
+ @param Handle The HII Handle.\r
+ @param PackageListHeader A pointer to a buffer that will contain the results of \r
+ the export function.\r
+ @param PackageListSize On output, the length of the buffer that is required for the exported data.\r
+\r
+ @retval EFI_SUCCESS Package exported.\r
+\r
+ @retval EFI_OUT_OF_RESOURCES Not enought memory to complete the operations.\r
+\r
+**/\r
+EFI_STATUS \r
+EFIAPI\r
+HiiLibExportPackageLists (\r
+ IN EFI_HII_HANDLE Handle,\r
+ OUT EFI_HII_PACKAGE_LIST_HEADER **PackageListHeader,\r
+ OUT UINTN *PackageListSize\r
+ )\r
+;\r
+\r
+EFI_STATUS\r
+EFIAPI\r
+HiiLibListPackageLists (\r
+ IN UINT8 PackageType,\r
+ IN CONST EFI_GUID *PackageGuid,\r
+ IN OUT UINTN *HandleBufferLength,\r
+ OUT EFI_HII_HANDLE **Handle\r
+ )\r
+;\r
+\r
+/**\r
+ Convert language code from RFC3066 to ISO639-2.\r
+\r
+ LanguageRfc3066 contain a single RFC 3066 code such as\r
+ "en-US" or "fr-FR".\r
+\r
+ The LanguageRfc3066 must be a buffer large enough\r
+ for ISO_639_2_ENTRY_SIZE characters.\r
+\r
+ If LanguageRfc3066 is NULL, then ASSERT.\r
+ If LanguageIso639 is NULL, then ASSERT.\r
+\r
+ @param LanguageRfc3066 RFC3066 language code.\r
+ @param LanguageIso639 ISO639-2 language code.\r
+\r
+ @retval EFI_SUCCESS Language code converted.\r
+ @retval EFI_NOT_FOUND Language code not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ConvertRfc3066LanguageToIso639Language (\r
+ IN CHAR8 *LanguageRfc3066,\r
+ OUT CHAR8 *LanguageIso639\r
+ )\r
+;\r
+\r
+/**\r
+ Convert language code from ISO639-2 to RFC3066.\r
+\r
+ LanguageIso639 contain a single ISO639-2 code such as\r
+ "eng" or "fra".\r
+\r
+ The LanguageRfc3066 must be a buffer large enough\r
+ for RFC_3066_ENTRY_SIZE characters.\r
+\r
+ If LanguageIso639 is NULL, then ASSERT.\r
+ If LanguageRfc3066 is NULL, then ASSERT.\r
+\r
+ @param LanguageIso639 ISO639-2 language code.\r
+ @param LanguageRfc3066 RFC3066 language code.\r
+\r
+ @retval EFI_SUCCESS Language code converted.\r
+ @retval EFI_NOT_FOUND Language code not found.\r
+\r
+**/\r
+EFI_STATUS\r
+EFIAPI\r
+ConvertIso639LanguageToRfc3066Language (\r
+ IN CONST CHAR8 *LanguageIso639,\r
+ OUT CHAR8 *LanguageRfc3066\r
+ )\r
+;\r
+\r
+/**\r
+ Convert language code list from RFC3066 to ISO639-2, e.g. "en-US;fr-FR" will\r
+ be converted to "engfra".\r
+\r
+ If SupportedLanguages is NULL, then ASSERT.\r
+\r
+ @param SupportedLanguages The RFC3066 language list.\r
+\r
+ @return The ISO639-2 language list.\r
+\r
+**/\r
+CHAR8 *\r
+EFIAPI\r
+Rfc3066ToIso639 (\r
+ CHAR8 *SupportedLanguages\r
+ )\r
+;\r
\r
#endif\r