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 ATA controller driver must implement.
28 #ifndef _IOATASTANDARDCONTROLLER_H
29 #define _IOATASTANDARDCONTROLLER_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 IOATAStandardDevice
;
39 class IOATAStandardCommand
;
40 class IOATAStandardDriver
;
42 class IOATAStandardController
: public IOService
44 OSDeclareDefaultStructors(IOATAStandardController
)
46 friend class IOATAStandardCommand
;
47 friend class IOATAStandardDevice
;
48 friend class IOATAStandardDriver
;
50 /*------------------Methods provided by IOATAStandardController---------------------------------*/
55 void enableCommands();
56 void disableCommands();
57 void disableCommands( UInt32 disableTimeoutmS
);
59 void rescheduleCommand( IOATAStandardCommand
*forATACmd
);
64 IOATAStandardCommand
*findCommandWithNexus( IOATAStandardDevice
*forDevice
, UInt32 tagValue
= (UInt32
)-1 );
66 void *getDeviceData( ATAUnit forUnit
);
68 virtual IOWorkLoop
*getWorkLoop() const;
70 UInt32
getCommandCount();
71 void setCommandLimit( IOATAStandardDevice
*device
, UInt32 commandLimit
);
73 void suspendDevice( IOATAStandardDevice
*forATADevice
);
74 void resumeDevice( IOATAStandardDevice
*forATADevice
);
75 IOATAStandardDevice
*selectDevice();
77 bool getTiming( ATAUnit unit
, ATATimingProtocol
*timingProtocol
);
80 /*------------------Methods the controller subclass must implement-----------------------*/
83 * Initialize controller hardware.
85 * Note: The controller driver's configure() method will be called prior to any other
86 * methods. If the controller driver returns successfully from this method it
87 * should be ready to accept any other method call listed.
89 virtual bool configure( IOService
*provider
, ATAControllerInfo
*controllerInfo
) = 0;
92 * Driver must indicate which ATA protocols it supports.
94 virtual bool getProtocolsSupported( ATAProtocol
*protocolsSupported
) = 0;
100 virtual void executeCommand( IOATAStandardCommand
*forATACmd
) = 0;
101 virtual void cancelCommand( IOATAStandardCommand
*forATACmd
) = 0;
102 virtual void resetCommand( IOATAStandardCommand
*forATACmd
) = 0;
103 virtual void abortCommand( IOATAStandardCommand
*forATACmd
) = 0;
106 * Methods to set timing for individual devices
108 virtual bool calculateTiming( UInt32 deviceNum
, ATATiming
*timing
) = 0;
110 /*------------------Optional methods the controller subclass may implement-----------------------*/
113 * These methods notify the IOATAStandardController subclass, that a target or lun is about to be
114 * probed. The subclass should initialize its per-target or per-lun data when called at these
115 * methods. If the subclass (for some reason) wants to prevent probing of a target or lun, it
116 * can return false to the corresponding allocate*() call.
118 virtual bool allocateDevice( ATAUnit unit
);
119 virtual void deallocateDevice( ATAUnit unit
);
121 virtual void disableTimeoutOccurred();
126 virtual void enableControllerInterrupts();
127 virtual void disableControllerInterrupts();
129 /*------------------Methods private to the IOATAStandardController class----------------------*/
132 bool start( IOService
*provider
);
140 bool createDeviceNubs();
141 bool probeDeviceNubs();
142 bool registerDeviceNubs();
144 bool matchNubWithPropertyTable( IOService
*nub
, OSDictionary
*table
);
149 bool initDevice( IOATAStandardDevice
*device
);
150 void releaseDevice( IOATAStandardDevice
*device
);
152 bool workLoopRequest( WorkLoopReqType type
, UInt32 p1
=0, UInt32 p2
=0, UInt32 p3
=0 );
153 void workLoopProcessRequest( WorkLoopRequest
*workLoopReq
, void *p1
, void *p2
, void *p3
);
155 void addDevice( IOATAStandardDevice
*forDevice
);
156 void deleteDevice( IOATAStandardDevice
*forDevice
);
158 void timer( IOTimerEventSource
*);
160 void dispatchRequest();
163 bool checkBusReset();
165 void completeCommand( IOATAStandardCommand
*forATACmd
);
167 bool createWorkLoop();
168 bool configureController();
170 IOATAStandardCommand
*allocCommand( UInt32 clientDataSize
);
174 UInt32 sequenceNumber
;
178 UInt32 commandLimitSave
;
183 UInt32 busResetState
;
184 IOATAStandardCommand
*resetCmd
;
187 IOATAStandardCommand
*noDisconnectCmd
;
189 ATAControllerInfo controllerInfo
;
192 IOWorkLoop
*workLoop
;
193 IOTimerEventSource
*timerEvent
;
194 IOInterruptEventSource
*dispatchEvent
;
195 IOCommandGate
*workLoopReqGate
;