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