diff options
Diffstat (limited to 'include/linux/usb/ch9.h')
-rw-r--r-- | include/linux/usb/ch9.h | 57 |
1 files changed, 37 insertions, 20 deletions
diff --git a/include/linux/usb/ch9.h b/include/linux/usb/ch9.h index ae7833749fa2..6169438ec5a2 100644 --- a/include/linux/usb/ch9.h +++ b/include/linux/usb/ch9.h | |||
@@ -1,8 +1,9 @@ | |||
1 | /* | 1 | /* |
2 | * This file holds USB constants and structures that are needed for USB | 2 | * This file holds USB constants and structures that are needed for |
3 | * device APIs. These are used by the USB device model, which is defined | 3 | * USB device APIs. These are used by the USB device model, which is |
4 | * in chapter 9 of the USB 2.0 specification. Linux has several APIs in C | 4 | * defined in chapter 9 of the USB 2.0 specification and in the |
5 | * that need these: | 5 | * Wireless USB 1.0 (spread around). Linux has several APIs in C that |
6 | * need these: | ||
6 | * | 7 | * |
7 | * - the master/host side Linux-USB kernel driver API; | 8 | * - the master/host side Linux-USB kernel driver API; |
8 | * - the "usbfs" user space API; and | 9 | * - the "usbfs" user space API; and |
@@ -14,6 +15,19 @@ | |||
14 | * | 15 | * |
15 | * There's also "Wireless USB", using low power short range radios for | 16 | * There's also "Wireless USB", using low power short range radios for |
16 | * peripheral interconnection but otherwise building on the USB framework. | 17 | * peripheral interconnection but otherwise building on the USB framework. |
18 | * | ||
19 | * Note all descriptors are declared '__attribute__((packed))' so that: | ||
20 | * | ||
21 | * [a] they never get padded, either internally (USB spec writers | ||
22 | * probably handled that) or externally; | ||
23 | * | ||
24 | * [b] so that accessing bigger-than-a-bytes fields will never | ||
25 | * generate bus errors on any platform, even when the location of | ||
26 | * its descriptor inside a bundle isn't "naturally aligned", and | ||
27 | * | ||
28 | * [c] for consistency, removing all doubt even when it appears to | ||
29 | * someone that the two other points are non-issues for that | ||
30 | * particular descriptor type. | ||
17 | */ | 31 | */ |
18 | 32 | ||
19 | #ifndef __LINUX_USB_CH9_H | 33 | #ifndef __LINUX_USB_CH9_H |
@@ -167,12 +181,15 @@ struct usb_ctrlrequest { | |||
167 | #define USB_DT_WIRE_ADAPTER 0x21 | 181 | #define USB_DT_WIRE_ADAPTER 0x21 |
168 | #define USB_DT_RPIPE 0x22 | 182 | #define USB_DT_RPIPE 0x22 |
169 | 183 | ||
170 | /* conventional codes for class-specific descriptors */ | 184 | /* Conventional codes for class-specific descriptors. The convention is |
171 | #define USB_DT_CS_DEVICE 0x21 | 185 | * defined in the USB "Common Class" Spec (3.11). Individual class specs |
172 | #define USB_DT_CS_CONFIG 0x22 | 186 | * are authoritative for their usage, not the "common class" writeup. |
173 | #define USB_DT_CS_STRING 0x23 | 187 | */ |
174 | #define USB_DT_CS_INTERFACE 0x24 | 188 | #define USB_DT_CS_DEVICE (USB_TYPE_CLASS | USB_DT_DEVICE) |
175 | #define USB_DT_CS_ENDPOINT 0x25 | 189 | #define USB_DT_CS_CONFIG (USB_TYPE_CLASS | USB_DT_CONFIG) |
190 | #define USB_DT_CS_STRING (USB_TYPE_CLASS | USB_DT_STRING) | ||
191 | #define USB_DT_CS_INTERFACE (USB_TYPE_CLASS | USB_DT_INTERFACE) | ||
192 | #define USB_DT_CS_ENDPOINT (USB_TYPE_CLASS | USB_DT_ENDPOINT) | ||
176 | 193 | ||
177 | /* All standard descriptors have these 2 fields at the beginning */ | 194 | /* All standard descriptors have these 2 fields at the beginning */ |
178 | struct usb_descriptor_header { | 195 | struct usb_descriptor_header { |
@@ -367,7 +384,7 @@ struct usb_debug_descriptor { | |||
367 | /* bulk endpoints with 8 byte maxpacket */ | 384 | /* bulk endpoints with 8 byte maxpacket */ |
368 | __u8 bDebugInEndpoint; | 385 | __u8 bDebugInEndpoint; |
369 | __u8 bDebugOutEndpoint; | 386 | __u8 bDebugOutEndpoint; |
370 | }; | 387 | } __attribute__((packed)); |
371 | 388 | ||
372 | /*-------------------------------------------------------------------------*/ | 389 | /*-------------------------------------------------------------------------*/ |
373 | 390 | ||
@@ -396,7 +413,7 @@ struct usb_security_descriptor { | |||
396 | 413 | ||
397 | __le16 wTotalLength; | 414 | __le16 wTotalLength; |
398 | __u8 bNumEncryptionTypes; | 415 | __u8 bNumEncryptionTypes; |
399 | }; | 416 | } __attribute__((packed)); |
400 | 417 | ||
401 | /*-------------------------------------------------------------------------*/ | 418 | /*-------------------------------------------------------------------------*/ |
402 | 419 | ||
@@ -410,7 +427,7 @@ struct usb_key_descriptor { | |||
410 | __u8 tTKID[3]; | 427 | __u8 tTKID[3]; |
411 | __u8 bReserved; | 428 | __u8 bReserved; |
412 | __u8 bKeyData[0]; | 429 | __u8 bKeyData[0]; |
413 | }; | 430 | } __attribute__((packed)); |
414 | 431 | ||
415 | /*-------------------------------------------------------------------------*/ | 432 | /*-------------------------------------------------------------------------*/ |
416 | 433 | ||
@@ -426,7 +443,7 @@ struct usb_encryption_descriptor { | |||
426 | #define USB_ENC_TYPE_RSA_1 3 /* rsa3072/sha1 auth */ | 443 | #define USB_ENC_TYPE_RSA_1 3 /* rsa3072/sha1 auth */ |
427 | __u8 bEncryptionValue; /* use in SET_ENCRYPTION */ | 444 | __u8 bEncryptionValue; /* use in SET_ENCRYPTION */ |
428 | __u8 bAuthKeyIndex; | 445 | __u8 bAuthKeyIndex; |
429 | }; | 446 | } __attribute__((packed)); |
430 | 447 | ||
431 | 448 | ||
432 | /*-------------------------------------------------------------------------*/ | 449 | /*-------------------------------------------------------------------------*/ |
@@ -438,7 +455,7 @@ struct usb_bos_descriptor { | |||
438 | 455 | ||
439 | __le16 wTotalLength; | 456 | __le16 wTotalLength; |
440 | __u8 bNumDeviceCaps; | 457 | __u8 bNumDeviceCaps; |
441 | }; | 458 | } __attribute__((packed)); |
442 | 459 | ||
443 | /*-------------------------------------------------------------------------*/ | 460 | /*-------------------------------------------------------------------------*/ |
444 | 461 | ||
@@ -447,7 +464,7 @@ struct usb_dev_cap_header { | |||
447 | __u8 bLength; | 464 | __u8 bLength; |
448 | __u8 bDescriptorType; | 465 | __u8 bDescriptorType; |
449 | __u8 bDevCapabilityType; | 466 | __u8 bDevCapabilityType; |
450 | }; | 467 | } __attribute__((packed)); |
451 | 468 | ||
452 | #define USB_CAP_TYPE_WIRELESS_USB 1 | 469 | #define USB_CAP_TYPE_WIRELESS_USB 1 |
453 | 470 | ||
@@ -475,7 +492,7 @@ struct usb_wireless_cap_descriptor { /* Ultra Wide Band */ | |||
475 | __u8 bmFFITXPowerInfo; /* FFI power levels */ | 492 | __u8 bmFFITXPowerInfo; /* FFI power levels */ |
476 | __le16 bmBandGroup; | 493 | __le16 bmBandGroup; |
477 | __u8 bReserved; | 494 | __u8 bReserved; |
478 | }; | 495 | } __attribute__((packed)); |
479 | 496 | ||
480 | /*-------------------------------------------------------------------------*/ | 497 | /*-------------------------------------------------------------------------*/ |
481 | 498 | ||
@@ -496,7 +513,7 @@ struct usb_wireless_ep_comp_descriptor { | |||
496 | #define USB_ENDPOINT_SWITCH_NO 0 | 513 | #define USB_ENDPOINT_SWITCH_NO 0 |
497 | #define USB_ENDPOINT_SWITCH_SWITCH 1 | 514 | #define USB_ENDPOINT_SWITCH_SWITCH 1 |
498 | #define USB_ENDPOINT_SWITCH_SCALE 2 | 515 | #define USB_ENDPOINT_SWITCH_SCALE 2 |
499 | }; | 516 | } __attribute__((packed)); |
500 | 517 | ||
501 | /*-------------------------------------------------------------------------*/ | 518 | /*-------------------------------------------------------------------------*/ |
502 | 519 | ||
@@ -512,7 +529,7 @@ struct usb_handshake { | |||
512 | __u8 CDID[16]; | 529 | __u8 CDID[16]; |
513 | __u8 nonce[16]; | 530 | __u8 nonce[16]; |
514 | __u8 MIC[8]; | 531 | __u8 MIC[8]; |
515 | }; | 532 | } __attribute__((packed)); |
516 | 533 | ||
517 | /*-------------------------------------------------------------------------*/ | 534 | /*-------------------------------------------------------------------------*/ |
518 | 535 | ||
@@ -524,7 +541,7 @@ struct usb_connection_context { | |||
524 | __u8 CHID[16]; /* persistent host id */ | 541 | __u8 CHID[16]; /* persistent host id */ |
525 | __u8 CDID[16]; /* device id (unique w/in host context) */ | 542 | __u8 CDID[16]; /* device id (unique w/in host context) */ |
526 | __u8 CK[16]; /* connection key */ | 543 | __u8 CK[16]; /* connection key */ |
527 | }; | 544 | } __attribute__((packed)); |
528 | 545 | ||
529 | /*-------------------------------------------------------------------------*/ | 546 | /*-------------------------------------------------------------------------*/ |
530 | 547 | ||