11.2 GetDriverName() Implementations

The GetDriverName() service retrieves the name of a UEFI Driver. It may be used to retrieve the name of a UEFI Driver even if the UEFI Driver is not managing any devices. Example 129, below, shows a typical implementation of the GetDriverName() service for the Component Name 2 Protocol along with a table of Unicode strings for the UEFI Driver name in English, French, and Spanish. The recommended implementation style shown here allows the same GetDriverName() service implementation to be shared between the Component Name Protocol and the Component Name 2 Protocol. The UefiLib function LookupUnicodeString2() supports looking up strings using either ISO 639-2 or RFC 4646 language code formats.
The static table of driver names contains two elements per entry. The first is an ASCII string containing one or more language codes separated by ';' characters. The language codes may be in the ISO639-2 or the RFC 4646 format.
The second element is a Unicode string representing the name of the UEFI Driver for the set of languages specified by the first element. The static table is terminated by two NULL elements. The format is very size efficient because each Unicode string name for the UEFI Driver can be associated with many language codes.

Example 129-GetDriverName() for Device, Bus, or Hybrid Driver

#include <Uefi.h>
#include <Protocol/ComponentName2.h>
#include <Library/UefiLib.h>
EFI_UNICODE_STRING_TABLE mAbcDriverNameTable[] = {
{ "eng;en", (CHAR16 *)L"ABC Driver in English"},
{ "fra;fr", (CHAR16 *)L"ABC Driver in French"},
{ "spa;sp", (CHAR16 *)L"ABC Driver in Spanish"},
AbcGetDriverName (
IN CHAR8 *Language,
OUT CHAR16 **DriverName
return LookupUnicodeString2 (
(BOOLEAN)(This != &gAbcComponentName2)