2 * Copyright (c) 1998 The NetBSD Foundation, Inc.
5 * This code is derived from software contributed to The NetBSD Foundation
6 * by Lennart Augustsson (lennart@augustsson.net) at
7 * Carlstedt Research & Technology.
9 * Redistribution and use in source and binary forms, with or without
10 * modification, are permitted provided that the following conditions
12 * 1. Redistributions of source code must retain the above copyright
13 * notice, this list of conditions and the following disclaimer.
14 * 2. Redistributions in binary form must reproduce the above copyright
15 * notice, this list of conditions and the following disclaimer in the
16 * documentation and/or other materials provided with the distribution.
17 * 3. All advertising materials mentioning features or use of this software
18 * must display the following acknowledgement:
19 * This product includes software developed by the NetBSD
20 * Foundation, Inc. and its contributors.
21 * 4. Neither the name of The NetBSD Foundation nor the names of its
22 * contributors may be used to endorse or promote products derived
23 * from this software without specific prior written permission.
25 * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
26 * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
27 * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
28 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
29 * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
30 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
31 * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
32 * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
33 * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
34 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
35 * POSSIBILITY OF SUCH DAMAGE.
38 /* Modified by Synopsys, Inc, 12/12/2007 */
49 * The USB records contain some unaligned little-endian word
50 * components. The U[SG]ETW macros take care of both the alignment
51 * and endian problem and should always be used to access non-byte
54 typedef u_int8_t uByte;
55 typedef u_int8_t uWord[2];
56 typedef u_int8_t uDWord[4];
58 #define USETW2(w,h,l) ((w)[0] = (u_int8_t)(l), (w)[1] = (u_int8_t)(h))
59 #define UCONSTW(x) { (x) & 0xff, ((x) >> 8) & 0xff }
60 #define UCONSTDW(x) { (x) & 0xff, ((x) >> 8) & 0xff, \
61 ((x) >> 16) & 0xff, ((x) >> 24) & 0xff }
64 #define UGETW(w) ((w)[0] | ((w)[1] << 8))
65 #define USETW(w,v) ((w)[0] = (u_int8_t)(v), (w)[1] = (u_int8_t)((v) >> 8))
66 #define UGETDW(w) ((w)[0] | ((w)[1] << 8) | ((w)[2] << 16) | ((w)[3] << 24))
67 #define USETDW(w,v) ((w)[0] = (u_int8_t)(v), \
68 (w)[1] = (u_int8_t)((v) >> 8), \
69 (w)[2] = (u_int8_t)((v) >> 16), \
70 (w)[3] = (u_int8_t)((v) >> 24))
73 * On little-endian machines that can handle unanliged accesses
74 * (e.g. i386) these macros can be replaced by the following.
76 #define UGETW(w) (*(u_int16_t *)(w))
77 #define USETW(w,v) (*(u_int16_t *)(w) = (v))
78 #define UGETDW(w) (*(u_int32_t *)(w))
79 #define USETDW(w,v) (*(u_int32_t *)(w) = (v))
83 * Macros for accessing UAS IU fields, which are big-endian
85 #define IUSETW2(w,h,l) ((w)[0] = (u_int8_t)(h), (w)[1] = (u_int8_t)(l))
86 #define IUCONSTW(x) { ((x) >> 8) & 0xff, (x) & 0xff }
87 #define IUCONSTDW(x) { ((x) >> 24) & 0xff, ((x) >> 16) & 0xff, \
88 ((x) >> 8) & 0xff, (x) & 0xff }
89 #define IUGETW(w) (((w)[0] << 8) | (w)[1])
90 #define IUSETW(w,v) ((w)[0] = (u_int8_t)((v) >> 8), (w)[1] = (u_int8_t)(v))
91 #define IUGETDW(w) (((w)[0] << 24) | ((w)[1] << 16) | ((w)[2] << 8) | (w)[3])
92 #define IUSETDW(w,v) ((w)[0] = (u_int8_t)((v) >> 24), \
93 (w)[1] = (u_int8_t)((v) >> 16), \
94 (w)[2] = (u_int8_t)((v) >> 8), \
95 (w)[3] = (u_int8_t)(v))
97 #define UPACKED __attribute__((__packed__))
105 } UPACKED usb_device_request_t;
107 #define UT_GET_DIR(a) ((a) & 0x80)
108 #define UT_WRITE 0x00
111 #define UT_GET_TYPE(a) ((a) & 0x60)
112 #define UT_STANDARD 0x00
113 #define UT_CLASS 0x20
114 #define UT_VENDOR 0x40
116 #define UT_GET_RECIPIENT(a) ((a) & 0x1f)
117 #define UT_DEVICE 0x00
118 #define UT_INTERFACE 0x01
119 #define UT_ENDPOINT 0x02
120 #define UT_OTHER 0x03
122 #define UT_READ_DEVICE (UT_READ | UT_STANDARD | UT_DEVICE)
123 #define UT_READ_INTERFACE (UT_READ | UT_STANDARD | UT_INTERFACE)
124 #define UT_READ_ENDPOINT (UT_READ | UT_STANDARD | UT_ENDPOINT)
125 #define UT_WRITE_DEVICE (UT_WRITE | UT_STANDARD | UT_DEVICE)
126 #define UT_WRITE_INTERFACE (UT_WRITE | UT_STANDARD | UT_INTERFACE)
127 #define UT_WRITE_ENDPOINT (UT_WRITE | UT_STANDARD | UT_ENDPOINT)
128 #define UT_READ_CLASS_DEVICE (UT_READ | UT_CLASS | UT_DEVICE)
129 #define UT_READ_CLASS_INTERFACE (UT_READ | UT_CLASS | UT_INTERFACE)
130 #define UT_READ_CLASS_OTHER (UT_READ | UT_CLASS | UT_OTHER)
131 #define UT_READ_CLASS_ENDPOINT (UT_READ | UT_CLASS | UT_ENDPOINT)
132 #define UT_WRITE_CLASS_DEVICE (UT_WRITE | UT_CLASS | UT_DEVICE)
133 #define UT_WRITE_CLASS_INTERFACE (UT_WRITE | UT_CLASS | UT_INTERFACE)
134 #define UT_WRITE_CLASS_OTHER (UT_WRITE | UT_CLASS | UT_OTHER)
135 #define UT_WRITE_CLASS_ENDPOINT (UT_WRITE | UT_CLASS | UT_ENDPOINT)
136 #define UT_READ_VENDOR_DEVICE (UT_READ | UT_VENDOR | UT_DEVICE)
137 #define UT_READ_VENDOR_INTERFACE (UT_READ | UT_VENDOR | UT_INTERFACE)
138 #define UT_READ_VENDOR_OTHER (UT_READ | UT_VENDOR | UT_OTHER)
139 #define UT_READ_VENDOR_ENDPOINT (UT_READ | UT_VENDOR | UT_ENDPOINT)
140 #define UT_WRITE_VENDOR_DEVICE (UT_WRITE | UT_VENDOR | UT_DEVICE)
141 #define UT_WRITE_VENDOR_INTERFACE (UT_WRITE | UT_VENDOR | UT_INTERFACE)
142 #define UT_WRITE_VENDOR_OTHER (UT_WRITE | UT_VENDOR | UT_OTHER)
143 #define UT_WRITE_VENDOR_ENDPOINT (UT_WRITE | UT_VENDOR | UT_ENDPOINT)
146 #define UR_GET_STATUS 0x00
147 #define USTAT_STANDARD_STATUS 0x00
148 #define WUSTAT_WUSB_FEATURE 0x01
149 #define WUSTAT_CHANNEL_INFO 0x02
150 #define WUSTAT_RECEIVED_DATA 0x03
151 #define WUSTAT_MAS_AVAILABILITY 0x04
152 #define WUSTAT_CURRENT_TRANSMIT_POWER 0x05
153 #define UR_CLEAR_FEATURE 0x01
154 #define UR_SET_FEATURE 0x03
155 #define UR_SET_AND_TEST_FEATURE 0x0c
156 #define UR_SET_ADDRESS 0x05
157 #define UR_GET_DESCRIPTOR 0x06
158 #define UDESC_DEVICE 0x01
159 #define UDESC_CONFIG 0x02
160 #define UDESC_STRING 0x03
161 #define UDESC_INTERFACE 0x04
162 #define UDESC_ENDPOINT 0x05
163 #define UDESC_SS_USB_COMPANION 0x30
164 #define UDESC_DEVICE_QUALIFIER 0x06
165 #define UDESC_OTHER_SPEED_CONFIGURATION 0x07
166 #define UDESC_INTERFACE_POWER 0x08
167 #define UDESC_OTG 0x09
168 #define WUDESC_SECURITY 0x0c
169 #define WUDESC_KEY 0x0d
170 #define WUD_GET_KEY_INDEX(_wValue_) ((_wValue_) & 0xf)
171 #define WUD_GET_KEY_TYPE(_wValue_) (((_wValue_) & 0x30) >> 4)
172 #define WUD_KEY_TYPE_ASSOC 0x01
173 #define WUD_KEY_TYPE_GTK 0x02
174 #define WUD_GET_KEY_ORIGIN(_wValue_) (((_wValue_) & 0x40) >> 6)
175 #define WUD_KEY_ORIGIN_HOST 0x00
176 #define WUD_KEY_ORIGIN_DEVICE 0x01
177 #define WUDESC_ENCRYPTION_TYPE 0x0e
178 #define WUDESC_BOS 0x0f
179 #define WUDESC_DEVICE_CAPABILITY 0x10
180 #define WUDESC_WIRELESS_ENDPOINT_COMPANION 0x11
181 #define UDESC_BOS 0x0f
182 #define UDESC_DEVICE_CAPABILITY 0x10
183 #define UDESC_CS_DEVICE 0x21 /* class specific */
184 #define UDESC_CS_CONFIG 0x22
185 #define UDESC_CS_STRING 0x23
186 #define UDESC_CS_INTERFACE 0x24
187 #define UDESC_CS_ENDPOINT 0x25
188 #define UDESC_HUB 0x29
189 #define UR_SET_DESCRIPTOR 0x07
190 #define UR_GET_CONFIG 0x08
191 #define UR_SET_CONFIG 0x09
192 #define UR_GET_INTERFACE 0x0a
193 #define UR_SET_INTERFACE 0x0b
194 #define UR_SYNCH_FRAME 0x0c
195 #define WUR_SET_ENCRYPTION 0x0d
196 #define WUR_GET_ENCRYPTION 0x0e
197 #define WUR_SET_HANDSHAKE 0x0f
198 #define WUR_GET_HANDSHAKE 0x10
199 #define WUR_SET_CONNECTION 0x11
200 #define WUR_SET_SECURITY_DATA 0x12
201 #define WUR_GET_SECURITY_DATA 0x13
202 #define WUR_SET_WUSB_DATA 0x14
203 #define WUDATA_DRPIE_INFO 0x01
204 #define WUDATA_TRANSMIT_DATA 0x02
205 #define WUDATA_TRANSMIT_PARAMS 0x03
206 #define WUDATA_RECEIVE_PARAMS 0x04
207 #define WUDATA_TRANSMIT_POWER 0x05
208 #define WUR_LOOPBACK_DATA_WRITE 0x15
209 #define WUR_LOOPBACK_DATA_READ 0x16
210 #define WUR_SET_INTERFACE_DS 0x17
212 /* Feature numbers */
213 #define UF_ENDPOINT_HALT 0
214 #define UF_DEVICE_REMOTE_WAKEUP 1
215 #define UF_TEST_MODE 2
216 #define UF_DEVICE_B_HNP_ENABLE 3
217 #define UF_DEVICE_A_HNP_SUPPORT 4
218 #define UF_DEVICE_A_ALT_HNP_SUPPORT 5
220 #define WUF_TX_DRPIE 0x0
221 #define WUF_DEV_XMIT_PACKET 0x1
222 #define WUF_COUNT_PACKETS 0x2
223 #define WUF_CAPTURE_PACKETS 0x3
224 #define UF_FUNCTION_SUSPEND 0
225 #define UF_U1_ENABLE 48
226 #define UF_U2_ENABLE 49
227 #define UF_LTM_ENABLE 50
229 /* Class requests from the USB 2.0 hub spec, table 11-15 */
230 #define UCR_CLEAR_HUB_FEATURE (0x2000 | UR_CLEAR_FEATURE)
231 #define UCR_CLEAR_PORT_FEATURE (0x2300 | UR_CLEAR_FEATURE)
232 #define UCR_GET_HUB_DESCRIPTOR (0xa000 | UR_GET_DESCRIPTOR)
233 #define UCR_GET_HUB_STATUS (0xa000 | UR_GET_STATUS)
234 #define UCR_GET_PORT_STATUS (0xa300 | UR_GET_STATUS)
235 #define UCR_SET_HUB_FEATURE (0x2000 | UR_SET_FEATURE)
236 #define UCR_SET_PORT_FEATURE (0x2300 | UR_SET_FEATURE)
237 #define UCR_SET_AND_TEST_PORT_FEATURE (0xa300 | UR_SET_AND_TEST_FEATURE)
240 #include <pshpack1.h>
245 uByte bDescriptorType;
246 uByte bDescriptorSubtype;
247 } UPACKED usb_descriptor_t;
251 uByte bDescriptorType;
252 } UPACKED usb_descriptor_header_t;
256 uByte bDescriptorType;
258 #define UD_USB_2_0 0x0200
259 #define UD_IS_USB2(d) (UGETW((d)->bcdUSB) >= UD_USB_2_0)
261 uByte bDeviceSubClass;
262 uByte bDeviceProtocol;
263 uByte bMaxPacketSize;
264 /* The fields below are not part of the initial descriptor. */
271 uByte bNumConfigurations;
272 } UPACKED usb_device_descriptor_t;
273 #define USB_DEVICE_DESCRIPTOR_SIZE 18
277 uByte bDescriptorType;
280 uByte bConfigurationValue;
281 uByte iConfiguration;
282 #define UC_ATT_ONE (1 << 7) /* must be set */
283 #define UC_ATT_SELFPOWER (1 << 6) /* self powered */
284 #define UC_ATT_WAKEUP (1 << 5) /* can wakeup */
285 #define UC_ATT_BATTERY (1 << 4) /* battery powered */
287 #define UC_BUS_POWERED 0x80
288 #define UC_SELF_POWERED 0x40
289 #define UC_REMOTE_WAKEUP 0x20
290 uByte bMaxPower; /* max current in 2 mA units */
291 #define UC_POWER_FACTOR 2
292 } UPACKED usb_config_descriptor_t;
293 #define USB_CONFIG_DESCRIPTOR_SIZE 9
297 uByte bDescriptorType;
298 uByte bInterfaceNumber;
299 uByte bAlternateSetting;
301 uByte bInterfaceClass;
302 uByte bInterfaceSubClass;
303 uByte bInterfaceProtocol;
305 } UPACKED usb_interface_descriptor_t;
306 #define USB_INTERFACE_DESCRIPTOR_SIZE 9
310 uByte bDescriptorType;
311 uByte bEndpointAddress;
312 #define UE_GET_DIR(a) ((a) & 0x80)
313 #define UE_SET_DIR(a,d) ((a) | (((d)&1) << 7))
314 #define UE_DIR_IN 0x80
315 #define UE_DIR_OUT 0x00
317 #define UE_GET_ADDR(a) ((a) & UE_ADDR)
319 #define UE_XFERTYPE 0x03
320 #define UE_CONTROL 0x00
321 #define UE_ISOCHRONOUS 0x01
323 #define UE_INTERRUPT 0x03
324 #define UE_GET_XFERTYPE(a) ((a) & UE_XFERTYPE)
325 #define UE_ISO_TYPE 0x0c
326 #define UE_ISO_ASYNC 0x04
327 #define UE_ISO_ADAPT 0x08
328 #define UE_ISO_SYNC 0x0c
329 #define UE_GET_ISO_TYPE(a) ((a) & UE_ISO_TYPE)
330 uWord wMaxPacketSize;
332 } UPACKED usb_endpoint_descriptor_t;
333 #define USB_ENDPOINT_DESCRIPTOR_SIZE 7
335 typedef struct ss_endpoint_companion_descriptor {
337 uByte bDescriptorType;
339 #define USSE_GET_MAX_STREAMS(a) ((a) & 0x1f)
340 #define USSE_SET_MAX_STREAMS(a, b) ((a) | ((b) & 0x1f))
341 #define USSE_GET_MAX_PACKET_NUM(a) ((a) & 0x03)
342 #define USSE_SET_MAX_PACKET_NUM(a, b) ((a) | ((b) & 0x03))
344 uWord wBytesPerInterval;
345 } UPACKED ss_endpoint_companion_descriptor_t;
346 #define USB_SS_ENDPOINT_COMPANION_DESCRIPTOR_SIZE 6
350 uByte bDescriptorType;
352 } UPACKED usb_string_descriptor_t;
353 #define USB_MAX_STRING_LEN 128
354 #define USB_LANGUAGE_TABLE 0 /* # of the string language id table */
356 /* Hub specific request */
357 #define UR_GET_BUS_STATE 0x02
358 #define UR_CLEAR_TT_BUFFER 0x08
359 #define UR_RESET_TT 0x09
360 #define UR_GET_TT_STATE 0x0a
361 #define UR_STOP_TT 0x0b
364 #define UHF_C_HUB_LOCAL_POWER 0
365 #define UHF_C_HUB_OVER_CURRENT 1
366 #define UHF_PORT_CONNECTION 0
367 #define UHF_PORT_ENABLE 1
368 #define UHF_PORT_SUSPEND 2
369 #define UHF_PORT_OVER_CURRENT 3
370 #define UHF_PORT_RESET 4
371 #define UHF_PORT_L1 5
372 #define UHF_PORT_POWER 8
373 #define UHF_PORT_LOW_SPEED 9
374 #define UHF_PORT_HIGH_SPEED 10
375 #define UHF_C_PORT_CONNECTION 16
376 #define UHF_C_PORT_ENABLE 17
377 #define UHF_C_PORT_SUSPEND 18
378 #define UHF_C_PORT_OVER_CURRENT 19
379 #define UHF_C_PORT_RESET 20
380 #define UHF_C_PORT_L1 23
381 #define UHF_PORT_TEST 21
382 #define UHF_PORT_INDICATOR 22
386 uByte bDescriptorType;
388 uWord wHubCharacteristics;
389 #define UHD_PWR 0x0003
390 #define UHD_PWR_GANGED 0x0000
391 #define UHD_PWR_INDIVIDUAL 0x0001
392 #define UHD_PWR_NO_SWITCH 0x0002
393 #define UHD_COMPOUND 0x0004
394 #define UHD_OC 0x0018
395 #define UHD_OC_GLOBAL 0x0000
396 #define UHD_OC_INDIVIDUAL 0x0008
397 #define UHD_OC_NONE 0x0010
398 #define UHD_TT_THINK 0x0060
399 #define UHD_TT_THINK_8 0x0000
400 #define UHD_TT_THINK_16 0x0020
401 #define UHD_TT_THINK_24 0x0040
402 #define UHD_TT_THINK_32 0x0060
403 #define UHD_PORT_IND 0x0080
404 uByte bPwrOn2PwrGood; /* delay in 2 ms units */
405 #define UHD_PWRON_FACTOR 2
406 uByte bHubContrCurrent;
407 uByte DeviceRemovable[32]; /* max 255 ports */
408 #define UHD_NOT_REMOV(desc, i) \
409 (((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1)
410 /* deprecated */ uByte PortPowerCtrlMask[1];
411 } UPACKED usb_hub_descriptor_t;
412 #define USB_HUB_DESCRIPTOR_SIZE 9 /* includes deprecated PortPowerCtrlMask */
416 uByte bDescriptorType;
419 uByte bDeviceSubClass;
420 uByte bDeviceProtocol;
421 uByte bMaxPacketSize0;
422 uByte bNumConfigurations;
424 } UPACKED usb_device_qualifier_t;
425 #define USB_DEVICE_QUALIFIER_SIZE 10
429 uByte bDescriptorType;
431 #define UOTG_SRP 0x01
432 #define UOTG_HNP 0x02
433 } UPACKED usb_otg_descriptor_t;
435 /* OTG feature selectors */
436 #define UOTG_B_HNP_ENABLE 3
437 #define UOTG_A_HNP_SUPPORT 4
438 #define UOTG_A_ALT_HNP_SUPPORT 5
442 /* Device status flags */
443 #define UDS_SELF_POWERED 0x0001
444 #define UDS_REMOTE_WAKEUP 0x0002
445 /* Endpoint status flags */
446 #define UES_HALT 0x0001
447 } UPACKED usb_status_t;
451 #define UHS_LOCAL_POWER 0x0001
452 #define UHS_OVER_CURRENT 0x0002
454 } UPACKED usb_hub_status_t;
458 #define UPS_CURRENT_CONNECT_STATUS 0x0001
459 #define UPS_PORT_ENABLED 0x0002
460 #define UPS_SUSPEND 0x0004
461 #define UPS_OVERCURRENT_INDICATOR 0x0008
462 #define UPS_RESET 0x0010
463 #define UPS_PORT_POWER 0x0100
464 #define UPS_LOW_SPEED 0x0200
465 #define UPS_HIGH_SPEED 0x0400
466 #define UPS_PORT_TEST 0x0800
467 #define UPS_PORT_INDICATOR 0x1000
469 #define UPS_C_CONNECT_STATUS 0x0001
470 #define UPS_C_PORT_ENABLED 0x0002
471 #define UPS_C_SUSPEND 0x0004
472 #define UPS_C_OVERCURRENT_INDICATOR 0x0008
473 #define UPS_C_PORT_RESET 0x0010
474 } UPACKED usb_port_status_t;
480 /* Device class codes */
481 #define UDCLASS_IN_INTERFACE 0x00
482 #define UDCLASS_COMM 0x02
483 #define UDCLASS_HUB 0x09
484 #define UDSUBCLASS_HUB 0x00
485 #define UDPROTO_FSHUB 0x00
486 #define UDPROTO_HSHUBSTT 0x01
487 #define UDPROTO_HSHUBMTT 0x02
488 #define UDCLASS_DIAGNOSTIC 0xdc
489 #define UDCLASS_WIRELESS 0xe0
490 #define UDSUBCLASS_RF 0x01
491 #define UDPROTO_BLUETOOTH 0x01
492 #define UDCLASS_VENDOR 0xff
494 /* Interface class codes */
495 #define UICLASS_UNSPEC 0x00
497 #define UICLASS_AUDIO 0x01
498 #define UISUBCLASS_AUDIOCONTROL 1
499 #define UISUBCLASS_AUDIOSTREAM 2
500 #define UISUBCLASS_MIDISTREAM 3
502 #define UICLASS_CDC 0x02 /* communication */
503 #define UISUBCLASS_DIRECT_LINE_CONTROL_MODEL 1
504 #define UISUBCLASS_ABSTRACT_CONTROL_MODEL 2
505 #define UISUBCLASS_TELEPHONE_CONTROL_MODEL 3
506 #define UISUBCLASS_MULTICHANNEL_CONTROL_MODEL 4
507 #define UISUBCLASS_CAPI_CONTROLMODEL 5
508 #define UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL 6
509 #define UISUBCLASS_ATM_NETWORKING_CONTROL_MODEL 7
510 #define UIPROTO_CDC_AT 1
512 #define UICLASS_HID 0x03
513 #define UISUBCLASS_BOOT 1
514 #define UIPROTO_BOOT_KEYBOARD 1
516 #define UICLASS_PHYSICAL 0x05
518 #define UICLASS_IMAGE 0x06
520 #define UICLASS_PRINTER 0x07
521 #define UISUBCLASS_PRINTER 1
522 #define UIPROTO_PRINTER_UNI 1
523 #define UIPROTO_PRINTER_BI 2
524 #define UIPROTO_PRINTER_1284 3
526 #define UICLASS_MASS 0x08
527 #define UISUBCLASS_RBC 1
528 #define UISUBCLASS_SFF8020I 2
529 #define UISUBCLASS_QIC157 3
530 #define UISUBCLASS_UFI 4
531 #define UISUBCLASS_SFF8070I 5
532 #define UISUBCLASS_SCSI 6
533 #define UIPROTO_MASS_CBI_I 0
534 #define UIPROTO_MASS_CBI 1
535 #define UIPROTO_MASS_BBB_OLD 2 /* Not in the spec anymore */
536 #define UIPROTO_MASS_BBB 80 /* 'P' for the Iomega Zip drive */
538 #define UICLASS_HUB 0x09
539 #define UISUBCLASS_HUB 0
540 #define UIPROTO_FSHUB 0
541 #define UIPROTO_HSHUBSTT 0 /* Yes, same as previous */
542 #define UIPROTO_HSHUBMTT 1
544 #define UICLASS_CDC_DATA 0x0a
545 #define UISUBCLASS_DATA 0
546 #define UIPROTO_DATA_ISDNBRI 0x30 /* Physical iface */
547 #define UIPROTO_DATA_HDLC 0x31 /* HDLC */
548 #define UIPROTO_DATA_TRANSPARENT 0x32 /* Transparent */
549 #define UIPROTO_DATA_Q921M 0x50 /* Management for Q921 */
550 #define UIPROTO_DATA_Q921 0x51 /* Data for Q921 */
551 #define UIPROTO_DATA_Q921TM 0x52 /* TEI multiplexer for Q921 */
552 #define UIPROTO_DATA_V42BIS 0x90 /* Data compression */
553 #define UIPROTO_DATA_Q931 0x91 /* Euro-ISDN */
554 #define UIPROTO_DATA_V120 0x92 /* V.24 rate adaption */
555 #define UIPROTO_DATA_CAPI 0x93 /* CAPI 2.0 commands */
556 #define UIPROTO_DATA_HOST_BASED 0xfd /* Host based driver */
557 #define UIPROTO_DATA_PUF 0xfe /* see Prot. Unit Func. Desc.*/
558 #define UIPROTO_DATA_VENDOR 0xff /* Vendor specific */
560 #define UICLASS_SMARTCARD 0x0b
562 /*#define UICLASS_FIRM_UPD 0x0c*/
564 #define UICLASS_SECURITY 0x0d
566 #define UICLASS_DIAGNOSTIC 0xdc
568 #define UICLASS_WIRELESS 0xe0
569 #define UISUBCLASS_RF 0x01
570 #define UIPROTO_BLUETOOTH 0x01
572 #define UICLASS_APPL_SPEC 0xfe
573 #define UISUBCLASS_FIRMWARE_DOWNLOAD 1
574 #define UISUBCLASS_IRDA 2
575 #define UIPROTO_IRDA 0
577 #define UICLASS_VENDOR 0xff
579 #define USB_HUB_MAX_DEPTH 5
582 * Minimum time a device needs to be powered down to go through
583 * a power cycle. XXX Are these time in the spec?
585 #define USB_POWER_DOWN_TIME 200 /* ms */
586 #define USB_PORT_POWER_DOWN_TIME 100 /* ms */
589 /* These are the values from the spec. */
590 #define USB_PORT_RESET_DELAY 10 /* ms */
591 #define USB_PORT_ROOT_RESET_DELAY 50 /* ms */
592 #define USB_PORT_RESET_RECOVERY 10 /* ms */
593 #define USB_PORT_POWERUP_DELAY 100 /* ms */
594 #define USB_SET_ADDRESS_SETTLE 2 /* ms */
595 #define USB_RESUME_DELAY (20*5) /* ms */
596 #define USB_RESUME_WAIT 10 /* ms */
597 #define USB_RESUME_RECOVERY 10 /* ms */
598 #define USB_EXTRA_POWER_UP_TIME 0 /* ms */
600 /* Allow for marginal (i.e. non-conforming) devices. */
601 #define USB_PORT_RESET_DELAY 50 /* ms */
602 #define USB_PORT_ROOT_RESET_DELAY 250 /* ms */
603 #define USB_PORT_RESET_RECOVERY 250 /* ms */
604 #define USB_PORT_POWERUP_DELAY 300 /* ms */
605 #define USB_SET_ADDRESS_SETTLE 10 /* ms */
606 #define USB_RESUME_DELAY (50*5) /* ms */
607 #define USB_RESUME_WAIT 50 /* ms */
608 #define USB_RESUME_RECOVERY 50 /* ms */
609 #define USB_EXTRA_POWER_UP_TIME 20 /* ms */
612 #define USB_MIN_POWER 100 /* mA */
613 #define USB_MAX_POWER 500 /* mA */
615 #define USB_BUS_RESET_DELAY 100 /* ms XXX?*/
617 #define USB_UNCONFIG_NO 0
618 #define USB_UNCONFIG_INDEX (-1)
620 /*** ioctl() related stuff ***/
622 struct usb_ctl_request {
624 usb_device_request_t ucr_request;
627 #define USBD_SHORT_XFER_OK 0x04 /* allow short reads */
628 int ucr_actlen; /* actual length transferred */
631 struct usb_alt_interface {
632 int uai_config_index;
633 int uai_interface_index;
637 #define USB_CURRENT_CONFIG_INDEX (-1)
638 #define USB_CURRENT_ALT_INDEX (-1)
640 struct usb_config_desc {
641 int ucd_config_index;
642 usb_config_descriptor_t ucd_desc;
645 struct usb_interface_desc {
646 int uid_config_index;
647 int uid_interface_index;
649 usb_interface_descriptor_t uid_desc;
652 struct usb_endpoint_desc {
653 int ued_config_index;
654 int ued_interface_index;
656 int ued_endpoint_index;
657 usb_endpoint_descriptor_t ued_desc;
660 struct usb_full_desc {
661 int ufd_config_index;
666 struct usb_string_desc {
667 int usd_string_index;
669 usb_string_descriptor_t usd_desc;
672 struct usb_ctl_report_desc {
674 u_char ucrd_data[1024]; /* filled data size will vary */
677 typedef struct { u_int32_t cookie; } usb_event_cookie_t;
679 #define USB_MAX_DEVNAMES 4
680 #define USB_MAX_DEVNAMELEN 16
681 struct usb_device_info {
683 u_int8_t udi_addr; /* device address */
684 usb_event_cookie_t udi_cookie;
685 char udi_product[USB_MAX_STRING_LEN];
686 char udi_vendor[USB_MAX_STRING_LEN];
688 u_int16_t udi_productNo;
689 u_int16_t udi_vendorNo;
690 u_int16_t udi_releaseNo;
692 u_int8_t udi_subclass;
693 u_int8_t udi_protocol;
696 #define USB_SPEED_UNKNOWN 0
697 #define USB_SPEED_LOW 1
698 #define USB_SPEED_FULL 2
699 #define USB_SPEED_HIGH 3
700 #define USB_SPEED_VARIABLE 4
701 #define USB_SPEED_SUPER 5
702 int udi_power; /* power consumption in mA, 0 if selfpowered */
704 char udi_devnames[USB_MAX_DEVNAMES][USB_MAX_DEVNAMELEN];
705 u_int8_t udi_ports[16];/* hub only: addresses of devices on ports */
706 #define USB_PORT_ENABLED 0xff
707 #define USB_PORT_SUSPENDED 0xfe
708 #define USB_PORT_POWERED 0xfd
709 #define USB_PORT_DISABLED 0xfc
712 struct usb_ctl_report {
714 u_char ucr_data[1024]; /* filled data size will vary */
717 struct usb_device_stats {
718 u_long uds_requests[4]; /* indexed by transfer type UE_* */
721 #define WUSB_MIN_IE 0x80
722 #define WUSB_WCTA_IE 0x80
723 #define WUSB_WCONNECTACK_IE 0x81
724 #define WUSB_WHOSTINFO_IE 0x82
725 #define WUHI_GET_CA(_bmAttributes_) ((_bmAttributes_) & 0x3)
726 #define WUHI_CA_RECONN 0x00
727 #define WUHI_CA_LIMITED 0x01
728 #define WUHI_CA_ALL 0x03
729 #define WUHI_GET_MLSI(_bmAttributes_) (((_bmAttributes_) & 0x38) >> 3)
730 #define WUSB_WCHCHANGEANNOUNCE_IE 0x83
731 #define WUSB_WDEV_DISCONNECT_IE 0x84
732 #define WUSB_WHOST_DISCONNECT_IE 0x85
733 #define WUSB_WRELEASE_CHANNEL_IE 0x86
734 #define WUSB_WWORK_IE 0x87
735 #define WUSB_WCHANNEL_STOP_IE 0x88
736 #define WUSB_WDEV_KEEPALIVE_IE 0x89
737 #define WUSB_WISOCH_DISCARD_IE 0x8A
738 #define WUSB_WRESETDEVICE_IE 0x8B
739 #define WUSB_WXMIT_PACKET_ADJUST_IE 0x8C
740 #define WUSB_MAX_IE 0x8C
742 /* Device Notification Types */
744 #define WUSB_DN_MIN 0x01
745 #define WUSB_DN_CONNECT 0x01
746 # define WUSB_DA_OLDCONN 0x00
747 # define WUSB_DA_NEWCONN 0x01
748 # define WUSB_DA_SELF_BEACON 0x02
749 # define WUSB_DA_DIR_BEACON 0x04
750 # define WUSB_DA_NO_BEACON 0x06
751 #define WUSB_DN_DISCONNECT 0x02
752 #define WUSB_DN_EPRDY 0x03
753 #define WUSB_DN_MASAVAILCHANGED 0x04
754 #define WUSB_DN_REMOTEWAKEUP 0x05
755 #define WUSB_DN_SLEEP 0x06
756 #define WUSB_DN_ALIVE 0x07
757 #define WUSB_DN_MAX 0x07
760 #include <pshpack1.h>
763 /* WUSB Handshake Data. Used during the SET/GET HANDSHAKE requests */
764 typedef struct wusb_hndshk_data {
765 uByte bMessageNumber;
772 } UPACKED wusb_hndshk_data_t;
773 #define WUSB_HANDSHAKE_LEN_FOR_MIC 38
775 /* WUSB Connection Context */
776 typedef struct wusb_conn_context {
780 } UPACKED wusb_conn_context_t;
782 /* WUSB Security Descriptor */
783 typedef struct wusb_security_desc {
785 uByte bDescriptorType;
787 uByte bNumEncryptionTypes;
788 } UPACKED wusb_security_desc_t;
790 /* WUSB Encryption Type Descriptor */
791 typedef struct wusb_encrypt_type_desc {
793 uByte bDescriptorType;
795 uByte bEncryptionType;
796 #define WUETD_UNSECURE 0
797 #define WUETD_WIRED 1
798 #define WUETD_CCM_1 2
799 #define WUETD_RSA_1 3
801 uByte bEncryptionValue;
803 } UPACKED wusb_encrypt_type_desc_t;
805 /* WUSB Key Descriptor */
806 typedef struct wusb_key_desc {
808 uByte bDescriptorType;
811 uByte KeyData[1]; /* variable length */
812 } UPACKED wusb_key_desc_t;
814 /* WUSB BOS Descriptor (Binary device Object Store) */
815 typedef struct wusb_bos_desc {
817 uByte bDescriptorType;
819 uByte bNumDeviceCaps;
820 } UPACKED wusb_bos_desc_t;
822 #define USB_DEVICE_CAPABILITY_20_EXTENSION 0x02
823 typedef struct usb_dev_cap_20_ext_desc {
825 uByte bDescriptorType;
826 uByte bDevCapabilityType;
827 #define USB_20_EXT_LPM 0x02
829 } UPACKED usb_dev_cap_20_ext_desc_t;
831 #define USB_DEVICE_CAPABILITY_SS_USB 0x03
832 typedef struct usb_dev_cap_ss_usb {
834 uByte bDescriptorType;
835 uByte bDevCapabilityType;
836 #define USB_DC_SS_USB_LTM_CAPABLE 0x02
838 #define USB_DC_SS_USB_SPEED_SUPPORT_LOW 0x01
839 #define USB_DC_SS_USB_SPEED_SUPPORT_FULL 0x02
840 #define USB_DC_SS_USB_SPEED_SUPPORT_HIGH 0x04
841 #define USB_DC_SS_USB_SPEED_SUPPORT_SS 0x08
842 uWord wSpeedsSupported;
843 uByte bFunctionalitySupport;
846 } UPACKED usb_dev_cap_ss_usb_t;
848 #define USB_DEVICE_CAPABILITY_CONTAINER_ID 0x04
849 typedef struct usb_dev_cap_container_id {
851 uByte bDescriptorType;
852 uByte bDevCapabilityType;
854 uByte containerID[16];
855 } UPACKED usb_dev_cap_container_id_t;
857 /* Device Capability Type Codes */
858 #define WUSB_DEVICE_CAPABILITY_WIRELESS_USB 0x01
860 /* Device Capability Descriptor */
861 typedef struct wusb_dev_cap_desc {
863 uByte bDescriptorType;
864 uByte bDevCapabilityType;
865 uByte caps[1]; /* Variable length */
866 } UPACKED wusb_dev_cap_desc_t;
868 /* Device Capability Descriptor */
869 typedef struct wusb_dev_cap_uwb_desc {
871 uByte bDescriptorType;
872 uByte bDevCapabilityType;
874 uWord wPHYRates; /* Bitmap */
875 uByte bmTFITXPowerInfo;
876 uByte bmFFITXPowerInfo;
879 } UPACKED wusb_dev_cap_uwb_desc_t;
881 /* Wireless USB Endpoint Companion Descriptor */
882 typedef struct wusb_endpoint_companion_desc {
884 uByte bDescriptorType;
887 uWord wMaxStreamDelay;
888 uWord wOverTheAirPacketSize;
889 uByte bOverTheAirInterval;
890 uByte bmCompAttributes;
891 } UPACKED wusb_endpoint_companion_desc_t;
893 /* Wireless USB Numeric Association M1 Data Structure */
894 typedef struct wusb_m1_data {
897 uByte deviceFriendlyNameLength;
898 uByte sha_256_m3[32];
899 uByte deviceFriendlyName[256];
900 } UPACKED wusb_m1_data_t;
902 typedef struct wusb_m2_data {
905 uByte hostFriendlyNameLength;
907 uByte hostFriendlyName[256];
908 } UPACKED wusb_m2_data_t;
910 typedef struct wusb_m3_data {
913 } UPACKED wusb_m3_data_t;
915 typedef struct wusb_m4_data {
916 uDWord _attributeTypeIdAndLength_1;
917 uWord associationTypeId;
919 uDWord _attributeTypeIdAndLength_2;
920 uWord associationSubTypeId;
922 uDWord _attributeTypeIdAndLength_3;
925 uDWord _attributeTypeIdAndLength_4;
926 uDWord associationStatus;
928 uDWord _attributeTypeIdAndLength_5;
931 uDWord _attributeTypeIdAndLength_6;
934 uDWord _attributeTypeIdAndLength_7;
936 } UPACKED wusb_m4_data_t;