A.5.4 Including Protocols, GUIDs, and Library Classes
A UEFI Driver that produces or consumes a protocol or GUID must include the protocol or GUID definitions using
#includestatements and also declare the usage of those Protocols or GUIDs in the
[Guids]sections of the INF file for the UEFI Driver. A UEFI Driver that uses defines, structures, unions, or functions from a library class must include the those definitions using an
#includestatements use paths in EDK II packages to the .h files for the required protocols or GUIDs or library classes. The include paths that an EDK II package supports are declared in the [Includes] section of an EDK II package. An EDK II package typically uses an include directory called Include and use subdirectories called
Protocol and Guid and Library for .h files. The example below shows some example
#includestatements for a UEFI Driver that uses protocols and GUIDs and library classes from the
MdePkgcontains all the protocols and GUIDs defined in the UEFI Specification along with a number of library classes that are very useful to UEFI Drivers. The include file Uefi.h pulls in all the standard definitions from the UEFI Specification. This file must be included before any other include files. This next three include statements pull in the Block I/O Protocol, the Driver Binding Protocol, and the Component Name 2 Protocol. The next 2 include statements pull in the definitions for the UEFI Global Variable GUID and the GUID associated with the SMBIOS table that may be registered in the UEFI System Table. The last set of include statements pull in the definitions from a number of library classes that are commonly used by UEFI Drivers.
Example A-33, below, shows a portion of an INF file for the same UEFI Driver that requires the protocols and GUIDs included in Example A-32 above. A UEFI Driver must declare the Protocols, GUIDs, and Library Classes the UEFI Driver uses in the INF file. The comment blocks associated with each Protocol and GUID and optional, but they describe how each Protocol and GUID is used by the UEFI Driver. This specific example shows that this UEFI Driver produces the Driver Binding Protocol and the Component Name Protocol, and it consumes the Block I/O Protocol in the
Start()function of the Driver Binding Protocol. It also shows that UEFI Global Variable GUID is used to access the variable called
ConInand that the SMBIOS Table GUID is used to lookup the SMBIOS Table in the UEFI System Table.
gEfiDriverBindingProtocolGuid ## PRODUCES
gEfiComponentName2ProtocolGuid ## PRODUCES
gEfiBlockIoProtocolGuid ## TO_START
gEfiGlobalVariableGuid ## CONSUMES ## Variable:L"ConIn"
gEfiSmbiosTableGuid ## CONSUMES