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