Subversion Repositories Kolibri OS

Rev

Rev 5056 | Rev 6082 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

Rev Author Line No. Line
1964 serge 1
/*
2
 *	pci.h
3
 *
4
 *	PCI defines and function prototypes
5
 *	Copyright 1994, Drew Eckhardt
6
 *	Copyright 1997--1999 Martin Mares 
7
 *
8
 *	For more information, please consult the following manuals (look at
9
 *	http://www.pcisig.com/ for how to get them):
10
 *
11
 *	PCI BIOS Specification
12
 *	PCI Local Bus Specification
13
 *	PCI to PCI Bridge Specification
14
 *	PCI System Design Guide
15
 */
1970 serge 16
#ifndef LINUX_PCI_H
17
#define LINUX_PCI_H
18
 
3031 serge 19
#include 
5270 serge 20
#include 
21
#include 
22
#include 
23
#include 
24
 
2161 serge 25
#include 	/* The pci register defines */
5270 serge 26
#include 
1408 serge 27
 
1628 serge 28
 
2161 serge 29
#define PCI_CFG_SPACE_SIZE      256
30
#define PCI_CFG_SPACE_EXP_SIZE  4096
1970 serge 31
 
2161 serge 32
 
1408 serge 33
#define PCI_ANY_ID (~0)
34
 
35
 
36
#define PCI_CLASS_NOT_DEFINED           0x0000
37
#define PCI_CLASS_NOT_DEFINED_VGA       0x0001
38
 
39
#define PCI_BASE_CLASS_STORAGE          0x01
40
#define PCI_CLASS_STORAGE_SCSI          0x0100
41
#define PCI_CLASS_STORAGE_IDE           0x0101
42
#define PCI_CLASS_STORAGE_FLOPPY        0x0102
43
#define PCI_CLASS_STORAGE_IPI           0x0103
44
#define PCI_CLASS_STORAGE_RAID          0x0104
45
#define PCI_CLASS_STORAGE_SATA          0x0106
46
#define PCI_CLASS_STORAGE_SATA_AHCI     0x010601
47
#define PCI_CLASS_STORAGE_SAS           0x0107
48
#define PCI_CLASS_STORAGE_OTHER         0x0180
49
 
50
#define PCI_BASE_CLASS_NETWORK          0x02
51
#define PCI_CLASS_NETWORK_ETHERNET      0x0200
52
#define PCI_CLASS_NETWORK_TOKEN_RING    0x0201
53
#define PCI_CLASS_NETWORK_FDDI          0x0202
54
#define PCI_CLASS_NETWORK_ATM           0x0203
55
#define PCI_CLASS_NETWORK_OTHER         0x0280
56
 
57
#define PCI_BASE_CLASS_DISPLAY          0x03
58
#define PCI_CLASS_DISPLAY_VGA           0x0300
59
#define PCI_CLASS_DISPLAY_XGA           0x0301
60
#define PCI_CLASS_DISPLAY_3D            0x0302
61
#define PCI_CLASS_DISPLAY_OTHER         0x0380
62
 
63
#define PCI_BASE_CLASS_MULTIMEDIA       0x04
64
#define PCI_CLASS_MULTIMEDIA_VIDEO      0x0400
65
#define PCI_CLASS_MULTIMEDIA_AUDIO      0x0401
66
#define PCI_CLASS_MULTIMEDIA_PHONE      0x0402
67
#define PCI_CLASS_MULTIMEDIA_OTHER      0x0480
68
 
69
#define PCI_BASE_CLASS_MEMORY           0x05
70
#define PCI_CLASS_MEMORY_RAM            0x0500
71
#define PCI_CLASS_MEMORY_FLASH          0x0501
72
#define PCI_CLASS_MEMORY_OTHER          0x0580
73
 
74
#define PCI_BASE_CLASS_BRIDGE           0x06
75
#define PCI_CLASS_BRIDGE_HOST           0x0600
76
#define PCI_CLASS_BRIDGE_ISA            0x0601
77
#define PCI_CLASS_BRIDGE_EISA           0x0602
78
#define PCI_CLASS_BRIDGE_MC             0x0603
79
#define PCI_CLASS_BRIDGE_PCI            0x0604
80
#define PCI_CLASS_BRIDGE_PCMCIA         0x0605
81
#define PCI_CLASS_BRIDGE_NUBUS          0x0606
82
#define PCI_CLASS_BRIDGE_CARDBUS        0x0607
83
#define PCI_CLASS_BRIDGE_RACEWAY        0x0608
84
#define PCI_CLASS_BRIDGE_OTHER          0x0680
85
 
86
#define PCI_BASE_CLASS_COMMUNICATION    0x07
87
#define PCI_CLASS_COMMUNICATION_SERIAL  0x0700
88
#define PCI_CLASS_COMMUNICATION_PARALLEL 0x0701
89
#define PCI_CLASS_COMMUNICATION_MULTISERIAL 0x0702
90
#define PCI_CLASS_COMMUNICATION_MODEM   0x0703
91
#define PCI_CLASS_COMMUNICATION_OTHER   0x0780
92
 
93
#define PCI_BASE_CLASS_SYSTEM           0x08
94
#define PCI_CLASS_SYSTEM_PIC            0x0800
95
#define PCI_CLASS_SYSTEM_PIC_IOAPIC     0x080010
96
#define PCI_CLASS_SYSTEM_PIC_IOXAPIC    0x080020
97
#define PCI_CLASS_SYSTEM_DMA            0x0801
98
#define PCI_CLASS_SYSTEM_TIMER          0x0802
99
#define PCI_CLASS_SYSTEM_RTC            0x0803
100
#define PCI_CLASS_SYSTEM_PCI_HOTPLUG    0x0804
101
#define PCI_CLASS_SYSTEM_SDHCI          0x0805
102
#define PCI_CLASS_SYSTEM_OTHER          0x0880
103
 
104
#define PCI_BASE_CLASS_INPUT            0x09
105
#define PCI_CLASS_INPUT_KEYBOARD        0x0900
106
#define PCI_CLASS_INPUT_PEN             0x0901
107
#define PCI_CLASS_INPUT_MOUSE           0x0902
108
#define PCI_CLASS_INPUT_SCANNER         0x0903
109
#define PCI_CLASS_INPUT_GAMEPORT        0x0904
110
#define PCI_CLASS_INPUT_OTHER           0x0980
111
 
112
#define PCI_BASE_CLASS_DOCKING          0x0a
113
#define PCI_CLASS_DOCKING_GENERIC       0x0a00
114
#define PCI_CLASS_DOCKING_OTHER         0x0a80
115
 
116
#define PCI_BASE_CLASS_PROCESSOR        0x0b
117
#define PCI_CLASS_PROCESSOR_386         0x0b00
118
#define PCI_CLASS_PROCESSOR_486         0x0b01
119
#define PCI_CLASS_PROCESSOR_PENTIUM     0x0b02
120
#define PCI_CLASS_PROCESSOR_ALPHA       0x0b10
121
#define PCI_CLASS_PROCESSOR_POWERPC     0x0b20
122
#define PCI_CLASS_PROCESSOR_MIPS        0x0b30
123
#define PCI_CLASS_PROCESSOR_CO          0x0b40
124
 
125
#define PCI_BASE_CLASS_SERIAL           0x0c
126
#define PCI_CLASS_SERIAL_FIREWIRE       0x0c00
127
#define PCI_CLASS_SERIAL_FIREWIRE_OHCI  0x0c0010
128
#define PCI_CLASS_SERIAL_ACCESS         0x0c01
129
#define PCI_CLASS_SERIAL_SSA            0x0c02
130
#define PCI_CLASS_SERIAL_USB            0x0c03
131
#define PCI_CLASS_SERIAL_USB_UHCI       0x0c0300
132
#define PCI_CLASS_SERIAL_USB_OHCI       0x0c0310
133
#define PCI_CLASS_SERIAL_USB_EHCI       0x0c0320
134
#define PCI_CLASS_SERIAL_FIBER          0x0c04
135
#define PCI_CLASS_SERIAL_SMBUS          0x0c05
136
 
137
#define PCI_BASE_CLASS_WIRELESS                 0x0d
138
#define PCI_CLASS_WIRELESS_RF_CONTROLLER        0x0d10
139
#define PCI_CLASS_WIRELESS_WHCI                 0x0d1010
140
 
141
#define PCI_BASE_CLASS_INTELLIGENT      0x0e
142
#define PCI_CLASS_INTELLIGENT_I2O       0x0e00
143
 
144
#define PCI_BASE_CLASS_SATELLITE        0x0f
145
#define PCI_CLASS_SATELLITE_TV          0x0f00
146
#define PCI_CLASS_SATELLITE_AUDIO       0x0f01
147
#define PCI_CLASS_SATELLITE_VOICE       0x0f03
148
#define PCI_CLASS_SATELLITE_DATA        0x0f04
149
 
150
#define PCI_BASE_CLASS_CRYPT            0x10
151
#define PCI_CLASS_CRYPT_NETWORK         0x1000
152
#define PCI_CLASS_CRYPT_ENTERTAINMENT   0x1001
153
#define PCI_CLASS_CRYPT_OTHER           0x1080
154
 
155
#define PCI_BASE_CLASS_SIGNAL_PROCESSING 0x11
156
#define PCI_CLASS_SP_DPIO               0x1100
157
#define PCI_CLASS_SP_OTHER              0x1180
158
 
159
#define PCI_CLASS_OTHERS                0xff
160
 
161
 
162
 
1964 serge 163
 
164
 
1408 serge 165
#define PCI_MAP_IS_IO(b)  ((b) & PCI_MAP_IO)
166
#define PCI_MAP_IS_MEM(b)   (!PCI_MAP_IS_IO(b))
167
 
168
#define PCI_MAP_IS64BITMEM(b)   \
169
    (((b) & PCI_MAP_MEMORY_TYPE_MASK) == PCI_MAP_MEMORY_TYPE_64BIT)
170
 
171
#define PCIGETMEMORY(b)   ((b) & PCI_MAP_MEMORY_ADDRESS_MASK)
172
#define PCIGETMEMORY64HIGH(b)   (*((CARD32*)&b + 1))
173
#define PCIGETMEMORY64(b)   \
174
    (PCIGETMEMORY(b) | ((CARD64)PCIGETMEMORY64HIGH(b) << 32))
175
 
176
#define PCI_MAP_IO_ADDRESS_MASK       0xfffffffc
177
 
178
#define PCIGETIO(b)     ((b) & PCI_MAP_IO_ADDRESS_MASK)
179
 
180
#define PCI_MAP_ROM_DECODE_ENABLE     0x00000001
181
#define PCI_MAP_ROM_ADDRESS_MASK      0xfffff800
182
 
183
#define PCIGETROM(b)        ((b) & PCI_MAP_ROM_ADDRESS_MASK)
184
 
185
 
186
#ifndef PCI_DOM_MASK
187
# define PCI_DOM_MASK 0x0ffu
188
#endif
189
#define PCI_DOMBUS_MASK (((PCI_DOM_MASK) << 8) | 0x0ffu)
190
 
191
#define PCI_MAKE_TAG(b,d,f)  ((((b) & (PCI_DOMBUS_MASK)) << 16) | \
192
                  (((d) & 0x00001fu) << 11) | \
193
                  (((f) & 0x000007u) << 8))
194
 
195
#define PCI_BUS_FROM_TAG(tag)  (((tag) >> 16) & (PCI_DOMBUS_MASK))
196
#define PCI_DEV_FROM_TAG(tag)  (((tag) & 0x0000f800u) >> 11)
197
#define PCI_FUNC_FROM_TAG(tag) (((tag) & 0x00000700u) >> 8)
198
#define PCI_DFN_FROM_TAG(tag)  (((tag) & 0x0000ff00u) >> 8)
199
 
2161 serge 200
/*
201
 * The PCI interface treats multi-function devices as independent
202
 * devices.  The slot/function address of each device is encoded
203
 * in a single byte as follows:
204
 *
205
 *	7:3 = slot
206
 *	2:0 = function
207
 */
1408 serge 208
#define PCI_DEVFN(slot, func)  ((((slot) & 0x1f) << 3) | ((func) & 0x07))
209
#define PCI_SLOT(devfn)        (((devfn) >> 3) & 0x1f)
210
#define PCI_FUNC(devfn)        ((devfn) & 0x07)
211
 
212
 
213
 
214
typedef unsigned int PCITAG;
215
 
216
extern inline PCITAG
217
pciTag(int busnum, int devnum, int funcnum)
218
{
219
    return(PCI_MAKE_TAG(busnum,devnum,funcnum));
220
}
221
 
2161 serge 222
/* pci_slot represents a physical slot */
223
struct pci_slot {
224
	struct pci_bus *bus;		/* The bus this slot is on */
225
	struct list_head list;		/* node in list of slots on this bus */
226
	struct hotplug_slot *hotplug;	/* Hotplug info (migrate over time) */
227
	unsigned char number;		/* PCI_SLOT(pci_dev->devfn) */
228
};
1627 serge 229
 
2161 serge 230
/* File state for mmap()s on /proc/bus/pci/X/Y */
231
enum pci_mmap_state {
232
	pci_mmap_io,
233
	pci_mmap_mem
1964 serge 234
};
235
 
2161 serge 236
/* This defines the direction arg to the DMA mapping routines. */
237
#define PCI_DMA_BIDIRECTIONAL	0
238
#define PCI_DMA_TODEVICE	1
239
#define PCI_DMA_FROMDEVICE	2
240
#define PCI_DMA_NONE		3
241
 
1408 serge 242
/*
2161 serge 243
 *  For PCI devices, the region numbers are assigned this way:
1627 serge 244
 */
2161 serge 245
enum {