1 | /** @file
|
---|
2 | * VUSB - VirtualBox USB. (DEV,VMM)
|
---|
3 | */
|
---|
4 |
|
---|
5 | /*
|
---|
6 | * Copyright (C) 2006-2007 Sun Microsystems, Inc.
|
---|
7 | *
|
---|
8 | * This file is part of VirtualBox Open Source Edition (OSE), as
|
---|
9 | * available from http://www.virtualbox.org. This file is free software;
|
---|
10 | * you can redistribute it and/or modify it under the terms of the GNU
|
---|
11 | * General Public License (GPL) as published by the Free Software
|
---|
12 | * Foundation, in version 2 as it comes in the "COPYING" file of the
|
---|
13 | * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
|
---|
14 | * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
|
---|
15 | *
|
---|
16 | * The contents of this file may alternatively be used under the terms
|
---|
17 | * of the Common Development and Distribution License Version 1.0
|
---|
18 | * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
|
---|
19 | * VirtualBox OSE distribution, in which case the provisions of the
|
---|
20 | * CDDL are applicable instead of those of the GPL.
|
---|
21 | *
|
---|
22 | * You may elect to license modified versions of this file under the
|
---|
23 | * terms and conditions of either the GPL or the CDDL or both.
|
---|
24 | *
|
---|
25 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
|
---|
26 | * Clara, CA 95054 USA or visit http://www.sun.com if you need
|
---|
27 | * additional information or have any questions.
|
---|
28 | */
|
---|
29 |
|
---|
30 | #ifndef ___VBox_vusb_h
|
---|
31 | #define ___VBox_vusb_h
|
---|
32 |
|
---|
33 | #include <VBox/cdefs.h>
|
---|
34 | #include <VBox/types.h>
|
---|
35 |
|
---|
36 | RT_C_DECLS_BEGIN
|
---|
37 |
|
---|
38 | /** @defgroup grp_vusb VBox USB API
|
---|
39 | * @{
|
---|
40 | */
|
---|
41 |
|
---|
42 | /** @defgroup grp_vusb_std Standard Stuff
|
---|
43 | * @{ */
|
---|
44 |
|
---|
45 | /** Frequency of USB bus (from spec). */
|
---|
46 | #define VUSB_BUS_HZ 12000000
|
---|
47 |
|
---|
48 |
|
---|
49 | /** @name USB Descriptor types (from spec)
|
---|
50 | * @{ */
|
---|
51 | #define VUSB_DT_DEVICE 0x01
|
---|
52 | #define VUSB_DT_CONFIG 0x02
|
---|
53 | #define VUSB_DT_STRING 0x03
|
---|
54 | #define VUSB_DT_INTERFACE 0x04
|
---|
55 | #define VUSB_DT_ENDPOINT 0x05
|
---|
56 | #define VUSB_DT_DEVICE_QUALIFIER 0x06
|
---|
57 | #define VUSB_DT_OTHER_SPEED_CFG 0x07
|
---|
58 | #define VUSB_DT_INTERFACE_POWER 0x08
|
---|
59 | /** @} */
|
---|
60 |
|
---|
61 | /** @name USB Descriptor minimum sizes (from spec)
|
---|
62 | * @{ */
|
---|
63 | #define VUSB_DT_DEVICE_MIN_LEN 18
|
---|
64 | #define VUSB_DT_CONFIG_MIN_LEN 9
|
---|
65 | #define VUSB_DT_CONFIG_STRING_MIN_LEN 2
|
---|
66 | #define VUSB_DT_INTERFACE_MIN_LEN 9
|
---|
67 | #define VUSB_DT_ENDPOINT_MIN_LEN 7
|
---|
68 | /** @} */
|
---|
69 |
|
---|
70 |
|
---|
71 | #pragma pack(1) /* ensure byte packing of the descriptors. */
|
---|
72 |
|
---|
73 | /**
|
---|
74 | * USB language id descriptor (from specs).
|
---|
75 | */
|
---|
76 | typedef struct VUSBDESCLANGID
|
---|
77 | {
|
---|
78 | uint8_t bLength;
|
---|
79 | uint8_t bDescriptorType;
|
---|
80 | } VUSBDESCLANGID;
|
---|
81 | /** Pointer to a USB language id descriptor. */
|
---|
82 | typedef VUSBDESCLANGID *PVUSBDESCLANGID;
|
---|
83 | /** Pointer to a const USB language id descriptor. */
|
---|
84 | typedef const VUSBDESCLANGID *PCVUSBDESCLANGID;
|
---|
85 |
|
---|
86 |
|
---|
87 | /**
|
---|
88 | * USB string descriptor (from specs).
|
---|
89 | */
|
---|
90 | typedef struct VUSBDESCSTRING
|
---|
91 | {
|
---|
92 | uint8_t bLength;
|
---|
93 | uint8_t bDescriptorType;
|
---|
94 | } VUSBDESCSTRING;
|
---|
95 | /** Pointer to a USB string descriptor. */
|
---|
96 | typedef VUSBDESCSTRING *PVUSBDESCSTRING;
|
---|
97 | /** Pointer to a const USB string descriptor. */
|
---|
98 | typedef const VUSBDESCSTRING *PCVUSBDESCSTRING;
|
---|
99 |
|
---|
100 |
|
---|
101 | /**
|
---|
102 | * USB device descriptor (from spec)
|
---|
103 | */
|
---|
104 | typedef struct VUSBDESCDEVICE
|
---|
105 | {
|
---|
106 | uint8_t bLength;
|
---|
107 | uint8_t bDescriptorType;
|
---|
108 | uint16_t bcdUSB;
|
---|
109 | uint8_t bDeviceClass;
|
---|
110 | uint8_t bDeviceSubClass;
|
---|
111 | uint8_t bDeviceProtocol;
|
---|
112 | uint8_t bMaxPacketSize0;
|
---|
113 | uint16_t idVendor;
|
---|
114 | uint16_t idProduct;
|
---|
115 | uint16_t bcdDevice;
|
---|
116 | uint8_t iManufacturer;
|
---|
117 | uint8_t iProduct;
|
---|
118 | uint8_t iSerialNumber;
|
---|
119 | uint8_t bNumConfigurations;
|
---|
120 | } VUSBDESCDEVICE;
|
---|
121 | /** Pointer to a USB device descriptor. */
|
---|
122 | typedef VUSBDESCDEVICE *PVUSBDESCDEVICE;
|
---|
123 | /** Pointer to a const USB device descriptor. */
|
---|
124 | typedef const VUSBDESCDEVICE *PCVUSBDESCDEVICE;
|
---|
125 |
|
---|
126 |
|
---|
127 | /**
|
---|
128 | * USB configuration descriptor (from spec).
|
---|
129 | */
|
---|
130 | typedef struct VUSBDESCCONFIG
|
---|
131 | {
|
---|
132 | uint8_t bLength;
|
---|
133 | uint8_t bDescriptorType;
|
---|
134 | uint16_t wTotalLength; /**< recalculated by VUSB when involved in URB. */
|
---|
135 | uint8_t bNumInterfaces;
|
---|
136 | uint8_t bConfigurationValue;
|
---|
137 | uint8_t iConfiguration;
|
---|
138 | uint8_t bmAttributes;
|
---|
139 | uint8_t MaxPower;
|
---|
140 | } VUSBDESCCONFIG;
|
---|
141 | /** Pointer to a USB configuration descriptor. */
|
---|
142 | typedef VUSBDESCCONFIG *PVUSBDESCCONFIG;
|
---|
143 | /** Pointer to a readonly USB configuration descriptor. */
|
---|
144 | typedef const VUSBDESCCONFIG *PCVUSBDESCCONFIG;
|
---|
145 |
|
---|
146 |
|
---|
147 | /**
|
---|
148 | * USB interface descriptor (from spec)
|
---|
149 | */
|
---|
150 | typedef struct VUSBDESCINTERFACE
|
---|
151 | {
|
---|
152 | uint8_t bLength;
|
---|
153 | uint8_t bDescriptorType;
|
---|
154 | uint8_t bInterfaceNumber;
|
---|
155 | uint8_t bAlternateSetting;
|
---|
156 | uint8_t bNumEndpoints;
|
---|
157 | uint8_t bInterfaceClass;
|
---|
158 | uint8_t bInterfaceSubClass;
|
---|
159 | uint8_t bInterfaceProtocol;
|
---|
160 | uint8_t iInterface;
|
---|
161 | } VUSBDESCINTERFACE;
|
---|
162 | /** Pointer to an USB interface descriptor. */
|
---|
163 | typedef VUSBDESCINTERFACE *PVUSBDESCINTERFACE;
|
---|
164 | /** Pointer to a const USB interface descriptor. */
|
---|
165 | typedef const VUSBDESCINTERFACE *PCVUSBDESCINTERFACE;
|
---|
166 |
|
---|
167 |
|
---|
168 | /**
|
---|
169 | * USB endpoint descriptor (from spec)
|
---|
170 | */
|
---|
171 | typedef struct VUSBDESCENDPOINT
|
---|
172 | {
|
---|
173 | uint8_t bLength;
|
---|
174 | uint8_t bDescriptorType;
|
---|
175 | uint8_t bEndpointAddress;
|
---|
176 | uint8_t bmAttributes;
|
---|
177 | uint16_t wMaxPacketSize;
|
---|
178 | uint8_t bInterval;
|
---|
179 | } VUSBDESCENDPOINT;
|
---|
180 | /** Pointer to an USB endpoint descriptor. */
|
---|
181 | typedef VUSBDESCENDPOINT *PVUSBDESCENDPOINT;
|
---|
182 | /** Pointer to a const USB endpoint descriptor. */
|
---|
183 | typedef const VUSBDESCENDPOINT *PCVUSBDESCENDPOINT;
|
---|
184 |
|
---|
185 | #pragma pack() /* end of the byte packing. */
|
---|
186 |
|
---|
187 |
|
---|
188 | /**
|
---|
189 | * USB configuration descriptor, the parsed variant used by VUSB.
|
---|
190 | */
|
---|
191 | typedef struct VUSBDESCCONFIGEX
|
---|
192 | {
|
---|
193 | /** The USB descriptor data.
|
---|
194 | * @remark The wTotalLength member is recalculated before the data is passed to the guest. */
|
---|
195 | VUSBDESCCONFIG Core;
|
---|
196 | /** Pointer to additional descriptor bytes following what's covered by VUSBDESCCONFIG. */
|
---|
197 | void *pvMore;
|
---|
198 | /** Pointer to an array of the interfaces referenced in the configuration.
|
---|
199 | * Core.bNumInterfaces in size. */
|
---|
200 | const struct VUSBINTERFACE *iface;
|
---|
201 | } VUSBDESCCONFIGEX;
|
---|
202 | /** Pointer to a parsed USB configuration descriptor. */
|
---|
203 | typedef VUSBDESCCONFIGEX *PVUSBDESCCONFIGEX;
|
---|
204 | /** Pointer to a const parsed USB configuration descriptor. */
|
---|
205 | typedef const VUSBDESCCONFIGEX *PCVUSBDESCCONFIGEX;
|
---|
206 |
|
---|
207 |
|
---|
208 | /**
|
---|
209 | * For tracking the alternate interface settings of a configuration.
|
---|
210 | */
|
---|
211 | typedef struct VUSBINTERFACE
|
---|
212 | {
|
---|
213 | /** Pointer to an array of interfaces. */
|
---|
214 | const struct VUSBDESCINTERFACEEX *setting;
|
---|
215 | /** The number of entries in the array. */
|
---|
216 | unsigned int num_settings;
|
---|
217 | } VUSBINTERFACE;
|
---|
218 | /** Pointer to a VUSBINTERFACE. */
|
---|
219 | typedef VUSBINTERFACE *PVUSBINTERFACE;
|
---|
220 | /** Pointer to a const VUSBINTERFACE. */
|
---|
221 | typedef const VUSBINTERFACE *PCVUSBINTERFACE;
|
---|
222 |
|
---|
223 |
|
---|
224 | /**
|
---|
225 | * USB interface descriptor, the parsed variant used by VUSB.
|
---|
226 | */
|
---|
227 | typedef struct VUSBDESCINTERFACEEX
|
---|
228 | {
|
---|
229 | /** The USB descriptor data. */
|
---|
230 | VUSBDESCINTERFACE Core;
|
---|
231 | /** Pointer to additional descriptor bytes following what's covered by VUSBDESCINTERFACE. */
|
---|
232 | void *pvMore;
|
---|
233 | /** Pointer to an array of the endpoints referenced by the interface.
|
---|
234 | * Core.bNumEndpoints in size. */
|
---|
235 | const struct VUSBDESCENDPOINTEX *endpoint;
|
---|
236 | } VUSBDESCINTERFACEEX;
|
---|
237 | /** Pointer to an prased USB interface descriptor. */
|
---|
238 | typedef VUSBDESCINTERFACEEX *PVUSBDESCINTERFACEEX;
|
---|
239 | /** Pointer to a const parsed USB interface descriptor. */
|
---|
240 | typedef const VUSBDESCINTERFACEEX *PCVUSBDESCINTERFACEEX;
|
---|
241 |
|
---|
242 |
|
---|
243 | /**
|
---|
244 | * USB endpoint descriptor, the parsed variant used by VUSB.
|
---|
245 | */
|
---|
246 | typedef struct VUSBDESCENDPOINTEX
|
---|
247 | {
|
---|
248 | /** The USB descriptor data.
|
---|
249 | * @remark The wMaxPacketSize member is converted to native endian. */
|
---|
250 | VUSBDESCENDPOINT Core;
|
---|
251 | /** Pointer to additional descriptor bytes following what's covered by VUSBDESCENDPOINT. */
|
---|
252 | void *pvMore;
|
---|
253 | } VUSBDESCENDPOINTEX;
|
---|
254 | /** Pointer to a parsed USB endpoint descriptor. */
|
---|
255 | typedef VUSBDESCENDPOINTEX *PVUSBDESCENDPOINTEX;
|
---|
256 | /** Pointer to a const parsed USB endpoint descriptor. */
|
---|
257 | typedef const VUSBDESCENDPOINTEX *PCVUSBDESCENDPOINTEX;
|
---|
258 |
|
---|
259 |
|
---|
260 | /** @name USB Control message recipient codes (from spec)
|
---|
261 | * @{ */
|
---|
262 | #define VUSB_TO_DEVICE 0x0
|
---|
263 | #define VUSB_TO_INTERFACE 0x1
|
---|
264 | #define VUSB_TO_ENDPOINT 0x2
|
---|
265 | #define VUSB_TO_OTHER 0x3
|
---|
266 | #define VUSB_RECIP_MASK 0x1f
|
---|
267 | /** @} */
|
---|
268 |
|
---|
269 | /** @name USB control pipe setup packet structure (from spec)
|
---|
270 | * @{ */
|
---|
271 | #define VUSB_REQ_SHIFT (5)
|
---|
272 | #define VUSB_REQ_STANDARD (0x0 << VUSB_REQ_SHIFT)
|
---|
273 | #define VUSB_REQ_CLASS (0x1 << VUSB_REQ_SHIFT)
|
---|
274 | #define VUSB_REQ_VENDOR (0x2 << VUSB_REQ_SHIFT)
|
---|
275 | #define VUSB_REQ_RESERVED (0x3 << VUSB_REQ_SHIFT)
|
---|
276 | #define VUSB_REQ_MASK (0x3 << VUSB_REQ_SHIFT)
|
---|
277 | /** @} */
|
---|
278 |
|
---|
279 | #define VUSB_DIR_TO_DEVICE 0x00
|
---|
280 | #define VUSB_DIR_TO_HOST 0x80
|
---|
281 | #define VUSB_DIR_MASK 0x80
|
---|
282 |
|
---|
283 | /**
|
---|
284 | * USB Setup request (from spec)
|
---|
285 | */
|
---|
286 | typedef struct vusb_setup
|
---|
287 | {
|
---|
288 | uint8_t bmRequestType;
|
---|
289 | uint8_t bRequest;
|
---|
290 | uint16_t wValue;
|
---|
291 | uint16_t wIndex;
|
---|
292 | uint16_t wLength;
|
---|
293 | } VUSBSETUP;
|
---|
294 | /** Pointer to a setup request. */
|
---|
295 | typedef VUSBSETUP *PVUSBSETUP;
|
---|
296 | /** Pointer to a const setup request. */
|
---|
297 | typedef const VUSBSETUP *PCVUSBSETUP;
|
---|
298 |
|
---|
299 | /** @name USB Standard device requests (from spec)
|
---|
300 | * @{ */
|
---|
301 | #define VUSB_REQ_GET_STATUS 0x00
|
---|
302 | #define VUSB_REQ_CLEAR_FEATURE 0x01
|
---|
303 | #define VUSB_REQ_SET_FEATURE 0x03
|
---|
304 | #define VUSB_REQ_SET_ADDRESS 0x05
|
---|
305 | #define VUSB_REQ_GET_DESCRIPTOR 0x06
|
---|
306 | #define VUSB_REQ_SET_DESCRIPTOR 0x07
|
---|
307 | #define VUSB_REQ_GET_CONFIGURATION 0x08
|
---|
308 | #define VUSB_REQ_SET_CONFIGURATION 0x09
|
---|
309 | #define VUSB_REQ_GET_INTERFACE 0x0a
|
---|
310 | #define VUSB_REQ_SET_INTERFACE 0x0b
|
---|
311 | #define VUSB_REQ_SYNCH_FRAME 0x0c
|
---|
312 | #define VUSB_REQ_MAX 0x0d
|
---|
313 | /** @} */
|
---|
314 |
|
---|
315 | /** @} */ /* end of grp_vusb_std */
|
---|
316 |
|
---|
317 |
|
---|
318 |
|
---|
319 | /** @name USB Standard version flags.
|
---|
320 | * @{ */
|
---|
321 | /** Indicates USB 1.1 support. */
|
---|
322 | #define VUSB_STDVER_11 RT_BIT(1)
|
---|
323 | /** Indicates USB 2.0 support. */
|
---|
324 | #define VUSB_STDVER_20 RT_BIT(2)
|
---|
325 | /** @} */
|
---|
326 |
|
---|
327 |
|
---|
328 | /** Pointer to a VBox USB device interface. */
|
---|
329 | typedef struct VUSBIDEVICE *PVUSBIDEVICE;
|
---|
330 |
|
---|
331 | /** Pointer to a VUSB RootHub port interface. */
|
---|
332 | typedef struct VUSBIROOTHUBPORT *PVUSBIROOTHUBPORT;
|
---|
333 |
|
---|
334 | /** Pointer to an USB request descriptor. */
|
---|
335 | typedef struct VUSBURB *PVUSBURB;
|
---|
336 |
|
---|
337 |
|
---|
338 |
|
---|
339 | /**
|
---|
340 | * VBox USB port bitmap.
|
---|
341 | *
|
---|
342 | * Bit 0 == Port 0, ... , Bit 127 == Port 127.
|
---|
343 | */
|
---|
344 | typedef struct VUSBPORTBITMAP
|
---|
345 | {
|
---|
346 | /** 128 bits */
|
---|
347 | char ach[16];
|
---|
348 | } VUSBPORTBITMAP;
|
---|
349 | /** Pointer to a VBox USB port bitmap. */
|
---|
350 | typedef VUSBPORTBITMAP *PVUSBPORTBITMAP;
|
---|
351 |
|
---|
352 |
|
---|
353 | /**
|
---|
354 | * The VUSB RootHub port interface provided by the HCI (down).
|
---|
355 | * Pair with VUSBIROOTCONNECTOR
|
---|
356 | */
|
---|
357 | typedef struct VUSBIROOTHUBPORT
|
---|
358 | {
|
---|
359 | /**
|
---|
360 | * Get the number of avilable ports in the hub.
|
---|
361 | *
|
---|
362 | * @returns The number of ports available.
|
---|
363 | * @param pInterface Pointer to this structure.
|
---|
364 | * @param pAvailable Bitmap indicating the available ports. Set bit == available port.
|
---|
365 | */
|
---|
366 | DECLR3CALLBACKMEMBER(unsigned, pfnGetAvailablePorts,(PVUSBIROOTHUBPORT pInterface, PVUSBPORTBITMAP pAvailable));
|
---|
367 |
|
---|
368 | /**
|
---|
369 | * Gets the supported USB versions.
|
---|
370 | *
|
---|
371 | * @returns The mask of supported USB versions.
|
---|
372 | * @param pInterface Pointer to this structure.
|
---|
373 | */
|
---|
374 | DECLR3CALLBACKMEMBER(uint32_t, pfnGetUSBVersions,(PVUSBIROOTHUBPORT pInterface));
|
---|
375 |
|
---|
376 | /**
|
---|
377 | * A device is being attached to a port in the roothub.
|
---|
378 | *
|
---|
379 | * @param pInterface Pointer to this structure.
|
---|
380 | * @param pDev Pointer to the device being attached.
|
---|
381 | * @param uPort The port number assigned to the device.
|
---|
382 | */
|
---|
383 | DECLR3CALLBACKMEMBER(int, pfnAttach,(PVUSBIROOTHUBPORT pInterface, PVUSBIDEVICE pDev, unsigned uPort));
|
---|
384 |
|
---|
385 | /**
|
---|
386 | * A device is being detached from a port in the roothub.
|
---|
387 | *
|
---|
388 | * @param pInterface Pointer to this structure.
|
---|
389 | * @param pDev Pointer to the device being detached.
|
---|
390 | * @param uPort The port number assigned to the device.
|
---|
391 | */
|
---|
392 | DECLR3CALLBACKMEMBER(void, pfnDetach,(PVUSBIROOTHUBPORT pInterface, PVUSBIDEVICE pDev, unsigned uPort));
|
---|
393 |
|
---|
394 | /**
|
---|
395 | * Reset the root hub.
|
---|
396 | *
|
---|
397 | * @returns VBox status code.
|
---|
398 | * @param pInterface Pointer to this structure.
|
---|
399 | * @param pResetOnLinux Whether or not to do real reset on linux.
|
---|
400 | */
|
---|
401 | DECLR3CALLBACKMEMBER(int, pfnReset,(PVUSBIROOTHUBPORT pInterface, bool fResetOnLinux));
|
---|
402 |
|
---|
403 | /**
|
---|
404 | * Transfer completion callback routine.
|
---|
405 | *
|
---|
406 | * VUSB will call this when a transfer have been completed
|
---|
407 | * in a one or another way.
|
---|
408 | *
|
---|
409 | * @param pInterface Pointer to this structure.
|
---|
410 | * @param pUrb Pointer to the URB in question.
|
---|
411 | */
|
---|
412 | DECLR3CALLBACKMEMBER(void, pfnXferCompletion,(PVUSBIROOTHUBPORT pInterface, PVUSBURB urb));
|
---|
413 |
|
---|
414 | /**
|
---|
415 | * Handle transfer errors.
|
---|
416 | *
|
---|
417 | * VUSB calls this when a transfer attempt failed. This function will respond
|
---|
418 | * indicating wheter to retry or complete the URB with failure.
|
---|
419 | *
|
---|
420 | * @returns Retry indicator.
|
---|
421 | * @param pInterface Pointer to this structure.
|
---|
422 | * @param pUrb Pointer to the URB in question.
|
---|
423 | */
|
---|
424 | DECLR3CALLBACKMEMBER(bool, pfnXferError,(PVUSBIROOTHUBPORT pInterface, PVUSBURB pUrb));
|
---|
425 |
|
---|
426 | /** Alignment dummy. */
|
---|
427 | RTR3PTR Alignment;
|
---|
428 |
|
---|
429 | } VUSBIROOTHUBPORT;
|
---|
430 | /** VUSBIROOTHUBPORT interface ID. */
|
---|
431 | #define VUSBIROOTHUBPORT_IID "e38e2978-7aa2-4860-94b6-9ef4a066d8a0"
|
---|
432 |
|
---|
433 |
|
---|
434 | /** Pointer to a VUSB RootHub connector interface. */
|
---|
435 | typedef struct VUSBIROOTHUBCONNECTOR *PVUSBIROOTHUBCONNECTOR;
|
---|
436 | /**
|
---|
437 | * The VUSB RootHub connector interface provided by the VBox USB RootHub driver
|
---|
438 | * (up).
|
---|
439 | * Pair with VUSBIROOTHUBPORT.
|
---|
440 | */
|
---|
441 | typedef struct VUSBIROOTHUBCONNECTOR
|
---|
442 | {
|
---|
443 | /**
|
---|
444 | * Allocates a new URB for a transfer.
|
---|
445 | *
|
---|
446 | * Either submit using pfnSubmitUrb or free using VUSBUrbFree().
|
---|
447 | *
|
---|
448 | * @returns Pointer to a new URB.
|
---|
449 | * @returns NULL on failure - try again later.
|
---|
450 | * This will not fail if the device wasn't found. We'll fail it
|
---|
451 | * at submit time, since that makes the usage of this api simpler.
|
---|
452 | * @param pInterface Pointer to this struct.
|
---|
453 | * @param DstAddress The destination address of the URB.
|
---|
454 | * @param cbData The amount of data space required.
|
---|
455 | * @param cTds The amount of TD space.
|
---|
456 | */
|
---|
457 | DECLR3CALLBACKMEMBER(PVUSBURB, pfnNewUrb,(PVUSBIROOTHUBCONNECTOR pInterface, uint8_t DstAddress, uint32_t cbData, uint32_t cTds));
|
---|
458 |
|
---|
459 | /**
|
---|
460 | * Submits a URB for transfer.
|
---|
461 | * The transfer will do asynchronously if possible.
|
---|
462 | *
|
---|
463 | * @returns VBox status code.
|
---|
464 | * @param pInterface Pointer to this struct.
|
---|
465 | * @param pUrb Pointer to the URB returned by pfnNewUrb.
|
---|
466 | * The URB will be freed in case of failure.
|
---|
467 | * @param pLed Pointer to USB Status LED
|
---|
468 | */
|
---|
469 | DECLR3CALLBACKMEMBER(int, pfnSubmitUrb,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb, struct PDMLED *pLed));
|
---|
470 |
|
---|
471 | /**
|
---|
472 | * Call to service asynchronous URB completions in a polling fashion.
|
---|
473 | *
|
---|
474 | * Reaped URBs will be finished by calling the completion callback,
|
---|
475 | * thus there is no return code or input or anything from this function
|
---|
476 | * except for potential state changes elsewhere.
|
---|
477 | *
|
---|
478 | * @returns VINF_SUCCESS if no URBs are pending upon return.
|
---|
479 | * @returns VERR_TIMEOUT if one or more URBs are still in flight upon returning.
|
---|
480 | * @returns Other VBox status code.
|
---|
481 | *
|
---|
482 | * @param pInterface Pointer to this struct.
|
---|
483 | * @param cMillies Number of milliseconds to poll for completion.
|
---|
484 | */
|
---|
485 | DECLR3CALLBACKMEMBER(void, pfnReapAsyncUrbs,(PVUSBIROOTHUBCONNECTOR pInterface, RTMSINTERVAL cMillies));
|
---|
486 |
|
---|
487 | /**
|
---|
488 | * Cancels and completes - with CRC failure - all in-flight async URBs.
|
---|
489 | * This is typically done before saving a state.
|
---|
490 | *
|
---|
491 | * @param pInterface Pointer to this struct.
|
---|
492 | */
|
---|
493 | DECLR3CALLBACKMEMBER(void, pfnCancelAllUrbs,(PVUSBIROOTHUBCONNECTOR pInterface));
|
---|
494 |
|
---|
495 | /**
|
---|
496 | * Attach the device to the root hub.
|
---|
497 | * The device must not be attached to any hub for this call to succeed.
|
---|
498 | *
|
---|
499 | * @returns VBox status code.
|
---|
500 | * @param pInterface Pointer to this struct.
|
---|
501 | * @param pDevice Pointer to the device (interface) attach.
|
---|
502 | */
|
---|
503 | DECLR3CALLBACKMEMBER(int, pfnAttachDevice,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice));
|
---|
504 |
|
---|
505 | /**
|
---|
506 | * Detach the device from the root hub.
|
---|
507 | * The device must already be attached for this call to succeed.
|
---|
508 | *
|
---|
509 | * @returns VBox status code.
|
---|
510 | * @param pInterface Pointer to this struct.
|
---|
511 | * @param pDevice Pointer to the device (interface) to detach.
|
---|
512 | */
|
---|
513 | DECLR3CALLBACKMEMBER(int, pfnDetachDevice,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice));
|
---|
514 |
|
---|
515 | } VUSBIROOTHUBCONNECTOR;
|
---|
516 | /** VUSBIROOTHUBCONNECTOR interface ID. */
|
---|
517 | #define VUSBIROOTHUBCONNECTOR_IID "d9a90c59-e3ff-4dff-9754-844557c3f7a0"
|
---|
518 |
|
---|
519 |
|
---|
520 | #ifdef IN_RING3
|
---|
521 | /** @copydoc VUSBIROOTHUBCONNECTOR::pfnNewUrb */
|
---|
522 | DECLINLINE(PVUSBURB) VUSBIRhNewUrb(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t DstAddress, uint32_t cbData, uint32_t cTds)
|
---|
523 | {
|
---|
524 | return pInterface->pfnNewUrb(pInterface, DstAddress, cbData, cTds);
|
---|
525 | }
|
---|
526 |
|
---|
527 | /** @copydoc VUSBIROOTHUBCONNECTOR::pfnSubmitUrb */
|
---|
528 | DECLINLINE(int) VUSBIRhSubmitUrb(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb, struct PDMLED *pLed)
|
---|
529 | {
|
---|
530 | return pInterface->pfnSubmitUrb(pInterface, pUrb, pLed);
|
---|
531 | }
|
---|
532 |
|
---|
533 | /** @copydoc VUSBIROOTHUBCONNECTOR::pfnReapAsyncUrbs */
|
---|
534 | DECLINLINE(void) VUSBIRhReapAsyncUrbs(PVUSBIROOTHUBCONNECTOR pInterface, RTMSINTERVAL cMillies)
|
---|
535 | {
|
---|
536 | pInterface->pfnReapAsyncUrbs(pInterface, cMillies);
|
---|
537 | }
|
---|
538 |
|
---|
539 | /** @copydoc VUSBIROOTHUBCONNECTOR::pfnCancelAllUrbs */
|
---|
540 | DECLINLINE(void) VUSBIRhCancelAllUrbs(PVUSBIROOTHUBCONNECTOR pInterface)
|
---|
541 | {
|
---|
542 | pInterface->pfnCancelAllUrbs(pInterface);
|
---|
543 | }
|
---|
544 |
|
---|
545 | /** @copydoc VUSBIROOTHUBCONNECTOR::pfnAttachDevice */
|
---|
546 | DECLINLINE(int) VUSBIRhAttachDevice(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice)
|
---|
547 | {
|
---|
548 | return pInterface->pfnAttachDevice(pInterface, pDevice);
|
---|
549 | }
|
---|
550 |
|
---|
551 | /** @copydoc VUSBIROOTHUBCONNECTOR::pfnDetachDevice */
|
---|
552 | DECLINLINE(int) VUSBIRhDetachDevice(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice)
|
---|
553 | {
|
---|
554 | return pInterface->pfnDetachDevice(pInterface, pDevice);
|
---|
555 | }
|
---|
556 | #endif /* IN_RING3 */
|
---|
557 |
|
---|
558 |
|
---|
559 |
|
---|
560 | /** Pointer to a Root Hub Configuration Interface. */
|
---|
561 | typedef struct VUSBIRHCONFIG *PVUSBIRHCONFIG;
|
---|
562 | /**
|
---|
563 | * Root Hub Configuration Interface (intended for MAIN).
|
---|
564 | * No interface pair.
|
---|
565 | */
|
---|
566 | typedef struct VUSBIRHCONFIG
|
---|
567 | {
|
---|
568 | /**
|
---|
569 | * Creates a USB proxy device and attaches it to the root hub.
|
---|
570 | *
|
---|
571 | * @returns VBox status code.
|
---|
572 | * @param pInterface Pointer to the root hub configuration interface structure.
|
---|
573 | * @param pUuid Pointer to the UUID for the new device.
|
---|
574 | * @param fRemote Whether the device must use the VRDP backend.
|
---|
575 | * @param pszAddress OS specific device address.
|
---|
576 | * @param pvBackend An opaque pointer for the backend. Only used by
|
---|
577 | * the VRDP backend so far.
|
---|
578 | */
|
---|
579 | DECLR3CALLBACKMEMBER(int, pfnCreateProxyDevice,(PVUSBIRHCONFIG pInterface, PCRTUUID pUuid, bool fRemote, const char *pszAddress, void *pvBackend));
|
---|
580 |
|
---|
581 | /**
|
---|
582 | * Removes a USB proxy device from the root hub and destroys it.
|
---|
583 | *
|
---|
584 | * @returns VBox status code.
|
---|
585 | * @param pInterface Pointer to the root hub configuration interface structure.
|
---|
586 | * @param pUuid Pointer to the UUID for the device.
|
---|
587 | */
|
---|
588 | DECLR3CALLBACKMEMBER(int, pfnDestroyProxyDevice,(PVUSBIRHCONFIG pInterface, PCRTUUID pUuid));
|
---|
589 |
|
---|
590 | } VUSBIRHCONFIG;
|
---|
591 | /** VUSBIRHCONFIG interface ID. */
|
---|
592 | #define VUSBIRHCONFIG_IID "c354cd97-e85f-465e-bc12-b58798465f52"
|
---|
593 |
|
---|
594 |
|
---|
595 | #ifdef IN_RING3
|
---|
596 | /** @copydoc VUSBIRHCONFIG::pfnCreateProxyDevice */
|
---|
597 | DECLINLINE(int) VUSBIRhCreateProxyDevice(PVUSBIRHCONFIG pInterface, PCRTUUID pUuid, bool fRemote, const char *pszAddress, void *pvBackend)
|
---|
598 | {
|
---|
599 | return pInterface->pfnCreateProxyDevice(pInterface, pUuid, fRemote, pszAddress, pvBackend);
|
---|
600 | }
|
---|
601 |
|
---|
602 | /** @copydoc VUSBIRHCONFIG::pfnDestroyProxyDevice */
|
---|
603 | DECLINLINE(int) VUSBIRhDestroyProxyDevice(PVUSBIRHCONFIG pInterface, PCRTUUID pUuid)
|
---|
604 | {
|
---|
605 | return pInterface->pfnDestroyProxyDevice(pInterface, pUuid);
|
---|
606 | }
|
---|
607 | #endif /* IN_RING3 */
|
---|
608 |
|
---|
609 |
|
---|
610 |
|
---|
611 | /**
|
---|
612 | * VUSB device reset completion callback function.
|
---|
613 | * This is called by the reset thread when the reset has been completed.
|
---|
614 | *
|
---|
615 | * @param pDev Pointer to the virtual USB device core.
|
---|
616 | * @param rc The VBox status code of the reset operation.
|
---|
617 | * @param pvUser User specific argument.
|
---|
618 | *
|
---|
619 | * @thread The reset thread or EMT.
|
---|
620 | */
|
---|
621 | typedef DECLCALLBACK(void) FNVUSBRESETDONE(PVUSBIDEVICE pDevice, int rc, void *pvUser);
|
---|
622 | /** Pointer to a device reset completion callback function (FNUSBRESETDONE). */
|
---|
623 | typedef FNVUSBRESETDONE *PFNVUSBRESETDONE;
|
---|
624 |
|
---|
625 | /**
|
---|
626 | * The state of a VUSB Device.
|
---|
627 | *
|
---|
628 | * @remark The order of these states is vital.
|
---|
629 | */
|
---|
630 | typedef enum VUSBDEVICESTATE
|
---|
631 | {
|
---|
632 | VUSB_DEVICE_STATE_INVALID = 0,
|
---|
633 | VUSB_DEVICE_STATE_DETACHED,
|
---|
634 | VUSB_DEVICE_STATE_ATTACHED,
|
---|
635 | VUSB_DEVICE_STATE_POWERED,
|
---|
636 | VUSB_DEVICE_STATE_DEFAULT,
|
---|
637 | VUSB_DEVICE_STATE_ADDRESS,
|
---|
638 | VUSB_DEVICE_STATE_CONFIGURED,
|
---|
639 | VUSB_DEVICE_STATE_SUSPENDED,
|
---|
640 | /** The device is being reset. Don't mess with it.
|
---|
641 | * Next states: VUSB_DEVICE_STATE_DEFAULT, VUSB_DEVICE_STATE_DESTROYED
|
---|
642 | */
|
---|
643 | VUSB_DEVICE_STATE_RESET,
|
---|
644 | /** The device has been destroy. */
|
---|
645 | VUSB_DEVICE_STATE_DESTROYED,
|
---|
646 | /** The usual 32-bit hack. */
|
---|
647 | VUSB_DEVICE_STATE_32BIT_HACK = 0x7fffffff
|
---|
648 | } VUSBDEVICESTATE;
|
---|
649 |
|
---|
650 |
|
---|
651 | /**
|
---|
652 | * USB Device Interface (up).
|
---|
653 | * No interface pair.
|
---|
654 | */
|
---|
655 | typedef struct VUSBIDEVICE
|
---|
656 | {
|
---|
657 | /**
|
---|
658 | * Resets the device.
|
---|
659 | *
|
---|
660 | * Since a device reset shall take at least 10ms from the guest point of view,
|
---|
661 | * it must be performed asynchronously. We create a thread which performs this
|
---|
662 | * operation and ensures it will take at least 10ms.
|
---|
663 | *
|
---|
664 | * At times - like init - a synchronous reset is required, this can be done
|
---|
665 | * by passing NULL for pfnDone.
|
---|
666 | *
|
---|
667 | * -- internal stuff, move it --
|
---|
668 | * While the device is being reset it is in the VUSB_DEVICE_STATE_RESET state.
|
---|
669 | * On completion it will be in the VUSB_DEVICE_STATE_DEFAULT state if successful,
|
---|
670 | * or in the VUSB_DEVICE_STATE_DETACHED state if the rest failed.
|
---|
671 | * -- internal stuff, move it --
|
---|
672 | *
|
---|
673 | * @returns VBox status code.
|
---|
674 | * @param pInterface Pointer to this structure.
|
---|
675 | * @param fResetOnLinux Set if we can permit a real reset and a potential logical
|
---|
676 | * device reconnect on linux hosts.
|
---|
677 | * @param pfnDone Pointer to the completion routine. If NULL a synchronous
|
---|
678 | * reset is preformed not respecting the 10ms.
|
---|
679 | * @param pvUser User argument to the completion routine.
|
---|
680 | * @param pVM Pointer to the VM handle if callback in EMT is required. (optional)
|
---|
681 | */
|
---|
682 | DECLR3CALLBACKMEMBER(int, pfnReset,(PVUSBIDEVICE pInterface, bool fResetOnLinux,
|
---|
683 | PFNVUSBRESETDONE pfnDone, void *pvUser, PVM pVM));
|
---|
684 |
|
---|
685 | /**
|
---|
686 | * Powers on the device.
|
---|
687 | *
|
---|
688 | * @returns VBox status code.
|
---|
689 | * @param pInterface Pointer to the device interface structure.
|
---|
690 | */
|
---|
691 | DECLR3CALLBACKMEMBER(int, pfnPowerOn,(PVUSBIDEVICE pInterface));
|
---|
692 |
|
---|
693 | /**
|
---|
694 | * Powers off the device.
|
---|
695 | *
|
---|
696 | * @returns VBox status code.
|
---|
697 | * @param pInterface Pointer to the device interface structure.
|
---|
698 | */
|
---|
699 | DECLR3CALLBACKMEMBER(int, pfnPowerOff,(PVUSBIDEVICE pInterface));
|
---|
700 |
|
---|
701 | /**
|
---|
702 | * Get the state of the device.
|
---|
703 | *
|
---|
704 | * @returns Device state.
|
---|
705 | * @param pInterface Pointer to the device interface structure.
|
---|
706 | */
|
---|
707 | DECLR3CALLBACKMEMBER(VUSBDEVICESTATE, pfnGetState,(PVUSBIDEVICE pInterface));
|
---|
708 |
|
---|
709 | } VUSBIDEVICE;
|
---|
710 | /** VUSBIDEVICE interface ID. */
|
---|
711 | #define VUSBIDEVICE_IID "88732dd3-0ccd-4625-b040-48804ac7a217"
|
---|
712 |
|
---|
713 |
|
---|
714 | #ifdef IN_RING3
|
---|
715 | /**
|
---|
716 | * Resets the device.
|
---|
717 | *
|
---|
718 | * Since a device reset shall take at least 10ms from the guest point of view,
|
---|
719 | * it must be performed asynchronously. We create a thread which performs this
|
---|
720 | * operation and ensures it will take at least 10ms.
|
---|
721 | *
|
---|
722 | * At times - like init - a synchronous reset is required, this can be done
|
---|
723 | * by passing NULL for pfnDone.
|
---|
724 | *
|
---|
725 | * -- internal stuff, move it --
|
---|
726 | * While the device is being reset it is in the VUSB_DEVICE_STATE_RESET state.
|
---|
727 | * On completion it will be in the VUSB_DEVICE_STATE_DEFAULT state if successful,
|
---|
728 | * or in the VUSB_DEVICE_STATE_DETACHED state if the rest failed.
|
---|
729 | * -- internal stuff, move it --
|
---|
730 | *
|
---|
731 | * @returns VBox status code.
|
---|
732 | * @param pInterface Pointer to the device interface structure.
|
---|
733 | * @param fResetOnLinux Set if we can permit a real reset and a potential logical
|
---|
734 | * device reconnect on linux hosts.
|
---|
735 | * @param pfnDone Pointer to the completion routine. If NULL a synchronous
|
---|
736 | * reset is preformed not respecting the 10ms.
|
---|
737 | * @param pvUser User argument to the completion routine.
|
---|
738 | * @param pVM Pointer to the VM handle if callback in EMT is required. (optional)
|
---|
739 | */
|
---|
740 | DECLINLINE(int) VUSBIDevReset(PVUSBIDEVICE pInterface, bool fResetOnLinux, PFNVUSBRESETDONE pfnDone, void *pvUser, PVM pVM)
|
---|
741 | {
|
---|
742 | return pInterface->pfnReset(pInterface, fResetOnLinux, pfnDone, pvUser, pVM);
|
---|
743 | }
|
---|
744 |
|
---|
745 | /**
|
---|
746 | * Powers on the device.
|
---|
747 | *
|
---|
748 | * @returns VBox status code.
|
---|
749 | * @param pInterface Pointer to the device interface structure.
|
---|
750 | */
|
---|
751 | DECLINLINE(int) VUSBIDevPowerOn(PVUSBIDEVICE pInterface)
|
---|
752 | {
|
---|
753 | return pInterface->pfnPowerOn(pInterface);
|
---|
754 | }
|
---|
755 |
|
---|
756 | /**
|
---|
757 | * Powers off the device.
|
---|
758 | *
|
---|
759 | * @returns VBox status code.
|
---|
760 | * @param pInterface Pointer to the device interface structure.
|
---|
761 | */
|
---|
762 | DECLINLINE(int) VUSBIDevPowerOff(PVUSBIDEVICE pInterface)
|
---|
763 | {
|
---|
764 | return pInterface->pfnPowerOff(pInterface);
|
---|
765 | }
|
---|
766 |
|
---|
767 | /**
|
---|
768 | * Get the state of the device.
|
---|
769 | *
|
---|
770 | * @returns Device state.
|
---|
771 | * @param pInterface Pointer to the device interface structure.
|
---|
772 | */
|
---|
773 | DECLINLINE(VUSBDEVICESTATE) VUSBIDevGetState(PVUSBIDEVICE pInterface)
|
---|
774 | {
|
---|
775 | return pInterface->pfnGetState(pInterface);
|
---|
776 | }
|
---|
777 | #endif /* IN_RING3 */
|
---|
778 |
|
---|
779 |
|
---|
780 | /** @name URB
|
---|
781 | * @{ */
|
---|
782 |
|
---|
783 | /**
|
---|
784 | * VUSB Transfer status codes.
|
---|
785 | */
|
---|
786 | typedef enum VUSBSTATUS
|
---|
787 | {
|
---|
788 | /** Transer was ok. */
|
---|
789 | VUSBSTATUS_OK = 0,
|
---|
790 | /** Transfer stalled, endpoint halted. */
|
---|
791 | VUSBSTATUS_STALL,
|
---|
792 | /** Device not responding. */
|
---|
793 | VUSBSTATUS_DNR,
|
---|
794 | /** CRC error. */
|
---|
795 | VUSBSTATUS_CRC,
|
---|
796 | /** Data overrun error. */
|
---|
797 | VUSBSTATUS_DATA_UNDERRUN,
|
---|
798 | /** Data overrun error. */
|
---|
799 | VUSBSTATUS_DATA_OVERRUN,
|
---|
800 | /** The isochronous buffer hasn't been touched. */
|
---|
801 | VUSBSTATUS_NOT_ACCESSED,
|
---|
802 | /** Invalid status. */
|
---|
803 | VUSBSTATUS_INVALID = 0x7f
|
---|
804 | } VUSBSTATUS;
|
---|
805 |
|
---|
806 |
|
---|
807 | /**
|
---|
808 | * VUSB Transfer types.
|
---|
809 | */
|
---|
810 | typedef enum VUSBXFERTYPE
|
---|
811 | {
|
---|
812 | /** Control message. Used to represent a single control transfer. */
|
---|
813 | VUSBXFERTYPE_CTRL = 0,
|
---|
814 | /* Isochronous transfer. */
|
---|
815 | VUSBXFERTYPE_ISOC,
|
---|
816 | /** Bulk transfer. */
|
---|
817 | VUSBXFERTYPE_BULK,
|
---|
818 | /** Interrupt transfer. */
|
---|
819 | VUSBXFERTYPE_INTR,
|
---|
820 | /** Complete control message. Used to represent an entire control message. */
|
---|
821 | VUSBXFERTYPE_MSG,
|
---|
822 | /** Invalid transfer type. */
|
---|
823 | VUSBXFERTYPE_INVALID = 0x7f
|
---|
824 | } VUSBXFERTYPE;
|
---|
825 |
|
---|
826 |
|
---|
827 | /**
|
---|
828 | * VUSB transfer direction.
|
---|
829 | */
|
---|
830 | typedef enum VUSBDIRECTION
|
---|
831 | {
|
---|
832 | /** Setup */
|
---|
833 | VUSBDIRECTION_SETUP = 0,
|
---|
834 | #define VUSB_DIRECTION_SETUP VUSBDIRECTION_SETUP
|
---|
835 | /** In - Device to host. */
|
---|
836 | VUSBDIRECTION_IN = 1,
|
---|
837 | #define VUSB_DIRECTION_IN VUSBDIRECTION_IN
|
---|
838 | /** Out - Host to device. */
|
---|
839 | VUSBDIRECTION_OUT = 2,
|
---|
840 | #define VUSB_DIRECTION_OUT VUSBDIRECTION_OUT
|
---|
841 | /** Invalid direction */
|
---|
842 | VUSBDIRECTION_INVALID = 0x7f
|
---|
843 | } VUSBDIRECTION;
|
---|
844 |
|
---|
845 | /**
|
---|
846 | * The URB states
|
---|
847 | */
|
---|
848 | typedef enum VUSBURBSTATE
|
---|
849 | {
|
---|
850 | /** The usual invalid state. */
|
---|
851 | VUSBURBSTATE_INVALID = 0,
|
---|
852 | /** The URB is free, i.e. not in use.
|
---|
853 | * Next state: ALLOCATED */
|
---|
854 | VUSBURBSTATE_FREE,
|
---|
855 | /** The URB is allocated, i.e. being prepared for submission.
|
---|
856 | * Next state: FREE, IN_FLIGHT */
|
---|
857 | VUSBURBSTATE_ALLOCATED,
|
---|
858 | /** The URB is in flight.
|
---|
859 | * Next state: REAPED, CANCELLED */
|
---|
860 | VUSBURBSTATE_IN_FLIGHT,
|
---|
861 | /** The URB has been reaped and is being completed.
|
---|
862 | * Next state: FREE */
|
---|
863 | VUSBURBSTATE_REAPED,
|
---|
864 | /** The URB has been cancelled and is awaiting reaping and immediate freeing.
|
---|
865 | * Next state: FREE */
|
---|
866 | VUSBURBSTATE_CANCELLED,
|
---|
867 | /** The end of the valid states (exclusive). */
|
---|
868 | VUSBURBSTATE_END,
|
---|
869 | /** The usual 32-bit blow up. */
|
---|
870 | VUSBURBSTATE_32BIT_HACK = 0x7fffffff
|
---|
871 | } VUSBURBSTATE;
|
---|
872 |
|
---|
873 |
|
---|
874 | /**
|
---|
875 | * Information about a isochronous packet.
|
---|
876 | */
|
---|
877 | typedef struct VUSBURBISOCPKT
|
---|
878 | {
|
---|
879 | /** The size of the packet.
|
---|
880 | * IN: The packet size. I.e. the number of bytes to the next packet or end of buffer.
|
---|
881 | * OUT: The actual size transfered. */
|
---|
882 | uint16_t cb;
|
---|
883 | /** The offset of the packet. (Relative to VUSBURB::abData[0].)
|
---|
884 | * OUT: This can be changed by the USB device if it does some kind of buffer squeezing. */
|
---|
885 | uint16_t off;
|
---|
886 | /** The status of the transfer.
|
---|
887 | * IN: VUSBSTATUS_INVALID
|
---|
888 | * OUT: VUSBSTATUS_INVALID if nothing was done, otherwise the correct status. */
|
---|
889 | VUSBSTATUS enmStatus;
|
---|
890 | } VUSBURBISOCPKT;
|
---|
891 | /** Pointer to a isochronous packet. */
|
---|
892 | typedef VUSBURBISOCPKT *PVUSBURBISOCPTK;
|
---|
893 | /** Pointer to a const isochronous packet. */
|
---|
894 | typedef const VUSBURBISOCPKT *PCVUSBURBISOCPKT;
|
---|
895 |
|
---|
896 | /**
|
---|
897 | * Asynchronous USB request descriptor
|
---|
898 | */
|
---|
899 | typedef struct VUSBURB
|
---|
900 | {
|
---|
901 | /** URB magic value. */
|
---|
902 | uint32_t u32Magic;
|
---|
903 | /** The USR state. */
|
---|
904 | VUSBURBSTATE enmState;
|
---|
905 | /** URB description, can be null. intended for logging. */
|
---|
906 | char *pszDesc;
|
---|
907 |
|
---|
908 | /** The VUSB data. */
|
---|
909 | struct VUSBURBVUSB
|
---|
910 | {
|
---|
911 | /** URB chain pointer. */
|
---|
912 | PVUSBURB pNext;
|
---|
913 | /** URB chain pointer. */
|
---|
914 | PVUSBURB *ppPrev;
|
---|
915 | /** Pointer to the original for control messages. */
|
---|
916 | PVUSBURB pCtrlUrb;
|
---|
917 | /** Pointer to the VUSB device.
|
---|
918 | * This may be NULL if the destination address is invalid. */
|
---|
919 | struct VUSBDEV *pDev;
|
---|
920 | /** Sepcific to the pfnFree function. */
|
---|
921 | void *pvFreeCtx;
|
---|
922 | /**
|
---|
923 | * Callback which will free the URB once it's reaped and completed.
|
---|
924 | * @param pUrb The URB.
|
---|
925 | */
|
---|
926 | DECLCALLBACKMEMBER(void, pfnFree)(PVUSBURB pUrb);
|
---|
927 | /** Submit timestamp. (logging only) */
|
---|
928 | uint64_t u64SubmitTS;
|
---|
929 | /** The allocated data length. */
|
---|
930 | uint32_t cbDataAllocated;
|
---|
931 | /** The allocated TD length. */
|
---|
932 | uint32_t cTdsAllocated;
|
---|
933 | } VUsb;
|
---|
934 |
|
---|
935 | /** The host controller data. */
|
---|
936 | struct VUSBURBHCI
|
---|
937 | {
|
---|
938 | /** The endpoint descriptor address. */
|
---|
939 | RTGCPHYS32 EdAddr;
|
---|
940 | /** Number of Tds in the array. */
|
---|
941 | uint32_t cTds;
|
---|
942 | /** Pointer to an array of TD info items.*/
|
---|
943 | struct VUSBURBHCITD
|
---|
944 | {
|
---|
945 | /** Type of TD (private) */
|
---|
946 | uint32_t TdType;
|
---|
947 | /** The address of the */
|
---|
948 | RTGCPHYS32 TdAddr;
|
---|
949 | /** A copy of the TD. */
|
---|
950 | uint32_t TdCopy[16];
|
---|
951 | } *paTds;
|
---|
952 | /** URB chain pointer. */
|
---|
953 | PVUSBURB pNext;
|
---|
954 | /** When this URB was created.
|
---|
955 | * (Used for isochronous frames and for logging.) */
|
---|
956 | uint32_t u32FrameNo;
|
---|
957 | /** Flag indicating that the TDs have been unlinked. */
|
---|
958 | bool fUnlinked;
|
---|
959 | } Hci;
|
---|
960 |
|
---|
961 | /** The device data. */
|
---|
962 | struct VUSBURBDEV
|
---|
963 | {
|
---|
964 | /** Pointer to the proxy URB. */
|
---|
965 | void *pvProxyUrb;
|
---|
966 | } Dev;
|
---|
967 |
|
---|
968 | /** The USB device instance this belongs to.
|
---|
969 | * This is NULL if the device address is invalid, in which case this belongs to the hub. */
|
---|
970 | PPDMUSBINS pUsbIns;
|
---|
971 | /** The device address.
|
---|
972 | * This is set at allocation time. */
|
---|
973 | uint8_t DstAddress;
|
---|
974 |
|
---|
975 | /** The endpoint.
|
---|
976 | * IN: Must be set before submitting the URB.
|
---|
977 | * @remark This does not have the high bit (direction) set! */
|
---|
978 | uint8_t EndPt;
|
---|
979 | /** The transfer type.
|
---|
980 | * IN: Must be set before submitting the URB. */
|
---|
981 | VUSBXFERTYPE enmType;
|
---|
982 | /** The transfer direction.
|
---|
983 | * IN: Must be set before submitting the URB. */
|
---|
984 | VUSBDIRECTION enmDir;
|
---|
985 | /** Indicates whether it is OK to receive/send less data than requested.
|
---|
986 | * IN: Must be initialized before submitting the URB. */
|
---|
987 | bool fShortNotOk;
|
---|
988 | /** The transfer status.
|
---|
989 | * OUT: This is set when reaping the URB. */
|
---|
990 | VUSBSTATUS enmStatus;
|
---|
991 |
|
---|
992 | /** The number of isochronous packets describe in aIsocPkts.
|
---|
993 | * This is ignored when enmType isn't VUSBXFERTYPE_ISOC. */
|
---|
994 | uint32_t cIsocPkts;
|
---|
995 | /** The iso packets within abData.
|
---|
996 | * This is ignored when enmType isn't VUSBXFERTYPE_ISOC. */
|
---|
997 | VUSBURBISOCPKT aIsocPkts[8];
|
---|
998 |
|
---|
999 | /** The message length.
|
---|
1000 | * IN: The amount of data to send / receive - set at allocation time.
|
---|
1001 | * OUT: The amount of data sent / received. */
|
---|
1002 | uint32_t cbData;
|
---|
1003 | /** The message data.
|
---|
1004 | * IN: On host to device transfers, the data to send.
|
---|
1005 | * OUT: On device to host transfers, the data to received. */
|
---|
1006 | uint8_t abData[8*_1K];
|
---|
1007 | } VUSBURB;
|
---|
1008 |
|
---|
1009 | /** The magic value of a valid VUSBURB. (Murakami Haruki) */
|
---|
1010 | #define VUSBURB_MAGIC 0x19490112
|
---|
1011 |
|
---|
1012 | /** @} */
|
---|
1013 |
|
---|
1014 |
|
---|
1015 | /** @} */
|
---|
1016 |
|
---|
1017 | RT_C_DECLS_END
|
---|
1018 |
|
---|
1019 | #endif
|
---|