]> git.saurik.com Git - apple/xnu.git/blob - iokit/IOKit/pci/IOPCIDevice.h
xnu-792.21.3.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 IOPCIDevice : public IOService
65 {
66 OSDeclareDefaultStructors(IOPCIDevice)
67
68 friend class IOPCIBridge;
69 friend class IOPCI2PCIBridge;
70
71 protected:
72 IOPCIBridge * parent;
73 IOMemoryMap * ioMap;
74 OSObject * slotNameProperty;
75
76 struct ExpansionData { };
77
78 ExpansionData *reserved;
79
80 public:
81 IOPCIAddressSpace space;
82 UInt32 * savedConfig;
83
84 public:
85
86 virtual bool attach( IOService * provider );
87 virtual void detach( IOService * provider );
88 virtual IOReturn setPowerState( unsigned long, IOService * );
89 virtual bool compareName( OSString * name, OSString ** matched = 0 ) const;
90 virtual bool matchPropertyTable( OSDictionary * table,
91 SInt32 * score );
92 virtual IOService * matchLocation( IOService * client );
93 virtual IOReturn getResources( void );
94
95 /* Config space accessors */
96
97 virtual UInt32 configRead32( IOPCIAddressSpace space, UInt8 offset );
98 virtual void configWrite32( IOPCIAddressSpace space,
99 UInt8 offset, UInt32 data );
100 virtual UInt16 configRead16( IOPCIAddressSpace space, UInt8 offset );
101 virtual void configWrite16( IOPCIAddressSpace space,
102 UInt8 offset, UInt16 data );
103 virtual UInt8 configRead8( IOPCIAddressSpace space, UInt8 offset );
104 virtual void configWrite8( IOPCIAddressSpace space,
105 UInt8 offset, UInt8 data );
106
107 virtual UInt32 configRead32( UInt8 offset );
108 virtual UInt16 configRead16( UInt8 offset );
109 virtual UInt8 configRead8( UInt8 offset );
110 virtual void configWrite32( UInt8 offset, UInt32 data );
111 virtual void configWrite16( UInt8 offset, UInt16 data );
112 virtual void configWrite8( UInt8 offset, UInt8 data );
113
114 virtual IOReturn saveDeviceState( IOOptionBits options = 0 );
115 virtual IOReturn restoreDeviceState( IOOptionBits options = 0 );
116 virtual UInt32 setConfigBits( UInt8 offset, UInt32 mask, UInt32 value );
117
118 virtual bool setMemoryEnable( bool enable );
119 virtual bool setIOEnable( bool enable, bool exclusive = false );
120 virtual bool setBusMasterEnable( bool enable );
121 virtual UInt32 findPCICapability( UInt8 capabilityID, UInt8 * offset = 0 );
122 virtual UInt8 getBusNumber( void );
123 virtual UInt8 getDeviceNumber( void );
124 virtual UInt8 getFunctionNumber( void );
125 virtual IODeviceMemory * getDeviceMemoryWithRegister( UInt8 reg );
126 virtual IOMemoryMap * mapDeviceMemoryWithRegister( UInt8 reg,
127 IOOptionBits options = 0 );
128 virtual IODeviceMemory * ioDeviceMemory( void );
129 virtual void ioWrite32( UInt16 offset, UInt32 value,
130 IOMemoryMap * map = 0 );
131 virtual void ioWrite16( UInt16 offset, UInt16 value,
132 IOMemoryMap * map = 0 );
133 virtual void ioWrite8( UInt16 offset, UInt8 value,
134 IOMemoryMap * map = 0 );
135 virtual UInt32 ioRead32( UInt16 offset, IOMemoryMap * map = 0 );
136 virtual UInt16 ioRead16( UInt16 offset, IOMemoryMap * map = 0 );
137 virtual UInt8 ioRead8( UInt16 offset, IOMemoryMap * map = 0 );
138
139 // Unused Padding
140 OSMetaClassDeclareReservedUnused(IOPCIDevice, 0);
141 OSMetaClassDeclareReservedUnused(IOPCIDevice, 1);
142 OSMetaClassDeclareReservedUnused(IOPCIDevice, 2);
143 OSMetaClassDeclareReservedUnused(IOPCIDevice, 3);
144 OSMetaClassDeclareReservedUnused(IOPCIDevice, 4);
145 OSMetaClassDeclareReservedUnused(IOPCIDevice, 5);
146 OSMetaClassDeclareReservedUnused(IOPCIDevice, 6);
147 OSMetaClassDeclareReservedUnused(IOPCIDevice, 7);
148 OSMetaClassDeclareReservedUnused(IOPCIDevice, 8);
149 OSMetaClassDeclareReservedUnused(IOPCIDevice, 9);
150 OSMetaClassDeclareReservedUnused(IOPCIDevice, 10);
151 OSMetaClassDeclareReservedUnused(IOPCIDevice, 11);
152 OSMetaClassDeclareReservedUnused(IOPCIDevice, 12);
153 OSMetaClassDeclareReservedUnused(IOPCIDevice, 13);
154 OSMetaClassDeclareReservedUnused(IOPCIDevice, 14);
155 OSMetaClassDeclareReservedUnused(IOPCIDevice, 15);
156 };
157
158 #endif /* ! _IOKIT_IOPCIDEVICE_H */