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