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