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