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 */
47 * The USB records contain some unaligned little-endian word
48 * components. The U[SG]ETW macros take care of both the alignment
49 * and endian problem and should always be used to access non-byte
52 typedef u_int8_t uByte;
53 typedef u_int8_t uWord[2];
54 typedef u_int8_t uDWord[4];
56 #define USETW2(w,h,l) ((w)[0] = (u_int8_t)(l), (w)[1] = (u_int8_t)(h))
59 #define UGETW(w) ((w)[0] | ((w)[1] << 8))
60 #define USETW(w,v) ((w)[0] = (u_int8_t)(v), (w)[1] = (u_int8_t)((v) >> 8))
61 #define UGETDW(w) ((w)[0] | ((w)[1] << 8) | ((w)[2] << 16) | ((w)[3] << 24))
62 #define USETDW(w,v) ((w)[0] = (u_int8_t)(v), \
63 (w)[1] = (u_int8_t)((v) >> 8), \
64 (w)[2] = (u_int8_t)((v) >> 16), \
65 (w)[3] = (u_int8_t)((v) >> 24))
68 * On little-endian machines that can handle unanliged accesses
69 * (e.g. i386) these macros can be replaced by the following.
71 #define UGETW(w) (*(u_int16_t *)(w))
72 #define USETW(w,v) (*(u_int16_t *)(w) = (v))
73 #define UGETDW(w) (*(u_int32_t *)(w))
74 #define USETDW(w,v) (*(u_int32_t *)(w) = (v))
77 #define UPACKED __attribute__((__packed__))
85 } UPACKED usb_device_request_t;
87 #define UT_GET_DIR(a) ((a) & 0x80)
91 #define UT_GET_TYPE(a) ((a) & 0x60)
92 #define UT_STANDARD 0x00
94 #define UT_VENDOR 0x40
96 #define UT_GET_RECIPIENT(a) ((a) & 0x1f)
97 #define UT_DEVICE 0x00
98 #define UT_INTERFACE 0x01
99 #define UT_ENDPOINT 0x02
100 #define UT_OTHER 0x03
102 #define UT_READ_DEVICE (UT_READ | UT_STANDARD | UT_DEVICE)
103 #define UT_READ_INTERFACE (UT_READ | UT_STANDARD | UT_INTERFACE)
104 #define UT_READ_ENDPOINT (UT_READ | UT_STANDARD | UT_ENDPOINT)
105 #define UT_WRITE_DEVICE (UT_WRITE | UT_STANDARD | UT_DEVICE)
106 #define UT_WRITE_INTERFACE (UT_WRITE | UT_STANDARD | UT_INTERFACE)
107 #define UT_WRITE_ENDPOINT (UT_WRITE | UT_STANDARD | UT_ENDPOINT)
108 #define UT_READ_CLASS_DEVICE (UT_READ | UT_CLASS | UT_DEVICE)
109 #define UT_READ_CLASS_INTERFACE (UT_READ | UT_CLASS | UT_INTERFACE)
110 #define UT_READ_CLASS_OTHER (UT_READ | UT_CLASS | UT_OTHER)
111 #define UT_READ_CLASS_ENDPOINT (UT_READ | UT_CLASS | UT_ENDPOINT)
112 #define UT_WRITE_CLASS_DEVICE (UT_WRITE | UT_CLASS | UT_DEVICE)
113 #define UT_WRITE_CLASS_INTERFACE (UT_WRITE | UT_CLASS | UT_INTERFACE)
114 #define UT_WRITE_CLASS_OTHER (UT_WRITE | UT_CLASS | UT_OTHER)
115 #define UT_WRITE_CLASS_ENDPOINT (UT_WRITE | UT_CLASS | UT_ENDPOINT)
116 #define UT_READ_VENDOR_DEVICE (UT_READ | UT_VENDOR | UT_DEVICE)
117 #define UT_READ_VENDOR_INTERFACE (UT_READ | UT_VENDOR | UT_INTERFACE)
118 #define UT_READ_VENDOR_OTHER (UT_READ | UT_VENDOR | UT_OTHER)
119 #define UT_READ_VENDOR_ENDPOINT (UT_READ | UT_VENDOR | UT_ENDPOINT)
120 #define UT_WRITE_VENDOR_DEVICE (UT_WRITE | UT_VENDOR | UT_DEVICE)
121 #define UT_WRITE_VENDOR_INTERFACE (UT_WRITE | UT_VENDOR | UT_INTERFACE)
122 #define UT_WRITE_VENDOR_OTHER (UT_WRITE | UT_VENDOR | UT_OTHER)
123 #define UT_WRITE_VENDOR_ENDPOINT (UT_WRITE | UT_VENDOR | UT_ENDPOINT)
126 #define UR_GET_STATUS 0x00
127 #define USTAT_STANDARD_STATUS 0x00
128 #define WUSTAT_WUSB_FEATURE 0x01
129 #define WUSTAT_CHANNEL_INFO 0x02
130 #define WUSTAT_RECEIVED_DATA 0x03
131 #define WUSTAT_MAS_AVAILABILITY 0x04
132 #define WUSTAT_CURRENT_TRANSMIT_POWER 0x05
133 #define UR_CLEAR_FEATURE 0x01
134 #define UR_SET_FEATURE 0x03
135 #define UR_SET_AND_TEST_FEATURE 0x0c
136 #define UR_SET_ADDRESS 0x05
137 #define UR_GET_DESCRIPTOR 0x06
138 #define UDESC_DEVICE 0x01
139 #define UDESC_CONFIG 0x02
140 #define UDESC_STRING 0x03
141 #define UDESC_INTERFACE 0x04
142 #define UDESC_ENDPOINT 0x05
143 #define UDESC_DEVICE_QUALIFIER 0x06
144 #define UDESC_OTHER_SPEED_CONFIGURATION 0x07
145 #define UDESC_INTERFACE_POWER 0x08
146 #define UDESC_OTG 0x09
147 #define WUDESC_SECURITY 0x0c
148 #define WUDESC_KEY 0x0d
149 #define WUD_GET_KEY_INDEX(_wValue_) ((_wValue_) & 0xf)
150 #define WUD_GET_KEY_TYPE(_wValue_) (((_wValue_) & 0x30) >> 4)
151 #define WUD_KEY_TYPE_ASSOC 0x01
152 #define WUD_KEY_TYPE_GTK 0x02
153 #define WUD_GET_KEY_ORIGIN(_wValue_) (((_wValue_) & 0x40) >> 6)
154 #define WUD_KEY_ORIGIN_HOST 0x00
155 #define WUD_KEY_ORIGIN_DEVICE 0x01
156 #define WUDESC_ENCRYPTION_TYPE 0x0e
157 #define WUDESC_BOS 0x0f
158 #define WUDESC_DEVICE_CAPABILITY 0x10
159 #define WUDESC_WIRELESS_ENDPOINT_COMPANION 0x11
160 #define UDESC_CS_DEVICE 0x21 /* class specific */
161 #define UDESC_CS_CONFIG 0x22
162 #define UDESC_CS_STRING 0x23
163 #define UDESC_CS_INTERFACE 0x24
164 #define UDESC_CS_ENDPOINT 0x25
165 #define UDESC_HUB 0x29
166 #define UR_SET_DESCRIPTOR 0x07
167 #define UR_GET_CONFIG 0x08
168 #define UR_SET_CONFIG 0x09
169 #define UR_GET_INTERFACE 0x0a
170 #define UR_SET_INTERFACE 0x0b
171 #define UR_SYNCH_FRAME 0x0c
172 #define WUR_SET_ENCRYPTION 0x0d
173 #define WUR_GET_ENCRYPTION 0x0e
174 #define WUR_SET_HANDSHAKE 0x0f
175 #define WUR_GET_HANDSHAKE 0x10
176 #define WUR_SET_CONNECTION 0x11
177 #define WUR_SET_SECURITY_DATA 0x12
178 #define WUR_GET_SECURITY_DATA 0x13
179 #define WUR_SET_WUSB_DATA 0x14
180 #define WUDATA_DRPIE_INFO 0x01
181 #define WUDATA_TRANSMIT_DATA 0x02
182 #define WUDATA_TRANSMIT_PARAMS 0x03
183 #define WUDATA_RECEIVE_PARAMS 0x04
184 #define WUDATA_TRANSMIT_POWER 0x05
185 #define WUR_LOOPBACK_DATA_WRITE 0x15
186 #define WUR_LOOPBACK_DATA_READ 0x16
187 #define WUR_SET_INTERFACE_DS 0x17
189 /* Feature numbers */
190 #define UF_ENDPOINT_HALT 0
191 #define UF_DEVICE_REMOTE_WAKEUP 1
192 #define UF_TEST_MODE 2
193 #define UF_DEVICE_B_HNP_ENABLE 3
194 #define UF_DEVICE_A_HNP_SUPPORT 4
195 #define UF_DEVICE_A_ALT_HNP_SUPPORT 5
197 #define WUF_TX_DRPIE 0x0
198 #define WUF_DEV_XMIT_PACKET 0x1
199 #define WUF_COUNT_PACKETS 0x2
200 #define WUF_CAPTURE_PACKETS 0x3
202 /* Class requests from the USB 2.0 hub spec, table 11-15 */
203 #define UCR_CLEAR_HUB_FEATURE (0x2000 | UR_CLEAR_FEATURE)
204 #define UCR_CLEAR_PORT_FEATURE (0x2300 | UR_CLEAR_FEATURE)
205 #define UCR_GET_HUB_DESCRIPTOR (0xa000 | UR_GET_DESCRIPTOR)
206 #define UCR_GET_HUB_STATUS (0xa000 | UR_GET_STATUS)
207 #define UCR_GET_PORT_STATUS (0xa300 | UR_GET_STATUS)
208 #define UCR_SET_HUB_FEATURE (0x2000 | UR_SET_FEATURE)
209 #define UCR_SET_PORT_FEATURE (0x2300 | UR_SET_FEATURE)
210 #define UCR_SET_AND_TEST_PORT_FEATURE (0xa300 | UR_SET_AND_TEST_FEATURE)
214 uByte bDescriptorType;
215 uByte bDescriptorSubtype;
216 } UPACKED usb_descriptor_t;
220 uByte bDescriptorType;
222 #define UD_USB_2_0 0x0200
223 #define UD_IS_USB2(d) (UGETW((d)->bcdUSB) >= UD_USB_2_0)
225 uByte bDeviceSubClass;
226 uByte bDeviceProtocol;
227 uByte bMaxPacketSize;
228 /* The fields below are not part of the initial descriptor. */
235 uByte bNumConfigurations;
236 } UPACKED usb_device_descriptor_t;
237 #define USB_DEVICE_DESCRIPTOR_SIZE 18
241 uByte bDescriptorType;
244 uByte bConfigurationValue;
245 uByte iConfiguration;
247 #define UC_BUS_POWERED 0x80
248 #define UC_SELF_POWERED 0x40
249 #define UC_REMOTE_WAKEUP 0x20
250 uByte bMaxPower; /* max current in 2 mA units */
251 #define UC_POWER_FACTOR 2
252 } UPACKED usb_config_descriptor_t;
253 #define USB_CONFIG_DESCRIPTOR_SIZE 9
257 uByte bDescriptorType;
258 uByte bInterfaceNumber;
259 uByte bAlternateSetting;
261 uByte bInterfaceClass;
262 uByte bInterfaceSubClass;
263 uByte bInterfaceProtocol;
265 } UPACKED usb_interface_descriptor_t;
266 #define USB_INTERFACE_DESCRIPTOR_SIZE 9
270 uByte bDescriptorType;
271 uByte bEndpointAddress;
272 #define UE_GET_DIR(a) ((a) & 0x80)
273 #define UE_SET_DIR(a,d) ((a) | (((d)&1) << 7))
274 #define UE_DIR_IN 0x80
275 #define UE_DIR_OUT 0x00
277 #define UE_GET_ADDR(a) ((a) & UE_ADDR)
279 #define UE_XFERTYPE 0x03
280 #define UE_CONTROL 0x00
281 #define UE_ISOCHRONOUS 0x01
283 #define UE_INTERRUPT 0x03
284 #define UE_GET_XFERTYPE(a) ((a) & UE_XFERTYPE)
285 #define UE_ISO_TYPE 0x0c
286 #define UE_ISO_ASYNC 0x04
287 #define UE_ISO_ADAPT 0x08
288 #define UE_ISO_SYNC 0x0c
289 #define UE_GET_ISO_TYPE(a) ((a) & UE_ISO_TYPE)
290 uWord wMaxPacketSize;
292 } UPACKED usb_endpoint_descriptor_t;
293 #define USB_ENDPOINT_DESCRIPTOR_SIZE 7
297 uByte bDescriptorType;
299 } UPACKED usb_string_descriptor_t;
300 #define USB_MAX_STRING_LEN 128
301 #define USB_LANGUAGE_TABLE 0 /* # of the string language id table */
303 /* Hub specific request */
304 #define UR_GET_BUS_STATE 0x02
305 #define UR_CLEAR_TT_BUFFER 0x08
306 #define UR_RESET_TT 0x09
307 #define UR_GET_TT_STATE 0x0a
308 #define UR_STOP_TT 0x0b
311 #define UHF_C_HUB_LOCAL_POWER 0
312 #define UHF_C_HUB_OVER_CURRENT 1
313 #define UHF_PORT_CONNECTION 0
314 #define UHF_PORT_ENABLE 1
315 #define UHF_PORT_SUSPEND 2
316 #define UHF_PORT_OVER_CURRENT 3
317 #define UHF_PORT_RESET 4
318 #define UHF_PORT_L1 5
319 #define UHF_PORT_POWER 8
320 #define UHF_PORT_LOW_SPEED 9
321 #define UHF_PORT_HIGH_SPEED 10
322 #define UHF_C_PORT_CONNECTION 16
323 #define UHF_C_PORT_ENABLE 17
324 #define UHF_C_PORT_SUSPEND 18
325 #define UHF_C_PORT_OVER_CURRENT 19
326 #define UHF_C_PORT_RESET 20
327 #define UHF_C_PORT_L1 23
328 #define UHF_PORT_TEST 21
329 #define UHF_PORT_INDICATOR 22
333 uByte bDescriptorType;
335 uWord wHubCharacteristics;
336 #define UHD_PWR 0x0003
337 #define UHD_PWR_GANGED 0x0000
338 #define UHD_PWR_INDIVIDUAL 0x0001
339 #define UHD_PWR_NO_SWITCH 0x0002
340 #define UHD_COMPOUND 0x0004
341 #define UHD_OC 0x0018
342 #define UHD_OC_GLOBAL 0x0000
343 #define UHD_OC_INDIVIDUAL 0x0008
344 #define UHD_OC_NONE 0x0010
345 #define UHD_TT_THINK 0x0060
346 #define UHD_TT_THINK_8 0x0000
347 #define UHD_TT_THINK_16 0x0020
348 #define UHD_TT_THINK_24 0x0040
349 #define UHD_TT_THINK_32 0x0060
350 #define UHD_PORT_IND 0x0080
351 uByte bPwrOn2PwrGood; /* delay in 2 ms units */
352 #define UHD_PWRON_FACTOR 2
353 uByte bHubContrCurrent;
354 uByte DeviceRemovable[32]; /* max 255 ports */
355 #define UHD_NOT_REMOV(desc, i) \
356 (((desc)->DeviceRemovable[(i)/8] >> ((i) % 8)) & 1)
357 /* deprecated */ uByte PortPowerCtrlMask[1];
358 } UPACKED usb_hub_descriptor_t;
359 #define USB_HUB_DESCRIPTOR_SIZE 9 /* includes deprecated PortPowerCtrlMask */
363 uByte bDescriptorType;
366 uByte bDeviceSubClass;
367 uByte bDeviceProtocol;
368 uByte bMaxPacketSize0;
369 uByte bNumConfigurations;
371 } UPACKED usb_device_qualifier_t;
372 #define USB_DEVICE_QUALIFIER_SIZE 10
376 uByte bDescriptorType;
378 #define UOTG_SRP 0x01
379 #define UOTG_HNP 0x02
380 } UPACKED usb_otg_descriptor_t;
382 /* OTG feature selectors */
383 #define UOTG_B_HNP_ENABLE 3
384 #define UOTG_A_HNP_SUPPORT 4
385 #define UOTG_A_ALT_HNP_SUPPORT 5
389 /* Device status flags */
390 #define UDS_SELF_POWERED 0x0001
391 #define UDS_REMOTE_WAKEUP 0x0002
392 /* Endpoint status flags */
393 #define UES_HALT 0x0001
394 } UPACKED usb_status_t;
398 #define UHS_LOCAL_POWER 0x0001
399 #define UHS_OVER_CURRENT 0x0002
401 } UPACKED usb_hub_status_t;
405 #define UPS_CURRENT_CONNECT_STATUS 0x0001
406 #define UPS_PORT_ENABLED 0x0002
407 #define UPS_SUSPEND 0x0004
408 #define UPS_OVERCURRENT_INDICATOR 0x0008
409 #define UPS_RESET 0x0010
410 #define UPS_PORT_POWER 0x0100
411 #define UPS_LOW_SPEED 0x0200
412 #define UPS_HIGH_SPEED 0x0400
413 #define UPS_PORT_TEST 0x0800
414 #define UPS_PORT_INDICATOR 0x1000
416 #define UPS_C_CONNECT_STATUS 0x0001
417 #define UPS_C_PORT_ENABLED 0x0002
418 #define UPS_C_SUSPEND 0x0004
419 #define UPS_C_OVERCURRENT_INDICATOR 0x0008
420 #define UPS_C_PORT_RESET 0x0010
421 } UPACKED usb_port_status_t;
423 /* Device class codes */
424 #define UDCLASS_IN_INTERFACE 0x00
425 #define UDCLASS_COMM 0x02
426 #define UDCLASS_HUB 0x09
427 #define UDSUBCLASS_HUB 0x00
428 #define UDPROTO_FSHUB 0x00
429 #define UDPROTO_HSHUBSTT 0x01
430 #define UDPROTO_HSHUBMTT 0x02
431 #define UDCLASS_DIAGNOSTIC 0xdc
432 #define UDCLASS_WIRELESS 0xe0
433 #define UDSUBCLASS_RF 0x01
434 #define UDPROTO_BLUETOOTH 0x01
435 #define UDCLASS_VENDOR 0xff
437 /* Interface class codes */
438 #define UICLASS_UNSPEC 0x00
440 #define UICLASS_AUDIO 0x01
441 #define UISUBCLASS_AUDIOCONTROL 1
442 #define UISUBCLASS_AUDIOSTREAM 2
443 #define UISUBCLASS_MIDISTREAM 3
445 #define UICLASS_CDC 0x02 /* communication */
446 #define UISUBCLASS_DIRECT_LINE_CONTROL_MODEL 1
447 #define UISUBCLASS_ABSTRACT_CONTROL_MODEL 2
448 #define UISUBCLASS_TELEPHONE_CONTROL_MODEL 3
449 #define UISUBCLASS_MULTICHANNEL_CONTROL_MODEL 4
450 #define UISUBCLASS_CAPI_CONTROLMODEL 5
451 #define UISUBCLASS_ETHERNET_NETWORKING_CONTROL_MODEL 6
452 #define UISUBCLASS_ATM_NETWORKING_CONTROL_MODEL 7
453 #define UIPROTO_CDC_AT 1
455 #define UICLASS_HID 0x03
456 #define UISUBCLASS_BOOT 1
457 #define UIPROTO_BOOT_KEYBOARD 1
459 #define UICLASS_PHYSICAL 0x05
461 #define UICLASS_IMAGE 0x06
463 #define UICLASS_PRINTER 0x07
464 #define UISUBCLASS_PRINTER 1
465 #define UIPROTO_PRINTER_UNI 1
466 #define UIPROTO_PRINTER_BI 2
467 #define UIPROTO_PRINTER_1284 3
469 #define UICLASS_MASS 0x08
470 #define UISUBCLASS_RBC 1
471 #define UISUBCLASS_SFF8020I 2
472 #define UISUBCLASS_QIC157 3
473 #define UISUBCLASS_UFI 4
474 #define UISUBCLASS_SFF8070I 5
475 #define UISUBCLASS_SCSI 6
476 #define UIPROTO_MASS_CBI_I 0
477 #define UIPROTO_MASS_CBI 1
478 #define UIPROTO_MASS_BBB_OLD 2 /* Not in the spec anymore */
479 #define UIPROTO_MASS_BBB 80 /* 'P' for the Iomega Zip drive */
481 #define UICLASS_HUB 0x09
482 #define UISUBCLASS_HUB 0
483 #define UIPROTO_FSHUB 0
484 #define UIPROTO_HSHUBSTT 0 /* Yes, same as previous */
485 #define UIPROTO_HSHUBMTT 1
487 #define UICLASS_CDC_DATA 0x0a
488 #define UISUBCLASS_DATA 0
489 #define UIPROTO_DATA_ISDNBRI 0x30 /* Physical iface */
490 #define UIPROTO_DATA_HDLC 0x31 /* HDLC */
491 #define UIPROTO_DATA_TRANSPARENT 0x32 /* Transparent */
492 #define UIPROTO_DATA_Q921M 0x50 /* Management for Q921 */
493 #define UIPROTO_DATA_Q921 0x51 /* Data for Q921 */
494 #define UIPROTO_DATA_Q921TM 0x52 /* TEI multiplexer for Q921 */
495 #define UIPROTO_DATA_V42BIS 0x90 /* Data compression */
496 #define UIPROTO_DATA_Q931 0x91 /* Euro-ISDN */
497 #define UIPROTO_DATA_V120 0x92 /* V.24 rate adaption */
498 #define UIPROTO_DATA_CAPI 0x93 /* CAPI 2.0 commands */
499 #define UIPROTO_DATA_HOST_BASED 0xfd /* Host based driver */
500 #define UIPROTO_DATA_PUF 0xfe /* see Prot. Unit Func. Desc.*/
501 #define UIPROTO_DATA_VENDOR 0xff /* Vendor specific */
503 #define UICLASS_SMARTCARD 0x0b
505 /*#define UICLASS_FIRM_UPD 0x0c*/
507 #define UICLASS_SECURITY 0x0d
509 #define UICLASS_DIAGNOSTIC 0xdc
511 #define UICLASS_WIRELESS 0xe0
512 #define UISUBCLASS_RF 0x01
513 #define UIPROTO_BLUETOOTH 0x01
515 #define UICLASS_APPL_SPEC 0xfe
516 #define UISUBCLASS_FIRMWARE_DOWNLOAD 1
517 #define UISUBCLASS_IRDA 2
518 #define UIPROTO_IRDA 0
520 #define UICLASS_VENDOR 0xff
523 #define USB_HUB_MAX_DEPTH 5
526 * Minimum time a device needs to be powered down to go through
527 * a power cycle. XXX Are these time in the spec?
529 #define USB_POWER_DOWN_TIME 200 /* ms */
530 #define USB_PORT_POWER_DOWN_TIME 100 /* ms */
533 /* These are the values from the spec. */
534 #define USB_PORT_RESET_DELAY 10 /* ms */
535 #define USB_PORT_ROOT_RESET_DELAY 50 /* ms */
536 #define USB_PORT_RESET_RECOVERY 10 /* ms */
537 #define USB_PORT_POWERUP_DELAY 100 /* ms */
538 #define USB_SET_ADDRESS_SETTLE 2 /* ms */
539 #define USB_RESUME_DELAY (20*5) /* ms */
540 #define USB_RESUME_WAIT 10 /* ms */
541 #define USB_RESUME_RECOVERY 10 /* ms */
542 #define USB_EXTRA_POWER_UP_TIME 0 /* ms */
544 /* Allow for marginal (i.e. non-conforming) devices. */
545 #define USB_PORT_RESET_DELAY 50 /* ms */
546 #define USB_PORT_ROOT_RESET_DELAY 250 /* ms */
547 #define USB_PORT_RESET_RECOVERY 250 /* ms */
548 #define USB_PORT_POWERUP_DELAY 300 /* ms */
549 #define USB_SET_ADDRESS_SETTLE 10 /* ms */
550 #define USB_RESUME_DELAY (50*5) /* ms */
551 #define USB_RESUME_WAIT 50 /* ms */
552 #define USB_RESUME_RECOVERY 50 /* ms */
553 #define USB_EXTRA_POWER_UP_TIME 20 /* ms */
556 #define USB_MIN_POWER 100 /* mA */
557 #define USB_MAX_POWER 500 /* mA */
559 #define USB_BUS_RESET_DELAY 100 /* ms XXX?*/
562 #define USB_UNCONFIG_NO 0
563 #define USB_UNCONFIG_INDEX (-1)
565 /*** ioctl() related stuff ***/
567 struct usb_ctl_request {
569 usb_device_request_t ucr_request;
572 #define USBD_SHORT_XFER_OK 0x04 /* allow short reads */
573 int ucr_actlen; /* actual length transferred */
576 struct usb_alt_interface {
577 int uai_config_index;
578 int uai_interface_index;
582 #define USB_CURRENT_CONFIG_INDEX (-1)
583 #define USB_CURRENT_ALT_INDEX (-1)
585 struct usb_config_desc {
586 int ucd_config_index;
587 usb_config_descriptor_t ucd_desc;
590 struct usb_interface_desc {
591 int uid_config_index;
592 int uid_interface_index;
594 usb_interface_descriptor_t uid_desc;
597 struct usb_endpoint_desc {
598 int ued_config_index;
599 int ued_interface_index;
601 int ued_endpoint_index;
602 usb_endpoint_descriptor_t ued_desc;
605 struct usb_full_desc {
606 int ufd_config_index;
611 struct usb_string_desc {
612 int usd_string_index;
614 usb_string_descriptor_t usd_desc;
617 struct usb_ctl_report_desc {
619 u_char ucrd_data[1024]; /* filled data size will vary */
622 typedef struct { u_int32_t cookie; } usb_event_cookie_t;
624 #define USB_MAX_DEVNAMES 4
625 #define USB_MAX_DEVNAMELEN 16
626 struct usb_device_info {
628 u_int8_t udi_addr; /* device address */
629 usb_event_cookie_t udi_cookie;
630 char udi_product[USB_MAX_STRING_LEN];
631 char udi_vendor[USB_MAX_STRING_LEN];
633 u_int16_t udi_productNo;
634 u_int16_t udi_vendorNo;
635 u_int16_t udi_releaseNo;
637 u_int8_t udi_subclass;
638 u_int8_t udi_protocol;
641 #define USB_SPEED_LOW 1
642 #define USB_SPEED_FULL 2
643 #define USB_SPEED_HIGH 3
644 int udi_power; /* power consumption in mA, 0 if selfpowered */
646 char udi_devnames[USB_MAX_DEVNAMES][USB_MAX_DEVNAMELEN];
647 u_int8_t udi_ports[16];/* hub only: addresses of devices on ports */
648 #define USB_PORT_ENABLED 0xff
649 #define USB_PORT_SUSPENDED 0xfe
650 #define USB_PORT_POWERED 0xfd
651 #define USB_PORT_DISABLED 0xfc
654 struct usb_ctl_report {
656 u_char ucr_data[1024]; /* filled data size will vary */
659 struct usb_device_stats {
660 u_long uds_requests[4]; /* indexed by transfer type UE_* */
666 #define WUSB_MIN_IE 0x80
667 #define WUSB_WCTA_IE 0x80
668 #define WUSB_WCONNECTACK_IE 0x81
669 #define WUSB_WHOSTINFO_IE 0x82
670 #define WUHI_GET_CA(_bmAttributes_) ((_bmAttributes_) & 0x3)
671 #define WUHI_CA_RECONN 0x00
672 #define WUHI_CA_LIMITED 0x01
673 #define WUHI_CA_ALL 0x03
674 #define WUHI_GET_MLSI(_bmAttributes_) (((_bmAttributes_) & 0x38) >> 3)
675 #define WUSB_WCHCHANGEANNOUNCE_IE 0x83
676 #define WUSB_WDEV_DISCONNECT_IE 0x84
677 #define WUSB_WHOST_DISCONNECT_IE 0x85
678 #define WUSB_WRELEASE_CHANNEL_IE 0x86
679 #define WUSB_WWORK_IE 0x87
680 #define WUSB_WCHANNEL_STOP_IE 0x88
681 #define WUSB_WDEV_KEEPALIVE_IE 0x89
682 #define WUSB_WISOCH_DISCARD_IE 0x8A
683 #define WUSB_WRESETDEVICE_IE 0x8B
684 #define WUSB_WXMIT_PACKET_ADJUST_IE 0x8C
685 #define WUSB_MAX_IE 0x8C
687 /* Device Notification Types */
689 #define WUSB_DN_MIN 0x01
690 #define WUSB_DN_CONNECT 0x01
691 # define WUSB_DA_OLDCONN 0x00
692 # define WUSB_DA_NEWCONN 0x01
693 # define WUSB_DA_SELF_BEACON 0x02
694 # define WUSB_DA_DIR_BEACON 0x04
695 # define WUSB_DA_NO_BEACON 0x06
696 #define WUSB_DN_DISCONNECT 0x02
697 #define WUSB_DN_EPRDY 0x03
698 #define WUSB_DN_MASAVAILCHANGED 0x04
699 #define WUSB_DN_REMOTEWAKEUP 0x05
700 #define WUSB_DN_SLEEP 0x06
701 #define WUSB_DN_ALIVE 0x07
702 #define WUSB_DN_MAX 0x07
705 /* WUSB Handshake Data. Used during the SET/GET HANDSHAKE requests */
706 typedef struct wusb_hndshk_data {
707 uint8_t bMessageNumber;
714 } UPACKED wusb_hndshk_data_t;
715 #define WUSB_HANDSHAKE_LEN_FOR_MIC 38
717 /* WUSB Connection Context */
718 typedef struct wusb_conn_context {
722 } UPACKED wusb_conn_context_t;
724 /* WUSB Security Descriptor */
725 typedef struct wusb_security_desc {
727 uint8_t bDescriptorType;
728 uint16_t wTotalLength;
729 uint8_t bNumEncryptionTypes;
730 } UPACKED wusb_security_desc_t;
732 /* WUSB Encryption Type Descriptor */
733 typedef struct wusb_encrypt_type_desc {
735 uint8_t bDescriptorType;
737 uint8_t bEncryptionType;
738 #define WUETD_UNSECURE 0
739 #define WUETD_WIRED 1
740 #define WUETD_CCM_1 2
741 #define WUETD_RSA_1 3
743 uint8_t bEncryptionValue;
744 uint8_t bAuthKeyIndex;
745 } UPACKED wusb_encrypt_type_desc_t;
747 /* WUSB Key Descriptor */
748 typedef struct wusb_key_desc {
750 uint8_t bDescriptorType;
753 uint8_t KeyData[1]; /* variable length */
754 } UPACKED wusb_key_desc_t;
756 /* WUSB BOS Descriptor (Binary device Object Store) */
757 typedef struct wusb_bos_desc {
759 uint8_t bDescriptorType;
760 uint16_t wTotalLength;
761 uint8_t bNumDeviceCaps;
762 } UPACKED wusb_bos_desc_t;
765 /* Device Capability Type Codes */
766 #define WUSB_DEVICE_CAPABILITY_WIRELESS_USB 0x01
768 /* Device Capability Descriptor */
769 typedef struct wusb_dev_cap_desc {
771 uint8_t bDescriptorType;
772 uint8_t bDevCapabilityType;
773 uint8_t caps[1]; /* Variable length */
774 } UPACKED wusb_dev_cap_desc_t;
776 /* Device Capability Descriptor */
777 typedef struct wusb_dev_cap_uwb_desc {
779 uint8_t bDescriptorType;
780 uint8_t bDevCapabilityType;
781 uint8_t bmAttributes;
782 uint16_t wPHYRates; /* Bitmap */
783 uint8_t bmTFITXPowerInfo;
784 uint8_t bmFFITXPowerInfo;
785 uint16_t bmBandGroup;
787 } UPACKED wusb_dev_cap_uwb_desc_t;
789 /* Wireless USB Endpoint Companion Descriptor */
790 typedef struct wusb_endpoint_companion_desc {
792 uint8_t bDescriptorType;
794 uint8_t bMaxSequence;
795 uint16_t wMaxStreamDelay;
796 uint16_t wOverTheAirPacketSize;
797 uint8_t bOverTheAirInterval;
798 uint8_t bmCompAttributes;
799 } UPACKED wusb_endpoint_companion_desc_t;
802 /* Wireless USB Numeric Association M1 Data Structure */
803 typedef struct wusb_m1_data {
806 uint8_t deviceFriendlyNameLength;
807 uint8_t sha_256_m3[32];
808 uint8_t deviceFriendlyName[256];
809 } UPACKED wusb_m1_data_t;
811 typedef struct wusb_m2_data {
814 uint8_t hostFriendlyNameLength;
816 uint8_t hostFriendlyName[256];
817 } UPACKED wusb_m2_data_t;
819 typedef struct wusb_m3_data {
822 } UPACKED wusb_m3_data_t;
824 typedef struct wusb_m4_data {
825 uint32_t _attributeTypeIdAndLength_1;
826 uint16_t associationTypeId;
828 uint32_t _attributeTypeIdAndLength_2;
829 uint16_t associationSubTypeId;
831 uint32_t _attributeTypeIdAndLength_3;
834 uint32_t _attributeTypeIdAndLength_4;
835 uint32_t associationStatus;
837 uint32_t _attributeTypeIdAndLength_5;
840 uint32_t _attributeTypeIdAndLength_6;
843 uint32_t _attributeTypeIdAndLength_7;
844 uint8_t bandGroups[2];
845 } UPACKED wusb_m4_data_t;