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