]>
Commit | Line | Data |
---|---|---|
1 | #define VERSION 0x910 | |
2 | #define LICENSE 0x952 | |
3 | #define TRANSFER 0x98c | |
4 | #define MULTI_TRANSFER 0x98d | |
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 | |
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 | |
21 | #define MULTI_TRANSFER_OLD 0x904 | |
22 | ||
23 | #define MAGIC 0xa410b413UL | |
24 | ||
25 | #define PP_DATA 0 | |
26 | #define PP_STATUS 1 | |
27 | #define PP_CONTROL 2 | |
28 | #define PP_ECP_CFGA 0 | |
29 | #define PP_ECP_CFGB 1 | |
30 | #define PP_ECP_ECR 2 | |
31 | #define PP_READ 10 | |
32 | #define PP_WRITE 13 | |
33 | ||
34 | #define WDU_GET_MAX_PACKET_SIZE(x) ((unsigned short) (((x) & 0x7ff) * (1 + (((x) & 0x1800) >> 11)))) | |
35 | ||
36 | struct pports { | |
37 | unsigned long base; | |
38 | int num; | |
39 | struct pports *next; | |
40 | }; | |
41 | ||
42 | /* http://www.jungo.com/support/documentation/windriver/811/wdusb_man_mhtml/node78.html#SECTION001734000000000000000 */ | |
43 | ||
44 | struct header_struct { | |
45 | unsigned long magic; | |
46 | void* data; | |
47 | unsigned long size; | |
48 | }; | |
49 | ||
50 | struct version_struct { | |
51 | unsigned long versionul; | |
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. | |
59 | unsigned long dwLicense; // Returns license settings: LICENSE_DEMO, LICENSE_WD | |
60 | // etc..., or 0 for invalid license. | |
61 | unsigned long dwLicense2; // Returns additional license settings, if dwLicense | |
62 | // could not hold all the information. | |
63 | // Then dwLicense will return 0. | |
64 | }; | |
65 | ||
66 | typedef struct | |
67 | { | |
68 | unsigned long dwVendorId; | |
69 | unsigned long dwDeviceId; | |
70 | } WD_PCI_ID; | |
71 | ||
72 | typedef struct | |
73 | { | |
74 | unsigned long dwBus; | |
75 | unsigned long dwSlot; | |
76 | unsigned long dwFunction; | |
77 | } WD_PCI_SLOT; | |
78 | ||
79 | typedef struct | |
80 | { | |
81 | unsigned long dwVendorId; | |
82 | unsigned long dwProductId; | |
83 | } WD_USB_ID; | |
84 | ||
85 | typedef struct | |
86 | { | |
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; | |
94 | } WDU_MATCH_TABLE; | |
95 | ||
96 | typedef struct | |
97 | { | |
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 | |
102 | // Isochronous, Bulk, Interrupt are either USB_DIR_IN or USB_DIR_OUT | |
103 | // Control are USB_DIR_IN_OUT | |
104 | unsigned long dwInterval; // interval in ms relevant to Interrupt pipes | |
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 | { | |
111 | unsigned long dwPipes; | |
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 | { | |
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: | |
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. | |
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. | |
133 | }; | |
134 | ||
135 | ||
136 | ||
137 | ||
138 | struct event { | |
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 | |
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; | |
156 | unsigned long dwUniqueID; | |
157 | } Usb; | |
158 | } u; | |
159 | unsigned long dwEventVer; | |
160 | unsigned long dwNumMatchTables; | |
161 | WDU_MATCH_TABLE matchTables[1]; | |
162 | }; | |
163 | ||
164 | typedef struct | |
165 | { | |
166 | unsigned long dwBusType; // Bus Type: ISA, EISA, PCI, PCMCIA. | |
167 | unsigned long dwBusNum; // Bus number. | |
168 | unsigned long dwSlotFunc; // Slot number on Bus. | |
169 | } WD_BUS, WD_BUS_V30; | |
170 | ||
171 | typedef struct | |
172 | { | |
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 | |
177 | union | |
178 | { | |
179 | struct | |
180 | { // ITEM_MEMORY | |
181 | unsigned long dwPhysicalAddr; // Physical address on card. | |
182 | unsigned long dwBytes; // Address range. | |
183 | void* dwTransAddr; // Returns the address to pass on to transfer commands. | |
184 | void* dwUserDirectAddr; // Returns the address for direct user read/write. | |
185 | unsigned long dwCpuPhysicalAddr; // Returns the CPU physical address | |
186 | unsigned long dwBar; // Base Address Register number of PCI card. | |
187 | } Mem; | |
188 | struct | |
189 | { // ITEM_IO | |
190 | void* dwAddr; // Beginning of io address. | |
191 | unsigned long dwBytes; // IO range. | |
192 | unsigned long dwBar; // Base Address Register number of PCI card. | |
193 | } IO; | |
194 | struct | |
195 | { // ITEM_INTERRUPT | |
196 | unsigned long dwInterrupt; // Number of interrupt to install. | |
197 | unsigned long dwOptions; // Interrupt options. For level sensitive | |
198 | // interrupts - set to: INTERRUPT_LEVEL_SENSITIVE. | |
199 | unsigned long hInterrupt; // Returns the handle of the interrupt installed. | |
200 | } Int; | |
201 | WD_BUS Bus; // ITEM_BUS | |
202 | struct | |
203 | { | |
204 | unsigned long dw1, dw2, dw3, dw4; // Reserved for internal use | |
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 | { | |
214 | unsigned long dwItems; | |
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. | |
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. | |
226 | char cName[32]; // Name of card. | |
227 | char cDescription[100]; // Description. | |
228 | }; | |
229 | ||
230 | typedef struct | |
231 | { | |
232 | void* dwPort; // IO port for transfer or kernel memory address. | |
233 | unsigned long cmdTrans; // Transfer command WD_TRANSFER_CMD. | |
234 | ||
235 | // Parameters used for string transfers: | |
236 | unsigned long dwBytes; // For string transfer. | |
237 | unsigned long fAutoinc; // Transfer from one port/address | |
238 | // or use incremental range of addresses. | |
239 | unsigned long dwOptions; // Must be 0. | |
240 | union | |
241 | { | |
242 | unsigned char Byte; // Use for 8 bit transfer. | |
243 | unsigned short Word; // Use for 16 bit transfer. | |
244 | uint32_t Dword; // Use for 32 bit transfer. | |
245 | uint64_t Qword; // Use for 64 bit transfer. | |
246 | void* pBuffer; // Use for string transfer. | |
247 | } Data; | |
248 | } WD_TRANSFER, WD_TRANSFER_V61; | |
249 | ||
250 | typedef struct | |
251 | { | |
252 | unsigned long hKernelPlugIn; | |
253 | unsigned long dwMessage; | |
254 | void* pData; | |
255 | unsigned long dwResult; | |
256 | } WD_KERNEL_PLUGIN_CALL, WD_KERNEL_PLUGIN_CALL_V40; | |
257 | ||
258 | ||
259 | struct interrupt | |
260 | { | |
261 | unsigned long hInterrupt; // Handle of interrupt. | |
262 | unsigned long dwOptions; // Interrupt options: can be INTERRUPT_CMD_COPY | |
263 | ||
264 | WD_TRANSFER *Cmd; // Commands to do on interrupt. | |
265 | unsigned long dwCmds; // Number of commands. | |
266 | ||
267 | // For WD_IntEnable(): | |
268 | WD_KERNEL_PLUGIN_CALL kpCall; // Kernel PlugIn call. | |
269 | unsigned long fEnableOk; // TRUE if interrupt was enabled (WD_IntEnable() succeed). | |
270 | ||
271 | // For WD_IntWait() and WD_IntCount(): | |
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. | |
275 | }; | |
276 | ||
277 | struct usb_set_interface | |
278 | { | |
279 | unsigned long dwUniqueID; | |
280 | unsigned long dwInterfaceNum; | |
281 | unsigned long dwAlternateSetting; | |
282 | unsigned long dwOptions; | |
283 | }; | |
284 | ||
285 | struct usb_get_device_data | |
286 | { | |
287 | unsigned long dwUniqueID; | |
288 | void* pBuf; | |
289 | unsigned long dwBytes; | |
290 | unsigned long dwOptions; | |
291 | }; | |
292 | ||
293 | #define WD_USB_MAX_INTERFACES 30 | |
294 | ||
295 | typedef struct | |
296 | { | |
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; | |
306 | } WDU_INTERFACE_DESCRIPTOR; | |
307 | ||
308 | typedef struct | |
309 | { | |
310 | unsigned char bLength; | |
311 | unsigned char bDescriptorType; | |
312 | unsigned char bEndpointAddress; | |
313 | unsigned char bmAttributes; | |
314 | unsigned short wMaxPacketSize; | |
315 | unsigned char bInterval; | |
316 | } WDU_ENDPOINT_DESCRIPTOR; | |
317 | ||
318 | typedef struct | |
319 | { | |
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; | |
328 | } WDU_CONFIGURATION_DESCRIPTOR; | |
329 | ||
330 | typedef struct | |
331 | { | |
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; | |
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; | |
359 | unsigned long dwNumAltSettings; | |
360 | WDU_ALTERNATE_SETTING *pActiveAltSetting; | |
361 | } WDU_INTERFACE; | |
362 | ||
363 | typedef struct | |
364 | { | |
365 | WDU_CONFIGURATION_DESCRIPTOR Descriptor; | |
366 | unsigned long dwNumInterfaces; | |
367 | WDU_INTERFACE *pInterfaces; | |
368 | } WDU_CONFIGURATION; | |
369 | ||
370 | struct usb_device_info { | |
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 | }; | |
377 | ||
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; |