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