3 * @copy 2012 MinGW.org project
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 * DEALINGS IN THE SOFTWARE.
24 /* Created by Casper S. Hornstrup <chorns@users.sourceforge.net> */
27 #pragma GCC system_header
40 #define MAXIMUM_USB_STRING_LENGTH 255
42 #define USB_DEVICE_CLASS_RESERVED 0x00
43 #define USB_DEVICE_CLASS_AUDIO 0x01
44 #define USB_DEVICE_CLASS_COMMUNICATIONS 0x02
45 #define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03
46 #define USB_DEVICE_CLASS_MONITOR 0x04
47 #define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05
48 #define USB_DEVICE_CLASS_POWER 0x06
49 #define USB_DEVICE_CLASS_PRINTER 0x07
50 #define USB_DEVICE_CLASS_STORAGE 0x08
51 #define USB_DEVICE_CLASS_HUB 0x09
52 #define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF
54 #define USB_RESERVED_DESCRIPTOR_TYPE 0x06
55 #define USB_CONFIG_POWER_DESCRIPTOR_TYPE 0x07
56 #define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 0x08
58 #define USB_REQUEST_GET_STATUS 0x00
59 #define USB_REQUEST_CLEAR_FEATURE 0x01
60 #define USB_REQUEST_SET_FEATURE 0x03
61 #define USB_REQUEST_SET_ADDRESS 0x05
62 #define USB_REQUEST_GET_DESCRIPTOR 0x06
63 #define USB_REQUEST_SET_DESCRIPTOR 0x07
64 #define USB_REQUEST_GET_CONFIGURATION 0x08
65 #define USB_REQUEST_SET_CONFIGURATION 0x09
66 #define USB_REQUEST_GET_INTERFACE 0x0A
67 #define USB_REQUEST_SET_INTERFACE 0x0B
68 #define USB_REQUEST_SYNC_FRAME 0x0C
70 #define USB_GETSTATUS_SELF_POWERED 0x01
71 #define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED 0x02
73 #define BMREQUEST_HOST_TO_DEVICE 0
74 #define BMREQUEST_DEVICE_TO_HOST 1
76 #define BMREQUEST_STANDARD 0
77 #define BMREQUEST_CLASS 1
78 #define BMREQUEST_VENDOR 2
80 #define BMREQUEST_TO_DEVICE 0
81 #define BMREQUEST_TO_INTERFACE 1
82 #define BMREQUEST_TO_ENDPOINT 2
83 #define BMREQUEST_TO_OTHER 3
85 /* USB_COMMON_DESCRIPTOR.bDescriptorType constants */
86 #define USB_DEVICE_DESCRIPTOR_TYPE 0x01
87 #define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
88 #define USB_STRING_DESCRIPTOR_TYPE 0x03
89 #define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
90 #define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
92 typedef struct _USB_COMMON_DESCRIPTOR {
94 UCHAR bDescriptorType;
95 } USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR;
97 #define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) ((USHORT)((USHORT)d << 8 | i))
99 /* USB_CONFIGURATION_DESCRIPTOR.bmAttributes constants */
100 #define USB_CONFIG_POWERED_MASK 0xc0
101 #define USB_CONFIG_BUS_POWERED 0x80
102 #define USB_CONFIG_SELF_POWERED 0x40
103 #define USB_CONFIG_REMOTE_WAKEUP 0x20
105 #include <pshpack1.h>
106 typedef struct _USB_CONFIGURATION_DESCRIPTOR {
108 UCHAR bDescriptorType;
110 UCHAR bNumInterfaces;
111 UCHAR bConfigurationValue;
112 UCHAR iConfiguration;
115 } USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
118 typedef struct _USB_DEVICE_DESCRIPTOR {
120 UCHAR bDescriptorType;
123 UCHAR bDeviceSubClass;
124 UCHAR bDeviceProtocol;
125 UCHAR bMaxPacketSize0;
132 UCHAR bNumConfigurations;
133 } USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
135 #define USB_ENDPOINT_DIRECTION_MASK 0x80
137 #define USB_ENDPOINT_DIRECTION_OUT(x) (!((x) & USB_ENDPOINT_DIRECTION_MASK))
138 #define USB_ENDPOINT_DIRECTION_IN(x) ((x) & USB_ENDPOINT_DIRECTION_MASK)
140 /* USB_ENDPOINT_DESCRIPTOR.bmAttributes constants */
141 #define USB_ENDPOINT_TYPE_MASK 0x03
142 #define USB_ENDPOINT_TYPE_CONTROL 0x00
143 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
144 #define USB_ENDPOINT_TYPE_BULK 0x02
145 #define USB_ENDPOINT_TYPE_INTERRUPT 0x03
147 #include <pshpack1.h>
148 typedef struct _USB_ENDPOINT_DESCRIPTOR {
150 UCHAR bDescriptorType;
151 UCHAR bEndpointAddress;
153 USHORT wMaxPacketSize;
155 } USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR;
158 #define USB_FEATURE_ENDPOINT_STALL 0x0000
159 #define USB_FEATURE_REMOTE_WAKEUP 0x0001
161 typedef struct _USB_INTERFACE_DESCRIPTOR {
163 UCHAR bDescriptorType;
164 UCHAR bInterfaceNumber;
165 UCHAR bAlternateSetting;
167 UCHAR bInterfaceClass;
168 UCHAR bInterfaceSubClass;
169 UCHAR bInterfaceProtocol;
171 } USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
173 typedef struct _USB_STRING_DESCRIPTOR {
175 UCHAR bDescriptorType;
177 } USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;
179 #include <pshpack1.h>
180 typedef struct _USB_HUB_DESCRIPTOR {
181 UCHAR bDescriptorLength;
182 UCHAR bDescriptorType;
183 UCHAR bNumberOfPorts;
184 USHORT wHubCharacteristics;
185 UCHAR bPowerOnToPowerGood;
186 UCHAR bHubControlCurrent;
187 UCHAR bRemoveAndPowerMask[64];
188 } USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;
191 #define USB_SUPPORT_D0_COMMAND 0x01
192 #define USB_SUPPORT_D1_COMMAND 0x02
193 #define USB_SUPPORT_D2_COMMAND 0x04
194 #define USB_SUPPORT_D3_COMMAND 0x08
196 #define USB_SUPPORT_D1_WAKEUP 0x10
197 #define USB_SUPPORT_D2_WAKEUP 0x20
199 typedef struct _USB_CONFIGURATION_POWER_DESCRIPTOR {
201 UCHAR bDescriptorType;
202 UCHAR SelfPowerConsumedD0[3];
203 UCHAR bPowerSummaryId;
204 UCHAR bBusPowerSavingD1;
205 UCHAR bSelfPowerSavingD1;
206 UCHAR bBusPowerSavingD2;
207 UCHAR bSelfPowerSavingD2;
208 UCHAR bBusPowerSavingD3;
209 UCHAR bSelfPowerSavingD3;
210 USHORT TransitionTimeFromD1;
211 USHORT TransitionTimeFromD2;
212 USHORT TransitionTimeFromD3;
213 } USB_CONFIGURATION_POWER_DESCRIPTOR, *PUSB_CONFIGURATION_POWER_DESCRIPTOR;
215 #define USB_FEATURE_INTERFACE_POWER_D0 0x0002
216 #define USB_FEATURE_INTERFACE_POWER_D1 0x0003
217 #define USB_FEATURE_INTERFACE_POWER_D2 0x0004
218 #define USB_FEATURE_INTERFACE_POWER_D3 0x0005
220 #include <pshpack1.h>
221 typedef struct _USB_INTERFACE_POWER_DESCRIPTOR {
223 UCHAR bDescriptorType;
224 UCHAR bmCapabilitiesFlags;
225 UCHAR bBusPowerSavingD1;
226 UCHAR bSelfPowerSavingD1;
227 UCHAR bBusPowerSavingD2;
228 UCHAR bSelfPowerSavingD2;
229 UCHAR bBusPowerSavingD3;
230 UCHAR bSelfPowerSavingD3;
231 USHORT TransitionTimeFromD1;
232 USHORT TransitionTimeFromD2;
233 USHORT TransitionTimeFromD3;
234 } USB_INTERFACE_POWER_DESCRIPTOR, *PUSB_INTERFACE_POWER_DESCRIPTOR;
241 #endif /* __USB100_H */