3 * SPDX-License-Identifier: BSD-2-Clause-FreeBSD
5 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
10 * 1. Redistributions of source code must retain the above copyright
11 * notice, this list of conditions and the following disclaimer.
12 * 2. Redistributions in binary form must reproduce the above copyright
13 * notice, this list of conditions and the following disclaimer in the
14 * documentation and/or other materials provided with the distribution.
16 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29 #ifdef USB_GLOBAL_INCLUDE_FILE
30 #include USB_GLOBAL_INCLUDE_FILE
32 #include <sys/stdint.h>
33 #include <sys/stddef.h>
34 #include <sys/param.h>
35 #include <sys/queue.h>
36 #include <sys/types.h>
37 #include <sys/systm.h>
38 #include <sys/kernel.h>
40 #include <sys/module.h>
42 #include <sys/mutex.h>
43 #include <sys/condvar.h>
44 #include <sys/sysctl.h>
46 #include <sys/unistd.h>
47 #include <sys/callout.h>
48 #include <sys/malloc.h>
51 #include <dev/usb/usb.h>
52 #include <dev/usb/usbdi.h>
54 #include <dev/usb/usb_core.h>
55 #include <dev/usb/usb_process.h>
56 #include <dev/usb/usb_device.h>
57 #include <dev/usb/usb_dynamic.h>
58 #include <dev/usb/usb_request.h>
59 #endif /* USB_GLOBAL_INCLUDE_FILE */
61 /* function prototypes */
62 static usb_handle_req_t usb_temp_get_desc_w;
63 static usb_temp_setup_by_index_t usb_temp_setup_by_index_w;
64 #if USB_HAVE_COMPAT_LINUX
65 static usb_linux_free_device_t usb_linux_free_device_w;
67 static usb_temp_unsetup_t usb_temp_unsetup_w;
68 static usb_test_quirk_t usb_test_quirk_w;
69 static usb_quirk_ioctl_t usb_quirk_ioctl_w;
71 /* global variables */
72 usb_handle_req_t *usb_temp_get_desc_p = &usb_temp_get_desc_w;
73 usb_temp_setup_by_index_t *usb_temp_setup_by_index_p = &usb_temp_setup_by_index_w;
74 #if USB_HAVE_COMPAT_LINUX
75 usb_linux_free_device_t *usb_linux_free_device_p = &usb_linux_free_device_w;
77 usb_temp_unsetup_t *usb_temp_unsetup_p = &usb_temp_unsetup_w;
78 usb_test_quirk_t *usb_test_quirk_p = &usb_test_quirk_w;
79 usb_quirk_ioctl_t *usb_quirk_ioctl_p = &usb_quirk_ioctl_w;
80 devclass_t usb_devclass_ptr;
83 usb_temp_setup_by_index_w(struct usb_device *udev, uint16_t index)
85 return (USB_ERR_INVAL);
89 usb_test_quirk_w(const struct usbd_lookup_info *info, uint16_t quirk)
91 return (0); /* no match */
95 usb_quirk_ioctl_w(unsigned long cmd, caddr_t data, int fflag, struct thread *td)
101 usb_temp_get_desc_w(struct usb_device *udev, struct usb_device_request *req, const void **pPtr, uint16_t *pLength)
104 return (USB_ERR_STALLED);
108 usb_temp_unsetup_w(struct usb_device *udev)
110 usbd_free_config_desc(udev, udev->usb_template_ptr);
111 udev->usb_template_ptr = NULL;
114 #if USB_HAVE_COMPAT_LINUX
116 usb_linux_free_device_w(struct usb_device *udev)
123 usb_quirk_unload(void *arg)
125 /* reset function pointers */
127 usb_test_quirk_p = &usb_test_quirk_w;
128 usb_quirk_ioctl_p = &usb_quirk_ioctl_w;
130 /* wait for CPU to exit the loaded functions, if any */
132 /* XXX this is a tradeoff */
138 usb_temp_unload(void *arg)
140 /* reset function pointers */
142 usb_temp_get_desc_p = &usb_temp_get_desc_w;
143 usb_temp_setup_by_index_p = &usb_temp_setup_by_index_w;
144 usb_temp_unsetup_p = &usb_temp_unsetup_w;
146 /* wait for CPU to exit the loaded functions, if any */
148 /* XXX this is a tradeoff */
154 usb_bus_unload(void *arg)
156 /* reset function pointers */
158 usb_devclass_ptr = NULL;
160 /* wait for CPU to exit the loaded functions, if any */
162 /* XXX this is a tradeoff */
167 #if USB_HAVE_COMPAT_LINUX
169 usb_linux_unload(void *arg)
171 /* reset function pointers */
173 usb_linux_free_device_p = &usb_linux_free_device_w;
175 /* wait for CPU to exit the loaded functions, if any */
177 /* XXX this is a tradeoff */