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@
26 * Methods in this header list the methods an SCSI controller driver must implement.
28 #ifndef _IOSCSIPARALLELCONTROLLER_H
29 #define _IOSCSIPARALLELCONTROLLER_H
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>
38 class IOSCSIParallelDevice
;
39 class IOSCSIParallelCommand
;
41 class IOSCSIParallelController
: public IOService
43 OSDeclareDefaultStructors(IOSCSIParallelController
)
45 friend class IOSCSIParallelCommand
;
46 friend class IOSCSIParallelDevice
;
48 /*------------------Methods provided by IOSCSIParallelController---------------------------------*/
50 bool probeTarget( SCSITargetLun targetLun
);
56 void enableCommands();
57 void disableCommands();
58 void disableCommands( UInt32 disableTimeoutmS
);
60 void rescheduleCommand( IOSCSIParallelCommand
*forSCSICmd
);
62 IOSCSIParallelDevice
*findDeviceWithTargetLun( SCSITargetLun targetLun
);
63 IOSCSIParallelCommand
*findCommandWithNexus( SCSITargetLun targetLun
, UInt32 tagValue
= (UInt32
)-1 );
65 void *getTargetData( SCSITargetLun targetLun
);
66 void *getLunData( SCSITargetLun targetLun
);
68 virtual IOWorkLoop
*getWorkLoop() const;
70 void setCommandLimit( UInt32 commandLimit
); // temp
73 /*------------------Methods the controller subclass must implement-----------------------*/
76 * Initialize controller hardware.
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.
82 virtual bool configure( IOService
*provider
, SCSIControllerInfo
*controllerInfo
) = 0;
88 virtual void executeCommand( IOSCSIParallelCommand
*forSCSICmd
) = 0;
89 virtual void cancelCommand( IOSCSIParallelCommand
*forSCSICmd
) = 0;
90 virtual void resetCommand( IOSCSIParallelCommand
*forSCSICmd
) = 0;
92 /*------------------Optional methods the controller subclass may implement-----------------------*/
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.
100 virtual bool allocateTarget( SCSITargetLun targetLun
);
101 virtual void deallocateTarget( SCSITargetLun targetLun
);
103 virtual bool allocateLun( SCSITargetLun targetLun
);
104 virtual void deallocateLun( SCSITargetLun targetLun
);
106 virtual void disableTimeoutOccurred();
109 /*------------------Methods private to the IOSCSIParallelController class----------------------*/
112 bool start( IOService
*provider
);
116 IOSCSIParallelDevice
*createDevice();
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
);
131 void addDevice( IOSCSIParallelDevice
*forDevice
);
132 void deleteDevice( IOSCSIParallelDevice
*forDevice
);
134 void timer( IOTimerEventSource
*);
136 void dispatchRequest();
139 bool checkBusReset();
141 void completeCommand( IOSCSIParallelCommand
*forSCSICmd
);
143 bool createWorkLoop();
144 bool configureController();
146 IOSCSIParallelCommand
*allocCommand( UInt32 clientDataSize
);
150 UInt32 sequenceNumber
;
154 UInt32 commandLimitSave
;
162 UInt32 busResetState
;
163 IOSCSIParallelCommand
*resetCmd
;
166 IOSCSIParallelCommand
*noDisconnectCmd
;
168 SCSIControllerInfo controllerInfo
;
171 IOWorkLoop
*workLoop
;
172 IOTimerEventSource
*timerEvent
;
173 IOInterruptEventSource
*dispatchEvent
;
175 IOCommandGate
*controllerGate
;