1 /** @file
2   The header file of IScsiDriver.c.
3 
4 Copyright (c) 2004 - 2011, Intel Corporation. All rights reserved.<BR>
5 This program and the accompanying materials
6 are licensed and made available under the terms and conditions of the BSD License
7 which accompanies this distribution.  The full text of the license may be found at
8 http://opensource.org/licenses/bsd-license.php
9 
10 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
11 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
12 
13 **/
14 
15 #ifndef _ISCSI_DRIVER_H_
16 #define _ISCSI_DRIVER_H_
17 
18 #include <Uefi.h>
19 #include <Protocol/DevicePath.h>
20 #include <Protocol/LoadedImage.h>
21 #include <Protocol/HiiConfigAccess.h>
22 #include <Protocol/HiiDatabase.h>
23 #include <Library/UefiDriverEntryPoint.h>
24 #include <Library/UefiBootServicesTableLib.h>
25 #include <Library/UefiLib.h>
26 #include <Library/DevicePathLib.h>
27 #include <Protocol/DriverBinding.h>
28 #include <Protocol/ScsiPassThruExt.h>
29 
30 #define ISCSI_INITIATOR_NAME_VAR_NAME L"I_NAME"
31 
32 typedef struct _ISCSI_PRIVATE_PROTOCOL {
33   UINT32  Reserved;
34 } ISCSI_PRIVATE_PROTOCOL;
35 
36 //
37 // EFI Driver Binding Protocol for iSCSI driver.
38 //
39 
40 /**
41   Tests to see if this driver supports a given controller. If a child device is provided,
42   it further tests to see if this driver supports creating a handle for the specified child device.
43 
44   @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
45   @param[in]  ControllerHandle     The handle of the controller to test. This handle
46                                    must support a protocol interface that supplies
47                                    an I/O abstraction to the driver.
48   @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.
49                                    This parameter is ignored by device drivers, and is optional for bus drivers.
50 
51 
52   @retval EFI_SUCCESS              The device specified by ControllerHandle and
53                                    RemainingDevicePath is supported by the driver specified by This.
54   @retval EFI_ALREADY_STARTED      The device specified by ControllerHandle and
55                                    RemainingDevicePath is already being managed by the driver
56                                    specified by This.
57   @retval EFI_ACCESS_DENIED        The device specified by ControllerHandle and
58                                    RemainingDevicePath is already being managed by a different
59                                    driver or an application that requires exclusive acces.
60                                    Currently not implemented.
61   @retval EFI_UNSUPPORTED          The device specified by ControllerHandle and
62                                    RemainingDevicePath is not supported by the driver specified by This.
63 **/
64 EFI_STATUS
65 EFIAPI
66 IScsiDriverBindingSupported (
67   IN EFI_DRIVER_BINDING_PROTOCOL  *This,
68   IN EFI_HANDLE                   ControllerHandle,
69   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
70   );
71 
72 /**
73   Start this driver on ControllerHandle. The Start() function is designed to be
74   invoked from the EFI boot service ConnectController(). As a result, much of
75   the error checking on the parameters to Start() has been moved into this
76   common boot service. It is legal to call Start() from other locations,
77   but the following calling restrictions must be followed or the system behavior will not be deterministic.
78   1. ControllerHandle must be a valid EFI_HANDLE.
79   2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
80      EFI_DEVICE_PATH_PROTOCOL.
81   3. Prior to calling Start(), the Supported() function for the driver specified by This must
82      have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
83 
84   @param[in]  This                 A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
85   @param[in]  ControllerHandle     The handle of the controller to start. This handle
86                                    must support a protocol interface that supplies
87                                    an I/O abstraction to the driver.
88   @param[in]  RemainingDevicePath  A pointer to the remaining portion of a device path.
89                                    This parameter is ignored by device drivers, and is optional for bus drivers.
90 
91   @retval EFI_SUCCESS              The device was started.
92   @retval EFI_DEVICE_ERROR         The device could not be started due to a device error.
93                                    Currently not implemented.
94   @retval EFI_OUT_OF_RESOURCES     The request could not be completed due to a lack of resources.
95   @retval Others                   The driver failded to start the device.
96 **/
97 EFI_STATUS
98 EFIAPI
99 IScsiDriverBindingStart (
100   IN EFI_DRIVER_BINDING_PROTOCOL  *This,
101   IN EFI_HANDLE                   ControllerHandle,
102   IN EFI_DEVICE_PATH_PROTOCOL     *RemainingDevicePath OPTIONAL
103   );
104 
105 /**
106   Stop this driver on ControllerHandle.
107 
108   Release the control of this controller and remove the IScsi functions. The Stop()
109   function is designed to be invoked from the EFI boot service DisconnectController().
110   As a result, much of the error checking on the parameters to Stop() has been moved
111   into this common boot service. It is legal to call Stop() from other locations,
112   but the following calling restrictions must be followed or the system behavior will not be deterministic.
113   1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
114      same driver's Start() function.
115   2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
116      EFI_HANDLE. In addition, all of these handles must have been created in this driver's
117      Start() function, and the Start() function must have called OpenProtocol() on
118      ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
119 
120   @param[in]  This              A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
121   @param[in]  ControllerHandle  A handle to the device being stopped. The handle must
122                                 support a bus specific I/O protocol for the driver
123                                 to use to stop the device.
124   @param[in]  NumberOfChildren  The number of child device handles in ChildHandleBuffer.Not used.
125   @param[in]  ChildHandleBuffer An array of child handles to be freed. May be NULL
126                                 if NumberOfChildren is 0.Not used.
127 
128   @retval EFI_SUCCESS           The device was stopped.
129   @retval EFI_DEVICE_ERROR      The device could not be stopped due to a device error.
130 **/
131 EFI_STATUS
132 EFIAPI
133 IScsiDriverBindingStop (
134   IN EFI_DRIVER_BINDING_PROTOCOL  *This,
135   IN EFI_HANDLE                   ControllerHandle,
136   IN UINTN                        NumberOfChildren,
137   IN EFI_HANDLE                   *ChildHandleBuffer OPTIONAL
138   );
139 
140 #endif
141