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