iPXE
DriverBinding.h
Go to the documentation of this file.
00001 /** @file
00002   UEFI DriverBinding Protocol is defined in UEFI specification.
00003 
00004   This protocol is produced by every driver that follows the UEFI Driver Model,
00005   and it is the central component that allows drivers and controllers to be managed.
00006 
00007 Copyright (c) 2006 - 2010, Intel Corporation. All rights reserved.<BR>
00008 This program and the accompanying materials are licensed and made available under
00009 the terms and conditions of the BSD License that accompanies this distribution.
00010 The full text of the license may be found at
00011 http://opensource.org/licenses/bsd-license.php.
00012 
00013 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
00014 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
00015 
00016 **/
00017 
00018 #ifndef __EFI_DRIVER_BINDING_H__
00019 #define __EFI_DRIVER_BINDING_H__
00020 
00021 FILE_LICENCE ( BSD3 );
00022 
00023 ///
00024 /// The global ID for the ControllerHandle Driver Protocol.
00025 ///
00026 #define EFI_DRIVER_BINDING_PROTOCOL_GUID \
00027   { \
00028     0x18a031ab, 0xb443, 0x4d1a, {0xa5, 0xc0, 0xc, 0x9, 0x26, 0x1e, 0x9f, 0x71 } \
00029   }
00030 
00031 typedef struct _EFI_DRIVER_BINDING_PROTOCOL  EFI_DRIVER_BINDING_PROTOCOL;
00032 
00033 /**
00034   Tests to see if this driver supports a given controller. If a child device is provided,
00035   it further tests to see if this driver supports creating a handle for the specified child device.
00036 
00037   This function checks to see if the driver specified by This supports the device specified by
00038   ControllerHandle. Drivers will typically use the device path attached to
00039   ControllerHandle and/or the services from the bus I/O abstraction attached to
00040   ControllerHandle to determine if the driver supports ControllerHandle. This function
00041   may be called many times during platform initialization. In order to reduce boot times, the tests
00042   performed by this function must be very small, and take as little time as possible to execute. This
00043   function must not change the state of any hardware devices, and this function must be aware that the
00044   device specified by ControllerHandle may already be managed by the same driver or a
00045   different driver. This function must match its calls to AllocatePages() with FreePages(),
00046   AllocatePool() with FreePool(), and OpenProtocol() with CloseProtocol().
00047   Because ControllerHandle may have been previously started by the same driver, if a protocol is
00048   already in the opened state, then it must not be closed with CloseProtocol(). This is required
00049   to guarantee the state of ControllerHandle is not modified by this function.
00050 
00051   @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
00052   @param[in]  ControllerHandle     The handle of the controller to test. This handle
00053                                    must support a protocol interface that supplies
00054                                    an I/O abstraction to the driver.
00055   @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This
00056                                    parameter is ignored by device drivers, and is optional for bus
00057                                    drivers. For bus drivers, if this parameter is not NULL, then
00058                                    the bus driver must determine if the bus controller specified
00059                                    by ControllerHandle and the child controller specified
00060                                    by RemainingDevicePath are both supported by this
00061                                    bus driver.
00062 
00063   @retval EFI_SUCCESS              The device specified by ControllerHandle and
00064                                    RemainingDevicePath is supported by the driver specified by This.
00065   @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and
00066                                    RemainingDevicePath is already being managed by the driver
00067                                    specified by This.
00068   @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and
00069                                    RemainingDevicePath is already being managed by a different
00070                                    driver or an application that requires exclusive access.
00071                                    Currently not implemented.
00072   @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and
00073                                    RemainingDevicePath is not supported by the driver specified by This.
00074 **/
00075 typedef
00076 EFI_STATUS
00077 (EFIAPI *EFI_DRIVER_BINDING_SUPPORTED)(
00078   IN EFI_DRIVER_BINDING_PROTOCOL            *This,
00079   IN EFI_HANDLE                             ControllerHandle,
00080   IN EFI_DEVICE_PATH_PROTOCOL               *RemainingDevicePath OPTIONAL
00081   );
00082 
00083 /**
00084   Starts a device controller or a bus controller.
00085 
00086   The Start() function is designed to be invoked from the EFI boot service ConnectController().
00087   As a result, much of the error checking on the parameters to Start() has been moved into this
00088   common boot service. It is legal to call Start() from other locations,
00089   but the following calling restrictions must be followed, or the system behavior will not be deterministic.
00090   1. ControllerHandle must be a valid EFI_HANDLE.
00091   2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
00092      EFI_DEVICE_PATH_PROTOCOL.
00093   3. Prior to calling Start(), the Supported() function for the driver specified by This must
00094      have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
00095 
00096   @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
00097   @param[in]  ControllerHandle     The handle of the controller to start. This handle
00098                                    must support a protocol interface that supplies
00099                                    an I/O abstraction to the driver.
00100   @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.  This
00101                                    parameter is ignored by device drivers, and is optional for bus
00102                                    drivers. For a bus driver, if this parameter is NULL, then handles
00103                                    for all the children of Controller are created by this driver.
00104                                    If this parameter is not NULL and the first Device Path Node is
00105                                    not the End of Device Path Node, then only the handle for the
00106                                    child device specified by the first Device Path Node of
00107                                    RemainingDevicePath is created by this driver.
00108                                    If the first Device Path Node of RemainingDevicePath is
00109                                    the End of Device Path Node, no child handle is created by this
00110                                    driver.
00111 
00112   @retval EFI_SUCCESS              The device was started.
00113   @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.Currently not implemented.
00114   @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.
00115   @retval Others                   The driver failded to start the device.
00116 
00117 **/
00118 typedef
00119 EFI_STATUS
00120 (EFIAPI *EFI_DRIVER_BINDING_START)(
00121   IN EFI_DRIVER_BINDING_PROTOCOL            *This,
00122   IN EFI_HANDLE                             ControllerHandle,
00123   IN EFI_DEVICE_PATH_PROTOCOL               *RemainingDevicePath OPTIONAL
00124   );
00125 
00126 /**
00127   Stops a device controller or a bus controller.
00128 
00129   The Stop() function is designed to be invoked from the EFI boot service DisconnectController().
00130   As a result, much of the error checking on the parameters to Stop() has been moved
00131   into this common boot service. It is legal to call Stop() from other locations,
00132   but the following calling restrictions must be followed, or the system behavior will not be deterministic.
00133   1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
00134      same driver's Start() function.
00135   2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
00136      EFI_HANDLE. In addition, all of these handles must have been created in this driver's
00137      Start() function, and the Start() function must have called OpenProtocol() on
00138      ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
00139 
00140   @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
00141   @param[in]  ControllerHandle  A handle to the device being stopped. The handle must
00142                                 support a bus specific I/O protocol for the driver
00143                                 to use to stop the device.
00144   @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.
00145   @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL
00146                                 if NumberOfChildren is 0.
00147 
00148   @retval EFI_SUCCESS           The device was stopped.
00149   @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.
00150 
00151 **/
00152 typedef
00153 EFI_STATUS
00154 (EFIAPI *EFI_DRIVER_BINDING_STOP)(
00155   IN EFI_DRIVER_BINDING_PROTOCOL            *This,
00156   IN  EFI_HANDLE                            ControllerHandle,
00157   IN  UINTN                                 NumberOfChildren,
00158   IN  EFI_HANDLE                            *ChildHandleBuffer OPTIONAL
00159   );
00160 
00161 ///
00162 /// This protocol provides the services required to determine if a driver supports a given controller.
00163 /// If a controller is supported, then it also provides routines to start and stop the controller.
00164 ///
00165 struct _EFI_DRIVER_BINDING_PROTOCOL {
00166   EFI_DRIVER_BINDING_SUPPORTED  Supported;
00167   EFI_DRIVER_BINDING_START      Start;
00168   EFI_DRIVER_BINDING_STOP       Stop;
00169 
00170   ///
00171   /// The version number of the UEFI driver that produced the
00172   /// EFI_DRIVER_BINDING_PROTOCOL. This field is used by
00173   /// the EFI boot service ConnectController() to determine
00174   /// the order that driver's Supported() service will be used when
00175   /// a controller needs to be started. EFI Driver Binding Protocol
00176   /// instances with higher Version values will be used before ones
00177   /// with lower Version values. The Version values of 0x0-
00178   /// 0x0f and 0xfffffff0-0xffffffff are reserved for
00179   /// platform/OEM specific drivers. The Version values of 0x10-
00180   /// 0xffffffef are reserved for IHV-developed drivers.
00181   ///
00182   UINT32                        Version;
00183 
00184   ///
00185   /// The image handle of the UEFI driver that produced this instance
00186   /// of the EFI_DRIVER_BINDING_PROTOCOL.
00187   ///
00188   EFI_HANDLE                    ImageHandle;
00189 
00190   ///
00191   /// The handle on which this instance of the
00192   /// EFI_DRIVER_BINDING_PROTOCOL is installed. In most
00193   /// cases, this is the same handle as ImageHandle. However, for
00194   /// UEFI drivers that produce more than one instance of the
00195   /// EFI_DRIVER_BINDING_PROTOCOL, this value may not be
00196   /// the same as ImageHandle.
00197   ///
00198   EFI_HANDLE                    DriverBindingHandle;
00199 };
00200 
00201 extern EFI_GUID gEfiDriverBindingProtocolGuid;
00202 
00203 #endif