16.1 Driver Supported EFI Version Protocol Implementation

The implementation of the Driver Supported EFI Version Protocol is typically found in the <<DriverName>>.c file for a UEFI Driver and is installed onto the ImageHandle in the driver entry point using the UEFI Boot Service InstallMultipleProtocolInterfaces(). Appendix A contains a template for the <<DriverName>>.c file that includes the declaration of a global variable for the Driver Supported EFI Version Protocol instance. The list of tasks required to implement the Driver Support EFI Version Protocol feature are as follows:

  • Add global variable for the EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL instance to <<DriverName>>.c
  • Set the FirmwareVersion field of the Driver Supported EFI Version Protocol instance in the driver entry point if the value required is different than the value assigned in the global variable declaration.
  • Install the Driver Supported EFI Version Protocol instance onto the ImageHandle of the UEFI Driver in the driver entry point.
  • If the UEFI Driver supports the unload feature, uninstall the Driver Supported EFI Version Protocol instance in the Unload() function.

The following example shows the protocol interface structure for the Driver Supported EFI Version Protocol for reference. It is composed of the two data fields called Length and FirmwareVersion.

Example 160-Driver Support EFI Version Protocol
///
/// The EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL provides a
/// mechanism for an EFI driver to publish the version of the EFI
/// specification it conforms to. This protocol must be placed on
/// the driver's image handle when the driver's entry point is
/// called.
///
typedef struct _EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL {
  ///
  /// The size, in bytes, of the entire structure. Future versions of this
  /// specification may grow the size of the structure.
  ///
  UINT32 Length; 
  ///
  /// The version of the EFI specification that this driver conforms to.
  ///
  UINT32 FirmwareVersion;
} EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL;

This example declares a global variable called gEbcDriverSupportedEfiVersion whose FirmwareVersion field is assigned to EFI_2_31_SYSTEM_TABLE_REVISION, the value associated with the UEFI 2.3.1 Specification.

Example 161-Driver Supported EFI Version Protocol Feature
#include <Uefi.h>
#include <Protocol/DriverSupportedEfiVersion.h>
#include <Library/UefiBootServicesTableLib.h>
#include <Library/DebugLib.h>

GLOBAL_REMOVE_IF_UNREFERENCED
EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL gAbcDriverSupportedEfiVersion = {
  sizeof (EFI_DRIVER_SUPPORTED_EFI_VERSION_PROTOCOL),  // Length
  EFI_2_31_SYSTEM_TABLE_REVISION                       // FirmwareVersion
};

EFI_STATUS
EFIAPI
AbcDriverEntryPoint (
  IN EFI_HANDLE                                        ImageHandle,
  IN EFI_SYSTEM_TABLE                                  *SystemTable
  )
{
  EFI_STATUS  Status;

  //
  // Install Driver Supported EFI Version Protocol onto ImageHandle
  //
  Status = gBS->InstallMultipleProtocolInterfaces (
                  &ImageHandle,
                  &gEfiDriverSupportedEfiVersionProtocolGuid,
                  & gAbcDriverSupportedEfiVersion,
                  NULL
                  );
  ASSERT_EFI_ERROR (Status);

  return Status;
}

The EFI System Table chapter of the UEFI Specification defines revision values for the EFI Specifications and UEFI Specifications. The table below provides a summary of the define name available to UEFI Drivers.

Table 24-UEFI Specific Revision Values
Specification Define Name Value
UEFI Specification Version 2.3.1 EFI_2_31_SYSTEM_TABLE_REVISION ((2 << 16) | (31))
UEFI Specification Version 2.3 EFI_2_30_SYSTEM_TABLE_REVISION ((2 << 16) | (30))
UEFI Specification Version 2.2 EFI_2_20_SYSTEM_TABLE_REVISION ((2 << 16) | (20))
UEFI Specification Version 2.1 EFI_2_10_SYSTEM_TABLE_REVISION ((2 << 16) | (10))
UEFI Specification Version 2.0 EFI_2_00_SYSTEM_TABLE_REVISION ((2 << 16) | (00))
EFI Specification Version 1.1 EFI_1_10_SYSTEM_TABLE_REVISION ((1 << 16) | (10))
EFI Specification Version 1.02 EFI_1_02_SYSTEM_TABLE_REVISION ((1 << 16) | (02))

UEFI Drivers producing the Driver Supported EFI Version Protocol typically use the style shown in the example above. However, more complex UEFI Drivers compatible with several versions of the EFI Specification and UEFI Specification must detect the UEFI capabilities of the platform firmware and adjust the behavior of the UEFI Driver to match those UEFI capabilities. In this more complex case, the UEFI Driver updates the FirmwareVersion field to declare the specific version of the UEFI Specification the UEFI Driver follows.