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
;
101 SCSIBusDriverBindingSupported (
102 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
103 IN EFI_HANDLE Controller
,
104 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
109 SCSIBusDriverBindingStart (
110 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
111 IN EFI_HANDLE Controller
,
112 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
117 SCSIBusDriverBindingStop (
118 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
119 IN EFI_HANDLE Controller
,
120 IN UINTN NumberOfChildren
,
121 IN EFI_HANDLE
*ChildHandleBuffer
125 // EFI Component Name Functions
129 ScsiBusComponentNameGetDriverName (
130 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
132 OUT CHAR16
**DriverName
137 ScsiBusComponentNameGetControllerName (
138 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
139 IN EFI_HANDLE ControllerHandle
,
140 IN EFI_HANDLE ChildHandle OPTIONAL
,
142 OUT CHAR16
**ControllerName
148 IN EFI_SCSI_IO_PROTOCOL
*This
,
149 OUT UINT8
*DeviceType
155 Retrieves the device type information of the SCSI Controller.
159 This - Protocol instance pointer.
160 DeviceType - A pointer to the device type information
161 retrieved from the SCSI Controller.
165 EFI_SUCCESS - Retrieves the device type information successfully.
166 EFI_INVALID_PARAMETER - The DeviceType is NULL.
174 IN EFI_SCSI_IO_PROTOCOL
*This
180 Resets the SCSI Bus that the SCSI Controller is attached to.
184 This - Protocol instance pointer.
188 EFI_SUCCESS - The SCSI bus is reset successfully.
189 EFI_DEVICE_ERROR - Errors encountered when resetting the SCSI bus.
190 EFI_UNSUPPORTED - The bus reset operation is not supported by the
191 SCSI Host Controller.
192 EFI_TIMEOUT - A timeout occurred while attempting to reset
201 IN EFI_SCSI_IO_PROTOCOL
*This
207 Resets the SCSI Controller that the device handle specifies.
211 This - Protocol instance pointer.
215 EFI_SUCCESS - Reset the SCSI controller successfully.
216 EFI_DEVICE_ERROR - Errors are encountered when resetting the
218 EFI_UNSUPPORTED - The SCSI bus does not support a device
220 EFI_TIMEOUT - A timeout occurred while attempting to
221 reset the SCSI Controller.
228 ScsiExecuteSCSICommand (
229 IN EFI_SCSI_IO_PROTOCOL
*This
,
230 IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET
*CommandPacket
,
237 Sends a SCSI Request Packet to the SCSI Controller for execution.
241 This - Protocol instance pointer.
242 Packet - The SCSI request packet to send to the SCSI
243 Controller specified by the device handle.
244 Event - If the SCSI bus where the SCSI device is attached
245 does not support non-blocking I/O, then Event is
246 ignored, and blocking I/O is performed.
247 If Event is NULL, then blocking I/O is performed.
248 If Event is not NULL and non-blocking I/O is
249 supported, then non-blocking I/O is performed,
250 and Event will be signaled when the SCSI Request
254 EFI_SUCCESS - The SCSI Request Packet was sent by the host
255 successfully, and TransferLength bytes were
256 transferred to/from DataBuffer.See
257 HostAdapterStatus, TargetStatus,
258 SenseDataLength, and SenseData in that order
259 for additional status information.
260 EFI_BAD_BUFFER_SIZE - The SCSI Request Packet was executed,
261 but the entire DataBuffer could not be transferred.
262 The actual number of bytes transferred is returned
263 in TransferLength. See HostAdapterStatus,
264 TargetStatus, SenseDataLength, and SenseData in
265 that order for additional status information.
266 EFI_NOT_READY - The SCSI Request Packet could not be sent because
267 there are too many SCSI Command Packets already
268 queued.The caller may retry again later.
269 EFI_DEVICE_ERROR - A device error occurred while attempting to send
270 the SCSI Request Packet. See HostAdapterStatus,
271 TargetStatus, SenseDataLength, and SenseData in
272 that order for additional status information.
273 EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid.
274 The SCSI Request Packet was not sent, so no
275 additional status information is available.
276 EFI_UNSUPPORTED - The command described by the SCSI Request Packet
277 is not supported by the SCSI initiator(i.e., SCSI
278 Host Controller). The SCSI Request Packet was not
279 sent, so no additional status information is
281 EFI_TIMEOUT - A timeout occurred while waiting for the SCSI
282 Request Packet to execute. See HostAdapterStatus,
283 TargetStatus, SenseDataLength, and SenseData in
284 that order for additional status information.
290 ScsiScanCreateDevice (
291 EFI_DRIVER_BINDING_PROTOCOL
*This
,
292 EFI_HANDLE Controller
,
293 SCSI_TARGET_ID
*TargetId
,
295 SCSI_BUS_DEVICE
*ScsiBusDev
301 Scan SCSI Bus to discover the device, and attach ScsiIoProtocol to it.
305 This - Protocol instance pointer
306 Controller - Controller handle
307 Pun - The Pun of the SCSI device on the SCSI channel.
308 Lun - The Lun of the SCSI device on the SCSI channel.
309 ScsiBusDev - The pointer of SCSI_BUS_DEVICE
313 EFI_SUCCESS - Successfully to discover the device and attach ScsiIoProtocol to it.
314 EFI_OUT_OF_RESOURCES - Fail to discover the device.
321 SCSI_IO_DEV
*ScsiIoDevice
327 Discovery SCSI Device
331 ScsiIoDevice - The pointer of SCSI_IO_DEV
335 TRUE - Find SCSI Device and verify it.
336 FALSE - Unable to find SCSI Device.