source: mainline/uspace/dist/src/bithenge/usbdesc.bh@ 1abcf1d

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 1abcf1d was 3061bc1, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 7 years ago

style: Remove trailing whitespace on non-empty lines, remaining files.

  • Property mode set to 100644
File size: 1.6 KB
Line 
1##
2##
3## USB DESCRIPTORS
4##
5##
6
7# Originally by Vojtech Horky.
8
9# Block prefixed with a byte length
10transform block = (in.data) <- struct {
11 .bLength <- uint8;
12 .data <- known_length(.bLength - 1);
13};
14
15# USB configuration descriptor
16# This is not the full configuration descriptor (i.e. with interface
17# and endpoint descriptors included) but only the header.
18transform usb_configuration_descriptor_bare = struct {
19 .wTotalLength <- uint16le;
20 .bNumInterfaces <- uint8;
21 .bConfigurationValue <- uint8;
22 .iConfiguration <- uint8;
23 .bmAttributes <- uint8;
24 .MaxPower <- uint8;
25};
26
27# USB interface descriptor
28transform usb_interface_descriptor = struct {
29 .bInterfaceNumber <- uint8;
30 .bAlternateSetting <- uint8;
31 .bNumEndpoints <- uint8;
32 .bInterfaceClass <- uint8;
33 .bInterfaceSubClass <- uint8;
34 .bInterfaceProtocol <- uint8;
35 .iInterface <- uint8;
36};
37
38# USB endpoint descriptor
39transform usb_endpoint_descriptor = struct {
40 .bEndpointAddress <- uint8;
41 .bmAttributes <- uint8;
42 .wMaxPacketSize <- uint16le;
43 .bInterval <- uint8;
44};
45
46# USB HID descriptor
47transform usb_hid_descriptor = struct {
48 .bcdHID <- uint16le;
49 .bCountryCode <- uint8;
50 .bNumDescriptors <- uint8;
51 <- repeat(.bNumDescriptors) { struct {
52 .bDescriptorType <- uint8;
53 .wDescriptorLength <- uint16le;
54 } };
55};
56
57# USB descriptor
58transform usb_descriptor = struct {
59 .bDescriptorType <- uint8;
60 <- switch (.bDescriptorType) {
61 2: usb_configuration_descriptor_bare;
62 4: usb_interface_descriptor;
63 5: usb_endpoint_descriptor;
64 33: usb_hid_descriptor;
65 };
66} <- block;
67
68transform main = repeat { usb_descriptor };
Note: See TracBrowser for help on using the repository browser.