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