Annotation of src/sys/compat/ndis/subr_usbd.c, Revision 1.2.20.2
1.2.20.2! rpaulo 1: /*-
! 2: * Copyright (c) 2005
! 3: * Bill Paul <wpaul@windriver.com>. All rights reserved.
! 4: *
! 5: * Redistribution and use in source and binary forms, with or without
! 6: * modification, are permitted provided that the following conditions
! 7: * are met:
! 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.
! 19: *
! 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.
! 31: */
! 32:
! 33: #include <sys/cdefs.h>
! 34: #ifdef __FreeBSD__
! 35: __FBSDID("$FreeBSD: src/sys/compat/ndis/subr_usbd.c,v 1.1.2.1 2005/03/31 04:24:36 wpaul Exp $");
! 36: #endif
! 37: #ifdef __NetBSD__
! 38: __KERNEL_RCSID(0, "$NetBSD");
! 39: #endif
! 40:
! 41: #include <sys/param.h>
! 42: #include <sys/systm.h>
! 43: #include <sys/unistd.h>
! 44: #include <sys/types.h>
! 45:
! 46: #include <sys/kernel.h>
! 47: #include <sys/malloc.h>
! 48: #include <sys/lock.h>
! 49: #ifdef __FreeBSD__
! 50: #include <sys/mutex.h>
! 51: #include <sys/module.h>
! 52: #endif
! 53: #include <sys/conf.h>
! 54: #include <sys/mbuf.h>
! 55: #ifdef __FreeBSD__
! 56: #include <sys/bus.h>
! 57: #endif
! 58:
! 59: #include <sys/queue.h>
! 60:
! 61: #include <compat/ndis/pe_var.h>
! 62: #include <compat/ndis/cfg_var.h>
! 63: #include <compat/ndis/resource_var.h>
! 64: #include <compat/ndis/ntoskrnl_var.h>
! 65: #include <compat/ndis/ndis_var.h>
! 66: #include <compat/ndis/hal_var.h>
! 67: #include <compat/ndis/usbd_var.h>
! 68:
! 69: static driver_object usbd_driver;
! 70:
! 71: __stdcall static uint32_t usbd_iodispatch(device_object *, irp *);
! 72:
! 73: __stdcall static void USBD_GetUSBDIVersion(usbd_version_info *);
! 74: __stdcall static void dummy(void);
! 75:
! 76: int
! 77: usbd_libinit(void)
! 78: {
! 79: image_patch_table *patch;
! 80:
! 81: patch = usbd_functbl;
! 82: while (patch->ipt_func != NULL) {
! 83: windrv_wrap((funcptr)patch->ipt_func,
! 84: (funcptr *)&patch->ipt_wrap);
! 85: patch++;
! 86: }
! 87:
! 88: /* Create a fake USB driver instance. */
! 89:
! 90: windrv_bus_attach(&usbd_driver, "USB Bus");
! 91:
! 92: /* Set up our dipatch routine. */
! 93:
! 94: usbd_driver.dro_dispatch[IRP_MJ_INTERNAL_DEVICE_CONTROL] =
! 95: (driver_dispatch)usbd_iodispatch;
! 96:
! 97: return(0);
! 98: }
! 99:
! 100: int
! 101: usbd_libfini(void)
! 102: {
! 103: image_patch_table *patch;
! 104:
! 105: patch = usbd_functbl;
! 106: while (patch->ipt_func != NULL) {
! 107: windrv_unwrap(patch->ipt_wrap);
! 108: patch++;
! 109: }
! 110:
! 111: free(usbd_driver.dro_drivername.us_buf, M_DEVBUF);
! 112:
! 113: return(0);
! 114: }
! 115:
! 116: __stdcall static uint32_t
! 117: usbd_iodispatch(dobj, ip)
! 118: device_object *dobj;
! 119: irp *ip;
! 120: {
! 121: return(0);
! 122: }
! 123:
! 124: __stdcall static void
! 125: USBD_GetUSBDIVersion(ui)
! 126: usbd_version_info *ui;
! 127: {
! 128: /* Pretend to be Windows XP. */
! 129:
! 130: ui->uvi_usbdi_vers = USBDI_VERSION;
! 131: ui->uvi_supported_vers = USB_VER_2_0;
! 132:
! 133: return;
! 134: }
! 135:
! 136: __stdcall static void
! 137: dummy(void)
! 138: {
! 139: printf("USBD dummy called\n");
! 140: return;
! 141: }
! 142:
! 143: image_patch_table usbd_functbl[] = {
! 144: IMPORT_FUNC(USBD_GetUSBDIVersion),
! 145: #ifdef notyet
! 146: IMPORT_FUNC_MAP(_USBD_ParseConfigurationDescriptorEx@28,
! 147: USBD_ParseConfigurationDescriptorEx),
! 148: IMPORT_FUNC_MAP(_USBD_CreateConfigurationRequestEx@8,
! 149: USBD_CreateConfigurationRequestEx),
! 150: #endif
! 151:
! 152: /*
! 153: * This last entry is a catch-all for any function we haven't
! 154: * implemented yet. The PE import list patching routine will
! 155: * use it for any function that doesn't have an explicit match
! 156: * in this table.
! 157: */
! 158:
! 159: { NULL, (FUNC)dummy, NULL },
! 160:
! 161: /* End of list. */
! 162:
! 163: { NULL, NULL, NULL }
! 164: };
! 165:
CVSweb <webmaster@jp.NetBSD.org>