update links for xc3sprog
[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
54357994 21#define MULTI_TRANSFER_OLD 0x904
da3ba95a 22
23#define MAGIC 0xa410b413UL
24
ae413cee 25#define PP_DATA 0
26#define PP_STATUS 1
27#define PP_CONTROL 2
54fc4508 28#define PP_ECP_CFGA 0
29#define PP_ECP_CFGB 1
30#define PP_ECP_ECR 2
ae413cee 31#define PP_READ 10
32#define PP_WRITE 13
33
19b2e286 34#define PP_TDI 0x01
35#define PP_TDO 0x10
d0e2002d 36#define PP_PROG 0x10
19b2e286 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
325556c9 47void __attribute__ ((visibility ("hidden"))) hexdump(unsigned char *buf, int len, char *prefix);
b122ac4b 48
b72b86b4 49#define WDU_GET_MAX_PACKET_SIZE(x) ((unsigned short) (((x) & 0x7ff) * (1 + (((x) & 0x1800) >> 11))))
795992ad 50
9c9fd67c 51/* http://www.jungo.com/support/documentation/windriver/811/wdusb_man_mhtml/node78.html#SECTION001734000000000000000 */
52
da3ba95a 53struct header_struct {
b72b86b4 54 unsigned long magic;
da3ba95a 55 void* data;
b72b86b4 56 unsigned long size;
da3ba95a 57};
58
59struct version_struct {
b72b86b4 60 unsigned long versionul;
da3ba95a 61 char version[128];
62};
63
64struct license_struct {
65 char cLicense[128]; // Buffer with license string to put.
66 // If empty string then get current license setting
67 // into dwLicense.
b72b86b4 68 unsigned long dwLicense; // Returns license settings: LICENSE_DEMO, LICENSE_WD
da3ba95a 69 // etc..., or 0 for invalid license.
b72b86b4 70 unsigned long dwLicense2; // Returns additional license settings, if dwLicense
da3ba95a 71 // could not hold all the information.
72 // Then dwLicense will return 0.
73};
74
75typedef struct
76{
b72b86b4 77 unsigned long dwVendorId;
78 unsigned long dwDeviceId;
da3ba95a 79} WD_PCI_ID;
80
81typedef struct
82{
b72b86b4 83 unsigned long dwBus;
84 unsigned long dwSlot;
85 unsigned long dwFunction;
da3ba95a 86} WD_PCI_SLOT;
87
88typedef struct
89{
b72b86b4 90 unsigned long dwVendorId;
91 unsigned long dwProductId;
da3ba95a 92} WD_USB_ID;
93
94typedef struct
95{
b72b86b4 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;
da3ba95a 103} WDU_MATCH_TABLE;
104
105typedef struct
106{
b72b86b4 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
da3ba95a 111 // Isochronous, Bulk, Interrupt are either USB_DIR_IN or USB_DIR_OUT
112 // Control are USB_DIR_IN_OUT
b72b86b4 113 unsigned long dwInterval; // interval in ms relevant to Interrupt pipes
da3ba95a 114} WD_USB_PIPE_INFO, WD_USB_PIPE_INFO_V43, WDU_PIPE_INFO;
115
116#define WD_USB_MAX_PIPE_NUMBER 32
117
118typedef struct
119{
b72b86b4 120 unsigned long dwPipes;
da3ba95a 121 WD_USB_PIPE_INFO Pipe[WD_USB_MAX_PIPE_NUMBER];
122} WD_USB_DEVICE_INFO, WD_USB_DEVICE_INFO_V43;
123
124struct usb_transfer
125{
b72b86b4 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:
da3ba95a 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.
b72b86b4 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.
da3ba95a 142};
143
144
145
146
147struct event {
b72b86b4 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
da3ba95a 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;
b72b86b4 165 unsigned long dwUniqueID;
da3ba95a 166 } Usb;
167 } u;
b72b86b4 168 unsigned long dwEventVer;
169 unsigned long dwNumMatchTables;
da3ba95a 170 WDU_MATCH_TABLE matchTables[1];
171};
172
173typedef struct
174{
b72b86b4 175 unsigned long dwBusType; // Bus Type: ISA, EISA, PCI, PCMCIA.
176 unsigned long dwBusNum; // Bus number.
177 unsigned long dwSlotFunc; // Slot number on Bus.
da3ba95a 178} WD_BUS, WD_BUS_V30;
179
180typedef struct
181{
b72b86b4 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
da3ba95a 186 union
187 {
188 struct
189 { // ITEM_MEMORY
b72b86b4 190 unsigned long dwPhysicalAddr; // Physical address on card.
191 unsigned long dwBytes; // Address range.
da3ba95a 192 void* dwTransAddr; // Returns the address to pass on to transfer commands.
193 void* dwUserDirectAddr; // Returns the address for direct user read/write.
b72b86b4 194 unsigned long dwCpuPhysicalAddr; // Returns the CPU physical address
195 unsigned long dwBar; // Base Address Register number of PCI card.
da3ba95a 196 } Mem;
197 struct
198 { // ITEM_IO
199 void* dwAddr; // Beginning of io address.
b72b86b4 200 unsigned long dwBytes; // IO range.
201 unsigned long dwBar; // Base Address Register number of PCI card.
da3ba95a 202 } IO;
203 struct
204 { // ITEM_INTERRUPT
b72b86b4 205 unsigned long dwInterrupt; // Number of interrupt to install.
206 unsigned long dwOptions; // Interrupt options. For level sensitive
da3ba95a 207 // interrupts - set to: INTERRUPT_LEVEL_SENSITIVE.
b72b86b4 208 unsigned long hInterrupt; // Returns the handle of the interrupt installed.
da3ba95a 209 } Int;
210 WD_BUS Bus; // ITEM_BUS
211 struct
212 {
b72b86b4 213 unsigned long dw1, dw2, dw3, dw4; // Reserved for internal use
da3ba95a 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
221typedef struct
222{
b72b86b4 223 unsigned long dwItems;
da3ba95a 224 WD_ITEMS Item[WD_CARD_ITEMS];
225} WD_CARD, WD_CARD_V30;
226
227enum { CARD_VX_NO_MMU_INIT = 0x4000000 };
228
229struct card_register
230{
231 WD_CARD Card; // Card to register.
b72b86b4 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.
da3ba95a 235 char cName[32]; // Name of card.
236 char cDescription[100]; // Description.
237};
9c9fd67c 238
239typedef struct
240{
241 void* dwPort; // IO port for transfer or kernel memory address.
b72b86b4 242 unsigned long cmdTrans; // Transfer command WD_TRANSFER_CMD.
9c9fd67c 243
244 // Parameters used for string transfers:
b72b86b4 245 unsigned long dwBytes; // For string transfer.
246 unsigned long fAutoinc; // Transfer from one port/address
9c9fd67c 247 // or use incremental range of addresses.
b72b86b4 248 unsigned long dwOptions; // Must be 0.
9c9fd67c 249 union
250 {
b72b86b4 251 unsigned char Byte; // Use for 8 bit transfer.
252 unsigned short Word; // Use for 16 bit transfer.
11d01742 253 uint32_t Dword; // Use for 32 bit transfer.
254 uint64_t Qword; // Use for 64 bit transfer.
9c9fd67c 255 void* pBuffer; // Use for string transfer.
256 } Data;
257} WD_TRANSFER, WD_TRANSFER_V61;
258
259typedef struct
260{
b72b86b4 261 unsigned long hKernelPlugIn;
262 unsigned long dwMessage;
9c9fd67c 263 void* pData;
b72b86b4 264 unsigned long dwResult;
9c9fd67c 265} WD_KERNEL_PLUGIN_CALL, WD_KERNEL_PLUGIN_CALL_V40;
266
267
268struct interrupt
269{
b72b86b4 270 unsigned long hInterrupt; // Handle of interrupt.
271 unsigned long dwOptions; // Interrupt options: can be INTERRUPT_CMD_COPY
9c9fd67c 272
273 WD_TRANSFER *Cmd; // Commands to do on interrupt.
b72b86b4 274 unsigned long dwCmds; // Number of commands.
9c9fd67c 275
276 // For WD_IntEnable():
277 WD_KERNEL_PLUGIN_CALL kpCall; // Kernel PlugIn call.
b72b86b4 278 unsigned long fEnableOk; // TRUE if interrupt was enabled (WD_IntEnable() succeed).
9c9fd67c 279
280 // For WD_IntWait() and WD_IntCount():
b72b86b4 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.
9c9fd67c 284};
285
286struct usb_set_interface
287{
b72b86b4 288 unsigned long dwUniqueID;
289 unsigned long dwInterfaceNum;
290 unsigned long dwAlternateSetting;
291 unsigned long dwOptions;
9c9fd67c 292};
293
294struct usb_get_device_data
295{
b72b86b4 296 unsigned long dwUniqueID;
9c9fd67c 297 void* pBuf;
b72b86b4 298 unsigned long dwBytes;
299 unsigned long dwOptions;
9c9fd67c 300};
301
302#define WD_USB_MAX_INTERFACES 30
303
304typedef struct
305{
b72b86b4 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;
9c9fd67c 315} WDU_INTERFACE_DESCRIPTOR;
316
317typedef struct
318{
b72b86b4 319 unsigned char bLength;
320 unsigned char bDescriptorType;
321 unsigned char bEndpointAddress;
322 unsigned char bmAttributes;
323 unsigned short wMaxPacketSize;
324 unsigned char bInterval;
9c9fd67c 325} WDU_ENDPOINT_DESCRIPTOR;
326
327typedef struct
328{
b72b86b4 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;
9c9fd67c 337} WDU_CONFIGURATION_DESCRIPTOR;
338
339typedef struct
340{
b72b86b4 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;
9c9fd67c 356} WDU_DEVICE_DESCRIPTOR;
357
358typedef struct
359{
360 WDU_INTERFACE_DESCRIPTOR Descriptor;
361 WDU_ENDPOINT_DESCRIPTOR *pEndpointDescriptors;
362 WDU_PIPE_INFO *pPipes;
363} WDU_ALTERNATE_SETTING;
364
365typedef struct
366{
367 WDU_ALTERNATE_SETTING *pAlternateSettings;
b72b86b4 368 unsigned long dwNumAltSettings;
9c9fd67c 369 WDU_ALTERNATE_SETTING *pActiveAltSetting;
370} WDU_INTERFACE;
371
372typedef struct
373{
374 WDU_CONFIGURATION_DESCRIPTOR Descriptor;
b72b86b4 375 unsigned long dwNumInterfaces;
9c9fd67c 376 WDU_INTERFACE *pInterfaces;
377} WDU_CONFIGURATION;
378
e71b6bf3 379struct usb_device_info {
9c9fd67c 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};
3be69a94 386
f95f1d2e 387typedef enum {
388 WDU_DIR_IN = 1,
389 WDU_DIR_OUT = 2,
390 WDU_DIR_IN_OUT = 3
391} WDU_DIR;
392
393typedef 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