summaryrefslogtreecommitdiffstats
path: root/sys/dev
diff options
context:
space:
mode:
authorwpaul <wpaul@FreeBSD.org>2005-04-24 20:21:22 +0000
committerwpaul <wpaul@FreeBSD.org>2005-04-24 20:21:22 +0000
commitb493dd59e2b39c6ee3f3016ffe21c427b8038eb8 (patch)
treeba1d66e7b03425d40e2969f60b5568a405137f90 /sys/dev
parente669069b43c7e2eed5fff4775fd3c6c18283165d (diff)
downloadFreeBSD-src-b493dd59e2b39c6ee3f3016ffe21c427b8038eb8.zip
FreeBSD-src-b493dd59e2b39c6ee3f3016ffe21c427b8038eb8.tar.gz
Throw the switch on the new driver generation/loading mechanism. From
here on in, if_ndis.ko will be pre-built as a module, and can be built into a static kernel (though it's not part of GENERIC). Drivers are created using the new ndisgen(8) script, which uses ndiscvt(8) under the covers, along with a few other tools. The result is a driver module that can be kldloaded into the kernel. A driver with foo.inf and foo.sys files will be converted into foo_sys.ko (and foo_sys.o, for those who want/need to make static kernels). This module contains all of the necessary info from the .INF file and the driver binary image, converted into an ELF module. You can kldload this module (or add it to /boot/loader.conf) to have it loaded automatically. Any required firmware files can be bundled into the module as well (or converted/loaded separately). Also, add a workaround for a problem in NdisMSleep(). During system bootstrap (cold == 1), msleep() always returns 0 without actually sleeping. The Intel 2200BG driver uses NdisMSleep() to wait for the NIC's firmware to come to life, and fails to load if NdisMSleep() doesn't actually delay. As a workaround, if msleep() (and hence ndis_thsuspend()) returns 0, use a hard DELAY() to sleep instead). This is not really the right thing to do, but we can't really do much else. At the very least, this makes the Intel driver happy. There are probably other drivers that fail in this way during bootstrap. Unfortunately, the only workaround for those is to avoid pre-loading them and kldload them once the system is running instead.
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/if_ndis/if_ndis.c30
-rw-r--r--sys/dev/if_ndis/if_ndis_pccard.c91
-rw-r--r--sys/dev/if_ndis/if_ndis_pci.c90
-rw-r--r--sys/dev/if_ndis/if_ndis_usb.c29
-rw-r--r--sys/dev/if_ndis/if_ndisvar.h1
5 files changed, 92 insertions, 149 deletions
diff --git a/sys/dev/if_ndis/if_ndis.c b/sys/dev/if_ndis/if_ndis.c
index aa0f5c2..cb9e38c 100644
--- a/sys/dev/if_ndis/if_ndis.c
+++ b/sys/dev/if_ndis/if_ndis.c
@@ -76,17 +76,18 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcivar.h>
#include <compat/ndis/pe_var.h>
+#include <compat/ndis/cfg_var.h>
#include <compat/ndis/resource_var.h>
#include <compat/ndis/ntoskrnl_var.h>
#include <compat/ndis/hal_var.h>
#include <compat/ndis/ndis_var.h>
-#include <compat/ndis/cfg_var.h>
#include <dev/if_ndis/if_ndisvar.h>
-#define NDIS_IMAGE
-#define NDIS_REGVALS
+MODULE_DEPEND(ndis, ether, 1, 1, 1);
+MODULE_DEPEND(ndis, wlan, 1, 1, 1);
+MODULE_DEPEND(ndis, ndisapi, 1, 1, 1);
-#include "ndis_driver_data.h"
+MODULE_VERSION(ndis, 1);
int ndis_attach (device_t);
int ndis_detach (device_t);
@@ -158,8 +159,6 @@ ndisdrv_modevent(mod, cmd, arg)
ndisdrv_loaded++;
if (ndisdrv_loaded > 1)
break;
- if (windrv_load(mod, (vm_offset_t)drv_data, 0))
- return(EINVAL);
windrv_wrap((funcptr)ndis_rxeof, &ndis_rxeof_wrap,
3, WINDRV_WRAP_STDCALL);
windrv_wrap((funcptr)ndis_txeof, &ndis_txeof_wrap,
@@ -173,7 +172,6 @@ ndisdrv_modevent(mod, cmd, arg)
ndisdrv_loaded--;
if (ndisdrv_loaded > 0)
break;
- windrv_unload(mod, (vm_offset_t)drv_data, 0);
windrv_unwrap(ndis_rxeof_wrap);
windrv_unwrap(ndis_txeof_wrap);
windrv_unwrap(ndis_linksts_wrap);
@@ -432,11 +430,9 @@ ndis_attach(dev)
{
u_char eaddr[ETHER_ADDR_LEN];
struct ndis_softc *sc;
- driver_object *drv;
driver_object *pdrv;
device_object *pdo;
struct ifnet *ifp = NULL;
- void *img;
int error = 0, len;
int i;
@@ -472,12 +468,10 @@ ndis_attach(dev)
}
}
- sc->ndis_regvals = ndis_regvals;
-
#if __FreeBSD_version < 502113
sysctl_ctx_init(&sc->ndis_ctx);
-
#endif
+
/* Create sysctl registry nodes */
ndis_create_sysctls(sc);
@@ -497,17 +491,7 @@ ndis_attach(dev)
* for this device instance.
*/
- img = drv_data;
-
- drv = windrv_lookup((vm_offset_t)img, NULL);
-
- if (drv == NULL) {
- device_printf(dev, "failed to find driver_object!\n");
- error = ENXIO;
- goto fail;
- }
-
- if (NdisAddDevice(drv, pdo) != STATUS_SUCCESS) {
+ if (NdisAddDevice(sc->ndis_dobj, pdo) != STATUS_SUCCESS) {
device_printf(dev, "failed to create FDO!\n");
error = ENXIO;
goto fail;
diff --git a/sys/dev/if_ndis/if_ndis_pccard.c b/sys/dev/if_ndis/if_ndis_pccard.c
index 918e89c..c67941a 100644
--- a/sys/dev/if_ndis/if_ndis_pccard.c
+++ b/sys/dev/if_ndis/if_ndis_pccard.c
@@ -54,39 +54,22 @@ __FBSDID("$FreeBSD$");
#include <net80211/ieee80211_var.h>
#include <compat/ndis/pe_var.h>
+#include <compat/ndis/cfg_var.h>
#include <compat/ndis/resource_var.h>
#include <compat/ndis/ntoskrnl_var.h>
#include <compat/ndis/ndis_var.h>
-#include <compat/ndis/cfg_var.h>
#include <dev/if_ndis/if_ndisvar.h>
#include <dev/pccard/pccardvar.h>
#include "card_if.h"
-#include "ndis_driver_data.h"
-
-#ifdef NDIS_PCMCIA_DEV_TABLE
-
MODULE_DEPEND(ndis, pccard, 1, 1, 1);
-MODULE_DEPEND(ndis, ether, 1, 1, 1);
-MODULE_DEPEND(ndis, wlan, 1, 1, 1);
-MODULE_DEPEND(ndis, ndisapi, 1, 1, 1);
-
-/*
- * Various supported device vendors/types and their names.
- * These are defined in the ndis_driver_data.h file.
- */
-static struct ndis_pccard_type ndis_devs[] = {
-#ifdef NDIS_PCMCIA_DEV_TABLE
- NDIS_PCMCIA_DEV_TABLE
-#endif
- { NULL, NULL, NULL }
-};
static int ndis_probe_pccard (device_t);
static int ndis_attach_pccard (device_t);
static struct resource_list *ndis_get_resource_list
(device_t, device_t);
+static int ndis_devcompare (struct ndis_pccard_type *, device_t);
extern int ndisdrv_modevent (module_t, int, void *);
extern int ndis_attach (device_t);
extern int ndis_shutdown (device_t);
@@ -118,63 +101,65 @@ static device_method_t ndis_methods[] = {
};
static driver_t ndis_driver = {
-#ifdef NDIS_DEVNAME
- NDIS_DEVNAME,
-#else
"ndis",
-#endif
ndis_methods,
sizeof(struct ndis_softc)
};
static devclass_t ndis_devclass;
-#ifdef NDIS_MODNAME
-#define NDIS_MODNAME_OVERRIDE_PCMCIA(x) \
- DRIVER_MODULE(x, pccard, ndis_driver, ndis_devclass, \
- ndisdrv_modevent, 0)
-NDIS_MODNAME_OVERRIDE_PCMCIA(NDIS_MODNAME);
-#else
DRIVER_MODULE(ndis, pccard, ndis_driver, ndis_devclass, ndisdrv_modevent, 0);
-#endif
-/*
- * Probe for an NDIS device. Check the PCI vendor and device
- * IDs against our list and return a device name if we find a match.
- */
static int
-ndis_probe_pccard(dev)
+ndis_devcompare(t, dev)
+ struct ndis_pccard_type *t;
device_t dev;
{
- struct ndis_pccard_type *t;
const char *prodstr, *vendstr;
int error;
- driver_object *drv;
-
- drv = windrv_lookup(0, "PCCARD Bus");
- if (drv == NULL)
- return(ENXIO);
-
- t = ndis_devs;
error = pccard_get_product_str(dev, &prodstr);
if (error)
- return(error);
+ return(FALSE);
error = pccard_get_vendor_str(dev, &vendstr);
if (error)
- return(error);
+ return(FALSE);
while(t->ndis_name != NULL) {
if (ndis_strcasecmp(vendstr, t->ndis_vid) == 0 &&
ndis_strcasecmp(prodstr, t->ndis_did) == 0) {
device_set_desc(dev, t->ndis_name);
- /* Create PDO for this device instance */
- windrv_create_pdo(drv, dev);
- return(0);
+ return(TRUE);
}
t++;
}
+ return(FALSE);
+}
+
+/*
+ * Probe for an NDIS device. Check the PCI vendor and device
+ * IDs against our list and return a device name if we find a match.
+ */
+static int
+ndis_probe_pccard(dev)
+ device_t dev;
+{
+ driver_object *drv;
+ struct drvdb_ent *db;
+
+ drv = windrv_lookup(0, "PCCARD Bus");
+ if (drv == NULL)
+ return(ENXIO);
+
+ db = windrv_match((matchfuncptr)ndis_devcompare, dev);
+
+ if (db != NULL) {
+ /* Create PDO for this device instance */
+ windrv_create_pdo(drv, dev);
+ return(0);
+ }
+
return(ENXIO);
}
@@ -191,10 +176,16 @@ ndis_attach_pccard(dev)
struct ndis_pccard_type *t;
int devidx = 0;
const char *prodstr, *vendstr;
+ struct drvdb_ent *db;
sc = device_get_softc(dev);
unit = device_get_unit(dev);
sc->ndis_dev = dev;
+
+ db = windrv_match((matchfuncptr)ndis_devcompare, dev);
+ if (db == NULL)
+ return (ENXIO);
+
resource_list_init(&sc->ndis_rl);
sc->ndis_io_rid = 0;
@@ -230,7 +221,7 @@ ndis_attach_pccard(dev)
/* Figure out exactly which device we matched. */
- t = ndis_devs;
+ t = db->windrv_devlist;
error = pccard_get_product_str(dev, &prodstr);
if (error)
@@ -266,8 +257,6 @@ ndis_get_resource_list(dev, child)
return (&sc->ndis_rl);
}
-#endif /* NDIS_PCI_DEV_TABLE */
-
#define NDIS_AM_RID 3
int
diff --git a/sys/dev/if_ndis/if_ndis_pci.c b/sys/dev/if_ndis/if_ndis_pci.c
index 08109e6..1c8691b 100644
--- a/sys/dev/if_ndis/if_ndis_pci.c
+++ b/sys/dev/if_ndis/if_ndis_pci.c
@@ -56,36 +56,19 @@ __FBSDID("$FreeBSD$");
#include <dev/pci/pcivar.h>
#include <compat/ndis/pe_var.h>
+#include <compat/ndis/cfg_var.h>
#include <compat/ndis/resource_var.h>
#include <compat/ndis/ntoskrnl_var.h>
#include <compat/ndis/ndis_var.h>
-#include <compat/ndis/cfg_var.h>
#include <dev/if_ndis/if_ndisvar.h>
-#include "ndis_driver_data.h"
-
-#ifdef NDIS_PCI_DEV_TABLE
-
MODULE_DEPEND(ndis, pci, 1, 1, 1);
-MODULE_DEPEND(ndis, ether, 1, 1, 1);
-MODULE_DEPEND(ndis, wlan, 1, 1, 1);
-MODULE_DEPEND(ndis, ndisapi, 1, 1, 1);
-
-/*
- * Various supported device vendors/types and their names.
- * These are defined in the ndis_driver_data.h file.
- */
-static struct ndis_pci_type ndis_devs[] = {
-#ifdef NDIS_PCI_DEV_TABLE
- NDIS_PCI_DEV_TABLE
-#endif
- { 0, 0, 0, NULL }
-};
static int ndis_probe_pci (device_t);
static int ndis_attach_pci (device_t);
static struct resource_list *ndis_get_resource_list
(device_t, device_t);
+static int ndis_devcompare (struct ndis_pci_type *, device_t);
extern int ndisdrv_modevent (module_t, int, void *);
extern int ndis_attach (device_t);
extern int ndis_shutdown (device_t);
@@ -93,8 +76,6 @@ extern int ndis_detach (device_t);
extern int ndis_suspend (device_t);
extern int ndis_resume (device_t);
-extern unsigned char drv_data[];
-
static device_method_t ndis_methods[] = {
/* Device interface */
DEVMETHOD(device_probe, ndis_probe_pci),
@@ -111,29 +92,34 @@ static device_method_t ndis_methods[] = {
};
static driver_t ndis_driver = {
-#ifdef NDIS_DEVNAME
- NDIS_DEVNAME,
-#else
"ndis",
-#endif
ndis_methods,
sizeof(struct ndis_softc)
};
static devclass_t ndis_devclass;
-#ifdef NDIS_MODNAME
-#define NDIS_MODNAME_OVERRIDE_PCI(x) \
- DRIVER_MODULE(x, pci, ndis_driver, ndis_devclass, ndisdrv_modevent, 0)
-#define NDIS_MODNAME_OVERRIDE_CARDBUS(x) \
- DRIVER_MODULE(x, cardbus, ndis_driver, ndis_devclass, \
- ndisdrv_modevent, 0)
-NDIS_MODNAME_OVERRIDE_PCI(NDIS_MODNAME);
-NDIS_MODNAME_OVERRIDE_CARDBUS(NDIS_MODNAME);
-#else
DRIVER_MODULE(ndis, pci, ndis_driver, ndis_devclass, ndisdrv_modevent, 0);
DRIVER_MODULE(ndis, cardbus, ndis_driver, ndis_devclass, ndisdrv_modevent, 0);
-#endif
+
+static int
+ndis_devcompare(t, dev)
+ struct ndis_pci_type *t;
+ device_t dev;
+{
+ while(t->ndis_name != NULL) {
+ if ((pci_get_vendor(dev) == t->ndis_vid) &&
+ (pci_get_device(dev) == t->ndis_did) &&
+ ((pci_read_config(dev, PCIR_SUBVEND_0, 4) ==
+ t->ndis_subsys) || t->ndis_subsys == 0)) {
+ device_set_desc(dev, t->ndis_name);
+ return(TRUE);
+ }
+ t++;
+ }
+
+ return(FALSE);
+}
/*
* Probe for an NDIS device. Check the PCI vendor and device
@@ -143,27 +129,20 @@ static int
ndis_probe_pci(dev)
device_t dev;
{
- struct ndis_pci_type *t;
driver_object *drv;
+ struct drvdb_ent *db;
- t = ndis_devs;
drv = windrv_lookup(0, "PCI Bus");
if (drv == NULL)
return(ENXIO);
- while(t->ndis_name != NULL) {
- if ((pci_get_vendor(dev) == t->ndis_vid) &&
- (pci_get_device(dev) == t->ndis_did) &&
- ((pci_read_config(dev, PCIR_SUBVEND_0, 4) ==
- t->ndis_subsys) || t->ndis_subsys == 0)) {
- device_set_desc(dev, t->ndis_name);
+ db = windrv_match((matchfuncptr)ndis_devcompare, dev);
- /* Create PDO for this device instance */
- windrv_create_pdo(drv, dev);
- return(0);
- }
- t++;
+ if (db != NULL) {
+ /* Create PDO for this device instance */
+ windrv_create_pdo(drv, dev);
+ return(0);
}
return(ENXIO);
@@ -183,11 +162,18 @@ ndis_attach_pci(dev)
int devidx = 0, defidx = 0;
struct resource_list *rl;
struct resource_list_entry *rle;
+ struct drvdb_ent *db;
sc = device_get_softc(dev);
unit = device_get_unit(dev);
sc->ndis_dev = dev;
+ db = windrv_match((matchfuncptr)ndis_devcompare, dev);
+ if (db == NULL)
+ return (ENXIO);
+ sc->ndis_dobj = db->windrv_object;
+ sc->ndis_regvals = db->windrv_regvals;
+
/*
* Map control/status registers.
*/
@@ -213,6 +199,7 @@ ndis_attach_pci(dev)
error = ENXIO;
goto fail;
}
+ pci_enable_io(dev, SYS_RES_IOPORT);
break;
case SYS_RES_MEMORY:
if (sc->ndis_res_altmem != NULL &&
@@ -250,6 +237,7 @@ ndis_attach_pci(dev)
goto fail;
}
}
+ pci_enable_io(dev, SYS_RES_MEMORY);
break;
case SYS_RES_IRQ:
rid = rle->rid;
@@ -312,7 +300,7 @@ ndis_attach_pci(dev)
/* Figure out exactly which device we matched. */
- t = ndis_devs;
+ t = db->windrv_devlist;
while(t->ndis_name != NULL) {
if ((pci_get_vendor(dev) == t->ndis_vid) &&
@@ -329,7 +317,7 @@ ndis_attach_pci(dev)
devidx++;
}
- if (ndis_devs[devidx].ndis_name == NULL)
+ if (t[devidx].ndis_name == NULL)
sc->ndis_devidx = defidx;
else
sc->ndis_devidx = devidx;
@@ -350,5 +338,3 @@ ndis_get_resource_list(dev, child)
sc = device_get_softc(dev);
return (BUS_GET_RESOURCE_LIST(device_get_parent(sc->ndis_dev), dev));
}
-
-#endif /* NDIS_PCI_DEV_TABLE */
diff --git a/sys/dev/if_ndis/if_ndis_usb.c b/sys/dev/if_ndis/if_ndis_usb.c
index 8199534..b5a6943 100644
--- a/sys/dev/if_ndis/if_ndis_usb.c
+++ b/sys/dev/if_ndis/if_ndis_usb.c
@@ -36,7 +36,7 @@ __FBSDID("$FreeBSD$");
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/sockio.h>
-#include <sys/mbuf.h>
+#include <sys/module.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/socket.h>
@@ -56,26 +56,18 @@ __FBSDID("$FreeBSD$");
#include <dev/usb/usbdi.h>
#include <dev/usb/usbdi_util.h>
#include <dev/usb/usbdivar.h>
-#include <dev/usb/usbdevs.h>
-#include <dev/usb/usb_ethersubr.h>
+#include "usbdevs.h"
#include <net80211/ieee80211_var.h>
#include <compat/ndis/pe_var.h>
+#include <compat/ndis/cfg_var.h>
#include <compat/ndis/resource_var.h>
#include <compat/ndis/ntoskrnl_var.h>
#include <compat/ndis/ndis_var.h>
-#include <compat/ndis/cfg_var.h>
#include <dev/if_ndis/if_ndisvar.h>
MODULE_DEPEND(ndis, usb, 1, 1, 1);
-MODULE_DEPEND(ndis, ether, 1, 1, 1);
-MODULE_DEPEND(ndis, wlan, 1, 1, 1);
-MODULE_DEPEND(ndis, ndisapi, 1, 1, 1);
-
-#include "ndis_driver_data.h"
-
-#ifdef NDIS_USB_DEV_TABLE
Static int ndisusb_match (device_ptr_t);
Static int ndisusb_attach (device_ptr_t);
@@ -107,24 +99,14 @@ Static device_method_t ndis_methods[] = {
};
Static driver_t ndis_driver = {
-#ifdef NDIS_DEVNAME
- NDIS_DEVNAME,
-#else
"ndis",
-#endif
ndis_methods,
sizeof(struct ndis_softc)
};
Static devclass_t ndis_devclass;
-#ifdef NDIS_MODNAME
-#define NDIS_MODNAME_OVERRIDE_USB(x)
- DRIVER_MODULE(x, usb, ndis_driver, ndis_devclass, ndisdrv_modevent, 0)
-NDIS_MODNAME_OVERRIDE_USB(NDIS_MODNAME);
-#else
DRIVER_MODULE(ndis, uhub, ndis_driver, ndis_devclass, ndisdrv_modevent, 0);
-#endif
USB_MATCH(ndisusb)
{
@@ -147,6 +129,9 @@ USB_ATTACH(ndisusb)
sc = (struct ndis_softc *)dummy;
+ if (uaa->device == NULL)
+ USB_ATTACH_ERROR_RETURN;
+
sc->ndis_dev = self;
/* Create PDO for this device instance */
@@ -170,5 +155,3 @@ ndis_get_resource_list(dev, child)
sc = device_get_softc(dev);
return (BUS_GET_RESOURCE_LIST(device_get_parent(sc->ndis_dev), dev));
}
-
-#endif /* NDIS_USB_DEV_TABLE */
diff --git a/sys/dev/if_ndis/if_ndisvar.h b/sys/dev/if_ndis/if_ndisvar.h
index 0936aaf..68f30f9 100644
--- a/sys/dev/if_ndis/if_ndisvar.h
+++ b/sys/dev/if_ndis/if_ndisvar.h
@@ -122,6 +122,7 @@ struct ndis_softc {
#endif
int ndis_devidx;
interface_type ndis_iftype;
+ driver_object *ndis_dobj;
bus_dma_tag_t ndis_parent_tag;
struct ndis_shmem *ndis_shlist;
OpenPOWER on IntegriCloud