include: Add usb.h, usb100.h, usb200.h and usbdlib.h.
[wine] / include / ddk / usb.h
1 /*
2  * Copyright (C) the Wine project
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17  */
18
19 #ifndef _USB_
20 #define _USB_
21
22 #include <usb200.h>
23
24 #define URB_FUNCTION_SELECT_CONFIGURATION            0x0000
25 #define URB_FUNCTION_SELECT_INTERFACE                0x0001
26 #define URB_FUNCTION_ABORT_PIPE                      0x0002
27 #define URB_FUNCTION_TAKE_FRAME_LENGTH_CONTROL       0x0003
28 #define URB_FUNCTION_RELEASE_FRAME_LENGTH_CONTROL    0x0004
29 #define URB_FUNCTION_GET_FRAME_LENGTH                0x0005
30 #define URB_FUNCTION_SET_FRAME_LENGTH                0x0006
31 #define URB_FUNCTION_GET_CURRENT_FRAME_NUMBER        0x0007
32 #define URB_FUNCTION_CONTROL_TRANSFER                0x0008
33 #define URB_FUNCTION_BULK_OR_INTERRUPT_TRANSFER      0x0009
34 #define URB_FUNCTION_ISOCH_TRANSFER                  0x000A
35 #define URB_FUNCTION_GET_DESCRIPTOR_FROM_DEVICE      0x000B
36 #define URB_FUNCTION_SET_DESCRIPTOR_TO_DEVICE        0x000C
37 #define URB_FUNCTION_SET_FEATURE_TO_DEVICE           0x000D
38 #define URB_FUNCTION_SET_FEATURE_TO_INTERFACE        0x000E
39 #define URB_FUNCTION_SET_FEATURE_TO_ENDPOINT         0x000F
40 #define URB_FUNCTION_CLEAR_FEATURE_TO_DEVICE         0x0010
41 #define URB_FUNCTION_CLEAR_FEATURE_TO_INTERFACE      0x0011
42 #define URB_FUNCTION_CLEAR_FEATURE_TO_ENDPOINT       0x0012
43 #define URB_FUNCTION_GET_STATUS_FROM_DEVICE          0x0013
44 #define URB_FUNCTION_GET_STATUS_FROM_INTERFACE       0x0014
45 #define URB_FUNCTION_GET_STATUS_FROM_ENDPOINT        0x0015
46 #define URB_FUNCTION_RESERVED_0X0016                 0x0016
47 #define URB_FUNCTION_VENDOR_DEVICE                   0x0017
48 #define URB_FUNCTION_VENDOR_INTERFACE                0x0018
49 #define URB_FUNCTION_VENDOR_ENDPOINT                 0x0019
50 #define URB_FUNCTION_CLASS_DEVICE                    0x001A
51 #define URB_FUNCTION_CLASS_INTERFACE                 0x001B
52 #define URB_FUNCTION_CLASS_ENDPOINT                  0x001C
53 #define URB_FUNCTION_RESERVE_0X001D                  0x001D
54 #define URB_FUNCTION_SYNC_RESET_PIPE_AND_CLEAR_STALL 0x001E
55 #define URB_FUNCTION_CLASS_OTHER                     0x001F
56 #define URB_FUNCTION_VENDOR_OTHER                    0x0020
57 #define URB_FUNCTION_GET_STATUS_FROM_OTHER           0x0021
58 #define URB_FUNCTION_CLEAR_FEATURE_TO_OTHER          0x0022
59 #define URB_FUNCTION_SET_FEATURE_TO_OTHER            0x0023
60 #define URB_FUNCTION_GET_DESCRIPTOR_FROM_ENDPOINT    0x0024
61 #define URB_FUNCTION_SET_DESCRIPTOR_TO_ENDPOINT      0x0025
62 #define URB_FUNCTION_GET_CONFIGURATION               0x0026
63 #define URB_FUNCTION_GET_INTERFACE                   0x0027
64 #define URB_FUNCTION_GET_DESCRIPTOR_FROM_INTERFACE   0x0028
65 #define URB_FUNCTION_SET_DESCRIPTOR_TO_INTERFACE     0x0029
66 #define URB_FUNCTION_GET_MS_FEATURE_DESCRIPTOR       0x002A
67 #define URB_FUNCTION_RESERVE_0X002B                  0x002B
68 #define URB_FUNCTION_RESERVE_0X002C                  0x002C
69 #define URB_FUNCTION_RESERVE_0X002D                  0x002D
70 #define URB_FUNCTION_RESERVE_0X002E                  0x002E
71 #define URB_FUNCTION_RESERVE_0X002F                  0x002F
72 #define URB_FUNCTION_SYNC_RESET_PIPE                 0x0030
73 #define URB_FUNCTION_SYNC_CLEAR_STALL                0x0031
74
75 #define USBD_SHORT_TRANSFER_OK                       0x00000002
76 #define USBD_TRANSFER_DIRECTION_OUT                  0
77 #define USBD_TRANSFER_DIRECTION_IN                   1
78
79 typedef LONG USBD_STATUS;
80
81 typedef PVOID USBD_PIPE_HANDLE;
82 typedef PVOID USBD_CONFIGURATION_HANDLE;
83 typedef PVOID USBD_INTERFACE_HANDLE;
84
85 typedef enum _USBD_PIPE_TYPE {
86     UsbdPipeTypeControl,
87     UsbdPipeTypeIsochronous,
88     UsbdPipeTypeBulk,
89     UsbdPipeTypeInterrupt
90 } USBD_PIPE_TYPE;
91
92 typedef struct _USBD_PIPE_INFORMATION {
93     USHORT MaximumPacketSize;
94     UCHAR EndpointAddress;
95     UCHAR Interval;
96     USBD_PIPE_TYPE PipeType;
97     USBD_PIPE_HANDLE PipeHandle;
98     ULONG MaximumTransferSize;
99     ULONG PipeFlags;
100 } USBD_PIPE_INFORMATION;
101 typedef struct _USBD_PIPE_INFORMATION *PUSBD_PIPE_INFORMATION;
102
103 typedef struct _USBD_INTERFACE_INFORMATION {
104     USHORT Length;
105     UCHAR InterfaceNumber;
106     UCHAR AlternateSetting;
107     UCHAR Class;
108     UCHAR SubClass;
109     UCHAR Protocol;
110     UCHAR Reserved;
111     USBD_INTERFACE_HANDLE InterfaceHandle;
112     ULONG NumberOfPipes;
113     USBD_PIPE_INFORMATION Pipes[1];
114 } USBD_INTERFACE_INFORMATION;
115 typedef struct _USBD_INTERFACE_INFORMATION *PUSBD_INTERFACE_INFORMATION;
116
117 typedef struct _USBD_ISO_PACKET_DESCRIPTOR {
118     ULONG Offset;
119     ULONG Length;
120     USBD_STATUS Status;
121 } USBD_ISO_PACKET_DESCRIPTOR;
122 typedef struct _USBD_ISO_PACKET_DESCRIPTOR *PUSBD_ISO_PACKET_DESCRIPTOR;
123
124 struct _URB_HCD_AREA {
125     PVOID Reserved8[8];
126 };
127
128 struct _URB_HEADER {
129     USHORT Length;
130     USHORT Function;
131     USBD_STATUS Status;
132     PVOID UsbdDeviceHandle;
133     ULONG UsbdFlags;
134 };
135
136 struct _URB_SELECT_INTERFACE {
137     struct _URB_HEADER Hdr;
138     USBD_CONFIGURATION_HANDLE ConfigurationHandle;
139     USBD_INTERFACE_INFORMATION Interface;
140 };
141
142 struct _URB_SELECT_CONFIGURATION {
143     struct _URB_HEADER Hdr;
144     PUSB_CONFIGURATION_DESCRIPTOR ConfigurationDescriptor;
145     USBD_CONFIGURATION_HANDLE ConfigurationHandle;
146     USBD_INTERFACE_INFORMATION Interface;
147 };
148
149 struct _URB_PIPE_REQUEST {
150     struct _URB_HEADER Hdr;
151     USBD_PIPE_HANDLE PipeHandle;
152     ULONG Reserved;
153 };
154
155 struct _URB_FRAME_LENGTH_CONTROL {
156     struct _URB_HEADER Hdr;
157 };
158
159 struct _URB_GET_FRAME_LENGTH {
160     struct _URB_HEADER Hdr;
161     ULONG FrameLength;
162     ULONG FrameNumber;
163 };
164
165 struct _URB_SET_FRAME_LENGTH {
166     struct _URB_HEADER Hdr;
167     LONG FrameLengthDelta;
168 };
169
170 struct _URB_GET_CURRENT_FRAME_NUMBER {
171     struct _URB_HEADER Hdr;
172     ULONG FrameNumber;
173 };
174
175 struct _URB_CONTROL_TRANSFER {
176     struct _URB_HEADER Hdr;
177     USBD_PIPE_HANDLE PipeHandle;
178     ULONG TransferFlags;
179     ULONG TransferBufferLength;
180     PVOID TransferBuffer;
181     PMDL TransferBufferMDL;
182     struct _URB *UrbLink;
183     struct _URB_HCD_AREA hca;
184     UCHAR SetupPacket[8];
185 };
186
187 struct _URB_BULK_OR_INTERRUPT_TRANSFER {
188     struct _URB_HEADER Hdr;
189     USBD_PIPE_HANDLE PipeHandle;
190     ULONG TransferFlags;
191     ULONG TransferBufferLength;
192     PVOID TransferBuffer;
193     PMDL TransferBufferMDL;
194     struct _URB *UrbLink;
195     struct _URB_HCD_AREA hca;
196 };
197
198 struct _URB_ISOCH_TRANSFER {
199     struct _URB_HEADER Hdr;
200     USBD_PIPE_HANDLE PipeHandle;
201     ULONG TransferFlags;
202     ULONG TransferBufferLength;
203     PVOID TransferBuffer;
204     PMDL TransferBufferMDL;
205     struct _URB *UrbLink;
206     struct _URB_HCD_AREA hca;
207     ULONG StartFrame;
208     ULONG NumberOfPackets;
209     ULONG ErrorCount;
210     USBD_ISO_PACKET_DESCRIPTOR IsoPacket[1];
211 };
212
213 struct _URB_CONTROL_DESCRIPTOR_REQUEST {
214     struct _URB_HEADER Hdr;
215     PVOID Reserved;
216     ULONG Reserved0;
217     ULONG TransferBufferLength;
218     PVOID TransferBuffer;
219     PMDL TransferBufferMDL;
220     struct _URB *UrbLink;
221     struct _URB_HCD_AREA hca;
222     USHORT Reserved1;
223     UCHAR Index;
224     UCHAR DescriptorType;
225     USHORT LanguageId;
226     USHORT Reserved2;
227 };
228
229 struct _URB_CONTROL_GET_STATUS_REQUEST {
230     struct _URB_HEADER Hdr;
231     PVOID Reserved;
232     ULONG Reserved0;
233     ULONG TransferBufferLength;
234     PVOID TransferBuffer;
235     PMDL TransferBufferMDL;
236     struct _URB *UrbLink;
237     struct _URB_HCD_AREA hca;
238     UCHAR Reserved1[4];
239     USHORT Index;
240     USHORT Reserved2;
241 };
242
243 struct _URB_CONTROL_FEATURE_REQUEST {
244     struct _URB_HEADER Hdr;
245     PVOID Reserved;
246     ULONG Reserved2;
247     ULONG Reserved3;
248     PVOID Reserved4;
249     PMDL Reserved5;
250     struct _URB *UrbLink;
251     struct _URB_HCD_AREA hca;
252     USHORT Reserved0;
253     USHORT FeatureSelector;
254     USHORT Index;
255     USHORT Reserved1;
256 };
257
258 struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST {
259     struct _URB_HEADER Hdr;
260     PVOID Reserved;
261     ULONG TransferFlags;
262     ULONG TransferBufferLength;
263     PVOID TransferBuffer;
264     PMDL TransferBufferMDL;
265     struct _URB *UrbLink;
266     struct _URB_HCD_AREA hca;
267     UCHAR RequestTypeReservedBits;
268     UCHAR Request;
269     USHORT Value;
270     USHORT Index;
271     USHORT Reserved1;
272 };
273
274 struct _URB_CONTROL_GET_INTERFACE_REQUEST {
275     struct _URB_HEADER Hdr;
276     PVOID Reserved;
277     ULONG Reserved0;
278     ULONG TransferBufferLength;
279     PVOID TransferBuffer;
280     PMDL TransferBufferMDL;
281     struct _URB *UrbLink;
282     struct _URB_HCD_AREA hca;
283     UCHAR Reserved1[4];
284     USHORT Interface;
285     USHORT Reserved2;
286 };
287
288 struct _URB_CONTROL_GET_CONFIGURATION_REQUEST {
289     struct _URB_HEADER Hdr;
290     PVOID Reserved;
291     ULONG Reserved0;
292     ULONG TransferBufferLength;
293     PVOID TransferBuffer;
294     PMDL TransferBufferMDL;
295     struct _URB *UrbLink;
296     struct _URB_HCD_AREA hca;
297     UCHAR Reserved1[8];
298 };
299
300 struct _URB_OS_FEATURE_DESCRIPTOR_REQUEST {
301     struct _URB_HEADER Hdr;
302     PVOID Reserved;
303     ULONG Reserved0;
304     ULONG TransferBufferLength;
305     PVOID TransferBuffer;
306     PMDL TransferBufferMDL;
307     struct _URB *UrbLink;
308     struct _URB_HCD_AREA hca;
309     UCHAR   Recipient:5;
310     UCHAR   Reserved1:3;
311     UCHAR   Reserved2;
312     UCHAR   InterfaceNumber;
313     UCHAR   MS_PageIndex;
314     USHORT  MS_FeatureDescriptorIndex;
315     USHORT  Reserved3;
316 };
317
318 typedef struct _URB {
319     union {
320         struct _URB_HEADER UrbHeader;
321         struct _URB_SELECT_INTERFACE UrbSelectInterface;
322         struct _URB_SELECT_CONFIGURATION UrbSelectConfiguration;
323         struct _URB_PIPE_REQUEST UrbPipeRequest;
324         struct _URB_FRAME_LENGTH_CONTROL UrbFrameLengthControl;
325         struct _URB_GET_FRAME_LENGTH UrbGetFrameLength;
326         struct _URB_SET_FRAME_LENGTH UrbSetFrameLength;
327         struct _URB_GET_CURRENT_FRAME_NUMBER UrbGetCurrentFrameNumber;
328         struct _URB_CONTROL_TRANSFER UrbControlTransfer;
329         struct _URB_BULK_OR_INTERRUPT_TRANSFER UrbBulkOrInterruptTransfer;
330         struct _URB_ISOCH_TRANSFER UrbIsochronousTransfer;
331         struct _URB_CONTROL_DESCRIPTOR_REQUEST UrbControlDescriptorRequest;
332         struct _URB_CONTROL_GET_STATUS_REQUEST UrbControlGetStatusRequest;
333         struct _URB_CONTROL_FEATURE_REQUEST UrbControlFeatureRequest;
334         struct _URB_CONTROL_VENDOR_OR_CLASS_REQUEST UrbControlVendorClassRequest;
335         struct _URB_CONTROL_GET_INTERFACE_REQUEST UrbControlGetInterfaceRequest;
336         struct _URB_CONTROL_GET_CONFIGURATION_REQUEST UrbControlGetConfigurationRequest;
337         struct _URB_OS_FEATURE_DESCRIPTOR_REQUEST UrbOSFeatureDescriptorRequest;
338     } DUMMYUNIONNAME;
339 } URB;
340 typedef struct _URB *PURB;
341
342 #endif