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