]> git.zerfleddert.de Git - usb-driver/blob - usb-driver.h
baddf4a56208fec525db31d373f98036e6a47483
[usb-driver] / usb-driver.h
1 #define VERSION 0x910
2 #define LICENSE 0x952
3 #define TRANSFER 0x98c
4 #define MULTI_TRANSFER 0x98d
5 #define USB_TRANSFER 0x983
6 #define EVENT_UNREGISTER 0x987
7 #define INT_DISABLE 0x91f
8 #define INT_WAIT 0x94b
9 #define CARD_REGISTER 0x9a4
10 #define EVENT_REGISTER 0x9a5
11 #define CARD_UNREGISTER 0x92b
12 #define USB_GET_DEVICE_DATA 0x9a7
13 #define INT_ENABLE 0x98e
14 #define EVENT_PULL 0x988
15 #define USB_SET_INTERFACE 0x981
16 #define CARD_REGISTER_OLD 0x97d
17 #define INT_ENABLE_OLD 0x91e
18 #define USB_GET_DEVICE_DATA_OLD 0x980
19 #define EVENT_REGISTER_OLD 0x986
20 #define TRANSFER_OLD 0x903
21 #define MULTI_TRANSFER_OLD 0x904
22
23 #define MAGIC 0xa410b413UL
24
25 #define PP_DATA 0
26 #define PP_STATUS 1
27 #define PP_CONTROL 2
28 #define PP_ECP_CFGA 0
29 #define PP_ECP_CFGB 1
30 #define PP_ECP_ECR 2
31 #define PP_READ 10
32 #define PP_WRITE 13
33
34 #define PP_TDI 0x01
35 #define PP_TDO 0x10
36 #define PP_PROG 0x10
37 #define PP_TCK 0x02
38 #define PP_TMS 0x04
39 #define PP_CTRL 0x08
40
41 #ifdef DEBUG
42 #define DPRINTF(format, args...) fprintf(stderr, format, ##args)
43 #else
44 #define DPRINTF(format, args...)
45 #endif
46
47 void hexdump(unsigned char *buf, int len);
48
49 #define WDU_GET_MAX_PACKET_SIZE(x) ((unsigned short) (((x) & 0x7ff) * (1 + (((x) & 0x1800) >> 11))))
50
51 /* http://www.jungo.com/support/documentation/windriver/811/wdusb_man_mhtml/node78.html#SECTION001734000000000000000 */
52
53 struct header_struct {
54 unsigned long magic;
55 void* data;
56 unsigned long size;
57 };
58
59 struct version_struct {
60 unsigned long versionul;
61 char version[128];
62 };
63
64 struct license_struct {
65 char cLicense[128]; // Buffer with license string to put.
66 // If empty string then get current license setting
67 // into dwLicense.
68 unsigned long dwLicense; // Returns license settings: LICENSE_DEMO, LICENSE_WD
69 // etc..., or 0 for invalid license.
70 unsigned long dwLicense2; // Returns additional license settings, if dwLicense
71 // could not hold all the information.
72 // Then dwLicense will return 0.
73 };
74
75 typedef struct
76 {
77 unsigned long dwVendorId;
78 unsigned long dwDeviceId;
79 } WD_PCI_ID;
80
81 typedef struct
82 {
83 unsigned long dwBus;
84 unsigned long dwSlot;
85 unsigned long dwFunction;
86 } WD_PCI_SLOT;
87
88 typedef struct
89 {
90 unsigned long dwVendorId;
91 unsigned long dwProductId;
92 } WD_USB_ID;
93
94 typedef struct
95 {
96 unsigned short VendorId;
97 unsigned short ProductId;
98 unsigned char bDeviceClass;
99 unsigned char bDeviceSubClass;
100 unsigned char bInterfaceClass;
101 unsigned char bInterfaceSubClass;
102 unsigned char bInterfaceProtocol;
103 } WDU_MATCH_TABLE;
104
105 typedef struct
106 {
107 unsigned long dwNumber; // Pipe 0 is the default pipe
108 unsigned long dwMaximumPacketSize;
109 unsigned long type; // USB_PIPE_TYPE
110 unsigned long direction; // WDU_DIR
111 // Isochronous, Bulk, Interrupt are either USB_DIR_IN or USB_DIR_OUT
112 // Control are USB_DIR_IN_OUT
113 unsigned long dwInterval; // interval in ms relevant to Interrupt pipes
114 } WD_USB_PIPE_INFO, WD_USB_PIPE_INFO_V43, WDU_PIPE_INFO;
115
116 #define WD_USB_MAX_PIPE_NUMBER 32
117
118 typedef struct
119 {
120 unsigned long dwPipes;
121 WD_USB_PIPE_INFO Pipe[WD_USB_MAX_PIPE_NUMBER];
122 } WD_USB_DEVICE_INFO, WD_USB_DEVICE_INFO_V43;
123
124 struct usb_transfer
125 {
126 unsigned long dwUniqueID;
127 unsigned long dwPipeNum; // Pipe number on device.
128 unsigned long fRead; // TRUE for read (IN) transfers; FALSE for write (OUT) transfers.
129 unsigned long dwOptions; // USB_TRANSFER options:
130 // USB_ISOCH_FULL_PACKETS_ONLY - For isochronous
131 // transfers only. If set, only full packets will be
132 // transmitted and the transfer function will return
133 // when the amount of bytes left to transfer is less
134 // than the maximum packet size for the pipe (the
135 // function will return without transmitting the
136 // remaining bytes).
137 void* pBuffer; // Pointer to buffer to read/write.
138 unsigned long dwBufferSize; // Amount of bytes to transfer.
139 unsigned long dwBytesTransferred; // Returns the number of bytes actually read/written
140 unsigned char SetupPacket[8]; // Setup packet for control pipe transfer.
141 unsigned long dwTimeout; // Timeout for the transfer in milliseconds. Set to 0 for infinite wait.
142 };
143
144
145
146
147 struct event {
148 unsigned long handle;
149 unsigned long dwAction; // WD_EVENT_ACTION
150 unsigned long dwStatus; // EVENT_STATUS
151 unsigned long dwEventId;
152 unsigned long dwCardType; //WD_BUS_PCI, WD_BUS_USB, WD_BUS_PCMCIA
153 unsigned long hKernelPlugIn;
154 unsigned long dwOptions; // WD_EVENT_OPTION
155 union
156 {
157 struct
158 {
159 WD_PCI_ID cardId;
160 WD_PCI_SLOT pciSlot;
161 } Pci;
162 struct
163 {
164 WD_USB_ID deviceId;
165 unsigned long dwUniqueID;
166 } Usb;
167 } u;
168 unsigned long dwEventVer;
169 unsigned long dwNumMatchTables;
170 WDU_MATCH_TABLE matchTables[1];
171 };
172
173 typedef struct
174 {
175 unsigned long dwBusType; // Bus Type: ISA, EISA, PCI, PCMCIA.
176 unsigned long dwBusNum; // Bus number.
177 unsigned long dwSlotFunc; // Slot number on Bus.
178 } WD_BUS, WD_BUS_V30;
179
180 typedef struct
181 {
182 unsigned long item; // ITEM_TYPE
183 unsigned long fNotSharable;
184 unsigned long dwReserved; // Reserved for internal use
185 unsigned long dwOptions; // WD_ITEM_OPTIONS
186 union
187 {
188 struct
189 { // ITEM_MEMORY
190 unsigned long dwPhysicalAddr; // Physical address on card.
191 unsigned long dwBytes; // Address range.
192 void* dwTransAddr; // Returns the address to pass on to transfer commands.
193 void* dwUserDirectAddr; // Returns the address for direct user read/write.
194 unsigned long dwCpuPhysicalAddr; // Returns the CPU physical address
195 unsigned long dwBar; // Base Address Register number of PCI card.
196 } Mem;
197 struct
198 { // ITEM_IO
199 void* dwAddr; // Beginning of io address.
200 unsigned long dwBytes; // IO range.
201 unsigned long dwBar; // Base Address Register number of PCI card.
202 } IO;
203 struct
204 { // ITEM_INTERRUPT
205 unsigned long dwInterrupt; // Number of interrupt to install.
206 unsigned long dwOptions; // Interrupt options. For level sensitive
207 // interrupts - set to: INTERRUPT_LEVEL_SENSITIVE.
208 unsigned long hInterrupt; // Returns the handle of the interrupt installed.
209 } Int;
210 WD_BUS Bus; // ITEM_BUS
211 struct
212 {
213 unsigned long dw1, dw2, dw3, dw4; // Reserved for internal use
214 void* dw5; // Reserved for internal use
215 } Val;
216 } I;
217 } WD_ITEMS, WD_ITEMS_V30;
218
219 #define WD_CARD_ITEMS 20
220
221 typedef struct
222 {
223 unsigned long dwItems;
224 WD_ITEMS Item[WD_CARD_ITEMS];
225 } WD_CARD, WD_CARD_V30;
226
227 enum { CARD_VX_NO_MMU_INIT = 0x4000000 };
228
229 struct card_register
230 {
231 WD_CARD Card; // Card to register.
232 unsigned long fCheckLockOnly; // Only check if card is lockable, return hCard=1 if OK.
233 unsigned long hCard; // Handle of card.
234 unsigned long dwOptions; // Should be zero.
235 char cName[32]; // Name of card.
236 char cDescription[100]; // Description.
237 };
238
239 typedef struct
240 {
241 void* dwPort; // IO port for transfer or kernel memory address.
242 unsigned long cmdTrans; // Transfer command WD_TRANSFER_CMD.
243
244 // Parameters used for string transfers:
245 unsigned long dwBytes; // For string transfer.
246 unsigned long fAutoinc; // Transfer from one port/address
247 // or use incremental range of addresses.
248 unsigned long dwOptions; // Must be 0.
249 union
250 {
251 unsigned char Byte; // Use for 8 bit transfer.
252 unsigned short Word; // Use for 16 bit transfer.
253 uint32_t Dword; // Use for 32 bit transfer.
254 uint64_t Qword; // Use for 64 bit transfer.
255 void* pBuffer; // Use for string transfer.
256 } Data;
257 } WD_TRANSFER, WD_TRANSFER_V61;
258
259 typedef struct
260 {
261 unsigned long hKernelPlugIn;
262 unsigned long dwMessage;
263 void* pData;
264 unsigned long dwResult;
265 } WD_KERNEL_PLUGIN_CALL, WD_KERNEL_PLUGIN_CALL_V40;
266
267
268 struct interrupt
269 {
270 unsigned long hInterrupt; // Handle of interrupt.
271 unsigned long dwOptions; // Interrupt options: can be INTERRUPT_CMD_COPY
272
273 WD_TRANSFER *Cmd; // Commands to do on interrupt.
274 unsigned long dwCmds; // Number of commands.
275
276 // For WD_IntEnable():
277 WD_KERNEL_PLUGIN_CALL kpCall; // Kernel PlugIn call.
278 unsigned long fEnableOk; // TRUE if interrupt was enabled (WD_IntEnable() succeed).
279
280 // For WD_IntWait() and WD_IntCount():
281 unsigned long dwCounter; // Number of interrupts received.
282 unsigned long dwLost; // Number of interrupts not yet dealt with.
283 unsigned long fStopped; // Was interrupt disabled during wait.
284 };
285
286 struct usb_set_interface
287 {
288 unsigned long dwUniqueID;
289 unsigned long dwInterfaceNum;
290 unsigned long dwAlternateSetting;
291 unsigned long dwOptions;
292 };
293
294 struct usb_get_device_data
295 {
296 unsigned long dwUniqueID;
297 void* pBuf;
298 unsigned long dwBytes;
299 unsigned long dwOptions;
300 };
301
302 #define WD_USB_MAX_INTERFACES 30
303
304 typedef struct
305 {
306 unsigned char bLength;
307 unsigned char bDescriptorType;
308 unsigned char bInterfaceNumber;
309 unsigned char bAlternateSetting;
310 unsigned char bNumEndpoints;
311 unsigned char bInterfaceClass;
312 unsigned char bInterfaceSubClass;
313 unsigned char bInterfaceProtocol;
314 unsigned char iInterface;
315 } WDU_INTERFACE_DESCRIPTOR;
316
317 typedef struct
318 {
319 unsigned char bLength;
320 unsigned char bDescriptorType;
321 unsigned char bEndpointAddress;
322 unsigned char bmAttributes;
323 unsigned short wMaxPacketSize;
324 unsigned char bInterval;
325 } WDU_ENDPOINT_DESCRIPTOR;
326
327 typedef struct
328 {
329 unsigned char bLength;
330 unsigned char bDescriptorType;
331 unsigned short wTotalLength;
332 unsigned char bNumInterfaces;
333 unsigned char bConfigurationValue;
334 unsigned char iConfiguration;
335 unsigned char bmAttributes;
336 unsigned char MaxPower;
337 } WDU_CONFIGURATION_DESCRIPTOR;
338
339 typedef struct
340 {
341 unsigned char bLength;
342 unsigned char bDescriptorType;
343 unsigned short bcdUSB;
344 unsigned char bDeviceClass;
345 unsigned char bDeviceSubClass;
346 unsigned char bDeviceProtocol;
347 unsigned char bMaxPacketSize0;
348
349 unsigned short idVendor;
350 unsigned short idProduct;
351 unsigned short bcdDevice;
352 unsigned char iManufacturer;
353 unsigned char iProduct;
354 unsigned char iSerialNumber;
355 unsigned char bNumConfigurations;
356 } WDU_DEVICE_DESCRIPTOR;
357
358 typedef struct
359 {
360 WDU_INTERFACE_DESCRIPTOR Descriptor;
361 WDU_ENDPOINT_DESCRIPTOR *pEndpointDescriptors;
362 WDU_PIPE_INFO *pPipes;
363 } WDU_ALTERNATE_SETTING;
364
365 typedef struct
366 {
367 WDU_ALTERNATE_SETTING *pAlternateSettings;
368 unsigned long dwNumAltSettings;
369 WDU_ALTERNATE_SETTING *pActiveAltSetting;
370 } WDU_INTERFACE;
371
372 typedef struct
373 {
374 WDU_CONFIGURATION_DESCRIPTOR Descriptor;
375 unsigned long dwNumInterfaces;
376 WDU_INTERFACE *pInterfaces;
377 } WDU_CONFIGURATION;
378
379 struct usb_device_info {
380 WDU_DEVICE_DESCRIPTOR Descriptor;
381 WDU_PIPE_INFO Pipe0;
382 WDU_CONFIGURATION *pConfigs;
383 WDU_CONFIGURATION *pActiveConfig;
384 WDU_INTERFACE *pActiveInterface[WD_USB_MAX_INTERFACES];
385 };
386
387 typedef enum {
388 WDU_DIR_IN = 1,
389 WDU_DIR_OUT = 2,
390 WDU_DIR_IN_OUT = 3
391 } WDU_DIR;
392
393 typedef enum {
394 PIPE_TYPE_CONTROL = 0,
395 PIPE_TYPE_ISOCHRONOUS = 1,
396 PIPE_TYPE_BULK = 2,
397 PIPE_TYPE_INTERRUPT = 3
398 } USB_PIPE_TYPE;
Impressum, Datenschutz