-
Notifications
You must be signed in to change notification settings - Fork 26
/
USBIOCTL.H
380 lines (269 loc) · 12.1 KB
/
USBIOCTL.H
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
/*++
Copyright (c) 1995 Microsoft Corporation
Module Name:
USBIOCTL.H
Abstract:
structures common to the USBD and USB device drivers.
Environment:
Kernel & user mode
Revision History:
09-29-95 : created
01-06-97 : added user mode hub ioctls
--*/
#ifndef __USBIOCTL_H__
#define __USBIOCTL_H__
#include "usb100.h"
#ifndef FAR
#define FAR
#endif
DEFINE_GUID( GUID_CLASS_USBHUB, 0xf18a0e88, 0xc30c, 0x11d0, 0x88, 0x15, 0x00, \
0xa0, 0xc9, 0x06, 0xbe, 0xd8);
//f18a0e88-c30c-11d0-8815-00a0c906bed8
// BUGBUG we need a device type added to DEVIOCTL.H
#define FILE_DEVICE_USB FILE_DEVICE_UNKNOWN
//
// USB IOCTLS
//
#define USB_IOCTL_INTERNAL_INDEX 0x0000
#define USB_IOCTL_INDEX 0x00ff
//
// USB Internal IOCtls
//
/* IOCTL_INTERNAL_USB_SUBMIT_URB
This IOCTL is used by client drivers to submit URB (USB Request Blocks)
Parameters.Others.Argument1 = pointer to URB
*/
#define IOCTL_INTERNAL_USB_SUBMIT_URB CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INTERNAL_INDEX, \
METHOD_NEITHER, \
FILE_ANY_ACCESS)
/* IOCTL_INTERNAL_USB_RESET_PORT
*/
#define IOCTL_INTERNAL_USB_RESET_PORT CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INTERNAL_INDEX+1, \
METHOD_NEITHER, \
FILE_ANY_ACCESS)
/* IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO
This IOCTL is used internally by the hub driver
Parameters.Others.Argument1 = pointer to be filled in with RootHubPdo;
Parameters.Others.Argument2 = pointer to be filled in with HcdDeviceObject;
*/
#define IOCTL_INTERNAL_USB_GET_ROOTHUB_PDO CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INTERNAL_INDEX+3, \
METHOD_NEITHER, \
FILE_ANY_ACCESS)
/* IOCTL_INTERNAL_USB_GET_PORT_STATUS
This IOCTL returns the current port status
Parameters.Others.Argument1 = pointer to port status register (ULONG)
status bits are:
USBD_PORT_ENABLED
*/
#define USBD_PORT_ENABLED 0x00000001
#define USBD_PORT_CONNECTED 0x00000002
#define IOCTL_INTERNAL_USB_GET_PORT_STATUS CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INTERNAL_INDEX+4, \
METHOD_NEITHER, \
FILE_ANY_ACCESS)
/* IOCTL_INTERNAL_USB_ENABLE_PORT
This IOCTL will request the hub to re-enable a disabled port
*/
#define IOCTL_INTERNAL_USB_ENABLE_PORT CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INTERNAL_INDEX+5, \
METHOD_NEITHER, \
FILE_ANY_ACCESS)
/* IOCTL_INTERNAL_USB_GET_HUB_COUNT
This IOCTL is used internally by the hub driver
Parameters.Others.Argument1 = pointer to be count of hubs in chain;
*/
#define IOCTL_INTERNAL_USB_GET_HUB_COUNT CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INTERNAL_INDEX+6, \
METHOD_NEITHER, \
FILE_ANY_ACCESS)
/* IOCTL_INTERNAL_USB_CYCLE_PORT
This will simulate a plug/unplug on the port
*/
#define IOCTL_INTERNAL_USB_CYCLE_PORT CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INTERNAL_INDEX+7, \
METHOD_NEITHER, \
FILE_ANY_ACCESS)
//
// USB Public IOCtls
//
//
// this ioctl is for adding debug hooks to HCDs
//
#define IOCTL_USB_HCD_GET_STATS CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INDEX, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
//
// These ioctls are used for USB diagnostic and test applications
//
#define IOCTL_USB_DIAGNOSTIC_MODE_ON CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INDEX+1, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
#define IOCTL_USB_DIAGNOSTIC_MODE_OFF CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INDEX+2, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
#define IOCTL_USB_GET_ROOT_HUB_NAME CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INDEX+3, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
/*
Utility IOCTLS supported by the hub device
*/
//
// These ioctls are supported by the hub driver for
// use by user mode USB utilities.
//
#define IOCTL_USB_GET_NODE_INFORMATION CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INDEX+3, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
#define IOCTL_USB_GET_NODE_CONNECTION_INFORMATION CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INDEX+4, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
#define IOCTL_USB_GET_DESCRIPTOR_FROM_NODE_CONNECTION CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INDEX+5, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
#define IOCTL_USB_GET_NODE_CONNECTION_NAME CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INDEX+6, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
#define IOCTL_USB_DIAG_IGNORE_HUBS_ON CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INDEX+7, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
#define IOCTL_USB_DIAG_IGNORE_HUBS_OFF CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INDEX+8, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
#define IOCTL_USB_GET_NODE_CONNECTION_DRIVERKEY_NAME CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INDEX+9, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
#define IOCTL_GET_HCD_DRIVERKEY_NAME CTL_CODE(FILE_DEVICE_USB, \
USB_IOCTL_INDEX+10, \
METHOD_BUFFERED, \
FILE_ANY_ACCESS)
//
// structures for user mode ioctls
//
#pragma pack (1)
typedef enum _USB_HUB_NODE {
UsbHub,
UsbMIParent
} USB_HUB_NODE;
typedef struct _USB_HUB_INFORMATION {
//
// copy of data from hub descriptor
//
USB_HUB_DESCRIPTOR HubDescriptor;
BOOLEAN HubIsBusPowered;
} USB_HUB_INFORMATION, *PUSB_HUB_INFORMATION;
typedef struct _USB_MI_PARENT_INFORMATION {
ULONG NumberOfInterfaces;
} USB_MI_PARENT_INFORMATION, *PUSB_MI_PARENT_INFORMATION;
typedef struct _USB_NODE_INFORMATION {
USB_HUB_NODE NodeType; // hub, mi parent
union {
USB_HUB_INFORMATION HubInformation;
USB_MI_PARENT_INFORMATION MiParentInformation;
} u;
} USB_NODE_INFORMATION, *PUSB_NODE_INFORMATION;
typedef struct _USB_PIPE_INFO {
USB_ENDPOINT_DESCRIPTOR EndpointDescriptor;
} USB_PIPE_INFO, PUSB_PIPE_INFO;
//
// BUGBUG
// more status codes?
//
typedef enum _USB_CONNECTION_STATUS {
NoDeviceConnected,
DeviceConnected,
// failure codes, these map to fail reasons
DeviceFailedEnumeration,
DeviceGeneralFailure,
DeviceCausedOvercurrent,
DeviceNotEnoughPower,
} USB_CONNECTION_STATUS, *PUSB_CONNECTION_STATUS;
typedef struct _USB_NODE_CONNECTION_INFORMATION {
ULONG ConnectionIndex;
// usb device descriptor returned by this device
// during enumeration
USB_DEVICE_DESCRIPTOR DeviceDescriptor;
UCHAR CurrentConfigurationValue;
BOOLEAN LowSpeed;
BOOLEAN DeviceIsHub;
USHORT DeviceAddress;
ULONG NumberOfOpenPipes;
USB_CONNECTION_STATUS ConnectionStatus;
USB_PIPE_INFO PipeList[0];
} USB_NODE_CONNECTION_INFORMATION, *PUSB_NODE_CONNECTION_INFORMATION;
typedef struct _USB_NODE_CONNECTION_DRIVERKEY_NAME {
ULONG ConnectionIndex; // INPUT
ULONG ActualLength; // OUTPUT
// unicode name for the devnode.
WCHAR DriverKeyName[1]; // OUTPUT
} USB_NODE_CONNECTION_DRIVERKEY_NAME, *PUSB_NODE_CONNECTION_DRIVERKEY_NAME;
typedef struct _USB_NODE_CONNECTION_NAME {
ULONG ConnectionIndex; // INPUT
ULONG ActualLength; // OUTPUT
// unicode symbolic name for this node if it is a hub or parent driver
// null if this node is a device.
WCHAR NodeName[1]; // OUTPUT
} USB_NODE_CONNECTION_NAME, *PUSB_NODE_CONNECTION_NAME;
typedef struct _USB_ROOT_HUB_NAME {
ULONG ActualLength; // OUTPUT
// NULL terminated unicode symbolic name for the root hub
WCHAR RootHubName[1]; // OUTPUT
} USB_ROOT_HUB_NAME, *PUSB_ROOT_HUB_NAME;
typedef struct _USB_HCD_DRIVERKEY_NAME {
ULONG ActualLength; // OUTPUT
// NULL terminated unicode driverkeyname for hcd
WCHAR DriverKeyName[1]; // OUTPUT
} USB_HCD_DRIVERKEY_NAME, *PUSB_HCD_DRIVERKEY_NAME;
typedef struct _USB_DESCRIPTOR_REQUEST {
ULONG ConnectionIndex;
struct {
UCHAR bmRequest;
UCHAR bRequest;
USHORT wValue;
USHORT wIndex;
USHORT wLength;
} SetupPacket;
UCHAR Data[0];
} USB_DESCRIPTOR_REQUEST, *PUSB_DESCRIPTOR_REQUEST;
//
// Structure for returning HCD debug and statistic information to
// a user mode application.
//
typedef struct _HCD_STAT_COUNTERS {
ULONG BytesTransferred;
USHORT IsoMissedCount;
USHORT DataOverrunErrorCount;
USHORT CrcErrorCount;
USHORT ScheduleOverrunCount;
USHORT TimeoutErrorCount;
USHORT InternalHcErrorCount;
USHORT BufferOverrunErrorCount;
USHORT SWErrorCount;
USHORT StallPidCount;
USHORT PortDisableCount;
} HCD_STAT_COUNTERS, *PHCD_STAT_COUNTERS;
typedef struct _HCD_STAT_INFORMATION {
ULONG Reserved1;
ULONG Reserved2;
ULONG ResetCounters;
LARGE_INTEGER TimeRead;
//
// stat registers
//
HCD_STAT_COUNTERS Counters;
} HCD_STAT_INFORMATION, *PHCD_STAT_INFORMATION;
#pragma pack()
#endif // __USBIOCTL_H__