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 __FBSDID("$FreeBSD: releng/6.0/sys/compat/ndis/subr_usbd.c 145895 2005-05-05 03:56:09Z wpaul $");
35
36 #include <sys/param.h>
37 #include <sys/systm.h>
38 #include <sys/unistd.h>
39 #include <sys/types.h>
40
41 #include <sys/kernel.h>
42 #include <sys/malloc.h>
43 #include <sys/lock.h>
44 #include <sys/mutex.h>
45 #include <sys/module.h>
46 #include <sys/conf.h>
47 #include <sys/mbuf.h>
48 #include <sys/bus.h>
49
50 #include <sys/queue.h>
51
52 #include <compat/ndis/pe_var.h>
53 #include <compat/ndis/cfg_var.h>
54 #include <compat/ndis/resource_var.h>
55 #include <compat/ndis/ntoskrnl_var.h>
56 #include <compat/ndis/ndis_var.h>
57 #include <compat/ndis/hal_var.h>
58 #include <compat/ndis/usbd_var.h>
59
60 static driver_object usbd_driver;
61
62 static uint32_t usbd_iodispatch(device_object *, irp *);
63
64 static void USBD_GetUSBDIVersion(usbd_version_info *);
65 static void dummy(void);
66
67 int
68 usbd_libinit(void)
69 {
70 image_patch_table *patch;
71
72 patch = usbd_functbl;
73 while (patch->ipt_func != NULL) {
74 windrv_wrap((funcptr)patch->ipt_func,
75 (funcptr *)&patch->ipt_wrap,
76 patch->ipt_argcnt, patch->ipt_ftype);
77 patch++;
78 }
79
80 /* Create a fake USB driver instance. */
81
82 windrv_bus_attach(&usbd_driver, "USB Bus");
83
84 /* Set up our dipatch routine. */
85
86 usbd_driver.dro_dispatch[IRP_MJ_INTERNAL_DEVICE_CONTROL] =
87 (driver_dispatch)usbd_iodispatch;
88
89 return(0);
90 }
91
92 int
93 usbd_libfini(void)
94 {
95 image_patch_table *patch;
96
97 patch = usbd_functbl;
98 while (patch->ipt_func != NULL) {
99 windrv_unwrap(patch->ipt_wrap);
100 patch++;
101 }
102
103 free(usbd_driver.dro_drivername.us_buf, M_DEVBUF);
104
105 return(0);
106 }
107
108 static uint32_t
109 usbd_iodispatch(dobj, ip)
110 device_object *dobj;
111 irp *ip;
112 {
113 return(0);
114 }
115
116 static void
117 USBD_GetUSBDIVersion(ui)
118 usbd_version_info *ui;
119 {
120 /* Pretend to be Windows XP. */
121
122 ui->uvi_usbdi_vers = USBDI_VERSION;
123 ui->uvi_supported_vers = USB_VER_2_0;
124
125 return;
126 }
127
128 static void
129 dummy(void)
130 {
131 printf("USBD dummy called\n");
132 return;
133 }
134
135 image_patch_table usbd_functbl[] = {
136 IMPORT_SFUNC(USBD_GetUSBDIVersion, 0),
137 IMPORT_SFUNC(usbd_iodispatch, 2),
138 #ifdef notyet
139 IMPORT_FUNC_MAP(_USBD_ParseConfigurationDescriptorEx@28,
140 USBD_ParseConfigurationDescriptorEx),
141 IMPORT_FUNC_MAP(_USBD_CreateConfigurationRequestEx@8,
142 USBD_CreateConfigurationRequestEx),
143 #endif
144
145 /*
146 * This last entry is a catch-all for any function we haven't
147 * implemented yet. The PE import list patching routine will
148 * use it for any function that doesn't have an explicit match
149 * in this table.
150 */
151
152 { NULL, (FUNC)dummy, NULL, 0, WINDRV_WRAP_STDCALL },
153
154 /* End of list. */
155
156 { NULL, NULL, NULL }
157 };
158
Cache object: 397eafece0df64e682022adc51a1656b
|