Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F171682074
D59602.id186493.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
3 KB
Referenced Files
None
Subscribers
None
D59602.id186493.diff
View Options
diff --git a/usr.sbin/pciconf/pciconf.8 b/usr.sbin/pciconf/pciconf.8
--- a/usr.sbin/pciconf/pciconf.8
+++ b/usr.sbin/pciconf/pciconf.8
@@ -31,7 +31,7 @@
.Nd diagnostic utility for the PCI bus
.Sh SYNOPSIS
.Nm
-.Fl l Oo Fl BbceVv Oc Op Ar device
+.Fl l Oo Fl BbceVv Oc Oo Fl C Ar class Oc Op Ar device
.Nm
.Fl t Oo Fl v Oc
.Nm
@@ -227,6 +227,12 @@
cap 10[40] = PCI-Express 1 root port
.Ed
.Pp
+If the
+.Fl C
+option is supplied,
+.Nm
+will list only the devices whose PCI class name matches the given argument.
+.Pp
The first value after the
.Dq Li cap
prefix is the capability ID in hexadecimal.
diff --git a/usr.sbin/pciconf/pciconf.c b/usr.sbin/pciconf/pciconf.c
--- a/usr.sbin/pciconf/pciconf.c
+++ b/usr.sbin/pciconf/pciconf.c
@@ -79,10 +79,11 @@
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 compact);
+ int caps, int errors, int vpd, int compact, const char *class);
static void show_tree(int verbose);
static void list_verbose(struct pci_conf *p);
static void list_vpd(int fd, struct pci_conf *p);
+static int validate_class(const char *class);
static const char *guess_class(struct pci_conf *p);
static const char *guess_subclass(struct pci_conf *p);
static int load_vendors(void);
@@ -103,7 +104,7 @@
{
fprintf(stderr, "%s",
- "usage: pciconf -l [-BbcevV] [device]\n"
+ "usage: pciconf -l [-BbcevV] [-C class] [device]\n"
" pciconf -t [-v]\n"
" pciconf -a device\n"
" pciconf -r [-b | -h] device addr[:addr2]\n"
@@ -122,12 +123,14 @@
enum { NONE, LIST, TREE, READ, WRITE, ATTACHED, DUMPBAR, READBAR,
WRITEBAR } mode;
int compact, bars, bridge, caps, errors, verbose, vpd;
+ const char *class;
mode = NONE;
compact = bars = bridge = caps = errors = verbose = vpd = 0;
width = 4;
+ class = NULL;
- while ((c = getopt(argc, argv, "aBbcDehlRrtWwVvx")) != -1) {
+ while ((c = getopt(argc, argv, "aBbcC:DehlRrtWwVvx")) != -1) {
switch(c) {
case 'a':
mode = ATTACHED;
@@ -146,6 +149,10 @@
caps++;
break;
+ case 'C':
+ class = optarg;
+ break;
+
case 'D':
mode = DUMPBAR;
break;
@@ -206,7 +213,7 @@
if (optind >= argc + 1)
usage();
list_devs(optind + 1 == argc ? argv[optind] : NULL, verbose,
- bars, bridge, caps, errors, vpd, compact);
+ bars, bridge, caps, errors, vpd, compact, class);
break;
case TREE:
if (optind != argc)
@@ -314,16 +321,20 @@
static void
list_devs(const char *name, int verbose, int bars, int bridge, int caps,
- int errors, int vpd, int compact)
+ int errors, int vpd, int compact, const char *class)
{
int fd;
struct pci_conf *conf, *p;
size_t count;
+ const char *pclass;
int none_count = 0;
if (verbose)
load_vendors();
+ if (!validate_class(class))
+ errx(1, "Invalid class name");
+
fd = open(_PATH_DEVPCI, (bridge || caps || errors) ? O_RDWR : O_RDONLY,
0);
if (fd < 0)
@@ -339,6 +350,12 @@
printf("drv\tselector\tclass rev hdr "
"vendor device subven subdev\n");
for (p = conf; p < conf + count; p++) {
+ if (class) {
+ pclass = guess_class(p);
+ if (!pclass || strcmp(pclass, class))
+ continue;
+ }
+
if (compact)
printf("%s%d@pci%d:%d:%d:%d:"
"\t%06x %02x %02x "
@@ -1074,6 +1091,18 @@
{0, 0, NULL}
};
+static int
+validate_class(const char *class)
+{
+ int i;
+
+ for (i = 0; pci_nomatch_tab[i].desc != NULL; i++) {
+ if (!strcmp(class, pci_nomatch_tab[i].desc))
+ return(1);
+ }
+ return(0);
+}
+
static const char *
guess_class(struct pci_conf *p)
{
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Sep 13, 4:12 PM (16 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38822494
Default Alt Text
D59602.id186493.diff (3 KB)
Attached To
Mode
D59602: pciconf: Add -C option to filter by class name
Attached
Detach File
Event Timeline
Log In to Comment