summaryrefslogtreecommitdiff
path: root/sys
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2001-01-27 01:19:12 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2001-01-27 01:19:12 +0000
commit84138674dfeb14cd80dbfc31378f3e5072618c9c (patch)
tree95c38ee1addcb4a5c9169f50357d05d1fe9c94b7 /sys
parent10774b5e033bb15b70f7cdacf2af5d47e0cea611 (diff)
split vendor & product lists into 2 tables, saving 12K
Diffstat (limited to 'sys')
-rw-r--r--sys/dev/pci/devlist2h.awk33
-rw-r--r--sys/dev/pci/pci_subr.c50
2 files changed, 38 insertions, 45 deletions
diff --git a/sys/dev/pci/devlist2h.awk b/sys/dev/pci/devlist2h.awk
index 84693e98be1..58588c55c09 100644
--- a/sys/dev/pci/devlist2h.awk
+++ b/sys/dev/pci/devlist2h.awk
@@ -1,5 +1,5 @@
#! /usr/bin/awk -f
-# $OpenBSD: devlist2h.awk,v 1.5 2001/01/26 22:27:37 mickey Exp $
+# $OpenBSD: devlist2h.awk,v 1.6 2001/01/27 01:19:11 deraadt Exp $
# $NetBSD: devlist2h.awk,v 1.2 1996/01/22 21:08:09 cgd Exp $
#
# Copyright (c) 1995, 1996 Christopher G. Demetriou
@@ -167,28 +167,13 @@ END {
if (nvendor_dup > 0)
exit(1);
- printf("static const struct pci_knowndev pci_knowndevs[] = {\n") > dfile
+ printf("static const struct pci_known_product pci_known_products[] = {\n") \
+ > dfile
for (i = 1; i <= nproducts; i++) {
printf("\t{\n") > dfile
printf("\t PCI_VENDOR_%s, PCI_PRODUCT_%s_%s,\n",
products[i, 1], products[i, 1], products[i, 2]) \
> dfile
- printf("\t ") > dfile
- printf("0") > dfile
- printf(",\n") > dfile
-
- vendi = vendorindex[products[i, 1]];
- printf("\t \"") > dfile
- j = 3;
- needspace = 0;
- while (vendors[vendi, j] != "") {
- if (needspace)
- printf(" ") > dfile
- printf("%s", vendors[vendi, j]) > dfile
- needspace = 1
- j++
- }
- printf("\",\n") > dfile
printf("\t \"") > dfile
j = 4;
@@ -203,11 +188,14 @@ END {
printf("\",\n") > dfile
printf("\t},\n") > dfile
}
+ printf("\t{ 0, 0, NULL, }\n") > dfile
+ printf("};\n\n") > dfile
+
+ printf("static const struct pci_known_vendor pci_known_vendors[] = {\n") \
+ > dfile
for (i = 1; i <= nvendors; i++) {
printf("\t{\n") > dfile
- printf("\t PCI_VENDOR_%s, 0,\n", vendors[i, 1]) \
- > dfile
- printf("\t PCI_KNOWNDEV_NOPROD,\n") \
+ printf("\t PCI_VENDOR_%s,\n", vendors[i, 1]) \
> dfile
printf("\t \"") > dfile
j = 3;
@@ -220,9 +208,8 @@ END {
j++
}
printf("\",\n") > dfile
- printf("\t NULL,\n") > dfile
printf("\t},\n") > dfile
}
- printf("\t{ 0, 0, 0, NULL, NULL, }\n") > dfile
+ printf("\t{ 0, NULL, }\n") > dfile
printf("};\n") > dfile
}
diff --git a/sys/dev/pci/pci_subr.c b/sys/dev/pci/pci_subr.c
index 96fa2babaef..849dd3219a6 100644
--- a/sys/dev/pci/pci_subr.c
+++ b/sys/dev/pci/pci_subr.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: pci_subr.c,v 1.10 2001/01/26 22:27:36 mickey Exp $ */
+/* $OpenBSD: pci_subr.c,v 1.11 2001/01/27 01:19:10 deraadt Exp $ */
/* $NetBSD: pci_subr.c,v 1.19 1996/10/13 01:38:29 christos Exp $ */
/*
@@ -201,13 +201,16 @@ const struct pci_class pci_class[] = {
/*
* Descriptions of of known vendors and devices ("products").
*/
-struct pci_knowndev {
+struct pci_known_vendor {
+ pci_vendor_id_t vendor;
+ const char *vendorname;
+};
+
+struct pci_known_product {
pci_vendor_id_t vendor;
pci_product_id_t product;
- int flags;
- const char *vendorname, *productname;
+ const char *productname;
};
-#define PCI_KNOWNDEV_NOPROD 0x01 /* match on vendor only */
#include <dev/pci/pcidevs_data.h>
#endif /* PCIVERBOSE */
@@ -224,10 +227,11 @@ pci_devinfo(id_reg, class_reg, showclass, cp)
pci_subclass_t subclass;
pci_interface_t interface;
pci_revision_t revision;
- const char *vendor_namep, *product_namep;
+ const char *vendor_namep = NULL, *product_namep = NULL;
const struct pci_class *classp, *subclassp;
#ifdef PCIVERBOSE
- const struct pci_knowndev *kdp;
+ const struct pci_known_vendor *pkv;
+ const struct pci_known_product *pkp;
const char *unmatched = "unknown ";
#else
const char *unmatched = "";
@@ -242,22 +246,24 @@ pci_devinfo(id_reg, class_reg, showclass, cp)
revision = PCI_REVISION(class_reg);
#ifdef PCIVERBOSE
- kdp = pci_knowndevs;
- while (kdp->vendorname != NULL) { /* all have vendor name */
- if (kdp->vendor == vendor && (kdp->product == product ||
- (kdp->flags & PCI_KNOWNDEV_NOPROD) != 0))
- break;
- kdp++;
+ pkv = pci_known_vendors;
+ while (pkv->vendorname != NULL) { /* all have vendor name */
+ if (pkv->vendor == vendor) {
+ vendor_namep = pkv->vendorname;
+ break;
+ }
+ pkv++;
+ }
+ if (vendor_namep) {
+ pkp = pci_known_products;
+ while (pkp->productname != NULL) { /* all have product name */
+ if (pkp->vendor == vendor && pkp->product == product) {
+ product_namep = pkp->productname;
+ break;
+ }
+ pkp++;
+ }
}
- if (kdp->vendorname == NULL)
- vendor_namep = product_namep = NULL;
- else {
- vendor_namep = kdp->vendorname;
- product_namep = (kdp->flags & PCI_KNOWNDEV_NOPROD) == 0 ?
- kdp->productname : NULL;
- }
-#else /* PCIVERBOSE */
- vendor_namep = product_namep = NULL;
#endif /* PCIVERBOSE */
classp = pci_class;