2 * The PCI Utilities -- List All PCI Devices
4 * Copyright (c) 1997--2015 Martin Mares <mj@ucw.cz>
6 * Can be freely distributed and used under the terms of the GNU GPL.
18 int verbose; /* Show detailed information */
19 static int opt_hex; /* Show contents of config space as hexadecimal numbers */
20 struct pci_filter filter; /* Device filter */
21 static int opt_tree; /* Show bus tree */
22 static int opt_machine; /* Generate machine-readable output */
23 static int opt_map_mode; /* Bus mapping mode enabled */
24 static int opt_domains; /* Show domain numbers (0=disabled, 1=auto-detected, 2=requested) */
25 static int opt_kernel; /* Show kernel drivers */
26 static int opt_query_dns; /* Query the DNS (0=disabled, 1=enabled, 2=refresh cache) */
27 static int opt_query_all; /* Query the DNS for all entries */
28 char *opt_pcimap; /* Override path to Linux modules.pcimap */
30 const char program_name[] = "lspci";
32 static char options[] = "nvbxs:d:ti:mgp:qkMDQ" GENERIC_OPTIONS ;
34 static char help_msg[] =
35 "Usage: lspci [<switches>]\n"
37 "Basic display modes:\n"
38 "-mm\t\tProduce machine-readable output (single -m for an obsolete format)\n"
39 "-t\t\tShow bus tree\n"
42 "-v\t\tBe verbose (-vv for very verbose)\n"
44 "-k\t\tShow kernel drivers handling each device\n"
46 "-x\t\tShow hex-dump of the standard part of the config space\n"
47 "-xxx\t\tShow hex-dump of the whole config space (dangerous; root only)\n"
48 "-xxxx\t\tShow hex-dump of the 4096-byte extended config space (root only)\n"
49 "-b\t\tBus-centric view (addresses and IRQ's as seen by the bus)\n"
50 "-D\t\tAlways show domain numbers\n"
52 "Resolving of device ID's to names:\n"
53 "-n\t\tShow numeric ID's\n"
54 "-nn\t\tShow both textual and numeric ID's (names & numbers)\n"
56 "-q\t\tQuery the PCI ID database for unknown ID's via DNS\n"
57 "-qq\t\tAs above, but re-query locally cached entries\n"
58 "-Q\t\tQuery the PCI ID database for all ID's via DNS\n"
61 "Selection of devices:\n"
62 "-s [[[[<domain>]:]<bus>]:][<slot>][.[<func>]]\tShow only devices in selected slots\n"
63 "-d [<vendor>]:[<device>][:<class>]\t\tShow only devices with specified ID's\n"
66 "-i <file>\tUse specified ID database instead of %s\n"
68 "-p <file>\tLook up kernel modules in a given file instead of default modules.pcimap\n"
70 "-M\t\tEnable `bus mapping' mode (dangerous; root only)\n"
72 "PCI access options:\n"
76 /*** Our view of the PCI bus ***/
78 struct pci_access *pacc;
79 struct device *first_dev;
80 static int seen_errors;
83 config_fetch(struct device *d, unsigned int pos, unsigned int len)
85 unsigned int end = pos+len;
88 while (pos < d->config_bufsize && len && d->present[pos])
90 while (pos+len <= d->config_bufsize && len && d->present[pos+len-1])
95 if (end > d->config_bufsize)
97 int orig_size = d->config_bufsize;
98 while (end > d->config_bufsize)
99 d->config_bufsize *= 2;
100 d->config = xrealloc(d->config, d->config_bufsize);
101 d->present = xrealloc(d->present, d->config_bufsize);
102 memset(d->present + orig_size, 0, d->config_bufsize - orig_size);
104 result = pci_read_block(d->dev, pos, d->config + pos, len);
106 memset(d->present + pos, 1, len);
111 scan_device(struct pci_dev *p)
115 if (p->domain && !opt_domains)
117 if (!pci_filter_match(&filter, p))
119 d = xmalloc(sizeof(struct device));
120 memset(d, 0, sizeof(*d));
122 d->config_cached = d->config_bufsize = 64;
123 d->config = xmalloc(64);
124 d->present = xmalloc(64);
125 memset(d->present, 1, 64);
126 if (!pci_read_block(p, 0, d->config, 64))
128 fprintf(stderr, "lspci: Unable to read the standard configuration space header of device %04x:%02x:%02x.%d\n",
129 p->domain, p->bus, p->dev, p->func);
133 if ((d->config[PCI_HEADER_TYPE] & 0x7f) == PCI_HEADER_TYPE_CARDBUS)
135 /* For cardbus bridges, we need to fetch 64 bytes more to get the
136 * full standard header... */
137 if (config_fetch(d, 64, 64))
138 d->config_cached += 64;
140 pci_setup_cache(p, d->config, d->config_cached);
141 pci_fill_info(p, PCI_FILL_IDENT | PCI_FILL_CLASS);
152 for (p=pacc->devices; p; p=p->next)
153 if (d = scan_device(p))
160 /*** Config space accesses ***/
163 check_conf_range(struct device *d, unsigned int pos, unsigned int len)
166 if (!d->present[pos])
167 die("Internal bug: Accessing non-read configuration byte at position %x", pos);
173 get_conf_byte(struct device *d, unsigned int pos)
175 check_conf_range(d, pos, 1);
176 return d->config[pos];
180 get_conf_word(struct device *d, unsigned int pos)
182 check_conf_range(d, pos, 2);
183 return d->config[pos] | (d->config[pos+1] << 8);
187 get_conf_long(struct device *d, unsigned int pos)
189 check_conf_range(d, pos, 4);
190 return d->config[pos] |
191 (d->config[pos+1] << 8) |
192 (d->config[pos+2] << 16) |
193 (d->config[pos+3] << 24);
199 compare_them(const void *A, const void *B)
201 const struct pci_dev *a = (*(const struct device **)A)->dev;
202 const struct pci_dev *b = (*(const struct device **)B)->dev;
204 if (a->domain < b->domain)
206 if (a->domain > b->domain)
216 if (a->func < b->func)
218 if (a->func > b->func)
226 struct device **index, **h, **last_dev;
231 for (d=first_dev; d; d=d->next)
233 h = index = alloca(sizeof(struct device *) * cnt);
234 for (d=first_dev; d; d=d->next)
236 qsort(index, cnt, sizeof(struct device *), compare_them);
237 last_dev = &first_dev;
242 last_dev = &(*h)->next;
248 /*** Normal output ***/
251 show_slot_name(struct device *d)
253 struct pci_dev *p = d->dev;
255 if (!opt_machine ? opt_domains : (p->domain || opt_domains >= 2))
256 printf("%04x:", p->domain);
257 printf("%02x:%02x.%d", p->bus, p->dev, p->func);
261 get_subid(struct device *d, word *subvp, word *subdp)
263 byte htype = get_conf_byte(d, PCI_HEADER_TYPE) & 0x7f;
265 if (htype == PCI_HEADER_TYPE_NORMAL)
267 *subvp = get_conf_word(d, PCI_SUBSYSTEM_VENDOR_ID);
268 *subdp = get_conf_word(d, PCI_SUBSYSTEM_ID);
270 else if (htype == PCI_HEADER_TYPE_CARDBUS && d->config_cached >= 128)
272 *subvp = get_conf_word(d, PCI_CB_SUBSYSTEM_VENDOR_ID);
273 *subdp = get_conf_word(d, PCI_CB_SUBSYSTEM_ID);
276 *subvp = *subdp = 0xffff;
280 show_terse(struct device *d)
283 struct pci_dev *p = d->dev;
284 char classbuf[128], devbuf[128];
288 pci_lookup_name(pacc, classbuf, sizeof(classbuf),
291 pci_lookup_name(pacc, devbuf, sizeof(devbuf),
292 PCI_LOOKUP_VENDOR | PCI_LOOKUP_DEVICE,
293 p->vendor_id, p->device_id));
294 if (c = get_conf_byte(d, PCI_REVISION_ID))
295 printf(" (rev %02x)", c);
299 c = get_conf_byte(d, PCI_CLASS_PROG);
300 x = pci_lookup_name(pacc, devbuf, sizeof(devbuf),
301 PCI_LOOKUP_PROGIF | PCI_LOOKUP_NO_NUMBERS,
305 printf(" (prog-if %02x", c);
313 if (verbose || opt_kernel)
315 word subsys_v, subsys_d;
319 printf("\tDeviceName: %s", p->label);
320 get_subid(d, &subsys_v, &subsys_d);
321 if (subsys_v && subsys_v != 0xffff)
322 printf("\tSubsystem: %s\n",
323 pci_lookup_name(pacc, ssnamebuf, sizeof(ssnamebuf),
324 PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_VENDOR | PCI_LOOKUP_DEVICE,
325 p->vendor_id, p->device_id, subsys_v, subsys_d));
329 /*** Verbose output ***/
332 show_size(pciaddr_t x)
334 static const char suffix[][2] = { "", "K", "M", "G", "T" };
338 for (i = 0; i < (sizeof(suffix) / sizeof(*suffix) - 1); i++) {
343 printf(" [size=%u%s]", (unsigned)x, suffix[i]);
347 show_bases(struct device *d, int cnt)
349 struct pci_dev *p = d->dev;
350 word cmd = get_conf_word(d, PCI_COMMAND);
354 for (i=0; i<cnt; i++)
356 pciaddr_t pos = p->base_addr[i];
357 pciaddr_t len = (p->known_fields & PCI_FILL_SIZES) ? p->size[i] : 0;
358 pciaddr_t ioflg = (p->known_fields & PCI_FILL_IO_FLAGS) ? p->flags[i] : 0;
359 u32 flg = get_conf_long(d, PCI_BASE_ADDRESS_0 + 4*i);
360 if (flg == 0xffffffff)
362 if (!pos && !flg && !len)
365 printf("\tRegion %d: ", i);
368 if (ioflg & PCI_IORESOURCE_PCI_EA_BEI)
369 printf("[enhanced] ");
370 else if (pos && !flg) /* Reported by the OS, but not by the device */
372 printf("[virtual] ");
376 if (flg & PCI_BASE_ADDRESS_SPACE_IO)
378 pciaddr_t a = pos & PCI_BASE_ADDRESS_IO_MASK;
379 printf("I/O ports at ");
380 if (a || (cmd & PCI_COMMAND_IO))
381 printf(PCIADDR_PORT_FMT, a);
382 else if (flg & PCI_BASE_ADDRESS_IO_MASK)
385 printf("<unassigned>");
386 if (!virtual && !(cmd & PCI_COMMAND_IO))
387 printf(" [disabled]");
391 int t = flg & PCI_BASE_ADDRESS_MEM_TYPE_MASK;
392 pciaddr_t a = pos & PCI_ADDR_MEM_MASK;
396 printf("Memory at ");
397 if (t == PCI_BASE_ADDRESS_MEM_TYPE_64)
401 printf("<invalid-64bit-slot>");
407 z = get_conf_long(d, PCI_BASE_ADDRESS_0 + 4*i);
413 printf(PCIADDR_T_FMT, a);
415 printf(((flg & PCI_BASE_ADDRESS_MEM_MASK) || z) ? "<ignored>" : "<unassigned>");
417 printf(" (%s, %sprefetchable)",
418 (t == PCI_BASE_ADDRESS_MEM_TYPE_32) ? "32-bit" :
419 (t == PCI_BASE_ADDRESS_MEM_TYPE_64) ? "64-bit" :
420 (t == PCI_BASE_ADDRESS_MEM_TYPE_1M) ? "low-1M" : "type 3",
421 (flg & PCI_BASE_ADDRESS_MEM_PREFETCH) ? "" : "non-");
422 if (!virtual && !(cmd & PCI_COMMAND_MEMORY))
423 printf(" [disabled]");
431 show_rom(struct device *d, int reg)
433 struct pci_dev *p = d->dev;
434 pciaddr_t rom = p->rom_base_addr;
435 pciaddr_t len = (p->known_fields & PCI_FILL_SIZES) ? p->rom_size : 0;
436 pciaddr_t ioflg = (p->known_fields & PCI_FILL_IO_FLAGS) ? p->rom_flags : 0;
437 u32 flg = get_conf_long(d, reg);
438 word cmd = get_conf_word(d, PCI_COMMAND);
441 if (!rom && !flg && !len)
444 if (ioflg & PCI_IORESOURCE_PCI_EA_BEI)
445 printf("[enhanced] ");
446 else if ((rom & PCI_ROM_ADDRESS_MASK) && !(flg & PCI_ROM_ADDRESS_MASK))
448 printf("[virtual] ");
452 printf("Expansion ROM at ");
453 if (rom & PCI_ROM_ADDRESS_MASK)
454 printf(PCIADDR_T_FMT, rom & PCI_ROM_ADDRESS_MASK);
455 else if (flg & PCI_ROM_ADDRESS_MASK)
458 printf("<unassigned>");
459 if (!(flg & PCI_ROM_ADDRESS_ENABLE))
460 printf(" [disabled]");
461 else if (!virtual && !(cmd & PCI_COMMAND_MEMORY))
462 printf(" [disabled by cmd]");
468 show_htype0(struct device *d)
471 show_rom(d, PCI_ROM_ADDRESS);
472 show_caps(d, PCI_CAPABILITY_LIST);
476 show_htype1(struct device *d)
478 u32 io_base = get_conf_byte(d, PCI_IO_BASE);
479 u32 io_limit = get_conf_byte(d, PCI_IO_LIMIT);
480 u32 io_type = io_base & PCI_IO_RANGE_TYPE_MASK;
481 u32 mem_base = get_conf_word(d, PCI_MEMORY_BASE);
482 u32 mem_limit = get_conf_word(d, PCI_MEMORY_LIMIT);
483 u32 mem_type = mem_base & PCI_MEMORY_RANGE_TYPE_MASK;
484 u32 pref_base = get_conf_word(d, PCI_PREF_MEMORY_BASE);
485 u32 pref_limit = get_conf_word(d, PCI_PREF_MEMORY_LIMIT);
486 u32 pref_type = pref_base & PCI_PREF_RANGE_TYPE_MASK;
487 word sec_stat = get_conf_word(d, PCI_SEC_STATUS);
488 word brc = get_conf_word(d, PCI_BRIDGE_CONTROL);
489 int verb = verbose > 2;
492 printf("\tBus: primary=%02x, secondary=%02x, subordinate=%02x, sec-latency=%d\n",
493 get_conf_byte(d, PCI_PRIMARY_BUS),
494 get_conf_byte(d, PCI_SECONDARY_BUS),
495 get_conf_byte(d, PCI_SUBORDINATE_BUS),
496 get_conf_byte(d, PCI_SEC_LATENCY_TIMER));
498 if (io_type != (io_limit & PCI_IO_RANGE_TYPE_MASK) ||
499 (io_type != PCI_IO_RANGE_TYPE_16 && io_type != PCI_IO_RANGE_TYPE_32))
500 printf("\t!!! Unknown I/O range types %x/%x\n", io_base, io_limit);
503 io_base = (io_base & PCI_IO_RANGE_MASK) << 8;
504 io_limit = (io_limit & PCI_IO_RANGE_MASK) << 8;
505 if (io_type == PCI_IO_RANGE_TYPE_32)
507 io_base |= (get_conf_word(d, PCI_IO_BASE_UPPER16) << 16);
508 io_limit |= (get_conf_word(d, PCI_IO_LIMIT_UPPER16) << 16);
510 if (io_base <= io_limit || verb)
511 printf("\tI/O behind bridge: %08x-%08x\n", io_base, io_limit+0xfff);
514 if (mem_type != (mem_limit & PCI_MEMORY_RANGE_TYPE_MASK) ||
516 printf("\t!!! Unknown memory range types %x/%x\n", mem_base, mem_limit);
519 mem_base = (mem_base & PCI_MEMORY_RANGE_MASK) << 16;
520 mem_limit = (mem_limit & PCI_MEMORY_RANGE_MASK) << 16;
521 if (mem_base <= mem_limit || verb)
522 printf("\tMemory behind bridge: %08x-%08x\n", mem_base, mem_limit + 0xfffff);
525 if (pref_type != (pref_limit & PCI_PREF_RANGE_TYPE_MASK) ||
526 (pref_type != PCI_PREF_RANGE_TYPE_32 && pref_type != PCI_PREF_RANGE_TYPE_64))
527 printf("\t!!! Unknown prefetchable memory range types %x/%x\n", pref_base, pref_limit);
530 pref_base = (pref_base & PCI_PREF_RANGE_MASK) << 16;
531 pref_limit = (pref_limit & PCI_PREF_RANGE_MASK) << 16;
532 if (pref_base <= pref_limit || verb)
534 if (pref_type == PCI_PREF_RANGE_TYPE_32)
535 printf("\tPrefetchable memory behind bridge: %08x-%08x\n", pref_base, pref_limit + 0xfffff);
537 printf("\tPrefetchable memory behind bridge: %08x%08x-%08x%08x\n",
538 get_conf_long(d, PCI_PREF_BASE_UPPER32),
540 get_conf_long(d, PCI_PREF_LIMIT_UPPER32),
541 pref_limit + 0xfffff);
546 printf("\tSecondary status: 66MHz%c FastB2B%c ParErr%c DEVSEL=%s >TAbort%c <TAbort%c <MAbort%c <SERR%c <PERR%c\n",
547 FLAG(sec_stat, PCI_STATUS_66MHZ),
548 FLAG(sec_stat, PCI_STATUS_FAST_BACK),
549 FLAG(sec_stat, PCI_STATUS_PARITY),
550 ((sec_stat & PCI_STATUS_DEVSEL_MASK) == PCI_STATUS_DEVSEL_SLOW) ? "slow" :
551 ((sec_stat & PCI_STATUS_DEVSEL_MASK) == PCI_STATUS_DEVSEL_MEDIUM) ? "medium" :
552 ((sec_stat & PCI_STATUS_DEVSEL_MASK) == PCI_STATUS_DEVSEL_FAST) ? "fast" : "??",
553 FLAG(sec_stat, PCI_STATUS_SIG_TARGET_ABORT),
554 FLAG(sec_stat, PCI_STATUS_REC_TARGET_ABORT),
555 FLAG(sec_stat, PCI_STATUS_REC_MASTER_ABORT),
556 FLAG(sec_stat, PCI_STATUS_SIG_SYSTEM_ERROR),
557 FLAG(sec_stat, PCI_STATUS_DETECTED_PARITY));
559 show_rom(d, PCI_ROM_ADDRESS1);
563 printf("\tBridgeCtl: Parity%c SERR%c NoISA%c VGA%c MAbort%c >Reset%c FastB2B%c\n",
564 FLAG(brc, PCI_BRIDGE_CTL_PARITY),
565 FLAG(brc, PCI_BRIDGE_CTL_SERR),
566 FLAG(brc, PCI_BRIDGE_CTL_NO_ISA),
567 FLAG(brc, PCI_BRIDGE_CTL_VGA),
568 FLAG(brc, PCI_BRIDGE_CTL_MASTER_ABORT),
569 FLAG(brc, PCI_BRIDGE_CTL_BUS_RESET),
570 FLAG(brc, PCI_BRIDGE_CTL_FAST_BACK));
571 printf("\t\tPriDiscTmr%c SecDiscTmr%c DiscTmrStat%c DiscTmrSERREn%c\n",
572 FLAG(brc, PCI_BRIDGE_CTL_PRI_DISCARD_TIMER),
573 FLAG(brc, PCI_BRIDGE_CTL_SEC_DISCARD_TIMER),
574 FLAG(brc, PCI_BRIDGE_CTL_DISCARD_TIMER_STATUS),
575 FLAG(brc, PCI_BRIDGE_CTL_DISCARD_TIMER_SERR_EN));
578 show_caps(d, PCI_CAPABILITY_LIST);
582 show_htype2(struct device *d)
585 word cmd = get_conf_word(d, PCI_COMMAND);
586 word brc = get_conf_word(d, PCI_CB_BRIDGE_CONTROL);
588 int verb = verbose > 2;
591 printf("\tBus: primary=%02x, secondary=%02x, subordinate=%02x, sec-latency=%d\n",
592 get_conf_byte(d, PCI_CB_PRIMARY_BUS),
593 get_conf_byte(d, PCI_CB_CARD_BUS),
594 get_conf_byte(d, PCI_CB_SUBORDINATE_BUS),
595 get_conf_byte(d, PCI_CB_LATENCY_TIMER));
599 u32 base = get_conf_long(d, PCI_CB_MEMORY_BASE_0 + p);
600 u32 limit = get_conf_long(d, PCI_CB_MEMORY_LIMIT_0 + p);
601 limit = limit + 0xfff;
602 if (base <= limit || verb)
603 printf("\tMemory window %d: %08x-%08x%s%s\n", i, base, limit,
604 (cmd & PCI_COMMAND_MEMORY) ? "" : " [disabled]",
605 (brc & (PCI_CB_BRIDGE_CTL_PREFETCH_MEM0 << i)) ? " (prefetchable)" : "");
610 u32 base = get_conf_long(d, PCI_CB_IO_BASE_0 + p);
611 u32 limit = get_conf_long(d, PCI_CB_IO_LIMIT_0 + p);
612 if (!(base & PCI_IO_RANGE_TYPE_32))
617 base &= PCI_CB_IO_RANGE_MASK;
618 limit = (limit & PCI_CB_IO_RANGE_MASK) + 3;
619 if (base <= limit || verb)
620 printf("\tI/O window %d: %08x-%08x%s\n", i, base, limit,
621 (cmd & PCI_COMMAND_IO) ? "" : " [disabled]");
624 if (get_conf_word(d, PCI_CB_SEC_STATUS) & PCI_STATUS_SIG_SYSTEM_ERROR)
625 printf("\tSecondary status: SERR\n");
627 printf("\tBridgeCtl: Parity%c SERR%c ISA%c VGA%c MAbort%c >Reset%c 16bInt%c PostWrite%c\n",
628 FLAG(brc, PCI_CB_BRIDGE_CTL_PARITY),
629 FLAG(brc, PCI_CB_BRIDGE_CTL_SERR),
630 FLAG(brc, PCI_CB_BRIDGE_CTL_ISA),
631 FLAG(brc, PCI_CB_BRIDGE_CTL_VGA),
632 FLAG(brc, PCI_CB_BRIDGE_CTL_MASTER_ABORT),
633 FLAG(brc, PCI_CB_BRIDGE_CTL_CB_RESET),
634 FLAG(brc, PCI_CB_BRIDGE_CTL_16BIT_INT),
635 FLAG(brc, PCI_CB_BRIDGE_CTL_POST_WRITES));
637 if (d->config_cached < 128)
639 printf("\t<access denied to the rest>\n");
643 exca = get_conf_word(d, PCI_CB_LEGACY_MODE_BASE);
645 printf("\t16-bit legacy interface ports at %04x\n", exca);
646 show_caps(d, PCI_CB_CAPABILITY_LIST);
650 show_verbose(struct device *d)
652 struct pci_dev *p = d->dev;
653 word status = get_conf_word(d, PCI_STATUS);
654 word cmd = get_conf_word(d, PCI_COMMAND);
655 word class = p->device_class;
656 byte bist = get_conf_byte(d, PCI_BIST);
657 byte htype = get_conf_byte(d, PCI_HEADER_TYPE) & 0x7f;
658 byte latency = get_conf_byte(d, PCI_LATENCY_TIMER);
659 byte cache_line = get_conf_byte(d, PCI_CACHE_LINE_SIZE);
660 byte max_lat, min_gnt;
661 byte int_pin = get_conf_byte(d, PCI_INTERRUPT_PIN);
666 pci_fill_info(p, PCI_FILL_IRQ | PCI_FILL_BASES | PCI_FILL_ROM_BASE | PCI_FILL_SIZES |
667 PCI_FILL_PHYS_SLOT | PCI_FILL_LABEL | PCI_FILL_NUMA_NODE);
672 case PCI_HEADER_TYPE_NORMAL:
673 if (class == PCI_CLASS_BRIDGE_PCI)
674 printf("\t!!! Invalid class %04x for header type %02x\n", class, htype);
675 max_lat = get_conf_byte(d, PCI_MAX_LAT);
676 min_gnt = get_conf_byte(d, PCI_MIN_GNT);
678 case PCI_HEADER_TYPE_BRIDGE:
679 if ((class >> 8) != PCI_BASE_CLASS_BRIDGE)
680 printf("\t!!! Invalid class %04x for header type %02x\n", class, htype);
681 min_gnt = max_lat = 0;
683 case PCI_HEADER_TYPE_CARDBUS:
684 if ((class >> 8) != PCI_BASE_CLASS_BRIDGE)
685 printf("\t!!! Invalid class %04x for header type %02x\n", class, htype);
686 min_gnt = max_lat = 0;
689 printf("\t!!! Unknown header type %02x\n", htype);
694 printf("\tPhysical Slot: %s\n", p->phy_slot);
698 printf("\tControl: I/O%c Mem%c BusMaster%c SpecCycle%c MemWINV%c VGASnoop%c ParErr%c Stepping%c SERR%c FastB2B%c DisINTx%c\n",
699 FLAG(cmd, PCI_COMMAND_IO),
700 FLAG(cmd, PCI_COMMAND_MEMORY),
701 FLAG(cmd, PCI_COMMAND_MASTER),
702 FLAG(cmd, PCI_COMMAND_SPECIAL),
703 FLAG(cmd, PCI_COMMAND_INVALIDATE),
704 FLAG(cmd, PCI_COMMAND_VGA_PALETTE),
705 FLAG(cmd, PCI_COMMAND_PARITY),
706 FLAG(cmd, PCI_COMMAND_WAIT),
707 FLAG(cmd, PCI_COMMAND_SERR),
708 FLAG(cmd, PCI_COMMAND_FAST_BACK),
709 FLAG(cmd, PCI_COMMAND_DISABLE_INTx));
710 printf("\tStatus: Cap%c 66MHz%c UDF%c FastB2B%c ParErr%c DEVSEL=%s >TAbort%c <TAbort%c <MAbort%c >SERR%c <PERR%c INTx%c\n",
711 FLAG(status, PCI_STATUS_CAP_LIST),
712 FLAG(status, PCI_STATUS_66MHZ),
713 FLAG(status, PCI_STATUS_UDF),
714 FLAG(status, PCI_STATUS_FAST_BACK),
715 FLAG(status, PCI_STATUS_PARITY),
716 ((status & PCI_STATUS_DEVSEL_MASK) == PCI_STATUS_DEVSEL_SLOW) ? "slow" :
717 ((status & PCI_STATUS_DEVSEL_MASK) == PCI_STATUS_DEVSEL_MEDIUM) ? "medium" :
718 ((status & PCI_STATUS_DEVSEL_MASK) == PCI_STATUS_DEVSEL_FAST) ? "fast" : "??",
719 FLAG(status, PCI_STATUS_SIG_TARGET_ABORT),
720 FLAG(status, PCI_STATUS_REC_TARGET_ABORT),
721 FLAG(status, PCI_STATUS_REC_MASTER_ABORT),
722 FLAG(status, PCI_STATUS_SIG_SYSTEM_ERROR),
723 FLAG(status, PCI_STATUS_DETECTED_PARITY),
724 FLAG(status, PCI_STATUS_INTx));
725 if (cmd & PCI_COMMAND_MASTER)
727 printf("\tLatency: %d", latency);
728 if (min_gnt || max_lat)
732 printf("%dns min", min_gnt*250);
733 if (min_gnt && max_lat)
736 printf("%dns max", max_lat*250);
740 printf(", Cache Line Size: %d bytes", cache_line * 4);
744 printf("\tInterrupt: pin %c routed to IRQ " PCIIRQ_FMT "\n",
745 (int_pin ? 'A' + int_pin - 1 : '?'), irq);
746 if (p->numa_node != -1)
747 printf("\tNUMA node: %d\n", p->numa_node);
752 if (cmd & PCI_COMMAND_MASTER)
753 printf("bus master, ");
754 if (cmd & PCI_COMMAND_VGA_PALETTE)
755 printf("VGA palette snoop, ");
756 if (cmd & PCI_COMMAND_WAIT)
757 printf("stepping, ");
758 if (cmd & PCI_COMMAND_FAST_BACK)
759 printf("fast Back2Back, ");
760 if (status & PCI_STATUS_66MHZ)
762 if (status & PCI_STATUS_UDF)
763 printf("user-definable features, ");
765 ((status & PCI_STATUS_DEVSEL_MASK) == PCI_STATUS_DEVSEL_SLOW) ? "slow" :
766 ((status & PCI_STATUS_DEVSEL_MASK) == PCI_STATUS_DEVSEL_MEDIUM) ? "medium" :
767 ((status & PCI_STATUS_DEVSEL_MASK) == PCI_STATUS_DEVSEL_FAST) ? "fast" : "??");
768 if (cmd & PCI_COMMAND_MASTER)
769 printf(", latency %d", latency);
771 printf(", IRQ " PCIIRQ_FMT, irq);
772 if (p->numa_node != -1)
773 printf(", NUMA node %d", p->numa_node);
777 if (bist & PCI_BIST_CAPABLE)
779 if (bist & PCI_BIST_START)
780 printf("\tBIST is running\n");
782 printf("\tBIST result: %02x\n", bist & PCI_BIST_CODE_MASK);
787 case PCI_HEADER_TYPE_NORMAL:
790 case PCI_HEADER_TYPE_BRIDGE:
793 case PCI_HEADER_TYPE_CARDBUS:
799 /*** Machine-readable dumps ***/
802 show_hex_dump(struct device *d)
806 cnt = d->config_cached;
807 if (opt_hex >= 3 && config_fetch(d, cnt, 256-cnt))
810 if (opt_hex >= 4 && config_fetch(d, 256, 4096-256))
814 for (i=0; i<cnt; i++)
818 printf(" %02x", get_conf_byte(d, i));
825 print_shell_escaped(char *c)
830 if (*c == '"' || *c == '\\')
838 show_machine(struct device *d)
840 struct pci_dev *p = d->dev;
843 char classbuf[128], vendbuf[128], devbuf[128], svbuf[128], sdbuf[128];
845 get_subid(d, &sv_id, &sd_id);
849 pci_fill_info(p, PCI_FILL_PHYS_SLOT | PCI_FILL_NUMA_NODE);
850 printf((opt_machine >= 2) ? "Slot:\t" : "Device:\t");
853 printf("Class:\t%s\n",
854 pci_lookup_name(pacc, classbuf, sizeof(classbuf), PCI_LOOKUP_CLASS, p->device_class));
855 printf("Vendor:\t%s\n",
856 pci_lookup_name(pacc, vendbuf, sizeof(vendbuf), PCI_LOOKUP_VENDOR, p->vendor_id, p->device_id));
857 printf("Device:\t%s\n",
858 pci_lookup_name(pacc, devbuf, sizeof(devbuf), PCI_LOOKUP_DEVICE, p->vendor_id, p->device_id));
859 if (sv_id && sv_id != 0xffff)
861 printf("SVendor:\t%s\n",
862 pci_lookup_name(pacc, svbuf, sizeof(svbuf), PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_VENDOR, sv_id));
863 printf("SDevice:\t%s\n",
864 pci_lookup_name(pacc, sdbuf, sizeof(sdbuf), PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_DEVICE, p->vendor_id, p->device_id, sv_id, sd_id));
867 printf("PhySlot:\t%s\n", p->phy_slot);
868 if (c = get_conf_byte(d, PCI_REVISION_ID))
869 printf("Rev:\t%02x\n", c);
870 if (c = get_conf_byte(d, PCI_CLASS_PROG))
871 printf("ProgIf:\t%02x\n", c);
873 show_kernel_machine(d);
874 if (p->numa_node != -1)
875 printf("NUMANode:\t%d\n", p->numa_node);
880 print_shell_escaped(pci_lookup_name(pacc, classbuf, sizeof(classbuf), PCI_LOOKUP_CLASS, p->device_class));
881 print_shell_escaped(pci_lookup_name(pacc, vendbuf, sizeof(vendbuf), PCI_LOOKUP_VENDOR, p->vendor_id, p->device_id));
882 print_shell_escaped(pci_lookup_name(pacc, devbuf, sizeof(devbuf), PCI_LOOKUP_DEVICE, p->vendor_id, p->device_id));
883 if (c = get_conf_byte(d, PCI_REVISION_ID))
884 printf(" -r%02x", c);
885 if (c = get_conf_byte(d, PCI_CLASS_PROG))
886 printf(" -p%02x", c);
887 if (sv_id && sv_id != 0xffff)
889 print_shell_escaped(pci_lookup_name(pacc, svbuf, sizeof(svbuf), PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_VENDOR, sv_id));
890 print_shell_escaped(pci_lookup_name(pacc, sdbuf, sizeof(sdbuf), PCI_LOOKUP_SUBSYSTEM | PCI_LOOKUP_DEVICE, p->vendor_id, p->device_id, sv_id, sd_id));
893 printf(" \"\" \"\"");
898 /*** Main show function ***/
901 show_device(struct device *d)
911 if (opt_kernel || verbose)
916 if (verbose || opt_hex)
925 for (d=first_dev; d; d=d->next)
932 main(int argc, char **argv)
937 if (argc == 2 && !strcmp(argv[1], "--version"))
939 puts("lspci version " PCIUTILS_VERSION);
945 pci_filter_init(pacc, &filter);
947 while ((i = getopt(argc, argv, options)) != -1)
957 pacc->buscentric = 1;
960 if (msg = pci_filter_parse_slot(&filter, optarg))
964 if (msg = pci_filter_parse_id(&filter, optarg))
974 pci_set_name_list_path(pacc, optarg, 0);
1003 die("DNS queries are not available in this version");
1006 if (parse_generic_option(i, pacc, optarg))
1009 fprintf(stderr, help_msg, pacc->id_file_name);
1017 pacc->id_lookup_mode |= PCI_LOOKUP_NETWORK;
1018 if (opt_query_dns > 1)
1019 pacc->id_lookup_mode |= PCI_LOOKUP_REFRESH_CACHE;
1022 pacc->id_lookup_mode |= PCI_LOOKUP_NETWORK | PCI_LOOKUP_SKIP_LOCAL;
1036 show_kernel_cleanup();
1039 return (seen_errors ? 2 : 0);