]> git.saurik.com Git - apple/xnu.git/blame - iokit/IOKit/pci/IOPCIDevice.h
xnu-792.21.3.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 *
8f6c56a5 4 * @APPLE_OSREFERENCE_LICENSE_HEADER_START@
1c79356b 5 *
8f6c56a5
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.
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
8ad349bb 24 * limitations under the License.
8f6c56a5
A
25 *
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
1c79356b
A
64class IOPCIDevice : public IOService
65{
66 OSDeclareDefaultStructors(IOPCIDevice)
67
68 friend class IOPCIBridge;
69 friend class IOPCI2PCIBridge;
70
71protected:
72 IOPCIBridge * parent;
73 IOMemoryMap * ioMap;
74 OSObject * slotNameProperty;
75
1c79356b
A
76 struct ExpansionData { };
77
1c79356b
A
78 ExpansionData *reserved;
79
80public:
43866e37 81 IOPCIAddressSpace space;
1c79356b
A
82 UInt32 * savedConfig;
83
84public:
1c79356b
A
85
86 virtual bool attach( IOService * provider );
0b4e3aa0 87 virtual void detach( IOService * provider );
1c79356b 88 virtual IOReturn setPowerState( unsigned long, IOService * );
1c79356b
A
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
1c79356b 107 virtual UInt32 configRead32( UInt8 offset );
1c79356b 108 virtual UInt16 configRead16( UInt8 offset );
1c79356b 109 virtual UInt8 configRead8( UInt8 offset );
1c79356b 110 virtual void configWrite32( UInt8 offset, UInt32 data );
1c79356b 111 virtual void configWrite16( UInt8 offset, UInt16 data );
1c79356b
A
112 virtual void configWrite8( UInt8 offset, UInt8 data );
113
114 virtual IOReturn saveDeviceState( IOOptionBits options = 0 );
115 virtual IOReturn restoreDeviceState( IOOptionBits options = 0 );
1c79356b
A
116 virtual UInt32 setConfigBits( UInt8 offset, UInt32 mask, UInt32 value );
117
1c79356b 118 virtual bool setMemoryEnable( bool enable );
1c79356b 119 virtual bool setIOEnable( bool enable, bool exclusive = false );
1c79356b 120 virtual bool setBusMasterEnable( bool enable );
1c79356b 121 virtual UInt32 findPCICapability( UInt8 capabilityID, UInt8 * offset = 0 );
1c79356b 122 virtual UInt8 getBusNumber( void );
1c79356b 123 virtual UInt8 getDeviceNumber( void );
1c79356b 124 virtual UInt8 getFunctionNumber( void );
1c79356b 125 virtual IODeviceMemory * getDeviceMemoryWithRegister( UInt8 reg );
1c79356b
A
126 virtual IOMemoryMap * mapDeviceMemoryWithRegister( UInt8 reg,
127 IOOptionBits options = 0 );
1c79356b 128 virtual IODeviceMemory * ioDeviceMemory( void );
1c79356b
A
129 virtual void ioWrite32( UInt16 offset, UInt32 value,
130 IOMemoryMap * map = 0 );
1c79356b
A
131 virtual void ioWrite16( UInt16 offset, UInt16 value,
132 IOMemoryMap * map = 0 );
1c79356b
A
133 virtual void ioWrite8( UInt16 offset, UInt8 value,
134 IOMemoryMap * map = 0 );
1c79356b 135 virtual UInt32 ioRead32( UInt16 offset, IOMemoryMap * map = 0 );
1c79356b 136 virtual UInt16 ioRead16( UInt16 offset, IOMemoryMap * map = 0 );
1c79356b
A
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 */