2 Header file for SCSI Bus Driver.
4 Copyright (c) 2006 - 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.
19 #include <IndustryStandard/Scsi.h>
23 #define ONE_SECOND_TIMER 10000000
25 #define SCSI_IO_DEV_SIGNATURE EFI_SIGNATURE_32 ('s', 'c', 'i', 'o')
27 typedef struct _SCSI_TARGET_ID
{
45 EFI_SCSI_IO_PROTOCOL ScsiIo
;
46 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
47 BOOLEAN ExtScsiSupport
;
48 EFI_SCSI_PASS_THRU_PROTOCOL
*ScsiPassThru
;
49 EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*ExtScsiPassThru
;
54 BOOLEAN RemovableDevice
;
57 #define SCSI_IO_DEV_FROM_THIS(a) CR (a, SCSI_IO_DEV, ScsiIo, SCSI_IO_DEV_SIGNATURE)
60 // SCSI Bus Controller device strcuture
62 #define EFI_SCSI_BUS_PROTOCOL_GUID \
64 0x5261213D, 0x3A3D, 0x441E, {0xB3, 0xAF, 0x21, 0xD3, 0xF7, 0xA4, 0xCA, 0x17} \
67 typedef struct _EFI_SCSI_BUS_PROTOCOL
{
69 } EFI_SCSI_BUS_PROTOCOL
;
71 #define SCSI_BUS_DEVICE_SIGNATURE EFI_SIGNATURE_32 ('s', 'c', 's', 'i')
74 typedef struct _SCSI_BUS_DEVICE
{
76 EFI_SCSI_BUS_PROTOCOL BusIdentify
;
77 BOOLEAN ExtScsiSupport
;
78 EFI_SCSI_PASS_THRU_PROTOCOL
*ScsiInterface
;
79 EFI_EXT_SCSI_PASS_THRU_PROTOCOL
*ExtScsiInterface
;
80 EFI_DEVICE_PATH_PROTOCOL
*DevicePath
;
83 #define SCSI_BUS_CONTROLLER_DEVICE_FROM_THIS(a) CR (a, SCSI_BUS_DEVICE, BusIdentify, SCSI_BUS_DEVICE_SIGNATURE)
88 extern EFI_DRIVER_BINDING_PROTOCOL gScsiBusDriverBinding
;
89 extern EFI_COMPONENT_NAME_PROTOCOL gScsiBusComponentName
;
90 extern EFI_COMPONENT_NAME2_PROTOCOL gScsiBusComponentName2
;
94 SCSIBusDriverBindingSupported (
95 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
96 IN EFI_HANDLE Controller
,
97 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
102 SCSIBusDriverBindingStart (
103 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
104 IN EFI_HANDLE Controller
,
105 IN EFI_DEVICE_PATH_PROTOCOL
*RemainingDevicePath
110 SCSIBusDriverBindingStop (
111 IN EFI_DRIVER_BINDING_PROTOCOL
*This
,
112 IN EFI_HANDLE Controller
,
113 IN UINTN NumberOfChildren
,
114 IN EFI_HANDLE
*ChildHandleBuffer
118 // EFI Component Name Functions
121 Retrieves a Unicode string that is the user readable name of the driver.
123 This function retrieves the user readable name of a driver in the form of a
124 Unicode string. If the driver specified by This has a user readable name in
125 the language specified by Language, then a pointer to the driver name is
126 returned in DriverName, and EFI_SUCCESS is returned. If the driver specified
127 by This does not support the language specified by Language,
128 then EFI_UNSUPPORTED is returned.
130 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
131 EFI_COMPONENT_NAME_PROTOCOL instance.
133 @param Language[in] A pointer to a Null-terminated ASCII string
134 array indicating the language. This is the
135 language of the driver name that the caller is
136 requesting, and it must match one of the
137 languages specified in SupportedLanguages. The
138 number of languages supported by a driver is up
139 to the driver writer. Language is specified
140 in RFC 3066 or ISO 639-2 language code format.
142 @param DriverName[out] A pointer to the Unicode string to return.
143 This Unicode string is the name of the
144 driver specified by This in the language
145 specified by Language.
147 @retval EFI_SUCCESS The Unicode string for the Driver specified by
148 This and the language specified by Language was
149 returned in DriverName.
151 @retval EFI_INVALID_PARAMETER Language is NULL.
153 @retval EFI_INVALID_PARAMETER DriverName is NULL.
155 @retval EFI_UNSUPPORTED The driver specified by This does not support
156 the language specified by Language.
161 ScsiBusComponentNameGetDriverName (
162 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
164 OUT CHAR16
**DriverName
169 Retrieves a Unicode string that is the user readable name of the controller
170 that is being managed by a driver.
172 This function retrieves the user readable name of the controller specified by
173 ControllerHandle and ChildHandle in the form of a Unicode string. If the
174 driver specified by This has a user readable name in the language specified by
175 Language, then a pointer to the controller name is returned in ControllerName,
176 and EFI_SUCCESS is returned. If the driver specified by This is not currently
177 managing the controller specified by ControllerHandle and ChildHandle,
178 then EFI_UNSUPPORTED is returned. If the driver specified by This does not
179 support the language specified by Language, then EFI_UNSUPPORTED is returned.
181 @param This[in] A pointer to the EFI_COMPONENT_NAME2_PROTOCOL or
182 EFI_COMPONENT_NAME_PROTOCOL instance.
184 @param ControllerHandle[in] The handle of a controller that the driver
185 specified by This is managing. This handle
186 specifies the controller whose name is to be
189 @param ChildHandle[in] The handle of the child controller to retrieve
190 the name of. This is an optional parameter that
191 may be NULL. It will be NULL for device
192 drivers. It will also be NULL for a bus drivers
193 that wish to retrieve the name of the bus
194 controller. It will not be NULL for a bus
195 driver that wishes to retrieve the name of a
198 @param Language[in] A pointer to a Null-terminated ASCII string
199 array indicating the language. This is the
200 language of the driver name that the caller is
201 requesting, and it must match one of the
202 languages specified in SupportedLanguages. The
203 number of languages supported by a driver is up
204 to the driver writer. Language is specified in
205 RFC 3066 or ISO 639-2 language code format.
207 @param ControllerName[out] A pointer to the Unicode string to return.
208 This Unicode string is the name of the
209 controller specified by ControllerHandle and
210 ChildHandle in the language specified by
211 Language from the point of view of the driver
214 @retval EFI_SUCCESS The Unicode string for the user readable name in
215 the language specified by Language for the
216 driver specified by This was returned in
219 @retval EFI_INVALID_PARAMETER ControllerHandle is not a valid EFI_HANDLE.
221 @retval EFI_INVALID_PARAMETER ChildHandle is not NULL and it is not a valid
224 @retval EFI_INVALID_PARAMETER Language is NULL.
226 @retval EFI_INVALID_PARAMETER ControllerName is NULL.
228 @retval EFI_UNSUPPORTED The driver specified by This is not currently
229 managing the controller specified by
230 ControllerHandle and ChildHandle.
232 @retval EFI_UNSUPPORTED The driver specified by This does not support
233 the language specified by Language.
238 ScsiBusComponentNameGetControllerName (
239 IN EFI_COMPONENT_NAME_PROTOCOL
*This
,
240 IN EFI_HANDLE ControllerHandle
,
241 IN EFI_HANDLE ChildHandle OPTIONAL
,
243 OUT CHAR16
**ControllerName
250 IN EFI_SCSI_IO_PROTOCOL
*This
,
251 OUT UINT8
*DeviceType
257 Retrieves the device type information of the SCSI Controller.
261 This - Protocol instance pointer.
262 DeviceType - A pointer to the device type information
263 retrieved from the SCSI Controller.
267 EFI_SUCCESS - Retrieves the device type information successfully.
268 EFI_INVALID_PARAMETER - The DeviceType is NULL.
276 IN EFI_SCSI_IO_PROTOCOL
*This
282 Resets the SCSI Bus that the SCSI Controller is attached to.
286 This - Protocol instance pointer.
290 EFI_SUCCESS - The SCSI bus is reset successfully.
291 EFI_DEVICE_ERROR - Errors encountered when resetting the SCSI bus.
292 EFI_UNSUPPORTED - The bus reset operation is not supported by the
293 SCSI Host Controller.
294 EFI_TIMEOUT - A timeout occurred while attempting to reset
303 IN EFI_SCSI_IO_PROTOCOL
*This
309 Resets the SCSI Controller that the device handle specifies.
313 This - Protocol instance pointer.
317 EFI_SUCCESS - Reset the SCSI controller successfully.
318 EFI_DEVICE_ERROR - Errors are encountered when resetting the
320 EFI_UNSUPPORTED - The SCSI bus does not support a device
322 EFI_TIMEOUT - A timeout occurred while attempting to
323 reset the SCSI Controller.
330 ScsiExecuteSCSICommand (
331 IN EFI_SCSI_IO_PROTOCOL
*This
,
332 IN OUT EFI_SCSI_IO_SCSI_REQUEST_PACKET
*CommandPacket
,
339 Sends a SCSI Request Packet to the SCSI Controller for execution.
343 This - Protocol instance pointer.
344 Packet - The SCSI request packet to send to the SCSI
345 Controller specified by the device handle.
346 Event - If the SCSI bus where the SCSI device is attached
347 does not support non-blocking I/O, then Event is
348 ignored, and blocking I/O is performed.
349 If Event is NULL, then blocking I/O is performed.
350 If Event is not NULL and non-blocking I/O is
351 supported, then non-blocking I/O is performed,
352 and Event will be signaled when the SCSI Request
356 EFI_SUCCESS - The SCSI Request Packet was sent by the host
357 successfully, and TransferLength bytes were
358 transferred to/from DataBuffer.See
359 HostAdapterStatus, TargetStatus,
360 SenseDataLength, and SenseData in that order
361 for additional status information.
362 EFI_BAD_BUFFER_SIZE - The SCSI Request Packet was executed,
363 but the entire DataBuffer could not be transferred.
364 The actual number of bytes transferred is returned
365 in TransferLength. See HostAdapterStatus,
366 TargetStatus, SenseDataLength, and SenseData in
367 that order for additional status information.
368 EFI_NOT_READY - The SCSI Request Packet could not be sent because
369 there are too many SCSI Command Packets already
370 queued.The caller may retry again later.
371 EFI_DEVICE_ERROR - A device error occurred while attempting to send
372 the SCSI Request Packet. See HostAdapterStatus,
373 TargetStatus, SenseDataLength, and SenseData in
374 that order for additional status information.
375 EFI_INVALID_PARAMETER - The contents of CommandPacket are invalid.
376 The SCSI Request Packet was not sent, so no
377 additional status information is available.
378 EFI_UNSUPPORTED - The command described by the SCSI Request Packet
379 is not supported by the SCSI initiator(i.e., SCSI
380 Host Controller). The SCSI Request Packet was not
381 sent, so no additional status information is
383 EFI_TIMEOUT - A timeout occurred while waiting for the SCSI
384 Request Packet to execute. See HostAdapterStatus,
385 TargetStatus, SenseDataLength, and SenseData in
386 that order for additional status information.
392 ScsiScanCreateDevice (
393 EFI_DRIVER_BINDING_PROTOCOL
*This
,
394 EFI_HANDLE Controller
,
395 SCSI_TARGET_ID
*TargetId
,
397 SCSI_BUS_DEVICE
*ScsiBusDev
403 Scan SCSI Bus to discover the device, and attach ScsiIoProtocol to it.
407 This - Protocol instance pointer
408 Controller - Controller handle
409 Pun - The Pun of the SCSI device on the SCSI channel.
410 Lun - The Lun of the SCSI device on the SCSI channel.
411 ScsiBusDev - The pointer of SCSI_BUS_DEVICE
415 EFI_SUCCESS - Successfully to discover the device and attach ScsiIoProtocol to it.
416 EFI_OUT_OF_RESOURCES - Fail to discover the device.
423 SCSI_IO_DEV
*ScsiIoDevice
429 Discovery SCSI Device
433 ScsiIoDevice - The pointer of SCSI_IO_DEV
437 TRUE - Find SCSI Device and verify it.
438 FALSE - Unable to find SCSI Device.