Add support for decoding the PCI vendor and device ID registers. Add a

database of about 1400 vendors and 2700 devices courtesy of
www.yourvote.com/pci.  We still need to add some more, but this is a good
start.
This commit is contained in:
Mike Smith 2000-11-13 12:08:29 +00:00
parent 8965720482
commit d8134896e9
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=68677
3 changed files with 4522 additions and 7 deletions

View File

@ -55,6 +55,11 @@ bar0@pci0:5:0: class=0x000100 card=0x00000000 chip=0x88c15333 rev=0x00 hdr=0x00
none0@pci0:6:0: class=0x020000 card=0x00000000 chip=0x802910ec rev=0x00 hdr=0x00
.Ed
.Pp
If the
.Fl v
option is supplied, vendor and device identification strings are printed for
each device on the following line.
.Pp
The first column gives the
device name, unit number, and
.Ar selector .

View File

@ -43,8 +43,10 @@ static const char rcsid[] =
#include <sys/pciio.h>
#include "pathnames.h"
#include "vendors.h"
static void list_devs(void);
static void list_devs(int vendors);
static void list_vendor(int vendor, int device);
static void readit(const char *, const char *, int);
static void writeit(const char *, const char *, const char *, int);
static void chkattached(const char *, int);
@ -55,7 +57,7 @@ static void
usage()
{
fprintf(stderr, "%s\n%s\n%s\n%s\n",
"usage: pciconf -l",
"usage: pciconf -l [-v]",
" pciconf -a sel",
" pciconf -r [-b | -h] sel addr",
" pciconf -w [-b | -h] sel addr [value]");
@ -66,12 +68,12 @@ int
main(int argc, char **argv)
{
int c;
int listmode, readmode, writemode, attachedmode;
int listmode, readmode, writemode, attachedmode, vendors;
int byte, isshort;
listmode = readmode = writemode = attachedmode = byte = isshort = 0;
listmode = readmode = writemode = attachedmode = vendors = byte = isshort = 0;
while ((c = getopt(argc, argv, "alrwbh")) != -1) {
while ((c = getopt(argc, argv, "alrwbhv")) != -1) {
switch(c) {
case 'a':
attachedmode = 1;
@ -97,6 +99,10 @@ main(int argc, char **argv)
isshort = 1;
break;
case 'v':
vendors = 1;
break;
default:
usage();
}
@ -109,7 +115,7 @@ main(int argc, char **argv)
usage();
if (listmode) {
list_devs();
list_devs(vendors);
} else if(attachedmode) {
chkattached(argv[optind],
byte ? 1 : isshort ? 2 : 4);
@ -127,7 +133,7 @@ main(int argc, char **argv)
}
static void
list_devs(void)
list_devs(int vendors)
{
int fd;
struct pci_conf_io pc;
@ -179,12 +185,38 @@ list_devs(void)
(p->pc_subdevice << 16) | p->pc_subvendor,
(p->pc_device << 16) | p->pc_vendor,
p->pc_revid, p->pc_hdr);
if (vendors)
list_vendor(p->pc_vendor, p->pc_device);
}
} while (pc.status == PCI_GETCONF_MORE_DEVS);
close(fd);
}
static void
list_vendor(int vendor, int device)
{
struct pci_vendor_information *pv;
struct pci_device_information *pd;
for (pv = pci_vendor_information; pv->desc != NULL; pv++)
if (pv->id == vendor)
break;
if (pv->desc != NULL) {
printf(" <%s>,", pv->desc);
} else {
printf(" <unknown vendor 0x%04x>,", vendor);
}
for (pd = pv->devices; (pd != NULL) && (pd->desc != NULL); pd++)
if (pd->id == device)
break;
if ((pd != NULL) && (pd->desc != NULL)) {
printf("<%s>\n", pd->desc);
} else {
printf("<unknown device 0x%04x>\n", device);
}
}
static struct pcisel
getsel(const char *str)
{

4478
usr.sbin/pciconf/vendors.h Normal file

File diff suppressed because it is too large Load Diff