TianoCore EDK2 master
Loading...
Searching...
No Matches
UefiLib.c File Reference
#include "UefiLibInternal.h"

Go to the source code of this file.

Functions

EFI_STATUS EFIAPI UefiLibConstructor (IN EFI_HANDLE ImageHandle, IN EFI_SYSTEM_TABLE *SystemTable)
 
BOOLEAN CompareIso639LanguageCode (IN CONST CHAR8 *Language1, IN CONST CHAR8 *Language2)
 
EFI_STATUS EFIAPI EfiGetSystemConfigurationTable (IN EFI_GUID *TableGuid, OUT VOID **Table)
 
EFI_EVENT EFIAPI EfiCreateProtocolNotifyEvent (IN EFI_GUID *ProtocolGuid, IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction, IN VOID *NotifyContext OPTIONAL, OUT VOID **Registration)
 
EFI_STATUS EFIAPI EfiNamedEventListen (IN CONST EFI_GUID *Name, IN EFI_TPL NotifyTpl, IN EFI_EVENT_NOTIFY NotifyFunction, IN CONST VOID *NotifyContext OPTIONAL, OUT VOID *Registration OPTIONAL)
 
EFI_STATUS EFIAPI EfiNamedEventSignal (IN CONST EFI_GUID *Name)
 
EFI_STATUS EFIAPI EfiEventGroupSignal (IN CONST EFI_GUID *EventGroup)
 
VOID EFIAPI EfiEventEmptyFunction (IN EFI_EVENT Event, IN VOID *Context)
 
EFI_TPL EFIAPI EfiGetCurrentTpl (VOID)
 
EFI_LOCK *EFIAPI EfiInitializeLock (IN OUT EFI_LOCK *Lock, IN EFI_TPL Priority)
 
VOID EFIAPI EfiAcquireLock (IN EFI_LOCK *Lock)
 
EFI_STATUS EFIAPI EfiAcquireLockOrFail (IN EFI_LOCK *Lock)
 
VOID EFIAPI EfiReleaseLock (IN EFI_LOCK *Lock)
 
EFI_STATUS EFIAPI EfiTestManagedDevice (IN CONST EFI_HANDLE ControllerHandle, IN CONST EFI_HANDLE DriverBindingHandle, IN CONST EFI_GUID *ProtocolGuid)
 
EFI_STATUS EFIAPI EfiTestChildHandle (IN CONST EFI_HANDLE ControllerHandle, IN CONST EFI_HANDLE ChildHandle, IN CONST EFI_GUID *ProtocolGuid)
 
EFI_STATUS EFIAPI IsLanguageSupported (IN CONST CHAR8 *SupportedLanguages, IN CONST CHAR8 *TargetLanguage)
 
EFI_STATUS EFIAPI LookupUnicodeString (IN CONST CHAR8 *Language, IN CONST CHAR8 *SupportedLanguages, IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable, OUT CHAR16 **UnicodeString)
 
EFI_STATUS EFIAPI LookupUnicodeString2 (IN CONST CHAR8 *Language, IN CONST CHAR8 *SupportedLanguages, IN CONST EFI_UNICODE_STRING_TABLE *UnicodeStringTable, OUT CHAR16 **UnicodeString, IN BOOLEAN Iso639Language)
 
EFI_STATUS EFIAPI AddUnicodeString (IN CONST CHAR8 *Language, IN CONST CHAR8 *SupportedLanguages, IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable, IN CONST CHAR16 *UnicodeString)
 
EFI_STATUS EFIAPI AddUnicodeString2 (IN CONST CHAR8 *Language, IN CONST CHAR8 *SupportedLanguages, IN OUT EFI_UNICODE_STRING_TABLE **UnicodeStringTable, IN CONST CHAR16 *UnicodeString, IN BOOLEAN Iso639Language)
 
EFI_STATUS EFIAPI FreeUnicodeStringTable (IN EFI_UNICODE_STRING_TABLE *UnicodeStringTable)
 
EFI_STATUS EFIAPI GetVariable2 (IN CONST CHAR16 *Name, IN CONST EFI_GUID *Guid, OUT VOID **Value, OUT UINTN *Size OPTIONAL)
 
EFI_STATUS EFIAPI GetVariable3 (IN CONST CHAR16 *Name, IN CONST EFI_GUID *Guid, OUT VOID **Value, OUT UINTN *Size OPTIONAL, OUT UINT32 *Attr OPTIONAL)
 
EFI_STATUS EFIAPI GetEfiGlobalVariable2 (IN CONST CHAR16 *Name, OUT VOID **Value, OUT UINTN *Size OPTIONAL)
 
CHAR8 *EFIAPI GetBestLanguage (IN CONST CHAR8 *SupportedLanguages, IN UINTN Iso639Language,...)
 
EFI_STATUS EFIAPI EfiLocateProtocolBuffer (IN EFI_GUID *Protocol, OUT UINTN *NoProtocols, OUT VOID ***Buffer)
 
EFI_STATUS EFIAPI EfiOpenFileByDevicePath (IN OUT EFI_DEVICE_PATH_PROTOCOL **FilePath, OUT EFI_FILE_PROTOCOL **File, IN UINT64 OpenMode, IN UINT64 Attributes)
 

Detailed Description

The UEFI Library provides functions and macros that simplify the development of UEFI Drivers and UEFI Applications. These functions and macros help manage EFI events, build simple locks utilizing EFI Task Priority Levels (TPLs), install EFI Driver Model related protocols, manage Unicode string tables for UEFI Drivers, and print messages on the console output and standard error devices.

Copyright (c) 2006 - 2018, Intel Corporation. All rights reserved.
SPDX-License-Identifier: BSD-2-Clause-Patent

Definition in file UefiLib.c.

Function Documentation

◆ AddUnicodeString()

EFI_STATUS EFIAPI AddUnicodeString ( IN CONST CHAR8 *  Language,
IN CONST CHAR8 *  SupportedLanguages,
IN OUT EFI_UNICODE_STRING_TABLE **  UnicodeStringTable,
IN CONST CHAR16 *  UnicodeString 
)

This function adds a Unicode string to UnicodeStringTable.

If Language is a member of SupportedLanguages then UnicodeString is added to UnicodeStringTable. New buffers are allocated for both Language and UnicodeString. The contents of Language and UnicodeString are copied into these new buffers. These buffers are automatically freed when FreeUnicodeStringTable() is called.

Parameters
LanguageA pointer to the ISO 639-2 language code for the Unicode string to add.
SupportedLanguagesA pointer to the set of ISO 639-2 language codes that the Unicode string table supports. Language must be a member of this set.
UnicodeStringTableA pointer to the table of Unicode strings.
UnicodeStringA pointer to the Unicode string to add.
Return values
EFI_SUCCESSThe Unicode string that matches the language specified by Language was found in the table of Unicode strings UnicodeStringTable, and it was returned in UnicodeString.
EFI_INVALID_PARAMETERLanguage is NULL.
EFI_INVALID_PARAMETERUnicodeString is NULL.
EFI_INVALID_PARAMETERUnicodeString is an empty string.
EFI_UNSUPPORTEDSupportedLanguages is NULL.
EFI_ALREADY_STARTEDA Unicode string with language Language is already present in UnicodeStringTable.
EFI_OUT_OF_RESOURCESThere is not enough memory to add another Unicode string to UnicodeStringTable.
EFI_UNSUPPORTEDThe language specified by Language is not a member of SupportedLanguages.

Definition at line 912 of file UefiLib.c.

◆ AddUnicodeString2()

EFI_STATUS EFIAPI AddUnicodeString2 ( IN CONST CHAR8 *  Language,
IN CONST CHAR8 *  SupportedLanguages,
IN OUT EFI_UNICODE_STRING_TABLE **  UnicodeStringTable,
IN CONST CHAR16 *  UnicodeString,
IN BOOLEAN  Iso639Language 
)

This function adds the Null-terminated Unicode string specified by UnicodeString to UnicodeStringTable.

If Language is a member of SupportedLanguages then UnicodeString is added to UnicodeStringTable. New buffers are allocated for both Language and UnicodeString. The contents of Language and UnicodeString are copied into these new buffers. These buffers are automatically freed when EfiLibFreeUnicodeStringTable() is called.

Parameters
LanguageA pointer to an ASCII string containing the ISO 639-2 or the RFC 4646 language code for the Unicode string to add. If Iso639Language is TRUE, then this ASCII string is not assumed to be Null-terminated, and only the first three chacters are used. If Iso639Language is FALSE, then this ASCII string must be Null-terminated.
SupportedLanguagesA pointer to a Null-terminated ASCII string that contains a set of ISO 639-2 or RFC 4646 language codes that the Unicode string table supports. Language must be a member of this set. If Iso639Language is TRUE, then this string contains one or more ISO 639-2 language codes with no separator characters. If Iso639Language is FALSE, then is string contains one or more RFC 4646 language codes separated by ';'.
UnicodeStringTableA pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE is defined in "Related Definitions".
UnicodeStringA pointer to the Unicode string to add.
Iso639LanguageSpecifies the supported language code format. If it is TRUE, then Language and SupportedLanguages follow ISO 639-2 language code format. Otherwise, they follow RFC 4646 language code format.
Return values
EFI_SUCCESSThe Unicode string that matches the language specified by Language was found in the table of Unicode strings UnicodeStringTable, and it was returned in UnicodeString.
EFI_INVALID_PARAMETERLanguage is NULL.
EFI_INVALID_PARAMETERUnicodeString is NULL.
EFI_INVALID_PARAMETERUnicodeString is an empty string.
EFI_UNSUPPORTEDSupportedLanguages is NULL.
EFI_ALREADY_STARTEDA Unicode string with language Language is already present in UnicodeStringTable.
EFI_OUT_OF_RESOURCESThere is not enough memory to add another Unicode string UnicodeStringTable.
EFI_UNSUPPORTEDThe language specified by Language is not a member of SupportedLanguages.

Definition at line 1087 of file UefiLib.c.

◆ CompareIso639LanguageCode()

BOOLEAN CompareIso639LanguageCode ( IN CONST CHAR8 *  Language1,
IN CONST CHAR8 *  Language2 
)

Compare whether two names of languages are identical.

Parameters
Language1Name of language 1.
Language2Name of language 2.
Return values
TRUELanguage 1 and language 2 are the same.
FALSELanguage 1 and language 2 are not the same.

Definition at line 48 of file UefiLib.c.

◆ EfiAcquireLock()

VOID EFIAPI EfiAcquireLock ( IN EFI_LOCK Lock)

Acquires ownership of a lock.

This function raises the system's current task priority level to the task priority level of the mutual exclusion lock. Then, it places the lock in the acquired state. If Lock is NULL, then ASSERT(). If Lock is not initialized, then ASSERT(). If Lock is already in the acquired state, then ASSERT().

Parameters
LockA pointer to the lock to acquire.

Definition at line 434 of file UefiLib.c.

◆ EfiAcquireLockOrFail()

EFI_STATUS EFIAPI EfiAcquireLockOrFail ( IN EFI_LOCK Lock)

Acquires ownership of a lock.

This function raises the system's current task priority level to the task priority level of the mutual exclusion lock. Then, it attempts to place the lock in the acquired state. If the lock is already in the acquired state, then EFI_ACCESS_DENIED is returned. Otherwise, EFI_SUCCESS is returned. If Lock is NULL, then ASSERT(). If Lock is not initialized, then ASSERT().

Parameters
LockA pointer to the lock to acquire.
Return values
EFI_SUCCESSThe lock was acquired.
EFI_ACCESS_DENIEDThe lock could not be acquired because it is already owned.

Definition at line 463 of file UefiLib.c.

◆ EfiCreateProtocolNotifyEvent()

EFI_EVENT EFIAPI EfiCreateProtocolNotifyEvent ( IN EFI_GUID ProtocolGuid,
IN EFI_TPL  NotifyTpl,
IN EFI_EVENT_NOTIFY  NotifyFunction,
IN VOID *NotifyContext  OPTIONAL,
OUT VOID **  Registration 
)

Creates and returns a notification event and registers that event with all the protocol instances specified by ProtocolGuid.

This function causes the notification function to be executed for every protocol of type ProtocolGuid instance that exists in the system when this function is invoked. If there are no instances of ProtocolGuid in the handle database at the time this function is invoked, then the notification function is still executed one time. In addition, every time a protocol of type ProtocolGuid instance is installed or reinstalled, the notification function is also executed. This function returns the notification event that was created. If ProtocolGuid is NULL, then ASSERT(). If NotifyTpl is not a legal TPL value, then ASSERT(). If NotifyFunction is NULL, then ASSERT(). If Registration is NULL, then ASSERT().

Parameters
ProtocolGuidSupplies GUID of the protocol upon whose installation the event is fired.
NotifyTplSupplies the task priority level of the event notifications.
NotifyFunctionSupplies the function to notify when the event is signaled.
NotifyContextThe context parameter to pass to NotifyFunction.
RegistrationA pointer to a memory location to receive the registration value. This value is passed to LocateHandle() to obtain new handles that have been added that support the ProtocolGuid-specified protocol.
Returns
The notification event that was created.

Definition at line 134 of file UefiLib.c.

◆ EfiEventEmptyFunction()

VOID EFIAPI EfiEventEmptyFunction ( IN EFI_EVENT  Event,
IN VOID *  Context 
)

An empty function that can be used as NotifyFunction parameter of CreateEvent() or CreateEventEx().

Parameters
EventEvent whose notification function is being invoked.
ContextThe pointer to the notification function's context, which is implementation-dependent.

Definition at line 354 of file UefiLib.c.

◆ EfiEventGroupSignal()

EFI_STATUS EFIAPI EfiEventGroupSignal ( IN CONST EFI_GUID EventGroup)

Signals an event group by placing a new event in the group temporarily and signaling it.

Parameters
[in]EventGroupSupplies the unique identifier of the event group to signal.
Return values
EFI_SUCCESSThe event group was signaled successfully.
EFI_INVALID_PARAMETEREventGroup is NULL.
Returns
Error codes that report problems about event creation or signaling.

Definition at line 314 of file UefiLib.c.

◆ EfiGetCurrentTpl()

EFI_TPL EFIAPI EfiGetCurrentTpl ( VOID  )

Returns the current TPL.

This function returns the current TPL. There is no EFI service to directly retrieve the current TPL. Instead, the RaiseTPL() function is used to raise the TPL to TPL_HIGH_LEVEL. This will return the current TPL. The TPL level can then immediately be restored back to the current TPL level with a call to RestoreTPL().

Returns
The current TPL.

Definition at line 375 of file UefiLib.c.

◆ EfiGetSystemConfigurationTable()

EFI_STATUS EFIAPI EfiGetSystemConfigurationTable ( IN EFI_GUID TableGuid,
OUT VOID **  Table 
)

Retrieves a pointer to the system configuration table from the EFI System Table based on a specified GUID.

This function searches the list of configuration tables stored in the EFI System Table for a table with a GUID that matches TableGuid. If a match is found, then a pointer to the configuration table is returned in Table., and EFI_SUCCESS is returned. If a matching GUID is not found, then EFI_NOT_FOUND is returned. If TableGuid is NULL, then ASSERT(). If Table is NULL, then ASSERT().

Parameters
TableGuidThe pointer to table's GUID type.
TableThe pointer to the table associated with TableGuid in the EFI System Table.
Return values
EFI_SUCCESSA configuration table matching TableGuid was found.
EFI_NOT_FOUNDA configuration table matching TableGuid could not be found.

Definition at line 82 of file UefiLib.c.

◆ EfiInitializeLock()

EFI_LOCK *EFIAPI EfiInitializeLock ( IN OUT EFI_LOCK Lock,
IN EFI_TPL  Priority 
)

Initializes a basic mutual exclusion lock.

This function initializes a basic mutual exclusion lock to the released state and returns the lock. Each lock provides mutual exclusion access at its task priority level. Since there is no preemption or multiprocessor support in EFI, acquiring the lock only consists of raising to the locks TPL. If Lock is NULL, then ASSERT(). If Priority is not a valid TPL value, then ASSERT().

Parameters
LockA pointer to the lock data structure to initialize.
PriorityEFI TPL is associated with the lock.
Returns
The lock.

Definition at line 405 of file UefiLib.c.

◆ EfiLocateProtocolBuffer()

EFI_STATUS EFIAPI EfiLocateProtocolBuffer ( IN EFI_GUID Protocol,
OUT UINTN NoProtocols,
OUT VOID ***  Buffer 
)

Returns an array of protocol instance that matches the given protocol.

Parameters
[in]ProtocolProvides the protocol to search for.
[out]NoProtocolsThe number of protocols returned in Buffer.
[out]BufferA pointer to the buffer to return the requested array of protocol instances that match Protocol. The returned buffer is allocated using EFI_BOOT_SERVICES.AllocatePool(). The caller is responsible for freeing this buffer with EFI_BOOT_SERVICES.FreePool().
Return values
EFI_SUCCESSThe array of protocols was returned in Buffer, and the number of protocols in Buffer was returned in NoProtocols.
EFI_NOT_FOUNDNo protocols found.
EFI_OUT_OF_RESOURCESThere is not enough pool memory to store the matching results.
EFI_INVALID_PARAMETERProtocol is NULL.
EFI_INVALID_PARAMETERNoProtocols is NULL.
EFI_INVALID_PARAMETERBuffer is NULL.

Definition at line 1650 of file UefiLib.c.

◆ EfiNamedEventListen()

EFI_STATUS EFIAPI EfiNamedEventListen ( IN CONST EFI_GUID Name,
IN EFI_TPL  NotifyTpl,
IN EFI_EVENT_NOTIFY  NotifyFunction,
IN CONST VOID *NotifyContext  OPTIONAL,
OUT VOID *Registration  OPTIONAL 
)

Creates a named event that can be signaled with EfiNamedEventSignal().

This function creates an event using NotifyTpl, NoifyFunction, and NotifyContext. This event is signaled with EfiNamedEventSignal(). This provides the ability for one or more listeners on the same event named by the GUID specified by Name. If Name is NULL, then ASSERT(). If NotifyTpl is not a legal TPL value, then ASSERT(). If NotifyFunction is NULL, then ASSERT().

Parameters
NameSupplies the GUID name of the event.
NotifyTplSupplies the task priority level of the event notifications.
NotifyFunctionSupplies the function to notify when the event is signaled.
NotifyContextThe context parameter to pass to NotifyFunction.
RegistrationA pointer to a memory location to receive the registration value.
Return values
EFI_SUCCESSA named event was created.
EFI_OUT_OF_RESOURCESThere are not enough resource to create the named event.

Definition at line 205 of file UefiLib.c.

◆ EfiNamedEventSignal()

EFI_STATUS EFIAPI EfiNamedEventSignal ( IN CONST EFI_GUID Name)

Signals a named event created with EfiNamedEventListen().

This function signals the named event specified by Name. The named event must have been created with EfiNamedEventListen(). If Name is NULL, then ASSERT().

Parameters
NameSupplies the GUID name of the event.
Return values
EFI_SUCCESSA named event was signaled.
EFI_OUT_OF_RESOURCESThere are not enough resource to signal the named event.

Definition at line 272 of file UefiLib.c.

◆ EfiOpenFileByDevicePath()

EFI_STATUS EFIAPI EfiOpenFileByDevicePath ( IN OUT EFI_DEVICE_PATH_PROTOCOL **  FilePath,
OUT EFI_FILE_PROTOCOL **  File,
IN UINT64  OpenMode,
IN UINT64  Attributes 
)

Open or create a file or directory, possibly creating the chain of directories leading up to the directory.

EfiOpenFileByDevicePath() first locates EFI_SIMPLE_FILE_SYSTEM_PROTOCOL on FilePath, and opens the root directory of that filesystem with EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume().

On the remaining device path, the longest initial sequence of FILEPATH_DEVICE_PATH nodes is node-wise traversed with EFI_FILE_PROTOCOL.Open().

(As a consequence, if OpenMode includes EFI_FILE_MODE_CREATE, and Attributes includes EFI_FILE_DIRECTORY, and each FILEPATH_DEVICE_PATH specifies a single pathname component, then EfiOpenFileByDevicePath() ensures that the specified series of subdirectories exist on return.)

The EFI_FILE_PROTOCOL identified by the last FILEPATH_DEVICE_PATH node is output to the caller; intermediate EFI_FILE_PROTOCOL instances are closed. If there are no FILEPATH_DEVICE_PATH nodes past the node that identifies the filesystem, then the EFI_FILE_PROTOCOL of the root directory of the filesystem is output to the caller. If a device path node that is different from FILEPATH_DEVICE_PATH is encountered relative to the filesystem, the traversal is stopped with an error, and a NULL EFI_FILE_PROTOCOL is output.

Parameters
[in,out]FilePathOn input, the device path to the file or directory to open or create. The caller is responsible for ensuring that the device path pointed-to by FilePath is well-formed. On output, FilePath points one past the last node in the original device path that has been successfully processed. FilePath is set on output even if EfiOpenFileByDevicePath() returns an error.
[out]FileOn error, File is set to NULL. On success, File is set to the EFI_FILE_PROTOCOL of the root directory of the filesystem, if there are no FILEPATH_DEVICE_PATH nodes in FilePath; otherwise, File is set to the EFI_FILE_PROTOCOL identified by the last node in FilePath.
[in]OpenModeThe OpenMode parameter to pass to EFI_FILE_PROTOCOL.Open().
[in]AttributesThe Attributes parameter to pass to EFI_FILE_PROTOCOL.Open().
Return values
EFI_SUCCESSThe file or directory has been opened or created.
EFI_INVALID_PARAMETERFilePath is NULL; or File is NULL; or FilePath contains a device path node, past the node that identifies EFI_SIMPLE_FILE_SYSTEM_PROTOCOL, that is not a FILEPATH_DEVICE_PATH node.
EFI_OUT_OF_RESOURCESMemory allocation failed.
Returns
Error codes propagated from the LocateDevicePath() and OpenProtocol() boot services, and from the EFI_SIMPLE_FILE_SYSTEM_PROTOCOL.OpenVolume() and EFI_FILE_PROTOCOL.Open() member functions.

Definition at line 1806 of file UefiLib.c.

◆ EfiReleaseLock()

VOID EFIAPI EfiReleaseLock ( IN EFI_LOCK Lock)

Releases ownership of a lock.

This function transitions a mutual exclusion lock from the acquired state to the released state, and restores the system's task priority level to its previous level. If Lock is NULL, then ASSERT(). If Lock is not initialized, then ASSERT(). If Lock is already in the released state, then ASSERT().

Parameters
LockA pointer to the lock to release.

Definition at line 499 of file UefiLib.c.

◆ EfiTestChildHandle()

EFI_STATUS EFIAPI EfiTestChildHandle ( IN CONST EFI_HANDLE  ControllerHandle,
IN CONST EFI_HANDLE  ChildHandle,
IN CONST EFI_GUID ProtocolGuid 
)

Tests whether a child handle is a child device of the controller.

This function tests whether ChildHandle is one of the children of ControllerHandle. This test is performed by checking to see if the protocol specified by ProtocolGuid is present on ControllerHandle and opened by ChildHandle with an attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER. If ProtocolGuid is NULL, then ASSERT().

Parameters
ControllerHandleA handle for a (parent) controller to test.
ChildHandleA child handle to test.
ProtocolGuidSupplies the protocol that the child controller opens on its parent controller.
Return values
EFI_SUCCESSChildHandle is a child of the ControllerHandle.
EFI_UNSUPPORTEDChildHandle is not a child of the ControllerHandle.

Definition at line 597 of file UefiLib.c.

◆ EfiTestManagedDevice()

EFI_STATUS EFIAPI EfiTestManagedDevice ( IN CONST EFI_HANDLE  ControllerHandle,
IN CONST EFI_HANDLE  DriverBindingHandle,
IN CONST EFI_GUID ProtocolGuid 
)

Tests whether a controller handle is being managed by a specific driver.

This function tests whether the driver specified by DriverBindingHandle is currently managing the controller specified by ControllerHandle. This test is performed by evaluating if the the protocol specified by ProtocolGuid is present on ControllerHandle and is was opened by DriverBindingHandle with an attribute of EFI_OPEN_PROTOCOL_BY_DRIVER. If ProtocolGuid is NULL, then ASSERT().

Parameters
ControllerHandleA handle for a controller to test.
DriverBindingHandleSpecifies the driver binding handle for the driver.
ProtocolGuidSpecifies the protocol that the driver specified by DriverBindingHandle opens in its Start() function.
Return values
EFI_SUCCESSControllerHandle is managed by the driver specified by DriverBindingHandle.
EFI_UNSUPPORTEDControllerHandle is not managed by the driver specified by DriverBindingHandle.

Definition at line 540 of file UefiLib.c.

◆ FreeUnicodeStringTable()

EFI_STATUS EFIAPI FreeUnicodeStringTable ( IN EFI_UNICODE_STRING_TABLE UnicodeStringTable)

This function frees the table of Unicode strings in UnicodeStringTable.

If UnicodeStringTable is NULL, then EFI_SUCCESS is returned. Otherwise, each language code, and each Unicode string in the Unicode string table are freed, and EFI_SUCCESS is returned.

Parameters
UnicodeStringTableA pointer to the table of Unicode strings.
Return values
EFI_SUCCESSThe Unicode string table was freed.

Definition at line 1257 of file UefiLib.c.

◆ GetBestLanguage()

CHAR8 *EFIAPI GetBestLanguage ( IN CONST CHAR8 *  SupportedLanguages,
IN UINTN  Iso639Language,
  ... 
)

Returns a pointer to an allocated buffer that contains the best matching language from a set of supported languages.

This function supports both ISO 639-2 and RFC 4646 language codes, but language code types may not be mixed in a single call to this function. The language code returned is allocated using AllocatePool(). The caller is responsible for freeing the allocated buffer using FreePool(). This function supports a variable argument list that allows the caller to pass in a prioritized list of language codes to test against all the language codes in SupportedLanguages.

If SupportedLanguages is NULL, then ASSERT().

Parameters
[in]SupportedLanguagesA pointer to a Null-terminated ASCII string that contains a set of language codes in the format specified by Iso639Language.
[in]Iso639LanguageIf not zero, then all language codes are assumed to be in ISO 639-2 format. If zero, then all language codes are assumed to be in RFC 4646 language format
[in]...A variable argument list that contains pointers to Null-terminated ASCII strings that contain one or more language codes in the format specified by Iso639Language. The first language code from each of these language code lists is used to determine if it is an exact or close match to any of the language codes in SupportedLanguages. Close matches only apply to RFC 4646 language codes, and the matching algorithm from RFC 4647 is used to determine if a close match is present. If an exact or close match is found, then the matching language code from SupportedLanguages is returned. If no matches are found, then the next variable argument parameter is evaluated. The variable argument list is terminated by a NULL.
Return values
NULLThe best matching language could not be found in SupportedLanguages.
NULLThere are not enough resources available to return the best matching language.
OtherA pointer to a Null-terminated ASCII string that is the best matching language in SupportedLanguages.

Definition at line 1522 of file UefiLib.c.

◆ GetEfiGlobalVariable2()

EFI_STATUS EFIAPI GetEfiGlobalVariable2 ( IN CONST CHAR16 *  Name,
OUT VOID **  Value,
OUT UINTN *Size  OPTIONAL 
)

Returns a pointer to an allocated buffer that contains the contents of a variable retrieved through the UEFI Runtime Service GetVariable(). This function always uses the EFI_GLOBAL_VARIABLE GUID to retrieve variables. The returned buffer is allocated using AllocatePool(). The caller is responsible for freeing this buffer with FreePool().

If Name is NULL, then ASSERT(). If Value is NULL, then ASSERT().

Parameters
[in]NameThe pointer to a Null-terminated Unicode string.
[out]ValueThe buffer point saved the variable info.
[out]SizeThe buffer size of the variable.
Returns
EFI_OUT_OF_RESOURCES Allocate buffer failed.
EFI_SUCCESS Find the specified variable.
Others Errors Return errors from call to gRT->GetVariable.

Definition at line 1470 of file UefiLib.c.

◆ GetVariable2()

EFI_STATUS EFIAPI GetVariable2 ( IN CONST CHAR16 *  Name,
IN CONST EFI_GUID Guid,
OUT VOID **  Value,
OUT UINTN *Size  OPTIONAL 
)

Returns the status whether get the variable success. The function retrieves variable through the UEFI Runtime Service GetVariable(). The returned buffer is allocated using AllocatePool(). The caller is responsible for freeing this buffer with FreePool().

If Name is NULL, then ASSERT(). If Guid is NULL, then ASSERT(). If Value is NULL, then ASSERT().

Parameters
[in]NameThe pointer to a Null-terminated Unicode string.
[in]GuidThe pointer to an EFI_GUID structure
[out]ValueThe buffer point saved the variable info.
[out]SizeThe buffer size of the variable.
Returns
EFI_OUT_OF_RESOURCES Allocate buffer failed.
EFI_SUCCESS Find the specified variable.
Others Errors Return errors from call to gRT->GetVariable.

Definition at line 1317 of file UefiLib.c.

◆ GetVariable3()

EFI_STATUS EFIAPI GetVariable3 ( IN CONST CHAR16 *  Name,
IN CONST EFI_GUID Guid,
OUT VOID **  Value,
OUT UINTN *Size  OPTIONAL,
OUT UINT32 *Attr  OPTIONAL 
)

Return the attributes of the variable.

Returns the status whether get the variable success. The function retrieves variable through the UEFI Runtime Service GetVariable(). The returned buffer is allocated using AllocatePool(). The caller is responsible for freeing this buffer with FreePool(). The attributes are returned if the caller provides a valid Attribute parameter.

If Name is NULL, then ASSERT(). If Guid is NULL, then ASSERT(). If Value is NULL, then ASSERT().

Parameters
[in]NameThe pointer to a Null-terminated Unicode string.
[in]GuidThe pointer to an EFI_GUID structure
[out]ValueThe buffer point saved the variable info.
[out]SizeThe buffer size of the variable.
[out]AttrThe pointer to the variable attributes as found in var store
Return values
EFI_OUT_OF_RESOURCESAllocate buffer failed.
EFI_SUCCESSFind the specified variable.
OthersErrors Return errors from call to gRT->GetVariable.

Definition at line 1393 of file UefiLib.c.

◆ IsLanguageSupported()

EFI_STATUS EFIAPI IsLanguageSupported ( IN CONST CHAR8 *  SupportedLanguages,
IN CONST CHAR8 *  TargetLanguage 
)

This function checks the supported languages list for a target language, This only supports RFC 4646 Languages.

Parameters
SupportedLanguagesThe supported languages
TargetLanguageThe target language
Return values
ReturnsEFI_SUCCESS if the language is supported, EFI_UNSUPPORTED otherwise

Definition at line 653 of file UefiLib.c.

◆ LookupUnicodeString()

EFI_STATUS EFIAPI LookupUnicodeString ( IN CONST CHAR8 *  Language,
IN CONST CHAR8 *  SupportedLanguages,
IN CONST EFI_UNICODE_STRING_TABLE UnicodeStringTable,
OUT CHAR16 **  UnicodeString 
)

This function looks up a Unicode string in UnicodeStringTable.

If Language is a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable that matches the language code specified by Language, then it is returned in UnicodeString.

Parameters
LanguageA pointer to the ISO 639-2 language code for the Unicode string to look up and return.
SupportedLanguagesA pointer to the set of ISO 639-2 language codes that the Unicode string table supports. Language must be a member of this set.
UnicodeStringTableA pointer to the table of Unicode strings.
UnicodeStringA pointer to the Unicode string from UnicodeStringTable that matches the language specified by Language.
Return values
EFI_SUCCESSThe Unicode string that matches the language specified by Language was found in the table of Unicode strings UnicodeStringTable, and it was returned in UnicodeString.
EFI_INVALID_PARAMETERLanguage is NULL.
EFI_INVALID_PARAMETERUnicodeString is NULL.
EFI_UNSUPPORTEDSupportedLanguages is NULL.
EFI_UNSUPPORTEDUnicodeStringTable is NULL.
EFI_UNSUPPORTEDThe language specified by Language is not a member of SupportedLanguages.
EFI_UNSUPPORTEDThe language specified by Language is not supported by UnicodeStringTable.

Definition at line 708 of file UefiLib.c.

◆ LookupUnicodeString2()

EFI_STATUS EFIAPI LookupUnicodeString2 ( IN CONST CHAR8 *  Language,
IN CONST CHAR8 *  SupportedLanguages,
IN CONST EFI_UNICODE_STRING_TABLE UnicodeStringTable,
OUT CHAR16 **  UnicodeString,
IN BOOLEAN  Iso639Language 
)

This function looks up a Unicode string in UnicodeStringTable.

If Language is a member of SupportedLanguages and a Unicode string is found in UnicodeStringTable that matches the language code specified by Language, then it is returned in UnicodeString.

Parameters
LanguageA pointer to an ASCII string containing the ISO 639-2 or the RFC 4646 language code for the Unicode string to look up and return. If Iso639Language is TRUE, then this ASCII string is not assumed to be Null-terminated, and only the first three characters are used. If Iso639Language is FALSE, then this ASCII string must be Null-terminated.
SupportedLanguagesA pointer to a Null-terminated ASCII string that contains a set of ISO 639-2 or RFC 4646 language codes that the Unicode string table supports. Language must be a member of this set. If Iso639Language is TRUE, then this string contains one or more ISO 639-2 language codes with no separator characters. If Iso639Language is FALSE, then is string contains one or more RFC 4646 language codes separated by ';'.
UnicodeStringTableA pointer to the table of Unicode strings. Type EFI_UNICODE_STRING_TABLE is defined in "Related Definitions".
UnicodeStringA pointer to the Null-terminated Unicode string from UnicodeStringTable that matches the language specified by Language.
Iso639LanguageSpecifies the supported language code format. If it is TRUE, then Language and SupportedLanguages follow ISO 639-2 language code format. Otherwise, they follow RFC 4646 language code format.
Return values
EFI_SUCCESSThe Unicode string that matches the language specified by Language was found in the table of Unicode strings UnicodeStringTable, and it was returned in UnicodeString.
EFI_INVALID_PARAMETERLanguage is NULL.
EFI_INVALID_PARAMETERUnicodeString is NULL.
EFI_UNSUPPORTEDSupportedLanguages is NULL.
EFI_UNSUPPORTEDUnicodeStringTable is NULL.
EFI_UNSUPPORTEDThe language specified by Language is not a member of SupportedLanguages.
EFI_UNSUPPORTEDThe language specified by Language is not supported by UnicodeStringTable.

Definition at line 801 of file UefiLib.c.

◆ UefiLibConstructor()

EFI_STATUS EFIAPI UefiLibConstructor ( IN EFI_HANDLE  ImageHandle,
IN EFI_SYSTEM_TABLE SystemTable 
)

Empty constructor function that is required to resolve dependencies between libraries.

 DO NOT REMOVE **
Parameters
ImageHandleThe firmware allocated handle for the EFI image.
SystemTableA pointer to the EFI System Table.
Return values
EFI_SUCCESSThe constructor executed correctly.

Definition at line 29 of file UefiLib.c.