]>
Commit | Line | Data |
---|---|---|
1c79356b A |
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 | * IOATATStandardDriver.h | |
25 | * | |
26 | */ | |
27 | #ifndef _IOATASTANDARDDRIVER_H | |
28 | #define _IOATASTANDARDDRIVER_H | |
29 | ||
30 | class IOATAStandardDriver : public IOATAStandardController | |
31 | { | |
32 | OSDeclareAbstractStructors( IOATAStandardDriver ) | |
33 | ||
34 | /* | |
35 | * Methods that subclasses IOATAStandardDriver must implement. | |
36 | */ | |
37 | protected: | |
38 | virtual void writeATAReg( UInt32 regIndex, UInt32 regValue ) = 0; | |
39 | virtual UInt32 readATAReg( UInt32 regIndex ) = 0; | |
40 | ||
41 | virtual bool selectTiming( ATAUnit deviceNum, ATATimingProtocol timingProtocol ) = 0; | |
42 | ||
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(); | |
48 | ||
49 | /* | |
50 | * Methods that subclasses of IOATAStandardDriver can optionally implement. | |
51 | */ | |
52 | virtual void newDeviceSelected( IOATAStandardDevice *newDevice ); | |
53 | virtual bool getProtocolsSupported( ATAProtocol *forProtocol ); | |
54 | ||
55 | /* | |
56 | * Methods provided to subclasses of IOATAStandardDriver. | |
57 | */ | |
58 | virtual void interruptOccurred(); | |
59 | ||
60 | virtual void resetCommand( IOATAStandardCommand *cmd ); | |
61 | virtual void executeCommand( IOATAStandardCommand *cmd ); | |
62 | virtual void abortCommand( IOATAStandardCommand *cmd ); | |
63 | virtual void cancelCommand( IOATAStandardCommand *cmd ); | |
64 | ||
65 | /*------------------Methods private to the IOATAStandardDriver class----------------*/ | |
66 | ||
67 | private: | |
68 | void processATAPioInt(); | |
69 | void processATADmaInt(); | |
70 | void processATAPIPioInt(); | |
71 | void processATAPIDmaInt(); | |
72 | void processATADmaQueuedInt(); | |
73 | ||
74 | ATAReturnCode readATAPIDevice( UInt32 n ); | |
75 | ATAReturnCode writeATAPIDevice( UInt32 n ); | |
76 | ATAReturnCode sendATAPIPacket( IOATAStandardCommand *cmd ); | |
77 | ||
78 | IOReturn getIOReturnCode( ATAReturnCode code ); | |
79 | ||
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 ); | |
89 | ||
90 | bool selectDrive( UInt32 driveHeadReg ); | |
91 | ||
92 | void completeCmd( IOATAStandardCommand *cmd, ATAReturnCode returnCode, UInt32 bytesTransferred = 0 ); | |
93 | void completeCmd( IOATAStandardCommand *cmd ); | |
94 | ||
95 | void updateCmdStatus( IOATAStandardCommand *cmd, ATAReturnCode returnCode, UInt32 bytesTransferred ); | |
96 | ||
97 | bool waitForStatus( UInt32 statusBitsOn, UInt32 statusBitsOff, UInt32 timeoutmS ); | |
98 | bool waitForAltStatus( UInt32 statusBitsOn, UInt32 statusBitsOff, UInt32 timeoutmS ); | |
99 | ATAReturnCode waitForDRQ( UInt32 timeoutmS ); | |
100 | ||
101 | bool start(IOService *provider); | |
102 | IOReturn setPowerState(unsigned long powerStateOrdinal, IOService* whatDevice); | |
103 | ||
104 | protected: | |
105 | IOATAStandardDevice *currentDevice; | |
106 | ATAUnit currentUnit; | |
107 | ATAProtocol currentProtocol; | |
108 | ||
109 | private: | |
110 | IOMemoryDescriptor *xferDesc; | |
111 | bool xferIsWrite; | |
112 | UInt32 xferCount; | |
113 | UInt32 xferRemaining; | |
114 | bool dmaActive; | |
115 | ||
116 | IOTimerEventSource *resetPollEvent; | |
117 | IOATAStandardCommand *resetCmd; | |
118 | AbsoluteTime resetTimeout; | |
119 | ||
120 | bool wakingUpFromSleep; | |
121 | }; | |
122 | ||
123 | ||
124 | #endif |