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/ComponentName.h>
31 #include <Protocol/ComponentName2.h>
34 #define ISCSI_PRIVATE_GUID \
35 { 0xfa3cde4c, 0x87c2, 0x427d, {0xae, 0xde, 0x7d, 0xd0, 0x96, 0xc8, 0x8c, 0x58} }
37 #define ISCSI_INITIATOR_NAME_VAR_NAME L"I_NAME"
39 extern EFI_COMPONENT_NAME2_PROTOCOL gIScsiComponentName2
;
40 extern EFI_COMPONENT_NAME_PROTOCOL gIScsiComponentName
;
42 extern EFI_ISCSI_INITIATOR_NAME_PROTOCOL gIScsiInitiatorName
;
45 extern EFI_GUID mIScsiPrivateGuid
;
47 typedef struct _ISCSI_PRIVATE_PROTOCOL
{
49 } ISCSI_PRIVATE_PROTOCOL
;
52 // EFI Driver Binding Protocol for iSCSI driver.
56 Tests to see if this driver supports a given controller. If a child device is provided,
57 it further tests to see if this driver supports creating a handle for the specified child device.
59 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
60 @param ControllerHandle The handle of the controller to test. This handle
61 must support a protocol interface that supplies
62 an I/O abstraction to the driver.
63 @param RemainingDevicePath A pointer to the remaining portion of a device path.
64 This parameter is ignored by device drivers, and is optional for bus drivers.
67 @retval EFI_SUCCESS The device specified by ControllerHandle and
68 RemainingDevicePath is supported by the driver specified by This.
69 @retval EFI_ALREADY_STARTED The device specified by ControllerHandle and
70 RemainingDevicePath is already being managed by the driver
72 @retval EFI_ACCESS_DENIED The device specified by ControllerHandle and
73 RemainingDevicePath is already being managed by a different
74 driver or an application that requires exclusive acces.
75 Currently not implemented.
76 @retval EFI_UNSUPPORTED The device specified by ControllerHandle and
77 RemainingDevicePath is not supported by the driver specified by This.
81 IScsiDriverBindingSupported (
82 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
83 IN EFI_HANDLE ControllerHandle
,
84 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
88 Start this driver on ControllerHandle. The Start() function is designed to be
89 invoked from the EFI boot service ConnectController(). As a result, much of
90 the error checking on the parameters to Start() has been moved into this
91 common boot service. It is legal to call Start() from other locations,
92 but the following calling restrictions must be followed or the system behavior will not be deterministic.
93 1. ControllerHandle must be a valid EFI_HANDLE.
94 2. If RemainingDevicePath is not NULL, then it must be a pointer to a naturally aligned
95 EFI_DEVICE_PATH_PROTOCOL.
96 3. Prior to calling Start(), the Supported() function for the driver specified by This must
97 have been called with the same calling parameters, and Supported() must have returned EFI_SUCCESS.
99 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
100 @param ControllerHandle The handle of the controller to start. This handle
101 must support a protocol interface that supplies
102 an I/O abstraction to the driver.
103 @param RemainingDevicePath A pointer to the remaining portion of a device path.
104 This parameter is ignored by device drivers, and is optional for bus drivers.
106 @retval EFI_SUCCESS The device was started.
107 @retval EFI_DEVICE_ERROR The device could not be started due to a device error.Currently not implemented.
108 @retval EFI_OUT_OF_RESOURCES The request could not be completed due to a lack of resources.
109 @retval other The driver failded to start the device.
113 IScsiDriverBindingStart (
114 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
115 IN EFI_HANDLE ControllerHandle
,
116 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath OPTIONAL
120 Stop this driver on ControllerHandle.
122 Release the control of this controller and remove the IScsi functions. The Stop()
123 function is designed to be invoked from the EFI boot service DisconnectController().
124 As a result, much of the error checking on the parameters to Stop() has been moved
125 into this common boot service. It is legal to call Stop() from other locations,
126 but the following calling restrictions must be followed or the system behavior will not be deterministic.
127 1. ControllerHandle must be a valid EFI_HANDLE that was used on a previous call to this
128 same driver's Start() function.
129 2. The first NumberOfChildren handles of ChildHandleBuffer must all be a valid
130 EFI_HANDLE. In addition, all of these handles must have been created in this driver's
131 Start() function, and the Start() function must have called OpenProtocol() on
132 ControllerHandle with an Attribute of EFI_OPEN_PROTOCOL_BY_CHILD_CONTROLLER.
134 @param This A pointer to the EFI_DRIVER_BINDING_PROTOCOL instance.
135 @param ControllerHandle A handle to the device being stopped. The handle must
136 support a bus specific I/O protocol for the driver
137 to use to stop the device.
138 @param NumberOfChildren The number of child device handles in ChildHandleBuffer.Not used.
139 @param ChildHandleBuffer An array of child handles to be freed. May be NULL
140 if NumberOfChildren is 0.Not used.
142 @retval EFI_SUCCESS The device was stopped.
143 @retval EFI_DEVICE_ERROR The device could not be stopped due to a device error.
147 IScsiDriverBindingStop (
148 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
149 IN EFI_HANDLE ControllerHandle
,
150 IN UINTN NumberOfChildren
,
151 IN EFI_HANDLE
*ChildHandleBuffer
155 // EFI Component Name Protocol for IScsi driver.
158 Retrieves a Unicode string that is the user readable name of the EFI Driver.
160 This function retrieves the user readable name of a driver in the form of a
161 Unicode string. If the driver specified by This has a user readable name in
162 the language specified by Language, then a pointer to the driver name is
163 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
164 by This does not support the language specified by Language,
165 then EFI_UNSUPPORTED is returned.
167 @param This[in] A pointer to the EFI_COMPONENT_NAME_PROTOCOL
170 @param Language[in] A pointer to a three character ISO 639-2 language
172 This is the language of the driver name that that
173 the caller is requesting, and it must match one of
174 the languages specified in SupportedLanguages.
175 The number of languages supported by a driver is up
176 to the driver writer.
178 @param DriverName[out] A pointer to the Unicode string to return.
179 This Unicode string is the name of the
180 driver specified by This in the language
181 specified by Language.
183 @retval EFI_SUCCESS The Unicode string for the Driver specified by
184 This and the language specified by Language was
185 returned in DriverName.
187 @retval EFI_INVALID_PARAMETER Language is NULL.
189 @retval EFI_INVALID_PARAMETER DriverName is NULL.
191 @retval EFI_UNSUPPORTED The driver specified by This does not support
192 the language specified by Language.
197 IScsiComponentNameGetDriverName (
198 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
200 OUT CHAR16
**DriverName
204 Retrieves a Unicode string that is the user readable name of the controller
205 that is being managed by an EFI Driver.
207 @param This[in] A pointer to the EFI_COMPONENT_NAME_PROTOCOL instance.
209 @param ControllerHandle[in] The handle of a controller that the driver specified by
210 This is managing. This handle specifies the controller
211 whose name is to be returned.
213 @param ChildHandle[in] The handle of the child controller to retrieve the name
214 of. This is an optional parameter that may be NULL. It
215 will be NULL for device drivers. It will also be NULL
216 for a bus drivers that wish to retrieve the name of the
217 bus controller. It will not be NULL for a bus driver
218 that wishes to retrieve the name of a child controller.
220 @param Language[in] A pointer to a three character ISO 639-2 language
221 identifier. This is the language of the controller name
222 that that the caller is requesting, and it must match one
223 of the languages specified in SupportedLanguages. The
224 number of languages supported by a driver is up to the
227 @param ControllerName[out] A pointer to the Unicode string to return. This Unicode
228 string is the name of the controller specified by
229 ControllerHandle and ChildHandle in the language
230 specified by Language from the point of view of the
231 driver specified by This.
233 @retval EFI_SUCCESS The Unicode string for the user readable name in the
234 language specified by Language for the driver
235 specified by This was returned in DriverName.
237 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
239 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid EFI_HANDLE.
241 @retval EFI_INVALID_PARAMETER Language is NULL.
243 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
245 @retval EFI_UNSUPPORTED The driver specified by This is not currently managing
246 the controller specified by ControllerHandle and ChildHandle.
248 @retval EFI_UNSUPPORTED The driver specified by This does not support the
249 language specified by Language.
254 IScsiComponentNameGetControllerName (
255 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
256 IN EFI_HANDLE ControllerHandle
,
257 IN EFI_HANDLE ChildHandle OPTIONAL
,
259 OUT CHAR16
**ControllerName
263 // EFI IScsi Initiator Name Protocol for IScsi driver.
266 Retrieves the current set value of iSCSI Initiator Name.
268 @param This[in] Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
270 @param BufferSize[in][out] Size of the buffer in bytes pointed to by Buffer / Actual
271 size of the variable data buffer.
273 @param Buffer[out] Pointer to the buffer for data to be read.
275 @retval EFI_SUCCESS Data was successfully retrieved into the provided
276 buffer and the BufferSize was sufficient to handle the
277 iSCSI initiator name.
278 @retval EFI_BUFFER_TOO_SMALL BufferSize is too small for the result. BufferSize will
279 be updated with the size required to complete the request.
280 Buffer will not be affected.
282 @retval EFI_INVALID_PARAMETER BufferSize is NULL. BufferSize and Buffer will not be
285 @retval EFI_INVALID_PARAMETER Buffer is NULL. BufferSize and Buffer will not be
288 @retval EFI_DEVICE_ERROR The iSCSI initiator name could not be retrieved due to
294 IScsiGetInitiatorName (
295 IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL
*This
,
296 IN OUT UINTN
*BufferSize
,
301 Sets the iSCSI Initiator Name.
303 @param This[in] Pointer to the EFI_ISCSI_INITIATOR_NAME_PROTOCOL instance.
305 @param BufferSize[in][out] Size of the buffer in bytes pointed to by Buffer.
307 @param Buffer[out] Pointer to the buffer for data to be written.
309 @retval EFI_SUCCESS Data was successfully stored by the protocol.
311 @retval EFI_UNSUPPORTED Platform policies do not allow for data to be written.
313 @retval EFI_INVALID_PARAMETER BufferSize exceeds the maximum allowed limit.
314 BufferSize will be updated with the maximum size
315 required to complete the request.
317 @retval EFI_INVALID_PARAMETER Buffersize is NULL. BufferSize and Buffer will not be
320 @retval EFI_INVALID_PARAMETER Buffer is NULL. BufferSize and Buffer will not be affected.
322 @retval EFI_DEVICE_ERROR The data could not be stored due to a hardware error.
324 @retval EFI_OUT_OF_RESOURCES Not enough storage is available to hold the data.
326 @retval EFI_PROTOCOL_ERROR Input iSCSI initiator name does not adhere to RFC 3720.
331 IScsiSetInitiatorName (
332 IN EFI_ISCSI_INITIATOR_NAME_PROTOCOL
*This
,
333 IN OUT UINTN
*BufferSize
,