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