2 * Copyright (c) 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@
23 * Copyright (c) 2000 Apple Computer, Inc. All rights reserved.
25 * AppleATAPIIX.h - ATA controller driver for Intel PIIX/PIIX3/PIIX4.
31 #ifndef _APPLEATAPIIX_H
32 #define _APPLEATAPIIX_H
34 #include <IOKit/IOTimerEventSource.h>
35 #include <IOKit/IOMemoryCursor.h>
36 #include <IOKit/pci/IOPCIDevice.h>
37 #include <libkern/OSByteOrder.h>
39 #include <IOKit/ata/IOATAStandardInterface.h>
40 #include "AppleATAPIIXRegs.h"
41 #include "AppleATAPIIXTiming.h"
43 class AppleATAPIIX
: public IOATAStandardDriver
45 OSDeclareDefaultStructors( AppleATAPIIX
)
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
;
64 * Internal (private) functions.
66 bool _getIDERanges(IOPCIDevice
* provider
);
67 bool _getBMRange(IOPCIDevice
* provider
);
68 bool _allocatePRDTable();
69 void _deallocatePRDTable();
71 bool _readPCIConfigSpace(UInt8
* configSpace
);
72 bool _writePCIConfigSpace(UInt8
* configSpace
);
73 bool _selectTiming(UInt32 unit
,
74 PIIXProtocol timingProtocol
,
81 static void initialize();
84 * Returns the IDE channel for the current driver instance.
86 static int PIIXGetChannel(IOPCIDevice
* provider
);
89 * Functions defined by our superclass that we must override.
91 void writeATAReg(UInt32 regIndex
, UInt32 regValue
);
93 UInt32
readATAReg(UInt32 regIndex
);
97 bool configure(IOService
* forProvider
,
98 ATAControllerInfo
* controllerInfo
);
100 bool createWorkLoop(IOWorkLoop
** workLoop
);
102 bool provideProtocols(enum ATAProtocol
* protocolsSupported
);
104 bool provideTimings(UInt32
* numTimings
,
105 ATATiming
* timingsSupported
);
107 bool calculateTiming(UInt32 deviceNum
, ATATiming
* pTiming
);
109 bool selectTiming(UInt32 unitNum
,
110 ATATimingProtocol timingProtocol
);
112 void disableControllerInterrupts();
113 void enableControllerInterrupts();
115 void ataTimer(IOTimerEventSource
* sender
);
118 * Functions that must be implemented by a bus-master controller.
120 bool programDma(IOATAStandardCommand
* cmd
);
121 bool startDma(IOATAStandardCommand
* cmd
);
122 bool stopDma(IOATAStandardCommand
* cmd
, UInt32
* transferCount
);
125 * Miscellaneous functions.
127 void interruptOccurred();
130 #endif /* !_APPLEATAPIIX_H */