xref: /freebsd/tools/tools/usbtest/usbtest.h (revision a64729f5077d77e13b9497cb33ecb3c82e606ee8)
1 /*-
2  * Copyright (c) 2010-2022 Hans Petter Selasky
3  *
4  * Redistribution and use in source and binary forms, with or without
5  * modification, are permitted provided that the following conditions
6  * are met:
7  * 1. Redistributions of source code must retain the above copyright
8  *    notice, this list of conditions and the following disclaimer.
9  * 2. Redistributions in binary form must reproduce the above copyright
10  *    notice, this list of conditions and the following disclaimer in the
11  *    documentation and/or other materials provided with the distribution.
12  *
13  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
14  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
16  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
17  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
19  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
20  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
21  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
22  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
23  * SUCH DAMAGE.
24  */
25 
26 #ifndef _USBTEST_H_
27 #define	_USBTEST_H_
28 
29 #define	USB_DEVICES_MAX		128
30 #define	USB_TS_MAX_LEVELS	8
31 
32 struct libusb20_device;
33 
34 struct bps {
35 	uint32_t bytes;
36 	time_t	time;
37 };
38 
39 struct uaddr {
40 	uint16_t vid;
41 	uint16_t pid;
42 	uint8_t bus;
43 	uint8_t addr;
44 };
45 
46 extern void usb_get_string_desc_test(struct uaddr);
47 extern void usb_port_reset_test(struct uaddr, uint32_t);
48 extern void usb_set_config_test(struct uaddr, uint32_t);
49 extern void usb_get_descriptor_test(struct uaddr, uint32_t);
50 extern void usb_control_ep_error_test(struct uaddr);
51 extern void usb_set_and_clear_stall_test(struct uaddr);
52 extern void usb_set_alt_interface_test(struct uaddr);
53 
54 extern void usb_suspend_resume_test(struct uaddr, uint32_t);
55 extern void do_bps(const char *, struct bps *, uint32_t len);
56 extern const char *indent[USB_TS_MAX_LEVELS];
57 extern void show_host_msc_test(uint8_t, struct uaddr, uint32_t);
58 extern void show_host_modem_test(uint8_t, struct uaddr, uint32_t);
59 extern void show_host_device_selection(uint8_t, struct uaddr *);
60 extern struct libusb20_device *find_usb_device(struct uaddr);
61 extern void find_usb_endpoints(struct libusb20_device *, uint8_t, uint8_t,
62     uint8_t, uint8_t, uint8_t *, uint8_t *, uint8_t *, uint8_t);
63 extern void get_string(char *, int);
64 extern int get_integer(void);
65 extern uint8_t usb_ts_show_menu(uint8_t, const char *, const char *,...);
66 extern int32_t usb_ts_rand_noise(void);
67 
68 #endif				/* _USBTEST_H_ */
69