Root/
Source at commit 2055 created 11 years 10 months ago. By cosmo1t, http://forge.voodooprojects.org/p/chameleon/issues/287/#ic2184 | |
---|---|
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/IOFilterInterruptEventSource.h>␊ |
36 | #include <IOKit/pci/IOAGPDevice.h>␊ |
37 | ␊ |
38 | ␊ |
39 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */␊ |
40 | ␊ |
41 | typedef uint64_t IOPCIScalar;␊ |
42 | ␊ |
43 | struct IOPCIRange␊ |
44 | {␊ |
45 | IOPCIScalar start;␊ |
46 | IOPCIScalar size;␊ |
47 | IOPCIScalar alignment;␊ |
48 | UInt32 type;␊ |
49 | UInt32 flags;␊ |
50 | struct IOPCIRange * next;␊ |
51 | struct IOPCIRange * nextSubRange;␊ |
52 | struct IOPCIRange * subRange;␊ |
53 | };␊ |
54 | ␊ |
55 | enum {␊ |
56 | kIOPCIResourceTypeMemory = 0,␊ |
57 | kIOPCIResourceTypePrefetchMemory,␊ |
58 | kIOPCIResourceTypeIO,␊ |
59 | kIOPCIResourceTypeBusNumber,␊ |
60 | kIOPCIResourceTypeCount␊ |
61 | };␊ |
62 | ␊ |
63 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */␊ |
64 | /*!␊ |
65 | @class IOPCIBridge␊ |
66 | @abstract Base class for all PCI bridge drivers.␊ |
67 | */␊ |
68 | class IOPCIConfigurator;␊ |
69 | class IOPCIDevice;␊ |
70 | ␊ |
71 | class IOPCIBridge : public IOService␊ |
72 | {␊ |
73 | friend class IOPCIDevice;␊ |
74 | friend class IOPCIConfigurator;␊ |
75 | ␊ |
76 | OSDeclareAbstractStructors(IOPCIBridge)␊ |
77 | ␊ |
78 | private:␊ |
79 | static void initialize(void);␊ |
80 | IORegistryEntry * findMatching( OSIterator * in, IOPCIAddressSpace space );␊ |
81 | virtual bool isDTNub( IOPCIDevice * nub );␊ |
82 | bool checkProperties( IOPCIDevice * entry );␊ |
83 | ␊ |
84 | void removeDevice( IOPCIDevice * device, IOOptionBits options = 0 );␊ |
85 | IOReturn restoreMachineState( IOOptionBits options = 0);␊ |
86 | IOReturn _restoreDeviceState( IOPCIDevice * device, IOOptionBits options );␊ |
87 | IOReturn resolveLegacyInterrupts( IOService * provider, IOPCIDevice * nub );␊ |
88 | IOReturn resolveMSIInterrupts ( IOService * provider, IOPCIDevice * nub );␊ |
89 | ␊ |
90 | protected:␊ |
91 | static void nvLocation( IORegistryEntry * entry,␊ |
92 | UInt8 * busNum, UInt8 * deviceNum, UInt8 * functionNum );␊ |
93 | static SInt32 compareAddressCell( UInt32 cellCount, UInt32 cleft[], UInt32 cright[] );␊ |
94 | void checkTerminateChildren(IOService * bridgeDevice, bool eject);␊ |
95 | IOReturn setDeviceASPMBits(IOPCIDevice * device, IOOptionBits state);␊ |
96 | ␊ |
97 | IORangeAllocator * bridgeMemoryRanges;␊ |
98 | IORangeAllocator * bridgeIORanges;␊ |
99 | ␊ |
100 | /*! @struct ExpansionData␊ |
101 | @discussion This structure will be used to expand the capablilties of the IOPCIBridge in the future.␊ |
102 | */ ␊ |
103 | struct ExpansionData␊ |
104 | {␊ |
105 | friend class IOPCIConfigurator;␊ |
106 | IORangeAllocator * cardBusMemoryRanges;␊ |
107 | IOPCIRange * rangeLists[kIOPCIResourceTypeCount];␊ |
108 | };␊ |
109 | ␊ |
110 | /*! @var reserved␊ |
111 | Reserved for future use. (Internal use only) ␊ |
112 | */␊ |
113 | ExpansionData *reserved;␊ |
114 | ␊ |
115 | protected:␊ |
116 | public:␊ |
117 | virtual void probeBus( IOService * provider, UInt8 busNum );␊ |
118 | ␊ |
119 | virtual UInt8 firstBusNum( void );␊ |
120 | virtual UInt8 lastBusNum( void );␊ |
121 | ␊ |
122 | virtual void spaceFromProperties( OSDictionary * propTable,␊ |
123 | IOPCIAddressSpace * space );␊ |
124 | virtual OSDictionary * constructProperties( IOPCIAddressSpace space );␊ |
125 | ␊ |
126 | virtual IOPCIDevice * createNub( OSDictionary * from );␊ |
127 | ␊ |
128 | virtual bool initializeNub( IOPCIDevice * nub, OSDictionary * from );␊ |
129 | ␊ |
130 | virtual bool publishNub( IOPCIDevice * nub, UInt32 index );␊ |
131 | ␊ |
132 | virtual bool addBridgeMemoryRange( IOPhysicalAddress start,␊ |
133 | IOPhysicalLength length, bool host );␊ |
134 | ␊ |
135 | virtual bool addBridgeIORange( IOByteCount start, IOByteCount length );␊ |
136 | ␊ |
137 | virtual bool constructRange( IOPCIAddressSpace * flags,␊ |
138 | IOPhysicalAddress phys, IOPhysicalLength len,␊ |
139 | OSArray * array );␊ |
140 | ␊ |
141 | virtual bool matchNubWithPropertyTable( IOService * nub,␊ |
142 | OSDictionary * propertyTable,␊ |
143 | SInt32 * score );␊ |
144 | ␊ |
145 | virtual bool compareNubName( const IOService * nub, OSString * name,␊ |
146 | OSString ** matched = 0 ) const;␊ |
147 | ␊ |
148 | virtual bool pciMatchNub( IOPCIDevice * nub,␊ |
149 | OSDictionary * table, SInt32 * score);␊ |
150 | ␊ |
151 | virtual bool matchKeys( IOPCIDevice * nub, const char * keys,␊ |
152 | UInt32 defaultMask, UInt8 regNum );␊ |
153 | ␊ |
154 | virtual IOReturn getNubResources( IOService * nub );␊ |
155 | ␊ |
156 | virtual IOReturn getNubAddressing( IOPCIDevice * nub );␊ |
157 | ␊ |
158 | virtual IOReturn getDTNubAddressing( IOPCIDevice * nub );␊ |
159 | ␊ |
160 | public:␊ |
161 | virtual void free( void );␊ |
162 | ␊ |
163 | virtual bool start( IOService * provider );␊ |
164 | ␊ |
165 | virtual void stop( IOService * provider );␊ |
166 | ␊ |
167 | virtual bool configure( IOService * provider );␊ |
168 | ␊ |
169 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * */␊ |
170 | ␊ |
171 | virtual IODeviceMemory * ioDeviceMemory( void ) = 0;␊ |
172 | ␊ |
173 | virtual UInt32 configRead32( IOPCIAddressSpace space, UInt8 offset ) = 0;␊ |
174 | virtual void configWrite32( IOPCIAddressSpace space,␊ |
175 | UInt8 offset, UInt32 data ) = 0;␊ |
176 | virtual UInt16 configRead16( IOPCIAddressSpace space, UInt8 offset ) = 0;␊ |
177 | virtual void configWrite16( IOPCIAddressSpace space,␊ |
178 | UInt8 offset, UInt16 data ) = 0;␊ |
179 | virtual UInt8 configRead8( IOPCIAddressSpace space, UInt8 offset ) = 0;␊ |
180 | virtual void configWrite8( IOPCIAddressSpace space,␊ |
181 | UInt8 offset, UInt8 data ) = 0;␊ |
182 | ␊ |
183 | virtual IOPCIAddressSpace getBridgeSpace( void ) = 0;␊ |
184 | ␊ |
185 | virtual UInt32 findPCICapability( IOPCIAddressSpace space,␊ |
186 | UInt8 capabilityID, UInt8 * offset = 0 );␊ |
187 | ␊ |
188 | virtual IOReturn setDevicePowerState( IOPCIDevice * device,␊ |
189 | unsigned long whatToDo );␊ |
190 | virtual IOReturn saveDeviceState( IOPCIDevice * device,␊ |
191 | IOOptionBits options = 0 );␊ |
192 | virtual IOReturn restoreDeviceState( IOPCIDevice * device,␊ |
193 | IOOptionBits options = 0 );␊ |
194 | ␊ |
195 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * */␊ |
196 | ␊ |
197 | virtual IOReturn createAGPSpace( IOAGPDevice * master,␊ |
198 | IOOptionBits options,␊ |
199 | IOPhysicalAddress * address, ␊ |
200 | IOPhysicalLength * length );␊ |
201 | ␊ |
202 | virtual IOReturn destroyAGPSpace( IOAGPDevice * master );␊ |
203 | ␊ |
204 | virtual IORangeAllocator * getAGPRangeAllocator( IOAGPDevice * master );␊ |
205 | ␊ |
206 | virtual IOOptionBits getAGPStatus( IOAGPDevice * master,␊ |
207 | IOOptionBits options = 0 );␊ |
208 | virtual IOReturn resetAGPDevice( IOAGPDevice * master,␊ |
209 | IOOptionBits options = 0 );␊ |
210 | ␊ |
211 | virtual IOReturn getAGPSpace( IOAGPDevice * master,␊ |
212 | IOPhysicalAddress * address, ␊ |
213 | IOPhysicalLength * length );␊ |
214 | ␊ |
215 | virtual IOReturn commitAGPMemory( IOAGPDevice * master, ␊ |
216 | IOMemoryDescriptor * memory,␊ |
217 | IOByteCount agpOffset,␊ |
218 | IOOptionBits options );␊ |
219 | ␊ |
220 | virtual IOReturn releaseAGPMemory( IOAGPDevice * master, ␊ |
221 | IOMemoryDescriptor * memory, ␊ |
222 | IOByteCount agpOffset,␊ |
223 | IOOptionBits options );␊ |
224 | ␊ |
225 | protected:␊ |
226 | OSMetaClassDeclareReservedUsed(IOPCIBridge, 0);␊ |
227 | virtual bool addBridgePrefetchableMemoryRange( IOPhysicalAddress start,␊ |
228 | IOPhysicalLength length,␊ |
229 | bool host );␊ |
230 | ␊ |
231 | OSMetaClassDeclareReservedUsed(IOPCIBridge, 1);␊ |
232 | virtual UInt32 extendedFindPCICapability( IOPCIAddressSpace space,␊ |
233 | UInt32 capabilityID, IOByteCount * offset = 0 );␊ |
234 | ␊ |
235 | OSMetaClassDeclareReservedUsed(IOPCIBridge, 2);␊ |
236 | virtual IOReturn setDeviceASPMState(IOPCIDevice * device,␊ |
237 | IOService * client, IOOptionBits state);␊ |
238 | ␊ |
239 | // Unused Padding␊ |
240 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 3);␊ |
241 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 4);␊ |
242 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 5);␊ |
243 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 6);␊ |
244 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 7);␊ |
245 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 8);␊ |
246 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 9);␊ |
247 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 10);␊ |
248 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 11);␊ |
249 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 12);␊ |
250 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 13);␊ |
251 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 14);␊ |
252 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 15);␊ |
253 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 16);␊ |
254 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 17);␊ |
255 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 18);␊ |
256 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 19);␊ |
257 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 20);␊ |
258 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 21);␊ |
259 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 22);␊ |
260 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 23);␊ |
261 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 24);␊ |
262 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 25);␊ |
263 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 26);␊ |
264 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 27);␊ |
265 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 28);␊ |
266 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 29);␊ |
267 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 30);␊ |
268 | OSMetaClassDeclareReservedUnused(IOPCIBridge, 31);␊ |
269 | ␊ |
270 | ␊ |
271 | ␊ |
272 | };␊ |
273 | ␊ |
274 | /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */␊ |
275 | ␊ |
276 | #define kIOPCIBridgeRegs (32)␊ |
277 | /*!␊ |
278 | @class IOPCI2PCIBridge␊ |
279 | @abstract Base class for all PCI-to-PCI bridge drivers.␊ |
280 | */␊ |
281 | ␊ |
282 | class IOPCI2PCIBridge : public IOPCIBridge␊ |
283 | {␊ |
284 | OSDeclareDefaultStructors(IOPCI2PCIBridge)␊ |
285 | ␊ |
286 | private:␊ |
287 | ␊ |
288 | IOPCIDevice * bridgeDevice;␊ |
289 | UInt32 bridgeState[kIOPCIBridgeRegs];␊ |
290 | ␊ |
291 | protected:␊ |
292 | /*! @struct ExpansionData␊ |
293 | @discussion This structure will be used to expand the capablilties of the IOWorkLoop in the future.␊ |
294 | */ ␊ |
295 | struct ExpansionData␊ |
296 | {␊ |
297 | // /hotp␊ |
298 | IOByteCount xpressCapability;␊ |
299 | IOFilterInterruptEventSource * bridgeInterruptSource;␊ |
300 | IOWorkLoop * workLoop;␊ |
301 | uint32_t hotplugCount;␊ |
302 | uint8_t presence;␊ |
303 | uint8_t waitingLinkEnable;␊ |
304 | uint8_t linkChangeOnly;␊ |
305 | uint8_t interruptEnablePending;␊ |
306 | uint8_t __reserved[4];␊ |
307 | // hotp/␊ |
308 | };␊ |
309 | ␊ |
310 | /*! @var reserved␊ |
311 | Reserved for future use. (Internal use only) */␊ |
312 | ExpansionData *reserved;␊ |
313 | public:␊ |
314 | ␊ |
315 | virtual UInt8 firstBusNum( void );␊ |
316 | virtual UInt8 lastBusNum( void );␊ |
317 | ␊ |
318 | public:␊ |
319 | virtual void free();␊ |
320 | ␊ |
321 | virtual bool serializeProperties( OSSerialize * serialize ) const;␊ |
322 | ␊ |
323 | virtual IOService * probe( IOService * provider,␊ |
324 | SInt32 * score );␊ |
325 | ␊ |
326 | virtual bool start( IOService * provider );␊ |
327 | ␊ |
328 | virtual void stop( IOService * provider );␊ |
329 | ␊ |
330 | virtual bool configure( IOService * provider );␊ |
331 | ␊ |
332 | virtual void probeBus( IOService * provider, UInt8 busNum );␊ |
333 | ␊ |
334 | virtual IOReturn requestProbe( IOOptionBits options );␊ |
335 | ␊ |
336 | virtual void saveBridgeState( void );␊ |
337 | ␊ |
338 | virtual void restoreBridgeState( void );␊ |
339 | ␊ |
340 | IOReturn setPowerState( unsigned long powerState,␊ |
341 | IOService * whatDevice );␊ |
342 | ␊ |
343 | virtual bool publishNub( IOPCIDevice * nub, UInt32 index );␊ |
344 | ␊ |
345 | virtual IODeviceMemory * ioDeviceMemory( void );␊ |
346 | ␊ |
347 | virtual IOPCIAddressSpace getBridgeSpace( void );␊ |
348 | ␊ |
349 | virtual UInt32 configRead32( IOPCIAddressSpace space, UInt8 offset );␊ |
350 | virtual void configWrite32( IOPCIAddressSpace space,␊ |
351 | UInt8 offset, UInt32 data );␊ |
352 | virtual UInt16 configRead16( IOPCIAddressSpace space, UInt8 offset );␊ |
353 | virtual void configWrite16( IOPCIAddressSpace space,␊ |
354 | UInt8 offset, UInt16 data );␊ |
355 | virtual UInt8 configRead8( IOPCIAddressSpace space, UInt8 offset );␊ |
356 | virtual void configWrite8( IOPCIAddressSpace space,␊ |
357 | UInt8 offset, UInt8 data );␊ |
358 | ␊ |
359 | virtual IOReturn setDeviceASPMState(IOPCIDevice * device,␊ |
360 | IOService * client, IOOptionBits state);␊ |
361 | ␊ |
362 | // Unused Padding␊ |
363 | OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 0);␊ |
364 | OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 1);␊ |
365 | OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 2);␊ |
366 | OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 3);␊ |
367 | OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 4);␊ |
368 | OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 5);␊ |
369 | OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 6);␊ |
370 | OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 7);␊ |
371 | OSMetaClassDeclareReservedUnused(IOPCI2PCIBridge, 8);␊ |
372 | ␊ |
373 | protected:␊ |
374 | bool filterInterrupt( IOFilterInterruptEventSource * source);␊ |
375 | ␊ |
376 | void handleInterrupt( IOInterruptEventSource * source,␊ |
377 | int count );␊ |
378 | ␊ |
379 | };␊ |
380 | ␊ |
381 | #endif /* ! _IOKIT_IOPCIBRIDGE_H */␊ |
382 |