2 The header file of IScsiDriver.c.
4 Copyright (c) 2004 - 2008, Intel Corporation.<BR>
5 All rights reserved. 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
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.
15 #ifndef _ISCSI_DRIVER_H_
16 #define _ISCSI_DRIVER_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 #include <Protocol/IScsiInitiatorName.h>
30 #include <Protocol/Ip4Config.h>
31 #include <Protocol/ComponentName.h>
32 #include <Protocol/ComponentName2.h>
35 #define ISCSI_PRIVATE_GUID \
36 { 0xfa3cde4c, 0x87c2, 0x427d, {0xae, 0xde, 0x7d, 0xd0, 0x96, 0xc8, 0x8c, 0x58} }
38 #define ISCSI_INITIATOR_NAME_VAR_NAME L"I_NAME"
40 extern EFI_COMPONENT_NAME2_PROTOCOL gIScsiComponentName2
;
41 extern EFI_COMPONENT_NAME_PROTOCOL gIScsiComponentName
;
43 extern EFI_ISCSI_INITIATOR_NAME_PROTOCOL gIScsiInitiatorName
;
46 extern EFI_GUID mIScsiPrivateGuid
;
48 typedef struct _ISCSI_PRIVATE_PROTOCOL
{
50 } ISCSI_PRIVATE_PROTOCOL
;
53 // EFI Driver Binding Protocol for iSCSI driver.
57 Tests to see if this driver supports a given controller. If a child device is provided,
58 it further tests to see if this driver supports creating a handle for the specified child device.
60 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
61 @param ControllerHandle The handle of the controller to test. This handle
62 must support a protocol interface that supplies
63 an I/O abstraction to the driver.
64 @param RemainingDevicePath A pointer to the remaining portion of a device path.
65 This parameter is ignored by device drivers, and is optional for bus drivers.
68 @retval EFI_SUCCESS The device specified by ControllerHandle and
69 RemainingDevicePath is supported by the driver specified by This.
70 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
71 RemainingDevicePath is already being managed by the driver
73 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
74 RemainingDevicePath is already being managed by a different
75 driver or an application that requires exclusive acces.
76 Currently not implemented.
77 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
78 RemainingDevicePath is not supported by the driver specified by This.
82 IScsiDriverBindingSupported (
83 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
84 IN EFI_HANDLE ControllerHandle
,
85 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
89 Start this driver on ControllerHandle. The Start() function is designed to be
90 invoked from the EFI boot service ConnectController(). As a result, much of
91 the error checking on the parameters to Start() has been moved into this
92 common boot service. It is legal to call Start() from other locations,
93 but the following calling restrictions must be followed or the system behavior will not be deterministic.
94 1. ControllerHandle must be a valid EFI_HANDLE.
95 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
96 EFI_DEVICE_PATH_PROTOCOL.
97 3. Prior to calling Start(), the Supported() function for the driver specified by This must
98 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
100 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
101 @param ControllerHandle The handle of the controller to start. This handle
102 must support a protocol interface that supplies
103 an I/O abstraction to the driver.
104 @param RemainingDevicePath A pointer to the remaining portion of a device path.
105 This parameter is ignored by device drivers, and is optional for bus drivers.
107 @retval EFI_SUCCESS The device was started.
108 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
109 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
110 @retval other The driver failded to start the device.
114 IScsiDriverBindingStart (
115 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
116 IN EFI_HANDLE ControllerHandle
,
117 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
121 Stop this driver on ControllerHandle.
123 Release the control of this controller and remove the IScsi functions. The Stop()
124 function is designed to be invoked from the EFI boot service DisconnectController().
125 As a result, much of the error checking on the parameters to Stop() has been moved
126 into this common boot service. It is legal to call Stop() from other locations,
127 but the following calling restrictions must be followed or the system behavior will not be deterministic.
128 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
129 same driver's Start() function.
130 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
131 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
132 Start() function, and the Start() function must have called OpenProtocol() on
133 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
135 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
136 @param ControllerHandle A handle to the device being stopped. The handle must
137 support a bus specific I/O protocol for the driver
138 to use to stop the device.
139 @param NumberOfChildren The number of child device handles in ChildHandleBuffer.Not used.
140 @param ChildHandleBuffer An array of child handles to be freed. May be NULL
141 if NumberOfChildren is 0.Not used.
143 @retval EFI_SUCCESS The device was stopped.
144 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
148 IScsiDriverBindingStop (
149 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
150 IN EFI_HANDLE ControllerHandle
,
151 IN UINTN NumberOfChildren
,
152 IN EFI_HANDLE
*ChildHandleBuffer
156 // EFI Component Name Protocol for IScsi driver.
159 Retrieves a Unicode string that is the user readable name of the EFI Driver.
161 This function retrieves the user readable name of a driver in the form of a
162 Unicode string. If the driver specified by This has a user readable name in
163 the language specified by Language, then a pointer to the driver name is
164 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
165 by This does not support the language specified by Language,
166 then EFI_UNSUPPORTED is returned.
168 @param This[in] A pointer to the EFI_COMPONENT_NAME_PROTOCOL
171 @param Language[in] A pointer to a three character ISO 639-2 language
173 This is the language of the driver name that that
174 the caller is requesting, and it must match one of
175 the languages specified in SupportedLanguages.
176 The number of languages supported by a driver is up
177 to the driver writer.
179 @param DriverName[out] A pointer to the Unicode string to return.
180 This Unicode string is the name of the
181 driver specified by This in the language
182 specified by Language.
184 @retval EFI_SUCCESS The Unicode string for the Driver specified by
185 This and the language specified by Language was
186 returned in DriverName.
188 @retval EFI_INVALID_PARAMETER Language is NULL.
190 @retval EFI_INVALID_PARAMETER DriverName is NULL.
192 @retval EFI_UNSUPPORTED The driver specified by This does not support
193 the language specified by Language.
198 IScsiComponentNameGetDriverName (
199 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
201 OUT CHAR16
**DriverName
205 Retrieves a Unicode string that is the user readable name of the controller
206 that is being managed by an EFI Driver.
208 @param This[in] A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
210 @param ControllerHandle[in] The handle of a controller that the driver specified by
211 This is managing. This handle specifies the controller
212 whose name is to be returned.
214 @param ChildHandle[in] The handle of the child controller to retrieve the name
215 of. This is an optional parameter that may be NULL. It
216 will be NULL for device drivers. It will also be NULL
217 for a bus drivers that wish to retrieve the name of the
218 bus controller. It will not be NULL for a bus driver
219 that wishes to retrieve the name of a child controller.
221 @param Language[in] A pointer to a three character ISO 639-2 language
222 identifier. This is the language of the controller name
223 that that the caller is requesting, and it must match one
224 of the languages specified in SupportedLanguages. The
225 number of languages supported by a driver is up to the
228 @param ControllerName[out] A pointer to the Unicode string to return. This Unicode
229 string is the name of the controller specified by
230 ControllerHandle and ChildHandle in the language
231 specified by Language from the point of view of the
232 driver specified by This.
234 @retval EFI_SUCCESS The Unicode string for the user readable name in the
235 language specified by Language for the driver
236 specified by This was returned in DriverName.
238 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
240 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
242 @retval EFI_INVALID_PARAMETER Language is NULL.
244 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
246 @retval EFI_UNSUPPORTED The driver specified by This is not currently managing
247 the controller specified by ControllerHandle and ChildHandle.
249 @retval EFI_UNSUPPORTED The driver specified by This does not support the
250 language specified by Language.
255 IScsiComponentNameGetControllerName (
256 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
257 IN EFI_HANDLE ControllerHandle
,
258 IN EFI_HANDLE ChildHandle OPTIONAL
,
260 OUT CHAR16
**ControllerName
264 // EFI IScsi Initiator Name Protocol for IScsi driver.
267 Retrieves the current set value of iSCSI Initiator Name.
269 @param This[in] Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
271 @param BufferSize[in][out] Size of the buffer in bytes pointed to by Buffer / Actual
272 size of the variable data buffer.
274 @param Buffer[out] Pointer to the buffer for data to be read.
276 @retval EFI_SUCCESS Data was successfully retrieved into the provided
277 buffer and the BufferSize was sufficient to handle the
278 iSCSI initiator name.
279 @retval EFI_BUFFER_TOO_SMALL BufferSize is too small for the result. BufferSize will
280 be updated with the size required to complete the request.
281 Buffer will not be affected.
283 @retval EFI_INVALID_PARAMETER BufferSize is NULL. BufferSize and Buffer will not be
286 @retval EFI_INVALID_PARAMETER Buffer is NULL. BufferSize and Buffer will not be
289 @retval EFI_DEVICE_ERROR The iSCSI initiator name could not be retrieved due to
295 IScsiGetInitiatorName (
296 IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL
*This
,
297 IN OUT UINTN
*BufferSize
,
302 Sets the iSCSI Initiator Name.
304 @param This[in] Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
306 @param BufferSize[in][out] Size of the buffer in bytes pointed to by Buffer.
308 @param Buffer[out] Pointer to the buffer for data to be written.
310 @retval EFI_SUCCESS Data was successfully stored by the protocol.
312 @retval EFI_UNSUPPORTED Platform policies do not allow for data to be written.
314 @retval EFI_INVALID_PARAMETER BufferSize exceeds the maximum allowed limit.
315 BufferSize will be updated with the maximum size
316 required to complete the request.
318 @retval EFI_INVALID_PARAMETER Buffersize is NULL. BufferSize and Buffer will not be
321 @retval EFI_INVALID_PARAMETER Buffer is NULL. BufferSize and Buffer will not be affected.
323 @retval EFI_DEVICE_ERROR The data could not be stored due to a hardware error.
325 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the data.
327 @retval EFI_PROTOCOL_ERROR Input iSCSI initiator name does not adhere to RFC 3720.
332 IScsiSetInitiatorName (
333 IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL
*This
,
334 IN OUT UINTN
*BufferSize
,