1
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h,v 1.36 2003/02/18 15:42:12 tsi Exp $ */
3
* Copyright 1998 by Concurrent Computer Corporation
5
* Permission to use, copy, modify, distribute, and sell this software
6
* and its documentation for any purpose is hereby granted without fee,
7
* provided that the above copyright notice appear in all copies and that
8
* both that copyright notice and this permission notice appear in
9
* supporting documentation, and that the name of Concurrent Computer
10
* Corporation not be used in advertising or publicity pertaining to
11
* distribution of the software without specific, written prior
12
* permission. Concurrent Computer Corporation makes no representations
13
* about the suitability of this software for any purpose. It is
14
* provided "as is" without express or implied warranty.
16
* CONCURRENT COMPUTER CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD
17
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
18
* AND FITNESS, IN NO EVENT SHALL CONCURRENT COMPUTER CORPORATION BE
19
* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
20
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
21
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
22
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
25
* Copyright 1998 by Metro Link Incorporated
27
* Permission to use, copy, modify, distribute, and sell this software
28
* and its documentation for any purpose is hereby granted without fee,
29
* provided that the above copyright notice appear in all copies and that
30
* both that copyright notice and this permission notice appear in
31
* supporting documentation, and that the name of Metro Link
32
* Incorporated not be used in advertising or publicity pertaining to
33
* distribution of the software without specific, written prior
34
* permission. Metro Link Incorporated makes no representations
35
* about the suitability of this software for any purpose. It is
36
* provided "as is" without express or implied warranty.
38
* METRO LINK INCORPORATED DISCLAIMS ALL WARRANTIES WITH REGARD
39
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
40
* AND FITNESS, IN NO EVENT SHALL METRO LINK INCORPORATED BE
41
* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
42
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43
* WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44
* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
47
* This file is derived in part from the original xf86_PCI.h that included
48
* following copyright message:
50
* Copyright 1995 by Robin Cutshaw <robin@XFree86.Org>
52
* Permission to use, copy, modify, distribute, and sell this software and its
53
* documentation for any purpose is hereby granted without fee, provided that
54
* the above copyright notice appear in all copies and that both that
55
* copyright notice and this permission notice appear in supporting
56
* documentation, and that the names of the above listed copyright holder(s)
57
* not be used in advertising or publicity pertaining to distribution of
58
* the software without specific, written prior permission. The above listed
59
* copyright holder(s) make(s) no representations about the suitability of this
60
* software for any purpose. It is provided "as is" without express or
63
* THE ABOVE LISTED COPYRIGHT HOLDER(S) DISCLAIM(S) ALL WARRANTIES WITH REGARD
64
* TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
65
* AND FITNESS, IN NO EVENT SHALL THE ABOVE LISTED COPYRIGHT HOLDER(S) BE
66
* LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY
67
* DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER
68
* IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
69
* OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
74
* This file contains just the public interface to the PCI code.
75
* Drivers should use this file rather than Pci.h.
81
#include "Xfuncproto.h"
85
* PCI cfg space definitions (e.g. stuff right out of the PCI spec)
88
/* Device identification register */
89
#define PCI_ID_REG 0x00
91
/* Command and status register */
92
#define PCI_CMD_STAT_REG 0x04
93
#define PCI_CMD_BASE_REG 0x10
94
#define PCI_CMD_BIOS_REG 0x30
95
#define PCI_CMD_MASK 0xffff
96
#define PCI_CMD_IO_ENABLE 0x01
97
#define PCI_CMD_MEM_ENABLE 0x02
98
#define PCI_CMD_MASTER_ENABLE 0x04
99
#define PCI_CMD_SPECIAL_ENABLE 0x08
100
#define PCI_CMD_INVALIDATE_ENABLE 0x10
101
#define PCI_CMD_PALETTE_ENABLE 0x20
102
#define PCI_CMD_PARITY_ENABLE 0x40
103
#define PCI_CMD_STEPPING_ENABLE 0x80
104
#define PCI_CMD_SERR_ENABLE 0x100
105
#define PCI_CMD_BACKTOBACK_ENABLE 0x200
106
#define PCI_CMD_BIOS_ENABLE 0x01
109
#define PCI_CLASS_REG 0x08
110
#define PCI_CLASS_MASK 0xff000000
111
#define PCI_CLASS_SHIFT 24
112
#define PCI_CLASS_EXTRACT(x) \
113
(((x) & PCI_CLASS_MASK) >> PCI_CLASS_SHIFT)
115
/* base class values */
116
#define PCI_CLASS_PREHISTORIC 0x00
117
#define PCI_CLASS_MASS_STORAGE 0x01
118
#define PCI_CLASS_NETWORK 0x02
119
#define PCI_CLASS_DISPLAY 0x03
120
#define PCI_CLASS_MULTIMEDIA 0x04
121
#define PCI_CLASS_MEMORY 0x05
122
#define PCI_CLASS_BRIDGE 0x06
123
#define PCI_CLASS_COMMUNICATIONS 0x07
124
#define PCI_CLASS_SYSPERIPH 0x08
125
#define PCI_CLASS_INPUT 0x09
126
#define PCI_CLASS_DOCKING 0x0a
127
#define PCI_CLASS_PROCESSOR 0x0b
128
#define PCI_CLASS_SERIALBUS 0x0c
129
#define PCI_CLASS_WIRELESS 0x0d
130
#define PCI_CLASS_I2O 0x0e
131
#define PCI_CLASS_SATELLITE 0x0f
132
#define PCI_CLASS_CRYPT 0x10
133
#define PCI_CLASS_DATA_ACQUISTION 0x11
134
#define PCI_CLASS_UNDEFINED 0xff
137
#define PCI_SUBCLASS_MASK 0x00ff0000
138
#define PCI_SUBCLASS_SHIFT 16
139
#define PCI_SUBCLASS_EXTRACT(x) \
140
(((x) & PCI_SUBCLASS_MASK) >> PCI_SUBCLASS_SHIFT)
142
/* Sub class values */
143
/* 0x00 prehistoric subclasses */
144
#define PCI_SUBCLASS_PREHISTORIC_MISC 0x00
145
#define PCI_SUBCLASS_PREHISTORIC_VGA 0x01
147
/* 0x01 mass storage subclasses */
148
#define PCI_SUBCLASS_MASS_STORAGE_SCSI 0x00
149
#define PCI_SUBCLASS_MASS_STORAGE_IDE 0x01
150
#define PCI_SUBCLASS_MASS_STORAGE_FLOPPY 0x02
151
#define PCI_SUBCLASS_MASS_STORAGE_IPI 0x03
152
#define PCI_SUBCLASS_MASS_STORAGE_MISC 0x80
154
/* 0x02 network subclasses */
155
#define PCI_SUBCLASS_NETWORK_ETHERNET 0x00
156
#define PCI_SUBCLASS_NETWORK_TOKENRING 0x01
157
#define PCI_SUBCLASS_NETWORK_FDDI 0x02
158
#define PCI_SUBCLASS_NETWORK_MISC 0x80
160
/* 0x03 display subclasses */
161
#define PCI_SUBCLASS_DISPLAY_VGA 0x00
162
#define PCI_SUBCLASS_DISPLAY_XGA 0x01
163
#define PCI_SUBCLASS_DISPLAY_MISC 0x80
165
/* 0x04 multimedia subclasses */
166
#define PCI_SUBCLASS_MULTIMEDIA_VIDEO 0x00
167
#define PCI_SUBCLASS_MULTIMEDIA_AUDIO 0x01
168
#define PCI_SUBCLASS_MULTIMEDIA_MISC 0x80
170
/* 0x05 memory subclasses */
171
#define PCI_SUBCLASS_MEMORY_RAM 0x00
172
#define PCI_SUBCLASS_MEMORY_FLASH 0x01
173
#define PCI_SUBCLASS_MEMORY_MISC 0x80
175
/* 0x06 bridge subclasses */
176
#define PCI_SUBCLASS_BRIDGE_HOST 0x00
177
#define PCI_SUBCLASS_BRIDGE_ISA 0x01
178
#define PCI_SUBCLASS_BRIDGE_EISA 0x02
179
#define PCI_SUBCLASS_BRIDGE_MC 0x03
180
#define PCI_SUBCLASS_BRIDGE_PCI 0x04
181
#define PCI_SUBCLASS_BRIDGE_PCMCIA 0x05
182
#define PCI_SUBCLASS_BRIDGE_NUBUS 0x06
183
#define PCI_SUBCLASS_BRIDGE_CARDBUS 0x07
184
#define PCI_SUBCLASS_BRIDGE_RACEWAY 0x08
185
#define PCI_SUBCLASS_BRIDGE_MISC 0x80
186
#define PCI_IF_BRIDGE_PCI_SUBTRACTIVE 0x01
188
/* 0x07 communications controller subclasses */
189
#define PCI_SUBCLASS_COMMUNICATIONS_SERIAL 0x00
190
#define PCI_SUBCLASS_COMMUNICATIONS_PARALLEL 0x01
191
#define PCI_SUBCLASS_COMMUNICATIONS_MULTISERIAL 0x02
192
#define PCI_SUBCLASS_COMMUNICATIONS_MODEM 0x03
193
#define PCI_SUBCLASS_COMMUNICATIONS_MISC 0x80
195
/* 0x08 generic system peripherals subclasses */
196
#define PCI_SUBCLASS_SYSPERIPH_PIC 0x00
197
#define PCI_SUBCLASS_SYSPERIPH_DMA 0x01
198
#define PCI_SUBCLASS_SYSPERIPH_TIMER 0x02
199
#define PCI_SUBCLASS_SYSPERIPH_RTC 0x03
200
#define PCI_SUBCLASS_SYSPERIPH_HOTPCI 0x04
201
#define PCI_SUBCLASS_SYSPERIPH_MISC 0x80
203
/* 0x09 input device subclasses */
204
#define PCI_SUBCLASS_INPUT_KEYBOARD 0x00
205
#define PCI_SUBCLASS_INPUT_DIGITIZER 0x01
206
#define PCI_SUBCLASS_INPUT_MOUSE 0x02
207
#define PCI_SUBCLASS_INPUT_SCANNER 0x03
208
#define PCI_SUBCLASS_INPUT_GAMEPORT 0x04
209
#define PCI_SUBCLASS_INPUT_MISC 0x80
211
/* 0x0a docking station subclasses */
212
#define PCI_SUBCLASS_DOCKING_GENERIC 0x00
213
#define PCI_SUBCLASS_DOCKING_MISC 0x80
215
/* 0x0b processor subclasses */
216
#define PCI_SUBCLASS_PROCESSOR_386 0x00
217
#define PCI_SUBCLASS_PROCESSOR_486 0x01
218
#define PCI_SUBCLASS_PROCESSOR_PENTIUM 0x02
219
#define PCI_SUBCLASS_PROCESSOR_ALPHA 0x10
220
#define PCI_SUBCLASS_PROCESSOR_POWERPC 0x20
221
#define PCI_SUBCLASS_PROCESSOR_MIPS 0x30
222
#define PCI_SUBCLASS_PROCESSOR_COPROC 0x40
224
/* 0x0c serial bus controller subclasses */
225
#define PCI_SUBCLASS_SERIAL_FIREWIRE 0x00
226
#define PCI_SUBCLASS_SERIAL_ACCESS 0x01
227
#define PCI_SUBCLASS_SERIAL_SSA 0x02
228
#define PCI_SUBCLASS_SERIAL_USB 0x03
229
#define PCI_SUBCLASS_SERIAL_FIBRECHANNEL 0x04
230
#define PCI_SUBCLASS_SERIAL_SMBUS 0x05
232
/* 0x0d wireless controller subclasses */
233
#define PCI_SUBCLASS_WIRELESS_IRDA 0x00
234
#define PCI_SUBCLASS_WIRELESS_CONSUMER_IR 0x01
235
#define PCI_SUBCLASS_WIRELESS_RF 0x02
236
#define PCI_SUBCLASS_WIRELESS_MISC 0x80
238
/* 0x0e intelligent I/O controller subclasses */
239
#define PCI_SUBCLASS_I2O_I2O 0x00
241
/* 0x0f satellite communications controller subclasses */
242
#define PCI_SUBCLASS_SATELLITE_TV 0x01
243
#define PCI_SUBCLASS_SATELLITE_AUDIO 0x02
244
#define PCI_SUBCLASS_SATELLITE_VOICE 0x03
245
#define PCI_SUBCLASS_SATELLITE_DATA 0x04
247
/* 0x10 encryption/decryption controller subclasses */
248
#define PCI_SUBCLASS_CRYPT_NET_COMPUTING 0x00
249
#define PCI_SUBCLASS_CRYPT_ENTERTAINMENT 0x10
250
#define PCI_SUBCLASS_CRYPT_MISC 0x80
252
/* 0x11 data acquisition and signal processing controller subclasses */
253
#define PCI_SUBCLASS_DATAACQ_DPIO 0x00
254
#define PCI_SUBCLASS_DATAACQ_MISC 0x80
258
#define PCI_HEADER_MISC 0x0c
259
#define PCI_HEADER_MULTIFUNCTION 0x00800000
261
/* Interrupt configration register */
262
#define PCI_INTERRUPT_REG 0x3c
263
#define PCI_INTERRUPT_PIN_MASK 0x0000ff00
264
#define PCI_INTERRUPT_PIN_EXTRACT(x) \
265
((((x) & PCI_INTERRUPT_PIN_MASK) >> 8) & 0xff)
266
#define PCI_INTERRUPT_PIN_NONE 0x00
267
#define PCI_INTERRUPT_PIN_A 0x01
268
#define PCI_INTERRUPT_PIN_B 0x02
269
#define PCI_INTERRUPT_PIN_C 0x03
270
#define PCI_INTERRUPT_PIN_D 0x04
272
#define PCI_INTERRUPT_LINE_MASK 0x000000ff
273
#define PCI_INTERRUPT_LINE_EXTRACT(x) \
274
((((x) & PCI_INTERRUPT_LINE_MASK) >> 0) & 0xff)
275
#define PCI_INTERRUPT_LINE_INSERT(x,v) \
276
(((x) & ~PCI_INTERRUPT_LINE_MASK) | ((v) << 0))
279
#define PCI_MAP_REG_START 0x10
280
#define PCI_MAP_REG_END 0x28
281
#define PCI_MAP_ROM_REG 0x30
283
#define PCI_MAP_MEMORY 0x00000000
284
#define PCI_MAP_IO 0x00000001
286
#define PCI_MAP_MEMORY_TYPE 0x00000007
287
#define PCI_MAP_IO_TYPE 0x00000003
289
#define PCI_MAP_MEMORY_TYPE_32BIT 0x00000000
290
#define PCI_MAP_MEMORY_TYPE_32BIT_1M 0x00000002
291
#define PCI_MAP_MEMORY_TYPE_64BIT 0x00000004
292
#define PCI_MAP_MEMORY_TYPE_MASK 0x00000006
293
#define PCI_MAP_MEMORY_CACHABLE 0x00000008
294
#define PCI_MAP_MEMORY_ATTR_MASK 0x0000000e
295
#define PCI_MAP_MEMORY_ADDRESS_MASK 0xfffffff0
297
#define PCI_MAP_IO_ATTR_MASK 0x00000003
299
#define PCI_MAP_IS_IO(b) ((b) & PCI_MAP_IO)
300
#define PCI_MAP_IS_MEM(b) (!PCI_MAP_IS_IO(b))
302
#define PCI_MAP_IS64BITMEM(b) \
303
(((b) & PCI_MAP_MEMORY_TYPE_MASK) == PCI_MAP_MEMORY_TYPE_64BIT)
305
#define PCIGETMEMORY(b) ((b) & PCI_MAP_MEMORY_ADDRESS_MASK)
306
#define PCIGETMEMORY64HIGH(b) (*((CARD32*)&b + 1))
307
#define PCIGETMEMORY64(b) \
308
(PCIGETMEMORY(b) | ((CARD64)PCIGETMEMORY64HIGH(b) << 32))
310
#define PCI_MAP_IO_ADDRESS_MASK 0xfffffffc
312
#define PCIGETIO(b) ((b) & PCI_MAP_IO_ADDRESS_MASK)
314
#define PCI_MAP_ROM_DECODE_ENABLE 0x00000001
315
#define PCI_MAP_ROM_ADDRESS_MASK 0xfffff800
317
#define PCIGETROM(b) ((b) & PCI_MAP_ROM_ADDRESS_MASK)
319
/* PCI-PCI bridge mapping registers */
320
#define PCI_PCI_BRIDGE_BUS_REG 0x18
321
#define PCI_SUBORDINATE_BUS_MASK 0x00ff0000
322
#define PCI_SECONDARY_BUS_MASK 0x0000ff00
323
#define PCI_PRIMARY_BUS_MASK 0x000000ff
325
#define PCI_PCI_BRIDGE_IO_REG 0x1c
326
#define PCI_PCI_BRIDGE_MEM_REG 0x20
327
#define PCI_PCI_BRIDGE_PMEM_REG 0x24
329
#define PCI_PPB_IOBASE_EXTRACT(x) (((x) << 8) & 0xFF00)
330
#define PCI_PPB_IOLIMIT_EXTRACT(x) (((x) << 0) & 0xFF00)
332
#define PCI_PPB_MEMBASE_EXTRACT(x) (((x) << 16) & 0xFFFF0000)
333
#define PCI_PPB_MEMLIMIT_EXTRACT(x) (((x) << 0) & 0xFFFF0000)
335
#define PCI_PCI_BRIDGE_CONTROL_REG 0x3E
336
#define PCI_PCI_BRIDGE_PARITY_EN 0x01
337
#define PCI_PCI_BRIDGE_SERR_EN 0x02
338
#define PCI_PCI_BRIDGE_ISA_EN 0x04
339
#define PCI_PCI_BRIDGE_VGA_EN 0x08
340
#define PCI_PCI_BRIDGE_MASTER_ABORT_EN 0x20
341
#define PCI_PCI_BRIDGE_SECONDARY_RESET 0x40
342
#define PCI_PCI_BRIDGE_FAST_B2B_EN 0x80
343
/* header type 2 extensions */
344
#define PCI_CB_BRIDGE_CTL_CB_RESET 0x40 /* CardBus reset */
345
#define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80 /* Enable interrupt for 16-bit cards */
346
#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100
347
#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM1 0x200
348
#define PCI_CB_BRIDGE_CTL_POST_WRITES 0x400
350
#define PCI_CB_SEC_STATUS_REG 0x16 /* Secondary status */
351
#define PCI_CB_PRIMARY_BUS_REG 0x18 /* PCI bus number */
352
#define PCI_CB_CARD_BUS_REG 0x19 /* CardBus bus number */
353
#define PCI_CB_SUBORDINATE_BUS_REG 0x1a /* Subordinate bus number */
354
#define PCI_CB_LATENCY_TIMER_REG 0x1b /* CardBus latency timer */
355
#define PCI_CB_MEM_BASE_0_REG 0x1c
356
#define PCI_CB_MEM_LIMIT_0_REG 0x20
357
#define PCI_CB_MEM_BASE_1_REG 0x24
358
#define PCI_CB_MEM_LIMIT_1_REG 0x28
359
#define PCI_CB_IO_BASE_0_REG 0x2c
360
#define PCI_CB_IO_LIMIT_0_REG 0x30
361
#define PCI_CB_IO_BASE_1_REG 0x34
362
#define PCI_CB_IO_LIMIT_1_REG 0x38
363
#define PCI_CB_BRIDGE_CONTROL_REG 0x3E
365
#define PCI_CB_IO_RANGE_MASK ~0x03
366
#define PCI_CB_IOBASE(x) (x & PCI_CB_IO_RANGE_MASK)
367
#define PCI_CB_IOLIMIT(x) ((x & PCI_CB_IO_RANGE_MASK) + 3)
369
/* Subsystem identification register */
370
#define PCI_SUBSYSTEM_ID_REG 0x2c
372
/* User defined cfg space regs */
373
#define PCI_REG_USERCONFIG 0x40
374
#define PCI_OPTION_REG 0x40
380
/* Primitive Types */
381
typedef unsigned long ADDRESS; /* Memory/PCI address */
382
typedef unsigned long IOADDRESS; /* Must be large enough for a pointer */
383
typedef unsigned long PCITAG;
386
* PCI configuration space
388
typedef struct pci_cfg_regs {
389
/* start of official PCI config space header */
390
union { /* Offset 0x0 - 0x3 */
391
CARD32 device_vendor;
393
#if X_BYTE_ORDER == X_BIG_ENDIAN
403
union { /* Offset 0x4 - 0x8 */
404
CARD32 status_command;
406
#if X_BYTE_ORDER == X_BIG_ENDIAN
416
union { /* Offset 0x8 - 0xb */
417
CARD32 class_revision;
419
#if X_BYTE_ORDER == X_BIG_ENDIAN
433
union { /* Offset 0xc - 0xf */
434
CARD32 bist_header_latency_cache;
436
#if X_BYTE_ORDER == X_BIG_ENDIAN
440
CARD8 cache_line_size;
442
CARD8 cache_line_size;
449
union { /* Offset 0x10 - 0x3b */
450
struct { /* header type 2 */
451
CARD32 cg_rsrvd1; /* 0x10 */
452
#if X_BYTE_ORDER == X_BIG_ENDIAN
453
CARD16 secondary_status; /* 0x16 */
454
CARD16 cg_rsrvd2; /* 0x14 */
459
CARD8 latency_timer; /* 0x1b */
460
CARD8 subordinate_bus_number; /* 0x1a */
461
CARD8 cardbus_bus_number; /* 0x19 */
462
CARD8 primary_bus_number; /* 0x18 */
466
CARD16 cg_rsrvd2; /* 0x14 */
467
CARD16 secondary_status; /* 0x16 */
472
CARD8 primary_bus_number; /* 0x18 */
473
CARD8 cardbus_bus_number; /* 0x19 */
474
CARD8 subordinate_bus_number; /* 0x1a */
475
CARD8 latency_timer; /* 0x1b */
479
CARD32 mem_base0; /* 0x1c */
480
CARD32 mem_limit0; /* 0x20 */
481
CARD32 mem_base1; /* 0x24 */
482
CARD32 mem_limit1; /* 0x28 */
483
CARD32 io_base0; /* 0x2c */
484
CARD32 io_limit0; /* 0x30 */
485
CARD32 io_base1; /* 0x34 */
486
CARD32 io_limit1; /* 0x38 */
489
union { /* Offset 0x10 - 0x27 */
490
struct { /* header type 0 */
498
struct { /* header type 1 */
500
#if X_BYTE_ORDER == X_BIG_ENDIAN
504
CARD8 secondary_latency_timer;
505
CARD8 subordinate_bus_number;
506
CARD8 secondary_bus_number;
507
CARD8 primary_bus_number;
511
CARD16 secondary_status;
518
CARD16 prefetch_mem_limit;
519
CARD16 prefetch_mem_base;
524
CARD8 primary_bus_number;
525
CARD8 secondary_bus_number;
526
CARD8 subordinate_bus_number;
527
CARD8 secondary_latency_timer;
533
CARD16 secondary_status;
538
CARD16 prefetch_mem_base;
539
CARD16 prefetch_mem_limit;
543
union { /* Offset 0x28 - 0x2b */
545
CARD32 pftch_umem_base;
546
CARD32 cardbus_cis_ptr;
548
union { /* Offset 0x2c - 0x2f */
549
CARD32 subsys_card_vendor;
550
CARD32 pftch_umem_limit;
553
#if X_BYTE_ORDER == X_BIG_ENDIAN
555
CARD16 subsys_vendor;
557
CARD16 subsys_vendor;
562
union { /* Offset 0x30 - 0x33 */
565
#if X_BYTE_ORDER == X_BIG_ENDIAN
575
CARD32 rsvd3; /* Offset 0x34 - 0x37 */
576
CARD32 rsvd4; /* Offset 0x38 - 0x3b */
580
union { /* Offset 0x3c - 0x3f */
581
union { /* header type 0 */
582
CARD32 max_min_ipin_iline;
584
#if X_BYTE_ORDER == X_BIG_ENDIAN
597
struct { /* header type 1 */
598
#if X_BYTE_ORDER == X_BIG_ENDIAN
599
CARD16 bridge_control; /* upper 8 bits reserved */
605
CARD16 bridge_control; /* upper 8 bits reserved */
609
union { /* Offset 0x40 - 0xff */
615
typedef union pci_cfg_spc {
617
CARD32 dwords[256/sizeof(CARD32)];
618
CARD8 bytes[256/sizeof(CARD8)];
622
* Data structure returned by xf86scanpci including contents of
623
* PCI config space header
625
typedef struct pci_device {
631
int basesize[7]; /* number of bits in base addr allocations */
634
pointer businfo; /* pointer to secondary's bus info structure */
635
Bool fakeDevice; /* Device added by system chipset support */
636
} pciDevice, *pciConfigPtr;
655
#define pci_device_vendor cfgspc.regs.dv_id.device_vendor
656
#define pci_vendor cfgspc.regs.dv_id.dv.vendor
657
#define pci_device cfgspc.regs.dv_id.dv.device
658
#define pci_status_command cfgspc.regs.stat_cmd.status_command
659
#define pci_command cfgspc.regs.stat_cmd.sc.command
660
#define pci_status cfgspc.regs.stat_cmd.sc.status
661
#define pci_class_revision cfgspc.regs.class_rev.class_revision
662
#define pci_rev_id cfgspc.regs.class_rev.cr.rev_id
663
#define pci_prog_if cfgspc.regs.class_rev.cr.prog_if
664
#define pci_sub_class cfgspc.regs.class_rev.cr.sub_class
665
#define pci_base_class cfgspc.regs.class_rev.cr.base_class
666
#define pci_bist_header_latency_cache cfgspc.regs.bhlc.bist_header_latency_cache
667
#define pci_cache_line_size cfgspc.regs.bhlc.bhlc.cache_line_size
668
#define pci_latency_timer cfgspc.regs.bhlc.bhlc.latency_timer
669
#define pci_header_type cfgspc.regs.bhlc.bhlc.header_type
670
#define pci_bist cfgspc.regs.bhlc.bhlc.bist
671
#define pci_cb_secondary_status cfgspc.regs.cx.cg.secondary_status
672
#define pci_cb_bus_register cfgspc.regs.cx.cg.cgbr.cg_bus_reg
673
#define pci_cb_primary_bus_number cfgspc.regs.cx.cg.cgbr.cgbr.primary_bus_number
674
#define pci_cb_cardbus_bus_number cfgspc.regs.cx.cg.cgbr.cgbr.cardbus_bus_number
675
#define pci_cb_subordinate_bus_number cfgspc.regs.cx.cg.cgbr.cgbr.subordinate_bus_number
676
#define pci_cb_latency_timer cfgspc.regs.cx.cg.cgbr.cgbr.latency_timer
677
#define pci_cb_membase0 cfgspc.regs.cx.cg.mem_base0
678
#define pci_cb_memlimit0 cfgspc.regs.cx.cg.mem_limit0
679
#define pci_cb_membase1 cfgspc.regs.cx.cg.mem_base1
680
#define pci_cb_memlimit1 cfgspc.regs.cx.cg.mem_limit1
681
#define pci_cb_iobase0 cfgspc.regs.cx.cg.io_base0
682
#define pci_cb_iolimit0 cfgspc.regs.cx.cg.io_limit0
683
#define pci_cb_iobase1 cfgspc.regs.cx.cg.io_base1
684
#define pci_cb_iolimit1 cfgspc.regs.cx.cg.io_limit1
685
#define pci_base0 cfgspc.regs.cx.cd.bc.dv.dv_base0
686
#define pci_base1 cfgspc.regs.cx.cd.bc.dv.dv_base1
687
#define pci_base2 cfgspc.regs.cx.cd.bc.dv.dv_base2
688
#define pci_base3 cfgspc.regs.cx.cd.bc.dv.dv_base3
689
#define pci_base4 cfgspc.regs.cx.cd.bc.dv.dv_base4
690
#define pci_base5 cfgspc.regs.cx.cd.bc.dv.dv_base5
691
#define pci_cardbus_cis_ptr cfgspc.regs.cx.cd.umem_c_cis.cardbus_cis_ptr
692
#define pci_subsys_card_vendor cfgspc.regs.cx.cd.um_ssys_id.subsys_card_vendor
693
#define pci_subsys_vendor cfgspc.regs.cx.cd.um_ssys_id.ssys.subsys_vendor
694
#define pci_subsys_card cfgspc.regs.cx.cd.um_ssys_id.ssys.subsys_card
695
#define pci_baserom cfgspc.regs.cx.cd.uio_rom.baserom
696
#define pci_pp_bus_register cfgspc.regs.cx.cd.bc.bg.ppbr.pp_bus_reg
697
#define pci_primary_bus_number cfgspc.regs.cx.cd.bc.bg.ppbr.ppbr.primary_bus_number
698
#define pci_secondary_bus_number cfgspc.regs.cx.cd.bc.bg.ppbr.ppbr.secondary_bus_number
699
#define pci_subordinate_bus_number cfgspc.regs.cx.cd.bc.bg.ppbr.ppbr.subordinate_bus_number
700
#define pci_secondary_latency_timer cfgspc.regs.cx.cd.bc.bg.ppbr.ppbr.secondary_latency_timer
701
#define pci_io_base cfgspc.regs.cx.cd.bc.bg.io_base
702
#define pci_io_limit cfgspc.regs.cx.cd.bc.bg.io_limit
703
#define pci_secondary_status cfgspc.regs.cx.cd.bc.bg.secondary_status
704
#define pci_mem_base cfgspc.regs.cx.cd.bc.bg.mem_base
705
#define pci_mem_limit cfgspc.regs.cx.cd.bc.bg.mem_limit
706
#define pci_prefetch_mem_base cfgspc.regs.cx.cd.bc.bg.prefetch_mem_base
707
#define pci_prefetch_mem_limit cfgspc.regs.cx.cd.bc.bg.prefetch_mem_limit
708
#define pci_rsvd1 cfgspc.regs.cx.cd.um_c_cis.rsvd1
709
#define pci_rsvd2 cfgspc.regs.cx.cd.um_ssys_id.rsvd2
710
#define pci_prefetch_upper_mem_base cfgspc.regs.cx.cd.um_c_cis.pftch_umem_base
711
#define pci_prefetch_upper_mem_limit cfgspc.regs.cx.cd.um_ssys_id.pftch_umem_limit
712
#define pci_upper_io_base cfgspc.regs.cx.cd.uio_rom.b_u_io.io_ubase
713
#define pci_upper_io_limit cfgspc.regs.cx.cd.uio_rom.b_u_io.io_ulimit
714
#define pci_int_line cfgspc.regs.bm.mmii.mmii.int_line
715
#define pci_int_pin cfgspc.regs.bm.mmii.mmii.int_pin
716
#define pci_min_gnt cfgspc.regs.bm.mmii.mmii.min_gnt
717
#define pci_max_lat cfgspc.regs.bm.mmii.mmii.max_lat
718
#define pci_max_min_ipin_iline cfgspc.regs.bm.mmii.max_min_ipin_iline
719
#define pci_bridge_control cfgspc.regs.bm.bctrl.bridge_control
720
#define pci_user_config cfgspc.regs.devspf.dwords[0]
721
#define pci_user_config_0 cfgspc.regs.devspf.bytes[0]
722
#define pci_user_config_1 cfgspc.regs.devspf.bytes[1]
723
#define pci_user_config_2 cfgspc.regs.devspf.bytes[2]
724
#define pci_user_config_3 cfgspc.regs.devspf.bytes[3]
728
PCI_BIOS_OPEN_FIRMARE,
733
/* Public PCI access functions */
735
PCITAG pciFindFirst(CARD32 id, CARD32 mask);
736
PCITAG pciFindNext(void);
737
CARD32 pciReadLong(PCITAG tag, int offset);
738
CARD16 pciReadWord(PCITAG tag, int offset);
739
CARD8 pciReadByte(PCITAG tag, int offset);
740
void pciWriteLong(PCITAG tag, int offset, CARD32 val);
741
void pciWriteWord(PCITAG tag, int offset, CARD16 val);
742
void pciWriteByte(PCITAG tag, int offset, CARD8 val);
743
void pciSetBitsLong(PCITAG tag, int offset, CARD32 mask, CARD32 val);
744
void pciSetBitsByte(PCITAG tag, int offset, CARD8 mask, CARD8 val);
745
pointer pciLongFunc(PCITAG tag, pciFunc func);
746
ADDRESS pciBusAddrToHostAddr(PCITAG tag, PciAddrType type, ADDRESS addr);
747
ADDRESS pciHostAddrToBusAddr(PCITAG tag, PciAddrType type, ADDRESS addr);
748
PCITAG pciTag(int busnum, int devnum, int funcnum);
749
int pciGetBaseSize(PCITAG tag, int indx, Bool destructive, Bool *min);
750
CARD32 pciCheckForBrokenBase(PCITAG tag,int basereg);
751
pointer xf86MapPciMem(int ScreenNum, int Flags, PCITAG Tag,
752
ADDRESS Base, unsigned long Size);
753
int xf86ReadPciBIOS(unsigned long Offset, PCITAG Tag, int basereg,
754
unsigned char *Buf, int Len);
755
int xf86ReadPciBIOSByType(unsigned long Offset, PCITAG Tag,
756
int basereg, unsigned char *Buf,
757
int Len, PciBiosType Type);
758
int xf86GetAvailablePciBIOSTypes(PCITAG Tag, int basereg,
760
pciConfigPtr *xf86scanpci(int flags);
762
extern int pciNumBuses;
764
/* Domain access functions. Some of these probably shouldn't be public */
765
int xf86GetPciDomain(PCITAG tag);
766
pointer xf86MapDomainMemory(int ScreenNum, int Flags, PCITAG Tag,
767
ADDRESS Base, unsigned long Size);
768
IOADDRESS xf86MapDomainIO(int ScreenNum, int Flags, PCITAG Tag,
769
IOADDRESS Base, unsigned long Size);
770
int xf86ReadDomainMemory(PCITAG Tag, ADDRESS Base, int Len,
774
ROM_BASE_PRESET = -2,
785
#endif /* _XF86PCI_H */