3 * Bill Paul <wpaul@windriver.com>. All rights reserved.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. All advertising materials mentioning features or use of this software
14 * must display the following acknowledgement:
15 * This product includes software developed by Bill Paul.
16 * 4. Neither the name of the author nor the names of any co-contributors
17 * may be used to endorse or promote products derived from this software
18 * without specific prior written permission.
20 * THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
21 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
22 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
23 * ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
24 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
25 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
26 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
27 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
28 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
29 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
30 * THE POSSIBILITY OF SUCH DAMAGE.
33 #include <sys/cdefs.h>
34 __FBSDID("$FreeBSD$");
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/sockio.h>
39 #include <sys/module.h>
40 #include <sys/malloc.h>
41 #include <sys/kernel.h>
42 #include <sys/socket.h>
43 #include <sys/sysctl.h>
46 #include <net/if_arp.h>
47 #include <net/ethernet.h>
48 #include <net/if_dl.h>
49 #include <net/if_media.h>
54 #include <machine/bus.h>
55 #include <dev/usb/usb.h>
56 #include <dev/usb/usbdi.h>
57 #include <dev/usb/usbdi_util.h>
58 #include <dev/usb/usbdivar.h>
61 #include <net80211/ieee80211_var.h>
63 #include <compat/ndis/pe_var.h>
64 #include <compat/ndis/cfg_var.h>
65 #include <compat/ndis/resource_var.h>
66 #include <compat/ndis/ntoskrnl_var.h>
67 #include <compat/ndis/ndis_var.h>
68 #include <dev/if_ndis/if_ndisvar.h>
70 MODULE_DEPEND(ndis, usb, 1, 1, 1);
72 static device_probe_t ndisusb_match;
73 static device_attach_t ndisusb_attach;
74 static bus_get_resource_list_t ndis_get_resource_list;
76 extern int ndisdrv_modevent (module_t, int, void *);
77 extern int ndis_attach (device_t);
78 extern int ndis_shutdown (device_t);
79 extern int ndis_detach (device_t);
80 extern int ndis_suspend (device_t);
81 extern int ndis_resume (device_t);
83 extern unsigned char drv_data[];
85 static device_method_t ndis_methods[] = {
86 /* Device interface */
87 DEVMETHOD(device_probe, ndisusb_match),
88 DEVMETHOD(device_attach, ndisusb_attach),
89 DEVMETHOD(device_detach, ndis_detach),
90 DEVMETHOD(device_shutdown, ndis_shutdown),
93 DEVMETHOD(bus_print_child, bus_generic_print_child),
94 DEVMETHOD(bus_driver_added, bus_generic_driver_added),
95 DEVMETHOD(bus_get_resource_list, ndis_get_resource_list),
100 static driver_t ndis_driver = {
103 sizeof(struct ndis_softc)
106 static devclass_t ndis_devclass;
108 DRIVER_MODULE(ndis, uhub, ndis_driver, ndis_devclass, ndisdrv_modevent, 0);
111 ndisusb_match(device_t self)
113 struct usb_attach_arg *uaa = device_get_ivars(self);
115 if (windrv_lookup(0, "USB Bus") == NULL)
116 return (UMATCH_NONE);
118 if (uaa->iface != NULL)
119 return (UMATCH_NONE);
121 return (UMATCH_NONE);
125 ndisusb_attach(device_t self)
127 struct ndisusb_softc *dummy = device_get_softc(self);
128 struct usb_attach_arg *uaa = device_get_ivars(self);
129 struct ndis_softc *sc;
132 sc = (struct ndis_softc *)dummy;
134 if (uaa->device == NULL)
139 /* Create PDO for this device instance */
141 drv = windrv_lookup(0, "USB Bus");
142 windrv_create_pdo(drv, self);
144 if (ndis_attach(self) != 0)
150 static struct resource_list *
151 ndis_get_resource_list(device_t dev, device_t child)
153 struct ndis_softc *sc;
155 sc = device_get_softc(dev);
156 return (BUS_GET_RESOURCE_LIST(device_get_parent(sc->ndis_dev), dev));