Library Classes and their associated functions, defines, and data structures are declared very similar to protocols and GUIDs. The difference is that Library Classes are typically placed in a different subdirectory of an EDK II package. The typical path to a library .h file is
<<PackageName>>/Include/Library/<<LibraryName>>.h. For example, all the libraries classes defined by the MdePkg can be found in the EDK II /MdePkg/Include/Library. When a new library class is defined and added to an include directory of an EDK II package, the library class must also be added to the [LibraryClasses] section of a package's .dec file. The .dec file is where the mapping between the name of the library class and the path to the include file for the library class is declared. Defining a new library class is not commonly required when implementing a new UEFI Driver. If a UEFI Driver implementation does require a new library class, then the new library class is usually added to the same EDK II package that contains the UEFI Driver implementation.
Example A-30 shows a template for adding a new library class to the [LibraryClasses] section of an EDK II package .dec file. Following that, Example A-31 shows the template for the .h files for a library class placed in the include directory of an EDK II package. All public functions provided by a library class must use the
EFIAPI calling convention. The return type for a library class function is not required to be
EFI_STATUS is only shown in this template as an example.
[LibraryClasses]## @libraryclass <<BriefDescription>>##<<LibraryClassName>>|Include/Library/<<LibraryClassName>>.h
/** @file<<BriefDescription>><<DetailedDescription>><<Copyright>><<License>>**/#ifndef __<<LIBRARY_CLASS_NAME>>_H__#define __<<LIBRARY_CLASS_NAME>>_H__////// Library class public defines///////// Library class public structures/unions///////// Library class public functions///EFI_STATUSEFIAPILibraryFunction1 (//// Additional function arguments here.//);VOIDEFIAPILibraryFunction2 (//// Additional function arguments here.//);UINT8EFIAPILibraryFunction3 (//// Additional function arguments here.//);#endif