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@
24 * IOSCSIParallelDevice.h
27 * Methods in this header provide information about the SCSI device
28 * the device client driver is submitting the SCSICommand(s) to.
30 * Note: SCSICommand(s) are allocated and freed by methods in this class.
31 * The remaining methods to setup and submit SCSICommands are defined in
35 #ifndef _IOSCSIPARALLELDEVICE_H
36 #define _IOSCSIPARALLELDEVICE_H
38 class IOSCSIParallelController
;
40 class IOSCSIParallelDevice
: public IOSCSIDevice
42 OSDeclareDefaultStructors(IOSCSIParallelDevice
)
44 friend class IOSCSIParallelCommand
;
45 friend class IOSCSIParallelController
;
47 /*------------------Methods provided to IOCDBDevice clients-----------------------*/
51 * Allocate a CDB Command
53 IOCDBCommand
*allocCommand( IOCDBDevice
*deviceType
, UInt32 clientDataSize
= 0 );
56 * Abort all outstanding commands on this device
61 * Reset device (also aborts all outstanding commands)
66 * Obtain information about this device
68 void getInquiryData( void *inquiryBuffer
,
69 UInt32 inquiryBufSize
,
70 UInt32
*inquiryDataSize
);
72 /*------------------Additional methods provided to IOSCSIDevice clients-----------------------*/
75 * Allocate a SCSICommand
77 IOSCSIParallelCommand
*allocCommand( IOSCSIParallelDevice
*deviceType
, UInt32 clientDataSize
= 0 );
80 * Target management commands
82 bool setTargetParms( SCSITargetParms
*targetParms
);
83 void getTargetParms( SCSITargetParms
*targetParms
);
86 * Lun management commands
88 bool setLunParms( SCSILunParms
*lunParms
);
89 void getLunParms( SCSILunParms
*lunParms
);
92 * Queue management commands
94 void holdQueue( UInt32 queueType
);
95 void releaseQueue( UInt32 queueType
);
96 void flushQueue( UInt32 queueType
, IOReturn rc
);
97 void notifyIdle( void *target
= 0, CallbackFn callback
= 0, void *refcon
= 0 );
102 IOWorkLoop
*getWorkLoop() const;
104 /*------------------Methods private to the IOSCSIDevice class----------------*/
106 bool open( IOService
*forClient
, IOOptionBits options
= 0, void *arg
= 0 );
107 void close( IOService
*forClient
, IOOptionBits options
= 0 );
108 IOReturn
message( UInt32 clientMsg
, IOService
*forProvider
, void *forArg
= 0 );
109 bool init( IOSCSIParallelController
*forController
, SCSITargetLun forTargetLun
);
112 bool matchPropertyTable( OSDictionary
* table
);
113 IOService
*matchLocation( IOService
* client
);
115 IOSCSICommand
*allocCommand( IOSCSIDevice
*deviceType
, UInt32 clientDataSize
= 0 );
118 void submitCommand( UInt32 cmdType
, IOSCSIParallelCommand
*scsiCmd
, UInt32 cmdSequenceNumber
= 0 );
119 void receiveCommand( UInt32 cmdType
, IOSCSIParallelCommand
*scsiCmd
, UInt32 cmdSequenceNumber
, void *p3
);
121 IOReturn
probeTargetLun();
122 bool checkCmdQueEnabled();
125 void dispatchRequest();
126 bool dispatch( UInt32
*dispatchAction
);
128 void abortAllCommands( SCSICommandType abortCmdType
);
130 IOSCSIParallelCommand
*findCommandWithNexus( UInt32 tagValue
);
132 void abortCommand( IOSCSIParallelCommand
*scsiCmd
, UInt32 cmdSequenceNumber
);
133 void completeCommand( IOSCSIParallelCommand
*cmd
);
135 void checkIdleNotify();
137 void executeCommandDone( IOSCSIParallelCommand
*scsiCmd
);
138 void executeReqSenseDone( IOSCSIParallelCommand
*scsiCmd
);
139 void abortCommandDone( IOSCSIParallelCommand
*scsiCmd
);
140 void cancelCommandDone( IOSCSIParallelCommand
*scsiCmd
);
141 void finishCommand( IOSCSIParallelCommand
*scsiCmd
);
143 OSDictionary
*createProperties();
144 bool addToRegistry( OSDictionary
*propTable
, OSObject
*regObj
, char *key
, bool doRelease
= true );
145 void stripBlanks( char *d
, char *s
, UInt32 l
);
147 bool checkDeviceQueue( UInt32
*dispatchAction
);
148 void checkNegotiate( IOSCSIParallelCommand
*scsiCmd
);
149 bool checkTag( IOSCSIParallelCommand
*scsiCmd
);
150 bool checkReqSense();
151 bool checkAbortQueue();
152 void checkCancelQueue();
154 void negotiationComplete();
156 bool allocTag( UInt32
*tagId
);
157 void freeTag( UInt32 tagId
);
161 void resetOccurred( SCSIClientMessage clientMsg
);
162 void resetComplete();
164 void rescheduleCommand( IOSCSIParallelCommand
*scsiCmd
);
166 void addCommand( queue_head_t
*list
, IOSCSIParallelCommand
*scsiCmd
);
167 void stackCommand( queue_head_t
*list
, IOSCSIParallelCommand
*scsiCmd
);
168 void deleteCommand( queue_head_t
*list
, IOSCSIParallelCommand
*scsiCmd
, IOReturn rc
= kIOReturnSuccess
);
169 IOSCSIParallelCommand
*checkCommand( queue_head_t
*list
);
170 IOSCSIParallelCommand
*getCommand( queue_head_t
*list
);
171 void moveCommand( queue_head_t
*fromList
,
172 queue_head_t
*toList
,
173 IOSCSIParallelCommand
*scsiCmd
,
174 IOReturn rc
= kIOReturnSuccess
);
175 void moveAllCommands( queue_head_t
*fromList
, queue_head_t
*toList
, IOReturn rc
= kIOReturnSuccess
);
176 bool findCommand( queue_head_t
*list
, IOSCSIParallelCommand
*findScsiCmd
);
177 void purgeAllCommands( queue_head_t
*list
, IOReturn rc
);
180 queue_chain_t nextDevice
;
182 SCSITargetLun targetLun
;
186 IOSCSIParallelController
*controller
;
187 IOCommandGate
*deviceGate
;
190 IORWLock
* clientSem
;
192 queue_head_t deviceList
;
193 queue_head_t bypassList
;
194 queue_head_t activeList
;
195 queue_head_t abortList
;
196 queue_head_t cancelList
;
198 SCSICommandType abortCmdPending
;
200 UInt32 reqSenseState
;
203 UInt32 negotiateState
;
205 IOSCSIParallelCommand
*reqSenseOrigCmd
;
207 IOSCSIParallelCommand
*reqSenseCmd
;
208 IOSCSIParallelCommand
*abortCmd
;
209 IOSCSIParallelCommand
*cancelCmd
;
210 IOSCSIParallelCommand
*probeCmd
;
215 bool idleNotifyActive
;
216 CallbackFn idleNotifyCallback
;
217 void *idleNotifyTarget
;
218 void *idleNotifyRefcon
;
222 UInt32 commandLimitSave
;
224 bool disableDisconnect
;
228 OSNumber
*regObjTransferPeriod
;
229 OSNumber
*regObjTransferOffset
;
230 OSNumber
*regObjTransferWidth
;
231 OSNumber
*regObjTransferOptions
;
232 OSNumber
*regObjCmdQueue
;
236 SCSILunParms lunParmsNew
;
238 SCSIInquiry
*inquiryData
;
239 UInt32 inquiryDataSize
;
241 void *devicePrivateData
;
244 #define kIOSCSIParallelDevice ((IOSCSIParallelDevice *)0)