- Fix KiDispatchException to unmask KI_EXCEPTION_INTERNAL when setting the exception...
[reactos.git] / reactos / 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 #if __GNUC__ >=3
27 #pragma GCC system_header
28 #endif
29
30 #ifdef __cplusplus
31 extern "C" {
32 #endif
33
34 #define MAXIMUM_USB_STRING_LENGTH 255
35
36 #define USB_DEVICE_CLASS_RESERVED 0x00
37 #define USB_DEVICE_CLASS_AUDIO 0x01
38 #define USB_DEVICE_CLASS_COMMUNICATIONS 0x02
39 #define USB_DEVICE_CLASS_HUMAN_INTERFACE 0x03
40 #define USB_DEVICE_CLASS_MONITOR 0x04
41 #define USB_DEVICE_CLASS_PHYSICAL_INTERFACE 0x05
42 #define USB_DEVICE_CLASS_POWER 0x06
43 #define USB_DEVICE_CLASS_PRINTER 0x07
44 #define USB_DEVICE_CLASS_STORAGE 0x08
45 #define USB_DEVICE_CLASS_HUB 0x09
46 #define USB_DEVICE_CLASS_VENDOR_SPECIFIC 0xFF
47
48 #define USB_RESERVED_DESCRIPTOR_TYPE 0x06
49 #define USB_CONFIG_POWER_DESCRIPTOR_TYPE 0x07
50 #define USB_INTERFACE_POWER_DESCRIPTOR_TYPE 0x08
51
52 #define USB_REQUEST_GET_STATUS 0x00
53 #define USB_REQUEST_CLEAR_FEATURE 0x01
54 #define USB_REQUEST_SET_FEATURE 0x03
55 #define USB_REQUEST_SET_ADDRESS 0x05
56 #define USB_REQUEST_GET_DESCRIPTOR 0x06
57 #define USB_REQUEST_SET_DESCRIPTOR 0x07
58 #define USB_REQUEST_GET_CONFIGURATION 0x08
59 #define USB_REQUEST_SET_CONFIGURATION 0x09
60 #define USB_REQUEST_GET_INTERFACE 0x0A
61 #define USB_REQUEST_SET_INTERFACE 0x0B
62 #define USB_REQUEST_SYNC_FRAME 0x0C
63
64 #define USB_GETSTATUS_SELF_POWERED 0x01
65 #define USB_GETSTATUS_REMOTE_WAKEUP_ENABLED 0x02
66
67 #define BMREQUEST_HOST_TO_DEVICE 0
68 #define BMREQUEST_DEVICE_TO_HOST 1
69
70 #define BMREQUEST_STANDARD 0
71 #define BMREQUEST_CLASS 1
72 #define BMREQUEST_VENDOR 2
73
74 #define BMREQUEST_TO_DEVICE 0
75 #define BMREQUEST_TO_INTERFACE 1
76 #define BMREQUEST_TO_ENDPOINT 2
77 #define BMREQUEST_TO_OTHER 3
78
79 /* USB_COMMON_DESCRIPTOR.bDescriptorType constants */
80 #define USB_DEVICE_DESCRIPTOR_TYPE 0x01
81 #define USB_CONFIGURATION_DESCRIPTOR_TYPE 0x02
82 #define USB_STRING_DESCRIPTOR_TYPE 0x03
83 #define USB_INTERFACE_DESCRIPTOR_TYPE 0x04
84 #define USB_ENDPOINT_DESCRIPTOR_TYPE 0x05
85
86 typedef struct _USB_COMMON_DESCRIPTOR {
87 UCHAR bLength;
88 UCHAR bDescriptorType;
89 } USB_COMMON_DESCRIPTOR, *PUSB_COMMON_DESCRIPTOR;
90
91 #define USB_DESCRIPTOR_MAKE_TYPE_AND_INDEX(d, i) ((USHORT)((USHORT)d << 8 | i))
92
93 /* USB_CONFIGURATION_DESCRIPTOR.bmAttributes constants */
94 #define USB_CONFIG_POWERED_MASK 0xc0
95 #define USB_CONFIG_BUS_POWERED 0x80
96 #define USB_CONFIG_SELF_POWERED 0x40
97 #define USB_CONFIG_REMOTE_WAKEUP 0x20
98
99 #include <pshpack1.h>
100 typedef struct _USB_CONFIGURATION_DESCRIPTOR {
101 UCHAR bLength;
102 UCHAR bDescriptorType;
103 USHORT wTotalLength;
104 UCHAR bNumInterfaces;
105 UCHAR bConfigurationValue;
106 UCHAR iConfiguration;
107 UCHAR bmAttributes;
108 UCHAR MaxPower;
109 } USB_CONFIGURATION_DESCRIPTOR, *PUSB_CONFIGURATION_DESCRIPTOR;
110 #include <poppack.h>
111
112 typedef struct _USB_DEVICE_DESCRIPTOR {
113 UCHAR bLength;
114 UCHAR bDescriptorType;
115 USHORT bcdUSB;
116 UCHAR bDeviceClass;
117 UCHAR bDeviceSubClass;
118 UCHAR bDeviceProtocol;
119 UCHAR bMaxPacketSize0;
120 USHORT idVendor;
121 USHORT idProduct;
122 USHORT bcdDevice;
123 UCHAR iManufacturer;
124 UCHAR iProduct;
125 UCHAR iSerialNumber;
126 UCHAR bNumConfigurations;
127 } USB_DEVICE_DESCRIPTOR, *PUSB_DEVICE_DESCRIPTOR;
128
129 #define USB_ENDPOINT_DIRECTION_MASK 0x80
130
131 #define USB_ENDPOINT_DIRECTION_OUT(x) (!((x) & USB_ENDPOINT_DIRECTION_MASK))
132 #define USB_ENDPOINT_DIRECTION_IN(x) ((x) & USB_ENDPOINT_DIRECTION_MASK)
133
134 /* USB_ENDPOINT_DESCRIPTOR.bmAttributes constants */
135 #define USB_ENDPOINT_TYPE_MASK 0x03
136 #define USB_ENDPOINT_TYPE_CONTROL 0x00
137 #define USB_ENDPOINT_TYPE_ISOCHRONOUS 0x01
138 #define USB_ENDPOINT_TYPE_BULK 0x02
139 #define USB_ENDPOINT_TYPE_INTERRUPT 0x03
140
141 #include <pshpack1.h>
142 typedef struct _USB_ENDPOINT_DESCRIPTOR {
143 UCHAR bLength;
144 UCHAR bDescriptorType;
145 UCHAR bEndpointAddress;
146 UCHAR bmAttributes;
147 USHORT wMaxPacketSize;
148 UCHAR bInterval;
149 } USB_ENDPOINT_DESCRIPTOR, *PUSB_ENDPOINT_DESCRIPTOR;
150 #include <poppack.h>
151
152 #define USB_FEATURE_ENDPOINT_STALL 0x0000
153 #define USB_FEATURE_REMOTE_WAKEUP 0x0001
154
155 typedef struct _USB_INTERFACE_DESCRIPTOR {
156 UCHAR bLength;
157 UCHAR bDescriptorType;
158 UCHAR bInterfaceNumber;
159 UCHAR bAlternateSetting;
160 UCHAR bNumEndpoints;
161 UCHAR bInterfaceClass;
162 UCHAR bInterfaceSubClass;
163 UCHAR bInterfaceProtocol;
164 UCHAR iInterface;
165 } USB_INTERFACE_DESCRIPTOR, *PUSB_INTERFACE_DESCRIPTOR;
166
167 typedef struct _USB_STRING_DESCRIPTOR {
168 UCHAR bLength;
169 UCHAR bDescriptorType;
170 WCHAR bString[1];
171 } USB_STRING_DESCRIPTOR, *PUSB_STRING_DESCRIPTOR;
172
173 #include <pshpack1.h>
174 typedef struct _USB_HUB_DESCRIPTOR {
175 UCHAR bDescriptorLength;
176 UCHAR bDescriptorType;
177 UCHAR bNumberOfPorts;
178 USHORT wHubCharacteristics;
179 UCHAR bPowerOnToPowerGood;
180 UCHAR bHubControlCurrent;
181 UCHAR bRemoveAndPowerMask[64];
182 } USB_HUB_DESCRIPTOR, *PUSB_HUB_DESCRIPTOR;
183 #include <poppack.h>
184
185 #define USB_SUPPORT_D0_COMMAND 0x01
186 #define USB_SUPPORT_D1_COMMAND 0x02
187 #define USB_SUPPORT_D2_COMMAND 0x04
188 #define USB_SUPPORT_D3_COMMAND 0x08
189
190 #define USB_SUPPORT_D1_WAKEUP 0x10
191 #define USB_SUPPORT_D2_WAKEUP 0x20
192
193 typedef struct _USB_CONFIGURATION_POWER_DESCRIPTOR {
194 UCHAR bLength;
195 UCHAR bDescriptorType;
196 UCHAR SelfPowerConsumedD0[3];
197 UCHAR bPowerSummaryId;
198 UCHAR bBusPowerSavingD1;
199 UCHAR bSelfPowerSavingD1;
200 UCHAR bBusPowerSavingD2;
201 UCHAR bSelfPowerSavingD2;
202 UCHAR bBusPowerSavingD3;
203 UCHAR bSelfPowerSavingD3;
204 USHORT TransitionTimeFromD1;
205 USHORT TransitionTimeFromD2;
206 USHORT TransitionTimeFromD3;
207 } USB_CONFIGURATION_POWER_DESCRIPTOR, *PUSB_CONFIGURATION_POWER_DESCRIPTOR;
208
209 #define USB_FEATURE_INTERFACE_POWER_D0 0x0002
210 #define USB_FEATURE_INTERFACE_POWER_D1 0x0003
211 #define USB_FEATURE_INTERFACE_POWER_D2 0x0004
212 #define USB_FEATURE_INTERFACE_POWER_D3 0x0005
213
214 #include <pshpack1.h>
215 typedef struct _USB_INTERFACE_POWER_DESCRIPTOR {
216 UCHAR bLength;
217 UCHAR bDescriptorType;
218 UCHAR bmCapabilitiesFlags;
219 UCHAR bBusPowerSavingD1;
220 UCHAR bSelfPowerSavingD1;
221 UCHAR bBusPowerSavingD2;
222 UCHAR bSelfPowerSavingD2;
223 UCHAR bBusPowerSavingD3;
224 UCHAR bSelfPowerSavingD3;
225 USHORT TransitionTimeFromD1;
226 USHORT TransitionTimeFromD2;
227 USHORT TransitionTimeFromD3;
228 } USB_INTERFACE_POWER_DESCRIPTOR, *PUSB_INTERFACE_POWER_DESCRIPTOR;
229 #include <poppack.h>
230
231 #ifdef __cplusplus
232 }
233 #endif
234
235 #endif /* __USB100_H */