-
Notifications
You must be signed in to change notification settings - Fork 40
/
drv_api.h
314 lines (246 loc) · 9.01 KB
/
drv_api.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
/*! \file drv_api.h
*/
#include "..\includes\lusbk_shared.h"
#ifndef __LIBUSBK_KUSB_DRIVER_API_H__
#define __LIBUSBK_KUSB_DRIVER_API_H__
enum
{
LIBUSB_DEBUG_OFF,
LIBUSB_DEBUG_ERR,
LIBUSB_DEBUG_WRN,
LIBUSB_DEBUG_MSG,
LIBUSB_DEBUG_MAX = 0xff,
};
/* 64k */
#define LIBUSB_MAX_READ_WRITE 0x10000
#define LIBUSB_MAX_NUMBER_OF_DEVICES 256
#define LIBUSB_MAX_NUMBER_OF_CHILDREN 32
#define LIBUSB_IOCTL_SET_CONFIGURATION CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x801, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_GET_CONFIGURATION CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x802, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_SET_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x803, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_GET_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x804, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_SET_FEATURE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x805, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_CLEAR_FEATURE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x806, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_GET_STATUS CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x807, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_SET_DESCRIPTOR CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x808, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_GET_DESCRIPTOR CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x809, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_INTERRUPT_OR_BULK_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x80A, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_INTERRUPT_OR_BULK_READ CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x80B, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_VENDOR_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x80C, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_VENDOR_READ CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x80D, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_RESET_ENDPOINT CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x80E, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_ABORT_ENDPOINT CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x80F, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_RESET_DEVICE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x810, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_SET_DEBUG_LEVEL CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x811, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_GET_VERSION CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x812, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_ISOCHRONOUS_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x813, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_ISOCHRONOUS_READ CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x814, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_CLAIM_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x815, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_RELEASE_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x816, METHOD_BUFFERED, FILE_ANY_ACCESS)
/////////////////////////////////////////////////////////////////////////////
// supported after 0.1.12.2
/////////////////////////////////////////////////////////////////////////////
// [trobinso] adds support for querying device properties
#define LIBUSB_IOCTL_GET_DEVICE_PROPERTY CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x900, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_GET_CUSTOM_REG_PROPERTY CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x901, METHOD_BUFFERED, FILE_ANY_ACCESS)
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// supported after 1.2.0.0
/////////////////////////////////////////////////////////////////////////////
#define LIBUSB_IOCTL_GET_CACHED_CONFIGURATION CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x902, METHOD_BUFFERED, FILE_ANY_ACCESS)
/////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////////////////////////////////
// supported in libusbK (3.0.0.0 and up)
/////////////////////////////////////////////////////////////////////////////
#define LIBUSB_IOCTL_QUERY_DEVICE_INFORMATION CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x904, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_SET_PIPE_POLICY CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x906, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_GET_PIPE_POLICY CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x907, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_SET_POWER_POLICY CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x908, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_GET_POWER_POLICY CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x909, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_CONTROL_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x90A, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_CONTROL_READ CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x90B, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
#define LIBUSB_IOCTL_FLUSH_PIPE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x90C, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSBK_IOCTL_CLAIM_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x90D, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSBK_IOCTL_RELEASE_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x90E, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSBK_IOCTL_RELEASE_ALL_INTERFACES CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x90F, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSBK_IOCTL_SET_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x910, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSBK_IOCTL_GET_INTERFACE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x911, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSBK_IOCTL_GET_CURRENTFRAME_NUMBER CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x912, METHOD_BUFFERED, FILE_ANY_ACCESS)
#define LIBUSBK_IOCTL_ISOEX_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x913, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define LIBUSBK_IOCTL_ISOEX_READ CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x914, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
#define LIBUSBK_IOCTL_AUTOISOEX_WRITE CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x915, METHOD_IN_DIRECT, FILE_ANY_ACCESS)
#define LIBUSBK_IOCTL_AUTOISOEX_READ CTL_CODE(FILE_DEVICE_UNKNOWN,\
0x916, METHOD_OUT_DIRECT, FILE_ANY_ACCESS)
/////////////////////////////////////////////////////////////////////////////
#include <pshpack1.h>
enum LIBUSB0_TRANSFER_FLAGS
{
TRANSFER_FLAGS_SHORT_NOT_OK = 1 << 0,
TRANSFER_FLAGS_ISO_SET_START_FRAME = 1 << 30,
TRANSFER_FLAGS_ISO_ADD_LATENCY = 1 << 31,
};
#pragma warning(disable:4201)
#pragma warning(disable:4214)
typedef struct
{
unsigned int interface_number;
unsigned int altsetting_number;
unsigned char intf_use_index: 1; // libusbK Only
unsigned char altf_use_index: 1; // libusbK Only
unsigned char: 6;
short interface_index; // libusbK Only
short altsetting_index; // libusbK Only
} interface_request_t;
#pragma warning(default:4214)
typedef struct
{
unsigned int major;
unsigned int minor;
unsigned int micro;
unsigned int nano;
unsigned int mod_value;
} version_t;
typedef struct
{
unsigned int timeout;
union
{
struct
{
unsigned int configuration;
} configuration;
interface_request_t intf; // libusbK Only
version_t version;
struct
{
unsigned int endpoint;
unsigned int packet_size;
unsigned int unused; // max_transfer_size is deprecated; (see pipe policies)
unsigned int transfer_flags;
unsigned int iso_start_frame_latency;
} endpoint;
struct
{
UCHAR PipeID;
ULONG IsoContextSize;
PKISO_CONTEXT IsoContext;
} IsoEx;
struct
{
UCHAR PipeID;
} AutoIsoEx;
struct
{
unsigned int type;
unsigned int recipient;
unsigned int request;
unsigned int value;
unsigned int index;
} vendor;
struct
{
unsigned int recipient;
unsigned int feature;
unsigned int index;
} feature;
struct
{
unsigned int recipient;
unsigned int index;
unsigned int status;
} status;
struct
{
unsigned int type;
unsigned int index;
unsigned int language_id;
unsigned int recipient;
} descriptor;
struct
{
unsigned int level;
} debug;
struct
{
unsigned int property;
} device_property;
struct
{
unsigned int key_type;
unsigned int name_offset;
unsigned int value_offset;
unsigned int value_length;
} device_registry_key;
struct
{
ULONG information_type;
} query_device;
struct
{
unsigned int interface_index;
unsigned int pipe_id;
unsigned int policy_type;
} pipe_policy;
struct
{
unsigned int policy_type;
} power_policy;
// WDF_USB_CONTROL_SETUP_PACKET control;
union
{
struct
{
UCHAR RequestType;
UCHAR Request;
USHORT Value;
USHORT Index;
USHORT Length;
} control;
};
};
} libusb_request;
#pragma warning(default:4201)
#include <poppack.h>
#endif