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