svn commit: r356267 - head/usr.sbin/pciconf
Scott Long
scottl at FreeBSD.org
Thu Jan 2 06:56:29 UTC 2020
Author: scottl
Date: Thu Jan 2 06:56:28 2020
New Revision: 356267
URL: https://svnweb.freebsd.org/changeset/base/356267
Log:
Add a compact columnar output format, available by specifying a second '-l'
command line option. Thanks to the removal of unnecessary information and
the organization into columns, this helps the output be more legible on
both 80 column displays and non-80 column displays. imp@ provided the
idea on this.
Modified:
head/usr.sbin/pciconf/pciconf.8
head/usr.sbin/pciconf/pciconf.c
Modified: head/usr.sbin/pciconf/pciconf.8
==============================================================================
--- head/usr.sbin/pciconf/pciconf.8 Thu Jan 2 04:34:22 2020 (r356266)
+++ head/usr.sbin/pciconf/pciconf.8 Thu Jan 2 06:56:28 2020 (r356267)
@@ -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 at pci0:0:4:0: 010000 01 00 1000 000f 0000 0000
+bar0 at pci0:0:5:0: 000100 00 00 88c1 5333 0000 0000
+none0 at 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,
Modified: head/usr.sbin/pciconf/pciconf.c
==============================================================================
--- head/usr.sbin/pciconf/pciconf.c Thu Jan 2 04:34:22 2020 (r356266)
+++ head/usr.sbin/pciconf/pciconf.c Thu Jan 2 06:56:28 2020 (r356267)
@@ -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
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 at 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 at 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 at 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)
More information about the svn-src-all
mailing list