3 Copyright (c) 2006, Intel Corporation
4 All rights reserved. This program and the accompanying materials
5 are licensed and made available under the terms and conditions of the BSD License
6 which accompanies this distribution. The full text of the license may be found at
7 http://opensource.org/licenses/bsd-license.php
9 THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
10 WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED.
18 Header file for SCSI Bus Driver.
27 #include <IndustryStandard/scsi.h>
31 #define ONE_SECOND_TIMER 10000000
33 #define SCSI_IO_DEV_SIGNATURE EFI_SIGNATURE_32 ('s', 'c', 'i', 'o')
35 typedef struct _SCSI_TARGET_ID
{
53 EFI_SCSI_IO_PROTOCOL ScsiIo
;
54 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
55 BOOLEAN ExtScsiSupport
;
56 EFI_SCSI_PASS_THRU_PROTOCOL
*ScsiPassThru
;
57 EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*ExtScsiPassThru
;
62 BOOLEAN RemovableDevice
;
65 #define SCSI_IO_DEV_FROM_THIS(a) CR (a, SCSI_IO_DEV, ScsiIo, SCSI_IO_DEV_SIGNATURE)
68 // SCSI Bus Controller device strcuture
70 #define EFI_SCSI_BUS_PROTOCOL_GUID \
72 0x5261213D, 0x3A3D, 0x441E, {0xB3, 0xAF, 0x21, 0xD3, 0xF7, 0xA4, 0xCA, 0x17} \
75 typedef struct _EFI_SCSI_BUS_PROTOCOL
{
77 } EFI_SCSI_BUS_PROTOCOL
;
79 #define SCSI_BUS_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('s', 'c', 's', 'i')
82 typedef struct _SCSI_BUS_DEVICE
{
84 EFI_SCSI_BUS_PROTOCOL BusIdentify
;
85 BOOLEAN ExtScsiSupport
;
86 EFI_SCSI_PASS_THRU_PROTOCOL
*ScsiInterface
;
87 EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*ExtScsiInterface
;
88 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
91 #define SCSI_BUS_CONTROLLER_DEVICE_FROM_THIS(a) CR (a, SCSI_BUS_DEVICE, BusIdentify, SCSI_BUS_DEVICE_SIGNATURE)
96 extern EFI_DRIVER_BINDING_PROTOCOL gScsiBusDriverBinding
;
97 extern EFI_COMPONENT_NAME_PROTOCOL gScsiBusComponentName
;
98 extern EFI_COMPONENT_NAME2_PROTOCOL gScsiBusComponentName2
;
102 SCSIBusDriverBindingSupported (
103 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
104 IN EFI_HANDLE Controller
,
105 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
110 SCSIBusDriverBindingStart (
111 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
112 IN EFI_HANDLE Controller
,
113 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
118 SCSIBusDriverBindingStop (
119 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
120 IN EFI_HANDLE Controller
,
121 IN UINTN NumberOfChildren
,
122 IN EFI_HANDLE
*ChildHandleBuffer
126 // EFI Component Name Functions
129 Retrieves a Unicode string that is the user readable name of the driver.
131 This function retrieves the user readable name of a driver in the form of a
132 Unicode string. If the driver specified by This has a user readable name in
133 the language specified by Language, then a pointer to the driver name is
134 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
135 by This does not support the language specified by Language,
136 then EFI_UNSUPPORTED is returned.
138 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
139 EFI_COMPONENT_NAME_PROTOCOL instance.
141 @param Language[in] A pointer to a Null-terminated ASCII string
142 array indicating the language. This is the
143 language of the driver name that the caller is
144 requesting, and it must match one of the
145 languages specified in SupportedLanguages. The
146 number of languages supported by a driver is up
147 to the driver writer. Language is specified
148 in RFC 3066 or ISO 639-2 language code format.
150 @param DriverName[out] A pointer to the Unicode string to return.
151 This Unicode string is the name of the
152 driver specified by This in the language
153 specified by Language.
155 @retval EFI_SUCCESS The Unicode string for the Driver specified by
156 This and the language specified by Language was
157 returned in DriverName.
159 @retval EFI_INVALID_PARAMETER Language is NULL.
161 @retval EFI_INVALID_PARAMETER DriverName is NULL.
163 @retval EFI_UNSUPPORTED The driver specified by This does not support
164 the language specified by Language.
169 ScsiBusComponentNameGetDriverName (
170 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
172 OUT CHAR16
**DriverName
177 Retrieves a Unicode string that is the user readable name of the controller
178 that is being managed by a driver.
180 This function retrieves the user readable name of the controller specified by
181 ControllerHandle and ChildHandle in the form of a Unicode string. If the
182 driver specified by This has a user readable name in the language specified by
183 Language, then a pointer to the controller name is returned in ControllerName,
184 and EFI_SUCCESS is returned. If the driver specified by This is not currently
185 managing the controller specified by ControllerHandle and ChildHandle,
186 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
187 support the language specified by Language, then EFI_UNSUPPORTED is returned.
189 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
190 EFI_COMPONENT_NAME_PROTOCOL instance.
192 @param ControllerHandle[in] The handle of a controller that the driver
193 specified by This is managing. This handle
194 specifies the controller whose name is to be
197 @param ChildHandle[in] The handle of the child controller to retrieve
198 the name of. This is an optional parameter that
199 may be NULL. It will be NULL for device
200 drivers. It will also be NULL for a bus drivers
201 that wish to retrieve the name of the bus
202 controller. It will not be NULL for a bus
203 driver that wishes to retrieve the name of a
206 @param Language[in] A pointer to a Null-terminated ASCII string
207 array indicating the language. This is the
208 language of the driver name that the caller is
209 requesting, and it must match one of the
210 languages specified in SupportedLanguages. The
211 number of languages supported by a driver is up
212 to the driver writer. Language is specified in
213 RFC 3066 or ISO 639-2 language code format.
215 @param ControllerName[out] A pointer to the Unicode string to return.
216 This Unicode string is the name of the
217 controller specified by ControllerHandle and
218 ChildHandle in the language specified by
219 Language from the point of view of the driver
222 @retval EFI_SUCCESS The Unicode string for the user readable name in
223 the language specified by Language for the
224 driver specified by This was returned in
227 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
229 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
232 @retval EFI_INVALID_PARAMETER Language is NULL.
234 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
236 @retval EFI_UNSUPPORTED The driver specified by This is not currently
237 managing the controller specified by
238 ControllerHandle and ChildHandle.
240 @retval EFI_UNSUPPORTED The driver specified by This does not support
241 the language specified by Language.
246 ScsiBusComponentNameGetControllerName (
247 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
248 IN EFI_HANDLE ControllerHandle
,
249 IN EFI_HANDLE ChildHandle OPTIONAL
,
251 OUT CHAR16
**ControllerName
258 IN EFI_SCSI_IO_PROTOCOL
*This
,
259 OUT UINT8
*DeviceType
265 Retrieves the device type information of the SCSI Controller.
269 This - Protocol instance pointer.
270 DeviceType - A pointer to the device type information
271 retrieved from the SCSI Controller.
275 EFI_SUCCESS - Retrieves the device type information successfully.
276 EFI_INVALID_PARAMETER - The DeviceType is NULL.
284 IN EFI_SCSI_IO_PROTOCOL
*This
290 Resets the SCSI Bus that the SCSI Controller is attached to.
294 This - Protocol instance pointer.
298 EFI_SUCCESS - The SCSI bus is reset successfully.
299 EFI_DEVICE_ERROR - Errors encountered when resetting the SCSI bus.
300 EFI_UNSUPPORTED - The bus reset operation is not supported by the
301 SCSI Host Controller.
302 EFI_TIMEOUT - A timeout occurred while attempting to reset
311 IN EFI_SCSI_IO_PROTOCOL
*This
317 Resets the SCSI Controller that the device handle specifies.
321 This - Protocol instance pointer.
325 EFI_SUCCESS - Reset the SCSI controller successfully.
326 EFI_DEVICE_ERROR - Errors are encountered when resetting the
328 EFI_UNSUPPORTED - The SCSI bus does not support a device
330 EFI_TIMEOUT - A timeout occurred while attempting to
331 reset the SCSI Controller.
338 ScsiExecuteSCSICommand (
339 IN EFI_SCSI_IO_PROTOCOL
*This
,
340 IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET
*CommandPacket
,
347 Sends a SCSI Request Packet to the SCSI Controller for execution.
351 This - Protocol instance pointer.
352 Packet - The SCSI request packet to send to the SCSI
353 Controller specified by the device handle.
354 Event - If the SCSI bus where the SCSI device is attached
355 does not support non-blocking I/O, then Event is
356 ignored, and blocking I/O is performed.
357 If Event is NULL, then blocking I/O is performed.
358 If Event is not NULL and non-blocking I/O is
359 supported, then non-blocking I/O is performed,
360 and Event will be signaled when the SCSI Request
364 EFI_SUCCESS - The SCSI Request Packet was sent by the host
365 successfully, and TransferLength bytes were
366 transferred to/from DataBuffer.See
367 HostAdapterStatus, TargetStatus,
368 SenseDataLength, and SenseData in that order
369 for additional status information.
370 EFI_BAD_BUFFER_SIZE - The SCSI Request Packet was executed,
371 but the entire DataBuffer could not be transferred.
372 The actual number of bytes transferred is returned
373 in TransferLength. See HostAdapterStatus,
374 TargetStatus, SenseDataLength, and SenseData in
375 that order for additional status information.
376 EFI_NOT_READY - The SCSI Request Packet could not be sent because
377 there are too many SCSI Command Packets already
378 queued.The caller may retry again later.
379 EFI_DEVICE_ERROR - A device error occurred while attempting to send
380 the SCSI Request Packet. See HostAdapterStatus,
381 TargetStatus, SenseDataLength, and SenseData in
382 that order for additional status information.
383 EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid.
384 The SCSI Request Packet was not sent, so no
385 additional status information is available.
386 EFI_UNSUPPORTED - The command described by the SCSI Request Packet
387 is not supported by the SCSI initiator(i.e., SCSI
388 Host Controller). The SCSI Request Packet was not
389 sent, so no additional status information is
391 EFI_TIMEOUT - A timeout occurred while waiting for the SCSI
392 Request Packet to execute. See HostAdapterStatus,
393 TargetStatus, SenseDataLength, and SenseData in
394 that order for additional status information.
400 ScsiScanCreateDevice (
401 EFI_DRIVER_BINDING_PROTOCOL
*This
,
402 EFI_HANDLE Controller
,
403 SCSI_TARGET_ID
*TargetId
,
405 SCSI_BUS_DEVICE
*ScsiBusDev
411 Scan SCSI Bus to discover the device, and attach ScsiIoProtocol to it.
415 This - Protocol instance pointer
416 Controller - Controller handle
417 Pun - The Pun of the SCSI device on the SCSI channel.
418 Lun - The Lun of the SCSI device on the SCSI channel.
419 ScsiBusDev - The pointer of SCSI_BUS_DEVICE
423 EFI_SUCCESS - Successfully to discover the device and attach ScsiIoProtocol to it.
424 EFI_OUT_OF_RESOURCES - Fail to discover the device.
431 SCSI_IO_DEV
*ScsiIoDevice
437 Discovery SCSI Device
441 ScsiIoDevice - The pointer of SCSI_IO_DEV
445 TRUE - Find SCSI Device and verify it.
446 FALSE - Unable to find SCSI Device.