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