]>
git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/scsi/IOSCSIDevice_Reference.h
e1436ea0d54896462368cbc20f897cec6628702a
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
4 * @APPLE_LICENSE_HEADER_START@
6 * The contents of this file constitute Original Code as defined in and
7 * are subject to the Apple Public Source License Version 1.1 (the
8 * "License"). You may not use this file except in compliance with the
9 * License. Please obtain a copy of the License at
10 * http://www.apple.com/publicsource and read it before using this file.
12 * This Original Code and all software distributed under the License are
13 * distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY KIND, EITHER
14 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
15 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT. Please see the
17 * License for the specific language governing rights and limitations
20 * @APPLE_LICENSE_HEADER_END@
25 @header IOSCSIDevice_Reference.h
27 This header defines the IOSCSIDevice class.
29 The SCSI framework creates instances of this class to
30 represent each valid SCSI device (target/lun) detected during
31 SCSI bus scanning. When an instance of this class is registered with
32 IOKit, the instance will be presented to clients which
33 'match' the IOSCSIDevice class.
37 @typedef SCSITargetParms
38 Parameter structure for get/setTargetParms
39 @field transferPeriodpS
40 Minimum SCSI synchronous transfer period allowed
41 for this target in picoseconds (10E-12). For asynchronous data transfer,
44 Maximum SCSI synchronous transfer offset allowed for this target in
45 bytes. For asynchronous data transfer, set this field to 0.
47 Maximum SCSI bus width in bytes. Note: must be a
49 @field enableTagQueuing
50 Setting enableTagQueuing to true enables tag queuing for SCSI Commands
53 Set to (true) to disable parity checking on the
54 SCSI bus for this target.
56 typedef struct SCSITargetParms
{
57 UInt32 transferPeriodpS
;
58 UInt32 transferOffset
;
61 bool enableTagQueuing
;
71 Parameter structure for get/setLunParms
72 @field disableDisconnect
73 Setting disableDisconnect to true disables SCSI disconnect for SCSI
74 Commands issued to the target/lun pair.
76 typedef struct SCSILunParms
{
77 bool disableDisconnect
;
85 @enum SCSIClientMessage
87 IOSCSIDevice notifies its client of significant 'events' by the IOService::message()
88 api. When possible the client is notified of the event prior to any action taken. The
89 client is responsible for managing the device queue for the IOSCSIDevice
90 via the holdQueue(), releaseQueue(), flushQueue() and notifyIdle() api's. The client is also
91 notified at the end of an 'event' by the corresponding message id with or'd with
93 @constant kClientMsgDeviceAbort
94 A client initiated device abort is beginning.
95 @constant kClientMsgDeviceReset
96 A client initiated device reset is beginning.
97 @constant kClientMsgBusReset
98 An unsolicited bus reset has occurred.
99 @constant kClientMsgDone
100 This constant is or'd with one of the above message ids to indicate the
101 client should complete processing of the corresponding event.
103 enum SCSIClientMessage
{
104 kClientMsgDeviceAbort
= 0x00005000,
105 kClientMsgDeviceReset
,
108 kClientMsgDone
= 0x80000000,
113 @class IOSCSIDevice : public IOCDBDevice
115 Class that describes a SCSI device (target/lun pair).
117 The IOSCSIDevice class provides basic services
118 to initialize and supervise a SCSI device. Once the device is
119 initialized, the client will normally use the allocCommand() member
120 function to create IOSCSICommand(s) to send SCSI CDBs to the target/lun.
122 class IOSCSIDevice
: public IOCDBDevice
127 @function allocCommand
129 Allocates a IOSCSICommand object for this device.
131 The client uses the allocCommand() member function to allocate IOSCSICommand(s)
132 for a IOSCSIDevice. The client then uses the member functions of
133 the IOSCSICommand to initialize it and send it to the device. A completed IOSCSICommand
134 may be reused for subsequent I/O requests or returned to the SCSI Family.
136 Always specify kIOSCSIDevice.
137 @param clientDataSize
138 The client may indicate the size of a per-command data area for its own
141 Note: The amount of per-command storage allowed is under review. We
142 anticipate that typical SCSI clients will need not more than 1024 bytes
145 IOSCSICommand
*allocCommand( IOSCSIDevice
*scsiDevice
, UInt32 clientDataSize
= 0 );
149 @function setTargetParms
151 Sets SCSI parameters that apply to all luns on a SCSI target device.
153 This function will block until we attempt to set the
154 requested parameters. It may not be called from the device's workloop context.
156 The SCSI Family will serialize accesses to the SCSI
157 target so as not to disrupt commands in progress prior to processing a
158 change of target parameters.
160 Pointer to structure of type SCSITargetParms.
162 bool setTargetParms( SCSITargetParms
*targetParms
);
166 @function getTargetParms
168 Gets the current target parameters.
170 Returns the parameters currently in effect for the SCSI target.
171 See setTargetParms().
173 Pointer to structure of type SCSITargetParms.
175 void getTargetParms( SCSITargetParms
*targetParms
);
179 @function setLunParms
181 Sets the logical unit parameters for this device.
183 This function will block until we attempt to set the
184 requested parameters. It may not be called from the device's workloop context.
186 The SCSI Family will serialize accesses to the SCSI
187 target/lun so as not to disrupt commands in progress prior to processing a
188 change of lun parameters.
190 Pointer to structure of type SCSILunParms
192 bool setLunParms( SCSILunParms
*lunParms
);
196 @function getLunParms
198 Gets the current logical unit parameters.
200 Returns the parameters currently in effect for the SCSI target/lun.
202 Pointer to structure of type SCSITargetParms
204 void getLunParms( SCSILunParms
*lunParms
);
210 Aborts all outstanding requests for the target/lun pair.
212 If any I/O requests are currently active for the target/lun, an abort
213 command is sent to the device and any active requests are completed.
215 Prior to abort processing beginning, the client will be notified via:
217 message( kClientMsgDeviceAbort );
219 When abort processing is completed, the client will be notified via:
221 message( kClientMsgDeviceAbort | kClientMsgDone );
223 The client is responsible for managing the pending work queue for
224 the device when an abort request occurs. See holdQueue(), flushQueue(),
225 notifyIdle() functions.
233 Resets the SCSI target.
235 Since a SCSI target may have multiple logical units (lun(s)) the
236 reset() function may affect multiple IOSCSIDevice instances. Processing for
239 Prior to reset processing beginning, the client will be notified via:
241 message( kClientMsgDeviceReset );
243 When reset processing is completed, the client will be notified via:
245 message( kClientMsgDeviceReset | kClientMsgDone );
247 The client is responsible for managing the pending work queue for
248 the device when an abort request occurs. See holdQueue(), flushQueue(),
249 notifyIdle() functions.
255 @function getInquiryData
256 @abstract Returns SCSI Inquiry data for the IOSCSIDevice.
258 Inquiry data returned is from the results of the last SCSI bus probe.
260 Pointer to a buffer to receive the Inquiry data.
261 @param inquiryBufSize
262 Size of the buffer supplied.
263 @param inquiryDataSize
264 Pointer to a UInt32 to receive the size of the Inquiry data actually
267 void getInquiryData( void *inquiryBuffer
, UInt32 inquiryBufSize
, UInt32
*inquiryDataSize
);
273 IOService message function.
275 IOSCSIDevice notifies its client of significant 'events' by the IOService::message()
276 api. When possible the client is notified of the event prior to any action taken. The
277 client is responsible for managing the device queue for the IOSCSIDevice
278 via the holdQueue(), releaseQueue(), flushQueue() and notifyIdle() api's.
280 Any return codes provided by the client are ignored.
282 Message id's for IOSCSIDevice are defined by enum SCSIClientMessage
284 Pointer to the IOSCSIDevice reporting the event.
288 IOReturn
message( UInt32 type
, IOService
* provider
, void * argument
= 0 );
294 IOService open function
296 A client should open a IOSCSIDevice prior to accessing it. Only one open is allowed
299 Pointer to the IOSCSI device the client is opening.
301 There are currently no options defined by the SCSI Family.
303 Unused. Omit or specify 0.
305 bool open( IOService
*client
, IOOptionBits options
= 0, void *arg
= 0 );
311 IOService close function
313 A client must close a IOSCSIDevice if the client plans no further accesses to it.
315 Pointer to the IOSCSI device the client is closing.
317 There are currently no options defined by the SCSI Family.
319 void close( IOService
*client
, IOOptionBits options
= 0 );
325 Suspends sending additional IOSCSICommands to the target/lun.
327 holdQueue() may only be called from the IOSCSIDevice workloop. The client
328 is guaranteed to be running in this context during a message() notification.
330 holdQueue() has no effect on commands already passed to the host adapter. One
331 or more commands may complete after the queue is held. See notifyIdle()
333 Perform action on the indicated queue. See enum SCSIQueueType in IOSCSICommand.
335 holdQueue( UInt32 queueType
);
341 Returns any commands on the IOSCSIDevice's pending work queue.
343 flushQueue() may only be called from the IOSCSIDevice workloop. This is
344 guaranteed to be the case after a IOSCSICommand completion of after a
345 message() notification.
347 All pending command are completed prior to flushQueue() returning to the caller.
349 flushQueue() has no effect on commands already passed to the host adapter. One
350 or more commands may complete after the queue is flushed. See notifyIdle().
352 Perform action on the indicated queue. See enum SCSIQueueType in IOSCSICommand.
354 The return code of any flushed commands is set to (rc).
356 void flushQueue( UInt32 queueType
, IOReturn rc
);
362 Notifies the client when all active commands on a SCSI device have completed.
364 notifyIdle() may only be called from the IOSCSIDevice workloop. This is guaranteed
365 to be the case after a IOSCSICommand completion of after a message() notification.
367 Only one notifyIdle() call may be active. Any outstanding notifyIdle() calls may
368 be cancelled by calling notifyIdle() with no parameters.
370 Object to receive the notification. Normally the client's (this) pointer.
372 Pointer to a callback routine of type CallbackFn.
374 Pointer to client's private data.
376 void notifyIdle( void *target
, Callback callback
, void *refcon
);
380 @function releaseQueue
382 Resumes sending IOSCSICommands to the IOSCSIDevice.
384 If the device queue was not held, releaseQueue() has no effect.
386 releaseQueue() may only be called from the IOSCSIDevice workloop. This is guaranteed
387 to be the case after a IOSCSICommand completion of after a message() notification.
389 Perform action on the indicated queue. See enum SCSIQueueType in IOSCSICommand.
391 void releaseQueue( UInt32 queueType
);
395 @function getWorkLoop
397 Returns the IOWorkLoop object that services this IOSCSIDevice.
399 IOWorkloop
*getWorkLoop();