int usbd_libinit(void) { image_patch_table *patch; int i; patch = usbd_functbl; while (patch->ipt_func != NULL) { windrv_wrap((funcptr)patch->ipt_func, (funcptr *)&patch->ipt_wrap, patch->ipt_argcnt, patch->ipt_ftype); patch++; } windrv_wrap((funcptr)usbd_ioinvalid, (funcptr *)&usbd_ioinvalid_wrap, 2, WINDRV_WRAP_STDCALL); windrv_wrap((funcptr)usbd_iodispatch, (funcptr *)&usbd_iodispatch_wrap, 2, WINDRV_WRAP_STDCALL); windrv_wrap((funcptr)usbd_pnp, (funcptr *)&usbd_pnp_wrap, 2, WINDRV_WRAP_STDCALL); windrv_wrap((funcptr)usbd_power, (funcptr *)&usbd_power_wrap, 2, WINDRV_WRAP_STDCALL); windrv_wrap((funcptr)usbd_irpcancel, (funcptr *)&usbd_irpcancel_wrap, 2, WINDRV_WRAP_STDCALL); windrv_wrap((funcptr)usbd_task, (funcptr *)&usbd_task_wrap, 2, WINDRV_WRAP_STDCALL); windrv_wrap((funcptr)usbd_xfertask, (funcptr *)&usbd_xfertask_wrap, 2, WINDRV_WRAP_STDCALL); /* Create a fake USB driver instance. */ windrv_bus_attach(&usbd_driver, "USB Bus"); /* Set up our dipatch routine. */ for (i = 0; i <= IRP_MJ_MAXIMUM_FUNCTION; i++) usbd_driver.dro_dispatch[i] = (driver_dispatch)usbd_ioinvalid_wrap; usbd_driver.dro_dispatch[IRP_MJ_INTERNAL_DEVICE_CONTROL] = (driver_dispatch)usbd_iodispatch_wrap; usbd_driver.dro_dispatch[IRP_MJ_DEVICE_CONTROL] = (driver_dispatch)usbd_iodispatch_wrap; usbd_driver.dro_dispatch[IRP_MJ_POWER] = (driver_dispatch)usbd_power_wrap; usbd_driver.dro_dispatch[IRP_MJ_PNP] = (driver_dispatch)usbd_pnp_wrap; return (0); }
int hal_libinit() { image_patch_table *patch; patch = hal_functbl; while (patch->ipt_func != NULL) { windrv_wrap((funcptr)patch->ipt_func, (funcptr *)&patch->ipt_wrap); patch++; } return(0); }
int hal_libinit() { image_patch_table *patch; int i; for (i = 0; i < NDIS_MAXCPUS; i++) mtx_init(&disp_lock[i], "HAL preemption lock", "HAL lock", MTX_RECURSE|MTX_DEF); patch = hal_functbl; while (patch->ipt_func != NULL) { windrv_wrap((funcptr)patch->ipt_func, (funcptr *)&patch->ipt_wrap, patch->ipt_argcnt, patch->ipt_ftype); patch++; } return (0); }
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->ipt_argcnt, patch->ipt_ftype); 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); }
static int ndis_modevent(module_t mod, int cmd, void *arg) { int error = 0; image_patch_table *patch; switch (cmd) { case MOD_LOAD: /* Initialize subsystems */ hal_libinit(); ntoskrnl_libinit(); windrv_libinit(); ndis_libinit(); usbd_libinit(); patch = kernndis_functbl; while (patch->ipt_func != NULL) { windrv_wrap((funcptr)patch->ipt_func, (funcptr *)&patch->ipt_wrap, patch->ipt_argcnt, patch->ipt_ftype); patch++; } TAILQ_INIT(&ndis_devhead); break; case MOD_SHUTDOWN: if (TAILQ_FIRST(&ndis_devhead) == NULL) { /* Shut down subsystems */ ndis_libfini(); usbd_libfini(); windrv_libfini(); ntoskrnl_libfini(); hal_libfini(); patch = kernndis_functbl; while (patch->ipt_func != NULL) { windrv_unwrap(patch->ipt_wrap); patch++; } } break; case MOD_UNLOAD: /* Shut down subsystems */ ndis_libfini(); usbd_libfini(); windrv_libfini(); ntoskrnl_libfini(); hal_libfini(); patch = kernndis_functbl; while (patch->ipt_func != NULL) { windrv_unwrap(patch->ipt_wrap); patch++; } break; default: error = EINVAL; break; } return (error); }