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