Deleted Added
full compact
1/* $FreeBSD: head/sys/dev/usb/usb_ioctl.h 250201 2013-05-03 07:44:58Z hselasky $ */
1/* $FreeBSD: head/sys/dev/usb/usb_ioctl.h 254243 2013-08-12 09:17:48Z hselasky $ */
2/*-
3 * Copyright (c) 2008 Hans Petter Selasky. All rights reserved.
4 * Copyright (c) 1998 The NetBSD Foundation, Inc. All rights reserved.
5 * Copyright (c) 1998 Lennart Augustsson. All rights reserved.
6 *
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
9 * are met:
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.
15 *
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
26 * SUCH DAMAGE.
27 */
28
29#ifndef _USB_IOCTL_H_
30#define _USB_IOCTL_H_
31
32#ifndef USB_GLOBAL_INCLUDE_FILE
33#include <sys/ioccom.h>
34#include <sys/cdefs.h>
35
36/* Building "kdump" depends on these includes */
37
38#include <dev/usb/usb_endian.h>
39#include <dev/usb/usb.h>
40#endif
41
42#define USB_DEVICE_NAME "usbctl"
43#define USB_DEVICE_DIR "usb"
44#define USB_GENERIC_NAME "ugen"
45#define USB_TEMPLATE_SYSCTL "hw.usb.template" /* integer type */
46
47/*
48 * Align IOCTL structures to hide differences when running 32-bit
49 * programs under 64-bit kernels:
50 */
51#ifdef COMPAT_32BIT
52#define USB_IOCTL_STRUCT_ALIGN(n) __aligned(n)
53#else
54#define USB_IOCTL_STRUCT_ALIGN(n)
55#endif
56
57/* Definition of valid template sysctl values */
58
59enum {
60 USB_TEMP_MSC, /* USB Mass Storage */
61 USB_TEMP_CDCE, /* USB CDC Ethernet */
62 USB_TEMP_MTP, /* Message Transfer Protocol */
63 USB_TEMP_MODEM, /* USB CDC Modem */
64 USB_TEMP_AUDIO, /* USB Audio */
65 USB_TEMP_KBD, /* USB Keyboard */
66 USB_TEMP_MOUSE, /* USB Mouse */
67 USB_TEMP_MAX,
68};
69
70struct usb_read_dir {
71#ifdef COMPAT_32BIT
72 uint64_t urd_data;
73#else
74 void *urd_data;
75#endif
76 uint32_t urd_startentry;
77 uint32_t urd_maxlen;
67};
78} USB_IOCTL_STRUCT_ALIGN(8);
79
80struct usb_ctl_request {
81#ifdef COMPAT_32BIT
82 uint64_t ucr_data;
83#else
84 void *ucr_data;
85#endif
86 uint16_t ucr_flags;
87 uint16_t ucr_actlen; /* actual length transferred */
88 uint8_t ucr_addr; /* zero - currently not used */
89 struct usb_device_request ucr_request;
79};
90} USB_IOCTL_STRUCT_ALIGN(8);
91
92struct usb_alt_interface {
93 uint8_t uai_interface_index;
94 uint8_t uai_alt_index;
84};
95} USB_IOCTL_STRUCT_ALIGN(1);
96
97struct usb_gen_descriptor {
98#ifdef COMPAT_32BIT
99 uint64_t ugd_data;
100#else
101 void *ugd_data;
102#endif
103 uint16_t ugd_lang_id;
104 uint16_t ugd_maxlen;
105 uint16_t ugd_actlen;
106 uint16_t ugd_offset;
107 uint8_t ugd_config_index;
108 uint8_t ugd_string_index;
109 uint8_t ugd_iface_index;
110 uint8_t ugd_altif_index;
111 uint8_t ugd_endpt_index;
112 uint8_t ugd_report_type;
113 uint8_t reserved[8];
103};
114} USB_IOCTL_STRUCT_ALIGN(8);
115
116struct usb_device_info {
117 uint16_t udi_productNo;
118 uint16_t udi_vendorNo;
119 uint16_t udi_releaseNo;
120 uint16_t udi_power; /* power consumption in mA, 0 if
121 * selfpowered */
122 uint8_t udi_bus;
123 uint8_t udi_addr; /* device address */
124 uint8_t udi_index; /* device index */
125 uint8_t udi_class;
126 uint8_t udi_subclass;
127 uint8_t udi_protocol;
128 uint8_t udi_config_no; /* current config number */
129 uint8_t udi_config_index; /* current config index */
130 uint8_t udi_speed; /* see "USB_SPEED_XXX" */
131 uint8_t udi_mode; /* see "USB_MODE_XXX" */
132 uint8_t udi_nports;
133 uint8_t udi_hubaddr; /* parent HUB address */
134 uint8_t udi_hubindex; /* parent HUB device index */
135 uint8_t udi_hubport; /* parent HUB port */
136 uint8_t udi_power_mode; /* see "USB_POWER_MODE_XXX" */
137 uint8_t udi_suspended; /* set if device is suspended */
138 uint8_t udi_reserved[16]; /* leave space for the future */
139 char udi_product[128];
140 char udi_vendor[128];
141 char udi_serial[64];
142 char udi_release[8];
132};
143} USB_IOCTL_STRUCT_ALIGN(2);
144
145#define USB_DEVICE_PORT_PATH_MAX 32
146
147struct usb_device_port_path {
148 uint8_t udp_bus; /* which bus we are on */
149 uint8_t udp_index; /* which device index */
150 uint8_t udp_port_level; /* how many levels: 0, 1, 2 ... */
151 uint8_t udp_port_no[USB_DEVICE_PORT_PATH_MAX];
141};
152} USB_IOCTL_STRUCT_ALIGN(1);
153
154struct usb_device_stats {
155 uint32_t uds_requests_ok[4]; /* Indexed by transfer type UE_XXX */
156 uint32_t uds_requests_fail[4]; /* Indexed by transfer type UE_XXX */
146};
157} USB_IOCTL_STRUCT_ALIGN(4);
158
159struct usb_fs_start {
160 uint8_t ep_index;
150};
161} USB_IOCTL_STRUCT_ALIGN(1);
162
163struct usb_fs_stop {
164 uint8_t ep_index;
154};
165} USB_IOCTL_STRUCT_ALIGN(1);
166
167struct usb_fs_complete {
168 uint8_t ep_index;
158};
169} USB_IOCTL_STRUCT_ALIGN(1);
170
171/* This structure is used for all endpoint types */
172struct usb_fs_endpoint {
173 /*
174 * NOTE: isochronous USB transfer only use one buffer, but can have
175 * multiple frame lengths !
176 */
177#ifdef COMPAT_32BIT
178 uint64_t ppBuffer;
179 uint64_t pLength;
180#else
181 void **ppBuffer; /* pointer to userland buffers */
182 uint32_t *pLength; /* pointer to frame lengths, updated
183 * to actual length */
184#endif
185 uint32_t nFrames; /* number of frames */
186 uint32_t aFrames; /* actual number of frames */
187 uint16_t flags;
188 /* a single short frame will terminate */
189#define USB_FS_FLAG_SINGLE_SHORT_OK 0x0001
190 /* multiple short frames are allowed */
191#define USB_FS_FLAG_MULTI_SHORT_OK 0x0002
192 /* all frame(s) transmitted are short terminated */
193#define USB_FS_FLAG_FORCE_SHORT 0x0004
194 /* will do a clear-stall before xfer */
195#define USB_FS_FLAG_CLEAR_STALL 0x0008
196 uint16_t timeout; /* in milliseconds */
197 /* isocronous completion time in milliseconds - used for echo cancel */
198 uint16_t isoc_time_complete;
199 /* timeout value for no timeout */
200#define USB_FS_TIMEOUT_NONE 0
201 int status; /* see USB_ERR_XXX */
191};
202} USB_IOCTL_STRUCT_ALIGN(8);
203
204struct usb_fs_init {
205 /* userland pointer to endpoints structure */
206#ifdef COMPAT_32BIT
207 uint64_t pEndpoints;
208#else
209 struct usb_fs_endpoint *pEndpoints;
210#endif
211 /* maximum number of endpoints */
212 uint8_t ep_index_max;
202};
213} USB_IOCTL_STRUCT_ALIGN(8);
214
215struct usb_fs_uninit {
216 uint8_t dummy; /* zero */
206};
217} USB_IOCTL_STRUCT_ALIGN(1);
218
219struct usb_fs_open {
220#define USB_FS_MAX_BUFSIZE (1 << 18)
221 uint32_t max_bufsize;
222#define USB_FS_MAX_FRAMES (1U << 12)
223#define USB_FS_MAX_FRAMES_PRE_SCALE (1U << 31) /* for ISOCHRONOUS transfers */
224 uint32_t max_frames; /* read and write */
225 uint16_t max_packet_length; /* read only */
226 uint8_t dev_index; /* currently unused */
227 uint8_t ep_index;
228 uint8_t ep_no; /* bEndpointNumber */
218};
229} USB_IOCTL_STRUCT_ALIGN(4);
230
231struct usb_fs_open_stream {
232 struct usb_fs_open fs_open;
222 uint16_t stream_id;
223};
233 uint16_t stream_id; /* stream ID */
234} USB_IOCTL_STRUCT_ALIGN(4);
235
236struct usb_fs_close {
237 uint8_t ep_index;
227};
238} USB_IOCTL_STRUCT_ALIGN(1);
239
240struct usb_fs_clear_stall_sync {
241 uint8_t ep_index;
231};
242} USB_IOCTL_STRUCT_ALIGN(1);
243
244struct usb_gen_quirk {
245 uint16_t index; /* Quirk Index */
246 uint16_t vid; /* Vendor ID */
247 uint16_t pid; /* Product ID */
248 uint16_t bcdDeviceLow; /* Low Device Revision */
249 uint16_t bcdDeviceHigh; /* High Device Revision */
250 uint16_t reserved[2];
251 /*
241 * String version of quirk including terminating zero. See UQ_XXX in
242 * "usb_quirk.h".
252 * String version of quirk including terminating zero. See
253 * UQ_XXX in "usb_quirk.h".
254 */
255 char quirkname[64 - 14];
245};
256} USB_IOCTL_STRUCT_ALIGN(2);
257
258/* USB controller */
259#define USB_REQUEST _IOWR('U', 1, struct usb_ctl_request)
260#define USB_SETDEBUG _IOW ('U', 2, int)
261#define USB_DISCOVER _IO ('U', 3)
262#define USB_DEVICEINFO _IOWR('U', 4, struct usb_device_info)
263#define USB_DEVICESTATS _IOR ('U', 5, struct usb_device_stats)
264#define USB_DEVICEENUMERATE _IOW ('U', 6, int)
265
266/* Generic HID device */
267#define USB_GET_REPORT_DESC _IOWR('U', 21, struct usb_gen_descriptor)
268#define USB_SET_IMMED _IOW ('U', 22, int)
269#define USB_GET_REPORT _IOWR('U', 23, struct usb_gen_descriptor)
270#define USB_SET_REPORT _IOW ('U', 24, struct usb_gen_descriptor)
271#define USB_GET_REPORT_ID _IOR ('U', 25, int)
272
273/* Generic USB device */
274#define USB_GET_CONFIG _IOR ('U', 100, int)
275#define USB_SET_CONFIG _IOW ('U', 101, int)
276#define USB_GET_ALTINTERFACE _IOWR('U', 102, struct usb_alt_interface)
277#define USB_SET_ALTINTERFACE _IOWR('U', 103, struct usb_alt_interface)
278#define USB_GET_DEVICE_DESC _IOR ('U', 105, struct usb_device_descriptor)
279#define USB_GET_CONFIG_DESC _IOR ('U', 106, struct usb_config_descriptor)
280#define USB_GET_RX_INTERFACE_DESC _IOR ('U', 107, struct usb_interface_descriptor)
281#define USB_GET_RX_ENDPOINT_DESC _IOR ('U', 108, struct usb_endpoint_descriptor)
282#define USB_GET_FULL_DESC _IOWR('U', 109, struct usb_gen_descriptor)
283#define USB_GET_STRING_DESC _IOWR('U', 110, struct usb_gen_descriptor)
284#define USB_DO_REQUEST _IOWR('U', 111, struct usb_ctl_request)
285#define USB_GET_DEVICEINFO _IOR ('U', 112, struct usb_device_info)
286#define USB_SET_RX_SHORT_XFER _IOW ('U', 113, int)
287#define USB_SET_RX_TIMEOUT _IOW ('U', 114, int)
288#define USB_GET_RX_FRAME_SIZE _IOR ('U', 115, int)
289#define USB_GET_RX_BUFFER_SIZE _IOR ('U', 117, int)
290#define USB_SET_RX_BUFFER_SIZE _IOW ('U', 118, int)
291#define USB_SET_RX_STALL_FLAG _IOW ('U', 119, int)
292#define USB_SET_TX_STALL_FLAG _IOW ('U', 120, int)
293#define USB_GET_IFACE_DRIVER _IOWR('U', 121, struct usb_gen_descriptor)
294#define USB_CLAIM_INTERFACE _IOW ('U', 122, int)
295#define USB_RELEASE_INTERFACE _IOW ('U', 123, int)
296#define USB_IFACE_DRIVER_ACTIVE _IOW ('U', 124, int)
297#define USB_IFACE_DRIVER_DETACH _IOW ('U', 125, int)
298#define USB_GET_PLUGTIME _IOR ('U', 126, uint32_t)
299#define USB_READ_DIR _IOW ('U', 127, struct usb_read_dir)
300/* 128 - 133 unused */
301#define USB_GET_DEV_PORT_PATH _IOR ('U', 134, struct usb_device_port_path)
302#define USB_GET_POWER_USAGE _IOR ('U', 135, int)
303#define USB_SET_TX_FORCE_SHORT _IOW ('U', 136, int)
304#define USB_SET_TX_TIMEOUT _IOW ('U', 137, int)
305#define USB_GET_TX_FRAME_SIZE _IOR ('U', 138, int)
306#define USB_GET_TX_BUFFER_SIZE _IOR ('U', 139, int)
307#define USB_SET_TX_BUFFER_SIZE _IOW ('U', 140, int)
308#define USB_GET_TX_INTERFACE_DESC _IOR ('U', 141, struct usb_interface_descriptor)
309#define USB_GET_TX_ENDPOINT_DESC _IOR ('U', 142, struct usb_endpoint_descriptor)
310#define USB_SET_PORT_ENABLE _IOW ('U', 143, int)
311#define USB_SET_PORT_DISABLE _IOW ('U', 144, int)
312#define USB_SET_POWER_MODE _IOW ('U', 145, int)
313#define USB_GET_POWER_MODE _IOR ('U', 146, int)
314#define USB_SET_TEMPLATE _IOW ('U', 147, int)
315#define USB_GET_TEMPLATE _IOR ('U', 148, int)
316
317/* Modem device */
318#define USB_GET_CM_OVER_DATA _IOR ('U', 180, int)
319#define USB_SET_CM_OVER_DATA _IOW ('U', 181, int)
320
321/* GPIO control */
322#define USB_GET_GPIO _IOR ('U', 182, int)
323#define USB_SET_GPIO _IOW ('U', 183, int)
324
325/* USB file system interface */
326#define USB_FS_START _IOW ('U', 192, struct usb_fs_start)
327#define USB_FS_STOP _IOW ('U', 193, struct usb_fs_stop)
328#define USB_FS_COMPLETE _IOR ('U', 194, struct usb_fs_complete)
329#define USB_FS_INIT _IOW ('U', 195, struct usb_fs_init)
330#define USB_FS_UNINIT _IOW ('U', 196, struct usb_fs_uninit)
331#define USB_FS_OPEN _IOWR('U', 197, struct usb_fs_open)
332#define USB_FS_CLOSE _IOW ('U', 198, struct usb_fs_close)
333#define USB_FS_CLEAR_STALL_SYNC _IOW ('U', 199, struct usb_fs_clear_stall_sync)
334#define USB_FS_OPEN_STREAM _IOWR('U', 200, struct usb_fs_open_stream)
335
336/* USB quirk system interface */
337#define USB_DEV_QUIRK_GET _IOWR('Q', 0, struct usb_gen_quirk)
338#define USB_QUIRK_NAME_GET _IOWR('Q', 1, struct usb_gen_quirk)
339#define USB_DEV_QUIRK_ADD _IOW ('Q', 2, struct usb_gen_quirk)
340#define USB_DEV_QUIRK_REMOVE _IOW ('Q', 3, struct usb_gen_quirk)
341
342#endif /* _USB_IOCTL_H_ */