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