wut  v1.7.0
Wii U Toolchain
uhs_usbspec.h
Go to the documentation of this file.
1 #pragma once
2 #include <wut.h>
3 
4 #ifdef __cplusplus
5 extern "C" {
6 #endif
7 
8 /* USB class codes */
9 #define USBCLASS_DEVICE 0x00
10 #define USBCLASS_AUDIO 0x01
11 #define USBCLASS_HID 0x03
12 #define USBCLASS_STORAGE 0x08
13 
17 typedef struct UhsSetupPacket UhsSetupPacket;
18 
19 /* USB device descriptor */
20 struct WUT_PACKED UhsDeviceDescriptor
21 {
22  uint8_t bLength;
23  uint8_t bDescriptorType;
24  uint16_t bcdUsb;
25  uint8_t bDeviceClass;
26  uint8_t bDeviceSubclass;
27  uint8_t bDeviceProtocol;
28  uint8_t bMaxPacketSize;
29  uint16_t idVendor;
30  uint16_t idProduct;
31  uint16_t bcdDevice;
32  uint8_t iManufacturer;
33  uint8_t iProduct;
34  uint8_t iSerialNumber;
36 };
37 WUT_CHECK_OFFSET(UhsDeviceDescriptor, 0x00, bLength);
38 WUT_CHECK_OFFSET(UhsDeviceDescriptor, 0x01, bDescriptorType);
39 WUT_CHECK_OFFSET(UhsDeviceDescriptor, 0x02, bcdUsb);
40 WUT_CHECK_OFFSET(UhsDeviceDescriptor, 0x04, bDeviceClass);
41 WUT_CHECK_OFFSET(UhsDeviceDescriptor, 0x05, bDeviceSubclass);
42 WUT_CHECK_OFFSET(UhsDeviceDescriptor, 0x06, bDeviceProtocol);
43 WUT_CHECK_OFFSET(UhsDeviceDescriptor, 0x07, bMaxPacketSize);
44 WUT_CHECK_OFFSET(UhsDeviceDescriptor, 0x08, idVendor);
45 WUT_CHECK_OFFSET(UhsDeviceDescriptor, 0x0A, idProduct);
46 WUT_CHECK_OFFSET(UhsDeviceDescriptor, 0x0C, bcdDevice);
47 WUT_CHECK_OFFSET(UhsDeviceDescriptor, 0x0E, iManufacturer);
48 WUT_CHECK_OFFSET(UhsDeviceDescriptor, 0x0F, iProduct);
49 WUT_CHECK_OFFSET(UhsDeviceDescriptor, 0x10, iSerialNumber);
50 WUT_CHECK_OFFSET(UhsDeviceDescriptor, 0x11, bNumConfigurations);
51 WUT_CHECK_SIZE(UhsDeviceDescriptor, 0x12);
52 
53 /* USB configuration descriptor */
54 struct WUT_PACKED UhsConfigDescriptor
55 {
56  uint8_t bLength;
57  uint8_t bDescriptorType;
58  uint16_t wTotalLength;
59  uint8_t bNumInterfaces;
61  uint8_t iConfiguration;
62  uint8_t bmAttributes;
63  uint8_t bMaxPower;
64 };
65 WUT_CHECK_OFFSET(UhsConfigDescriptor, 0x00, bLength);
66 WUT_CHECK_OFFSET(UhsConfigDescriptor, 0x01, bDescriptorType);
67 WUT_CHECK_OFFSET(UhsConfigDescriptor, 0x02, wTotalLength);
68 WUT_CHECK_OFFSET(UhsConfigDescriptor, 0x04, bNumInterfaces);
69 WUT_CHECK_OFFSET(UhsConfigDescriptor, 0x05, bConfigurationValue);
70 WUT_CHECK_OFFSET(UhsConfigDescriptor, 0x06, iConfiguration);
71 WUT_CHECK_OFFSET(UhsConfigDescriptor, 0x07, bmAttributes);
72 WUT_CHECK_OFFSET(UhsConfigDescriptor, 0x08, bMaxPower);
73 WUT_CHECK_SIZE(UhsConfigDescriptor, 0x09);
74 
75 /* USB interface descriptor */
76 struct WUT_PACKED UhsInterfaceDescriptor
77 {
78  uint8_t bLength;
79  uint8_t bDescriptorType;
82  uint8_t bNumEndpoints;
83  uint8_t bInterfaceClass;
86  uint8_t iInterface;
87 };
88 WUT_CHECK_OFFSET(UhsInterfaceDescriptor, 0x00, bLength);
89 WUT_CHECK_OFFSET(UhsInterfaceDescriptor, 0x01, bDescriptorType);
90 WUT_CHECK_OFFSET(UhsInterfaceDescriptor, 0x02, bInterfaceNumber);
91 WUT_CHECK_OFFSET(UhsInterfaceDescriptor, 0x03, bAlternateSetting);
92 WUT_CHECK_OFFSET(UhsInterfaceDescriptor, 0x04, bNumEndpoints);
93 WUT_CHECK_OFFSET(UhsInterfaceDescriptor, 0x05, bInterfaceClass);
94 WUT_CHECK_OFFSET(UhsInterfaceDescriptor, 0x06, bInterfaceSubClass);
95 WUT_CHECK_OFFSET(UhsInterfaceDescriptor, 0x07, bInterfaceProtocol);
96 WUT_CHECK_OFFSET(UhsInterfaceDescriptor, 0x08, iInterface);
97 WUT_CHECK_SIZE(UhsInterfaceDescriptor, 0x09);
98 
99 /* USB setup packet */
100 struct WUT_PACKED UhsSetupPacket
101 {
102  uint8_t bmRequestType;
103  uint8_t bRequest;
104  uint16_t wValue;
105  uint16_t wIndex;
106  uint16_t wLength;
107 };
108 WUT_CHECK_OFFSET(UhsSetupPacket, 0x00, bmRequestType);
109 WUT_CHECK_OFFSET(UhsSetupPacket, 0x01, bRequest);
110 WUT_CHECK_OFFSET(UhsSetupPacket, 0x02, wValue);
111 WUT_CHECK_OFFSET(UhsSetupPacket, 0x04, wIndex);
112 WUT_CHECK_OFFSET(UhsSetupPacket, 0x06, wLength);
113 WUT_CHECK_SIZE(UhsSetupPacket, 0x08);
114 
115 #ifdef __cplusplus
116 }
117 #endif
uint8_t bNumInterfaces
Definition: uhs_usbspec.h:59
uint8_t bRequest
Definition: uhs_usbspec.h:103
uint8_t bDeviceProtocol
Definition: uhs_usbspec.h:27
uint16_t wLength
Definition: uhs_usbspec.h:106
uint8_t iConfiguration
Definition: uhs_usbspec.h:61
uint8_t bDescriptorType
Definition: uhs_usbspec.h:23
uint8_t bDeviceSubclass
Definition: uhs_usbspec.h:26
uint16_t wValue
Definition: uhs_usbspec.h:104
uint16_t wTotalLength
Definition: uhs_usbspec.h:58
uint8_t bMaxPacketSize
Definition: uhs_usbspec.h:28
uint8_t bNumConfigurations
Definition: uhs_usbspec.h:35
uint8_t bmRequestType
Definition: uhs_usbspec.h:102
uint16_t wIndex
Definition: uhs_usbspec.h:105
uint8_t bConfigurationValue
Definition: uhs_usbspec.h:60