5.2 Write the UEFI Driver entry point
The following table lists the most common protocols used in UEFI driver entry point.

Table 9 Protocols Used to Separate the Loading and Starting/Stopping of Drivers

Protocol
Description
Driver Binding Protocol
Provides functions for starting and stopping the driver, as well as a function for determining if the driver can manage a particular controller. The UEFI Driver Model requires this protocol.
Component Name Protocol
Provides functions for retrieving a human-readable name of a driver and the controllers that a driver is managing. While the UEFI Specification lists this protocol as optional, the Developer's Interface Guide for 64-bit Intel Architecturebased Servers (hereafter referred to as "DIG64 specification" or "DIG64") lists this protocol as required for Itanium-based platforms.
Driver Diagnostics Protocol
Provides functions for executing diagnostic functions on the devices that a driver is managing. While the UEFI
Specification lists this protocol as optional, DIG64 lists this protocol as required for Itanium-based platforms.
The UefiLib library class is provided to simplify the driver entry point of a UEFI driver.

5.2.1 Example: APIs in UefiLib

The two APIs in UefiLib are shown below:
1
EFI_STATUS
2
EfiLibInstallDriverBinding (
3
IN CONST EFI_HANDLE ImageHandle ,
4
IN CONST EFI_SYSTEM_TABLE * SystemTable ,
5
IN EFI_DRIVER_BINDING_PROTOCOL * DriverBinding ,
6
IN EFI_HANDLE DriverBindingHandle
7
);
8
9
EFI_STATUS
10
EfiLibInstallAllDriverProtocols2 (
11
IN CONST EFI_HANDLE ImageHandle ,
12
IN CONST EFI_SYSTEM_TABLE * SystemTable ,
13
IN EFI_DRIVER_BINDING_PROTOCOL * DriverBinding ,
14
IN EFI_HANDLE DriverBindingHandle ,
15
IN CONST EFI_COMPONENT_NAME_PROTOCOL * ComponentName , OPTIONAL
16
IN CONST EFI_COMPONENT_NAME2_PROTOCOL * ComponentName2 , OPTIONAL
17
IN CONST EFI_DRIVER_CONFIGURATION_PROTOCOL * DriverConfiguration ,OPTIONAL
18
IN CONST EFI_DRIVER_CONFIGURATION2_PROTOCOL * DriverConfiguration2 ,OPTIONAL
19
IN CONST EFI_DRIVER_DIAGNOSTICS_PROTOCOL * DriverDiagnostics ,OPTIONAL
20
IN CONST EFI_DRIVER_DIAGNOSTICS2_PROTOCOL * DriverDiagnostics2 OPTIONAL
21
);
Copied!

5.2.2 Example: Entry point to the Abc driver

The following shows an example of the entry point to the Abc driver that installs the Driver Binding Protocol gAbcDriverBindingProtocol, the Component Name Protocol gAbcComponentName, the Component Name2 Protocol gAbcComponentName2, the
Diagnostic Protocol gAbcDriverDiagnostics and the Diagnostic2 Protocol
gAbcDriverDiagnostics2 onto the Abc driver's image handle. This driver simply returns the status from the UefiLib function EfiLibInstallAllDriverProtocols2()
1
EFI_DRIVER_BINDING_PROTOCOL gAbcDriverBinding = {
2
AbcDriverBindingSupported,
3
AbcDriverBindingStart,
4
AbcDriverBindingStop,
5
0xa,
6
NULL,
7
NULL
8
};
9
EFI_COMPONENT_NAME_PROTOCOL gAbcComponentName = {
10
AbcComponentNameGetDriverName,
11
AbcComponentNameGetControllerName,
12
"eng"
13
};
14
EFI_COMPONENT_NAME2_PROTOCOL gAbcComponentName2 = {
15
(EFI_COMPONENT_NAME2_GET_DRIVER_NAME) AbcComponentNameGetDriverName,
16
(EFI_COMPONENT_NAME2_GET_CONTROLLER_NAME)
17
AbcComponentNameGetControllerName,
18
"en"
19
};
20
EFI_DRIVER_DIAGNOSTICS_PROTOCOL gAbcDriverDiagnostics = {
21
AbcDriverDiagnosticsRunDiagnostics,
22
"eng"
23
};
24
EFI_DRIVER_DIAGNOSTICS2_PROTOCOL gAbcDriverDiagnostics2 = {
25
(EFI_DRIVER_DIAGNOSTICS2_RUN_DIAGNOSTICS) gAbcDriverDiagnosticsRunDiagnostics,
26
"en"
27
};
28
EFI_STATUS
29
EFIAPI
30
AbcDriverEntryPoint (
31
IN EFI_HANDLE ImageHandle,
32
IN EFI_SYSTEM_TABLE *SystemTable
33
)
34
{
35
//
36
// Initialize a simple EFI driver that follows the EFI Driver Model
37
//
38
return EfiLibInstallAllDriverProtocols (
39
ImageHandle, // Driver's image handle
40
SystemTable, // EFI System Table Pointer
41
&gAbcDriverBinding, // Required parameters
42
ImageHandle,
43
// Handle for driver-related protocols &gAbcComponentName,
44
// Component Name Procol. May be NULL.
45
&gAbcComponentName2, // Component Name2 Procol. May be NULL.
46
NULL, // Configuration Protocol. May be NULL.
47
NULL // Configuration Protocol2 May be NULL.
48
&gAbcDriverDiagnostics, // Diagnostics Protocol. May be NULL.
49
&gAbcDriverDiagnostics2,// Diagnostics Protocol2 May be NULL.
50
);
51
}
Copied!
Last modified 1yr ago