- Correct one aspect of the driver_object/device_object/IRP framework:
when we create a PDO, the driver_object associated with it is that of the parent driver, not the driver we're trying to attach. For example, if we attach a PCI device, the PDO we pass to the NdisAddDevice() function should contain a pointer to fake_pci_driver, not to the NDIS driver itself. For PCI or PCMCIA devices this doesn't matter because the child never needs to talk to the parent bus driver, but for USB, the child needs to be able to send IRPs to the parent USB bus driver, and for that to work the parent USB bus driver has to be hung off the PDO. This involves modifying windrv_lookup() so that we can search for bus drivers by name, if necessary. Our fake bus drivers attach themselves as "PCI Bus," "PCCARD Bus" and "USB Bus," so we can search for them using those names. The individual attachment stubs now create and attach PDOs to the parent bus drivers instead of hanging them off the NDIS driver's object, and in if_ndis.c, we now search for the correct driver object depending on the bus type, and use that to find the correct PDO. With this fix, I can get my sample USB ethernet driver to deliver an IRP to my fake parent USB bus driver's dispatch routines. - Add stub modules for USB support: subr_usbd.c, usbd_var.h and if_ndis_usb.c. The subr_usbd.c module is hooked up the build but currently doesn't do very much. It provides the stub USB parent driver object and a dispatch routine for IRM_MJ_INTERNAL_DEVICE_CONTROL. The only exported function at the moment is USBD_GetUSBDIVersion(). The if_ndis_usb.c stub compiles, but is not hooked up to the build yet. I'm putting these here so I can keep them under source code control as I flesh them out.
This commit is contained in:
parent
d701c91325
commit
63ba67b69c
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=142399
@ -73,6 +73,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <compat/ndis/ndis_var.h>
|
||||
#include <compat/ndis/hal_var.h>
|
||||
#include <compat/ndis/cfg_var.h>
|
||||
#include <compat/ndis/usbd_var.h>
|
||||
#include <dev/if_ndis/if_ndisvar.h>
|
||||
|
||||
#define NDIS_DUMMY_PATH "\\\\some\\bogus\\path"
|
||||
@ -150,6 +151,7 @@ ndis_modevent(module_t mod, int cmd, void *arg)
|
||||
hal_libinit();
|
||||
ndis_libinit();
|
||||
ntoskrnl_libinit();
|
||||
usbd_libinit();
|
||||
|
||||
patch = kernndis_functbl;
|
||||
while (patch->ipt_func != NULL) {
|
||||
@ -176,6 +178,7 @@ ndis_modevent(module_t mod, int cmd, void *arg)
|
||||
hal_libfini();
|
||||
ndis_libfini();
|
||||
ntoskrnl_libfini();
|
||||
usbd_libfini();
|
||||
windrv_libfini();
|
||||
|
||||
patch = kernndis_functbl;
|
||||
@ -196,6 +199,7 @@ ndis_modevent(module_t mod, int cmd, void *arg)
|
||||
hal_libfini();
|
||||
ndis_libfini();
|
||||
ntoskrnl_libfini();
|
||||
usbd_libfini();
|
||||
windrv_libfini();
|
||||
|
||||
patch = kernndis_functbl;
|
||||
|
@ -55,6 +55,7 @@ __FBSDID("$FreeBSD$");
|
||||
#include <compat/ndis/ntoskrnl_var.h>
|
||||
#include <compat/ndis/ndis_var.h>
|
||||
#include <compat/ndis/hal_var.h>
|
||||
#include <compat/ndis/usbd_var.h>
|
||||
|
||||
struct windrv_type {
|
||||
uint16_t windrv_vid; /* for PCI or USB */
|
||||
@ -130,20 +131,36 @@ windrv_libfini(void)
|
||||
*/
|
||||
|
||||
driver_object *
|
||||
windrv_lookup(img)
|
||||
windrv_lookup(img, name)
|
||||
vm_offset_t img;
|
||||
char *name;
|
||||
{
|
||||
struct drvdb_ent *d;
|
||||
unicode_string us;
|
||||
|
||||
/* Damn unicode. */
|
||||
|
||||
if (name != NULL) {
|
||||
us.us_len = strlen(name) * 2;
|
||||
us.us_maxlen = strlen(name) * 2;
|
||||
us.us_buf = NULL;
|
||||
ndis_ascii_to_unicode(name, &us.us_buf);
|
||||
}
|
||||
|
||||
mtx_lock(&drvdb_mtx);
|
||||
STAILQ_FOREACH(d, &drvdb_head, link) {
|
||||
if (d->windrv_object->dro_driverstart == (void *)img) {
|
||||
if (d->windrv_object->dro_driverstart == (void *)img ||
|
||||
bcmp((char *)d->windrv_object->dro_drivername.us_buf,
|
||||
(char *)us.us_buf, us.us_len) == 0) {
|
||||
mtx_unlock(&drvdb_mtx);
|
||||
return(d->windrv_object);
|
||||
}
|
||||
}
|
||||
mtx_unlock(&drvdb_mtx);
|
||||
|
||||
if (name != NULL)
|
||||
ExFreePool(us.us_buf);
|
||||
|
||||
return(NULL);
|
||||
}
|
||||
|
||||
@ -244,12 +261,10 @@ windrv_load(mod, img, len)
|
||||
}
|
||||
|
||||
/* Dynamically link USBD.SYS -- optional */
|
||||
#ifdef notyet
|
||||
if (pe_get_import_descriptor(img, &imp_desc, "USBD") == 0) {
|
||||
if (pe_patch_imports(img, "USBD", ntoskrnl_functbl))
|
||||
if (pe_patch_imports(img, "USBD", usbd_functbl))
|
||||
return(ENOEXEC);
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Next step: find the driver entry point. */
|
||||
|
||||
|
@ -1127,7 +1127,7 @@ typedef void (*funcptr)(void);
|
||||
__BEGIN_DECLS
|
||||
extern int windrv_libinit(void);
|
||||
extern int windrv_libfini(void);
|
||||
extern driver_object *windrv_lookup(vm_offset_t);
|
||||
extern driver_object *windrv_lookup(vm_offset_t, char *);
|
||||
extern int windrv_load(module_t, vm_offset_t, int);
|
||||
extern int windrv_unload(module_t, vm_offset_t, int);
|
||||
extern int windrv_create_pdo(driver_object *, device_t);
|
||||
|
156
sys/compat/ndis/subr_usbd.c
Normal file
156
sys/compat/ndis/subr_usbd.c
Normal file
@ -0,0 +1,156 @@
|
||||
/*-
|
||||
* Copyright (c) 2005
|
||||
* Bill Paul <wpaul@windriver.com>. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Bill Paul.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/lock.h>
|
||||
#include <sys/mutex.h>
|
||||
#include <sys/module.h>
|
||||
#include <sys/conf.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/bus.h>
|
||||
|
||||
#include <sys/queue.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/hal_var.h>
|
||||
#include <compat/ndis/usbd_var.h>
|
||||
|
||||
static driver_object usbd_driver;
|
||||
|
||||
__stdcall static uint32_t usbd_iodispatch(device_object *, irp *);
|
||||
|
||||
__stdcall static void USBD_GetUSBDIVersion(usbd_version_info *);
|
||||
__stdcall static void dummy(void);
|
||||
|
||||
int
|
||||
usbd_libinit(void)
|
||||
{
|
||||
image_patch_table *patch;
|
||||
|
||||
patch = usbd_functbl;
|
||||
while (patch->ipt_func != NULL) {
|
||||
windrv_wrap((funcptr)patch->ipt_func,
|
||||
(funcptr *)&patch->ipt_wrap);
|
||||
patch++;
|
||||
}
|
||||
|
||||
/* Create a fake USB driver instance. */
|
||||
|
||||
windrv_bus_attach(&usbd_driver, "USB Bus");
|
||||
|
||||
/* Set up our dipatch routine. */
|
||||
|
||||
usbd_driver.dro_dispatch[IRP_MJ_INTERNAL_DEVICE_CONTROL] =
|
||||
(driver_dispatch)usbd_iodispatch;
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
int
|
||||
usbd_libfini(void)
|
||||
{
|
||||
image_patch_table *patch;
|
||||
|
||||
patch = usbd_functbl;
|
||||
while (patch->ipt_func != NULL) {
|
||||
windrv_unwrap(patch->ipt_wrap);
|
||||
patch++;
|
||||
}
|
||||
|
||||
free(usbd_driver.dro_drivername.us_buf, M_DEVBUF);
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
__stdcall static uint32_t
|
||||
usbd_iodispatch(dobj, ip)
|
||||
device_object *dobj;
|
||||
irp *ip;
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
__stdcall static void
|
||||
USBD_GetUSBDIVersion(ui)
|
||||
usbd_version_info *ui;
|
||||
{
|
||||
/* Pretend to be Windows XP. */
|
||||
|
||||
ui->uvi_usbdi_vers = USBDI_VERSION;
|
||||
ui->uvi_supported_vers = USB_VER_2_0;
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
__stdcall static void
|
||||
dummy(void)
|
||||
{
|
||||
printf("USBD dummy called\n");
|
||||
return;
|
||||
}
|
||||
|
||||
image_patch_table usbd_functbl[] = {
|
||||
IMPORT_FUNC(USBD_GetUSBDIVersion),
|
||||
#ifdef notyet
|
||||
IMPORT_FUNC_MAP(_USBD_ParseConfigurationDescriptorEx@28,
|
||||
USBD_ParseConfigurationDescriptorEx),
|
||||
IMPORT_FUNC_MAP(_USBD_CreateConfigurationRequestEx@8,
|
||||
USBD_CreateConfigurationRequestEx),
|
||||
#endif
|
||||
|
||||
/*
|
||||
* This last entry is a catch-all for any function we haven't
|
||||
* implemented yet. The PE import list patching routine will
|
||||
* use it for any function that doesn't have an explicit match
|
||||
* in this table.
|
||||
*/
|
||||
|
||||
{ NULL, (FUNC)dummy, NULL },
|
||||
|
||||
/* End of list. */
|
||||
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
|
56
sys/compat/ndis/usbd_var.h
Normal file
56
sys/compat/ndis/usbd_var.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*-
|
||||
* Copyright (c) 2003
|
||||
* Bill Paul <wpaul@windriver.com>. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Bill Paul.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
* $FreeBSD$
|
||||
*/
|
||||
|
||||
#ifndef _USBD_VAR_H_
|
||||
#define _USBD_VAR_H_
|
||||
|
||||
#define USBDI_VERSION 0x00000500
|
||||
#define USB_VER_1_1 0x00000110
|
||||
#define USB_VER_2_0 0x00000200
|
||||
|
||||
struct usbd_version_info {
|
||||
uint32_t uvi_usbdi_vers;
|
||||
uint32_t uvi_supported_vers;
|
||||
};
|
||||
|
||||
typedef struct usbd_version_info usbd_version_info;
|
||||
|
||||
extern image_patch_table usbd_functbl[];
|
||||
|
||||
__BEGIN_DECLS
|
||||
extern int usbd_libinit(void);
|
||||
extern int usbd_libfini(void);
|
||||
__END_DECLS
|
||||
|
||||
#endif /* _USBD_VAR_H_ */
|
@ -209,4 +209,5 @@ compat/ndis/subr_hal.c optional ndisapi pci
|
||||
compat/ndis/subr_ndis.c optional ndisapi pci
|
||||
compat/ndis/subr_ntoskrnl.c optional ndisapi pci
|
||||
compat/ndis/subr_pe.c optional ndisapi pci
|
||||
compat/ndis/subr_usbd.c optional ndisapi pci
|
||||
compat/ndis/winx64_wrap.S optional ndisapi pci
|
||||
|
@ -85,6 +85,7 @@ compat/ndis/subr_hal.c optional ndisapi pci
|
||||
compat/ndis/subr_ndis.c optional ndisapi pci
|
||||
compat/ndis/subr_ntoskrnl.c optional ndisapi pci
|
||||
compat/ndis/subr_pe.c optional ndisapi pci
|
||||
compat/ndis/subr_usbd.c optional ndisapi pci
|
||||
compat/pecoff/imgact_pecoff.c optional pecoff_support
|
||||
compat/svr4/imgact_svr4.c optional compat_svr4
|
||||
compat/svr4/svr4_fcntl.c optional compat_svr4
|
||||
|
@ -428,6 +428,7 @@ 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;
|
||||
@ -439,17 +440,22 @@ ndis_attach(dev)
|
||||
mtx_init(&sc->ndis_mtx, "ndis softc lock",
|
||||
MTX_NETWORK_LOCK, MTX_DEF);
|
||||
|
||||
/*
|
||||
/*
|
||||
* Hook interrupt early, since calling the driver's
|
||||
* init routine may trigger an interrupt.
|
||||
* init routine may trigger an interrupt. Note that
|
||||
* we don't need to do any explicit interrupt setup
|
||||
* for USB.
|
||||
*/
|
||||
|
||||
error = bus_setup_intr(dev, sc->ndis_irq, INTR_TYPE_NET | INTR_MPSAFE,
|
||||
ndis_intr, sc, &sc->ndis_intrhand);
|
||||
if (sc->ndis_iftype == PCMCIABus || sc->ndis_iftype == PCIBus) {
|
||||
error = bus_setup_intr(dev, sc->ndis_irq,
|
||||
INTR_TYPE_NET | INTR_MPSAFE,
|
||||
ndis_intr, sc, &sc->ndis_intrhand);
|
||||
|
||||
if (error) {
|
||||
device_printf(dev, "couldn't set up irq\n");
|
||||
goto fail;
|
||||
if (error) {
|
||||
device_printf(dev, "couldn't set up irq\n");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
|
||||
if (sc->ndis_iftype == PCMCIABus) {
|
||||
@ -470,6 +476,16 @@ ndis_attach(dev)
|
||||
/* Create sysctl registry nodes */
|
||||
ndis_create_sysctls(sc);
|
||||
|
||||
/* Find the PDO for this device instance. */
|
||||
|
||||
if (sc->ndis_iftype == PCIBus)
|
||||
pdrv = windrv_lookup(NULL, "PCI Bus");
|
||||
else if (sc->ndis_iftype == PCMCIABus)
|
||||
pdrv = windrv_lookup(NULL, "PCCARD Bus");
|
||||
else
|
||||
pdrv = windrv_lookup(NULL, "USB Bus");
|
||||
pdo = windrv_find_pdo(pdrv, dev);
|
||||
|
||||
/*
|
||||
* Create a new functional device object for this
|
||||
* device. This is what creates the miniport block
|
||||
@ -477,8 +493,7 @@ ndis_attach(dev)
|
||||
*/
|
||||
|
||||
img = drv_data;
|
||||
drv = windrv_lookup((vm_offset_t)img);
|
||||
pdo = windrv_find_pdo(drv, dev);
|
||||
drv = windrv_lookup((vm_offset_t)img, NULL);
|
||||
if (NdisAddDevice(drv, pdo) != STATUS_SUCCESS) {
|
||||
device_printf(dev, "failed to create FDO!\n");
|
||||
error = ENXIO;
|
||||
@ -491,7 +506,8 @@ ndis_attach(dev)
|
||||
sc->ndis_chars->nmc_version_minor);
|
||||
|
||||
/* Do resource conversion. */
|
||||
ndis_convert_res(sc);
|
||||
if (sc->ndis_iftype == PCMCIABus || sc->ndis_iftype == PCIBus)
|
||||
ndis_convert_res(sc);
|
||||
|
||||
/* Install our RX and TX interrupt handlers. */
|
||||
sc->ndis_block->nmb_senddone_func = ndis_txeof_wrap;
|
||||
@ -857,7 +873,12 @@ ndis_detach(dev)
|
||||
|
||||
/* Destroy the PDO for this device. */
|
||||
|
||||
drv = windrv_lookup((vm_offset_t)drv_data);
|
||||
if (sc->ndis_iftype == PCIBus)
|
||||
drv = windrv_lookup(NULL, "PCI Bus");
|
||||
else if (sc->ndis_iftype == PCMCIABus)
|
||||
drv = windrv_lookup(NULL, "PCCARD Bus");
|
||||
else
|
||||
drv = windrv_lookup(NULL, "USB Bus");
|
||||
if (drv == NULL)
|
||||
panic("couldn't find driver object");
|
||||
windrv_destroy_pdo(drv, dev);
|
||||
|
@ -150,10 +150,8 @@ ndis_probe_pccard(dev)
|
||||
const char *prodstr, *vendstr;
|
||||
int error;
|
||||
driver_object *drv;
|
||||
vm_offset_t img;
|
||||
|
||||
img = (vm_offset_t)drv_data;
|
||||
drv = windrv_lookup(img);
|
||||
|
||||
drv = windrv_lookup(NULL, "PCCARD Bus");
|
||||
if (drv == NULL)
|
||||
return(ENXIO);
|
||||
|
||||
|
@ -145,11 +145,9 @@ ndis_probe_pci(dev)
|
||||
{
|
||||
struct ndis_pci_type *t;
|
||||
driver_object *drv;
|
||||
vm_offset_t img;
|
||||
|
||||
t = ndis_devs;
|
||||
img = (vm_offset_t)drv_data;
|
||||
drv = windrv_lookup(img);
|
||||
drv = windrv_lookup(NULL, "PCI Bus");
|
||||
|
||||
if (drv == NULL)
|
||||
return(ENXIO);
|
||||
|
176
sys/dev/if_ndis/if_ndis_usb.c
Normal file
176
sys/dev/if_ndis/if_ndis_usb.c
Normal file
@ -0,0 +1,176 @@
|
||||
/*-
|
||||
* Copyright (c) 2005
|
||||
* Bill Paul <wpaul@ee.columbia.edu>. All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in the
|
||||
* documentation and/or other materials provided with the distribution.
|
||||
* 3. All advertising materials mentioning features or use of this software
|
||||
* must display the following acknowledgement:
|
||||
* This product includes software developed by Bill Paul.
|
||||
* 4. Neither the name of the author nor the names of any co-contributors
|
||||
* may be used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY Bill Paul AND CONTRIBUTORS ``AS IS'' AND
|
||||
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
* ARE DISCLAIMED. IN NO EVENT SHALL Bill Paul OR THE VOICES IN HIS HEAD
|
||||
* BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
|
||||
* THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
__FBSDID("$FreeBSD$");
|
||||
|
||||
#include <sys/param.h>
|
||||
#include <sys/systm.h>
|
||||
#include <sys/sockio.h>
|
||||
#include <sys/mbuf.h>
|
||||
#include <sys/malloc.h>
|
||||
#include <sys/kernel.h>
|
||||
#include <sys/socket.h>
|
||||
#include <sys/sysctl.h>
|
||||
|
||||
#include <net/if.h>
|
||||
#include <net/if_arp.h>
|
||||
#include <net/ethernet.h>
|
||||
#include <net/if_dl.h>
|
||||
#include <net/if_media.h>
|
||||
|
||||
#include <net/bpf.h>
|
||||
|
||||
#include <sys/bus.h>
|
||||
#include <machine/bus.h>
|
||||
#include <dev/usb/usb.h>
|
||||
#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 <net80211/ieee80211_var.h>
|
||||
|
||||
#include <compat/ndis/pe_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);
|
||||
Static struct resource_list *ndis_get_resource_list
|
||||
(device_t, device_t);
|
||||
|
||||
extern int ndisdrv_modevent (module_t, int, void *);
|
||||
extern int ndis_attach (device_t);
|
||||
extern int ndis_shutdown (device_t);
|
||||
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, ndisusb_match),
|
||||
DEVMETHOD(device_attach, ndisusb_attach),
|
||||
DEVMETHOD(device_detach, ndis_detach),
|
||||
DEVMETHOD(device_shutdown, ndis_shutdown),
|
||||
|
||||
/* bus interface */
|
||||
DEVMETHOD(bus_print_child, bus_generic_print_child),
|
||||
DEVMETHOD(bus_driver_added, bus_generic_driver_added),
|
||||
DEVMETHOD(bus_get_resource_list, ndis_get_resource_list),
|
||||
|
||||
{ 0, 0 }
|
||||
};
|
||||
|
||||
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)
|
||||
{
|
||||
USB_MATCH_START(ndisusb, uaa);
|
||||
driver_object *drv;
|
||||
|
||||
drv = windrv_lookup(NULL, "USB Bus");
|
||||
if (drv == NULL)
|
||||
return(UMATCH_NONE);
|
||||
|
||||
if (0) {
|
||||
/* Create PDO for this device instance */
|
||||
windrv_create_pdo(drv, self);
|
||||
return(0);
|
||||
}
|
||||
|
||||
if (uaa->iface != NULL)
|
||||
return(UMATCH_NONE);
|
||||
|
||||
return(UMATCH_NONE);
|
||||
}
|
||||
|
||||
USB_ATTACH(ndisusb)
|
||||
{
|
||||
USB_ATTACH_START(ndisusb, dummy, uaa);
|
||||
struct ndis_softc *sc;
|
||||
|
||||
sc = (struct ndis_softc *)dummy;
|
||||
|
||||
sc->ndis_dev = self;
|
||||
|
||||
if (ndis_attach(self) != 0)
|
||||
USB_ATTACH_ERROR_RETURN;
|
||||
|
||||
USB_ATTACH_SUCCESS_RETURN;
|
||||
}
|
||||
|
||||
static struct resource_list *
|
||||
ndis_get_resource_list(dev, child)
|
||||
device_t dev;
|
||||
device_t child;
|
||||
{
|
||||
struct ndis_softc *sc;
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
return (BUS_GET_RESOURCE_LIST(device_get_parent(sc->ndis_dev), dev));
|
||||
}
|
||||
|
||||
#endif /* NDIS_USB_DEV_TABLE */
|
@ -4,7 +4,7 @@
|
||||
|
||||
KMOD= ndis
|
||||
SRCS= subr_pe.c subr_ndis.c subr_hal.c subr_ntoskrnl.c kern_ndis.c
|
||||
SRCS+= kern_windrv.c
|
||||
SRCS+= kern_windrv.c subr_usbd.c
|
||||
SRCS+= opt_bdg.h device_if.h bus_if.h pci_if.h vnode_if.h
|
||||
|
||||
.if ${MACHINE_ARCH} == "amd64"
|
||||
|
Loading…
Reference in New Issue
Block a user