Chameleon

Chameleon Svn Source Tree

Root/branches/rewrite/i386/include/IOKit/ata/IOPCIATA.h

Source at commit 1146 created 12 years 11 months ago.
By azimutz, Sync with trunk (r1145). Add nVidia dev id's, 0DF4 for "GeForce GT 450M" (issue 99) and 1251 for "GeForce GTX 560M" (thanks to oSxFr33k for testing).
1/*
2 * Copyright (c) 1998-2008 Apple 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#ifndef _DRV_PCI_ATA_H
24#define _DRV_PCI_ATA_H
25
26#include <libkern/c++/OSObject.h>
27#include <IOKit/IOTypes.h>
28#include "IOATAController.h"
29#include <IOKit/IOMemoryCursor.h>
30#include <IOKit/IOBufferMemoryDescriptor.h>
31
32#include <IOKit/IOInterruptEventSource.h>
33
34/*! @class IOPCIATA
35 @abstract The base class for PCI-IDE ata controller family.
36 @discussion class defining the common elements of bus-mastering PCI ATA controllers which meet or at least loosely follow the pci bus mastering pci-ide controller spec. Header doc is incomplete, but source is heavily commented.
37
38*/
39
40
41
42class IOPCIATA : public IOATAController
43{
44 OSDeclareDefaultStructors(IOPCIATA);
45
46public:
47
48/*--- Overrides from IOATAController ---*/
49virtual bool init(OSDictionary * properties);
50 virtual bool start( IOService* provider );
51
52protected:
53
54// The DMA states: not in use, in use and running with additional passes needed,
55// in use on final pass, transfer complete, and failure
56enum ATADMAState
57{
58// DMA state flags
59kATADMAInactive,
60kATADMAStarting,
61kATADMAActive,
62kATADMAStatus,
63kATADMAComplete,
64kATADMAError,
65
66};
67
68enum {
69// PRD flags
70kLast_PRD =0x8000,
71kContinue_PRD = 0,
72
73};
74
75
76enum {
77mBMCmdStartOutput = 0x01, // start engine to transfer from memory to device.
78mBMCmdStartInput = (1 << 3 ) | 0x01, // start engine to transfer from device to memory
79mBMCmdStop = 0x00,// halt engine.
80};
81
82enum {
83// bus master status register definitions.
84bBMStatusSimplex = 7, // 0 = simultaneous transactions allowed. 1 = primary and secondary busses may not be active at same time.
85bBMStatusDrv1 = 6, // 1 = device 1 and bus are already configured by some other software/firmware
86bBMStatusDrv0 = 5, // 1 = device 0 and bus are already configured by some other software/firmware
87bBMStatusInt = 2,// 1 = device has asserted INTRQ and all data is flushed to/from memory.
88bBMStatusError = 1,// 1 = an error in the DMA has occured. Software clears by writing 1 to this bit.
89bBMStatusActive = 0,// 1 = DMA engine is active.
90};
91
92enum{
93
94mBMStatusSimplex = 1 << 7,
95mBMStatusDrv1 = 1 << 6,
96mBMStatusDrv0 = 1 << 5,
97mBMStatusInt = 1 << 2,
98mBMStatusError = 1 << 1,
99mBMStatusActive = 1
100};
101
102// the physical region descriptor used for the dma engine.
103struct PRD
104{
105UInt32bufferPtr;// address
106UInt16byteCount;// 16 bit byte count where 0x0000 = 64K
107UInt16flags;// 0 in flags means contine, 0x80 means stop
108};
109
110
111// descendants of this class MUST initialize these values
112// prior to activating any DMA command.
113IOATARegPtr8 _bmCommandReg;
114IOATARegPtr8 _bmStatusReg;
115IOATARegPtr32 _bmPRDAddresReg;
116
117// semaphore for DMA state
118UInt32_dmaState;
119
120// table of PRD descriptors
121PRD*_prdTable;
122IOPhysicalAddress _prdTablePhysical;
123
124IONaturalMemoryCursor*_DMACursor;
125
126// override from IOATAController
127// activate the DMA engine as per the current command
128virtual IOReturn startDMA( void );
129
130// override from IOATAController
131// safely halt the DMA engine regardless of state
132virtual IOReturn stopDMA( void );
133
134// allocate memory for the PRD descriptors.
135virtual bool allocDMAChannel(void);
136
137// fill CC with stop commands.
138virtual void initATADMAChains (PRD* descPtr);
139
140// fill out a PRD, respecting endianess
141virtual void setPRD(UInt8 *bffr, UInt16 count, PRD *tableElement, UInt16 end);
142
143// setup the CC with IO commands
144virtual IOReturn createChannelCommands(void);
145
146// deallocate memory for the DMA engine
147virtual bool freeDMAChannel(void);
148
149// clean up on device interrupt
150virtual IOReturn handleDeviceInterrupt(void);
151
152// activate the DMA engine
153virtual void activateDMAEngine(void);
154
155// shutdown the DMA engine
156virtual void stopDMAEngine(void);
157
158// safely suspend the DMA engine
159virtual void shutDownATADMA (void);
160
161// overrides
162virtual void free();
163protected:
164/*! @struct ExpansionData
165 @discussion This structure will be used to expand the capablilties of the IOPCIATA class in the future.
166 */
167 typedef struct ExpansionData
168 {
169 IOBufferMemoryDescriptor*_prdBuffer;
170 } ExpansionData;
171
172/*! @var reserved
173 Reserved for future use. (Internal use only) */
174 ExpansionData *reserved;
175
176private:
177 OSMetaClassDeclareReservedUnused(IOPCIATA, 0);
178 OSMetaClassDeclareReservedUnused(IOPCIATA, 1);
179 OSMetaClassDeclareReservedUnused(IOPCIATA, 2);
180 OSMetaClassDeclareReservedUnused(IOPCIATA, 3);
181 OSMetaClassDeclareReservedUnused(IOPCIATA, 4);
182 OSMetaClassDeclareReservedUnused(IOPCIATA, 5);
183 OSMetaClassDeclareReservedUnused(IOPCIATA, 6);
184 OSMetaClassDeclareReservedUnused(IOPCIATA, 7);
185 OSMetaClassDeclareReservedUnused(IOPCIATA, 8);
186 OSMetaClassDeclareReservedUnused(IOPCIATA, 9);
187 OSMetaClassDeclareReservedUnused(IOPCIATA, 10);
188 OSMetaClassDeclareReservedUnused(IOPCIATA, 11);
189 OSMetaClassDeclareReservedUnused(IOPCIATA, 12);
190 OSMetaClassDeclareReservedUnused(IOPCIATA, 13);
191 OSMetaClassDeclareReservedUnused(IOPCIATA, 14);
192 OSMetaClassDeclareReservedUnused(IOPCIATA, 15);
193 OSMetaClassDeclareReservedUnused(IOPCIATA, 16);
194 OSMetaClassDeclareReservedUnused(IOPCIATA, 17);
195 OSMetaClassDeclareReservedUnused(IOPCIATA, 18);
196 OSMetaClassDeclareReservedUnused(IOPCIATA, 19);
197 OSMetaClassDeclareReservedUnused(IOPCIATA, 20);
198};
199
200#endif // _DRV_PCI_ATA_H
201

Archive Download this file

Revision: 1146