2 * The PCI Utilities -- List All PCI Devices
4 * Copyright (c) 1997--2005 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
19 static int verbose
; /* Show detailed information */
20 static int buscentric_view
; /* Show bus addresses/IRQ's instead of CPU-visible ones */
21 static int show_hex
; /* Show contents of config space as hexadecimal numbers */
22 static struct pci_filter filter
; /* Device filter */
23 static int show_tree
; /* Show bus tree */
24 static int machine_readable
; /* Generate machine-readable output */
25 static int map_mode
; /* Bus mapping mode enabled */
27 static char options
[] = "nvbxs:d:ti:mgM" GENERIC_OPTIONS
;
29 static char help_msg
[] = "\
30 Usage: lspci [<switches>]\n\
33 -n\t\tShow numeric ID's\n\
34 -b\t\tBus-centric view (PCI addresses and IRQ's instead of those seen by the CPU)\n\
35 -x\t\tShow hex-dump of the standard portion of config space\n\
36 -xxx\t\tShow hex-dump of the whole config space (dangerous; root only)\n\
37 -xxxx\t\tShow hex-dump of the 4096-byte extended config space (root only)\n\
38 -s [[[[<domain>]:]<bus>]:][<slot>][.[<func>]]\tShow only devices in selected slots\n\
39 -d [<vendor>]:[<device>]\tShow only selected devices\n\
40 -t\t\tShow bus tree\n\
41 -m\t\tProduce machine-readable output\n\
42 -i <file>\tUse specified ID database instead of %s\n\
43 -M\t\tEnable `bus mapping' mode (dangerous; root only)\n"
47 /* Communication with libpci */
49 static struct pci_access
*pacc
;
52 * If we aren't being compiled by GCC, use xmalloc() instead of alloca().
53 * This increases our memory footprint, but only slightly since we don't
59 #define alloca xmalloc
62 /* Our view of the PCI bus */
67 unsigned int config_cached
, config_bufsize
;
68 byte
*config
; /* Cached configuration space data */
69 byte
*present
; /* Maps which configuration bytes are present */
72 static struct device
*first_dev
;
75 config_fetch(struct device
*d
, unsigned int pos
, unsigned int len
)
77 unsigned int end
= pos
+len
;
80 while (pos
< d
->config_bufsize
&& len
&& d
->present
[pos
])
82 while (pos
+len
<= d
->config_bufsize
&& len
&& d
->present
[pos
+len
-1])
87 if (end
> d
->config_bufsize
)
89 int orig_size
= d
->config_bufsize
;
90 while (end
> d
->config_bufsize
)
91 d
->config_bufsize
*= 2;
92 d
->config
= xrealloc(d
->config
, d
->config_bufsize
);
93 d
->present
= xrealloc(d
->present
, d
->config_bufsize
);
94 bzero(d
->present
+ orig_size
, d
->config_bufsize
- orig_size
);
96 result
= pci_read_block(d
->dev
, pos
, d
->config
+ pos
, len
);
98 memset(d
->present
+ pos
, 1, len
);
102 static struct device
*
103 scan_device(struct pci_dev
*p
)
107 if (!pci_filter_match(&filter
, p
))
109 d
= xmalloc(sizeof(struct device
));
110 bzero(d
, sizeof(*d
));
112 d
->config_cached
= d
->config_bufsize
= 64;
113 d
->config
= xmalloc(64);
114 d
->present
= xmalloc(64);
115 memset(d
->present
, 1, 64);
116 if (!pci_read_block(p
, 0, d
->config
, 64))
117 die("Unable to read the standard configuration space header");
118 if ((d
->config
[PCI_HEADER_TYPE
] & 0x7f) == PCI_HEADER_TYPE_CARDBUS
)
120 /* For cardbus bridges, we need to fetch 64 bytes more to get the
121 * full standard header... */
122 if (config_fetch(d
, 64, 64))
123 d
->config_cached
+= 64;
125 pci_setup_cache(p
, d
->config
, d
->config_cached
);
126 pci_fill_info(p
, PCI_FILL_IDENT
| PCI_FILL_IRQ
| PCI_FILL_BASES
| PCI_FILL_ROM_BASE
| PCI_FILL_SIZES
);
137 for(p
=pacc
->devices
; p
; p
=p
->next
)
138 if (d
= scan_device(p
))
145 /* Config space accesses */
148 check_conf_range(struct device
*d
, unsigned int pos
, unsigned int len
)
151 if (!d
->present
[pos
])
152 die("Internal bug: Accessing non-read configuration byte at position %x", pos
);
158 get_conf_byte(struct device
*d
, unsigned int pos
)
160 check_conf_range(d
, pos
, 1);
161 return d
->config
[pos
];
165 get_conf_word(struct device
*d
, unsigned int pos
)
167 check_conf_range(d
, pos
, 2);
168 return d
->config
[pos
] | (d
->config
[pos
+1] << 8);
172 get_conf_long(struct device
*d
, unsigned int pos
)
174 check_conf_range(d
, pos
, 4);
175 return d
->config
[pos
] |
176 (d
->config
[pos
+1] << 8) |
177 (d
->config
[pos
+2] << 16) |
178 (d
->config
[pos
+3] << 24);
184 compare_them(const void *A
, const void *B
)
186 const struct pci_dev
*a
= (*(const struct device
**)A
)->dev
;
187 const struct pci_dev
*b
= (*(const struct device
**)B
)->dev
;
189 if (a
->domain
< b
->domain
)
191 if (a
->domain
> b
->domain
)
201 if (a
->func
< b
->func
)
203 if (a
->func
> b
->func
)
211 struct device
**index
, **h
, **last_dev
;
216 for(d
=first_dev
; d
; d
=d
->next
)
218 h
= index
= alloca(sizeof(struct device
*) * cnt
);
219 for(d
=first_dev
; d
; d
=d
->next
)
221 qsort(index
, cnt
, sizeof(struct device
*), compare_them
);
222 last_dev
= &first_dev
;
227 last_dev
= &(*h
)->next
;
235 #define FLAG(x,y) ((x & y) ? '+' : '-')
238 show_slot_name(struct device
*d
)
240 struct pci_dev
*p
= d
->dev
;
243 printf("%04x:", p
->domain
);
244 printf("%02x:%02x.%d", p
->bus
, p
->dev
, p
->func
);
248 show_terse(struct device
*d
)
251 struct pci_dev
*p
= d
->dev
;
252 byte classbuf
[128], devbuf
[128];
256 pci_lookup_name(pacc
, classbuf
, sizeof(classbuf
),
258 get_conf_word(d
, PCI_CLASS_DEVICE
), 0, 0, 0),
259 pci_lookup_name(pacc
, devbuf
, sizeof(devbuf
),
260 PCI_LOOKUP_VENDOR
| PCI_LOOKUP_DEVICE
,
261 p
->vendor_id
, p
->device_id
, 0, 0));
262 if (c
= get_conf_byte(d
, PCI_REVISION_ID
))
263 printf(" (rev %02x)", c
);
267 c
= get_conf_byte(d
, PCI_CLASS_PROG
);
268 x
= pci_lookup_name(pacc
, devbuf
, sizeof(devbuf
),
270 get_conf_word(d
, PCI_CLASS_DEVICE
), c
, 0, 0);
273 printf(" (prog-if %02x", c
);
283 show_size(pciaddr_t x
)
289 printf("%d", (int) x
);
290 else if (x
< 1048576)
291 printf("%dK", (int)(x
/ 1024));
292 else if (x
< 0x80000000)
293 printf("%dM", (int)(x
/ 1048576));
295 printf(PCIADDR_T_FMT
, x
);
300 show_bases(struct device
*d
, int cnt
)
302 struct pci_dev
*p
= d
->dev
;
303 word cmd
= get_conf_word(d
, PCI_COMMAND
);
308 pciaddr_t pos
= p
->base_addr
[i
];
309 pciaddr_t len
= (p
->known_fields
& PCI_FILL_SIZES
) ? p
->size
[i
] : 0;
310 u32 flg
= get_conf_long(d
, PCI_BASE_ADDRESS_0
+ 4*i
);
311 if (flg
== 0xffffffff)
313 if (!pos
&& !flg
&& !len
)
316 printf("\tRegion %d: ", i
);
319 if (pos
&& !flg
) /* Reported by the OS, but not by the device */
321 printf("[virtual] ");
324 if (flg
& PCI_BASE_ADDRESS_SPACE_IO
)
326 pciaddr_t a
= pos
& PCI_BASE_ADDRESS_IO_MASK
;
327 printf("I/O ports at ");
329 printf(PCIADDR_PORT_FMT
, a
);
330 else if (flg
& PCI_BASE_ADDRESS_IO_MASK
)
333 printf("<unassigned>");
334 if (!(cmd
& PCI_COMMAND_IO
))
335 printf(" [disabled]");
339 int t
= flg
& PCI_BASE_ADDRESS_MEM_TYPE_MASK
;
340 pciaddr_t a
= pos
& PCI_ADDR_MEM_MASK
;
344 printf("Memory at ");
345 if (t
== PCI_BASE_ADDRESS_MEM_TYPE_64
)
349 printf("<invalid-64bit-slot>");
355 z
= get_conf_long(d
, PCI_BASE_ADDRESS_0
+ 4*i
);
359 printf("%08x" PCIADDR_T_FMT
, z
, a
);
361 printf("<unassigned>");
369 printf(PCIADDR_T_FMT
, a
);
371 printf(((flg
& PCI_BASE_ADDRESS_MEM_MASK
) || z
) ? "<ignored>" : "<unassigned>");
373 printf(" (%s, %sprefetchable)",
374 (t
== PCI_BASE_ADDRESS_MEM_TYPE_32
) ? "32-bit" :
375 (t
== PCI_BASE_ADDRESS_MEM_TYPE_64
) ? "64-bit" :
376 (t
== PCI_BASE_ADDRESS_MEM_TYPE_1M
) ? "low-1M" : "type 3",
377 (flg
& PCI_BASE_ADDRESS_MEM_PREFETCH
) ? "" : "non-");
378 if (!(cmd
& PCI_COMMAND_MEMORY
))
379 printf(" [disabled]");
387 show_pm(struct device
*d
, int where
, int cap
)
390 static int pm_aux_current
[8] = { 0, 55, 100, 160, 220, 270, 320, 375 };
392 printf("Power Management version %d\n", cap
& PCI_PM_CAP_VER_MASK
);
395 printf("\t\tFlags: PMEClk%c DSI%c D1%c D2%c AuxCurrent=%dmA PME(D0%c,D1%c,D2%c,D3hot%c,D3cold%c)\n",
396 FLAG(cap
, PCI_PM_CAP_PME_CLOCK
),
397 FLAG(cap
, PCI_PM_CAP_DSI
),
398 FLAG(cap
, PCI_PM_CAP_D1
),
399 FLAG(cap
, PCI_PM_CAP_D2
),
400 pm_aux_current
[(cap
>> 6) & 7],
401 FLAG(cap
, PCI_PM_CAP_PME_D0
),
402 FLAG(cap
, PCI_PM_CAP_PME_D1
),
403 FLAG(cap
, PCI_PM_CAP_PME_D2
),
404 FLAG(cap
, PCI_PM_CAP_PME_D3_HOT
),
405 FLAG(cap
, PCI_PM_CAP_PME_D3_COLD
));
406 if (!config_fetch(d
, where
+ PCI_PM_CTRL
, PCI_PM_SIZEOF
- PCI_PM_CTRL
))
408 t
= get_conf_word(d
, where
+ PCI_PM_CTRL
);
409 printf("\t\tStatus: D%d PME-Enable%c DSel=%d DScale=%d PME%c\n",
410 t
& PCI_PM_CTRL_STATE_MASK
,
411 FLAG(t
, PCI_PM_CTRL_PME_ENABLE
),
412 (t
& PCI_PM_CTRL_DATA_SEL_MASK
) >> 9,
413 (t
& PCI_PM_CTRL_DATA_SCALE_MASK
) >> 13,
414 FLAG(t
, PCI_PM_CTRL_PME_STATUS
));
415 b
= get_conf_byte(d
, where
+ PCI_PM_PPB_EXTENSIONS
);
417 printf("\t\tBridge: PM%c B3%c\n",
418 FLAG(t
, PCI_PM_BPCC_ENABLE
),
419 FLAG(~t
, PCI_PM_PPB_B2_B3
));
423 format_agp_rate(int rate
, char *buf
, int agp3
)
433 c
+= sprintf(c
, "x%d", 1 << (i
+ 2*agp3
));
438 strcpy(buf
, "<none>");
442 show_agp(struct device
*d
, int where
, int cap
)
449 ver
= (cap
>> 4) & 0x0f;
451 printf("AGP version %x.%x\n", ver
, rev
);
454 if (!config_fetch(d
, where
+ PCI_AGP_STATUS
, PCI_AGP_SIZEOF
- PCI_AGP_STATUS
))
456 t
= get_conf_long(d
, where
+ PCI_AGP_STATUS
);
457 if (ver
>= 3 && (t
& PCI_AGP_STATUS_AGP3
))
459 format_agp_rate(t
& 7, rate
, agp3
);
460 printf("\t\tStatus: RQ=%d Iso%c ArqSz=%d Cal=%d SBA%c ITACoh%c GART64%c HTrans%c 64bit%c FW%c AGP3%c Rate=%s\n",
461 ((t
& PCI_AGP_STATUS_RQ_MASK
) >> 24U) + 1,
462 FLAG(t
, PCI_AGP_STATUS_ISOCH
),
463 ((t
& PCI_AGP_STATUS_ARQSZ_MASK
) >> 13),
464 ((t
& PCI_AGP_STATUS_CAL_MASK
) >> 10),
465 FLAG(t
, PCI_AGP_STATUS_SBA
),
466 FLAG(t
, PCI_AGP_STATUS_ITA_COH
),
467 FLAG(t
, PCI_AGP_STATUS_GART64
),
468 FLAG(t
, PCI_AGP_STATUS_HTRANS
),
469 FLAG(t
, PCI_AGP_STATUS_64BIT
),
470 FLAG(t
, PCI_AGP_STATUS_FW
),
471 FLAG(t
, PCI_AGP_STATUS_AGP3
),
473 t
= get_conf_long(d
, where
+ PCI_AGP_COMMAND
);
474 format_agp_rate(t
& 7, rate
, agp3
);
475 printf("\t\tCommand: RQ=%d ArqSz=%d Cal=%d SBA%c AGP%c GART64%c 64bit%c FW%c Rate=%s\n",
476 ((t
& PCI_AGP_COMMAND_RQ_MASK
) >> 24U) + 1,
477 ((t
& PCI_AGP_COMMAND_ARQSZ_MASK
) >> 13),
478 ((t
& PCI_AGP_COMMAND_CAL_MASK
) >> 10),
479 FLAG(t
, PCI_AGP_COMMAND_SBA
),
480 FLAG(t
, PCI_AGP_COMMAND_AGP
),
481 FLAG(t
, PCI_AGP_COMMAND_GART64
),
482 FLAG(t
, PCI_AGP_COMMAND_64BIT
),
483 FLAG(t
, PCI_AGP_COMMAND_FW
),
488 show_pcix_nobridge(struct device
*d
, int where
)
492 static const byte max_outstanding
[8] = { 1, 2, 3, 4, 8, 12, 16, 32 };
494 printf("PCI-X non-bridge device\n");
499 if (!config_fetch(d
, where
+ PCI_PCIX_STATUS
, 4))
502 command
= get_conf_word(d
, where
+ PCI_PCIX_COMMAND
);
503 status
= get_conf_long(d
, where
+ PCI_PCIX_STATUS
);
504 printf("\t\tCommand: DPERE%c ERO%c RBC=%d OST=%d\n",
505 FLAG(command
, PCI_PCIX_COMMAND_DPERE
),
506 FLAG(command
, PCI_PCIX_COMMAND_ERO
),
507 1 << (9 + ((command
& PCI_PCIX_COMMAND_MAX_MEM_READ_BYTE_COUNT
) >> 2U)),
508 max_outstanding
[(command
& PCI_PCIX_COMMAND_MAX_OUTSTANDING_SPLIT_TRANS
) >> 4U]);
509 printf("\t\tStatus: Dev=%02x:%02x.%d 64bit%c 133MHz%c SCD%c USC%c DC=%s DMMRBC=%u DMOST=%u DMCRS=%u RSCEM%c 266MHz%c 533MHz%c\n",
510 ((status
>> 8) & 0xff),
511 ((status
>> 3) & 0x1f),
512 (status
& PCI_PCIX_STATUS_FUNCTION
),
513 FLAG(status
, PCI_PCIX_STATUS_64BIT
),
514 FLAG(status
, PCI_PCIX_STATUS_133MHZ
),
515 FLAG(status
, PCI_PCIX_STATUS_SC_DISCARDED
),
516 FLAG(status
, PCI_PCIX_STATUS_UNEXPECTED_SC
),
517 ((status
& PCI_PCIX_STATUS_DEVICE_COMPLEXITY
) ? "bridge" : "simple"),
518 1 << (9 + ((status
>> 21) & 3U)),
519 max_outstanding
[(status
>> 23) & 7U],
520 1 << (3 + ((status
>> 26) & 7U)),
521 FLAG(status
, PCI_PCIX_STATUS_RCVD_SC_ERR_MESS
),
522 FLAG(status
, PCI_PCIX_STATUS_266MHZ
),
523 FLAG(status
, PCI_PCIX_STATUS_533MHZ
));
527 show_pcix_bridge(struct device
*d
, int where
)
529 static const byte
* const sec_clock_freq
[8] = { "conv", "66MHz", "100MHz", "133MHz", "?4", "?5", "?6", "?7" };
531 u32 status
, upstcr
, downstcr
;
533 printf("PCI-X bridge device\n");
538 if (!config_fetch(d
, where
+ PCI_PCIX_BRIDGE_STATUS
, 12))
541 secstatus
= get_conf_word(d
, where
+ PCI_PCIX_BRIDGE_SEC_STATUS
);
542 printf("\t\tSecondary Status: 64bit%c 133MHz%c SCD%c USC%c SCO%c SRD%c Freq=%s\n",
543 FLAG(secstatus
, PCI_PCIX_BRIDGE_SEC_STATUS_64BIT
),
544 FLAG(secstatus
, PCI_PCIX_BRIDGE_SEC_STATUS_133MHZ
),
545 FLAG(secstatus
, PCI_PCIX_BRIDGE_SEC_STATUS_SC_DISCARDED
),
546 FLAG(secstatus
, PCI_PCIX_BRIDGE_SEC_STATUS_UNEXPECTED_SC
),
547 FLAG(secstatus
, PCI_PCIX_BRIDGE_SEC_STATUS_SC_OVERRUN
),
548 FLAG(secstatus
, PCI_PCIX_BRIDGE_SEC_STATUS_SPLIT_REQUEST_DELAYED
),
549 sec_clock_freq
[(secstatus
>> 6) & 7]);
550 status
= get_conf_long(d
, where
+ PCI_PCIX_BRIDGE_STATUS
);
551 printf("\t\tStatus: Dev=%02x:%02x.%d 64bit%c 133MHz%c SCD%c USC%c SCO%c SRD%c\n",
552 ((status
>> 8) & 0xff),
553 ((status
>> 3) & 0x1f),
554 (status
& PCI_PCIX_BRIDGE_STATUS_FUNCTION
),
555 FLAG(status
, PCI_PCIX_BRIDGE_STATUS_64BIT
),
556 FLAG(status
, PCI_PCIX_BRIDGE_STATUS_133MHZ
),
557 FLAG(status
, PCI_PCIX_BRIDGE_STATUS_SC_DISCARDED
),
558 FLAG(status
, PCI_PCIX_BRIDGE_STATUS_UNEXPECTED_SC
),
559 FLAG(status
, PCI_PCIX_BRIDGE_STATUS_SC_OVERRUN
),
560 FLAG(status
, PCI_PCIX_BRIDGE_STATUS_SPLIT_REQUEST_DELAYED
));
561 upstcr
= get_conf_long(d
, where
+ PCI_PCIX_BRIDGE_UPSTREAM_SPLIT_TRANS_CTRL
);
562 printf("\t\tUpstream: Capacity=%u CommitmentLimit=%u\n",
563 (upstcr
& PCI_PCIX_BRIDGE_STR_CAPACITY
),
564 (upstcr
>> 16) & 0xffff);
565 downstcr
= get_conf_long(d
, where
+ PCI_PCIX_BRIDGE_DOWNSTREAM_SPLIT_TRANS_CTRL
);
566 printf("\t\tDownstream: Capacity=%u CommitmentLimit=%u\n",
567 (downstcr
& PCI_PCIX_BRIDGE_STR_CAPACITY
),
568 (downstcr
>> 16) & 0xffff);
572 show_pcix(struct device
*d
, int where
)
574 switch (get_conf_byte(d
, PCI_HEADER_TYPE
) & 0x7f)
576 case PCI_HEADER_TYPE_NORMAL
:
577 show_pcix_nobridge(d
, where
);
579 case PCI_HEADER_TYPE_BRIDGE
:
580 show_pcix_bridge(d
, where
);
586 ht_link_width(unsigned width
)
588 static char * const widths
[8] = { "8bit", "16bit", "[2]", "32bit", "2bit", "4bit", "[6]", "N/C" };
589 return widths
[width
];
593 ht_link_freq(unsigned freq
)
595 static char * const freqs
[16] = { "200MHz", "300MHz", "400MHz", "500MHz", "600MHz", "800MHz", "1.0GHz", "1.2GHz",
596 "1.4GHz", "1.6GHz", "[a]", "[b]", "[c]", "[d]", "[e]", "Vend" };
601 show_ht_pri(struct device
*d
, int where
, int cmd
)
603 u16 lctr0
, lcnf0
, lctr1
, lcnf1
, eh
;
604 u8 rid
, lfrer0
, lfcap0
, ftr
, lfrer1
, lfcap1
, mbu
, mlu
, bn
;
607 printf("HyperTransport: Slave or Primary Interface\n");
611 if (!config_fetch(d
, where
+ PCI_HT_PRI_LCTR0
, PCI_HT_PRI_SIZEOF
- PCI_HT_PRI_LCTR0
))
613 rid
= get_conf_byte(d
, where
+ PCI_HT_PRI_RID
);
614 if (rid
< 0x23 && rid
> 0x11)
615 printf("\t\t!!! Possibly incomplete decoding\n");
618 fmt
= "\t\tCommand: BaseUnitID=%u UnitCnt=%u MastHost%c DefDir%c DUL%c\n";
620 fmt
= "\t\tCommand: BaseUnitID=%u UnitCnt=%u MastHost%c DefDir%c\n";
622 (cmd
& PCI_HT_PRI_CMD_BUID
),
623 (cmd
& PCI_HT_PRI_CMD_UC
) >> 5,
624 FLAG(cmd
, PCI_HT_PRI_CMD_MH
),
625 FLAG(cmd
, PCI_HT_PRI_CMD_DD
),
626 FLAG(cmd
, PCI_HT_PRI_CMD_DUL
));
627 lctr0
= get_conf_word(d
, where
+ PCI_HT_PRI_LCTR0
);
629 fmt
= "\t\tLink Control 0: CFlE%c CST%c CFE%c <LkFail%c Init%c EOC%c TXO%c <CRCErr=%x IsocEn%c LSEn%c ExtCTL%c 64b%c\n";
631 fmt
= "\t\tLink Control 0: CFlE%c CST%c CFE%c <LkFail%c Init%c EOC%c TXO%c <CRCErr=%x\n";
633 FLAG(lctr0
, PCI_HT_LCTR_CFLE
),
634 FLAG(lctr0
, PCI_HT_LCTR_CST
),
635 FLAG(lctr0
, PCI_HT_LCTR_CFE
),
636 FLAG(lctr0
, PCI_HT_LCTR_LKFAIL
),
637 FLAG(lctr0
, PCI_HT_LCTR_INIT
),
638 FLAG(lctr0
, PCI_HT_LCTR_EOC
),
639 FLAG(lctr0
, PCI_HT_LCTR_TXO
),
640 (lctr0
& PCI_HT_LCTR_CRCERR
) >> 8,
641 FLAG(lctr0
, PCI_HT_LCTR_ISOCEN
),
642 FLAG(lctr0
, PCI_HT_LCTR_LSEN
),
643 FLAG(lctr0
, PCI_HT_LCTR_EXTCTL
),
644 FLAG(lctr0
, PCI_HT_LCTR_64B
));
645 lcnf0
= get_conf_word(d
, where
+ PCI_HT_PRI_LCNF0
);
647 fmt
= "\t\tLink Config 0: MLWI=%1$s DwFcIn%5$c MLWO=%2$s DwFcOut%6$c LWI=%3$s DwFcInEn%7$c LWO=%4$s DwFcOutEn%8$c\n";
649 fmt
= "\t\tLink Config 0: MLWI=%s MLWO=%s LWI=%s LWO=%s\n";
651 ht_link_width(lcnf0
& PCI_HT_LCNF_MLWI
),
652 ht_link_width((lcnf0
& PCI_HT_LCNF_MLWO
) >> 4),
653 ht_link_width((lcnf0
& PCI_HT_LCNF_LWI
) >> 8),
654 ht_link_width((lcnf0
& PCI_HT_LCNF_LWO
) >> 12),
655 FLAG(lcnf0
, PCI_HT_LCNF_DFI
),
656 FLAG(lcnf0
, PCI_HT_LCNF_DFO
),
657 FLAG(lcnf0
, PCI_HT_LCNF_DFIE
),
658 FLAG(lcnf0
, PCI_HT_LCNF_DFOE
));
659 lctr1
= get_conf_word(d
, where
+ PCI_HT_PRI_LCTR1
);
661 fmt
= "\t\tLink Control 1: CFlE%c CST%c CFE%c <LkFail%c Init%c EOC%c TXO%c <CRCErr=%x IsocEn%c LSEn%c ExtCTL%c 64b%c\n";
663 fmt
= "\t\tLink Control 1: CFlE%c CST%c CFE%c <LkFail%c Init%c EOC%c TXO%c <CRCErr=%x\n";
665 FLAG(lctr1
, PCI_HT_LCTR_CFLE
),
666 FLAG(lctr1
, PCI_HT_LCTR_CST
),
667 FLAG(lctr1
, PCI_HT_LCTR_CFE
),
668 FLAG(lctr1
, PCI_HT_LCTR_LKFAIL
),
669 FLAG(lctr1
, PCI_HT_LCTR_INIT
),
670 FLAG(lctr1
, PCI_HT_LCTR_EOC
),
671 FLAG(lctr1
, PCI_HT_LCTR_TXO
),
672 (lctr1
& PCI_HT_LCTR_CRCERR
) >> 8,
673 FLAG(lctr1
, PCI_HT_LCTR_ISOCEN
),
674 FLAG(lctr1
, PCI_HT_LCTR_LSEN
),
675 FLAG(lctr1
, PCI_HT_LCTR_EXTCTL
),
676 FLAG(lctr1
, PCI_HT_LCTR_64B
));
677 lcnf1
= get_conf_word(d
, where
+ PCI_HT_PRI_LCNF1
);
679 fmt
= "\t\tLink Config 1: MLWI=%1$s DwFcIn%5$c MLWO=%2$s DwFcOut%6$c LWI=%3$s DwFcInEn%7$c LWO=%4$s DwFcOutEn%8$c\n";
681 fmt
= "\t\tLink Config 1: MLWI=%s MLWO=%s LWI=%s LWO=%s\n";
683 ht_link_width(lcnf1
& PCI_HT_LCNF_MLWI
),
684 ht_link_width((lcnf1
& PCI_HT_LCNF_MLWO
) >> 4),
685 ht_link_width((lcnf1
& PCI_HT_LCNF_LWI
) >> 8),
686 ht_link_width((lcnf1
& PCI_HT_LCNF_LWO
) >> 12),
687 FLAG(lcnf1
, PCI_HT_LCNF_DFI
),
688 FLAG(lcnf1
, PCI_HT_LCNF_DFO
),
689 FLAG(lcnf1
, PCI_HT_LCNF_DFIE
),
690 FLAG(lcnf1
, PCI_HT_LCNF_DFOE
));
691 printf("\t\tRevision ID: %u.%02u\n",
692 (rid
& PCI_HT_RID_MAJ
) >> 5, (rid
& PCI_HT_RID_MIN
));
695 lfrer0
= get_conf_byte(d
, where
+ PCI_HT_PRI_LFRER0
);
696 printf("\t\tLink Frequency 0: %s\n", ht_link_freq(lfrer0
& PCI_HT_LFRER_FREQ
));
697 printf("\t\tLink Error 0: <Prot%c <Ovfl%c <EOC%c CTLTm%c\n",
698 FLAG(lfrer0
, PCI_HT_LFRER_PROT
),
699 FLAG(lfrer0
, PCI_HT_LFRER_OV
),
700 FLAG(lfrer0
, PCI_HT_LFRER_EOC
),
701 FLAG(lfrer0
, PCI_HT_LFRER_CTLT
));
702 lfcap0
= get_conf_byte(d
, where
+ PCI_HT_PRI_LFCAP0
);
703 printf("\t\tLink Frequency Capability 0: 200MHz%c 300MHz%c 400MHz%c 500MHz%c 600MHz%c 800MHz%c 1.0GHz%c 1.2GHz%c 1.4GHz%c 1.6GHz%c Vend%c\n",
704 FLAG(lfcap0
, PCI_HT_LFCAP_200
),
705 FLAG(lfcap0
, PCI_HT_LFCAP_300
),
706 FLAG(lfcap0
, PCI_HT_LFCAP_400
),
707 FLAG(lfcap0
, PCI_HT_LFCAP_500
),
708 FLAG(lfcap0
, PCI_HT_LFCAP_600
),
709 FLAG(lfcap0
, PCI_HT_LFCAP_800
),
710 FLAG(lfcap0
, PCI_HT_LFCAP_1000
),
711 FLAG(lfcap0
, PCI_HT_LFCAP_1200
),
712 FLAG(lfcap0
, PCI_HT_LFCAP_1400
),
713 FLAG(lfcap0
, PCI_HT_LFCAP_1600
),
714 FLAG(lfcap0
, PCI_HT_LFCAP_VEND
));
715 ftr
= get_conf_byte(d
, where
+ PCI_HT_PRI_FTR
);
716 printf("\t\tFeature Capability: IsocFC%c LDTSTOP%c CRCTM%c ECTLT%c 64bA%c UIDRD%c\n",
717 FLAG(ftr
, PCI_HT_FTR_ISOCFC
),
718 FLAG(ftr
, PCI_HT_FTR_LDTSTOP
),
719 FLAG(ftr
, PCI_HT_FTR_CRCTM
),
720 FLAG(ftr
, PCI_HT_FTR_ECTLT
),
721 FLAG(ftr
, PCI_HT_FTR_64BA
),
722 FLAG(ftr
, PCI_HT_FTR_UIDRD
));
723 lfrer1
= get_conf_byte(d
, where
+ PCI_HT_PRI_LFRER1
);
724 printf("\t\tLink Frequency 1: %s\n", ht_link_freq(lfrer1
& PCI_HT_LFRER_FREQ
));
725 printf("\t\tLink Error 1: <Prot%c <Ovfl%c <EOC%c CTLTm%c\n",
726 FLAG(lfrer1
, PCI_HT_LFRER_PROT
),
727 FLAG(lfrer1
, PCI_HT_LFRER_OV
),
728 FLAG(lfrer1
, PCI_HT_LFRER_EOC
),
729 FLAG(lfrer1
, PCI_HT_LFRER_CTLT
));
730 lfcap1
= get_conf_byte(d
, where
+ PCI_HT_PRI_LFCAP1
);
731 printf("\t\tLink Frequency Capability 1: 200MHz%c 300MHz%c 400MHz%c 500MHz%c 600MHz%c 800MHz%c 1.0GHz%c 1.2GHz%c 1.4GHz%c 1.6GHz%c Vend%c\n",
732 FLAG(lfcap1
, PCI_HT_LFCAP_200
),
733 FLAG(lfcap1
, PCI_HT_LFCAP_300
),
734 FLAG(lfcap1
, PCI_HT_LFCAP_400
),
735 FLAG(lfcap1
, PCI_HT_LFCAP_500
),
736 FLAG(lfcap1
, PCI_HT_LFCAP_600
),
737 FLAG(lfcap1
, PCI_HT_LFCAP_800
),
738 FLAG(lfcap1
, PCI_HT_LFCAP_1000
),
739 FLAG(lfcap1
, PCI_HT_LFCAP_1200
),
740 FLAG(lfcap1
, PCI_HT_LFCAP_1400
),
741 FLAG(lfcap1
, PCI_HT_LFCAP_1600
),
742 FLAG(lfcap1
, PCI_HT_LFCAP_VEND
));
743 eh
= get_conf_word(d
, where
+ PCI_HT_PRI_EH
);
744 printf("\t\tError Handling: PFlE%c OFlE%c PFE%c OFE%c EOCFE%c RFE%c CRCFE%c SERRFE%c CF%c RE%c PNFE%c ONFE%c EOCNFE%c RNFE%c CRCNFE%c SERRNFE%c\n",
745 FLAG(eh
, PCI_HT_EH_PFLE
),
746 FLAG(eh
, PCI_HT_EH_OFLE
),
747 FLAG(eh
, PCI_HT_EH_PFE
),
748 FLAG(eh
, PCI_HT_EH_OFE
),
749 FLAG(eh
, PCI_HT_EH_EOCFE
),
750 FLAG(eh
, PCI_HT_EH_RFE
),
751 FLAG(eh
, PCI_HT_EH_CRCFE
),
752 FLAG(eh
, PCI_HT_EH_SERRFE
),
753 FLAG(eh
, PCI_HT_EH_CF
),
754 FLAG(eh
, PCI_HT_EH_RE
),
755 FLAG(eh
, PCI_HT_EH_PNFE
),
756 FLAG(eh
, PCI_HT_EH_ONFE
),
757 FLAG(eh
, PCI_HT_EH_EOCNFE
),
758 FLAG(eh
, PCI_HT_EH_RNFE
),
759 FLAG(eh
, PCI_HT_EH_CRCNFE
),
760 FLAG(eh
, PCI_HT_EH_SERRNFE
));
761 mbu
= get_conf_byte(d
, where
+ PCI_HT_PRI_MBU
);
762 mlu
= get_conf_byte(d
, where
+ PCI_HT_PRI_MLU
);
763 printf("\t\tPrefetchable memory behind bridge Upper: %02x-%02x\n", mbu
, mlu
);
764 bn
= get_conf_byte(d
, where
+ PCI_HT_PRI_BN
);
765 printf("\t\tBus Number: %02x\n", bn
);
769 show_ht_sec(struct device
*d
, int where
, int cmd
)
771 u16 lctr
, lcnf
, ftr
, eh
;
772 u8 rid
, lfrer
, lfcap
, mbu
, mlu
;
775 printf("HyperTransport: Host or Secondary Interface\n");
779 if (!config_fetch(d
, where
+ PCI_HT_SEC_LCTR
, PCI_HT_SEC_SIZEOF
- PCI_HT_SEC_LCTR
))
781 rid
= get_conf_byte(d
, where
+ PCI_HT_SEC_RID
);
782 if (rid
< 0x23 && rid
> 0x11)
783 printf("\t\t!!! Possibly incomplete decoding\n");
786 fmt
= "\t\tCommand: WarmRst%c DblEnd%c DevNum=%u ChainSide%c HostHide%c Slave%c <EOCErr%c DUL%c\n";
788 fmt
= "\t\tCommand: WarmRst%c DblEnd%c\n";
790 FLAG(cmd
, PCI_HT_SEC_CMD_WR
),
791 FLAG(cmd
, PCI_HT_SEC_CMD_DE
),
792 (cmd
& PCI_HT_SEC_CMD_DN
) >> 2,
793 FLAG(cmd
, PCI_HT_SEC_CMD_CS
),
794 FLAG(cmd
, PCI_HT_SEC_CMD_HH
),
795 FLAG(cmd
, PCI_HT_SEC_CMD_AS
),
796 FLAG(cmd
, PCI_HT_SEC_CMD_HIECE
),
797 FLAG(cmd
, PCI_HT_SEC_CMD_DUL
));
798 lctr
= get_conf_word(d
, where
+ PCI_HT_SEC_LCTR
);
800 fmt
= "\t\tLink Control: CFlE%c CST%c CFE%c <LkFail%c Init%c EOC%c TXO%c <CRCErr=%x IsocEn%c LSEn%c ExtCTL%c 64b%c\n";
802 fmt
= "\t\tLink Control: CFlE%c CST%c CFE%c <LkFail%c Init%c EOC%c TXO%c <CRCErr=%x\n";
804 FLAG(lctr
, PCI_HT_LCTR_CFLE
),
805 FLAG(lctr
, PCI_HT_LCTR_CST
),
806 FLAG(lctr
, PCI_HT_LCTR_CFE
),
807 FLAG(lctr
, PCI_HT_LCTR_LKFAIL
),
808 FLAG(lctr
, PCI_HT_LCTR_INIT
),
809 FLAG(lctr
, PCI_HT_LCTR_EOC
),
810 FLAG(lctr
, PCI_HT_LCTR_TXO
),
811 (lctr
& PCI_HT_LCTR_CRCERR
) >> 8,
812 FLAG(lctr
, PCI_HT_LCTR_ISOCEN
),
813 FLAG(lctr
, PCI_HT_LCTR_LSEN
),
814 FLAG(lctr
, PCI_HT_LCTR_EXTCTL
),
815 FLAG(lctr
, PCI_HT_LCTR_64B
));
816 lcnf
= get_conf_word(d
, where
+ PCI_HT_SEC_LCNF
);
818 fmt
= "\t\tLink Config: MLWI=%1$s DwFcIn%5$c MLWO=%2$s DwFcOut%6$c LWI=%3$s DwFcInEn%7$c LWO=%4$s DwFcOutEn%8$c\n";
820 fmt
= "\t\tLink Config: MLWI=%s MLWO=%s LWI=%s LWO=%s\n";
822 ht_link_width(lcnf
& PCI_HT_LCNF_MLWI
),
823 ht_link_width((lcnf
& PCI_HT_LCNF_MLWO
) >> 4),
824 ht_link_width((lcnf
& PCI_HT_LCNF_LWI
) >> 8),
825 ht_link_width((lcnf
& PCI_HT_LCNF_LWO
) >> 12),
826 FLAG(lcnf
, PCI_HT_LCNF_DFI
),
827 FLAG(lcnf
, PCI_HT_LCNF_DFO
),
828 FLAG(lcnf
, PCI_HT_LCNF_DFIE
),
829 FLAG(lcnf
, PCI_HT_LCNF_DFOE
));
830 printf("\t\tRevision ID: %u.%02u\n",
831 (rid
& PCI_HT_RID_MAJ
) >> 5, (rid
& PCI_HT_RID_MIN
));
834 lfrer
= get_conf_byte(d
, where
+ PCI_HT_SEC_LFRER
);
835 printf("\t\tLink Frequency: %s\n", ht_link_freq(lfrer
& PCI_HT_LFRER_FREQ
));
836 printf("\t\tLink Error: <Prot%c <Ovfl%c <EOC%c CTLTm%c\n",
837 FLAG(lfrer
, PCI_HT_LFRER_PROT
),
838 FLAG(lfrer
, PCI_HT_LFRER_OV
),
839 FLAG(lfrer
, PCI_HT_LFRER_EOC
),
840 FLAG(lfrer
, PCI_HT_LFRER_CTLT
));
841 lfcap
= get_conf_byte(d
, where
+ PCI_HT_SEC_LFCAP
);
842 printf("\t\tLink Frequency Capability: 200MHz%c 300MHz%c 400MHz%c 500MHz%c 600MHz%c 800MHz%c 1.0GHz%c 1.2GHz%c 1.4GHz%c 1.6GHz%c Vend%c\n",
843 FLAG(lfcap
, PCI_HT_LFCAP_200
),
844 FLAG(lfcap
, PCI_HT_LFCAP_300
),
845 FLAG(lfcap
, PCI_HT_LFCAP_400
),
846 FLAG(lfcap
, PCI_HT_LFCAP_500
),
847 FLAG(lfcap
, PCI_HT_LFCAP_600
),
848 FLAG(lfcap
, PCI_HT_LFCAP_800
),
849 FLAG(lfcap
, PCI_HT_LFCAP_1000
),
850 FLAG(lfcap
, PCI_HT_LFCAP_1200
),
851 FLAG(lfcap
, PCI_HT_LFCAP_1400
),
852 FLAG(lfcap
, PCI_HT_LFCAP_1600
),
853 FLAG(lfcap
, PCI_HT_LFCAP_VEND
));
854 ftr
= get_conf_word(d
, where
+ PCI_HT_SEC_FTR
);
855 printf("\t\tFeature Capability: IsocFC%c LDTSTOP%c CRCTM%c ECTLT%c 64bA%c UIDRD%c ExtRS%c UCnfE%c\n",
856 FLAG(ftr
, PCI_HT_FTR_ISOCFC
),
857 FLAG(ftr
, PCI_HT_FTR_LDTSTOP
),
858 FLAG(ftr
, PCI_HT_FTR_CRCTM
),
859 FLAG(ftr
, PCI_HT_FTR_ECTLT
),
860 FLAG(ftr
, PCI_HT_FTR_64BA
),
861 FLAG(ftr
, PCI_HT_FTR_UIDRD
),
862 FLAG(ftr
, PCI_HT_SEC_FTR_EXTRS
),
863 FLAG(ftr
, PCI_HT_SEC_FTR_UCNFE
));
864 if (ftr
& PCI_HT_SEC_FTR_EXTRS
)
866 eh
= get_conf_word(d
, where
+ PCI_HT_SEC_EH
);
867 printf("\t\tError Handling: PFlE%c OFlE%c PFE%c OFE%c EOCFE%c RFE%c CRCFE%c SERRFE%c CF%c RE%c PNFE%c ONFE%c EOCNFE%c RNFE%c CRCNFE%c SERRNFE%c\n",
868 FLAG(eh
, PCI_HT_EH_PFLE
),
869 FLAG(eh
, PCI_HT_EH_OFLE
),
870 FLAG(eh
, PCI_HT_EH_PFE
),
871 FLAG(eh
, PCI_HT_EH_OFE
),
872 FLAG(eh
, PCI_HT_EH_EOCFE
),
873 FLAG(eh
, PCI_HT_EH_RFE
),
874 FLAG(eh
, PCI_HT_EH_CRCFE
),
875 FLAG(eh
, PCI_HT_EH_SERRFE
),
876 FLAG(eh
, PCI_HT_EH_CF
),
877 FLAG(eh
, PCI_HT_EH_RE
),
878 FLAG(eh
, PCI_HT_EH_PNFE
),
879 FLAG(eh
, PCI_HT_EH_ONFE
),
880 FLAG(eh
, PCI_HT_EH_EOCNFE
),
881 FLAG(eh
, PCI_HT_EH_RNFE
),
882 FLAG(eh
, PCI_HT_EH_CRCNFE
),
883 FLAG(eh
, PCI_HT_EH_SERRNFE
));
884 mbu
= get_conf_byte(d
, where
+ PCI_HT_SEC_MBU
);
885 mlu
= get_conf_byte(d
, where
+ PCI_HT_SEC_MLU
);
886 printf("\t\tPrefetchable memory behind bridge Upper: %02x-%02x\n", mbu
, mlu
);
891 show_ht(struct device
*d
, int where
, int cmd
)
895 switch (cmd
& PCI_HT_CMD_TYP_HI
)
897 case PCI_HT_CMD_TYP_HI_PRI
:
898 show_ht_pri(d
, where
, cmd
);
900 case PCI_HT_CMD_TYP_HI_SEC
:
901 show_ht_sec(d
, where
, cmd
);
905 type
= cmd
& PCI_HT_CMD_TYP
;
908 case PCI_HT_CMD_TYP_SW
:
909 printf("HyperTransport: Switch\n");
911 case PCI_HT_CMD_TYP_IDC
:
912 printf("HyperTransport: Interrupt Discovery and Configuration\n");
914 case PCI_HT_CMD_TYP_RID
:
915 printf("HyperTransport: Revision ID: %u.%02u\n",
916 (cmd
& PCI_HT_RID_MAJ
) >> 5, (cmd
& PCI_HT_RID_MIN
));
918 case PCI_HT_CMD_TYP_UIDC
:
919 printf("HyperTransport: UnitID Clumping\n");
921 case PCI_HT_CMD_TYP_ECSA
:
922 printf("HyperTransport: Extended Configuration Space Access\n");
924 case PCI_HT_CMD_TYP_AM
:
925 printf("HyperTransport: Address Mapping\n");
927 case PCI_HT_CMD_TYP_MSIM
:
928 printf("HyperTransport: MSI Mapping\n");
930 case PCI_HT_CMD_TYP_DR
:
931 printf("HyperTransport: DirectRoute\n");
933 case PCI_HT_CMD_TYP_VCS
:
934 printf("HyperTransport: VCSet\n");
936 case PCI_HT_CMD_TYP_RM
:
937 printf("HyperTransport: Retry Mode\n");
939 case PCI_HT_CMD_TYP_X86
:
940 printf("HyperTransport: X86 (reserved)\n");
943 printf("HyperTransport: #%02x\n", type
>> 11);
948 show_rom(struct device
*d
, int reg
)
950 struct pci_dev
*p
= d
->dev
;
951 pciaddr_t rom
= p
->rom_base_addr
;
952 pciaddr_t len
= (p
->known_fields
& PCI_FILL_SIZES
) ? p
->rom_size
: 0;
953 u32 flg
= get_conf_long(d
, reg
);
954 word cmd
= get_conf_word(d
, PCI_COMMAND
);
956 if (!rom
&& !flg
&& !len
)
959 if ((rom
& PCI_ROM_ADDRESS_MASK
) && !(flg
& PCI_ROM_ADDRESS_MASK
))
961 printf("[virtual] ");
964 printf("Expansion ROM at ");
965 if (rom
& PCI_ROM_ADDRESS_MASK
)
966 printf(PCIADDR_T_FMT
, rom
& PCI_ROM_ADDRESS_MASK
);
967 else if (flg
& PCI_ROM_ADDRESS_MASK
)
970 printf("<unassigned>");
971 if (!(flg
& PCI_ROM_ADDRESS_ENABLE
))
972 printf(" [disabled]");
973 else if (!(cmd
& PCI_COMMAND_MEMORY
))
974 printf(" [disabled by cmd]");
980 show_msi(struct device
*d
, int where
, int cap
)
986 printf("Message Signalled Interrupts: 64bit%c Queue=%d/%d Enable%c\n",
987 FLAG(cap
, PCI_MSI_FLAGS_64BIT
),
988 (cap
& PCI_MSI_FLAGS_QSIZE
) >> 4,
989 (cap
& PCI_MSI_FLAGS_QMASK
) >> 1,
990 FLAG(cap
, PCI_MSI_FLAGS_ENABLE
));
993 is64
= cap
& PCI_MSI_FLAGS_64BIT
;
994 if (!config_fetch(d
, where
+ PCI_MSI_ADDRESS_LO
, (is64
? PCI_MSI_DATA_64
: PCI_MSI_DATA_32
) + 2 - PCI_MSI_ADDRESS_LO
))
996 printf("\t\tAddress: ");
999 t
= get_conf_long(d
, where
+ PCI_MSI_ADDRESS_HI
);
1000 w
= get_conf_word(d
, where
+ PCI_MSI_DATA_64
);
1004 w
= get_conf_word(d
, where
+ PCI_MSI_DATA_32
);
1005 t
= get_conf_long(d
, where
+ PCI_MSI_ADDRESS_LO
);
1006 printf("%08x Data: %04x\n", t
, w
);
1009 static void show_vendor(void)
1011 printf("Vendor Specific Information\n");
1014 static void show_debug(void)
1016 printf("Debug port\n");
1019 static float power_limit(int value
, int scale
)
1021 static const float scales
[4] = { 1.0, 0.1, 0.01, 0.001 };
1022 return value
* scales
[scale
];
1025 static const char *latency_l0s(int value
)
1027 static const char *latencies
[] = { "<64ns", "<128ns", "<256ns", "<512ns", "<1us", "<2us", "<4us", "unlimited" };
1028 return latencies
[value
];
1031 static const char *latency_l1(int value
)
1033 static const char *latencies
[] = { "<1us", "<2us", "<4us", "<8us", "<16us", "<32us", "<64us", "unlimited" };
1034 return latencies
[value
];
1037 static void show_express_dev(struct device
*d
, int where
, int type
)
1042 t
= get_conf_long(d
, where
+ PCI_EXP_DEVCAP
);
1043 printf("\t\tDevice: Supported: MaxPayload %d bytes, PhantFunc %d, ExtTag%c\n",
1044 128 << (t
& PCI_EXP_DEVCAP_PAYLOAD
),
1045 (1 << ((t
& PCI_EXP_DEVCAP_PHANTOM
) >> 3)) - 1,
1046 FLAG(t
, PCI_EXP_DEVCAP_EXT_TAG
));
1047 printf("\t\tDevice: Latency L0s %s, L1 %s\n",
1048 latency_l0s((t
& PCI_EXP_DEVCAP_L0S
) >> 6),
1049 latency_l1((t
& PCI_EXP_DEVCAP_L1
) >> 9));
1050 if ((type
== PCI_EXP_TYPE_ENDPOINT
) || (type
== PCI_EXP_TYPE_LEG_END
) ||
1051 (type
== PCI_EXP_TYPE_UPSTREAM
) || (type
== PCI_EXP_TYPE_PCI_BRIDGE
))
1052 printf("\t\tDevice: AtnBtn%c AtnInd%c PwrInd%c\n",
1053 FLAG(t
, PCI_EXP_DEVCAP_ATN_BUT
),
1054 FLAG(t
, PCI_EXP_DEVCAP_ATN_IND
), FLAG(t
, PCI_EXP_DEVCAP_PWR_IND
));
1055 if (type
== PCI_EXP_TYPE_UPSTREAM
)
1056 printf("\t\tDevice: SlotPowerLimit %f\n",
1057 power_limit((t
& PCI_EXP_DEVCAP_PWR_VAL
) >> 18,
1058 (t
& PCI_EXP_DEVCAP_PWR_SCL
) >> 26));
1060 w
= get_conf_word(d
, where
+ PCI_EXP_DEVCTL
);
1061 printf("\t\tDevice: Errors: Correctable%c Non-Fatal%c Fatal%c Unsupported%c\n",
1062 FLAG(w
, PCI_EXP_DEVCTL_CERE
),
1063 FLAG(w
, PCI_EXP_DEVCTL_NFERE
),
1064 FLAG(w
, PCI_EXP_DEVCTL_FERE
),
1065 FLAG(w
, PCI_EXP_DEVCTL_URRE
));
1066 printf("\t\tDevice: RlxdOrd%c ExtTag%c PhantFunc%c AuxPwr%c NoSnoop%c\n",
1067 FLAG(w
, PCI_EXP_DEVCTL_RELAXED
),
1068 FLAG(w
, PCI_EXP_DEVCTL_EXT_TAG
),
1069 FLAG(w
, PCI_EXP_DEVCTL_PHANTOM
),
1070 FLAG(w
, PCI_EXP_DEVCTL_AUX_PME
),
1071 FLAG(w
, PCI_EXP_DEVCTL_NOSNOOP
));
1072 printf("\t\tDevice: MaxPayload %d bytes, MaxReadReq %d bytes\n",
1073 128 << ((w
& PCI_EXP_DEVCTL_PAYLOAD
) >> 5),
1074 128 << ((w
& PCI_EXP_DEVCTL_READRQ
) >> 12));
1077 static char *link_speed(int speed
)
1088 static char *aspm_support(int code
)
1101 static const char *aspm_enabled(int code
)
1103 static const char *desc
[] = { "Disabled", "L0s Enabled", "L1 Enabled", "L0s L1 Enabled" };
1107 static void show_express_link(struct device
*d
, int where
, int type
)
1112 t
= get_conf_long(d
, where
+ PCI_EXP_LNKCAP
);
1113 printf("\t\tLink: Supported Speed %s, Width x%d, ASPM %s, Port %d\n",
1114 link_speed(t
& PCI_EXP_LNKCAP_SPEED
), (t
& PCI_EXP_LNKCAP_WIDTH
) >> 4,
1115 aspm_support((t
& PCI_EXP_LNKCAP_ASPM
) >> 10),
1117 printf("\t\tLink: Latency L0s %s, L1 %s\n",
1118 latency_l0s((t
& PCI_EXP_LNKCAP_L0S
) >> 12),
1119 latency_l1((t
& PCI_EXP_LNKCAP_L1
) >> 15));
1120 w
= get_conf_word(d
, where
+ PCI_EXP_LNKCTL
);
1121 printf("\t\tLink: ASPM %s", aspm_enabled(w
& PCI_EXP_LNKCTL_ASPM
));
1122 if ((type
== PCI_EXP_TYPE_ROOT_PORT
) || (type
== PCI_EXP_TYPE_ENDPOINT
) ||
1123 (type
== PCI_EXP_TYPE_LEG_END
))
1124 printf(" RCB %d bytes", w
& PCI_EXP_LNKCTL_RCB
? 128 : 64);
1125 if (w
& PCI_EXP_LNKCTL_DISABLE
)
1126 printf(" Disabled");
1127 printf(" CommClk%c ExtSynch%c\n", FLAG(w
, PCI_EXP_LNKCTL_CLOCK
),
1128 FLAG(w
, PCI_EXP_LNKCTL_XSYNCH
));
1129 w
= get_conf_word(d
, where
+ PCI_EXP_LNKSTA
);
1130 printf("\t\tLink: Speed %s, Width x%d\n",
1131 link_speed(t
& PCI_EXP_LNKSTA_SPEED
), (t
& PCI_EXP_LNKSTA_WIDTH
) >> 4);
1134 static const char *indicator(int code
)
1136 static const char *names
[] = { "Unknown", "On", "Blink", "Off" };
1140 static void show_express_slot(struct device
*d
, int where
)
1145 t
= get_conf_long(d
, where
+ PCI_EXP_SLTCAP
);
1146 printf("\t\tSlot: AtnBtn%c PwrCtrl%c MRL%c AtnInd%c PwrInd%c HotPlug%c Surpise%c\n",
1147 FLAG(t
, PCI_EXP_SLTCAP_ATNB
),
1148 FLAG(t
, PCI_EXP_SLTCAP_PWRC
),
1149 FLAG(t
, PCI_EXP_SLTCAP_MRL
),
1150 FLAG(t
, PCI_EXP_SLTCAP_ATNI
),
1151 FLAG(t
, PCI_EXP_SLTCAP_PWRI
),
1152 FLAG(t
, PCI_EXP_SLTCAP_HPC
),
1153 FLAG(t
, PCI_EXP_SLTCAP_HPS
));
1154 printf("\t\tSlot: Number %d, PowerLimit %f\n", t
>> 19,
1155 power_limit((t
& PCI_EXP_SLTCAP_PWR_VAL
) >> 7,
1156 (t
& PCI_EXP_SLTCAP_PWR_SCL
) >> 15));
1157 w
= get_conf_word(d
, where
+ PCI_EXP_SLTCTL
);
1158 printf("\t\tSlot: Enabled AtnBtn%c PwrFlt%c MRL%c PresDet%c CmdCplt%c HPIrq%c\n",
1159 FLAG(w
, PCI_EXP_SLTCTL_ATNB
),
1160 FLAG(w
, PCI_EXP_SLTCTL_PWRF
),
1161 FLAG(w
, PCI_EXP_SLTCTL_MRLS
),
1162 FLAG(w
, PCI_EXP_SLTCTL_PRSD
),
1163 FLAG(w
, PCI_EXP_SLTCTL_CMDC
),
1164 FLAG(w
, PCI_EXP_SLTCTL_HPIE
));
1165 printf("\t\tSlot: AttnInd %s, PwrInd %s, Power%c\n",
1166 indicator((w
& PCI_EXP_SLTCTL_ATNI
) >> 6),
1167 indicator((w
& PCI_EXP_SLTCTL_PWRI
) >> 8),
1168 FLAG(w
, w
& PCI_EXP_SLTCTL_PWRC
));
1171 static void show_express_root(struct device
*d
, int where
)
1173 u16 w
= get_conf_word(d
, where
+ PCI_EXP_RTCTL
);
1174 printf("\t\tRoot: Correctable%c Non-Fatal%c Fatal%c PME%c\n",
1175 FLAG(w
, PCI_EXP_RTCTL_SECEE
),
1176 FLAG(w
, PCI_EXP_RTCTL_SENFEE
),
1177 FLAG(w
, PCI_EXP_RTCTL_SEFEE
),
1178 FLAG(w
, PCI_EXP_RTCTL_PMEIE
));
1182 show_express(struct device
*d
, int where
, int cap
)
1184 int type
= (cap
& PCI_EXP_FLAGS_TYPE
) >> 4;
1191 case PCI_EXP_TYPE_ENDPOINT
:
1194 case PCI_EXP_TYPE_LEG_END
:
1195 printf("Legacy Endpoint");
1197 case PCI_EXP_TYPE_ROOT_PORT
:
1198 slot
= cap
& PCI_EXP_FLAGS_SLOT
;
1199 printf("Root Port (Slot%c)", FLAG(cap
, PCI_EXP_FLAGS_SLOT
));
1201 case PCI_EXP_TYPE_UPSTREAM
:
1202 printf("Upstream Port");
1204 case PCI_EXP_TYPE_DOWNSTREAM
:
1205 slot
= cap
& PCI_EXP_FLAGS_SLOT
;
1206 printf("Downstream Port (Slot%c)", FLAG(cap
, PCI_EXP_FLAGS_SLOT
));
1208 case PCI_EXP_TYPE_PCI_BRIDGE
:
1209 printf("PCI/PCI-X Bridge");
1212 printf("Unknown type");
1214 printf(" IRQ %d\n", (cap
& PCI_EXP_FLAGS_IRQ
) >> 9);
1221 if (type
== PCI_EXP_TYPE_ROOT_PORT
)
1223 if (!config_fetch(d
, where
+ PCI_EXP_DEVCAP
, size
))
1226 show_express_dev(d
, where
, type
);
1227 show_express_link(d
, where
, type
);
1229 show_express_slot(d
, where
);
1230 if (type
== PCI_EXP_TYPE_ROOT_PORT
)
1231 show_express_root(d
, where
);
1235 show_msix(struct device
*d
, int where
, int cap
)
1239 printf("MSI-X: Enable%c Mask%c TabSize=%d\n",
1240 FLAG(cap
, PCI_MSIX_ENABLE
),
1241 FLAG(cap
, PCI_MSIX_MASK
),
1242 (cap
& PCI_MSIX_TABSIZE
) + 1);
1243 if (verbose
< 2 || !config_fetch(d
, where
+ PCI_MSIX_TABLE
, 8))
1246 off
= get_conf_long(d
, where
+ PCI_MSIX_TABLE
);
1247 printf("\t\tVector table: BAR=%d offset=%08x\n",
1248 off
& PCI_MSIX_BIR
, off
& ~PCI_MSIX_BIR
);
1249 off
= get_conf_long(d
, where
+ PCI_MSIX_PBA
);
1250 printf("\t\tPBA: BAR=%d offset=%08x\n",
1251 off
& PCI_MSIX_BIR
, off
& ~PCI_MSIX_BIR
);
1255 show_slotid(int cap
)
1257 int esr
= cap
& 0xff;
1260 printf("Slot ID: %d slots, First%c, chassis %02x\n",
1261 esr
& PCI_SID_ESR_NSLOTS
,
1262 FLAG(esr
, PCI_SID_ESR_FIC
),
1267 show_aer(struct device
*d UNUSED
, int where UNUSED
)
1269 printf("Advanced Error Reporting\n");
1273 show_vc(struct device
*d UNUSED
, int where UNUSED
)
1275 printf("Virtual Channel\n");
1279 show_dsn(struct device
*d
, int where
)
1282 if (!config_fetch(d
, where
+ 4, 8))
1284 t1
= get_conf_long(d
, where
+ 4);
1285 t2
= get_conf_long(d
, where
+ 8);
1286 printf("Device Serial Number %02x-%02x-%02x-%02x-%02x-%02x-%02x-%02x\n",
1287 t1
& 0xff, (t1
>> 8) & 0xff, (t1
>> 16) & 0xff, t1
>> 24,
1288 t2
& 0xff, (t2
>> 8) & 0xff, (t2
>> 16) & 0xff, t2
>> 24);
1292 show_pb(struct device
*d UNUSED
, int where UNUSED
)
1294 printf("Power Budgeting\n");
1298 show_ext_caps(struct device
*d
)
1306 if (!config_fetch(d
, where
, 4))
1308 header
= get_conf_long(d
, where
);
1311 id
= header
& 0xffff;
1312 printf("\tCapabilities: [%03x] ", where
);
1315 case PCI_EXT_CAP_ID_AER
:
1318 case PCI_EXT_CAP_ID_VC
:
1321 case PCI_EXT_CAP_ID_DSN
:
1324 case PCI_EXT_CAP_ID_PB
:
1328 printf("Unknown (%d)\n", id
);
1331 where
= header
>> 20;
1336 show_caps(struct device
*d
)
1338 int can_have_ext_caps
= 0;
1340 if (get_conf_word(d
, PCI_STATUS
) & PCI_STATUS_CAP_LIST
)
1342 int where
= get_conf_byte(d
, PCI_CAPABILITY_LIST
) & ~3;
1346 printf("\tCapabilities: ");
1347 if (!config_fetch(d
, where
, 4))
1349 puts("<access denied>");
1352 id
= get_conf_byte(d
, where
+ PCI_CAP_LIST_ID
);
1353 next
= get_conf_byte(d
, where
+ PCI_CAP_LIST_NEXT
) & ~3;
1354 cap
= get_conf_word(d
, where
+ PCI_CAP_FLAGS
);
1355 printf("[%02x] ", where
);
1358 printf("<chain broken>\n");
1364 show_pm(d
, where
, cap
);
1366 case PCI_CAP_ID_AGP
:
1367 show_agp(d
, where
, cap
);
1369 case PCI_CAP_ID_VPD
:
1370 printf("Vital Product Data\n");
1372 case PCI_CAP_ID_SLOTID
:
1375 case PCI_CAP_ID_MSI
:
1376 show_msi(d
, where
, cap
);
1378 case PCI_CAP_ID_PCIX
:
1379 show_pcix(d
, where
);
1380 can_have_ext_caps
= 1;
1383 show_ht(d
, where
, cap
);
1385 case PCI_CAP_ID_VNDR
:
1388 case PCI_CAP_ID_DBG
:
1391 case PCI_CAP_ID_EXP
:
1392 show_express(d
, where
, cap
);
1393 can_have_ext_caps
= 1;
1395 case PCI_CAP_ID_MSIX
:
1396 show_msix(d
, where
, cap
);
1399 printf("#%02x [%04x]\n", id
, cap
);
1404 if (can_have_ext_caps
)
1409 show_htype0(struct device
*d
)
1412 show_rom(d
, PCI_ROM_ADDRESS
);
1417 show_htype1(struct device
*d
)
1419 u32 io_base
= get_conf_byte(d
, PCI_IO_BASE
);
1420 u32 io_limit
= get_conf_byte(d
, PCI_IO_LIMIT
);
1421 u32 io_type
= io_base
& PCI_IO_RANGE_TYPE_MASK
;
1422 u32 mem_base
= get_conf_word(d
, PCI_MEMORY_BASE
);
1423 u32 mem_limit
= get_conf_word(d
, PCI_MEMORY_LIMIT
);
1424 u32 mem_type
= mem_base
& PCI_MEMORY_RANGE_TYPE_MASK
;
1425 u32 pref_base
= get_conf_word(d
, PCI_PREF_MEMORY_BASE
);
1426 u32 pref_limit
= get_conf_word(d
, PCI_PREF_MEMORY_LIMIT
);
1427 u32 pref_type
= pref_base
& PCI_PREF_RANGE_TYPE_MASK
;
1428 word sec_stat
= get_conf_word(d
, PCI_SEC_STATUS
);
1429 word brc
= get_conf_word(d
, PCI_BRIDGE_CONTROL
);
1430 int verb
= verbose
> 2;
1433 printf("\tBus: primary=%02x, secondary=%02x, subordinate=%02x, sec-latency=%d\n",
1434 get_conf_byte(d
, PCI_PRIMARY_BUS
),
1435 get_conf_byte(d
, PCI_SECONDARY_BUS
),
1436 get_conf_byte(d
, PCI_SUBORDINATE_BUS
),
1437 get_conf_byte(d
, PCI_SEC_LATENCY_TIMER
));
1439 if (io_type
!= (io_limit
& PCI_IO_RANGE_TYPE_MASK
) ||
1440 (io_type
!= PCI_IO_RANGE_TYPE_16
&& io_type
!= PCI_IO_RANGE_TYPE_32
))
1441 printf("\t!!! Unknown I/O range types %x/%x\n", io_base
, io_limit
);
1444 io_base
= (io_base
& PCI_IO_RANGE_MASK
) << 8;
1445 io_limit
= (io_limit
& PCI_IO_RANGE_MASK
) << 8;
1446 if (io_type
== PCI_IO_RANGE_TYPE_32
)
1448 io_base
|= (get_conf_word(d
, PCI_IO_BASE_UPPER16
) << 16);
1449 io_limit
|= (get_conf_word(d
, PCI_IO_LIMIT_UPPER16
) << 16);
1451 if (io_base
<= io_limit
|| verb
)
1452 printf("\tI/O behind bridge: %08x-%08x\n", io_base
, io_limit
+0xfff);
1455 if (mem_type
!= (mem_limit
& PCI_MEMORY_RANGE_TYPE_MASK
) ||
1457 printf("\t!!! Unknown memory range types %x/%x\n", mem_base
, mem_limit
);
1460 mem_base
= (mem_base
& PCI_MEMORY_RANGE_MASK
) << 16;
1461 mem_limit
= (mem_limit
& PCI_MEMORY_RANGE_MASK
) << 16;
1462 if (mem_base
<= mem_limit
|| verb
)
1463 printf("\tMemory behind bridge: %08x-%08x\n", mem_base
, mem_limit
+ 0xfffff);
1466 if (pref_type
!= (pref_limit
& PCI_PREF_RANGE_TYPE_MASK
) ||
1467 (pref_type
!= PCI_PREF_RANGE_TYPE_32
&& pref_type
!= PCI_PREF_RANGE_TYPE_64
))
1468 printf("\t!!! Unknown prefetchable memory range types %x/%x\n", pref_base
, pref_limit
);
1471 pref_base
= (pref_base
& PCI_PREF_RANGE_MASK
) << 16;
1472 pref_limit
= (pref_limit
& PCI_PREF_RANGE_MASK
) << 16;
1473 if (pref_base
<= pref_limit
|| verb
)
1475 if (pref_type
== PCI_PREF_RANGE_TYPE_32
)
1476 printf("\tPrefetchable memory behind bridge: %08x-%08x\n", pref_base
, pref_limit
+ 0xfffff);
1478 printf("\tPrefetchable memory behind bridge: %08x%08x-%08x%08x\n",
1479 get_conf_long(d
, PCI_PREF_BASE_UPPER32
),
1481 get_conf_long(d
, PCI_PREF_LIMIT_UPPER32
),
1487 printf("\tSecondary status: 66MHz%c FastB2B%c ParErr%c DEVSEL=%s >TAbort%c <TAbort%c <MAbort%c <SERR%c <PERR%c\n",
1488 FLAG(sec_stat
, PCI_STATUS_66MHZ
),
1489 FLAG(sec_stat
, PCI_STATUS_FAST_BACK
),
1490 FLAG(sec_stat
, PCI_STATUS_PARITY
),
1491 ((sec_stat
& PCI_STATUS_DEVSEL_MASK
) == PCI_STATUS_DEVSEL_SLOW
) ? "slow" :
1492 ((sec_stat
& PCI_STATUS_DEVSEL_MASK
) == PCI_STATUS_DEVSEL_MEDIUM
) ? "medium" :
1493 ((sec_stat
& PCI_STATUS_DEVSEL_MASK
) == PCI_STATUS_DEVSEL_FAST
) ? "fast" : "??",
1494 FLAG(sec_stat
, PCI_STATUS_SIG_TARGET_ABORT
),
1495 FLAG(sec_stat
, PCI_STATUS_REC_TARGET_ABORT
),
1496 FLAG(sec_stat
, PCI_STATUS_REC_MASTER_ABORT
),
1497 FLAG(sec_stat
, PCI_STATUS_SIG_SYSTEM_ERROR
),
1498 FLAG(sec_stat
, PCI_STATUS_DETECTED_PARITY
));
1500 show_rom(d
, PCI_ROM_ADDRESS1
);
1503 printf("\tBridgeCtl: Parity%c SERR%c NoISA%c VGA%c MAbort%c >Reset%c FastB2B%c\n",
1504 FLAG(brc
, PCI_BRIDGE_CTL_PARITY
),
1505 FLAG(brc
, PCI_BRIDGE_CTL_SERR
),
1506 FLAG(brc
, PCI_BRIDGE_CTL_NO_ISA
),
1507 FLAG(brc
, PCI_BRIDGE_CTL_VGA
),
1508 FLAG(brc
, PCI_BRIDGE_CTL_MASTER_ABORT
),
1509 FLAG(brc
, PCI_BRIDGE_CTL_BUS_RESET
),
1510 FLAG(brc
, PCI_BRIDGE_CTL_FAST_BACK
));
1516 show_htype2(struct device
*d
)
1519 word cmd
= get_conf_word(d
, PCI_COMMAND
);
1520 word brc
= get_conf_word(d
, PCI_CB_BRIDGE_CONTROL
);
1522 int verb
= verbose
> 2;
1525 printf("\tBus: primary=%02x, secondary=%02x, subordinate=%02x, sec-latency=%d\n",
1526 get_conf_byte(d
, PCI_CB_PRIMARY_BUS
),
1527 get_conf_byte(d
, PCI_CB_CARD_BUS
),
1528 get_conf_byte(d
, PCI_CB_SUBORDINATE_BUS
),
1529 get_conf_byte(d
, PCI_CB_LATENCY_TIMER
));
1533 u32 base
= get_conf_long(d
, PCI_CB_MEMORY_BASE_0
+ p
);
1534 u32 limit
= get_conf_long(d
, PCI_CB_MEMORY_LIMIT_0
+ p
);
1535 if (limit
> base
|| verb
)
1536 printf("\tMemory window %d: %08x-%08x%s%s\n", i
, base
, limit
,
1537 (cmd
& PCI_COMMAND_MEMORY
) ? "" : " [disabled]",
1538 (brc
& (PCI_CB_BRIDGE_CTL_PREFETCH_MEM0
<< i
)) ? " (prefetchable)" : "");
1543 u32 base
= get_conf_long(d
, PCI_CB_IO_BASE_0
+ p
);
1544 u32 limit
= get_conf_long(d
, PCI_CB_IO_LIMIT_0
+ p
);
1545 if (!(base
& PCI_IO_RANGE_TYPE_32
))
1550 base
&= PCI_CB_IO_RANGE_MASK
;
1551 limit
= (limit
& PCI_CB_IO_RANGE_MASK
) + 3;
1552 if (base
<= limit
|| verb
)
1553 printf("\tI/O window %d: %08x-%08x%s\n", i
, base
, limit
,
1554 (cmd
& PCI_COMMAND_IO
) ? "" : " [disabled]");
1557 if (get_conf_word(d
, PCI_CB_SEC_STATUS
) & PCI_STATUS_SIG_SYSTEM_ERROR
)
1558 printf("\tSecondary status: SERR\n");
1560 printf("\tBridgeCtl: Parity%c SERR%c ISA%c VGA%c MAbort%c >Reset%c 16bInt%c PostWrite%c\n",
1561 FLAG(brc
, PCI_CB_BRIDGE_CTL_PARITY
),
1562 FLAG(brc
, PCI_CB_BRIDGE_CTL_SERR
),
1563 FLAG(brc
, PCI_CB_BRIDGE_CTL_ISA
),
1564 FLAG(brc
, PCI_CB_BRIDGE_CTL_VGA
),
1565 FLAG(brc
, PCI_CB_BRIDGE_CTL_MASTER_ABORT
),
1566 FLAG(brc
, PCI_CB_BRIDGE_CTL_CB_RESET
),
1567 FLAG(brc
, PCI_CB_BRIDGE_CTL_16BIT_INT
),
1568 FLAG(brc
, PCI_CB_BRIDGE_CTL_POST_WRITES
));
1570 if (d
->config_cached
< 128)
1572 printf("\t<access denied to the rest>\n");
1576 exca
= get_conf_word(d
, PCI_CB_LEGACY_MODE_BASE
);
1578 printf("\t16-bit legacy interface ports at %04x\n", exca
);
1582 show_verbose(struct device
*d
)
1584 struct pci_dev
*p
= d
->dev
;
1585 word status
= get_conf_word(d
, PCI_STATUS
);
1586 word cmd
= get_conf_word(d
, PCI_COMMAND
);
1587 word
class = get_conf_word(d
, PCI_CLASS_DEVICE
);
1588 byte bist
= get_conf_byte(d
, PCI_BIST
);
1589 byte htype
= get_conf_byte(d
, PCI_HEADER_TYPE
) & 0x7f;
1590 byte latency
= get_conf_byte(d
, PCI_LATENCY_TIMER
);
1591 byte cache_line
= get_conf_byte(d
, PCI_CACHE_LINE_SIZE
);
1592 byte max_lat
, min_gnt
;
1593 byte int_pin
= get_conf_byte(d
, PCI_INTERRUPT_PIN
);
1594 unsigned int irq
= p
->irq
;
1595 word subsys_v
= 0, subsys_d
= 0;
1596 char ssnamebuf
[256];
1602 case PCI_HEADER_TYPE_NORMAL
:
1603 if (class == PCI_CLASS_BRIDGE_PCI
)
1604 printf("\t!!! Invalid class %04x for header type %02x\n", class, htype
);
1605 max_lat
= get_conf_byte(d
, PCI_MAX_LAT
);
1606 min_gnt
= get_conf_byte(d
, PCI_MIN_GNT
);
1607 subsys_v
= get_conf_word(d
, PCI_SUBSYSTEM_VENDOR_ID
);
1608 subsys_d
= get_conf_word(d
, PCI_SUBSYSTEM_ID
);
1610 case PCI_HEADER_TYPE_BRIDGE
:
1611 if ((class >> 8) != PCI_BASE_CLASS_BRIDGE
)
1612 printf("\t!!! Invalid class %04x for header type %02x\n", class, htype
);
1613 irq
= int_pin
= min_gnt
= max_lat
= 0;
1615 case PCI_HEADER_TYPE_CARDBUS
:
1616 if ((class >> 8) != PCI_BASE_CLASS_BRIDGE
)
1617 printf("\t!!! Invalid class %04x for header type %02x\n", class, htype
);
1618 min_gnt
= max_lat
= 0;
1619 if (d
->config_cached
>= 128)
1621 subsys_v
= get_conf_word(d
, PCI_CB_SUBSYSTEM_VENDOR_ID
);
1622 subsys_d
= get_conf_word(d
, PCI_CB_SUBSYSTEM_ID
);
1626 printf("\t!!! Unknown header type %02x\n", htype
);
1630 if (subsys_v
&& subsys_v
!= 0xffff)
1631 printf("\tSubsystem: %s\n",
1632 pci_lookup_name(pacc
, ssnamebuf
, sizeof(ssnamebuf
),
1633 PCI_LOOKUP_SUBSYSTEM
| PCI_LOOKUP_VENDOR
| PCI_LOOKUP_DEVICE
,
1634 p
->vendor_id
, p
->device_id
, subsys_v
, subsys_d
));
1638 printf("\tControl: I/O%c Mem%c BusMaster%c SpecCycle%c MemWINV%c VGASnoop%c ParErr%c Stepping%c SERR%c FastB2B%c\n",
1639 FLAG(cmd
, PCI_COMMAND_IO
),
1640 FLAG(cmd
, PCI_COMMAND_MEMORY
),
1641 FLAG(cmd
, PCI_COMMAND_MASTER
),
1642 FLAG(cmd
, PCI_COMMAND_SPECIAL
),
1643 FLAG(cmd
, PCI_COMMAND_INVALIDATE
),
1644 FLAG(cmd
, PCI_COMMAND_VGA_PALETTE
),
1645 FLAG(cmd
, PCI_COMMAND_PARITY
),
1646 FLAG(cmd
, PCI_COMMAND_WAIT
),
1647 FLAG(cmd
, PCI_COMMAND_SERR
),
1648 FLAG(cmd
, PCI_COMMAND_FAST_BACK
));
1649 printf("\tStatus: Cap%c 66MHz%c UDF%c FastB2B%c ParErr%c DEVSEL=%s >TAbort%c <TAbort%c <MAbort%c >SERR%c <PERR%c\n",
1650 FLAG(status
, PCI_STATUS_CAP_LIST
),
1651 FLAG(status
, PCI_STATUS_66MHZ
),
1652 FLAG(status
, PCI_STATUS_UDF
),
1653 FLAG(status
, PCI_STATUS_FAST_BACK
),
1654 FLAG(status
, PCI_STATUS_PARITY
),
1655 ((status
& PCI_STATUS_DEVSEL_MASK
) == PCI_STATUS_DEVSEL_SLOW
) ? "slow" :
1656 ((status
& PCI_STATUS_DEVSEL_MASK
) == PCI_STATUS_DEVSEL_MEDIUM
) ? "medium" :
1657 ((status
& PCI_STATUS_DEVSEL_MASK
) == PCI_STATUS_DEVSEL_FAST
) ? "fast" : "??",
1658 FLAG(status
, PCI_STATUS_SIG_TARGET_ABORT
),
1659 FLAG(status
, PCI_STATUS_REC_TARGET_ABORT
),
1660 FLAG(status
, PCI_STATUS_REC_MASTER_ABORT
),
1661 FLAG(status
, PCI_STATUS_SIG_SYSTEM_ERROR
),
1662 FLAG(status
, PCI_STATUS_DETECTED_PARITY
));
1663 if (cmd
& PCI_COMMAND_MASTER
)
1665 printf("\tLatency: %d", latency
);
1666 if (min_gnt
|| max_lat
)
1670 printf("%dns min", min_gnt
*250);
1671 if (min_gnt
&& max_lat
)
1674 printf("%dns max", max_lat
*250);
1678 printf(", Cache Line Size %02x", cache_line
);
1682 printf("\tInterrupt: pin %c routed to IRQ " PCIIRQ_FMT
"\n",
1683 (int_pin
? 'A' + int_pin
- 1 : '?'), irq
);
1687 printf("\tFlags: ");
1688 if (cmd
& PCI_COMMAND_MASTER
)
1689 printf("bus master, ");
1690 if (cmd
& PCI_COMMAND_VGA_PALETTE
)
1691 printf("VGA palette snoop, ");
1692 if (cmd
& PCI_COMMAND_WAIT
)
1693 printf("stepping, ");
1694 if (cmd
& PCI_COMMAND_FAST_BACK
)
1695 printf("fast Back2Back, ");
1696 if (status
& PCI_STATUS_66MHZ
)
1698 if (status
& PCI_STATUS_UDF
)
1699 printf("user-definable features, ");
1701 ((status
& PCI_STATUS_DEVSEL_MASK
) == PCI_STATUS_DEVSEL_SLOW
) ? "slow" :
1702 ((status
& PCI_STATUS_DEVSEL_MASK
) == PCI_STATUS_DEVSEL_MEDIUM
) ? "medium" :
1703 ((status
& PCI_STATUS_DEVSEL_MASK
) == PCI_STATUS_DEVSEL_FAST
) ? "fast" : "??");
1704 if (cmd
& PCI_COMMAND_MASTER
)
1705 printf(", latency %d", latency
);
1707 printf(", IRQ " PCIIRQ_FMT
, irq
);
1711 if (bist
& PCI_BIST_CAPABLE
)
1713 if (bist
& PCI_BIST_START
)
1714 printf("\tBIST is running\n");
1716 printf("\tBIST result: %02x\n", bist
& PCI_BIST_CODE_MASK
);
1721 case PCI_HEADER_TYPE_NORMAL
:
1724 case PCI_HEADER_TYPE_BRIDGE
:
1727 case PCI_HEADER_TYPE_CARDBUS
:
1734 show_hex_dump(struct device
*d
)
1736 unsigned int i
, cnt
;
1738 cnt
= d
->config_cached
;
1739 if (show_hex
>= 3 && config_fetch(d
, cnt
, 256-cnt
))
1742 if (show_hex
>= 4 && config_fetch(d
, 256, 4096-256))
1746 for(i
=0; i
<cnt
; i
++)
1750 printf(" %02x", get_conf_byte(d
, i
));
1757 show_machine(struct device
*d
)
1759 struct pci_dev
*p
= d
->dev
;
1761 word sv_id
=0, sd_id
=0;
1762 char classbuf
[128], vendbuf
[128], devbuf
[128], svbuf
[128], sdbuf
[128];
1764 switch (get_conf_byte(d
, PCI_HEADER_TYPE
) & 0x7f)
1766 case PCI_HEADER_TYPE_NORMAL
:
1767 sv_id
= get_conf_word(d
, PCI_SUBSYSTEM_VENDOR_ID
);
1768 sd_id
= get_conf_word(d
, PCI_SUBSYSTEM_ID
);
1770 case PCI_HEADER_TYPE_CARDBUS
:
1771 if (d
->config_cached
>= 128)
1773 sv_id
= get_conf_word(d
, PCI_CB_SUBSYSTEM_VENDOR_ID
);
1774 sd_id
= get_conf_word(d
, PCI_CB_SUBSYSTEM_ID
);
1781 printf("Device:\t");
1784 printf("Class:\t%s\n",
1785 pci_lookup_name(pacc
, classbuf
, sizeof(classbuf
), PCI_LOOKUP_CLASS
, get_conf_word(d
, PCI_CLASS_DEVICE
), 0, 0, 0));
1786 printf("Vendor:\t%s\n",
1787 pci_lookup_name(pacc
, vendbuf
, sizeof(vendbuf
), PCI_LOOKUP_VENDOR
, p
->vendor_id
, p
->device_id
, 0, 0));
1788 printf("Device:\t%s\n",
1789 pci_lookup_name(pacc
, devbuf
, sizeof(devbuf
), PCI_LOOKUP_DEVICE
, p
->vendor_id
, p
->device_id
, 0, 0));
1790 if (sv_id
&& sv_id
!= 0xffff)
1792 printf("SVendor:\t%s\n",
1793 pci_lookup_name(pacc
, svbuf
, sizeof(svbuf
), PCI_LOOKUP_SUBSYSTEM
| PCI_LOOKUP_VENDOR
, p
->vendor_id
, p
->device_id
, sv_id
, sd_id
));
1794 printf("SDevice:\t%s\n",
1795 pci_lookup_name(pacc
, sdbuf
, sizeof(sdbuf
), PCI_LOOKUP_SUBSYSTEM
| PCI_LOOKUP_DEVICE
, p
->vendor_id
, p
->device_id
, sv_id
, sd_id
));
1797 if (c
= get_conf_byte(d
, PCI_REVISION_ID
))
1798 printf("Rev:\t%02x\n", c
);
1799 if (c
= get_conf_byte(d
, PCI_CLASS_PROG
))
1800 printf("ProgIf:\t%02x\n", c
);
1805 printf(" \"%s\" \"%s\" \"%s\"",
1806 pci_lookup_name(pacc
, classbuf
, sizeof(classbuf
), PCI_LOOKUP_CLASS
,
1807 get_conf_word(d
, PCI_CLASS_DEVICE
), 0, 0, 0),
1808 pci_lookup_name(pacc
, vendbuf
, sizeof(vendbuf
), PCI_LOOKUP_VENDOR
,
1809 p
->vendor_id
, p
->device_id
, 0, 0),
1810 pci_lookup_name(pacc
, devbuf
, sizeof(devbuf
), PCI_LOOKUP_DEVICE
,
1811 p
->vendor_id
, p
->device_id
, 0, 0));
1812 if (c
= get_conf_byte(d
, PCI_REVISION_ID
))
1813 printf(" -r%02x", c
);
1814 if (c
= get_conf_byte(d
, PCI_CLASS_PROG
))
1815 printf(" -p%02x", c
);
1816 if (sv_id
&& sv_id
!= 0xffff)
1817 printf(" \"%s\" \"%s\"",
1818 pci_lookup_name(pacc
, svbuf
, sizeof(svbuf
), PCI_LOOKUP_SUBSYSTEM
| PCI_LOOKUP_VENDOR
, p
->vendor_id
, p
->device_id
, sv_id
, sd_id
),
1819 pci_lookup_name(pacc
, sdbuf
, sizeof(sdbuf
), PCI_LOOKUP_SUBSYSTEM
| PCI_LOOKUP_DEVICE
, p
->vendor_id
, p
->device_id
, sv_id
, sd_id
));
1821 printf(" \"\" \"\"");
1827 show_device(struct device
*d
)
1829 if (machine_readable
)
1837 if (verbose
|| show_hex
)
1846 for(d
=first_dev
; d
; d
=d
->next
)
1853 struct bridge
*chain
; /* Single-linked list of bridges */
1854 struct bridge
*next
, *child
; /* Tree of bridges */
1855 struct bus
*first_bus
; /* List of buses connected to this bridge */
1856 unsigned int domain
;
1857 unsigned int primary
, secondary
, subordinate
; /* Bus numbers */
1858 struct device
*br_dev
;
1862 unsigned int domain
;
1863 unsigned int number
;
1864 struct bus
*sibling
;
1865 struct device
*first_dev
, **last_dev
;
1868 static struct bridge host_bridge
= { NULL
, NULL
, NULL
, NULL
, 0, ~0, 0, ~0, NULL
};
1871 find_bus(struct bridge
*b
, unsigned int domain
, unsigned int n
)
1875 for(bus
=b
->first_bus
; bus
; bus
=bus
->sibling
)
1876 if (bus
->domain
== domain
&& bus
->number
== n
)
1882 new_bus(struct bridge
*b
, unsigned int domain
, unsigned int n
)
1884 struct bus
*bus
= xmalloc(sizeof(struct bus
));
1886 bus
= xmalloc(sizeof(struct bus
));
1887 bus
->domain
= domain
;
1889 bus
->sibling
= b
->first_bus
;
1890 bus
->first_dev
= NULL
;
1891 bus
->last_dev
= &bus
->first_dev
;
1897 insert_dev(struct device
*d
, struct bridge
*b
)
1899 struct pci_dev
*p
= d
->dev
;
1902 if (! (bus
= find_bus(b
, p
->domain
, p
->bus
)))
1905 for(c
=b
->child
; c
; c
=c
->next
)
1906 if (c
->domain
== p
->domain
&& c
->secondary
<= p
->bus
&& p
->bus
<= c
->subordinate
)
1911 bus
= new_bus(b
, p
->domain
, p
->bus
);
1913 /* Simple insertion at the end _does_ guarantee the correct order as the
1914 * original device list was sorted by (domain, bus, devfn) lexicographically
1915 * and all devices on the new list have the same bus number.
1918 bus
->last_dev
= &d
->next
;
1925 struct device
*d
, *d2
;
1926 struct bridge
**last_br
, *b
;
1928 /* Build list of bridges */
1930 last_br
= &host_bridge
.chain
;
1931 for(d
=first_dev
; d
; d
=d
->next
)
1933 word
class = get_conf_word(d
, PCI_CLASS_DEVICE
);
1934 byte ht
= get_conf_byte(d
, PCI_HEADER_TYPE
) & 0x7f;
1935 if (class == PCI_CLASS_BRIDGE_PCI
&&
1936 (ht
== PCI_HEADER_TYPE_BRIDGE
|| ht
== PCI_HEADER_TYPE_CARDBUS
))
1938 b
= xmalloc(sizeof(struct bridge
));
1939 b
->domain
= d
->dev
->domain
;
1940 if (ht
== PCI_HEADER_TYPE_BRIDGE
)
1942 b
->primary
= get_conf_byte(d
, PCI_CB_PRIMARY_BUS
);
1943 b
->secondary
= get_conf_byte(d
, PCI_CB_CARD_BUS
);
1944 b
->subordinate
= get_conf_byte(d
, PCI_CB_SUBORDINATE_BUS
);
1948 b
->primary
= get_conf_byte(d
, PCI_PRIMARY_BUS
);
1949 b
->secondary
= get_conf_byte(d
, PCI_SECONDARY_BUS
);
1950 b
->subordinate
= get_conf_byte(d
, PCI_SUBORDINATE_BUS
);
1953 last_br
= &b
->chain
;
1954 b
->next
= b
->child
= NULL
;
1955 b
->first_bus
= NULL
;
1961 /* Create a bridge tree */
1963 for(b
=&host_bridge
; b
; b
=b
->chain
)
1965 struct bridge
*c
, *best
;
1967 for(c
=&host_bridge
; c
; c
=c
->chain
)
1968 if (c
!= b
&& (c
== &host_bridge
|| b
->domain
== c
->domain
) &&
1969 b
->primary
>= c
->secondary
&& b
->primary
<= c
->subordinate
&&
1970 (!best
|| best
->subordinate
- best
->primary
> c
->subordinate
- c
->primary
))
1974 b
->next
= best
->child
;
1979 /* Insert secondary bus for each bridge */
1981 for(b
=&host_bridge
; b
; b
=b
->chain
)
1982 if (!find_bus(b
, b
->domain
, b
->secondary
))
1983 new_bus(b
, b
->domain
, b
->secondary
);
1985 /* Create bus structs and link devices */
1987 for(d
=first_dev
; d
;)
1990 insert_dev(d
, &host_bridge
);
1996 print_it(byte
*line
, byte
*p
)
2000 fputs(line
, stdout
);
2001 for(p
=line
; *p
; p
++)
2002 if (*p
== '+' || *p
== '|')
2008 static void show_tree_bridge(struct bridge
*, byte
*, byte
*);
2011 show_tree_dev(struct device
*d
, byte
*line
, byte
*p
)
2013 struct pci_dev
*q
= d
->dev
;
2017 p
+= sprintf(p
, "%02x.%x", q
->dev
, q
->func
);
2018 for(b
=&host_bridge
; b
; b
=b
->chain
)
2021 if (b
->secondary
== b
->subordinate
)
2022 p
+= sprintf(p
, "-[%04x:%02x]-", b
->domain
, b
->secondary
);
2024 p
+= sprintf(p
, "-[%04x:%02x-%02x]-", b
->domain
, b
->secondary
, b
->subordinate
);
2025 show_tree_bridge(b
, line
, p
);
2029 p
+= sprintf(p
, " %s",
2030 pci_lookup_name(pacc
, namebuf
, sizeof(namebuf
),
2031 PCI_LOOKUP_VENDOR
| PCI_LOOKUP_DEVICE
,
2032 q
->vendor_id
, q
->device_id
, 0, 0));
2037 show_tree_bus(struct bus
*b
, byte
*line
, byte
*p
)
2041 else if (!b
->first_dev
->next
)
2045 show_tree_dev(b
->first_dev
, line
, p
);
2049 struct device
*d
= b
->first_dev
;
2054 show_tree_dev(d
, line
, p
+2);
2059 show_tree_dev(d
, line
, p
+2);
2064 show_tree_bridge(struct bridge
*b
, byte
*line
, byte
*p
)
2067 if (!b
->first_bus
->sibling
)
2069 if (b
== &host_bridge
)
2070 p
+= sprintf(p
, "[%04x:%02x]-", b
->domain
, b
->first_bus
->number
);
2071 show_tree_bus(b
->first_bus
, line
, p
);
2075 struct bus
*u
= b
->first_bus
;
2080 k
= p
+ sprintf(p
, "+-[%04x:%02x]-", u
->domain
, u
->number
);
2081 show_tree_bus(u
, line
, k
);
2084 k
= p
+ sprintf(p
, "\\-[%04x:%02x]-", u
->domain
, u
->number
);
2085 show_tree_bus(u
, line
, k
);
2095 show_tree_bridge(&host_bridge
, line
, line
);
2098 /* Bus mapping mode */
2101 struct bus_bridge
*next
;
2102 byte
this, dev
, func
, first
, last
, bug
;
2108 struct bus_bridge
*bridges
, *via
;
2111 static struct bus_info
*bus_info
;
2114 map_bridge(struct bus_info
*bi
, struct device
*d
, int np
, int ns
, int nl
)
2116 struct bus_bridge
*b
= xmalloc(sizeof(struct bus_bridge
));
2117 struct pci_dev
*p
= d
->dev
;
2119 b
->next
= bi
->bridges
;
2121 b
->this = get_conf_byte(d
, np
);
2124 b
->first
= get_conf_byte(d
, ns
);
2125 b
->last
= get_conf_byte(d
, nl
);
2126 printf("## %02x.%02x:%d is a bridge from %02x to %02x-%02x\n",
2127 p
->bus
, p
->dev
, p
->func
, b
->this, b
->first
, b
->last
);
2128 if (b
->this != p
->bus
)
2129 printf("!!! Bridge points to invalid primary bus.\n");
2130 if (b
->first
> b
->last
)
2132 printf("!!! Bridge points to invalid bus range.\n");
2141 int verbose
= pacc
->debugging
;
2142 struct bus_info
*bi
= bus_info
+ bus
;
2146 printf("Mapping bus %02x\n", bus
);
2147 for(dev
= 0; dev
< 32; dev
++)
2148 if (filter
.slot
< 0 || filter
.slot
== dev
)
2151 for(func
= 0; func
< func_limit
; func
++)
2152 if (filter
.func
< 0 || filter
.func
== func
)
2154 /* XXX: Bus mapping supports only domain 0 */
2155 struct pci_dev
*p
= pci_get_dev(pacc
, 0, bus
, dev
, func
);
2156 u16 vendor
= pci_read_word(p
, PCI_VENDOR_ID
);
2157 if (vendor
&& vendor
!= 0xffff)
2159 if (!func
&& (pci_read_byte(p
, PCI_HEADER_TYPE
) & 0x80))
2162 printf("Discovered device %02x:%02x.%d\n", bus
, dev
, func
);
2164 if (d
= scan_device(p
))
2167 switch (get_conf_byte(d
, PCI_HEADER_TYPE
) & 0x7f)
2169 case PCI_HEADER_TYPE_BRIDGE
:
2170 map_bridge(bi
, d
, PCI_PRIMARY_BUS
, PCI_SECONDARY_BUS
, PCI_SUBORDINATE_BUS
);
2172 case PCI_HEADER_TYPE_CARDBUS
:
2173 map_bridge(bi
, d
, PCI_CB_PRIMARY_BUS
, PCI_CB_CARD_BUS
, PCI_CB_SUBORDINATE_BUS
);
2179 printf("But it was filtered out.\n");
2187 do_map_bridges(int bus
, int min
, int max
)
2189 struct bus_info
*bi
= bus_info
+ bus
;
2190 struct bus_bridge
*b
;
2193 for(b
=bi
->bridges
; b
; b
=b
->next
)
2195 if (bus_info
[b
->first
].guestbook
)
2197 else if (b
->first
< min
|| b
->last
> max
)
2201 bus_info
[b
->first
].via
= b
;
2202 do_map_bridges(b
->first
, b
->first
, b
->last
);
2212 printf("\nSummary of buses:\n\n");
2213 for(i
=0; i
<256; i
++)
2214 if (bus_info
[i
].exists
&& !bus_info
[i
].guestbook
)
2215 do_map_bridges(i
, 0, 255);
2216 for(i
=0; i
<256; i
++)
2218 struct bus_info
*bi
= bus_info
+ i
;
2219 struct bus_bridge
*b
= bi
->via
;
2223 printf("%02x: ", i
);
2225 printf("Entered via %02x:%02x.%d\n", b
->this, b
->dev
, b
->func
);
2227 printf("Primary host bus\n");
2229 printf("Secondary host bus (?)\n");
2231 for(b
=bi
->bridges
; b
; b
=b
->next
)
2233 printf("\t%02x.%d Bridge to %02x-%02x", b
->dev
, b
->func
, b
->first
, b
->last
);
2237 printf(" <overlap bug>");
2240 printf(" <crossing bug>");
2251 if (pacc
->method
== PCI_ACCESS_PROC_BUS_PCI
||
2252 pacc
->method
== PCI_ACCESS_DUMP
)
2253 printf("WARNING: Bus mapping can be reliable only with direct hardware access enabled.\n\n");
2254 bus_info
= xmalloc(sizeof(struct bus_info
) * 256);
2255 bzero(bus_info
, sizeof(struct bus_info
) * 256);
2256 if (filter
.bus
>= 0)
2257 do_map_bus(filter
.bus
);
2261 for(bus
=0; bus
<256; bus
++)
2270 main(int argc
, char **argv
)
2275 if (argc
== 2 && !strcmp(argv
[1], "--version"))
2277 puts("lspci version " PCIUTILS_VERSION
);
2283 pci_filter_init(pacc
, &filter
);
2285 while ((i
= getopt(argc
, argv
, options
)) != -1)
2289 pacc
->numeric_ids
= 1;
2295 pacc
->buscentric
= 1;
2296 buscentric_view
= 1;
2299 if (msg
= pci_filter_parse_slot(&filter
, optarg
))
2303 if (msg
= pci_filter_parse_id(&filter
, optarg
))
2313 pacc
->id_file_name
= optarg
;
2322 if (parse_generic_option(i
, pacc
, optarg
))
2325 fprintf(stderr
, help_msg
, pacc
->id_file_name
);