]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/scsi/scsi-parallel/IOSCSIParallelDevice.h
xnu-201.42.3.tar.gz
[apple/xnu.git] / iokit / IOKit / scsi / scsi-parallel / IOSCSIParallelDevice.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 * IOSCSIParallelDevice.h
25 *
26 *
27 * Methods in this header provide information about the SCSI device
28 * the device client driver is submitting the SCSICommand(s) to.
29 *
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
32 * IOSCSICommand.h
33 */
34
35#ifndef _IOSCSIPARALLELDEVICE_H
36#define _IOSCSIPARALLELDEVICE_H
37
38class IOSCSIParallelController;
39
40class IOSCSIParallelDevice : public IOSCSIDevice
41{
42 OSDeclareDefaultStructors(IOSCSIParallelDevice)
43
44 friend class IOSCSIParallelCommand;
45 friend class IOSCSIParallelController;
46
47/*------------------Methods provided to IOCDBDevice clients-----------------------*/
48public:
49
50 /*
51 * Allocate a CDB Command
52 */
53 IOCDBCommand *allocCommand( IOCDBDevice *deviceType, UInt32 clientDataSize = 0 );
54
55 /*
56 * Abort all outstanding commands on this device
57 */
58 void abort();
59
60 /*
61 * Reset device (also aborts all outstanding commands)
62 */
63 void reset();
64
65 /*
66 * Obtain information about this device
67 */
68 void getInquiryData( void *inquiryBuffer,
69 UInt32 inquiryBufSize,
70 UInt32 *inquiryDataSize );
71
72/*------------------Additional methods provided to IOSCSIDevice clients-----------------------*/
73public:
74 /*
75 * Allocate a SCSICommand
76 */
77 IOSCSIParallelCommand *allocCommand( IOSCSIParallelDevice *deviceType, UInt32 clientDataSize = 0 );
78
79 /*
80 * Target management commands
81 */
82 bool setTargetParms( SCSITargetParms *targetParms );
83 void getTargetParms( SCSITargetParms *targetParms );
84
85 /*
86 * Lun management commands
87 */
88 bool setLunParms( SCSILunParms *lunParms );
89 void getLunParms( SCSILunParms *lunParms );
90
91 /*
92 * Queue management commands
93 */
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 );
98
99 /*
100 *
101 */
102 IOWorkLoop *getWorkLoop() const;
103
104/*------------------Methods private to the IOSCSIDevice class----------------*/
105public:
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 );
110 void free();
111
112 bool matchPropertyTable( OSDictionary * table );
113 IOService *matchLocation( IOService * client );
114
115 IOSCSICommand *allocCommand( IOSCSIDevice *deviceType, UInt32 clientDataSize = 0 );
116
117private:
118 void submitCommand( UInt32 cmdType, IOSCSIParallelCommand *scsiCmd, UInt32 cmdSequenceNumber = 0 );
119 void receiveCommand( UInt32 cmdType, IOSCSIParallelCommand *scsiCmd, UInt32 cmdSequenceNumber, void *p3 );
120
121 IOReturn probeTargetLun();
122 bool checkCmdQueEnabled();
123 void setupTarget();
124
125 void dispatchRequest();
126 bool dispatch( UInt32 *dispatchAction );
127
128 void abortAllCommands( SCSICommandType abortCmdType );
129
130 IOSCSIParallelCommand *findCommandWithNexus( UInt32 tagValue );
131
132 void abortCommand( IOSCSIParallelCommand *scsiCmd, UInt32 cmdSequenceNumber );
133 void completeCommand( IOSCSIParallelCommand *cmd );
134
135 void checkIdleNotify();
136
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 );
142
143 OSDictionary *createProperties();
144 bool addToRegistry( OSDictionary *propTable, OSObject *regObj, char *key, bool doRelease = true );
145 void stripBlanks( char *d, char *s, UInt32 l );
146
147 bool checkDeviceQueue( UInt32 *dispatchAction );
148 void checkNegotiate( IOSCSIParallelCommand *scsiCmd );
149 bool checkTag( IOSCSIParallelCommand *scsiCmd );
150 bool checkReqSense();
151 bool checkAbortQueue();
152 void checkCancelQueue();
153
154 void negotiationComplete();
155
156 bool allocTag( UInt32 *tagId );
157 void freeTag( UInt32 tagId );
158
159 void timer();
160
161 void resetOccurred( SCSIClientMessage clientMsg );
162 void resetComplete();
163
164 void rescheduleCommand( IOSCSIParallelCommand *scsiCmd );
165
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 );
178
179private:
180 queue_chain_t nextDevice;
181
182 SCSITargetLun targetLun;
183
184 SCSITarget *target;
185
186 IOSCSIParallelController *controller;
187 IOCommandGate *deviceGate;
188
189 IOService *client;
190 IORWLock * clientSem;
191
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;
197
198 SCSICommandType abortCmdPending;
199
200 UInt32 reqSenseState;
201 UInt32 abortState;
202 UInt32 cancelState;
203 UInt32 negotiateState;
204
205 IOSCSIParallelCommand *reqSenseOrigCmd;
206
207 IOSCSIParallelCommand *reqSenseCmd;
208 IOSCSIParallelCommand *abortCmd;
209 IOSCSIParallelCommand *cancelCmd;
210 IOSCSIParallelCommand *probeCmd;
211
212 bool normalQHeld;
213 bool bypassQHeld;
214
215 bool idleNotifyActive;
216 CallbackFn idleNotifyCallback;
217 void *idleNotifyTarget;
218 void *idleNotifyRefcon;
219
220 UInt32 commandCount;
221 UInt32 commandLimit;
222 UInt32 commandLimitSave;
223
224 bool disableDisconnect;
225
226 bool lunAllocated;
227
228 OSNumber *regObjTransferPeriod;
229 OSNumber *regObjTransferOffset;
230 OSNumber *regObjTransferWidth;
231 OSNumber *regObjTransferOptions;
232 OSNumber *regObjCmdQueue;
233
234 UInt32 *tagArray;
235
236 SCSILunParms lunParmsNew;
237
238 SCSIInquiry *inquiryData;
239 UInt32 inquiryDataSize;
240
241 void *devicePrivateData;
242};
243
244#define kIOSCSIParallelDevice ((IOSCSIParallelDevice *)0)
245
246#endif