More work on USB related definitions
[reactos.git] / include / ddk / usb100.h
1 /*
2 * usb100.h
3 *
4 * USB 1.0 support
5 *
6 * This file is part of the w32api package.
7 *
8 * Contributors:
9 * Created by Casper S. Hornstrup <chorns@users.sourceforge.net>
10 *
11 * THIS SOFTWARE IS NOT COPYRIGHTED
12 *
13 * This source code is offered for use in the public domain. You may
14 * use, modify or distribute it freely.
15 *
16 * This code is distributed in the hope that it will be useful but
17 * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY
18 * DISCLAIMED. This includes but is not limited to warranties of
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
20 *
21 */
22
23 #ifndef __USB100_H
24 #define __USB100_H
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 #define MAXIMUM_USB_STRING_LENGTH 255
31
32 #define USB_DEVICE_CLASS_RESERVED 0x00
33 #define USB_DEVICE_CLASS_AUDIO 0x01
34 #define USB_DEVICE_CLASS_COMMUNICATIONS 0x02
35 #define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03
36 #define USB_DEVICE_CLASS_MONITOR 0x04
37 #define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05
38 #define USB_DEVICE_CLASS_POWER 0x06
39 #define USB_DEVICE_CLASS_PRINTER 0x07
40 #define USB_DEVICE_CLASS_STORAGE 0x08
41 #define USB_DEVICE_CLASS_HUB 0x09
42 #define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF
43
44 #define USB_RESERVED_DESCRIPTOR_TYPE 0x06
45 #define USB_CONFIG_POWER_DESCRIPTOR_TYPE 0x07
46 #define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 0x08
47
48 #define USB_REQUEST_GET_STATUS 0x00
49 #define USB_REQUEST_CLEAR_FEATURE 0x01
50 #define USB_REQUEST_SET_FEATURE 0x03
51 #define USB_REQUEST_SET_ADDRESS 0x05
52 #define USB_REQUEST_GET_DESCRIPTOR 0x06
53 #define USB_REQUEST_SET_DESCRIPTOR 0x07
54 #define USB_REQUEST_GET_CONFIGURATION 0x08
55 #define USB_REQUEST_SET_CONFIGURATION 0x09
56 #define USB_REQUEST_GET_INTERFACE 0x0A
57 #define USB_REQUEST_SET_INTERFACE 0x0B
58 #define USB_REQUEST_SYNC_FRAME 0x0C
59
60 #define USB_GETSTATUS_SELF_POWERED 0x01
61 #define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED 0x02
62
63 #define BMREQUEST_HOST_TO_DEVICE 0
64 #define BMREQUEST_DEVICE_TO_HOST 1
65
66 #define BMREQUEST_STANDARD 0
67 #define BMREQUEST_CLASS 1
68 #define BMREQUEST_VENDOR 2
69
70 #define BMREQUEST_TO_DEVICE 0
71 #define BMREQUEST_TO_INTERFACE 1
72 #define BMREQUEST_TO_ENDPOINT 2
73 #define BMREQUEST_TO_OTHER 3
74
75 /* USB_COMMON_DESCRIPTOR.bDescriptorType constants */
76 #define USB_DEVICE_DESCRIPTOR_TYPE 0x01
77 #define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
78 #define USB_STRING_DESCRIPTOR_TYPE 0x03
79 #define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
80 #define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
81
82 typedef struct _USB_COMMON_DESCRIPTOR {
83 UCHAR bLength;
84 UCHAR bDescriptorType;
85 } USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR;
86
87 #define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) ((USHORT)((USHORT)d << 8 | i))
88
89 /* USB_CONFIGURATION_DESCRIPTOR.bmAttributes constants */
90 #define USB_CONFIG_POWERED_MASK 0xc0
91 #define USB_CONFIG_BUS_POWERED 0x80
92 #define USB_CONFIG_SELF_POWERED 0x40
93 #define USB_CONFIG_REMOTE_WAKEUP 0x20
94
95 #include <pshpack1.h>
96 typedef struct _USB_CONFIGURATION_DESCRIPTOR {
97 UCHAR bLength;
98 UCHAR bDescriptorType;
99 USHORT wTotalLength;
100 UCHAR bNumInterfaces;
101 UCHAR bConfigurationValue;
102 UCHAR iConfiguration;
103 UCHAR bmAttributes;
104 UCHAR MaxPower;
105 } USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
106 #include <poppack.h>
107
108 typedef struct _USB_DEVICE_DESCRIPTOR {
109 UCHAR bLength;
110 UCHAR bDescriptorType;
111 USHORT bcdUSB;
112 UCHAR bDeviceClass;
113 UCHAR bDeviceSubClass;
114 UCHAR bDeviceProtocol;
115 UCHAR bMaxPacketSize0;
116 USHORT idVendor;
117 USHORT idProduct;
118 USHORT bcdDevice;
119 UCHAR iManufacturer;
120 UCHAR iProduct;
121 UCHAR iSerialNumber;
122 UCHAR bNumConfigurations;
123 } USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
124
125 #define USB_ENDPOINT_DIRECTION_MASK 0x80
126
127 #define USB_ENDPOINT_DIRECTION_OUT(x) (!((x) & USB_ENDPOINT_DIRECTION_MASK))
128 #define USB_ENDPOINT_DIRECTION_IN(x) ((x) & USB_ENDPOINT_DIRECTION_MASK)
129
130 /* USB_ENDPOINT_DESCRIPTOR.bmAttributes constants */
131 #define USB_ENDPOINT_TYPE_MASK 0x03
132 #define USB_ENDPOINT_TYPE_CONTROL 0x00
133 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
134 #define USB_ENDPOINT_TYPE_BULK 0x02
135 #define USB_ENDPOINT_TYPE_INTERRUPT 0x03
136
137 #include <pshpack1.h>
138 typedef struct _USB_ENDPOINT_DESCRIPTOR {
139 UCHAR bLength;
140 UCHAR bDescriptorType;
141 UCHAR bEndpointAddress;
142 UCHAR bmAttributes;
143 USHORT wMaxPacketSize;
144 UCHAR bInterval;
145 } USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR;
146 #include <poppack.h>
147
148 #define USB_FEATURE_ENDPOINT_STALL 0x0000
149 #define USB_FEATURE_REMOTE_WAKEUP 0x0001
150
151 typedef struct _USB_INTERFACE_DESCRIPTOR {
152 UCHAR bLength;
153 UCHAR bDescriptorType;
154 UCHAR bInterfaceNumber;
155 UCHAR bAlternateSetting;
156 UCHAR bNumEndpoints;
157 UCHAR bInterfaceClass;
158 UCHAR bInterfaceSubClass;
159 UCHAR bInterfaceProtocol;
160 UCHAR iInterface;
161 } USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
162
163 typedef struct _USB_STRING_DESCRIPTOR {
164 UCHAR bLength;
165 UCHAR bDescriptorType;
166 WCHAR bString[1];
167 } USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;
168
169 #include <pshpack1.h>
170 typedef struct _USB_HUB_DESCRIPTOR {
171 UCHAR bDescriptorLength;
172 UCHAR bDescriptorType;
173 UCHAR bNumberOfPorts;
174 USHORT wHubCharacteristics;
175 UCHAR bPowerOnToPowerGood;
176 UCHAR bHubControlCurrent;
177 UCHAR bRemoveAndPowerMask[64];
178 } USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;
179 #include <poppack.h>
180
181 #define USB_SUPPORT_D0_COMMAND 0x01
182 #define USB_SUPPORT_D1_COMMAND 0x02
183 #define USB_SUPPORT_D2_COMMAND 0x04
184 #define USB_SUPPORT_D3_COMMAND 0x08
185
186 #define USB_SUPPORT_D1_WAKEUP 0x10
187 #define USB_SUPPORT_D2_WAKEUP 0x20
188
189 typedef struct _USB_CONFIGURATION_POWER_DESCRIPTOR {
190 UCHAR bLength;
191 UCHAR bDescriptorType;
192 UCHAR SelfPowerConsumedD0[3];
193 UCHAR bPowerSummaryId;
194 UCHAR bBusPowerSavingD1;
195 UCHAR bSelfPowerSavingD1;
196 UCHAR bBusPowerSavingD2;
197 UCHAR bSelfPowerSavingD2;
198 UCHAR bBusPowerSavingD3;
199 UCHAR bSelfPowerSavingD3;
200 USHORT TransitionTimeFromD1;
201 USHORT TransitionTimeFromD2;
202 USHORT TransitionTimeFromD3;
203 } USB_CONFIGURATION_POWER_DESCRIPTOR, *PUSB_CONFIGURATION_POWER_DESCRIPTOR;
204
205 #define USB_FEATURE_INTERFACE_POWER_D0 0x0002
206 #define USB_FEATURE_INTERFACE_POWER_D1 0x0003
207 #define USB_FEATURE_INTERFACE_POWER_D2 0x0004
208 #define USB_FEATURE_INTERFACE_POWER_D3 0x0005
209
210 #include <pshpack1.h>
211 typedef struct _USB_INTERFACE_POWER_DESCRIPTOR {
212 UCHAR bLength;
213 UCHAR bDescriptorType;
214 UCHAR bmCapabilitiesFlags;
215 UCHAR bBusPowerSavingD1;
216 UCHAR bSelfPowerSavingD1;
217 UCHAR bBusPowerSavingD2;
218 UCHAR bSelfPowerSavingD2;
219 UCHAR bBusPowerSavingD3;
220 UCHAR bSelfPowerSavingD3;
221 USHORT TransitionTimeFromD1;
222 USHORT TransitionTimeFromD2;
223 USHORT TransitionTimeFromD3;
224 } USB_INTERFACE_POWER_DESCRIPTOR, *PUSB_INTERFACE_POWER_DESCRIPTOR;
225 #include <poppack.h>
226
227 #ifdef __cplusplus
228 }
229 #endif
230
231 #endif /* __USB100_H */