diff options
author | Bill Nottingham <notting@redhat.com> | 1999-07-06 01:36:12 +0000 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 1999-07-06 01:36:12 +0000 |
commit | 9f133caa4aaaf6e73de50c7598e84d383de74400 (patch) | |
tree | a910c2c898ba948bf14110f944c91f5802ce5c2d /isys | |
parent | 736c5ea6feaf005d966b74a388f74aa94cc40c14 (diff) | |
download | anaconda-9f133caa4aaaf6e73de50c7598e84d383de74400.tar.gz anaconda-9f133caa4aaaf6e73de50c7598e84d383de74400.tar.xz anaconda-9f133caa4aaaf6e73de50c7598e84d383de74400.zip |
fixes for unknown vendors (now get translated)
Diffstat (limited to 'isys')
-rw-r--r-- | isys/pci/README | 41 | ||||
-rwxr-xr-x | isys/pci/makeids | 6 | ||||
-rw-r--r-- | isys/pci/pciprobe.c | 52 |
3 files changed, 82 insertions, 17 deletions
diff --git a/isys/pci/README b/isys/pci/README new file mode 100644 index 000000000..384e3288c --- /dev/null +++ b/isys/pci/README @@ -0,0 +1,41 @@ + +Requires the pciutils-devel-2.0-2 rpm currently in playpen +(static lib + headers). Probably will get moved into dist-6.1 +soon. + +Use is as follows: +-- +/* pciprobe.h */ + +struct pciDevice { + unsigned int vendor, device, type; + char * driver; + char * desc; +}; + +int probePciReadDrivers(const char *fn); +struct pciDevice **probePci(unsigned int type, int all); +-- + +probePciReadDrivers is same as before. +probePci returns a null-terminated list of pciDevice *. + +'type' is a base class/subclass type (look in /usr/include/pci/header.h +under 'Device classes and subclasses' for constants to use, or you +can hard-code them....). +'all=0' means return only those for which there are drivers +(which means entries where the drivers are *not* 'unknown' or 'ignore'.) +'all=anything else' means return everything. + +Currently, the pcitable is more-or-less the same as before: +0xvendor 0xdevice <driver> "description" + +It's generated from the pci.ids file by the 'makeids' command, +which reads the driver mappings from the *current* pcitable +file in the current directory. Basically, to change a driver, +edit the pcitable and commit; rerunning makeids will simply +merge in any new PCI ids in the pci.ids file, and change +any changed descriptions. + +testprobe currently prints (more-or-less) the results +of probePci(0,1); diff --git a/isys/pci/makeids b/isys/pci/makeids index 12831e41f..8d516be92 100755 --- a/isys/pci/makeids +++ b/isys/pci/makeids @@ -54,7 +54,7 @@ while (<F>) { s/ */ /g; s/^ *//g; s/ *$//g; - if (/^# List of known device classes/) { print "moo\n"; last; } + if (/^# List of known device classes/) { last; } if (/^#.*/) { next }; if (!length($_)) { next }; @@ -78,9 +78,9 @@ while (<F>) { s/([0-9A-Fa-f]+) +//; $classid = $1; if ($classtr{$_}) { - $class = $classtr{$_}; + $class = $classtr{$_}; } else { - $class = $_; + $class = $_; } } } diff --git a/isys/pci/pciprobe.c b/isys/pci/pciprobe.c index d83e06c26..306e8c9cf 100644 --- a/isys/pci/pciprobe.c +++ b/isys/pci/pciprobe.c @@ -28,6 +28,34 @@ static int devCmp(const void * a, const void * b) { return y; } +static int vendCmp(const void * a, const void * b) { + const struct pciDevice * one = a; + const struct pciDevice * two = b; + + return (one->vendor - two->vendor); +} + + +char *getVendor(unsigned int vendor) { + struct pciDevice *searchDev, key; + char *tmpstr; + + key.vendor = vendor; + + searchDev = bsearch(&key,pciDeviceList,numPciDevices, + sizeof(struct pciDevice), vendCmp); + if (searchDev) { + int x; + + x=strchr(searchDev->desc,'|')-searchDev->desc-1; + tmpstr=calloc(x,sizeof(char)); + tmpstr=strncpy(tmpstr,searchDev->desc,x); + return tmpstr; + } else { + return NULL; + } +} + int probePciReadDrivers(const char * fn) { int fd; struct stat sb; @@ -36,6 +64,7 @@ int probePciReadDrivers(const char * fn) { char * start; struct pciDevice * nextDevice; char module[5000]; + char descrip[5000]; fd = open(fn, O_RDONLY); if (fd < 0) return -1; @@ -62,16 +91,11 @@ int probePciReadDrivers(const char * fn) { while (start && *start) { while (isspace(*start)) start++; if (*start != '#' && *start != '\n') { - if (sscanf(start, "%x %x %s", &nextDevice->vendor, - &nextDevice->device, module ) == 3) { - int x; + if (sscanf(start, "%x %x %s \"%[^\"]", &nextDevice->vendor, + &nextDevice->device, module, descrip ) == 4) { numPciDevices++; nextDevice->driver = strdup(module); - x=strchr(start,'\n')-strchr(start,'"')-2; - if (x>0) { - nextDevice->desc = calloc(x,sizeof(char)); - nextDevice->desc = strncpy(nextDevice->desc,strchr(start,'"')+1,x); - } + nextDevice->desc = strdup(descrip); nextDevice++; } } @@ -94,21 +118,21 @@ struct pciDevice * pciGetDeviceInfo(unsigned int vend, unsigned int dev) { searchDev = bsearch(&key,pciDeviceList,numPciDevices, sizeof(struct pciDevice), devCmp); if (!searchDev) { - char *namebuf=calloc(128,sizeof(char *)); + char *namebuf; + searchDev = malloc(sizeof(struct pciDevice)); searchDev->vendor = vend; searchDev->device = dev; searchDev->driver = strdup("unknown"); searchDev->desc = calloc(128, sizeof(char)); - namebuf=pci_lookup_name(pacc,namebuf,128, - PCI_LOOKUP_VENDOR, searchDev->vendor,0); - if ((strtol(namebuf, (char **)NULL, 16)) == searchDev->vendor) { + namebuf = getVendor(vend); + if (!namebuf) { snprintf(searchDev->desc,128, - "Unknown vendor unknown device: %04x:%04x", + "Unknown vendor unknown device %04x:%04x", searchDev->vendor, searchDev->device); } else { snprintf(searchDev->desc,128, - "%s unknown device: %04x:%04x", + "%s unknown device %04x:%04x", namebuf, searchDev->vendor, searchDev->device); } } |