aboutsummaryrefslogtreecommitdiff
path: root/usr.sbin/ndiscvt
diff options
context:
space:
mode:
authorBill Paul <wpaul@FreeBSD.org>2003-12-18 03:51:21 +0000
committerBill Paul <wpaul@FreeBSD.org>2003-12-18 03:51:21 +0000
commita22ec80eced588e8f57c74312fe233a5e703d21c (patch)
tree5ee952471a833e8a8748d227d48d1f385c5adb16 /usr.sbin/ndiscvt
parent1e4925e8d398c943cac862ec5c1d0b000c161567 (diff)
downloadsrc-a22ec80eced588e8f57c74312fe233a5e703d21c.tar.gz
src-a22ec80eced588e8f57c74312fe233a5e703d21c.zip
Deal with the duplicate sysctl leaf problem. A .inf file may contain
definitions for more than one device (usually differentiated by the PCI subvendor/subdevice ID). Each device also has its own tree of registry keys. In some cases, each device has the same keys, but sometimes each device has a unique tree but with overlap. Originally, I just had ndiscvt(8) dump out all the keys it could find, and we would try to apply them to every device we could find. Now, each key has an index number that matches it to a device in the device ID list. This lets us create just the keys that apply to a particular device. I also added an extra field to the device list to hold the subvendor and subdevice ID. Some devices are generic, i.e. there is no subsystem definition. If we have a device that doesn't match a specific subsystem value and we have a generic entry, we use the generic entry.
Notes
Notes: svn path=/head/; revision=123620
Diffstat (limited to 'usr.sbin/ndiscvt')
-rw-r--r--usr.sbin/ndiscvt/Makefile2
-rw-r--r--usr.sbin/ndiscvt/inf.c58
2 files changed, 27 insertions, 33 deletions
diff --git a/usr.sbin/ndiscvt/Makefile b/usr.sbin/ndiscvt/Makefile
index f5c7f13913b3..c8aa86f047b3 100644
--- a/usr.sbin/ndiscvt/Makefile
+++ b/usr.sbin/ndiscvt/Makefile
@@ -16,7 +16,7 @@ LDADD= -ll
YFLAGS+=-v
-CFLAGS+=-I. -I${.CURDIR} -I${.CURDIR}/../../sys
+CFLAGS+=-g -I. -I${.CURDIR} -I${.CURDIR}/../../sys
CLEANFILES= y.output
diff --git a/usr.sbin/ndiscvt/inf.c b/usr.sbin/ndiscvt/inf.c
index 46f11464496e..30bc2565cdf7 100644
--- a/usr.sbin/ndiscvt/inf.c
+++ b/usr.sbin/ndiscvt/inf.c
@@ -32,7 +32,8 @@ static struct section
static void dump_deviceids (void);
static void dump_pci_id (const char *);
static void dump_regvals (void);
-static void dump_paramreg (const struct section *, const struct reg *);
+static void dump_paramreg (const struct section *,
+ const struct reg *, int);
static FILE *ofp;
@@ -119,7 +120,7 @@ static void
dump_pci_id(const char *s)
{
char *p;
- char vidstr[7], didstr[7];
+ char vidstr[7], didstr[7], subsysstr[14];
p = strcasestr(s, "VEN_");
if (p == NULL)
@@ -135,8 +136,16 @@ dump_pci_id(const char *s)
strncat(didstr, p, 4);
if (p == NULL)
return;
+ p = strcasestr(s, "SUBSYS_");
+ if (p == NULL)
+ strcpy(subsysstr, "0x00000000");
+ else {
+ p += 7;
+ strcpy(subsysstr, "0x");
+ strncat(subsysstr, p, 8);
+ }
- fprintf(ofp, "\t\\\n\t{ %s, %s,", vidstr, didstr);
+ fprintf(ofp, "\t\\\n\t{ %s, %s, %s, ", vidstr, didstr, subsysstr);
return;
}
@@ -193,7 +202,7 @@ dump_deviceids()
}
static void
-dump_addreg(const char *s)
+dump_addreg(const char *s, int devidx)
{
struct section *sec;
struct reg *reg;
@@ -213,13 +222,13 @@ dump_addreg(const char *s)
if (reg->subkey == NULL) {
fprintf(ofp, "\n\t{ \"%s\",", reg->key);
fprintf(ofp,"\n\t\"%s \",", reg->key);
- fprintf(ofp, "\n\t{ \"%s\" } },",
+ fprintf(ofp, "\n\t{ \"%s\" }, %d },",
reg->value == NULL ? "" :
- stringcvt(reg->value));
+ stringcvt(reg->value), devidx);
} else if (strcasestr(reg->subkey,
"Ndi\\params") != NULL &&
strcasecmp(reg->key, "ParamDesc") == 0)
- dump_paramreg(sec, reg);
+ dump_paramreg(sec, reg, devidx);
}
}
@@ -283,7 +292,7 @@ dump_dwordreg(const struct section *s, const struct reg *r)
}
static void
-dump_defaultinfo(const struct section *s, const struct reg *r)
+dump_defaultinfo(const struct section *s, const struct reg *r, int devidx)
{
struct reg *reg;
TAILQ_FOREACH(reg, &rh, link) {
@@ -293,8 +302,8 @@ dump_defaultinfo(const struct section *s, const struct reg *r)
continue;
if (strcasecmp(reg->key, "Default"))
continue;
- fprintf(ofp, "\n\t{ \"%s\" } },", reg->value == NULL ? "" :
- reg->value);
+ fprintf(ofp, "\n\t{ \"%s\" }, %d },", reg->value == NULL ? "" :
+ reg->value, devidx);
break;
}
return;
@@ -340,7 +349,7 @@ dump_typeinfo(const struct section *s, const struct reg *r)
}
static void
-dump_paramreg(const struct section *s, const struct reg *r)
+dump_paramreg(const struct section *s, const struct reg *r, int devidx)
{
const char *keyname;
@@ -349,7 +358,7 @@ dump_paramreg(const struct section *s, const struct reg *r)
dump_paramdesc(s, r);
dump_typeinfo(s, r);
fprintf(ofp, "\",");
- dump_defaultinfo(s, r);
+ dump_defaultinfo(s, r, devidx);
return;
}
@@ -357,14 +366,11 @@ dump_paramreg(const struct section *s, const struct reg *r)
static void
dump_regvals(void)
{
- struct assign *manf, *dev, *dev_dup;
+ struct assign *manf, *dev;
struct section *sec;
struct assign *assign;
- struct assign_head tmp_ah;
char sname[256];
- int i, is_winxp = 0;
-
- TAILQ_INIT(&tmp_ah);
+ int i, is_winxp = 0, devidx = 0;
/* Find manufacturer name */
manf = find_assign("Manufacturer", NULL);
@@ -385,19 +391,6 @@ dump_regvals(void)
fprintf (ofp, "ndis_cfg ndis_regvals[] = {");
TAILQ_FOREACH(assign, &ah, link) {
- /* Avoid repeating the same section. */
- i = 0;
- TAILQ_FOREACH(dev_dup, &tmp_ah, link)
- if (strcmp(dev_dup->vals[0], assign->vals[0]) == 0) {
- i++;
- break;
- }
- if (i)
- continue;
- dev_dup = malloc(sizeof(struct assign));
- bcopy((char *)assign, (char *)dev_dup,
- sizeof(struct assign));
- TAILQ_INSERT_TAIL(&tmp_ah, dev_dup, link);
if (assign->section == sec) {
/*
* Find all the AddReg sections.
@@ -419,12 +412,13 @@ dump_regvals(void)
continue;
for (i = 0; i < W_MAX; i++) {
if (dev->vals[i] != NULL)
- dump_addreg(dev->vals[i]);
+ dump_addreg(dev->vals[i], devidx);
}
+ devidx++;
}
}
- fprintf(ofp, "\n\t{ NULL, NULL, { 0 } }\n};\n\n");
+ fprintf(ofp, "\n\t{ NULL, NULL, { 0 }, 0 }\n};\n\n");
return;
}