Last active
July 6, 2023 23:43
-
-
Save tannewt/4c03dfe354c5d979720c7167730554b3 to your computer and use it in GitHub Desktop.
Start of Kaitai struct definition for usb descriptors
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| meta: | |
| id: usb_descriptors | |
| endian: le | |
| bit-endian: le | |
| seq: | |
| - id: descriptor | |
| type: usb_descriptor | |
| repeat: eos | |
| enums: | |
| descriptor_type: | |
| 0x01: device | |
| 0x02: configuration | |
| 0x03: string | |
| 0x04: interface | |
| 0x05: endpoint | |
| 0x06: device_qualifier | |
| 0x07: other_speed_configuration | |
| 0x08: interface_power | |
| 0x09: otg | |
| 0x0A: debug | |
| 0x0B: interface_association | |
| 0x21: cs_device | |
| 0x0F: bos | |
| 0x10: device_capability | |
| 0x29: hub_descriptor | |
| device_class: | |
| 0x00: reserved | |
| 0x02: communications | |
| 0x09: hub | |
| 0x11: billboard | |
| 0xDC: diagnostic | |
| 0xEF: miscellaneous | |
| 0xFF: vendor | |
| interface_class: | |
| 0x00: reserved | |
| 0x01: audio | |
| 0x02: communications | |
| 0x03: human_interface_device | |
| 0x05: physical | |
| 0x06: image | |
| 0x07: printer | |
| 0x08: mass_storage | |
| 0x0A: cdc_data | |
| 0x0B: smart_card | |
| 0x0D: content_security | |
| 0x0E: video | |
| 0x0F: personal_healthcare | |
| 0x10: audio_video | |
| 0x12: type_c_bridge | |
| 0x13: bulk_display | |
| 0x3C: i3c | |
| 0xDC: diagnostic | |
| 0xE0: wireless_controller | |
| 0xEF: miscellaneous | |
| 0xFF: vendor | |
| hub_protocol: | |
| 0x00: full_speed_hub | |
| 0x01: hi_speed_hub_with_single_tt | |
| 0x02: hi_speed_hub_with_multiple_tts | |
| audio_video_sub_class: | |
| 0x01: avcontrol_interface | |
| 0x02: avdata_video_streaming_interface | |
| 0x03: avdata_audio_streaming_interface | |
| hid_subclass: | |
| 0x00: no_subclass | |
| 0x01: boot | |
| hid_protocol: | |
| 0x00: none | |
| 0x01: keyboard | |
| 0x02: mouse | |
| transfer_type: | |
| 0: control | |
| 1: isochronous | |
| 2: bulk | |
| 3: interrupt | |
| synchronization_type: | |
| 0: no_synchronization | |
| 1: asynchronous | |
| 2: adaptive | |
| 3: synchronous | |
| usage_type: | |
| 0: data_endpoint | |
| 1: feedback_endpoint | |
| 2: implicit_feedback_data_endpoint | |
| hid_country_code: | |
| 00: not_supported | |
| 01: arabic | |
| 02: belgian | |
| 03: canadian_bilingual | |
| 04: canadian_french | |
| 05: czech_republic | |
| 06: danish | |
| 07: finnish | |
| 08: french | |
| 09: german | |
| 10: greek | |
| 11: hebrew | |
| 12: hungary | |
| 13: international_iso | |
| 14: italian | |
| 15: japan_katakana | |
| 16: korean | |
| 17: latin_american | |
| 18: netherlands_dutch | |
| 19: norwegian | |
| 20: persian_farsi | |
| 21: poland | |
| 22: portuguese | |
| 23: russia | |
| 24: slovakia | |
| 25: spanish | |
| 26: swedish | |
| 27: swiss_french | |
| 28: swiss_german | |
| 29: switzerland | |
| 30: taiwan | |
| 31: turkish_q | |
| 32: uk | |
| 33: us | |
| 34: yugoslavia | |
| 35: turkish_f | |
| types: | |
| usb_descriptor: | |
| seq: | |
| - id: b_length | |
| type: u1 | |
| doc: Total length of the descriptor | |
| - id: b_descriptor_type | |
| type: u1 | |
| enum: descriptor_type | |
| doc: Type of the descriptor | |
| - id: body | |
| size: b_length - 2 | |
| type: | |
| switch-on: b_descriptor_type | |
| cases: | |
| 'descriptor_type::device': device_descriptor | |
| 'descriptor_type::configuration': configuration_descriptor | |
| 'descriptor_type::string': string_descriptor | |
| 'descriptor_type::interface': interface_descriptor | |
| 'descriptor_type::endpoint': endpoint_descriptor | |
| 'descriptor_type::cs_device': class_specific_descriptor | |
| device_descriptor: | |
| doc-ref: USB 2.0 Table 9-8 | |
| seq: | |
| - id: bcd_usb | |
| type: u2 | |
| - id: b_device_class | |
| type: u1 | |
| enum: device_class | |
| - id: b_device_sub_class | |
| type: u1 | |
| - id: b_device_protocol | |
| type: u1 | |
| - id: b_max_packet_size0 | |
| type: u1 | |
| - id: id_vendor | |
| type: u2 | |
| - id: id_product | |
| type: u2 | |
| - id: bcd_device | |
| type: u2 | |
| - id: i_manufacturer | |
| type: u1 | |
| - id: i_product | |
| type: u1 | |
| - id: i_serial_number | |
| type: u1 | |
| - id: b_num_configurations | |
| type: u1 | |
| configuration_descriptor: | |
| doc-ref: USB 2.0 Table 9-10 | |
| seq: | |
| - id: w_total_length | |
| type: u2 | |
| - id: b_num_interfaces | |
| type: u1 | |
| - id: b_configuration_value | |
| type: u1 | |
| - id: i_configuration | |
| type: u1 | |
| - id: bm_attributes | |
| type: u1 | |
| - id: b_max_power | |
| type: u1 | |
| doc: Max power in milliamps | |
| string_descriptor: | |
| doc-ref: USB 2.0 Table 9-16 | |
| seq: | |
| - id: b_string | |
| type: str | |
| encoding: UTF-16 | |
| size: _parent.b_length - 2 | |
| interface_descriptor: | |
| doc-ref: USB 2.0 Table 9-12 | |
| seq: | |
| - id: b_interface_number | |
| type: u1 | |
| - id: b_alternate_setting | |
| type: u1 | |
| - id: b_num_endpoints | |
| type: u1 | |
| - id: b_interface_class | |
| type: u1 | |
| enum: interface_class | |
| - id: b_interface_sub_class | |
| type: u1 | |
| enum: hid_subclass | |
| - id: b_interface_protocol | |
| type: u1 | |
| enum: hid_protocol | |
| - id: i_interface | |
| type: u1 | |
| endpoint_descriptor: | |
| doc-ref: USB 2.0 Table 9-13 | |
| seq: | |
| - id: b_endpoint_address | |
| type: u1 | |
| # - id: bm_attributes | |
| # type: u1 | |
| - id: transfer_type | |
| type: b2 | |
| enum: transfer_type | |
| - id: synchronization_type | |
| type: b2 | |
| enum: synchronization_type | |
| if: transfer_type == transfer_type::isochronous | |
| - id: usage_type | |
| type: b2 | |
| enum: usage_type | |
| if: transfer_type == transfer_type::isochronous | |
| - type: b2 | |
| if: transfer_type == transfer_type::isochronous | |
| - type: b6 | |
| if: transfer_type != transfer_type::isochronous | |
| - id: w_max_packet_size | |
| type: u2 | |
| - id: b_interval | |
| type: u1 | |
| descriptor_info: | |
| seq: | |
| - id: b_descriptor_type | |
| type: u1 | |
| - id: w_descriptor_length | |
| type: u2 | |
| hid_descriptor: | |
| seq: | |
| - id: bcd_hid | |
| type: u2 | |
| - id: b_country_code | |
| type: u1 | |
| enum: hid_country_code | |
| - id: b_num_descriptors | |
| type: u1 | |
| - id: descriptors | |
| type: descriptor_info | |
| repeat: eos | |
| class_specific_descriptor: | |
| seq: | |
| - id: class_descriptor | |
| size: _parent.b_length - 2 | |
| type: hid_descriptor |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment