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

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since e8e31d9 was ff788c3, checked in by Sean Bartell <wingedtachikoma@…>, 13 years ago

Bithenge: add USB descriptor example

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