]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/pci/IOPCIDevice.h
xnu-1699.26.8.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 *
2d21ac55 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
2d21ac55
A
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.
8f6c56a5 14 *
2d21ac55
A
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
8f6c56a5
A
20 * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES,
21 * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY,
2d21ac55
A
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.
8f6c56a5 25 *
2d21ac55 26 * @APPLE_OSREFERENCE_LICENSE_HEADER_END@
1c79356b 27 */
1c79356b
A
28
29#ifndef _IOKIT_IOPCIDEVICE_H
30#define _IOKIT_IOPCIDEVICE_H
31
43866e37
A
32#warning IOPCIDevice.h moved to IOPCIFamily project
33#warning IOPCIDevice.h will be removed from xnu; do not edit or add new usage
de355530 34
43866e37 35#include <IOKit/IOService.h>
de355530 36
1c79356b
A
37union IOPCIAddressSpace {
38 UInt32 bits;
39 struct {
55e303ae 40#ifdef __BIG_ENDIAN__
1c79356b
A
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;
55e303ae 50#elif defined(__LITTLE_ENDIAN__)
1c79356b
A
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
2d21ac55
A
64class IOPCIBridge;
65class IOPCI2PCIBridge;
66
1c79356b
A
67class IOPCIDevice : public IOService
68{
69 OSDeclareDefaultStructors(IOPCIDevice)
70
71 friend class IOPCIBridge;
72 friend class IOPCI2PCIBridge;
73
74protected:
75 IOPCIBridge * parent;
76 IOMemoryMap * ioMap;
77 OSObject * slotNameProperty;
78
1c79356b
A
79 struct ExpansionData { };
80
1c79356b
A
81 ExpansionData *reserved;
82
83public:
43866e37 84 IOPCIAddressSpace space;
1c79356b
A
85 UInt32 * savedConfig;
86
87public:
1c79356b
A
88
89 virtual bool attach( IOService * provider );
0b4e3aa0 90 virtual void detach( IOService * provider );
1c79356b 91 virtual IOReturn setPowerState( unsigned long, IOService * );
1c79356b
A
92 virtual bool compareName( OSString * name, OSString ** matched = 0 ) const;
93 virtual bool matchPropertyTable( OSDictionary * table,
94 SInt32 * score );
95 virtual IOService * matchLocation( IOService * client );
96 virtual IOReturn getResources( void );
97
98 /* Config space accessors */
99
100 virtual UInt32 configRead32( IOPCIAddressSpace space, UInt8 offset );
101 virtual void configWrite32( IOPCIAddressSpace space,
102 UInt8 offset, UInt32 data );
103 virtual UInt16 configRead16( IOPCIAddressSpace space, UInt8 offset );
104 virtual void configWrite16( IOPCIAddressSpace space,
105 UInt8 offset, UInt16 data );
106 virtual UInt8 configRead8( IOPCIAddressSpace space, UInt8 offset );
107 virtual void configWrite8( IOPCIAddressSpace space,
108 UInt8 offset, UInt8 data );
109
1c79356b 110 virtual UInt32 configRead32( UInt8 offset );
1c79356b 111 virtual UInt16 configRead16( UInt8 offset );
1c79356b 112 virtual UInt8 configRead8( UInt8 offset );
1c79356b 113 virtual void configWrite32( UInt8 offset, UInt32 data );
1c79356b 114 virtual void configWrite16( UInt8 offset, UInt16 data );
1c79356b
A
115 virtual void configWrite8( UInt8 offset, UInt8 data );
116
117 virtual IOReturn saveDeviceState( IOOptionBits options = 0 );
118 virtual IOReturn restoreDeviceState( IOOptionBits options = 0 );
1c79356b
A
119 virtual UInt32 setConfigBits( UInt8 offset, UInt32 mask, UInt32 value );
120
1c79356b 121 virtual bool setMemoryEnable( bool enable );
1c79356b 122 virtual bool setIOEnable( bool enable, bool exclusive = false );
1c79356b 123 virtual bool setBusMasterEnable( bool enable );
1c79356b 124 virtual UInt32 findPCICapability( UInt8 capabilityID, UInt8 * offset = 0 );
1c79356b 125 virtual UInt8 getBusNumber( void );
1c79356b 126 virtual UInt8 getDeviceNumber( void );
1c79356b 127 virtual UInt8 getFunctionNumber( void );
1c79356b 128 virtual IODeviceMemory * getDeviceMemoryWithRegister( UInt8 reg );
1c79356b
A
129 virtual IOMemoryMap * mapDeviceMemoryWithRegister( UInt8 reg,
130 IOOptionBits options = 0 );
1c79356b 131 virtual IODeviceMemory * ioDeviceMemory( void );
1c79356b
A
132 virtual void ioWrite32( UInt16 offset, UInt32 value,
133 IOMemoryMap * map = 0 );
1c79356b
A
134 virtual void ioWrite16( UInt16 offset, UInt16 value,
135 IOMemoryMap * map = 0 );
1c79356b
A
136 virtual void ioWrite8( UInt16 offset, UInt8 value,
137 IOMemoryMap * map = 0 );
1c79356b 138 virtual UInt32 ioRead32( UInt16 offset, IOMemoryMap * map = 0 );
1c79356b 139 virtual UInt16 ioRead16( UInt16 offset, IOMemoryMap * map = 0 );
1c79356b
A
140 virtual UInt8 ioRead8( UInt16 offset, IOMemoryMap * map = 0 );
141
142 // Unused Padding
143 OSMetaClassDeclareReservedUnused(IOPCIDevice, 0);
144 OSMetaClassDeclareReservedUnused(IOPCIDevice, 1);
145 OSMetaClassDeclareReservedUnused(IOPCIDevice, 2);
146 OSMetaClassDeclareReservedUnused(IOPCIDevice, 3);
147 OSMetaClassDeclareReservedUnused(IOPCIDevice, 4);
148 OSMetaClassDeclareReservedUnused(IOPCIDevice, 5);
149 OSMetaClassDeclareReservedUnused(IOPCIDevice, 6);
150 OSMetaClassDeclareReservedUnused(IOPCIDevice, 7);
151 OSMetaClassDeclareReservedUnused(IOPCIDevice, 8);
152 OSMetaClassDeclareReservedUnused(IOPCIDevice, 9);
153 OSMetaClassDeclareReservedUnused(IOPCIDevice, 10);
154 OSMetaClassDeclareReservedUnused(IOPCIDevice, 11);
155 OSMetaClassDeclareReservedUnused(IOPCIDevice, 12);
156 OSMetaClassDeclareReservedUnused(IOPCIDevice, 13);
157 OSMetaClassDeclareReservedUnused(IOPCIDevice, 14);
158 OSMetaClassDeclareReservedUnused(IOPCIDevice, 15);
159};
160
161#endif /* ! _IOKIT_IOPCIDEVICE_H */