No empty .Rs/.Re
[netbsd-mini2440.git] / sys / compat / ndis / subr_usbd.c
blobcc6ee015a149bed1cd2cd89e6052356f5da8d8bb
1 /*-
2 * Copyright (c) 2005
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
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.
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 #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: subr_usbd.c,v 1.5 2007/12/11 23:32:44 lukem Exp $");
39 #endif
41 #include <sys/param.h>
42 #include <sys/systm.h>
43 #include <sys/unistd.h>
44 #include <sys/types.h>
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
59 #include <sys/queue.h>
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>
69 static driver_object usbd_driver;
71 __stdcall static uint32_t usbd_iodispatch(device_object *, irp *);
73 __stdcall static void USBD_GetUSBDIVersion(usbd_version_info *);
74 __stdcall static void dummy(void);
76 int
77 usbd_libinit(void)
79 image_patch_table *patch;
81 patch = usbd_functbl;
82 while (patch->ipt_func != NULL) {
83 windrv_wrap((funcptr)patch->ipt_func,
84 (funcptr *)&patch->ipt_wrap);
85 patch++;
88 /* Create a fake USB driver instance. */
90 windrv_bus_attach(&usbd_driver, "USB Bus");
92 /* Set up our dipatch routine. */
94 usbd_driver.dro_dispatch[IRP_MJ_INTERNAL_DEVICE_CONTROL] =
95 (driver_dispatch)usbd_iodispatch;
97 return(0);
101 usbd_libfini(void)
103 image_patch_table *patch;
105 patch = usbd_functbl;
106 while (patch->ipt_func != NULL) {
107 windrv_unwrap(patch->ipt_wrap);
108 patch++;
111 free(usbd_driver.dro_drivername.us_buf, M_DEVBUF);
113 return(0);
116 __stdcall static uint32_t
117 usbd_iodispatch(
118 device_object *dobj,
119 irp *ip)
121 return(0);
124 __stdcall static void
125 USBD_GetUSBDIVersion(usbd_version_info *ui)
127 /* Pretend to be Windows XP. */
129 ui->uvi_usbdi_vers = USBDI_VERSION;
130 ui->uvi_supported_vers = USB_VER_2_0;
132 return;
135 __stdcall static void
136 dummy(void)
138 printf("USBD dummy called\n");
139 return;
142 image_patch_table usbd_functbl[] = {
143 IMPORT_FUNC(USBD_GetUSBDIVersion),
144 #ifdef notyet
145 IMPORT_FUNC_MAP(_USBD_ParseConfigurationDescriptorEx@28,
146 USBD_ParseConfigurationDescriptorEx),
147 IMPORT_FUNC_MAP(_USBD_CreateConfigurationRequestEx@8,
148 USBD_CreateConfigurationRequestEx),
149 #endif
152 * This last entry is a catch-all for any function we haven't
153 * implemented yet. The PE import list patching routine will
154 * use it for any function that doesn't have an explicit match
155 * in this table.
158 { NULL, (FUNC)dummy, NULL },
160 /* End of list. */
162 { NULL, NULL, NULL }