]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/scsi/scsi-parallel/IOSCSIParallelController.h
xnu-201.42.3.tar.gz
[apple/xnu.git] / iokit / IOKit / scsi / scsi-parallel / IOSCSIParallelController.h
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 * IOSCSIController.h
25 *
26 * Methods in this header list the methods an SCSI controller driver must implement.
27 */
28 #ifndef _IOSCSIPARALLELCONTROLLER_H
29 #define _IOSCSIPARALLELCONTROLLER_H
30
31 #include <IOKit/IOWorkLoop.h>
32 #include <IOKit/IOCommandGate.h>
33 #include <IOKit/IOInterruptEventSource.h>
34 #include <IOKit/IOTimerEventSource.h>
35 #include <libkern/OSByteOrder.h>
36 #include <IOKit/IOMemoryCursor.h>
37
38 class IOSCSIParallelDevice;
39 class IOSCSIParallelCommand;
40
41 class IOSCSIParallelController : public IOService
42 {
43 OSDeclareDefaultStructors(IOSCSIParallelController)
44
45 friend class IOSCSIParallelCommand;
46 friend class IOSCSIParallelDevice;
47
48 /*------------------Methods provided by IOSCSIParallelController---------------------------------*/
49 public:
50 bool probeTarget( SCSITargetLun targetLun );
51 void reset();
52
53 protected:
54 void resetOccurred();
55
56 void enableCommands();
57 void disableCommands();
58 void disableCommands( UInt32 disableTimeoutmS );
59
60 void rescheduleCommand( IOSCSIParallelCommand *forSCSICmd );
61
62 IOSCSIParallelDevice *findDeviceWithTargetLun( SCSITargetLun targetLun );
63 IOSCSIParallelCommand *findCommandWithNexus( SCSITargetLun targetLun, UInt32 tagValue = (UInt32)-1 );
64
65 void *getTargetData( SCSITargetLun targetLun );
66 void *getLunData( SCSITargetLun targetLun );
67
68 virtual IOWorkLoop *getWorkLoop() const;
69
70 void setCommandLimit( UInt32 commandLimit ); // temp
71
72
73 /*------------------Methods the controller subclass must implement-----------------------*/
74 protected:
75 /*
76 * Initialize controller hardware.
77 *
78 * Note: The controller driver's configure() method will be called prior to any other
79 * methods. If the controller driver returns successfully from this method it
80 * should be ready to accept any other method call listed.
81 */
82 virtual bool configure( IOService *provider, SCSIControllerInfo *controllerInfo ) = 0;
83
84 /*
85 * Bus/target commands
86 *
87 */
88 virtual void executeCommand( IOSCSIParallelCommand *forSCSICmd ) = 0;
89 virtual void cancelCommand( IOSCSIParallelCommand *forSCSICmd ) = 0;
90 virtual void resetCommand( IOSCSIParallelCommand *forSCSICmd ) = 0;
91
92 /*------------------Optional methods the controller subclass may implement-----------------------*/
93 protected:
94 /*
95 * These methods notify the IOSCSIParallelController subclass, that a target or lun is about to be
96 * probed. The subclass should initialize its per-target or per-lun data when called at these
97 * methods. If the subclass (for some reason) wants to prevent probing of a target or lun, it
98 * can return false to the corresponding allocate*() call.
99 */
100 virtual bool allocateTarget( SCSITargetLun targetLun );
101 virtual void deallocateTarget( SCSITargetLun targetLun );
102
103 virtual bool allocateLun( SCSITargetLun targetLun );
104 virtual void deallocateLun( SCSITargetLun targetLun );
105
106 virtual void disableTimeoutOccurred();
107
108
109 /*------------------Methods private to the IOSCSIParallelController class----------------------*/
110
111 public:
112 bool start( IOService *provider );
113 void free();
114
115 private:
116 IOSCSIParallelDevice *createDevice();
117
118 void initQueues();
119 bool scanSCSIBus();
120
121 bool initTarget( SCSITargetLun targetLun );
122 bool initTargetGated( SCSITargetLun *targetLun );
123 void releaseTarget( SCSITargetLun targetLun );
124 void releaseTargetGated( SCSITargetLun *targetLun );
125 bool initDevice( IOSCSIParallelDevice *device );
126 bool initDeviceGated( IOSCSIParallelDevice *device );
127 void releaseDevice( IOSCSIParallelDevice *device );
128 void releaseDeviceGated( IOSCSIParallelDevice *device );
129
130
131 void addDevice( IOSCSIParallelDevice *forDevice );
132 void deleteDevice( IOSCSIParallelDevice *forDevice );
133
134 void timer( IOTimerEventSource *);
135
136 void dispatchRequest();
137 void dispatch();
138
139 bool checkBusReset();
140
141 void completeCommand( IOSCSIParallelCommand *forSCSICmd );
142
143 bool createWorkLoop();
144 bool configureController();
145
146 IOSCSIParallelCommand *allocCommand( UInt32 clientDataSize );
147
148 private:
149
150 UInt32 sequenceNumber;
151
152 UInt32 commandCount;
153 UInt32 commandLimit;
154 UInt32 commandLimitSave;
155
156 UInt32 disableTimer;
157 bool commandDisable;
158
159 UInt32 tagArraySize;
160 UInt32 *tagArray;
161
162 UInt32 busResetState;
163 IOSCSIParallelCommand *resetCmd;
164 UInt32 resetTimer;
165
166 IOSCSIParallelCommand *noDisconnectCmd;
167
168 SCSIControllerInfo controllerInfo;
169 SCSITarget *targets;
170
171 IOWorkLoop *workLoop;
172 IOTimerEventSource *timerEvent;
173 IOInterruptEventSource *dispatchEvent;
174
175 IOCommandGate *controllerGate;
176
177 IOService *provider;
178 };
179
180 #endif