source: Daodan/MinGW/include/ddk/usb100.h@ 1054

Last change on this file since 1054 was 1046, checked in by alloc, 8 years ago

Daodan: Added Windows MinGW and build batch file

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