2 UEFI DriverBinding Protocol is defined in UEFI specification.
4 This protocol is produced by every driver that follows the UEFI Driver Model,
5 and it is the central component that allows drivers and controllers to be managed.
7 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
8 This program and the accompanying materials are licensed and made available under
9 the terms and conditions of the BSD License that accompanies this distribution.
10 The full text of the license may be found at
11 http://opensource.org/licenses/bsd-license.php.
13 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
14 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 #ifndef __EFI_DRIVER_BINDING_H__
19 #define __EFI_DRIVER_BINDING_H__
21 FILE_LICENCE ( BSD3 );
24 /// The global ID for the ControllerHandle Driver Protocol.
26 #define EFI_DRIVER_BINDING_PROTOCOL_GUID \
28 0x18a031ab, 0xb443, 0x4d1a, {0xa5, 0xc0, 0xc, 0x9, 0x26, 0x1e, 0x9f, 0x71 } \
31 typedef struct _EFI_DRIVER_BINDING_PROTOCOL EFI_DRIVER_BINDING_PROTOCOL;
34 Tests to see if this driver supports a given controller. If a child device is provided,
35 it further tests to see if this driver supports creating a handle for the specified child device.
37 This function checks to see if the driver specified by This supports the device specified by
38 ControllerHandle. Drivers will typically use the device path attached to
39 ControllerHandle and/or the services from the bus I/O abstraction attached to
40 ControllerHandle to determine if the driver supports ControllerHandle. This function
41 may be called many times during platform initialization. In order to reduce boot times, the tests
42 performed by this function must be very small, and take as little time as possible to execute. This
43 function must not change the state of any hardware devices, and this function must be aware that the
44 device specified by ControllerHandle may already be managed by the same driver or a
45 different driver. This function must match its calls to AllocatePages() with FreePages(),
46 AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
47 Because ControllerHandle may have been previously started by the same driver, if a protocol is
48 already in the opened state, then it must not be closed with CloseProtocol(). This is required
49 to guarantee the state of ControllerHandle is not modified by this function.
51 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
52 @param[in] ControllerHandle The handle of the controller to test. This handle
53 must support a protocol interface that supplies
54 an I/O abstraction to the driver.
55 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
56 parameter is ignored by device drivers, and is optional for bus
57 drivers. For bus drivers, if this parameter is not NULL, then
58 the bus driver must determine if the bus controller specified
59 by ControllerHandle and the child controller specified
60 by RemainingDevicePath are both supported by this
63 @retval EFI_SUCCESS The device specified by ControllerHandle and
64 RemainingDevicePath is supported by the driver specified by This.
65 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
66 RemainingDevicePath is already being managed by the driver
68 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
69 RemainingDevicePath is already being managed by a different
70 driver or an application that requires exclusive access.
71 Currently not implemented.
72 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
73 RemainingDevicePath is not supported by the driver specified by This.
77 (EFIAPI *EFI_DRIVER_BINDING_SUPPORTED)(
78 IN EFI_DRIVER_BINDING_PROTOCOL *This,
79 IN EFI_HANDLE ControllerHandle,
80 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
84 Starts a device controller or a bus controller.
86 The Start() function is designed to be invoked from the EFI boot service ConnectController().
87 As a result, much of the error checking on the parameters to Start() has been moved into this
88 common boot service. It is legal to call Start() from other locations,
89 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
90 1. ControllerHandle must be a valid EFI_HANDLE.
91 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
92 EFI_DEVICE_PATH_PROTOCOL.
93 3. Prior to calling Start(), the Supported() function for the driver specified by This must
94 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
96 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
97 @param[in] ControllerHandle The handle of the controller to start. This handle
98 must support a protocol interface that supplies
99 an I/O abstraction to the driver.
100 @param[in] RemainingDevicePath A pointer to the remaining portion of a device path. This
101 parameter is ignored by device drivers, and is optional for bus
102 drivers. For a bus driver, if this parameter is NULL, then handles
103 for all the children of Controller are created by this driver.
104 If this parameter is not NULL and the first Device Path Node is
105 not the End of Device Path Node, then only the handle for the
106 child device specified by the first Device Path Node of
107 RemainingDevicePath is created by this driver.
108 If the first Device Path Node of RemainingDevicePath is
109 the End of Device Path Node, no child handle is created by this
112 @retval EFI_SUCCESS The device was started.
113 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
114 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
115 @retval Others The driver failded to start the device.
120 (EFIAPI *EFI_DRIVER_BINDING_START)(
121 IN EFI_DRIVER_BINDING_PROTOCOL *This,
122 IN EFI_HANDLE ControllerHandle,
123 IN EFI_DEVICE_PATH_PROTOCOL *RemainingDevicePath OPTIONAL
127 Stops a device controller or a bus controller.
129 The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
130 As a result, much of the error checking on the parameters to Stop() has been moved
131 into this common boot service. It is legal to call Stop() from other locations,
132 but the following calling restrictions must be followed, or the system behavior will not be deterministic.
133 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
134 same driver's Start() function.
135 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
136 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
137 Start() function, and the Start() function must have called OpenProtocol() on
138 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
140 @param[in] This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
141 @param[in] ControllerHandle A handle to the device being stopped. The handle must
142 support a bus specific I/O protocol for the driver
143 to use to stop the device.
144 @param[in] NumberOfChildren The number of child device handles in ChildHandleBuffer.
145 @param[in] ChildHandleBuffer An array of child handles to be freed. May be NULL
146 if NumberOfChildren is 0.
148 @retval EFI_SUCCESS The device was stopped.
149 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
154 (EFIAPI *EFI_DRIVER_BINDING_STOP)(
155 IN EFI_DRIVER_BINDING_PROTOCOL *This,
156 IN EFI_HANDLE ControllerHandle,
157 IN UINTN NumberOfChildren,
158 IN EFI_HANDLE *ChildHandleBuffer OPTIONAL
162 /// This protocol provides the services required to determine if a driver supports a given controller.
163 /// If a controller is supported, then it also provides routines to start and stop the controller.
165 struct _EFI_DRIVER_BINDING_PROTOCOL {
166 EFI_DRIVER_BINDING_SUPPORTED Supported;
167 EFI_DRIVER_BINDING_START Start;
168 EFI_DRIVER_BINDING_STOP Stop;
171 /// The version number of the UEFI driver that produced the
172 /// EFI_DRIVER_BINDING_PROTOCOL. This field is used by
173 /// the EFI boot service ConnectController() to determine
174 /// the order that driver's Supported() service will be used when
175 /// a controller needs to be started. EFI Driver Binding Protocol
176 /// instances with higher Version values will be used before ones
177 /// with lower Version values. The Version values of 0x0-
178 /// 0x0f and 0xfffffff0-0xffffffff are reserved for
179 /// platform/OEM specific drivers. The Version values of 0x10-
180 /// 0xffffffef are reserved for IHV-developed drivers.
185 /// The image handle of the UEFI driver that produced this instance
186 /// of the EFI_DRIVER_BINDING_PROTOCOL.
188 EFI_HANDLE ImageHandle;
191 /// The handle on which this instance of the
192 /// EFI_DRIVER_BINDING_PROTOCOL is installed. In most
193 /// cases, this is the same handle as ImageHandle. However, for
194 /// UEFI drivers that produce more than one instance of the
195 /// EFI_DRIVER_BINDING_PROTOCOL, this value may not be
196 /// the same as ImageHandle.
198 EFI_HANDLE DriverBindingHandle;
201 extern EFI_GUID gEfiDriverBindingProtocolGuid;