diff --git a/usr.sbin/pciconf/pciconf.8 b/usr.sbin/pciconf/pciconf.8 index 233240acb0a8..24dccb1aa321 100644 --- a/usr.sbin/pciconf/pciconf.8 +++ b/usr.sbin/pciconf/pciconf.8 @@ -110,6 +110,19 @@ in revision 2.1 of the standard. Note that they will be 0 for older cards. .Pp +Adding a second +.Fl l +option causes output to be in a compact columnar format, suitable for +80 column output: +.Bd -literal +drv selector class rev hdr vendor device subven subdev +foo0@pci0:0:4:0: 010000 01 00 1000 000f 0000 0000 +bar0@pci0:0:5:0: 000100 00 00 88c1 5333 0000 0000 +none0@pci0:0:6:0: 020000 00 00 10ec 8029 0000 0000 +.Ed +.Pp +All fields retain the same definition as with the non-compact form. +.Pp If the .Fl B option is supplied, diff --git a/usr.sbin/pciconf/pciconf.c b/usr.sbin/pciconf/pciconf.c index e7f2df765fc1..3c5c507797de 100644 --- a/usr.sbin/pciconf/pciconf.c +++ b/usr.sbin/pciconf/pciconf.c @@ -76,7 +76,7 @@ static struct pcisel getsel(const char *str); static void list_bridge(int fd, struct pci_conf *p); static void list_bars(int fd, struct pci_conf *p); static void list_devs(const char *name, int verbose, int bars, int bridge, - int caps, int errors, int vpd); + int caps, int errors, int vpd, int listmode); static void list_verbose(struct pci_conf *p); static void list_vpd(int fd, struct pci_conf *p); static const char *guess_class(struct pci_conf *p); @@ -147,7 +147,7 @@ main(int argc, char **argv) break; case 'l': - listmode = 1; + listmode++; break; case 'r': @@ -185,7 +185,7 @@ main(int argc, char **argv) if (listmode) { list_devs(optind + 1 == argc ? argv[optind] : NULL, verbose, - bars, bridge, caps, errors, vpd); + bars, bridge, caps, errors, vpd, listmode); } else if (attachedmode) { chkattached(argv[optind]); } else if (readmode) { @@ -207,7 +207,7 @@ main(int argc, char **argv) static void list_devs(const char *name, int verbose, int bars, int bridge, int caps, - int errors, int vpd) + int errors, int vpd, int listmode) { int fd; struct pci_conf_io pc; @@ -260,21 +260,36 @@ list_devs(const char *name, int verbose, int bars, int bridge, int caps, close(fd); return; } + if (listmode == 2) + printf("drv\tselector\tclass rev hdr vendor device " + "subven subdev\n"); for (p = conf; p < &conf[pc.num_matches]; p++) { - printf("%s%d@pci%d:%d:%d:%d:" - "\tclass=0x%06x rev=0x%02x hdr=0x%02x " - "vendor=0x%04x device=0x%04x " - "subvendor=0x%04x subdevice=0x%04x\n", - *p->pd_name ? p->pd_name : - "none", - *p->pd_name ? (int)p->pd_unit : - none_count++, p->pc_sel.pc_domain, - p->pc_sel.pc_bus, p->pc_sel.pc_dev, - p->pc_sel.pc_func, (p->pc_class << 16) | - (p->pc_subclass << 8) | p->pc_progif, - p->pc_revid, p->pc_hdr, - p->pc_vendor, p->pc_device, - p->pc_subvendor, p->pc_subdevice); + if (listmode == 2) + printf("%s%d@pci%d:%d:%d:%d:" + "\t%06x %02x %02x %04x %04x %04x %04x\n", + *p->pd_name ? p->pd_name : "none", + *p->pd_name ? (int)p->pd_unit : + none_count++, p->pc_sel.pc_domain, + p->pc_sel.pc_bus, p->pc_sel.pc_dev, + p->pc_sel.pc_func, (p->pc_class << 16) | + (p->pc_subclass << 8) | p->pc_progif, + p->pc_revid, p->pc_hdr, + p->pc_vendor, p->pc_device, + p->pc_subvendor, p->pc_subdevice); + else + printf("%s%d@pci%d:%d:%d:%d:" + "\tclass=0x%06x rev=0x%02x hdr=0x%02x " + "vendor=0x%04x device=0x%04x " + "subvendor=0x%04x subdevice=0x%04x\n", + *p->pd_name ? p->pd_name : "none", + *p->pd_name ? (int)p->pd_unit : + none_count++, p->pc_sel.pc_domain, + p->pc_sel.pc_bus, p->pc_sel.pc_dev, + p->pc_sel.pc_func, (p->pc_class << 16) | + (p->pc_subclass << 8) | p->pc_progif, + p->pc_revid, p->pc_hdr, + p->pc_vendor, p->pc_device, + p->pc_subvendor, p->pc_subdevice); if (verbose) list_verbose(p); if (bars)