]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/scsi/IOSCSIDevice_Reference.h
xnu-201.42.3.tar.gz
[apple/xnu.git] / iokit / IOKit / scsi / IOSCSIDevice_Reference.h
CommitLineData
1c79356b
A
1/*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
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.
11 *
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
18 * under the License.
19 *
20 * @APPLE_LICENSE_HEADER_END@
21 */
22
23
24/*!
25@header IOSCSIDevice_Reference.h
26
27This header defines the IOSCSIDevice class.
28
29The SCSI framework creates instances of this class to
30represent each valid SCSI device (target/lun) detected during
31SCSI bus scanning. When an instance of this class is registered with
32IOKit, the instance will be presented to clients which
33'match' the IOSCSIDevice class.
34*/
35
36/*!
37@typedef SCSITargetParms
38Parameter structure for get/setTargetParms
39@field transferPeriodpS
40Minimum SCSI synchronous transfer period allowed
41for this target in picoseconds (10E-12). For asynchronous data transfer,
42set this field to 0.
43@field transferOffset
44Maximum SCSI synchronous transfer offset allowed for this target in
45bytes. For asynchronous data transfer, set this field to 0.
46@field transferWidth
47Maximum SCSI bus width in bytes. Note: must be a
48power of 2.
49@field enableTagQueuing
50Setting enableTagQueuing to true enables tag queuing for SCSI Commands
51issued to the target.
52@field disableParity
53Set to (true) to disable parity checking on the
54SCSI bus for this target.
55*/
56typedef struct SCSITargetParms {
57 UInt32 transferPeriodpS;
58 UInt32 transferOffset;
59 UInt32 transferWidth;
60
61 bool enableTagQueuing;
62 bool disableParity;
63
64 UInt32 reserved[16];
65
66} SCSITargetParms;
67
68
69/*!
70@typedef SCSILunParms
71Parameter structure for get/setLunParms
72@field disableDisconnect
73Setting disableDisconnect to true disables SCSI disconnect for SCSI
74Commands issued to the target/lun pair.
75*/
76typedef struct SCSILunParms {
77 bool disableDisconnect;
78
79 UInt32 reserved[16];
80
81} SCSILunParms;
82
83
84/*!
85@enum SCSIClientMessage
86@discussion
87IOSCSIDevice notifies its client of significant 'events' by the IOService::message()
88api. When possible the client is notified of the event prior to any action taken. The
89client is responsible for managing the device queue for the IOSCSIDevice
90via the holdQueue(), releaseQueue(), flushQueue() and notifyIdle() api's. The client is also
91notified at the end of an 'event' by the corresponding message id with or'd with
92kClientMsgDone.
93@constant kClientMsgDeviceAbort
94A client initiated device abort is beginning.
95@constant kClientMsgDeviceReset
96A client initiated device reset is beginning.
97@constant kClientMsgBusReset
98An unsolicited bus reset has occurred.
99@constant kClientMsgDone
100This constant is or'd with one of the above message ids to indicate the
101client should complete processing of the corresponding event.
102*/
103enum SCSIClientMessage {
104 kClientMsgDeviceAbort = 0x00005000,
105 kClientMsgDeviceReset,
106 kClientMsgBusReset,
107
108 kClientMsgDone = 0x80000000,
109};
110
111
112/*!
113@class IOSCSIDevice : public IOCDBDevice
114@abstract
115Class that describes a SCSI device (target/lun pair).
116@discussion
117The IOSCSIDevice class provides basic services
118to initialize and supervise a SCSI device. Once the device is
119initialized, the client will normally use the allocCommand() member
120function to create IOSCSICommand(s) to send SCSI CDBs to the target/lun.
121*/
122class IOSCSIDevice : public IOCDBDevice
123{
124public:
125
126/*!
127@function allocCommand
128@abstract
129Allocates a IOSCSICommand object for this device.
130@discussion
131The client uses the allocCommand() member function to allocate IOSCSICommand(s)
132for a IOSCSIDevice. The client then uses the member functions of
133the IOSCSICommand to initialize it and send it to the device. A completed IOSCSICommand
134may be reused for subsequent I/O requests or returned to the SCSI Family.
135@param scsiDevice
136Always specify kIOSCSIDevice.
137@param clientDataSize
138The client may indicate the size of a per-command data area for its own
139use.
140
141Note: The amount of per-command storage allowed is under review. We
142anticipate that typical SCSI clients will need not more than 1024 bytes
143per command.
144*/
145IOSCSICommand *allocCommand( IOSCSIDevice *scsiDevice, UInt32 clientDataSize = 0 );
146
147
148/*!
149@function setTargetParms
150@abstract
151Sets SCSI parameters that apply to all luns on a SCSI target device.
152@discussion
153This function will block until we attempt to set the
154requested parameters. It may not be called from the device's workloop context.
155
156The SCSI Family will serialize accesses to the SCSI
157target so as not to disrupt commands in progress prior to processing a
158change of target parameters.
159@param targetParms
160Pointer to structure of type SCSITargetParms.
161*/
162bool setTargetParms( SCSITargetParms *targetParms );
163
164
165/*!
166@function getTargetParms
167@abstract
168Gets the current target parameters.
169@discussion
170Returns the parameters currently in effect for the SCSI target.
171See setTargetParms().
172@param targetParms
173Pointer to structure of type SCSITargetParms.
174*/
175void getTargetParms( SCSITargetParms *targetParms );
176
177
178/*!
179@function setLunParms
180@abstract
181Sets the logical unit parameters for this device.
182@discussion
183This function will block until we attempt to set the
184requested parameters. It may not be called from the device's workloop context.
185
186The SCSI Family will serialize accesses to the SCSI
187target/lun so as not to disrupt commands in progress prior to processing a
188change of lun parameters.
189@param lunParms
190Pointer to structure of type SCSILunParms
191*/
192bool setLunParms( SCSILunParms *lunParms );
193
194
195/*!
196@function getLunParms
197@abstract
198Gets the current logical unit parameters.
199@discussion
200Returns the parameters currently in effect for the SCSI target/lun.
201@param lunParms
202Pointer to structure of type SCSITargetParms
203*/
204void getLunParms( SCSILunParms *lunParms );
205
206
207/*!
208@function abort
209@abstract
210Aborts all outstanding requests for the target/lun pair.
211@discussion
212If any I/O requests are currently active for the target/lun, an abort
213command is sent to the device and any active requests are completed.
214
215Prior to abort processing beginning, the client will be notified via:
216
217message( kClientMsgDeviceAbort );
218
219When abort processing is completed, the client will be notified via:
220
221message( kClientMsgDeviceAbort | kClientMsgDone );
222
223The client is responsible for managing the pending work queue for
224the device when an abort request occurs. See holdQueue(), flushQueue(),
225notifyIdle() functions.
226*/
227void abort();
228
229
230/*!
231@function reset
232@abstract
233Resets the SCSI target.
234@discussion
235Since a SCSI target may have multiple logical units (lun(s)) the
236reset() function may affect multiple IOSCSIDevice instances. Processing for
237each lun is similar.
238
239Prior to reset processing beginning, the client will be notified via:
240
241message( kClientMsgDeviceReset );
242
243When reset processing is completed, the client will be notified via:
244
245message( kClientMsgDeviceReset | kClientMsgDone );
246
247The client is responsible for managing the pending work queue for
248the device when an abort request occurs. See holdQueue(), flushQueue(),
249notifyIdle() functions.
250*/
251void reset();
252
253
254/*!
255@function getInquiryData
256@abstract Returns SCSI Inquiry data for the IOSCSIDevice.
257@discussion
258Inquiry data returned is from the results of the last SCSI bus probe.
259@param inquiryBuffer
260Pointer to a buffer to receive the Inquiry data.
261@param inquiryBufSize
262Size of the buffer supplied.
263@param inquiryDataSize
264Pointer to a UInt32 to receive the size of the Inquiry data actually
265returned.
266*/
267void getInquiryData( void *inquiryBuffer, UInt32 inquiryBufSize, UInt32 *inquiryDataSize );
268
269
270/*!
271@function message
272@abstract
273IOService message function.
274@discussion
275IOSCSIDevice notifies its client of significant 'events' by the IOService::message()
276api. When possible the client is notified of the event prior to any action taken. The
277client is responsible for managing the device queue for the IOSCSIDevice
278via the holdQueue(), releaseQueue(), flushQueue() and notifyIdle() api's.
279
280Any return codes provided by the client are ignored.
281@param message-id
282Message id's for IOSCSIDevice are defined by enum SCSIClientMessage
283@param provider
284Pointer to the IOSCSIDevice reporting the event.
285@param argument
286Unused.
287*/
288IOReturn message( UInt32 type, IOService * provider, void * argument = 0 );
289
290
291/*!
292@function open
293@abstract
294IOService open function
295@discussion
296A client should open a IOSCSIDevice prior to accessing it. Only one open is allowed
297per device.
298@param client
299Pointer to the IOSCSI device the client is opening.
300@param options
301There are currently no options defined by the SCSI Family.
302@param arg
303Unused. Omit or specify 0.
304*/
305bool open( IOService *client, IOOptionBits options = 0, void *arg = 0 );
306
307
308/*!
309@function close
310@abstract
311IOService close function
312@discussion
313A client must close a IOSCSIDevice if the client plans no further accesses to it.
314@param client
315Pointer to the IOSCSI device the client is closing.
316@param options
317There are currently no options defined by the SCSI Family.
318*/
319void close( IOService *client, IOOptionBits options = 0 );
320
321
322/*!
323@function holdQueue
324@abstract
325Suspends sending additional IOSCSICommands to the target/lun.
326@discussion
327holdQueue() may only be called from the IOSCSIDevice workloop. The client
328is guaranteed to be running in this context during a message() notification.
329
330holdQueue() has no effect on commands already passed to the host adapter. One
331or more commands may complete after the queue is held. See notifyIdle()
332@param queueType
333Perform action on the indicated queue. See enum SCSIQueueType in IOSCSICommand.
334*/
335holdQueue( UInt32 queueType );
336
337
338/*!
339@function flushQueue
340@abstract
341Returns any commands on the IOSCSIDevice's pending work queue.
342@discussion
343flushQueue() may only be called from the IOSCSIDevice workloop. This is
344guaranteed to be the case after a IOSCSICommand completion of after a
345message() notification.
346
347All pending command are completed prior to flushQueue() returning to the caller.
348
349flushQueue() has no effect on commands already passed to the host adapter. One
350or more commands may complete after the queue is flushed. See notifyIdle().
351@param queueType
352Perform action on the indicated queue. See enum SCSIQueueType in IOSCSICommand.
353@param rc
354The return code of any flushed commands is set to (rc).
355*/
356void flushQueue( UInt32 queueType, IOReturn rc );
357
358
359/*!
360@function notifyIdle
361@abstract
362Notifies the client when all active commands on a SCSI device have completed.
363@discussion
364notifyIdle() may only be called from the IOSCSIDevice workloop. This is guaranteed
365to be the case after a IOSCSICommand completion of after a message() notification.
366
367Only one notifyIdle() call may be active. Any outstanding notifyIdle() calls may
368be cancelled by calling notifyIdle() with no parameters.
369@param target
370Object to receive the notification. Normally the client's (this) pointer.
371@param callback
372Pointer to a callback routine of type CallbackFn.
373@param refcon
374Pointer to client's private data.
375*/
376void notifyIdle( void *target, Callback callback, void *refcon );
377
378
379/*!
380@function releaseQueue
381@abstract
382Resumes sending IOSCSICommands to the IOSCSIDevice.
383@discussion
384If the device queue was not held, releaseQueue() has no effect.
385
386releaseQueue() may only be called from the IOSCSIDevice workloop. This is guaranteed
387to be the case after a IOSCSICommand completion of after a message() notification.
388@param queueType
389Perform action on the indicated queue. See enum SCSIQueueType in IOSCSICommand.
390*/
391void releaseQueue( UInt32 queueType );
392
393
394/*!
395@function getWorkLoop
396@abstract
397Returns the IOWorkLoop object that services this IOSCSIDevice.
398*/
399IOWorkloop *getWorkLoop();
400
401}