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.
This commit is contained in:
parent
475008d6ca
commit
eb51967b50
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=356267
@ -110,6 +110,19 @@ in revision 2.1 of the
|
|||||||
standard.
|
standard.
|
||||||
Note that they will be 0 for older cards.
|
Note that they will be 0 for older cards.
|
||||||
.Pp
|
.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
|
If the
|
||||||
.Fl B
|
.Fl B
|
||||||
option is supplied,
|
option is supplied,
|
||||||
|
@ -76,7 +76,7 @@ static struct pcisel getsel(const char *str);
|
|||||||
static void list_bridge(int fd, struct pci_conf *p);
|
static void list_bridge(int fd, struct pci_conf *p);
|
||||||
static void list_bars(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,
|
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_verbose(struct pci_conf *p);
|
||||||
static void list_vpd(int fd, struct pci_conf *p);
|
static void list_vpd(int fd, struct pci_conf *p);
|
||||||
static const char *guess_class(struct pci_conf *p);
|
static const char *guess_class(struct pci_conf *p);
|
||||||
@ -147,7 +147,7 @@ main(int argc, char **argv)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case 'l':
|
case 'l':
|
||||||
listmode = 1;
|
listmode++;
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 'r':
|
case 'r':
|
||||||
@ -185,7 +185,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
if (listmode) {
|
if (listmode) {
|
||||||
list_devs(optind + 1 == argc ? argv[optind] : NULL, verbose,
|
list_devs(optind + 1 == argc ? argv[optind] : NULL, verbose,
|
||||||
bars, bridge, caps, errors, vpd);
|
bars, bridge, caps, errors, vpd, listmode);
|
||||||
} else if (attachedmode) {
|
} else if (attachedmode) {
|
||||||
chkattached(argv[optind]);
|
chkattached(argv[optind]);
|
||||||
} else if (readmode) {
|
} else if (readmode) {
|
||||||
@ -207,7 +207,7 @@ main(int argc, char **argv)
|
|||||||
|
|
||||||
static void
|
static void
|
||||||
list_devs(const char *name, int verbose, int bars, int bridge, int caps,
|
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;
|
int fd;
|
||||||
struct pci_conf_io pc;
|
struct pci_conf_io pc;
|
||||||
@ -260,13 +260,28 @@ list_devs(const char *name, int verbose, int bars, int bridge, int caps,
|
|||||||
close(fd);
|
close(fd);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
if (listmode == 2)
|
||||||
|
printf("drv\tselector\tclass rev hdr vendor device "
|
||||||
|
"subven subdev\n");
|
||||||
for (p = conf; p < &conf[pc.num_matches]; p++) {
|
for (p = conf; p < &conf[pc.num_matches]; p++) {
|
||||||
|
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:"
|
printf("%s%d@pci%d:%d:%d:%d:"
|
||||||
"\tclass=0x%06x rev=0x%02x hdr=0x%02x "
|
"\tclass=0x%06x rev=0x%02x hdr=0x%02x "
|
||||||
"vendor=0x%04x device=0x%04x "
|
"vendor=0x%04x device=0x%04x "
|
||||||
"subvendor=0x%04x subdevice=0x%04x\n",
|
"subvendor=0x%04x subdevice=0x%04x\n",
|
||||||
*p->pd_name ? p->pd_name :
|
*p->pd_name ? p->pd_name : "none",
|
||||||
"none",
|
|
||||||
*p->pd_name ? (int)p->pd_unit :
|
*p->pd_name ? (int)p->pd_unit :
|
||||||
none_count++, p->pc_sel.pc_domain,
|
none_count++, p->pc_sel.pc_domain,
|
||||||
p->pc_sel.pc_bus, p->pc_sel.pc_dev,
|
p->pc_sel.pc_bus, p->pc_sel.pc_dev,
|
||||||
|
Loading…
Reference in New Issue
Block a user