summaryrefslogtreecommitdiffstats
path: root/usr.sbin/ndiscvt
diff options
context:
space:
mode:
authorweongyo <weongyo@FreeBSD.org>2008-12-27 08:03:32 +0000
committerweongyo <weongyo@FreeBSD.org>2008-12-27 08:03:32 +0000
commit0f8825b3f7e9bfd96fc59b8c4404742798efbb5a (patch)
treedc3b2fd3e52b250688d8fdeaf2b7a3c6352c07a2 /usr.sbin/ndiscvt
parenta83406ae2e355dade6f31bbd0874fbf4d7100323 (diff)
downloadFreeBSD-src-0f8825b3f7e9bfd96fc59b8c4404742798efbb5a.zip
FreeBSD-src-0f8825b3f7e9bfd96fc59b8c4404742798efbb5a.tar.gz
Integrate the NDIS USB support code to CURRENT.
Now the NDISulator supports NDIS USB drivers that it've tested with devices as follows: - Anygate XM-142 (Conexant) - Netgear WG111v2 (Realtek) - U-Khan UW-2054u (Marvell) - Shuttle XPC Accessory PN20 (Realtek) - ipTIME G054U2 (Ralink) - UNiCORN WL-54G (ZyDAS) - ZyXEL G-200v2 (ZyDAS) All of them succeeded to attach and worked though there are still some problems that it's expected to be solved. To use NDIS USB support, you should rebuild and install ndiscvt(8) and if you encounter a problem to attach please set `hw.ndisusb.halt' to 0 then retry. I expect no changes of the NDIS code for PCI, PCMCIA devices. Obtained from: //depot/projects/ndisusb/...
Diffstat (limited to 'usr.sbin/ndiscvt')
-rw-r--r--usr.sbin/ndiscvt/inf.c120
-rw-r--r--usr.sbin/ndiscvt/windrv_stub.c19
2 files changed, 139 insertions, 0 deletions
diff --git a/usr.sbin/ndiscvt/inf.c b/usr.sbin/ndiscvt/inf.c
index 05f863d..fe4db6a 100644
--- a/usr.sbin/ndiscvt/inf.c
+++ b/usr.sbin/ndiscvt/inf.c
@@ -62,8 +62,10 @@ static struct section
*find_section (const char *);
static void dump_deviceids_pci (void);
static void dump_deviceids_pcmcia (void);
+static void dump_deviceids_usb (void);
static void dump_pci_id (const char *);
static void dump_pcmcia_id (const char *);
+static void dump_usb_id (const char *);
static void dump_regvals (void);
static void dump_paramreg (const struct section *,
const struct reg *, int);
@@ -83,6 +85,7 @@ inf_parse (FILE *fp, FILE *outfp)
dump_deviceids_pci();
dump_deviceids_pcmcia();
+ dump_deviceids_usb();
fprintf(outfp, "#ifdef NDIS_REGVALS\n");
dump_regvals();
fprintf(outfp, "#endif /* NDIS_REGVALS */\n");
@@ -252,6 +255,30 @@ dump_pci_id(const char *s)
}
static void
+dump_usb_id(const char *s)
+{
+ char *p;
+ char vidstr[7], pidstr[7];
+
+ p = strcasestr(s, "VID_");
+ if (p == NULL)
+ return;
+ p += 4;
+ strcpy(vidstr, "0x");
+ strncat(vidstr, p, 4);
+ p = strcasestr(s, "PID_");
+ if (p == NULL)
+ return;
+ p += 4;
+ strcpy(pidstr, "0x");
+ strncat(pidstr, p, 4);
+ if (p == NULL)
+ return;
+
+ fprintf(ofp, "\t\\\n\t{ %s, %s, ", vidstr, pidstr);
+}
+
+static void
dump_deviceids_pci()
{
struct assign *manf, *dev;
@@ -438,6 +465,99 @@ done:
}
static void
+dump_deviceids_usb()
+{
+ struct assign *manf, *dev;
+ struct section *sec;
+ struct assign *assign;
+ char xpsec[256];
+ int first = 1, found = 0;
+
+ /* Find manufacturer name */
+ manf = find_assign("Manufacturer", NULL);
+
+nextmanf:
+
+ /* Find manufacturer section */
+ if (manf->vals[1] != NULL &&
+ (strcasecmp(manf->vals[1], "NT.5.1") == 0 ||
+ strcasecmp(manf->vals[1], "NTx86") == 0 ||
+ strcasecmp(manf->vals[1], "NTx86.5.1") == 0 ||
+ strcasecmp(manf->vals[1], "NTamd64") == 0)) {
+ /* Handle Windows XP INF files. */
+ snprintf(xpsec, sizeof(xpsec), "%s.%s",
+ manf->vals[0], manf->vals[1]);
+ sec = find_section(xpsec);
+ } else
+ sec = find_section(manf->vals[0]);
+
+ /* See if there are any USB device definitions. */
+
+ TAILQ_FOREACH(assign, &ah, link) {
+ if (assign->section == sec) {
+ dev = find_assign("strings", assign->key);
+ if (strcasestr(assign->vals[1], "USB") != NULL) {
+ found++;
+ break;
+ }
+ }
+ }
+
+ if (found == 0)
+ goto done;
+
+ found = 0;
+
+ if (first == 1) {
+ /* Emit start of USB device table */
+ fprintf (ofp, "#define NDIS_USB_DEV_TABLE");
+ first = 0;
+ }
+
+retry:
+
+ /*
+ * Now run through all the device names listed
+ * in the manufacturer section and dump out the
+ * device descriptions and vendor/device IDs.
+ */
+
+ TAILQ_FOREACH(assign, &ah, link) {
+ if (assign->section == sec) {
+ dev = find_assign("strings", assign->key);
+ /* Emit device IDs. */
+ if (strcasestr(assign->vals[1], "USB") != NULL)
+ dump_usb_id(assign->vals[1]);
+ else
+ continue;
+ /* Emit device description */
+ fprintf (ofp, "\t\\\n\t\"%s\" },", dev->vals[0]);
+ found++;
+ }
+ }
+
+ /* Someone tried to fool us. Shame on them. */
+ if (!found) {
+ found++;
+ sec = find_section(manf->vals[0]);
+ goto retry;
+ }
+
+ /* Handle Manufacturer sections with multiple entries. */
+ manf = find_next_assign(manf);
+
+ if (manf != NULL)
+ goto nextmanf;
+
+done:
+ /* Emit end of table */
+
+ fprintf(ofp, "\n\n");
+
+ return;
+}
+
+static void
dump_addreg(const char *s, int devidx)
{
struct section *sec;
diff --git a/usr.sbin/ndiscvt/windrv_stub.c b/usr.sbin/ndiscvt/windrv_stub.c
index 30e74bf..46a0e83 100644
--- a/usr.sbin/ndiscvt/windrv_stub.c
+++ b/usr.sbin/ndiscvt/windrv_stub.c
@@ -69,6 +69,11 @@ struct ndis_pccard_type {
char *ndis_name;
};
+struct ndis_usb_type {
+ uint16_t ndis_vid;
+ uint16_t ndis_did;
+ char *ndis_name;
+};
#ifdef NDIS_PCI_DEV_TABLE
static struct ndis_pci_type ndis_devs_pci[] = {
@@ -84,6 +89,13 @@ static struct ndis_pccard_type ndis_devs_pccard[] = {
};
#endif
+#ifdef NDIS_USB_DEV_TABLE
+static struct ndis_usb_type ndis_devs_usb[] = {
+ NDIS_USB_DEV_TABLE
+ { 0, 0, NULL }
+};
+#endif
+
enum interface_type {
InterfaceTypeUndefined = -1,
Internal,
@@ -224,6 +236,10 @@ windrv_modevent(mod, cmd, arg)
windrv_load(mod, drv_data_start, drv_data_len, PCMCIABus,
ndis_devs_pccard, &ndis_regvals);
#endif
+#ifdef NDIS_USB_DEV_TABLE
+ windrv_load(mod, drv_data_start, drv_data_len, PNPBus,
+ ndis_devs_usb, &ndis_regvals);
+#endif
break;
case MOD_UNLOAD:
windrv_loaded--;
@@ -235,6 +251,9 @@ windrv_modevent(mod, cmd, arg)
#ifdef NDIS_PCMCIA_DEV_TABLE
windrv_unload(mod, drv_data_start, drv_data_len);
#endif
+#ifdef NDIS_USB_DEV_TABLE
+ windrv_unload(mod, drv_data_start, drv_data_len);
+#endif
break;
case MOD_SHUTDOWN:
break;
OpenPOWER on IntegriCloud