]> git.saurik.com Git - apple/xnu.git/blob - iokit/Drivers/ata/drvApplePIIXATA/AppleATAPIIX.h
xnu-201.42.3.tar.gz
[apple/xnu.git] / iokit / Drivers / ata / drvApplePIIXATA / AppleATAPIIX.h
1 /*
2 * Copyright (c) 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 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
24 *
25 * AppleATAPIIX.h - ATA controller driver for Intel PIIX/PIIX3/PIIX4.
26 *
27 * HISTORY
28 *
29 */
30
31 #ifndef _APPLEATAPIIX_H
32 #define _APPLEATAPIIX_H
33
34 #include <IOKit/IOTimerEventSource.h>
35 #include <IOKit/IOMemoryCursor.h>
36 #include <IOKit/pci/IOPCIDevice.h>
37 #include <libkern/OSByteOrder.h>
38
39 #include <IOKit/ata/IOATAStandardInterface.h>
40 #include "AppleATAPIIXRegs.h"
41 #include "AppleATAPIIXTiming.h"
42
43 class AppleATAPIIX : public IOATAStandardDriver
44 {
45 OSDeclareDefaultStructors( AppleATAPIIX )
46
47 protected:
48 IOPCIDevice * provider; // our provider
49 UInt32 pciCFID; // our PCI vendor/device ID
50 UInt32 channel; // IDE channel
51 UInt16 ioCmdRange; // command block
52 UInt16 ioCtlRange; // control block
53 UInt16 ioBMRange; // bus-master register block
54 UInt32 dmaReqLength; // transaction state
55 bool dmaIsWrite; // transaction state
56 prdEntry_t * prdTable; // physical region descriptor table
57 IOPhysicalAddress prdTablePhys; // physical address of prdTable
58 PIIXSelectedTimings timings[2]; // drive0 and drive1 timings
59 IOLittleMemoryCursor * prdCursor; // request -> scatter-gather list
60 IOTimerEventSource * timerEventSource;
61 IOInterruptEventSource * interruptEventSource;
62
63 /*
64 * Internal (private) functions.
65 */
66 bool _getIDERanges(IOPCIDevice * provider);
67 bool _getBMRange(IOPCIDevice * provider);
68 bool _allocatePRDTable();
69 void _deallocatePRDTable();
70 bool _resetTimings();
71 bool _readPCIConfigSpace(UInt8 * configSpace);
72 bool _writePCIConfigSpace(UInt8 * configSpace);
73 bool _selectTiming(UInt32 unit,
74 PIIXProtocol timingProtocol,
75 UInt8 * pciConfig);
76
77 public:
78 /*
79 * Class initializer.
80 */
81 static void initialize();
82
83 /*
84 * Returns the IDE channel for the current driver instance.
85 */
86 static int PIIXGetChannel(IOPCIDevice * provider);
87
88 /*
89 * Functions defined by our superclass that we must override.
90 */
91 void writeATAReg(UInt32 regIndex, UInt32 regValue);
92
93 UInt32 readATAReg(UInt32 regIndex);
94
95 void free();
96
97 bool configure(IOService * forProvider,
98 ATAControllerInfo * controllerInfo);
99
100 bool createWorkLoop(IOWorkLoop ** workLoop);
101
102 bool provideProtocols(enum ATAProtocol * protocolsSupported);
103
104 bool provideTimings(UInt32 * numTimings,
105 ATATiming * timingsSupported);
106
107 bool calculateTiming(UInt32 deviceNum, ATATiming * pTiming);
108
109 bool selectTiming(UInt32 unitNum,
110 ATATimingProtocol timingProtocol);
111
112 void disableControllerInterrupts();
113 void enableControllerInterrupts();
114
115 void ataTimer(IOTimerEventSource * sender);
116
117 /*
118 * Functions that must be implemented by a bus-master controller.
119 */
120 bool programDma(IOATAStandardCommand * cmd);
121 bool startDma(IOATAStandardCommand * cmd);
122 bool stopDma(IOATAStandardCommand * cmd, UInt32 * transferCount);
123
124 /*
125 * Miscellaneous functions.
126 */
127 void interruptOccurred();
128 };
129
130 #endif /* !_APPLEATAPIIX_H */