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