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