1
/* $XFree86: xc/programs/Xserver/hw/xfree86/os-support/bus/xf86Pci.h,v 1.39 2003/08/24 17:37:05 dawes 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.
73
* Copyright (c) 1999-2003 by The XFree86 Project, Inc.
75
* Permission is hereby granted, free of charge, to any person obtaining a
76
* copy of this software and associated documentation files (the "Software"),
77
* to deal in the Software without restriction, including without limitation
78
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
79
* and/or sell copies of the Software, and to permit persons to whom the
80
* Software is furnished to do so, subject to the following conditions:
82
* The above copyright notice and this permission notice shall be included in
83
* all copies or substantial portions of the Software.
85
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
86
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
87
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
88
* THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
89
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
90
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
91
* OTHER DEALINGS IN THE SOFTWARE.
93
* Except as contained in this notice, the name of the copyright holder(s)
94
* and author(s) shall not be used in advertising or otherwise to promote
95
* the sale, use or other dealings in this Software without prior written
96
* authorization from the copyright holder(s) and author(s).
101
* This file contains just the public interface to the PCI code.
102
* Drivers should use this file rather than Pci.h.
107
#include <X11/Xarch.h>
108
#include <X11/Xfuncproto.h>
111
#define PCI_NOT_FOUND 0xFFFFFFFFU
114
* PCI cfg space definitions (e.g. stuff right out of the PCI spec)
117
/* Device identification register */
118
#define PCI_ID_REG 0x00
120
/* Command and status register */
121
#define PCI_CMD_STAT_REG 0x04
122
#define PCI_CMD_BASE_REG 0x10
123
#define PCI_CMD_BIOS_REG 0x30
124
#define PCI_CMD_MASK 0xffff
125
#define PCI_CMD_IO_ENABLE 0x01
126
#define PCI_CMD_MEM_ENABLE 0x02
127
#define PCI_CMD_MASTER_ENABLE 0x04
128
#define PCI_CMD_SPECIAL_ENABLE 0x08
129
#define PCI_CMD_INVALIDATE_ENABLE 0x10
130
#define PCI_CMD_PALETTE_ENABLE 0x20
131
#define PCI_CMD_PARITY_ENABLE 0x40
132
#define PCI_CMD_STEPPING_ENABLE 0x80
133
#define PCI_CMD_SERR_ENABLE 0x100
134
#define PCI_CMD_BACKTOBACK_ENABLE 0x200
135
#define PCI_CMD_BIOS_ENABLE 0x01
138
#define PCI_CLASS_REG 0x08
139
#define PCI_CLASS_MASK 0xff000000
140
#define PCI_CLASS_SHIFT 24
141
#define PCI_CLASS_EXTRACT(x) \
142
(((x) & PCI_CLASS_MASK) >> PCI_CLASS_SHIFT)
144
/* base class values */
145
#define PCI_CLASS_PREHISTORIC 0x00
146
#define PCI_CLASS_MASS_STORAGE 0x01
147
#define PCI_CLASS_NETWORK 0x02
148
#define PCI_CLASS_DISPLAY 0x03
149
#define PCI_CLASS_MULTIMEDIA 0x04
150
#define PCI_CLASS_MEMORY 0x05
151
#define PCI_CLASS_BRIDGE 0x06
152
#define PCI_CLASS_COMMUNICATIONS 0x07
153
#define PCI_CLASS_SYSPERIPH 0x08
154
#define PCI_CLASS_INPUT 0x09
155
#define PCI_CLASS_DOCKING 0x0a
156
#define PCI_CLASS_PROCESSOR 0x0b
157
#define PCI_CLASS_SERIALBUS 0x0c
158
#define PCI_CLASS_WIRELESS 0x0d
159
#define PCI_CLASS_I2O 0x0e
160
#define PCI_CLASS_SATELLITE 0x0f
161
#define PCI_CLASS_CRYPT 0x10
162
#define PCI_CLASS_DATA_ACQUISTION 0x11
163
#define PCI_CLASS_UNDEFINED 0xff
166
#define PCI_SUBCLASS_MASK 0x00ff0000
167
#define PCI_SUBCLASS_SHIFT 16
168
#define PCI_SUBCLASS_EXTRACT(x) \
169
(((x) & PCI_SUBCLASS_MASK) >> PCI_SUBCLASS_SHIFT)
171
/* Sub class values */
172
/* 0x00 prehistoric subclasses */
173
#define PCI_SUBCLASS_PREHISTORIC_MISC 0x00
174
#define PCI_SUBCLASS_PREHISTORIC_VGA 0x01
176
/* 0x01 mass storage subclasses */
177
#define PCI_SUBCLASS_MASS_STORAGE_SCSI 0x00
178
#define PCI_SUBCLASS_MASS_STORAGE_IDE 0x01
179
#define PCI_SUBCLASS_MASS_STORAGE_FLOPPY 0x02
180
#define PCI_SUBCLASS_MASS_STORAGE_IPI 0x03
181
#define PCI_SUBCLASS_MASS_STORAGE_MISC 0x80
183
/* 0x02 network subclasses */
184
#define PCI_SUBCLASS_NETWORK_ETHERNET 0x00
185
#define PCI_SUBCLASS_NETWORK_TOKENRING 0x01
186
#define PCI_SUBCLASS_NETWORK_FDDI 0x02
187
#define PCI_SUBCLASS_NETWORK_MISC 0x80
189
/* 0x03 display subclasses */
190
#define PCI_SUBCLASS_DISPLAY_VGA 0x00
191
#define PCI_SUBCLASS_DISPLAY_XGA 0x01
192
#define PCI_SUBCLASS_DISPLAY_MISC 0x80
194
/* 0x04 multimedia subclasses */
195
#define PCI_SUBCLASS_MULTIMEDIA_VIDEO 0x00
196
#define PCI_SUBCLASS_MULTIMEDIA_AUDIO 0x01
197
#define PCI_SUBCLASS_MULTIMEDIA_MISC 0x80
199
/* 0x05 memory subclasses */
200
#define PCI_SUBCLASS_MEMORY_RAM 0x00
201
#define PCI_SUBCLASS_MEMORY_FLASH 0x01
202
#define PCI_SUBCLASS_MEMORY_MISC 0x80
204
/* 0x06 bridge subclasses */
205
#define PCI_SUBCLASS_BRIDGE_HOST 0x00
206
#define PCI_SUBCLASS_BRIDGE_ISA 0x01
207
#define PCI_SUBCLASS_BRIDGE_EISA 0x02
208
#define PCI_SUBCLASS_BRIDGE_MC 0x03
209
#define PCI_SUBCLASS_BRIDGE_PCI 0x04
210
#define PCI_SUBCLASS_BRIDGE_PCMCIA 0x05
211
#define PCI_SUBCLASS_BRIDGE_NUBUS 0x06
212
#define PCI_SUBCLASS_BRIDGE_CARDBUS 0x07
213
#define PCI_SUBCLASS_BRIDGE_RACEWAY 0x08
214
#define PCI_SUBCLASS_BRIDGE_MISC 0x80
215
#define PCI_IF_BRIDGE_PCI_SUBTRACTIVE 0x01
217
/* 0x07 communications controller subclasses */
218
#define PCI_SUBCLASS_COMMUNICATIONS_SERIAL 0x00
219
#define PCI_SUBCLASS_COMMUNICATIONS_PARALLEL 0x01
220
#define PCI_SUBCLASS_COMMUNICATIONS_MULTISERIAL 0x02
221
#define PCI_SUBCLASS_COMMUNICATIONS_MODEM 0x03
222
#define PCI_SUBCLASS_COMMUNICATIONS_MISC 0x80
224
/* 0x08 generic system peripherals subclasses */
225
#define PCI_SUBCLASS_SYSPERIPH_PIC 0x00
226
#define PCI_SUBCLASS_SYSPERIPH_DMA 0x01
227
#define PCI_SUBCLASS_SYSPERIPH_TIMER 0x02
228
#define PCI_SUBCLASS_SYSPERIPH_RTC 0x03
229
#define PCI_SUBCLASS_SYSPERIPH_HOTPCI 0x04
230
#define PCI_SUBCLASS_SYSPERIPH_MISC 0x80
232
/* 0x09 input device subclasses */
233
#define PCI_SUBCLASS_INPUT_KEYBOARD 0x00
234
#define PCI_SUBCLASS_INPUT_DIGITIZER 0x01
235
#define PCI_SUBCLASS_INPUT_MOUSE 0x02
236
#define PCI_SUBCLASS_INPUT_SCANNER 0x03
237
#define PCI_SUBCLASS_INPUT_GAMEPORT 0x04
238
#define PCI_SUBCLASS_INPUT_MISC 0x80
240
/* 0x0a docking station subclasses */
241
#define PCI_SUBCLASS_DOCKING_GENERIC 0x00
242
#define PCI_SUBCLASS_DOCKING_MISC 0x80
244
/* 0x0b processor subclasses */
245
#define PCI_SUBCLASS_PROCESSOR_386 0x00
246
#define PCI_SUBCLASS_PROCESSOR_486 0x01
247
#define PCI_SUBCLASS_PROCESSOR_PENTIUM 0x02
248
#define PCI_SUBCLASS_PROCESSOR_ALPHA 0x10
249
#define PCI_SUBCLASS_PROCESSOR_POWERPC 0x20
250
#define PCI_SUBCLASS_PROCESSOR_MIPS 0x30
251
#define PCI_SUBCLASS_PROCESSOR_COPROC 0x40
253
/* 0x0c serial bus controller subclasses */
254
#define PCI_SUBCLASS_SERIAL_FIREWIRE 0x00
255
#define PCI_SUBCLASS_SERIAL_ACCESS 0x01
256
#define PCI_SUBCLASS_SERIAL_SSA 0x02
257
#define PCI_SUBCLASS_SERIAL_USB 0x03
258
#define PCI_SUBCLASS_SERIAL_FIBRECHANNEL 0x04
259
#define PCI_SUBCLASS_SERIAL_SMBUS 0x05
261
/* 0x0d wireless controller subclasses */
262
#define PCI_SUBCLASS_WIRELESS_IRDA 0x00
263
#define PCI_SUBCLASS_WIRELESS_CONSUMER_IR 0x01
264
#define PCI_SUBCLASS_WIRELESS_RF 0x02
265
#define PCI_SUBCLASS_WIRELESS_MISC 0x80
267
/* 0x0e intelligent I/O controller subclasses */
268
#define PCI_SUBCLASS_I2O_I2O 0x00
270
/* 0x0f satellite communications controller subclasses */
271
#define PCI_SUBCLASS_SATELLITE_TV 0x01
272
#define PCI_SUBCLASS_SATELLITE_AUDIO 0x02
273
#define PCI_SUBCLASS_SATELLITE_VOICE 0x03
274
#define PCI_SUBCLASS_SATELLITE_DATA 0x04
276
/* 0x10 encryption/decryption controller subclasses */
277
#define PCI_SUBCLASS_CRYPT_NET_COMPUTING 0x00
278
#define PCI_SUBCLASS_CRYPT_ENTERTAINMENT 0x10
279
#define PCI_SUBCLASS_CRYPT_MISC 0x80
281
/* 0x11 data acquisition and signal processing controller subclasses */
282
#define PCI_SUBCLASS_DATAACQ_DPIO 0x00
283
#define PCI_SUBCLASS_DATAACQ_MISC 0x80
287
#define PCI_HEADER_MISC 0x0c
288
#define PCI_HEADER_MULTIFUNCTION 0x00800000
290
/* Interrupt configration register */
291
#define PCI_INTERRUPT_REG 0x3c
292
#define PCI_INTERRUPT_PIN_MASK 0x0000ff00
293
#define PCI_INTERRUPT_PIN_EXTRACT(x) \
294
((((x) & PCI_INTERRUPT_PIN_MASK) >> 8) & 0xff)
295
#define PCI_INTERRUPT_PIN_NONE 0x00
296
#define PCI_INTERRUPT_PIN_A 0x01
297
#define PCI_INTERRUPT_PIN_B 0x02
298
#define PCI_INTERRUPT_PIN_C 0x03
299
#define PCI_INTERRUPT_PIN_D 0x04
301
#define PCI_INTERRUPT_LINE_MASK 0x000000ff
302
#define PCI_INTERRUPT_LINE_EXTRACT(x) \
303
((((x) & PCI_INTERRUPT_LINE_MASK) >> 0) & 0xff)
304
#define PCI_INTERRUPT_LINE_INSERT(x,v) \
305
(((x) & ~PCI_INTERRUPT_LINE_MASK) | ((v) << 0))
308
#define PCI_MAP_REG_START 0x10
309
#define PCI_MAP_REG_END 0x28
310
#define PCI_MAP_ROM_REG 0x30
312
#define PCI_MAP_MEMORY 0x00000000
313
#define PCI_MAP_IO 0x00000001
315
#define PCI_MAP_MEMORY_TYPE 0x00000007
316
#define PCI_MAP_IO_TYPE 0x00000003
318
#define PCI_MAP_MEMORY_TYPE_32BIT 0x00000000
319
#define PCI_MAP_MEMORY_TYPE_32BIT_1M 0x00000002
320
#define PCI_MAP_MEMORY_TYPE_64BIT 0x00000004
321
#define PCI_MAP_MEMORY_TYPE_MASK 0x00000006
322
#define PCI_MAP_MEMORY_CACHABLE 0x00000008
323
#define PCI_MAP_MEMORY_ATTR_MASK 0x0000000e
324
#define PCI_MAP_MEMORY_ADDRESS_MASK 0xfffffff0
326
#define PCI_MAP_IO_ATTR_MASK 0x00000003
328
#define PCI_MAP_IS_IO(b) ((b) & PCI_MAP_IO)
329
#define PCI_MAP_IS_MEM(b) (!PCI_MAP_IS_IO(b))
331
#define PCI_MAP_IS64BITMEM(b) \
332
(((b) & PCI_MAP_MEMORY_TYPE) == PCI_MAP_MEMORY_TYPE_64BIT)
334
#define PCIGETMEMORY(b) ((b) & PCI_MAP_MEMORY_ADDRESS_MASK)
335
#define PCIGETMEMORY64HIGH(b) (*((CARD32*)&(b) + 1))
336
#define PCIGETMEMORY64(b) \
337
(PCIGETMEMORY(b) | ((CARD64)PCIGETMEMORY64HIGH(b) << 32))
339
#define PCI_MAP_IO_ADDRESS_MASK 0xfffffffc
341
#define PCIGETIO(b) ((b) & PCI_MAP_IO_ADDRESS_MASK)
343
#define PCI_MAP_ROM_DECODE_ENABLE 0x00000001
344
#define PCI_MAP_ROM_ADDRESS_MASK 0xfffff800
346
#define PCIGETROM(b) ((b) & PCI_MAP_ROM_ADDRESS_MASK)
348
/* PCI-PCI bridge mapping registers */
349
#define PCI_PCI_BRIDGE_BUS_REG 0x18
350
#define PCI_SUBORDINATE_BUS_MASK 0x00ff0000
351
#define PCI_SECONDARY_BUS_MASK 0x0000ff00
352
#define PCI_PRIMARY_BUS_MASK 0x000000ff
354
#define PCI_PCI_BRIDGE_IO_REG 0x1c
355
#define PCI_PCI_BRIDGE_MEM_REG 0x20
356
#define PCI_PCI_BRIDGE_PMEM_REG 0x24
358
#define PCI_PPB_IOBASE_EXTRACT(x) (((x) << 8) & 0xFF00)
359
#define PCI_PPB_IOLIMIT_EXTRACT(x) (((x) << 0) & 0xFF00)
361
#define PCI_PPB_MEMBASE_EXTRACT(x) (((x) << 16) & 0xFFFF0000)
362
#define PCI_PPB_MEMLIMIT_EXTRACT(x) (((x) << 0) & 0xFFFF0000)
364
#define PCI_PCI_BRIDGE_CONTROL_REG 0x3E
365
#define PCI_PCI_BRIDGE_PARITY_EN 0x01
366
#define PCI_PCI_BRIDGE_SERR_EN 0x02
367
#define PCI_PCI_BRIDGE_ISA_EN 0x04
368
#define PCI_PCI_BRIDGE_VGA_EN 0x08
369
#define PCI_PCI_BRIDGE_MASTER_ABORT_EN 0x20
370
#define PCI_PCI_BRIDGE_SECONDARY_RESET 0x40
371
#define PCI_PCI_BRIDGE_FAST_B2B_EN 0x80
372
/* header type 2 extensions */
373
#define PCI_CB_BRIDGE_CTL_CB_RESET 0x40 /* CardBus reset */
374
#define PCI_CB_BRIDGE_CTL_16BIT_INT 0x80 /* Enable interrupt for 16-bit cards */
375
#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 0x100
376
#define PCI_CB_BRIDGE_CTL_PREFETCH_MEM1 0x200
377
#define PCI_CB_BRIDGE_CTL_POST_WRITES 0x400
379
#define PCI_CB_SEC_STATUS_REG 0x16 /* Secondary status */
380
#define PCI_CB_PRIMARY_BUS_REG 0x18 /* PCI bus number */
381
#define PCI_CB_CARD_BUS_REG 0x19 /* CardBus bus number */
382
#define PCI_CB_SUBORDINATE_BUS_REG 0x1a /* Subordinate bus number */
383
#define PCI_CB_LATENCY_TIMER_REG 0x1b /* CardBus latency timer */
384
#define PCI_CB_MEM_BASE_0_REG 0x1c
385
#define PCI_CB_MEM_LIMIT_0_REG 0x20
386
#define PCI_CB_MEM_BASE_1_REG 0x24
387
#define PCI_CB_MEM_LIMIT_1_REG 0x28
388
#define PCI_CB_IO_BASE_0_REG 0x2c
389
#define PCI_CB_IO_LIMIT_0_REG 0x30
390
#define PCI_CB_IO_BASE_1_REG 0x34
391
#define PCI_CB_IO_LIMIT_1_REG 0x38
392
#define PCI_CB_BRIDGE_CONTROL_REG 0x3E
394
#define PCI_CB_IO_RANGE_MASK ~0x03
395
#define PCI_CB_IOBASE(x) (x & PCI_CB_IO_RANGE_MASK)
396
#define PCI_CB_IOLIMIT(x) ((x & PCI_CB_IO_RANGE_MASK) + 3)
398
/* Subsystem identification register */
399
#define PCI_SUBSYSTEM_ID_REG 0x2c
401
/* User defined cfg space regs */
402
#define PCI_REG_USERCONFIG 0x40
403
#define PCI_OPTION_REG 0x40
409
/* Primitive Types */
410
typedef unsigned long ADDRESS; /* Memory/PCI address */
411
typedef unsigned long IOADDRESS; /* Must be large enough for a pointer */
412
typedef unsigned long PCITAG;
415
* PCI configuration space
417
typedef struct pci_cfg_regs {
418
/* start of official PCI config space header */
419
union { /* Offset 0x0 - 0x3 */
420
CARD32 device_vendor;
422
#if X_BYTE_ORDER == X_BIG_ENDIAN
432
union { /* Offset 0x4 - 0x8 */
433
CARD32 status_command;
435
#if X_BYTE_ORDER == X_BIG_ENDIAN
445
union { /* Offset 0x8 - 0xb */
446
CARD32 class_revision;
448
#if X_BYTE_ORDER == X_BIG_ENDIAN
462
union { /* Offset 0xc - 0xf */
463
CARD32 bist_header_latency_cache;
465
#if X_BYTE_ORDER == X_BIG_ENDIAN
469
CARD8 cache_line_size;
471
CARD8 cache_line_size;
478
union { /* Offset 0x10 - 0x3b */
479
struct { /* header type 2 */
480
CARD32 cg_rsrvd1; /* 0x10 */
481
#if X_BYTE_ORDER == X_BIG_ENDIAN
482
CARD16 secondary_status; /* 0x16 */
483
CARD16 cg_rsrvd2; /* 0x14 */
488
CARD8 latency_timer; /* 0x1b */
489
CARD8 subordinate_bus_number; /* 0x1a */
490
CARD8 cardbus_bus_number; /* 0x19 */
491
CARD8 primary_bus_number; /* 0x18 */
495
CARD16 cg_rsrvd2; /* 0x14 */
496
CARD16 secondary_status; /* 0x16 */
501
CARD8 primary_bus_number; /* 0x18 */
502
CARD8 cardbus_bus_number; /* 0x19 */
503
CARD8 subordinate_bus_number; /* 0x1a */
504
CARD8 latency_timer; /* 0x1b */
508
CARD32 mem_base0; /* 0x1c */
509
CARD32 mem_limit0; /* 0x20 */
510
CARD32 mem_base1; /* 0x24 */
511
CARD32 mem_limit1; /* 0x28 */
512
CARD32 io_base0; /* 0x2c */
513
CARD32 io_limit0; /* 0x30 */
514
CARD32 io_base1; /* 0x34 */
515
CARD32 io_limit1; /* 0x38 */
518
union { /* Offset 0x10 - 0x27 */
519
struct { /* header type 0 */
527
struct { /* header type 1 */
529
#if X_BYTE_ORDER == X_BIG_ENDIAN
533
CARD8 secondary_latency_timer;
534
CARD8 subordinate_bus_number;
535
CARD8 secondary_bus_number;
536
CARD8 primary_bus_number;
540
CARD16 secondary_status;
547
CARD16 prefetch_mem_limit;
548
CARD16 prefetch_mem_base;
553
CARD8 primary_bus_number;
554
CARD8 secondary_bus_number;
555
CARD8 subordinate_bus_number;
556
CARD8 secondary_latency_timer;
562
CARD16 secondary_status;
567
CARD16 prefetch_mem_base;
568
CARD16 prefetch_mem_limit;
572
union { /* Offset 0x28 - 0x2b */
574
CARD32 pftch_umem_base;
575
CARD32 cardbus_cis_ptr;
577
union { /* Offset 0x2c - 0x2f */
578
CARD32 subsys_card_vendor;
579
CARD32 pftch_umem_limit;
582
#if X_BYTE_ORDER == X_BIG_ENDIAN
584
CARD16 subsys_vendor;
586
CARD16 subsys_vendor;
591
union { /* Offset 0x30 - 0x33 */
594
#if X_BYTE_ORDER == X_BIG_ENDIAN
604
CARD32 rsvd3; /* Offset 0x34 - 0x37 */
605
CARD32 rsvd4; /* Offset 0x38 - 0x3b */
609
union { /* Offset 0x3c - 0x3f */
610
union { /* header type 0 */
611
CARD32 max_min_ipin_iline;
613
#if X_BYTE_ORDER == X_BIG_ENDIAN
626
struct { /* header type 1 */
627
#if X_BYTE_ORDER == X_BIG_ENDIAN
628
CARD16 bridge_control; /* upper 8 bits reserved */
634
CARD16 bridge_control; /* upper 8 bits reserved */
638
union { /* Offset 0x40 - 0xff */
644
typedef union pci_cfg_spc {
646
CARD32 dwords[256/sizeof(CARD32)];
647
CARD8 bytes[256/sizeof(CARD8)];
651
* Data structure returned by xf86scanpci including contents of
652
* PCI config space header
654
typedef struct pci_device {
660
int basesize[7]; /* number of bits in base addr allocations */
662
pointer businfo; /* pointer to secondary's bus info structure */
663
Bool fakeDevice; /* Device added by system chipset support */
664
} pciDevice, *pciConfigPtr;
677
#define pci_device_vendor cfgspc.regs.dv_id.device_vendor
678
#define pci_vendor cfgspc.regs.dv_id.dv.vendor
679
#define pci_device cfgspc.regs.dv_id.dv.device
680
#define pci_status_command cfgspc.regs.stat_cmd.status_command
681
#define pci_command cfgspc.regs.stat_cmd.sc.command
682
#define pci_status cfgspc.regs.stat_cmd.sc.status
683
#define pci_class_revision cfgspc.regs.class_rev.class_revision
684
#define pci_rev_id cfgspc.regs.class_rev.cr.rev_id
685
#define pci_prog_if cfgspc.regs.class_rev.cr.prog_if
686
#define pci_sub_class cfgspc.regs.class_rev.cr.sub_class
687
#define pci_base_class cfgspc.regs.class_rev.cr.base_class
688
#define pci_bist_header_latency_cache cfgspc.regs.bhlc.bist_header_latency_cache
689
#define pci_cache_line_size cfgspc.regs.bhlc.bhlc.cache_line_size
690
#define pci_latency_timer cfgspc.regs.bhlc.bhlc.latency_timer
691
#define pci_header_type cfgspc.regs.bhlc.bhlc.header_type
692
#define pci_bist cfgspc.regs.bhlc.bhlc.bist
693
#define pci_cb_secondary_status cfgspc.regs.cx.cg.secondary_status
694
#define pci_cb_bus_register cfgspc.regs.cx.cg.cgbr.cg_bus_reg
695
#define pci_cb_primary_bus_number cfgspc.regs.cx.cg.cgbr.cgbr.primary_bus_number
696
#define pci_cb_cardbus_bus_number cfgspc.regs.cx.cg.cgbr.cgbr.cardbus_bus_number
697
#define pci_cb_subordinate_bus_number cfgspc.regs.cx.cg.cgbr.cgbr.subordinate_bus_number
698
#define pci_cb_latency_timer cfgspc.regs.cx.cg.cgbr.cgbr.latency_timer
699
#define pci_cb_membase0 cfgspc.regs.cx.cg.mem_base0
700
#define pci_cb_memlimit0 cfgspc.regs.cx.cg.mem_limit0
701
#define pci_cb_membase1 cfgspc.regs.cx.cg.mem_base1
702
#define pci_cb_memlimit1 cfgspc.regs.cx.cg.mem_limit1
703
#define pci_cb_iobase0 cfgspc.regs.cx.cg.io_base0
704
#define pci_cb_iolimit0 cfgspc.regs.cx.cg.io_limit0
705
#define pci_cb_iobase1 cfgspc.regs.cx.cg.io_base1
706
#define pci_cb_iolimit1 cfgspc.regs.cx.cg.io_limit1
707
#define pci_base0 cfgspc.regs.cx.cd.bc.dv.dv_base0
708
#define pci_base1 cfgspc.regs.cx.cd.bc.dv.dv_base1
709
#define pci_base2 cfgspc.regs.cx.cd.bc.dv.dv_base2
710
#define pci_base3 cfgspc.regs.cx.cd.bc.dv.dv_base3
711
#define pci_base4 cfgspc.regs.cx.cd.bc.dv.dv_base4
712
#define pci_base5 cfgspc.regs.cx.cd.bc.dv.dv_base5
713
#define pci_cardbus_cis_ptr cfgspc.regs.cx.cd.umem_c_cis.cardbus_cis_ptr
714
#define pci_subsys_card_vendor cfgspc.regs.cx.cd.um_ssys_id.subsys_card_vendor
715
#define pci_subsys_vendor cfgspc.regs.cx.cd.um_ssys_id.ssys.subsys_vendor
716
#define pci_subsys_card cfgspc.regs.cx.cd.um_ssys_id.ssys.subsys_card
717
#define pci_baserom cfgspc.regs.cx.cd.uio_rom.baserom
718
#define pci_pp_bus_register cfgspc.regs.cx.cd.bc.bg.ppbr.pp_bus_reg
719
#define pci_primary_bus_number cfgspc.regs.cx.cd.bc.bg.ppbr.ppbr.primary_bus_number
720
#define pci_secondary_bus_number cfgspc.regs.cx.cd.bc.bg.ppbr.ppbr.secondary_bus_number
721
#define pci_subordinate_bus_number cfgspc.regs.cx.cd.bc.bg.ppbr.ppbr.subordinate_bus_number
722
#define pci_secondary_latency_timer cfgspc.regs.cx.cd.bc.bg.ppbr.ppbr.secondary_latency_timer
723
#define pci_io_base cfgspc.regs.cx.cd.bc.bg.io_base
724
#define pci_io_limit cfgspc.regs.cx.cd.bc.bg.io_limit
725
#define pci_secondary_status cfgspc.regs.cx.cd.bc.bg.secondary_status
726
#define pci_mem_base cfgspc.regs.cx.cd.bc.bg.mem_base
727
#define pci_mem_limit cfgspc.regs.cx.cd.bc.bg.mem_limit
728
#define pci_prefetch_mem_base cfgspc.regs.cx.cd.bc.bg.prefetch_mem_base
729
#define pci_prefetch_mem_limit cfgspc.regs.cx.cd.bc.bg.prefetch_mem_limit
730
#define pci_rsvd1 cfgspc.regs.cx.cd.um_c_cis.rsvd1
731
#define pci_rsvd2 cfgspc.regs.cx.cd.um_ssys_id.rsvd2
732
#define pci_prefetch_upper_mem_base cfgspc.regs.cx.cd.um_c_cis.pftch_umem_base
733
#define pci_prefetch_upper_mem_limit cfgspc.regs.cx.cd.um_ssys_id.pftch_umem_limit
734
#define pci_upper_io_base cfgspc.regs.cx.cd.uio_rom.b_u_io.io_ubase
735
#define pci_upper_io_limit cfgspc.regs.cx.cd.uio_rom.b_u_io.io_ulimit
736
#define pci_int_line cfgspc.regs.bm.mmii.mmii.int_line
737
#define pci_int_pin cfgspc.regs.bm.mmii.mmii.int_pin
738
#define pci_min_gnt cfgspc.regs.bm.mmii.mmii.min_gnt
739
#define pci_max_lat cfgspc.regs.bm.mmii.mmii.max_lat
740
#define pci_max_min_ipin_iline cfgspc.regs.bm.mmii.max_min_ipin_iline
741
#define pci_bridge_control cfgspc.regs.bm.bctrl.bridge_control
742
#define pci_user_config cfgspc.regs.devspf.dwords[0]
743
#define pci_user_config_0 cfgspc.regs.devspf.bytes[0]
744
#define pci_user_config_1 cfgspc.regs.devspf.bytes[1]
745
#define pci_user_config_2 cfgspc.regs.devspf.bytes[2]
746
#define pci_user_config_3 cfgspc.regs.devspf.bytes[3]
750
PCI_BIOS_OPEN_FIRMWARE,
755
/* Public PCI access functions */
757
PCITAG pciFindFirst(CARD32 id, CARD32 mask);
758
PCITAG pciFindNext(void);
759
CARD32 pciReadLong(PCITAG tag, int offset);
760
CARD16 pciReadWord(PCITAG tag, int offset);
761
CARD8 pciReadByte(PCITAG tag, int offset);
762
void pciWriteLong(PCITAG tag, int offset, CARD32 val);
763
void pciWriteWord(PCITAG tag, int offset, CARD16 val);
764
void pciWriteByte(PCITAG tag, int offset, CARD8 val);
765
void pciSetBitsLong(PCITAG tag, int offset, CARD32 mask, CARD32 val);
766
void pciSetBitsByte(PCITAG tag, int offset, CARD8 mask, CARD8 val);
767
ADDRESS pciBusAddrToHostAddr(PCITAG tag, PciAddrType type, ADDRESS addr);
768
ADDRESS pciHostAddrToBusAddr(PCITAG tag, PciAddrType type, ADDRESS addr);
769
PCITAG pciTag(int busnum, int devnum, int funcnum);
770
int pciGetBaseSize(PCITAG tag, int indx, Bool destructive, Bool *min);
771
CARD32 pciCheckForBrokenBase(PCITAG tag,int basereg);
772
pointer xf86MapPciMem(int ScreenNum, int Flags, PCITAG Tag,
773
ADDRESS Base, unsigned long Size);
774
int xf86ReadPciBIOS(unsigned long Offset, PCITAG Tag, int basereg,
775
unsigned char *Buf, int Len);
776
pciConfigPtr *xf86scanpci(int flags);
777
pciConfigPtr xf86GetPciConfigFromTag(PCITAG Tag);
779
extern int pciNumBuses;
781
/* Domain access functions. Some of these probably shouldn't be public */
782
int xf86GetPciDomain(PCITAG tag);
783
pointer xf86MapDomainMemory(int ScreenNum, int Flags, PCITAG Tag,
784
ADDRESS Base, unsigned long Size);
785
IOADDRESS xf86MapDomainIO(int ScreenNum, int Flags, PCITAG Tag,
786
IOADDRESS Base, unsigned long Size);
787
int xf86ReadDomainMemory(PCITAG Tag, ADDRESS Base, int Len,
791
ROM_BASE_PRESET = -2,
802
#endif /* _XF86PCI_H */