xref: /freebsd/tools/tools/usbtest/usbtest.h (revision 2a63c3be158216222d89a073dcbd6a72ee4aab5a)
18030839bSHans Petter Selasky /*-
2*16346e14SHans Petter Selasky  * Copyright (c) 2010-2022 Hans Petter Selasky
38030839bSHans Petter Selasky  *
48030839bSHans Petter Selasky  * Redistribution and use in source and binary forms, with or without
58030839bSHans Petter Selasky  * modification, are permitted provided that the following conditions
68030839bSHans Petter Selasky  * are met:
78030839bSHans Petter Selasky  * 1. Redistributions of source code must retain the above copyright
88030839bSHans Petter Selasky  *    notice, this list of conditions and the following disclaimer.
98030839bSHans Petter Selasky  * 2. Redistributions in binary form must reproduce the above copyright
108030839bSHans Petter Selasky  *    notice, this list of conditions and the following disclaimer in the
118030839bSHans Petter Selasky  *    documentation and/or other materials provided with the distribution.
128030839bSHans Petter Selasky  *
138030839bSHans Petter Selasky  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
148030839bSHans Petter Selasky  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
158030839bSHans Petter Selasky  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
168030839bSHans Petter Selasky  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
178030839bSHans Petter Selasky  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
188030839bSHans Petter Selasky  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
198030839bSHans Petter Selasky  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
208030839bSHans Petter Selasky  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
218030839bSHans Petter Selasky  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
228030839bSHans Petter Selasky  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
238030839bSHans Petter Selasky  * SUCH DAMAGE.
248030839bSHans Petter Selasky  */
258030839bSHans Petter Selasky 
268030839bSHans Petter Selasky #ifndef _USBTEST_H_
278030839bSHans Petter Selasky #define	_USBTEST_H_
288030839bSHans Petter Selasky 
298030839bSHans Petter Selasky #define	USB_DEVICES_MAX		128
308030839bSHans Petter Selasky #define	USB_TS_MAX_LEVELS	8
318030839bSHans Petter Selasky 
328030839bSHans Petter Selasky struct libusb20_device;
338030839bSHans Petter Selasky 
348030839bSHans Petter Selasky struct bps {
358030839bSHans Petter Selasky 	uint32_t bytes;
368030839bSHans Petter Selasky 	time_t	time;
378030839bSHans Petter Selasky };
388030839bSHans Petter Selasky 
39*16346e14SHans Petter Selasky struct uaddr {
40*16346e14SHans Petter Selasky 	uint16_t vid;
41*16346e14SHans Petter Selasky 	uint16_t pid;
42*16346e14SHans Petter Selasky 	uint8_t bus;
43*16346e14SHans Petter Selasky 	uint8_t addr;
44*16346e14SHans Petter Selasky };
458030839bSHans Petter Selasky 
46*16346e14SHans Petter Selasky extern void usb_get_string_desc_test(struct uaddr);
47*16346e14SHans Petter Selasky extern void usb_port_reset_test(struct uaddr, uint32_t);
48*16346e14SHans Petter Selasky extern void usb_set_config_test(struct uaddr, uint32_t);
49*16346e14SHans Petter Selasky extern void usb_get_descriptor_test(struct uaddr, uint32_t);
50*16346e14SHans Petter Selasky extern void usb_control_ep_error_test(struct uaddr);
51*16346e14SHans Petter Selasky extern void usb_set_and_clear_stall_test(struct uaddr);
52*16346e14SHans Petter Selasky extern void usb_set_alt_interface_test(struct uaddr);
53*16346e14SHans Petter Selasky 
54*16346e14SHans Petter Selasky extern void usb_suspend_resume_test(struct uaddr, uint32_t);
558030839bSHans Petter Selasky extern void do_bps(const char *, struct bps *, uint32_t len);
568030839bSHans Petter Selasky extern const char *indent[USB_TS_MAX_LEVELS];
57*16346e14SHans Petter Selasky extern void show_host_msc_test(uint8_t, struct uaddr, uint32_t);
58*16346e14SHans Petter Selasky extern void show_host_modem_test(uint8_t, struct uaddr, uint32_t);
59*16346e14SHans Petter Selasky extern void show_host_device_selection(uint8_t, struct uaddr *);
60*16346e14SHans Petter Selasky extern struct libusb20_device *find_usb_device(struct uaddr);
618030839bSHans Petter Selasky extern void find_usb_endpoints(struct libusb20_device *, uint8_t, uint8_t,
628030839bSHans Petter Selasky     uint8_t, uint8_t, uint8_t *, uint8_t *, uint8_t *, uint8_t);
638030839bSHans Petter Selasky extern void get_string(char *, int);
648030839bSHans Petter Selasky extern int get_integer(void);
658030839bSHans Petter Selasky extern uint8_t usb_ts_show_menu(uint8_t, const char *, const char *,...);
668030839bSHans Petter Selasky extern int32_t usb_ts_rand_noise(void);
678030839bSHans Petter Selasky 
688030839bSHans Petter Selasky #endif				/* _USBTEST_H_ */
69