OSDN Git Service

Insert removed author attribution.
[mingw/mingw-org-wsl.git] / include / ddk / usb100.h
1 /**
2  * @file usb100.h
3  * @copy 2012 MinGW.org project
4  *
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:
11  * 
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
14  * Software.
15  * 
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.
23  */
24 /* Created by Casper S. Hornstrup <chorns@users.sourceforge.net> */
25 #ifndef __USB100_H
26 #define __USB100_H
27 #pragma GCC system_header
28 #include <_mingw.h>
29
30 /*
31  * USB 1.0 support
32  */
33
34 #ifdef __cplusplus
35 extern "C" {
36 #endif
37
38 #include "ntddk.h"
39
40 #define MAXIMUM_USB_STRING_LENGTH         255
41
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
53
54 #define USB_RESERVED_DESCRIPTOR_TYPE        0x06
55 #define USB_CONFIG_POWER_DESCRIPTOR_TYPE    0x07
56 #define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 0x08
57
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
69
70 #define USB_GETSTATUS_SELF_POWERED            0x01
71 #define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED   0x02
72
73 #define BMREQUEST_HOST_TO_DEVICE          0
74 #define BMREQUEST_DEVICE_TO_HOST          1
75
76 #define BMREQUEST_STANDARD                0
77 #define BMREQUEST_CLASS                   1
78 #define BMREQUEST_VENDOR                  2
79
80 #define BMREQUEST_TO_DEVICE               0
81 #define BMREQUEST_TO_INTERFACE            1
82 #define BMREQUEST_TO_ENDPOINT             2
83 #define BMREQUEST_TO_OTHER                3
84
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
91
92 typedef struct _USB_COMMON_DESCRIPTOR {
93         UCHAR  bLength;
94         UCHAR  bDescriptorType;
95 } USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR;
96
97 #define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) ((USHORT)((USHORT)d << 8 | i))
98
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
104
105 #include <pshpack1.h>
106 typedef struct _USB_CONFIGURATION_DESCRIPTOR { 
107   UCHAR  bLength;
108   UCHAR  bDescriptorType;
109   USHORT  wTotalLength;
110   UCHAR  bNumInterfaces;
111   UCHAR  bConfigurationValue;
112   UCHAR  iConfiguration;
113   UCHAR  bmAttributes;
114   UCHAR  MaxPower;
115 } USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
116 #include <poppack.h>
117
118 typedef struct _USB_DEVICE_DESCRIPTOR { 
119   UCHAR  bLength;
120   UCHAR  bDescriptorType;
121   USHORT  bcdUSB;
122   UCHAR  bDeviceClass;
123   UCHAR  bDeviceSubClass;
124   UCHAR  bDeviceProtocol;
125   UCHAR  bMaxPacketSize0;
126   USHORT  idVendor;
127   USHORT  idProduct;
128   USHORT  bcdDevice;
129   UCHAR  iManufacturer;
130   UCHAR  iProduct;
131   UCHAR  iSerialNumber;
132   UCHAR  bNumConfigurations;
133 } USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
134
135 #define USB_ENDPOINT_DIRECTION_MASK       0x80
136
137 #define USB_ENDPOINT_DIRECTION_OUT(x) (!((x) & USB_ENDPOINT_DIRECTION_MASK))
138 #define USB_ENDPOINT_DIRECTION_IN(x) ((x) & USB_ENDPOINT_DIRECTION_MASK)
139
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
146
147 #include <pshpack1.h>
148 typedef struct _USB_ENDPOINT_DESCRIPTOR { 
149   UCHAR  bLength;
150   UCHAR  bDescriptorType;
151   UCHAR  bEndpointAddress;
152   UCHAR  bmAttributes;
153   USHORT  wMaxPacketSize;
154   UCHAR  bInterval;
155 } USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR;
156 #include <poppack.h>
157
158 #define USB_FEATURE_ENDPOINT_STALL        0x0000
159 #define USB_FEATURE_REMOTE_WAKEUP         0x0001
160
161 typedef struct _USB_INTERFACE_DESCRIPTOR { 
162   UCHAR  bLength;
163   UCHAR  bDescriptorType;
164   UCHAR  bInterfaceNumber;
165   UCHAR  bAlternateSetting;
166   UCHAR  bNumEndpoints;
167   UCHAR  bInterfaceClass;
168   UCHAR  bInterfaceSubClass;
169   UCHAR  bInterfaceProtocol;
170   UCHAR  iInterface;
171 } USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
172
173 typedef struct _USB_STRING_DESCRIPTOR {
174   UCHAR  bLength;
175   UCHAR  bDescriptorType;
176   WCHAR  bString[1];
177 } USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;
178
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;
189 #include <poppack.h>
190
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
195
196 #define USB_SUPPORT_D1_WAKEUP             0x10
197 #define USB_SUPPORT_D2_WAKEUP             0x20
198
199 typedef struct _USB_CONFIGURATION_POWER_DESCRIPTOR {
200         UCHAR  bLength;
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;
214
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
219
220 #include <pshpack1.h>
221 typedef struct _USB_INTERFACE_POWER_DESCRIPTOR {
222         UCHAR  bLength;
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;
235 #include <poppack.h>
236
237 #ifdef __cplusplus
238 }
239 #endif
240
241 #endif /* __USB100_H */