]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/pci/IOPCIDevice.h
xnu-344.49.tar.gz
[apple/xnu.git] / iokit / IOKit / pci / IOPCIDevice.h
1 /*
2 * Copyright (c) 1998-2000 Apple Computer, Inc. All rights reserved.
3 *
4 * @APPLE_LICENSE_HEADER_START@
5 *
6 * Copyright (c) 1999-2003 Apple Computer, Inc. All Rights Reserved.
7 *
8 * This file contains Original Code and/or Modifications of Original Code
9 * as defined in and that are subject to the Apple Public Source License
10 * Version 2.0 (the 'License'). You may not use this file except in
11 * compliance with the License. Please obtain a copy of the License at
12 * http://www.opensource.apple.com/apsl/ and read it before using this
13 * file.
14 *
15 * The Original Code and all software distributed under the License are
16 * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER
17 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
18 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT.
20 * Please see the License for the specific language governing rights and
21 * limitations under the License.
22 *
23 * @APPLE_LICENSE_HEADER_END@
24 */
25
26 #ifndef _IOKIT_IOPCIDEVICE_H
27 #define _IOKIT_IOPCIDEVICE_H
28
29 #warning IOPCIDevice.h moved to IOPCIFamily project
30 #warning IOPCIDevice.h will be removed from xnu; do not edit or add new usage
31
32 #include <IOKit/IOService.h>
33
34 union IOPCIAddressSpace {
35 UInt32 bits;
36 struct {
37 #if __BIG_ENDIAN__
38 unsigned int reloc:1;
39 unsigned int prefetch:1;
40 unsigned int t:1;
41 unsigned int resv:3;
42 unsigned int space:2;
43 unsigned int busNum:8;
44 unsigned int deviceNum:5;
45 unsigned int functionNum:3;
46 unsigned int registerNum:8;
47 #elif __LITTLE_ENDIAN__
48 unsigned int registerNum:8;
49 unsigned int functionNum:3;
50 unsigned int deviceNum:5;
51 unsigned int busNum:8;
52 unsigned int space:2;
53 unsigned int resv:3;
54 unsigned int t:1;
55 unsigned int prefetch:1;
56 unsigned int reloc:1;
57 #endif
58 } s;
59 };
60
61 class IOPCIDevice : public IOService
62 {
63 OSDeclareDefaultStructors(IOPCIDevice)
64
65 friend class IOPCIBridge;
66 friend class IOPCI2PCIBridge;
67
68 protected:
69 IOPCIBridge * parent;
70 IOMemoryMap * ioMap;
71 OSObject * slotNameProperty;
72
73 struct ExpansionData { };
74
75 ExpansionData *reserved;
76
77 public:
78 IOPCIAddressSpace space;
79 UInt32 * savedConfig;
80
81 public:
82
83 virtual bool attach( IOService * provider );
84 virtual void detach( IOService * provider );
85 virtual IOReturn setPowerState( unsigned long, IOService * );
86 virtual bool compareName( OSString * name, OSString ** matched = 0 ) const;
87 virtual bool matchPropertyTable( OSDictionary * table,
88 SInt32 * score );
89 virtual IOService * matchLocation( IOService * client );
90 virtual IOReturn getResources( void );
91
92 /* Config space accessors */
93
94 virtual UInt32 configRead32( IOPCIAddressSpace space, UInt8 offset );
95 virtual void configWrite32( IOPCIAddressSpace space,
96 UInt8 offset, UInt32 data );
97 virtual UInt16 configRead16( IOPCIAddressSpace space, UInt8 offset );
98 virtual void configWrite16( IOPCIAddressSpace space,
99 UInt8 offset, UInt16 data );
100 virtual UInt8 configRead8( IOPCIAddressSpace space, UInt8 offset );
101 virtual void configWrite8( IOPCIAddressSpace space,
102 UInt8 offset, UInt8 data );
103
104 virtual UInt32 configRead32( UInt8 offset );
105 virtual UInt16 configRead16( UInt8 offset );
106 virtual UInt8 configRead8( UInt8 offset );
107 virtual void configWrite32( UInt8 offset, UInt32 data );
108 virtual void configWrite16( UInt8 offset, UInt16 data );
109 virtual void configWrite8( UInt8 offset, UInt8 data );
110
111 virtual IOReturn saveDeviceState( IOOptionBits options = 0 );
112 virtual IOReturn restoreDeviceState( IOOptionBits options = 0 );
113 virtual UInt32 setConfigBits( UInt8 offset, UInt32 mask, UInt32 value );
114
115 virtual bool setMemoryEnable( bool enable );
116 virtual bool setIOEnable( bool enable, bool exclusive = false );
117 virtual bool setBusMasterEnable( bool enable );
118 virtual UInt32 findPCICapability( UInt8 capabilityID, UInt8 * offset = 0 );
119 virtual UInt8 getBusNumber( void );
120 virtual UInt8 getDeviceNumber( void );
121 virtual UInt8 getFunctionNumber( void );
122 virtual IODeviceMemory * getDeviceMemoryWithRegister( UInt8 reg );
123 virtual IOMemoryMap * mapDeviceMemoryWithRegister( UInt8 reg,
124 IOOptionBits options = 0 );
125 virtual IODeviceMemory * ioDeviceMemory( void );
126 virtual void ioWrite32( UInt16 offset, UInt32 value,
127 IOMemoryMap * map = 0 );
128 virtual void ioWrite16( UInt16 offset, UInt16 value,
129 IOMemoryMap * map = 0 );
130 virtual void ioWrite8( UInt16 offset, UInt8 value,
131 IOMemoryMap * map = 0 );
132 virtual UInt32 ioRead32( UInt16 offset, IOMemoryMap * map = 0 );
133 virtual UInt16 ioRead16( UInt16 offset, IOMemoryMap * map = 0 );
134 virtual UInt8 ioRead8( UInt16 offset, IOMemoryMap * map = 0 );
135
136 // Unused Padding
137 OSMetaClassDeclareReservedUnused(IOPCIDevice, 0);
138 OSMetaClassDeclareReservedUnused(IOPCIDevice, 1);
139 OSMetaClassDeclareReservedUnused(IOPCIDevice, 2);
140 OSMetaClassDeclareReservedUnused(IOPCIDevice, 3);
141 OSMetaClassDeclareReservedUnused(IOPCIDevice, 4);
142 OSMetaClassDeclareReservedUnused(IOPCIDevice, 5);
143 OSMetaClassDeclareReservedUnused(IOPCIDevice, 6);
144 OSMetaClassDeclareReservedUnused(IOPCIDevice, 7);
145 OSMetaClassDeclareReservedUnused(IOPCIDevice, 8);
146 OSMetaClassDeclareReservedUnused(IOPCIDevice, 9);
147 OSMetaClassDeclareReservedUnused(IOPCIDevice, 10);
148 OSMetaClassDeclareReservedUnused(IOPCIDevice, 11);
149 OSMetaClassDeclareReservedUnused(IOPCIDevice, 12);
150 OSMetaClassDeclareReservedUnused(IOPCIDevice, 13);
151 OSMetaClassDeclareReservedUnused(IOPCIDevice, 14);
152 OSMetaClassDeclareReservedUnused(IOPCIDevice, 15);
153 };
154
155 #endif /* ! _IOKIT_IOPCIDEVICE_H */