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@
24 * IOATATStandardDriver.h
27 #ifndef _IOATASTANDARDDRIVER_H
28 #define _IOATASTANDARDDRIVER_H
30 class IOATAStandardDriver
: public IOATAStandardController
32 OSDeclareAbstractStructors( IOATAStandardDriver
)
35 * Methods that subclasses IOATAStandardDriver must implement.
38 virtual void writeATAReg( UInt32 regIndex
, UInt32 regValue
) = 0;
39 virtual UInt32
readATAReg( UInt32 regIndex
) = 0;
41 virtual bool selectTiming( ATAUnit deviceNum
, ATATimingProtocol timingProtocol
) = 0;
43 virtual bool programDma( IOATAStandardCommand
*cmd
);
44 virtual bool startDma( IOATAStandardCommand
*cmd
);
45 virtual bool stopDma( IOATAStandardCommand
*cmd
, UInt32
*transferCount
);
46 virtual bool resetDma();
47 virtual bool checkDmaActive();
50 * Methods that subclasses of IOATAStandardDriver can optionally implement.
52 virtual void newDeviceSelected( IOATAStandardDevice
*newDevice
);
53 virtual bool getProtocolsSupported( ATAProtocol
*forProtocol
);
56 * Methods provided to subclasses of IOATAStandardDriver.
58 virtual void interruptOccurred();
60 virtual void resetCommand( IOATAStandardCommand
*cmd
);
61 virtual void executeCommand( IOATAStandardCommand
*cmd
);
62 virtual void abortCommand( IOATAStandardCommand
*cmd
);
63 virtual void cancelCommand( IOATAStandardCommand
*cmd
);
65 /*------------------Methods private to the IOATAStandardDriver class----------------*/
68 void processATAPioInt();
69 void processATADmaInt();
70 void processATAPIPioInt();
71 void processATAPIDmaInt();
72 void processATADmaQueuedInt();
74 ATAReturnCode
readATAPIDevice( UInt32 n
);
75 ATAReturnCode
writeATAPIDevice( UInt32 n
);
76 ATAReturnCode
sendATAPIPacket( IOATAStandardCommand
*cmd
);
78 IOReturn
getIOReturnCode( ATAReturnCode code
);
80 void doProtocolSetRegs( IOATAStandardCommand
*cmd
);
81 void doATAReset( IOATAStandardCommand
*cmd
);
82 void checkATAResetComplete();
83 void doATAProtocolPio( IOATAStandardCommand
*cmd
);
84 void doATAProtocolDma( IOATAStandardCommand
*cmd
);
85 void doATAProtocolDmaQueued( IOATAStandardCommand
*cmd
);
86 void doATAPIProtocolPio( IOATAStandardCommand
*cmd
);
87 void doATAPIProtocolDma( IOATAStandardCommand
*cmd
);
88 void doProtocolNotSupported( IOATAStandardCommand
*cmd
);
90 bool selectDrive( UInt32 driveHeadReg
);
92 void completeCmd( IOATAStandardCommand
*cmd
, ATAReturnCode returnCode
, UInt32 bytesTransferred
= 0 );
93 void completeCmd( IOATAStandardCommand
*cmd
);
95 void updateCmdStatus( IOATAStandardCommand
*cmd
, ATAReturnCode returnCode
, UInt32 bytesTransferred
);
97 bool waitForStatus( UInt32 statusBitsOn
, UInt32 statusBitsOff
, UInt32 timeoutmS
);
98 bool waitForAltStatus( UInt32 statusBitsOn
, UInt32 statusBitsOff
, UInt32 timeoutmS
);
99 ATAReturnCode
waitForDRQ( UInt32 timeoutmS
);
101 bool start(IOService
*provider
);
102 IOReturn
setPowerState(unsigned long powerStateOrdinal
, IOService
* whatDevice
);
105 IOATAStandardDevice
*currentDevice
;
107 ATAProtocol currentProtocol
;
110 IOMemoryDescriptor
*xferDesc
;
113 UInt32 xferRemaining
;
116 IOTimerEventSource
*resetPollEvent
;
117 IOATAStandardCommand
*resetCmd
;
118 AbsoluteTime resetTimeout
;
120 bool wakingUpFromSleep
;