OpenCore  1.0.4
OpenCore Bootloader
Loading...
Searching...
No Matches
String.c File Reference
#include "HiiDatabase.h"

Go to the source code of this file.

Functions

BOOLEAN ReferFontInfoLocally (IN HII_DATABASE_PRIVATE_DATA *Private, IN HII_STRING_PACKAGE_INSTANCE *StringPackage, IN UINT8 FontId, IN BOOLEAN DuplicateEnable, IN HII_GLOBAL_FONT_INFO *GlobalFontInfo, OUT HII_FONT_INFO **LocalFontInfo)
 
EFI_STATUS ConvertToUnicodeText (OUT EFI_STRING StringDest, IN CHAR8 *StringSrc, IN OUT UINTN *BufferSize)
 
EFI_STATUS GetUnicodeStringTextOrSize (OUT EFI_STRING StringDest, OPTIONAL IN UINT8 *StringSrc, IN OUT UINTN *BufferSize)
 
EFI_STATUS GetStringFontInfo (IN HII_STRING_PACKAGE_INSTANCE *StringPackage, IN UINT8 FontId, OUT EFI_FONT_INFO **StringFontInfo)
 
EFI_STATUS FindStringBlock (IN HII_DATABASE_PRIVATE_DATA *Private, IN HII_STRING_PACKAGE_INSTANCE *StringPackage, IN EFI_STRING_ID StringId, OUT UINT8 *BlockType, OPTIONAL OUT UINT8 **StringBlockAddr, OPTIONAL OUT UINTN *StringTextOffset, OPTIONAL OUT EFI_STRING_ID *LastStringId, OPTIONAL OUT EFI_STRING_ID *StartStringId OPTIONAL)
 
EFI_STATUS GetStringWorker (IN HII_DATABASE_PRIVATE_DATA *Private, IN HII_STRING_PACKAGE_INSTANCE *StringPackage, IN EFI_STRING_ID StringId, OUT EFI_STRING String, IN OUT UINTN *StringSize, OPTIONAL OUT EFI_FONT_INFO **StringFontInfo OPTIONAL)
 
EFI_STATUS InsertLackStringBlock (IN OUT HII_STRING_PACKAGE_INSTANCE *StringPackage, IN EFI_STRING_ID StartStringId, IN EFI_STRING_ID StringId, IN OUT UINT8 *BlockType, IN OUT UINT8 **StringBlockAddr, IN BOOLEAN FontBlock)
 
EFI_STATUS SetStringWorker (IN HII_DATABASE_PRIVATE_DATA *Private, IN OUT HII_STRING_PACKAGE_INSTANCE *StringPackage, IN EFI_STRING_ID StringId, IN EFI_STRING String, IN EFI_FONT_INFO *StringFontInfo OPTIONAL)
 
EFI_STATUS EFIAPI HiiNewString (IN CONST EFI_HII_STRING_PROTOCOL *This, IN EFI_HII_HANDLE PackageList, OUT EFI_STRING_ID *StringId, IN CONST CHAR8 *Language, IN CONST CHAR16 *LanguageName, OPTIONAL IN CONST EFI_STRING String, IN CONST EFI_FONT_INFO *StringFontInfo OPTIONAL)
 
EFI_STATUS EFIAPI InternalHiiGetString (IN CONST EFI_HII_STRING_PROTOCOL *This, IN CONST CHAR8 *Language, IN EFI_HII_HANDLE PackageList, IN EFI_STRING_ID StringId, OUT EFI_STRING String, IN OUT UINTN *StringSize, OUT EFI_FONT_INFO **StringFontInfo OPTIONAL)
 
EFI_STATUS EFIAPI InternalHiiSetString (IN CONST EFI_HII_STRING_PROTOCOL *This, IN EFI_HII_HANDLE PackageList, IN EFI_STRING_ID StringId, IN CONST CHAR8 *Language, IN CONST EFI_STRING String, IN CONST EFI_FONT_INFO *StringFontInfo OPTIONAL)
 
EFI_STATUS EFIAPI HiiGetLanguages (IN CONST EFI_HII_STRING_PROTOCOL *This, IN EFI_HII_HANDLE PackageList, IN OUT CHAR8 *Languages, IN OUT UINTN *LanguagesSize)
 
EFI_STATUS EFIAPI HiiGetSecondaryLanguages (IN CONST EFI_HII_STRING_PROTOCOL *This, IN EFI_HII_HANDLE PackageList, IN CONST CHAR8 *PrimaryLanguage, IN OUT CHAR8 *SecondaryLanguages, IN OUT UINTN *SecondaryLanguagesSize)
 
VOID EFIAPI AsciiHiiToLower (IN CHAR8 *ConfigString)
 
BOOLEAN HiiCompareLanguage (IN CHAR8 *Language1, IN CHAR8 *Language2)
 

Variables

CHAR16 mLanguageWindow [16]
 

Detailed Description

Implementation for EFI_HII_STRING_PROTOCOL.

Copyright (c) 2007 - 2020, Intel Corporation. All rights reserved.
(C) Copyright 2016 Hewlett Packard Enterprise Development LP
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file String.c.

Function Documentation

◆ AsciiHiiToLower()

VOID EFIAPI AsciiHiiToLower ( IN CHAR8 * ConfigString)

Converts the ascii character of the string from uppercase to lowercase. This is a internal function.

Parameters
ConfigStringString to be converted

Definition at line 2044 of file String.c.

◆ ConvertToUnicodeText()

EFI_STATUS ConvertToUnicodeText ( OUT EFI_STRING StringDest,
IN CHAR8 * StringSrc,
IN OUT UINTN * BufferSize )

Convert Ascii string text to unicode string test.

This is a internal function.

Parameters
StringDestBuffer to store the string text. If it is NULL, only the size will be returned.
StringSrcPoints to current null-terminated string.
BufferSizeLength of the buffer.
Return values
EFI_SUCCESSThe string text was outputted successfully.
EFI_BUFFER_TOO_SMALLBuffer is insufficient to store the found string text. BufferSize is updated to the required buffer size.

Definition at line 109 of file String.c.

◆ FindStringBlock()

EFI_STATUS FindStringBlock ( IN HII_DATABASE_PRIVATE_DATA * Private,
IN HII_STRING_PACKAGE_INSTANCE * StringPackage,
IN EFI_STRING_ID StringId,
OUT UINT8 * BlockType,
OPTIONAL OUT UINT8 ** StringBlockAddr,
OPTIONAL OUT UINTN * StringTextOffset,
OPTIONAL OUT EFI_STRING_ID * LastStringId,
OPTIONAL OUT EFI_STRING_ID *StartStringId OPTIONAL )

Parse all string blocks to find a String block specified by StringId. If StringId = (EFI_STRING_ID) (-1), find out all EFI_HII_SIBT_FONT blocks within this string package and backup its information. If LastStringId is specified, the string id of last string block will also be output. If StringId = 0, output the string id of last string block (EFI_HII_SIBT_STRING).

Parameters
PrivateHii database private structure.
StringPackageHii string package instance.
StringIdThe string's id, which is unique within PackageList.
BlockTypeOutput the block type of found string block.
StringBlockAddrOutput the block address of found string block.
StringTextOffsetOffset, relative to the found block address, of the string text information.
LastStringIdOutput the last string id when StringId = 0 or StringId = -1.
StartStringIdThe first id in the skip block which StringId in the block.
Return values
EFI_SUCCESSThe string text and font is retrieved successfully.
EFI_NOT_FOUNDThe specified text or font info can not be found out.
EFI_OUT_OF_RESOURCESThe system is out of resources to accomplish the task.

Definition at line 255 of file String.c.

◆ GetStringFontInfo()

EFI_STATUS GetStringFontInfo ( IN HII_STRING_PACKAGE_INSTANCE * StringPackage,
IN UINT8 FontId,
OUT EFI_FONT_INFO ** StringFontInfo )

Copy string font info to a buffer.

This is a internal function.

Parameters
StringPackageHii string package instance.
FontIdFont identifier which is unique in a string package.
StringFontInfoBuffer to record the output font info. It's caller's responsibility to free this buffer.
Return values
EFI_SUCCESSThe string font is outputted successfully.
EFI_NOT_FOUNDThe specified font id does not exist.

Definition at line 199 of file String.c.

◆ GetStringWorker()

EFI_STATUS GetStringWorker ( IN HII_DATABASE_PRIVATE_DATA * Private,
IN HII_STRING_PACKAGE_INSTANCE * StringPackage,
IN EFI_STRING_ID StringId,
OUT EFI_STRING String,
IN OUT UINTN * StringSize,
OPTIONAL OUT EFI_FONT_INFO **StringFontInfo OPTIONAL )

Parse all string blocks to get a string specified by StringId.

This is a internal function.

Parameters
PrivateHii database private structure.
StringPackageHii string package instance.
StringIdThe string's id, which is unique within PackageList.
StringPoints to retrieved null-terminated string.
StringSizeOn entry, points to the size of the buffer pointed to by String, in bytes. On return, points to the length of the string, in bytes.
StringFontInfoIf not NULL, allocate a buffer to record the output font info. It's caller's responsibility to free this buffer.
Return values
EFI_SUCCESSThe string text and font is retrieved successfully.
EFI_NOT_FOUNDThe specified text or font info can not be found out.
EFI_BUFFER_TOO_SMALLThe buffer specified by StringSize is too small to hold the string.

Definition at line 618 of file String.c.

◆ GetUnicodeStringTextOrSize()

EFI_STATUS GetUnicodeStringTextOrSize ( OUT EFI_STRING StringDest,
OPTIONAL IN UINT8 * StringSrc,
IN OUT UINTN * BufferSize )

Calculate the size of StringSrc and output it. If StringDest is not NULL, copy string text from src to dest.

This is a internal function.

Parameters
StringDestBuffer to store the string text. If it is NULL, only the size will be returned.
StringSrcPoints to current null-terminated string.
BufferSizeLength of the buffer.
Return values
EFI_SUCCESSThe string text was outputted successfully.
EFI_BUFFER_TOO_SMALLBuffer is insufficient to store the found string text. BufferSize is updated to the required buffer size.

Definition at line 152 of file String.c.

◆ HiiCompareLanguage()

BOOLEAN HiiCompareLanguage ( IN CHAR8 * Language1,
IN CHAR8 * Language2 )

Compare whether two names of languages are identical.

Parameters
Language1Name of language 1 from StringPackage
Language2Name of language 2 to be compared with language 1.
Return values
TRUEsame
FALSEnot same

Definition at line 2071 of file String.c.

◆ HiiGetLanguages()

EFI_STATUS EFIAPI HiiGetLanguages ( IN CONST EFI_HII_STRING_PROTOCOL * This,
IN EFI_HII_HANDLE PackageList,
IN OUT CHAR8 * Languages,
IN OUT UINTN * LanguagesSize )

This function returns the list of supported languages, in the format specified in Appendix M of UEFI 2.1 spec.

Parameters
ThisA pointer to the EFI_HII_STRING_PROTOCOL instance.
PackageListThe package list to examine.
LanguagesPoints to the buffer to hold the returned null-terminated ASCII string.
LanguagesSizeOn entry, points to the size of the buffer pointed to by Languages, in bytes. On return, points to the length of Languages, in bytes.
Return values
EFI_SUCCESSThe languages were returned successfully.
EFI_INVALID_PARAMETERThe LanguagesSize was NULL.
EFI_INVALID_PARAMETERThe value referenced by LanguagesSize is not zero and Languages is NULL.
EFI_BUFFER_TOO_SMALLThe LanguagesSize is too small to hold the list of supported languages. LanguageSize is updated to contain the required size.
EFI_NOT_FOUNDCould not find string package in specified packagelist.

Definition at line 1847 of file String.c.

◆ HiiGetSecondaryLanguages()

EFI_STATUS EFIAPI HiiGetSecondaryLanguages ( IN CONST EFI_HII_STRING_PROTOCOL * This,
IN EFI_HII_HANDLE PackageList,
IN CONST CHAR8 * PrimaryLanguage,
IN OUT CHAR8 * SecondaryLanguages,
IN OUT UINTN * SecondaryLanguagesSize )

Each string package has associated with it a single primary language and zero or more secondary languages. This routine returns the secondary languages associated with a package list.

Parameters
ThisA pointer to the EFI_HII_STRING_PROTOCOL instance.
PackageListThe package list to examine.
PrimaryLanguagePoints to the null-terminated ASCII string that specifies the primary language. Languages are specified in the format specified in Appendix M of the UEFI 2.0 specification.
SecondaryLanguagesPoints to the buffer to hold the returned null-terminated ASCII string that describes the list of secondary languages for the specified PrimaryLanguage. If there are no secondary languages, the function returns successfully, but this is set to NULL.
SecondaryLanguagesSizeOn entry, points to the size of the buffer pointed to by SecondaryLanguages, in bytes. On return, points to the length of SecondaryLanguages in bytes.
Return values
EFI_SUCCESSSecondary languages were correctly returned.
EFI_INVALID_PARAMETERPrimaryLanguage or SecondaryLanguagesSize was NULL.
EFI_INVALID_PARAMETERThe value referenced by SecondaryLanguagesSize is not zero and SecondaryLanguages is NULL.
EFI_BUFFER_TOO_SMALLThe buffer specified by SecondaryLanguagesSize is too small to hold the returned information. SecondaryLanguageSize is updated to hold the size of the buffer required.
EFI_INVALID_LANGUAGEThe language specified by PrimaryLanguage is not present in the specified package list.
EFI_NOT_FOUNDThe specified PackageList is not in the Database.

Definition at line 1954 of file String.c.

◆ HiiNewString()

EFI_STATUS EFIAPI HiiNewString ( IN CONST EFI_HII_STRING_PROTOCOL * This,
IN EFI_HII_HANDLE PackageList,
OUT EFI_STRING_ID * StringId,
IN CONST CHAR8 * Language,
IN CONST CHAR16 * LanguageName,
OPTIONAL IN CONST EFI_STRING String,
IN CONST EFI_FONT_INFO *StringFontInfo OPTIONAL )

This function adds the string String to the group of strings owned by PackageList, with the specified font information StringFontInfo and returns a new string id. The new string identifier is guaranteed to be unique within the package list. That new string identifier is reserved for all languages in the package list.

Parameters
ThisA pointer to the EFI_HII_STRING_PROTOCOL instance.
PackageListHandle of the package list where this string will be added.
StringIdOn return, contains the new strings id, which is unique within PackageList.
LanguagePoints to the language for the new string.
LanguageNamePoints to the printable language name to associate with the passed in Language field.If LanguageName is not NULL and the string package header's LanguageName associated with a given Language is not zero, the LanguageName being passed in will be ignored.
StringPoints to the new null-terminated string.
StringFontInfoPoints to the new string's font information or NULL if the string should have the default system font, size and style.
Return values
EFI_SUCCESSThe new string was added successfully.
EFI_NOT_FOUNDThe specified PackageList could not be found in database.
EFI_OUT_OF_RESOURCESCould not add the string due to lack of resources.
EFI_INVALID_PARAMETERString is NULL or StringId is NULL or Language is NULL.
EFI_INVALID_PARAMETERThe specified StringFontInfo does not exist in current database.

Definition at line 1156 of file String.c.

◆ InsertLackStringBlock()

EFI_STATUS InsertLackStringBlock ( IN OUT HII_STRING_PACKAGE_INSTANCE * StringPackage,
IN EFI_STRING_ID StartStringId,
IN EFI_STRING_ID StringId,
IN OUT UINT8 * BlockType,
IN OUT UINT8 ** StringBlockAddr,
IN BOOLEAN FontBlock )

If GetStringBlock find the StringId's string is not saved in the exist string block, this function will create the UCS2 string block to save the string; also split the skip block into two or one skip block.

This is a internal function.

Parameters
StringPackageHii string package instance.
StartStringIdThe first id in the skip block which StringId in the block.
StringIdThe string's id, which is unique within PackageList.
BlockTypeOutput the block type of found string block.
StringBlockAddrOutput the block address of found string block.
FontBlockwhether this string block has font info.
Return values
EFI_SUCCESSThe string font is outputted successfully.
EFI_OUT_OF_RESOURCESNO resource for the memory to save the new string block.

Definition at line 731 of file String.c.

◆ InternalHiiGetString()

EFI_STATUS EFIAPI InternalHiiGetString ( IN CONST EFI_HII_STRING_PROTOCOL * This,
IN CONST CHAR8 * Language,
IN EFI_HII_HANDLE PackageList,
IN EFI_STRING_ID StringId,
OUT EFI_STRING String,
IN OUT UINTN * StringSize,
OUT EFI_FONT_INFO **StringFontInfo OPTIONAL )

This function retrieves the string specified by StringId which is associated with the specified PackageList in the language Language and copies it into the buffer specified by String.

Parameters
ThisA pointer to the EFI_HII_STRING_PROTOCOL instance.
LanguagePoints to the language for the retrieved string.
PackageListThe package list in the HII database to search for the specified string.
StringIdThe string's id, which is unique within PackageList.
StringPoints to the new null-terminated string.
StringSizeOn entry, points to the size of the buffer pointed to by String, in bytes. On return, points to the length of the string, in bytes.
StringFontInfoIf not NULL, points to the string's font information. It's caller's responsibility to free this buffer.
Return values
EFI_SUCCESSThe string was returned successfully.
EFI_NOT_FOUNDThe string specified by StringId is not available.
EFI_NOT_FOUNDThe string specified by StringId is available but not in the specified language. The specified PackageList is not in the database.
EFI_INVALID_LANGUAGE- The string specified by StringId is available but
EFI_BUFFER_TOO_SMALLThe buffer specified by StringSize is too small to hold the string.
EFI_INVALID_PARAMETERThe Language or StringSize was NULL.
EFI_INVALID_PARAMETERThe value referenced by StringSize was not zero and String was NULL.
EFI_OUT_OF_RESOURCESThere were insufficient resources to complete the request.

Definition at line 1644 of file String.c.

◆ InternalHiiSetString()

EFI_STATUS EFIAPI InternalHiiSetString ( IN CONST EFI_HII_STRING_PROTOCOL * This,
IN EFI_HII_HANDLE PackageList,
IN EFI_STRING_ID StringId,
IN CONST CHAR8 * Language,
IN CONST EFI_STRING String,
IN CONST EFI_FONT_INFO *StringFontInfo OPTIONAL )

This function updates the string specified by StringId in the specified PackageList to the text specified by String and, optionally, the font information specified by StringFontInfo.

Parameters
ThisA pointer to the EFI_HII_STRING_PROTOCOL instance.
PackageListThe package list containing the strings.
StringIdThe string's id, which is unique within PackageList.
LanguagePoints to the language for the updated string.
StringPoints to the new null-terminated string.
StringFontInfoPoints to the string's font information or NULL if the string font information is not changed.
Return values
EFI_SUCCESSThe string was updated successfully.
EFI_NOT_FOUNDThe string specified by StringId is not in the database.
EFI_INVALID_PARAMETERThe String or Language was NULL.
EFI_INVALID_PARAMETERThe specified StringFontInfo does not exist in current database.
EFI_OUT_OF_RESOURCESThe system is out of resources to accomplish the task.

Definition at line 1746 of file String.c.

◆ ReferFontInfoLocally()

BOOLEAN ReferFontInfoLocally ( IN HII_DATABASE_PRIVATE_DATA * Private,
IN HII_STRING_PACKAGE_INSTANCE * StringPackage,
IN UINT8 FontId,
IN BOOLEAN DuplicateEnable,
IN HII_GLOBAL_FONT_INFO * GlobalFontInfo,
OUT HII_FONT_INFO ** LocalFontInfo )

This function checks whether a global font info is referred by local font info list or not. (i.e. HII_FONT_INFO is generated.) If not, create a HII_FONT_INFO to refer it locally.

This is a internal function.

Parameters
PrivateHii database private structure.
StringPackageHII string package instance.
FontIdFont identifer, which must be unique within the string package.
DuplicateEnableIf true, duplicate HII_FONT_INFO which refers to the same EFI_FONT_INFO is permitted. Otherwise it is not allowed.
GlobalFontInfoInput a global font info which specify a EFI_FONT_INFO.
LocalFontInfoOutput a local font info which refers to a EFI_FONT_INFO.
Return values
TRUEAlready referred before calling this function.
FALSENot referred before calling this function.

Definition at line 44 of file String.c.

◆ SetStringWorker()

EFI_STATUS SetStringWorker ( IN HII_DATABASE_PRIVATE_DATA * Private,
IN OUT HII_STRING_PACKAGE_INSTANCE * StringPackage,
IN EFI_STRING_ID StringId,
IN EFI_STRING String,
IN EFI_FONT_INFO *StringFontInfo OPTIONAL )

Parse all string blocks to set a String specified by StringId.

This is a internal function.

Parameters
PrivateHII database driver private structure.
StringPackageHII string package instance.
StringIdThe string's id, which is unique within PackageList.
StringPoints to the new null-terminated string.
StringFontInfoPoints to the input font info.
Return values
EFI_SUCCESSThe string was updated successfully.
EFI_NOT_FOUNDThe string specified by StringId is not in the database.
EFI_INVALID_PARAMETERThe String or Language was NULL.
EFI_INVALID_PARAMETERThe specified StringFontInfo does not exist in current database.
EFI_OUT_OF_RESOURCESThe system is out of resources to accomplish the task.

Definition at line 886 of file String.c.

Variable Documentation

◆ mLanguageWindow

CHAR16 mLanguageWindow[16]
Initial value:
= {
0x0000, 0x0080, 0x0100, 0x0300,
0x2000, 0x2080, 0x2100, 0x3000,
0x0080, 0x00C0, 0x0400, 0x0600,
0x0900, 0x3040, 0x30A0, 0xFF00
}

Definition at line 13 of file String.c.