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