]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/pci/IOPCIBridge.h
xnu-344.23.tar.gz
[apple/xnu.git] / iokit / IOKit / pci / IOPCIBridge.h
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 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
24 *
25 * HISTORY
26 *
27 */
28
29
30 #ifndef _IOKIT_IOPCIBRIDGE_H
31 #define _IOKIT_IOPCIBRIDGE_H
32
33 #include <IOKit/IOService.h>
34 #include <IOKit/IODeviceMemory.h>
35 #include <IOKit/pci/IOAGPDevice.h>
36
37
38 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
39
40 class IOPCIBridge : public IOService
41 {
42 friend class IOPCIDevice;
43
44 OSDeclareAbstractStructors(IOPCIBridge)
45
46 private:
47 IORegistryEntry * findMatching( OSIterator * in, IOPCIAddressSpace space );
48 void publishNubs( OSIterator * kids, UInt32 index );
49 virtual bool isDTNub( IOPCIDevice * nub );
50 static void nvLocation( IORegistryEntry * entry,
51 UInt8 * busNum, UInt8 * deviceNum, UInt8 * functionNum );
52
53 protected:
54 IORangeAllocator * bridgeMemoryRanges;
55 IORangeAllocator * bridgeIORanges;
56
57 /*! @struct ExpansionData
58 @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
59 */
60 struct ExpansionData { };
61
62 /*! @var reserved
63 Reserved for future use. (Internal use only) */
64 ExpansionData *reserved;
65
66 protected:
67 virtual void probeBus( IOService * provider, UInt8 busNum );
68
69 virtual UInt8 firstBusNum( void );
70 virtual UInt8 lastBusNum( void );
71
72 virtual void spaceFromProperties( OSDictionary * propTable,
73 IOPCIAddressSpace * space );
74 virtual OSDictionary * constructProperties( IOPCIAddressSpace space );
75
76 virtual IOPCIDevice * createNub( OSDictionary * from );
77
78 virtual bool initializeNub( IOPCIDevice * nub, OSDictionary * from );
79
80 virtual bool publishNub( IOPCIDevice * nub, UInt32 index );
81
82 virtual bool addBridgeMemoryRange( IOPhysicalAddress start,
83 IOPhysicalLength length, bool host );
84
85 virtual bool addBridgeIORange( IOByteCount start, IOByteCount length );
86
87 virtual bool constructRange( IOPCIAddressSpace * flags,
88 IOPhysicalAddress phys, IOPhysicalLength len,
89 OSArray * array );
90
91 virtual bool matchNubWithPropertyTable( IOService * nub,
92 OSDictionary * propertyTable,
93 SInt32 * score );
94
95 virtual bool compareNubName( const IOService * nub, OSString * name,
96 OSString ** matched = 0 ) const;
97
98 virtual bool pciMatchNub( IOPCIDevice * nub,
99 OSDictionary * table, SInt32 * score);
100
101 virtual bool matchKeys( IOPCIDevice * nub, const char * keys,
102 UInt32 defaultMask, UInt8 regNum );
103
104 virtual IOReturn getNubResources( IOService * nub );
105
106 virtual IOReturn getNubAddressing( IOPCIDevice * nub );
107
108 virtual IOReturn getDTNubAddressing( IOPCIDevice * nub );
109
110 public:
111
112 virtual bool start( IOService * provider );
113
114 virtual bool configure( IOService * provider );
115
116 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
117
118 virtual IODeviceMemory * ioDeviceMemory( void ) = 0;
119
120 virtual UInt32 configRead32( IOPCIAddressSpace space, UInt8 offset ) = 0;
121 virtual void configWrite32( IOPCIAddressSpace space,
122 UInt8 offset, UInt32 data ) = 0;
123 virtual UInt16 configRead16( IOPCIAddressSpace space, UInt8 offset ) = 0;
124 virtual void configWrite16( IOPCIAddressSpace space,
125 UInt8 offset, UInt16 data ) = 0;
126 virtual UInt8 configRead8( IOPCIAddressSpace space, UInt8 offset ) = 0;
127 virtual void configWrite8( IOPCIAddressSpace space,
128 UInt8 offset, UInt8 data ) = 0;
129
130 virtual IOPCIAddressSpace getBridgeSpace( void ) = 0;
131
132 virtual UInt32 findPCICapability( IOPCIAddressSpace space,
133 UInt8 capabilityID, UInt8 * offset = 0 );
134
135 virtual IOReturn setDevicePowerState( IOPCIDevice * device,
136 unsigned long whatToDo );
137 virtual IOReturn saveDeviceState( IOPCIDevice * device,
138 IOOptionBits options = 0 );
139 virtual IOReturn restoreDeviceState( IOPCIDevice * device,
140 IOOptionBits options = 0 );
141
142 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * */
143
144 virtual IOReturn createAGPSpace( IOAGPDevice * master,
145 IOOptionBits options,
146 IOPhysicalAddress * address,
147 IOPhysicalLength * length );
148
149 virtual IOReturn destroyAGPSpace( IOAGPDevice * master );
150
151 virtual IORangeAllocator * getAGPRangeAllocator( IOAGPDevice * master );
152
153 virtual IOOptionBits getAGPStatus( IOAGPDevice * master,
154 IOOptionBits options = 0 );
155 virtual IOReturn resetAGPDevice( IOAGPDevice * master,
156 IOOptionBits options = 0 );
157
158 virtual IOReturn getAGPSpace( IOAGPDevice * master,
159 IOPhysicalAddress * address,
160 IOPhysicalLength * length );
161
162 virtual IOReturn commitAGPMemory( IOAGPDevice * master,
163 IOMemoryDescriptor * memory,
164 IOByteCount agpOffset,
165 IOOptionBits options );
166
167 virtual IOReturn releaseAGPMemory( IOAGPDevice * master,
168 IOMemoryDescriptor * memory,
169 IOByteCount agpOffset,
170 IOOptionBits options );
171
172 // Unused Padding
173 OSMetaClassDeclareReservedUnused(IOPCIBridge, 0);
174 OSMetaClassDeclareReservedUnused(IOPCIBridge, 1);
175 OSMetaClassDeclareReservedUnused(IOPCIBridge, 2);
176 OSMetaClassDeclareReservedUnused(IOPCIBridge, 3);
177 OSMetaClassDeclareReservedUnused(IOPCIBridge, 4);
178 OSMetaClassDeclareReservedUnused(IOPCIBridge, 5);
179 OSMetaClassDeclareReservedUnused(IOPCIBridge, 6);
180 OSMetaClassDeclareReservedUnused(IOPCIBridge, 7);
181 OSMetaClassDeclareReservedUnused(IOPCIBridge, 8);
182 OSMetaClassDeclareReservedUnused(IOPCIBridge, 9);
183 OSMetaClassDeclareReservedUnused(IOPCIBridge, 10);
184 OSMetaClassDeclareReservedUnused(IOPCIBridge, 11);
185 OSMetaClassDeclareReservedUnused(IOPCIBridge, 12);
186 OSMetaClassDeclareReservedUnused(IOPCIBridge, 13);
187 OSMetaClassDeclareReservedUnused(IOPCIBridge, 14);
188 OSMetaClassDeclareReservedUnused(IOPCIBridge, 15);
189 OSMetaClassDeclareReservedUnused(IOPCIBridge, 16);
190 OSMetaClassDeclareReservedUnused(IOPCIBridge, 17);
191 OSMetaClassDeclareReservedUnused(IOPCIBridge, 18);
192 OSMetaClassDeclareReservedUnused(IOPCIBridge, 19);
193 OSMetaClassDeclareReservedUnused(IOPCIBridge, 20);
194 OSMetaClassDeclareReservedUnused(IOPCIBridge, 21);
195 OSMetaClassDeclareReservedUnused(IOPCIBridge, 22);
196 OSMetaClassDeclareReservedUnused(IOPCIBridge, 23);
197 OSMetaClassDeclareReservedUnused(IOPCIBridge, 24);
198 OSMetaClassDeclareReservedUnused(IOPCIBridge, 25);
199 OSMetaClassDeclareReservedUnused(IOPCIBridge, 26);
200 OSMetaClassDeclareReservedUnused(IOPCIBridge, 27);
201 OSMetaClassDeclareReservedUnused(IOPCIBridge, 28);
202 OSMetaClassDeclareReservedUnused(IOPCIBridge, 29);
203 OSMetaClassDeclareReservedUnused(IOPCIBridge, 30);
204 OSMetaClassDeclareReservedUnused(IOPCIBridge, 31);
205 };
206
207 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
208
209 #define kIOPCIBridgeRegs (32)
210
211 class IOPCI2PCIBridge : public IOPCIBridge
212 {
213 OSDeclareDefaultStructors(IOPCI2PCIBridge)
214
215 private:
216
217 IOPCIDevice * bridgeDevice;
218 UInt32 bridgeState[kIOPCIBridgeRegs];
219
220 protected:
221 /*! @struct ExpansionData
222 @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.
223 */
224 struct ExpansionData { };
225
226 /*! @var reserved
227 Reserved for future use. (Internal use only) */
228 ExpansionData *reserved;
229
230 virtual UInt8 firstBusNum( void );
231 virtual UInt8 lastBusNum( void );
232
233 public:
234 virtual IOService * probe( IOService * provider,
235 SInt32 * score );
236
237 virtual bool configure( IOService * provider );
238
239 virtual void saveBridgeState( void );
240
241 virtual void restoreBridgeState( void );
242
243 virtual bool publishNub( IOPCIDevice * nub, UInt32 index );
244
245 virtual IODeviceMemory * ioDeviceMemory( void );
246
247 virtual IOPCIAddressSpace getBridgeSpace( void );
248
249 virtual UInt32 configRead32( IOPCIAddressSpace space, UInt8 offset );
250 virtual void configWrite32( IOPCIAddressSpace space,
251 UInt8 offset, UInt32 data );
252 virtual UInt16 configRead16( IOPCIAddressSpace space, UInt8 offset );
253 virtual void configWrite16( IOPCIAddressSpace space,
254 UInt8 offset, UInt16 data );
255 virtual UInt8 configRead8( IOPCIAddressSpace space, UInt8 offset );
256 virtual void configWrite8( IOPCIAddressSpace space,
257 UInt8 offset, UInt8 data );
258
259 // Unused Padding
260 OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 0);
261 OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 1);
262 OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 2);
263 OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 3);
264 OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 4);
265 OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 5);
266 OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 6);
267 OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 7);
268 OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 8);
269 };
270
271 #endif /* ! _IOKIT_IOPCIBRIDGE_H */