|
|
1.1 root 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:
38: class IOSCSIParallelController;
39:
40: class IOSCSIParallelDevice : public IOSCSIDevice
41: {
42: OSDeclareDefaultStructors(IOSCSIParallelDevice)
43:
44: friend class IOSCSIParallelCommand;
45: friend class IOSCSIParallelController;
46:
47: /*------------------Methods provided to IOCDBDevice clients-----------------------*/
48: public:
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-----------------------*/
73: public:
74: /*
75: * Allocate a SCSICommand
76: */
77: IOSCSICommand *allocCommand( IOSCSIDevice *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----------------*/
105: public:
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: private:
116: void submitCommand( UInt32 cmdType, IOSCSIParallelCommand *scsiCmd, UInt32 cmdSequenceNumber = 0 );
117: void receiveCommand( UInt32 cmdType, IOSCSIParallelCommand *scsiCmd, UInt32 cmdSequenceNumber, void *p3 );
118:
119: IOReturn probeTargetLun();
120: void setupTarget();
121:
122: void dispatchRequest();
123: bool dispatch( UInt32 *dispatchAction );
124:
125: void abortAllCommands( SCSICommandType abortCmdType );
126:
127: IOSCSIParallelCommand *findCommandWithNexus( UInt32 tagValue );
128:
129: void abortCommand( IOSCSIParallelCommand *scsiCmd, UInt32 cmdSequenceNumber );
130: void completeCommand( IOSCSIParallelCommand *cmd );
131:
132: void checkIdleNotify();
133:
134: void executeCommandDone( IOSCSIParallelCommand *scsiCmd );
135: void executeReqSenseDone( IOSCSIParallelCommand *scsiCmd );
136: void abortCommandDone( IOSCSIParallelCommand *scsiCmd );
137: void cancelCommandDone( IOSCSIParallelCommand *scsiCmd );
138: void finishCommand( IOSCSIParallelCommand *scsiCmd );
139:
140: OSDictionary *createProperties();
141: bool addToRegistry( OSDictionary *propTable, OSObject *regObj, char *key );
142: void stripBlanks( char *d, char *s, UInt32 l );
143:
144: bool checkDeviceQueue( UInt32 *dispatchAction );
145: void checkNegotiate( IOSCSIParallelCommand *scsiCmd );
146: bool checkTag( IOSCSIParallelCommand *scsiCmd );
147: bool checkReqSense();
148: bool checkAbortQueue();
149: void checkCancelQueue();
150:
151: bool allocTag( UInt32 *tagId );
152: void freeTag( UInt32 tagId );
153:
154: void timer();
155:
156: void resetOccurred( SCSIClientMessage clientMsg );
157: void resetComplete();
158:
159: void rescheduleCommand( IOSCSIParallelCommand *scsiCmd );
160:
161: void addCommand( queue_head_t *list, IOSCSIParallelCommand *scsiCmd );
162: void stackCommand( queue_head_t *list, IOSCSIParallelCommand *scsiCmd );
163: void deleteCommand( queue_head_t *list, IOSCSIParallelCommand *scsiCmd, IOReturn rc = kIOReturnSuccess );
164: IOSCSIParallelCommand *checkCommand( queue_head_t *list );
165: IOSCSIParallelCommand *getCommand( queue_head_t *list );
166: void moveCommand( queue_head_t *fromList,
167: queue_head_t *toList,
168: IOSCSIParallelCommand *scsiCmd,
169: IOReturn rc = kIOReturnSuccess );
170: void moveAllCommands( queue_head_t *fromList, queue_head_t *toList, IOReturn rc = kIOReturnSuccess );
171: bool findCommand( queue_head_t *list, IOSCSIParallelCommand *findScsiCmd );
172: void purgeAllCommands( queue_head_t *list, IOReturn rc );
173:
174: IOSCSIParallelCommand *allocCommand( IOSCSIParallelDevice *deviceType, UInt32 clientDataSize = 0 );
175:
176: private:
177: queue_chain_t nextDevice;
178:
179: SCSITargetLun targetLun;
180:
181: SCSITarget *target;
182:
183: IOSCSIParallelController *controller;
184: IOCommandGate *deviceGate;
185:
186: IOService *client;
187: IORWLock * clientSem;
188:
189: queue_head_t deviceList;
190: queue_head_t bypassList;
191: queue_head_t activeList;
192: queue_head_t abortList;
193: queue_head_t cancelList;
194:
195: SCSICommandType abortCmdPending;
196:
197: UInt32 reqSenseState;
198: UInt32 abortState;
199: UInt32 cancelState;
200: UInt32 negotiateState;
201:
202: IOSCSIParallelCommand *reqSenseOrigCmd;
203:
204: IOSCSIParallelCommand *reqSenseCmd;
205: IOSCSIParallelCommand *abortCmd;
206: IOSCSIParallelCommand *cancelCmd;
207: IOSCSIParallelCommand *probeCmd;
208:
209: bool normalQHeld;
210: bool bypassQHeld;
211:
212: bool idleNotifyActive;
213: CallbackFn idleNotifyCallback;
214: void *idleNotifyTarget;
215: void *idleNotifyRefcon;
216:
217: UInt32 commandCount;
218: UInt32 commandLimit;
219: UInt32 commandLimitSave;
220:
221: bool disableDisconnect;
222:
223: UInt32 *tagArray;
224:
225: SCSILunParms lunParmsNew;
226:
227: SCSIInquiry *inquiryData;
228: UInt32 inquiryDataSize;
229:
230: void *devicePrivateData;
231: };
232:
233: #define kIOSCSIParallelDevice ((IOSCSIParallelDevice *)0)
234:
235: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.