4 #define MULTI_TRANSFER 0x98d
5 #define USB_TRANSFER 0x983
6 #define EVENT_UNREGISTER 0x987
7 #define INT_DISABLE 0x91f
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
23 #define MAGIC 0xa410b413UL
42 #define DPRINTF(format, args...) fprintf(stderr, format, ##args)
44 #define DPRINTF(format, args...)
47 void hexdump(unsigned char *buf, int len);
49 #define WDU_GET_MAX_PACKET_SIZE(x) ((unsigned short) (((x) & 0x7ff) * (1 + (((x) & 0x1800) >> 11))))
51 /* http://www.jungo.com/support/documentation/windriver/811/wdusb_man_mhtml/node78.html#SECTION001734000000000000000 */
53 struct header_struct {
59 struct version_struct {
60 unsigned long versionul;
64 struct license_struct {
65 char cLicense[128]; // Buffer with license string to put.
66 // If empty string then get current license setting
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.
77 unsigned long dwVendorId;
78 unsigned long dwDeviceId;
85 unsigned long dwFunction;
90 unsigned long dwVendorId;
91 unsigned long dwProductId;
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;
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;
116 #define WD_USB_MAX_PIPE_NUMBER 32
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;
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
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.
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
165 unsigned long dwUniqueID;
168 unsigned long dwEventVer;
169 unsigned long dwNumMatchTables;
170 WDU_MATCH_TABLE matchTables[1];
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;
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
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.
199 void* dwAddr; // Beginning of io address.
200 unsigned long dwBytes; // IO range.
201 unsigned long dwBar; // Base Address Register number of PCI card.
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.
210 WD_BUS Bus; // ITEM_BUS
213 unsigned long dw1, dw2, dw3, dw4; // Reserved for internal use
214 void* dw5; // Reserved for internal use
217 } WD_ITEMS, WD_ITEMS_V30;
219 #define WD_CARD_ITEMS 20
223 unsigned long dwItems;
224 WD_ITEMS Item[WD_CARD_ITEMS];
225 } WD_CARD, WD_CARD_V30;
227 enum { CARD_VX_NO_MMU_INIT = 0x4000000 };
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.
241 void* dwPort; // IO port for transfer or kernel memory address.
242 unsigned long cmdTrans; // Transfer command WD_TRANSFER_CMD.
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.
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.
257 } WD_TRANSFER, WD_TRANSFER_V61;
261 unsigned long hKernelPlugIn;
262 unsigned long dwMessage;
264 unsigned long dwResult;
265 } WD_KERNEL_PLUGIN_CALL, WD_KERNEL_PLUGIN_CALL_V40;
270 unsigned long hInterrupt; // Handle of interrupt.
271 unsigned long dwOptions; // Interrupt options: can be INTERRUPT_CMD_COPY
273 WD_TRANSFER *Cmd; // Commands to do on interrupt.
274 unsigned long dwCmds; // Number of commands.
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).
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.
286 struct usb_set_interface
288 unsigned long dwUniqueID;
289 unsigned long dwInterfaceNum;
290 unsigned long dwAlternateSetting;
291 unsigned long dwOptions;
294 struct usb_get_device_data
296 unsigned long dwUniqueID;
298 unsigned long dwBytes;
299 unsigned long dwOptions;
302 #define WD_USB_MAX_INTERFACES 30
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;
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;
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;
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;
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;
360 WDU_INTERFACE_DESCRIPTOR Descriptor;
361 WDU_ENDPOINT_DESCRIPTOR *pEndpointDescriptors;
362 WDU_PIPE_INFO *pPipes;
363 } WDU_ALTERNATE_SETTING;
367 WDU_ALTERNATE_SETTING *pAlternateSettings;
368 unsigned long dwNumAltSettings;
369 WDU_ALTERNATE_SETTING *pActiveAltSetting;
374 WDU_CONFIGURATION_DESCRIPTOR Descriptor;
375 unsigned long dwNumInterfaces;
376 WDU_INTERFACE *pInterfaces;
379 struct usb_device_info {
380 WDU_DEVICE_DESCRIPTOR Descriptor;
382 WDU_CONFIGURATION *pConfigs;
383 WDU_CONFIGURATION *pActiveConfig;
384 WDU_INTERFACE *pActiveInterface[WD_USB_MAX_INTERFACES];
394 PIPE_TYPE_CONTROL = 0,
395 PIPE_TYPE_ISOCHRONOUS = 1,
397 PIPE_TYPE_INTERRUPT = 3