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