|
|
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: * 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( IOSCSICommand *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( IOSCSICommand *forSCSICmd ) = 0;
89: virtual void cancelCommand( IOSCSICommand *forSCSICmd ) = 0;
90: virtual void resetCommand( IOSCSICommand *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:
116: private:
117: IOSCSIParallelDevice *createDevice();
118:
119: void initQueues();
120: bool scanSCSIBus();
121:
122: bool initTarget( SCSITargetLun targetLun );
123: void releaseTarget( SCSITargetLun targetLun );
124: bool initDevice( IOSCSIParallelDevice *device );
125: void releaseDevice( IOSCSIParallelDevice *device );
126:
127: bool workLoopRequest( WorkLoopReqType type, UInt32 p1=0, UInt32 p2=0, UInt32 p3=0 );
128: void workLoopProcessRequest( WorkLoopRequest *workLoopReq, void *p1, void *p2, void *p3 );
129:
130: void addDevice( IOSCSIParallelDevice *forDevice );
131: void deleteDevice( IOSCSIParallelDevice *forDevice );
132:
133: void timer( IOTimerEventSource *);
134:
135: void dispatchRequest();
136: void dispatch();
137:
138: bool checkBusReset();
139:
140: void completeCommand( IOSCSIParallelCommand *forSCSICmd );
141:
142: bool createWorkLoop();
143: bool configureController();
144:
145: IOSCSIParallelCommand *allocCommand( UInt32 clientDataSize );
146:
147: private:
148:
149: UInt32 sequenceNumber;
150:
151: UInt32 commandCount;
152: UInt32 commandLimit;
153: UInt32 commandLimitSave;
154:
155: UInt32 disableTimer;
156: bool commandDisable;
157:
158: UInt32 tagArraySize;
159: UInt32 *tagArray;
160:
161: UInt32 busResetState;
162: IOSCSIParallelCommand *resetCmd;
163: UInt32 resetTimer;
164:
165: IOSCSIParallelCommand *noDisconnectCmd;
166:
167: SCSIControllerInfo controllerInfo;
168: SCSITarget *targets;
169:
170: IOWorkLoop *workLoop;
171: IOTimerEventSource *timerEvent;
172: IOInterruptEventSource *dispatchEvent;
173: IOCommandGate *workLoopReqGate;
174:
175: IOService *provider;
176: };
177:
178: #endif
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.