VirtualBox

source: vbox/trunk/include/VBox/vusb.h@ 54506

最後變更 在這個檔案從54506是 53977,由 vboxsync 提交於 10 年 前

VUSB: Added separate SS EP companion descriptor to VUSBDESCENDPOINTEX since it is mandatory for USB3 and not class specific.

  • 屬性 svn:eol-style 設為 native
  • 屬性 svn:keywords 設為 Author Date Id Revision
檔案大小: 40.1 KB
 
1/** @file
2 * VUSB - VirtualBox USB. (DEV,VMM)
3 */
4
5/*
6 * Copyright (C) 2006-2012 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.alldomusa.eu.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
26#ifndef ___VBox_vusb_h
27#define ___VBox_vusb_h
28
29#include <VBox/cdefs.h>
30#include <VBox/types.h>
31
32#include <iprt/queueatomic.h>
33
34struct PDMLED;
35
36RT_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#define VUSB_DT_INTERFACE_ASSOCIATION 0x0B
60#define VUSB_DT_BOS 0x0F
61#define VUSB_DT_DEVICE_CAPABILITY 0x10
62#define VUSB_DT_SS_ENDPOINT_COMPANION 0x30
63/** @} */
64
65/** @name USB Descriptor minimum sizes (from spec)
66 * @{ */
67#define VUSB_DT_DEVICE_MIN_LEN 18
68#define VUSB_DT_CONFIG_MIN_LEN 9
69#define VUSB_DT_CONFIG_STRING_MIN_LEN 2
70#define VUSB_DT_INTERFACE_MIN_LEN 9
71#define VUSB_DT_ENDPOINT_MIN_LEN 7
72#define VUSB_DT_SSEP_COMPANION_MIN_LEN 6
73/** @} */
74
75/** @name USB Device Capability Type Codes (from spec)
76 * @{ */
77#define VUSB_DCT_WIRELESS_USB 0x01
78#define VUSB_DCT_USB_20_EXTENSION 0x02
79#define VUSB_DCT_SUPERSPEED_USB 0x03
80#define VUSB_DCT_CONTAINER_ID 0x04
81/** @} */
82
83
84#pragma pack(1) /* ensure byte packing of the descriptors. */
85
86/**
87 * USB language id descriptor (from specs).
88 */
89typedef struct VUSBDESCLANGID
90{
91 uint8_t bLength;
92 uint8_t bDescriptorType;
93} VUSBDESCLANGID;
94/** Pointer to a USB language id descriptor. */
95typedef VUSBDESCLANGID *PVUSBDESCLANGID;
96/** Pointer to a const USB language id descriptor. */
97typedef const VUSBDESCLANGID *PCVUSBDESCLANGID;
98
99
100/**
101 * USB string descriptor (from specs).
102 */
103typedef struct VUSBDESCSTRING
104{
105 uint8_t bLength;
106 uint8_t bDescriptorType;
107} VUSBDESCSTRING;
108/** Pointer to a USB string descriptor. */
109typedef VUSBDESCSTRING *PVUSBDESCSTRING;
110/** Pointer to a const USB string descriptor. */
111typedef const VUSBDESCSTRING *PCVUSBDESCSTRING;
112
113
114/**
115 * USB device descriptor (from spec)
116 */
117typedef struct VUSBDESCDEVICE
118{
119 uint8_t bLength;
120 uint8_t bDescriptorType;
121 uint16_t bcdUSB;
122 uint8_t bDeviceClass;
123 uint8_t bDeviceSubClass;
124 uint8_t bDeviceProtocol;
125 uint8_t bMaxPacketSize0;
126 uint16_t idVendor;
127 uint16_t idProduct;
128 uint16_t bcdDevice;
129 uint8_t iManufacturer;
130 uint8_t iProduct;
131 uint8_t iSerialNumber;
132 uint8_t bNumConfigurations;
133} VUSBDESCDEVICE;
134/** Pointer to a USB device descriptor. */
135typedef VUSBDESCDEVICE *PVUSBDESCDEVICE;
136/** Pointer to a const USB device descriptor. */
137typedef const VUSBDESCDEVICE *PCVUSBDESCDEVICE;
138
139/**
140 * USB device qualifier (from spec 9.6.2)
141 */
142struct VUSBDEVICEQUALIFIER
143{
144 uint8_t bLength;
145 uint8_t bDescriptorType;
146 uint16_t bcdUsb;
147 uint8_t bDeviceClass;
148 uint8_t bDeviceSubClass;
149 uint8_t bDeviceProtocol;
150 uint8_t bMaxPacketSize0;
151 uint8_t bNumConfigurations;
152 uint8_t bReserved;
153};
154
155typedef struct VUSBDEVICEQUALIFIER VUSBDEVICEQUALIFIER;
156typedef VUSBDEVICEQUALIFIER *PVUSBDEVICEQUALIFIER;
157
158
159/**
160 * USB configuration descriptor (from spec).
161 */
162typedef struct VUSBDESCCONFIG
163{
164 uint8_t bLength;
165 uint8_t bDescriptorType;
166 uint16_t wTotalLength; /**< recalculated by VUSB when involved in URB. */
167 uint8_t bNumInterfaces;
168 uint8_t bConfigurationValue;
169 uint8_t iConfiguration;
170 uint8_t bmAttributes;
171 uint8_t MaxPower;
172} VUSBDESCCONFIG;
173/** Pointer to a USB configuration descriptor. */
174typedef VUSBDESCCONFIG *PVUSBDESCCONFIG;
175/** Pointer to a readonly USB configuration descriptor. */
176typedef const VUSBDESCCONFIG *PCVUSBDESCCONFIG;
177
178
179/**
180 * USB interface association descriptor (from USB ECN Interface Association Descriptors)
181 */
182typedef struct VUSBDESCIAD
183{
184 uint8_t bLength;
185 uint8_t bDescriptorType;
186 uint8_t bFirstInterface;
187 uint8_t bInterfaceCount;
188 uint8_t bFunctionClass;
189 uint8_t bFunctionSubClass;
190 uint8_t bFunctionProtocol;
191 uint8_t iFunction;
192} VUSBDESCIAD;
193/** Pointer to a USB interface association descriptor. */
194typedef VUSBDESCIAD *PVUSBDESCIAD;
195/** Pointer to a readonly USB interface association descriptor. */
196typedef const VUSBDESCIAD *PCVUSBDESCIAD;
197
198
199/**
200 * USB interface descriptor (from spec)
201 */
202typedef struct VUSBDESCINTERFACE
203{
204 uint8_t bLength;
205 uint8_t bDescriptorType;
206 uint8_t bInterfaceNumber;
207 uint8_t bAlternateSetting;
208 uint8_t bNumEndpoints;
209 uint8_t bInterfaceClass;
210 uint8_t bInterfaceSubClass;
211 uint8_t bInterfaceProtocol;
212 uint8_t iInterface;
213} VUSBDESCINTERFACE;
214/** Pointer to a USB interface descriptor. */
215typedef VUSBDESCINTERFACE *PVUSBDESCINTERFACE;
216/** Pointer to a const USB interface descriptor. */
217typedef const VUSBDESCINTERFACE *PCVUSBDESCINTERFACE;
218
219
220/**
221 * USB endpoint descriptor (from spec)
222 */
223typedef struct VUSBDESCENDPOINT
224{
225 uint8_t bLength;
226 uint8_t bDescriptorType;
227 uint8_t bEndpointAddress;
228 uint8_t bmAttributes;
229 uint16_t wMaxPacketSize;
230 uint8_t bInterval;
231} VUSBDESCENDPOINT;
232/** Pointer to a USB endpoint descriptor. */
233typedef VUSBDESCENDPOINT *PVUSBDESCENDPOINT;
234/** Pointer to a const USB endpoint descriptor. */
235typedef const VUSBDESCENDPOINT *PCVUSBDESCENDPOINT;
236
237
238/**
239 * USB SuperSpeed endpoint companion descriptor (from USB3 spec)
240 */
241typedef struct VUSBDESCSSEPCOMPANION
242{
243 uint8_t bLength;
244 uint8_t bDescriptorType;
245 uint8_t bMaxBurst;
246 uint8_t bmAttributes;
247 uint16_t wBytesPerInterval;
248} VUSBDESCSSEPCOMPANION;
249/** Pointer to a USB endpoint companion descriptor. */
250typedef VUSBDESCSSEPCOMPANION *PVUSBDESCSSEPCOMPANION;
251/** Pointer to a const USB endpoint companion descriptor. */
252typedef const VUSBDESCSSEPCOMPANION *PCVUSBDESCSSEPCOMPANION;
253
254
255/**
256 * USB Binary Device Object Store, aka BOS (from USB3 spec)
257 */
258typedef struct VUSBDESCBOS
259{
260 uint8_t bLength;
261 uint8_t bDescriptorType;
262 uint16_t wTotalLength;
263 uint8_t bNumDeviceCaps;
264} VUSBDESCBOS;
265/** Pointer to a USB BOS descriptor. */
266typedef VUSBDESCBOS *PVUSBDESCBOS;
267/** Pointer to a const USB BOS descriptor. */
268typedef const VUSBDESCBOS *PCVUSBDESCBOS;
269
270
271/**
272 * Generic USB Device Capability Descriptor within BOS (from USB3 spec)
273 */
274typedef struct VUSBDESCDEVICECAP
275{
276 uint8_t bLength;
277 uint8_t bDescriptorType;
278 uint8_t bDevCapabilityType;
279 uint8_t aCapSpecific[1];
280} VUSBDESCDEVICECAP;
281/** Pointer to a USB device capability descriptor. */
282typedef VUSBDESCDEVICECAP *PVUSBDESCDEVICECAP;
283/** Pointer to a const USB device capability descriptor. */
284typedef const VUSBDESCDEVICECAP *PCVUSBDESCDEVICECAP;
285
286
287/**
288 * SuperSpeed USB Device Capability Descriptor within BOS
289 */
290typedef struct VUSBDESCSSDEVCAP
291{
292 uint8_t bLength;
293 uint8_t bDescriptorType; /* DEVICE CAPABILITY */
294 uint8_t bDevCapabilityType; /* SUPERSPEED_USB */
295 uint8_t bmAttributes;
296 uint16_t wSpeedsSupported;
297 uint8_t bFunctionalitySupport;
298 uint8_t bU1DevExitLat;
299 uint16_t wU2DevExitLat;
300} VUSBDESCSSDEVCAP;
301/** Pointer to an SS USB device capability descriptor. */
302typedef VUSBDESCSSDEVCAP *PVUSBDESCSSDEVCAP;
303/** Pointer to a const SS USB device capability descriptor. */
304typedef const VUSBDESCSSDEVCAP *PCVUSBDESCSSDEVCAP;
305
306
307/**
308 * USB 2.0 Extension Descriptor within BOS
309 */
310typedef struct VUSBDESCUSB2EXT
311{
312 uint8_t bLength;
313 uint8_t bDescriptorType; /* DEVICE CAPABILITY */
314 uint8_t bDevCapabilityType; /* USB 2.0 EXTENSION */
315 uint8_t bmAttributes;
316} VUSBDESCUSB2EXT;
317/** Pointer to a USB 2.0 extension capability descriptor. */
318typedef VUSBDESCUSB2EXT *PVUSBDESCUSB2EXT;
319/** Pointer to a const USB 2.0 extension capability descriptor. */
320typedef const VUSBDESCUSB2EXT *PCVUSBDESCUSB2EXT;
321
322
323#pragma pack() /* end of the byte packing. */
324
325
326/**
327 * USB configuration descriptor, the parsed variant used by VUSB.
328 */
329typedef struct VUSBDESCCONFIGEX
330{
331 /** The USB descriptor data.
332 * @remark The wTotalLength member is recalculated before the data is passed to the guest. */
333 VUSBDESCCONFIG Core;
334 /** Pointer to additional descriptor bytes following what's covered by VUSBDESCCONFIG. */
335 void *pvMore;
336 /** Pointer to an array of the interfaces referenced in the configuration.
337 * Core.bNumInterfaces in size. */
338 const struct VUSBINTERFACE *paIfs;
339 /** Pointer to the original descriptor data read from the device. */
340 const void *pvOriginal;
341} VUSBDESCCONFIGEX;
342/** Pointer to a parsed USB configuration descriptor. */
343typedef VUSBDESCCONFIGEX *PVUSBDESCCONFIGEX;
344/** Pointer to a const parsed USB configuration descriptor. */
345typedef const VUSBDESCCONFIGEX *PCVUSBDESCCONFIGEX;
346
347
348/**
349 * For tracking the alternate interface settings of a configuration.
350 */
351typedef struct VUSBINTERFACE
352{
353 /** Pointer to an array of interfaces. */
354 const struct VUSBDESCINTERFACEEX *paSettings;
355 /** The number of entries in the array. */
356 uint32_t cSettings;
357} VUSBINTERFACE;
358/** Pointer to a VUSBINTERFACE. */
359typedef VUSBINTERFACE *PVUSBINTERFACE;
360/** Pointer to a const VUSBINTERFACE. */
361typedef const VUSBINTERFACE *PCVUSBINTERFACE;
362
363
364/**
365 * USB interface descriptor, the parsed variant used by VUSB.
366 */
367typedef struct VUSBDESCINTERFACEEX
368{
369 /** The USB descriptor data. */
370 VUSBDESCINTERFACE Core;
371 /** Pointer to additional descriptor bytes following what's covered by VUSBDESCINTERFACE. */
372 const void *pvMore;
373 /** Pointer to additional class- or vendor-specific interface descriptors. */
374 const void *pvClass;
375 /** Size of class- or vendor-specific descriptors. */
376 uint16_t cbClass;
377 /** Pointer to an array of the endpoints referenced by the interface.
378 * Core.bNumEndpoints in size. */
379 const struct VUSBDESCENDPOINTEX *paEndpoints;
380 /** Interface association descriptor, which prepends a group of interfaces,
381 * starting with this interface. */
382 PCVUSBDESCIAD pIAD;
383 /** Size of interface association descriptor. */
384 uint16_t cbIAD;
385} VUSBDESCINTERFACEEX;
386/** Pointer to an prased USB interface descriptor. */
387typedef VUSBDESCINTERFACEEX *PVUSBDESCINTERFACEEX;
388/** Pointer to a const parsed USB interface descriptor. */
389typedef const VUSBDESCINTERFACEEX *PCVUSBDESCINTERFACEEX;
390
391
392/**
393 * USB endpoint descriptor, the parsed variant used by VUSB.
394 */
395typedef struct VUSBDESCENDPOINTEX
396{
397 /** The USB descriptor data.
398 * @remark The wMaxPacketSize member is converted to native endian. */
399 VUSBDESCENDPOINT Core;
400 /** Pointer to additional descriptor bytes following what's covered by VUSBDESCENDPOINT. */
401 const void *pvMore;
402 /** Pointer to additional class- or vendor-specific endpoint descriptors. */
403 const void *pvClass;
404 /** Size of class- or vendor-specific descriptors. */
405 uint16_t cbClass;
406 /** Pointer to SuperSpeed endpoint companion descriptor (SS endpoints only). */
407 const void *pvSsepc;
408 /** Size of SuperSpeed endpoint companion descriptor.
409 * @remark Must be non-zero for SuperSpeed endpoints. */
410 uint16_t cbSsepc;
411} VUSBDESCENDPOINTEX;
412/** Pointer to a parsed USB endpoint descriptor. */
413typedef VUSBDESCENDPOINTEX *PVUSBDESCENDPOINTEX;
414/** Pointer to a const parsed USB endpoint descriptor. */
415typedef const VUSBDESCENDPOINTEX *PCVUSBDESCENDPOINTEX;
416
417
418/** @name USB Control message recipient codes (from spec)
419 * @{ */
420#define VUSB_TO_DEVICE 0x0
421#define VUSB_TO_INTERFACE 0x1
422#define VUSB_TO_ENDPOINT 0x2
423#define VUSB_TO_OTHER 0x3
424#define VUSB_RECIP_MASK 0x1f
425/** @} */
426
427/** @name USB control pipe setup packet structure (from spec)
428 * @{ */
429#define VUSB_REQ_SHIFT (5)
430#define VUSB_REQ_STANDARD (0x0 << VUSB_REQ_SHIFT)
431#define VUSB_REQ_CLASS (0x1 << VUSB_REQ_SHIFT)
432#define VUSB_REQ_VENDOR (0x2 << VUSB_REQ_SHIFT)
433#define VUSB_REQ_RESERVED (0x3 << VUSB_REQ_SHIFT)
434#define VUSB_REQ_MASK (0x3 << VUSB_REQ_SHIFT)
435/** @} */
436
437#define VUSB_DIR_TO_DEVICE 0x00
438#define VUSB_DIR_TO_HOST 0x80
439#define VUSB_DIR_MASK 0x80
440
441/**
442 * USB Setup request (from spec)
443 */
444typedef struct vusb_setup
445{
446 uint8_t bmRequestType;
447 uint8_t bRequest;
448 uint16_t wValue;
449 uint16_t wIndex;
450 uint16_t wLength;
451} VUSBSETUP;
452/** Pointer to a setup request. */
453typedef VUSBSETUP *PVUSBSETUP;
454/** Pointer to a const setup request. */
455typedef const VUSBSETUP *PCVUSBSETUP;
456
457/** @name USB Standard device requests (from spec)
458 * @{ */
459#define VUSB_REQ_GET_STATUS 0x00
460#define VUSB_REQ_CLEAR_FEATURE 0x01
461#define VUSB_REQ_SET_FEATURE 0x03
462#define VUSB_REQ_SET_ADDRESS 0x05
463#define VUSB_REQ_GET_DESCRIPTOR 0x06
464#define VUSB_REQ_SET_DESCRIPTOR 0x07
465#define VUSB_REQ_GET_CONFIGURATION 0x08
466#define VUSB_REQ_SET_CONFIGURATION 0x09
467#define VUSB_REQ_GET_INTERFACE 0x0a
468#define VUSB_REQ_SET_INTERFACE 0x0b
469#define VUSB_REQ_SYNCH_FRAME 0x0c
470#define VUSB_REQ_MAX 0x0d
471/** @} */
472
473/** @} */ /* end of grp_vusb_std */
474
475
476
477/** @name USB Standard version flags.
478 * @{ */
479/** Indicates USB 1.1 support. */
480#define VUSB_STDVER_11 RT_BIT(1)
481/** Indicates USB 2.0 support. */
482#define VUSB_STDVER_20 RT_BIT(2)
483/** Indicates USB 3.0 support. */
484#define VUSB_STDVER_30 RT_BIT(3)
485/** @} */
486
487/**
488 * USB port/device speeds.
489 */
490typedef enum VUSBSPEED
491{
492 /** Undetermined/unknown speed. */
493 VUSB_SPEED_UNKNOWN = 0,
494 /** Low-speed (LS), 1.5 Mbit/s, USB 1.0. */
495 VUSB_SPEED_LOW,
496 /** Full-speed (FS), 12 Mbit/s, USB 1.1. */
497 VUSB_SPEED_FULL,
498 /** High-speed (HS), 480 Mbit/s, USB 2.0. */
499 VUSB_SPEED_HIGH,
500 /** Variable speed, wireless USB 2.5. */
501 VUSB_SPEED_VARIABLE,
502 /** SuperSpeed (SS), 5.0 Gbit/s, USB 3.0. */
503 VUSB_SPEED_SUPER,
504 /** SuperSpeed+ (SS+), 10.0 Gbit/s, USB 3.1. */
505 VUSB_SPEED_SUPERPLUS,
506 /** The usual 32-bit hack. */
507 VUSB_SPEED_32BIT_HACK = 0x7fffffff
508} VUSBSPEED;
509
510/** Pointer to a VBox USB device interface. */
511typedef struct VUSBIDEVICE *PVUSBIDEVICE;
512
513/** Pointer to a VUSB RootHub port interface. */
514typedef struct VUSBIROOTHUBPORT *PVUSBIROOTHUBPORT;
515
516/** Pointer to an USB request descriptor. */
517typedef struct VUSBURB *PVUSBURB;
518
519
520
521/**
522 * VBox USB port bitmap.
523 *
524 * Bit 0 == Port 0, ... , Bit 127 == Port 127.
525 */
526typedef struct VUSBPORTBITMAP
527{
528 /** 128 bits */
529 char ach[16];
530} VUSBPORTBITMAP;
531/** Pointer to a VBox USB port bitmap. */
532typedef VUSBPORTBITMAP *PVUSBPORTBITMAP;
533
534#ifndef RDESKTOP
535
536/**
537 * The VUSB RootHub port interface provided by the HCI (down).
538 * Pair with VUSBIROOTCONNECTOR
539 */
540typedef struct VUSBIROOTHUBPORT
541{
542 /**
543 * Get the number of available ports in the hub.
544 *
545 * @returns The number of ports available.
546 * @param pInterface Pointer to this structure.
547 * @param pAvailable Bitmap indicating the available ports. Set bit == available port.
548 */
549 DECLR3CALLBACKMEMBER(unsigned, pfnGetAvailablePorts,(PVUSBIROOTHUBPORT pInterface, PVUSBPORTBITMAP pAvailable));
550
551 /**
552 * Gets the supported USB versions.
553 *
554 * @returns The mask of supported USB versions.
555 * @param pInterface Pointer to this structure.
556 */
557 DECLR3CALLBACKMEMBER(uint32_t, pfnGetUSBVersions,(PVUSBIROOTHUBPORT pInterface));
558
559 /**
560 * A device is being attached to a port in the roothub.
561 *
562 * @param pInterface Pointer to this structure.
563 * @param pDev Pointer to the device being attached.
564 * @param uPort The port number assigned to the device.
565 */
566 DECLR3CALLBACKMEMBER(int, pfnAttach,(PVUSBIROOTHUBPORT pInterface, PVUSBIDEVICE pDev, unsigned uPort));
567
568 /**
569 * A device is being detached from a port in the roothub.
570 *
571 * @param pInterface Pointer to this structure.
572 * @param pDev Pointer to the device being detached.
573 * @param uPort The port number assigned to the device.
574 */
575 DECLR3CALLBACKMEMBER(void, pfnDetach,(PVUSBIROOTHUBPORT pInterface, PVUSBIDEVICE pDev, unsigned uPort));
576
577 /**
578 * Reset the root hub.
579 *
580 * @returns VBox status code.
581 * @param pInterface Pointer to this structure.
582 * @param pResetOnLinux Whether or not to do real reset on linux.
583 */
584 DECLR3CALLBACKMEMBER(int, pfnReset,(PVUSBIROOTHUBPORT pInterface, bool fResetOnLinux));
585
586 /**
587 * Transfer completion callback routine.
588 *
589 * VUSB will call this when a transfer have been completed
590 * in a one or another way.
591 *
592 * @param pInterface Pointer to this structure.
593 * @param pUrb Pointer to the URB in question.
594 */
595 DECLR3CALLBACKMEMBER(void, pfnXferCompletion,(PVUSBIROOTHUBPORT pInterface, PVUSBURB urb));
596
597 /**
598 * Handle transfer errors.
599 *
600 * VUSB calls this when a transfer attempt failed. This function will respond
601 * indicating whether to retry or complete the URB with failure.
602 *
603 * @returns Retry indicator.
604 * @param pInterface Pointer to this structure.
605 * @param pUrb Pointer to the URB in question.
606 */
607 DECLR3CALLBACKMEMBER(bool, pfnXferError,(PVUSBIROOTHUBPORT pInterface, PVUSBURB pUrb));
608
609 /** Alignment dummy. */
610 RTR3PTR Alignment;
611
612} VUSBIROOTHUBPORT;
613/** VUSBIROOTHUBPORT interface ID. */
614#define VUSBIROOTHUBPORT_IID "e38e2978-7aa2-4860-94b6-9ef4a066d8a0"
615
616
617/** Pointer to a VUSB RootHub connector interface. */
618typedef struct VUSBIROOTHUBCONNECTOR *PVUSBIROOTHUBCONNECTOR;
619/**
620 * The VUSB RootHub connector interface provided by the VBox USB RootHub driver
621 * (up).
622 * Pair with VUSBIROOTHUBPORT.
623 */
624typedef struct VUSBIROOTHUBCONNECTOR
625{
626 /**
627 * Allocates a new URB for a transfer.
628 *
629 * Either submit using pfnSubmitUrb or free using VUSBUrbFree().
630 *
631 * @returns Pointer to a new URB.
632 * @returns NULL on failure - try again later.
633 * This will not fail if the device wasn't found. We'll fail it
634 * at submit time, since that makes the usage of this api simpler.
635 * @param pInterface Pointer to this struct.
636 * @param DstAddress The destination address of the URB.
637 * @param cbData The amount of data space required.
638 * @param cTds The amount of TD space.
639 */
640 DECLR3CALLBACKMEMBER(PVUSBURB, pfnNewUrb,(PVUSBIROOTHUBCONNECTOR pInterface, uint8_t DstAddress, uint32_t cbData, uint32_t cTds));
641
642 /**
643 * Submits a URB for transfer.
644 * The transfer will do asynchronously if possible.
645 *
646 * @returns VBox status code.
647 * @param pInterface Pointer to this struct.
648 * @param pUrb Pointer to the URB returned by pfnNewUrb.
649 * The URB will be freed in case of failure.
650 * @param pLed Pointer to USB Status LED
651 */
652 DECLR3CALLBACKMEMBER(int, pfnSubmitUrb,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb, struct PDMLED *pLed));
653
654 /**
655 * Call to service asynchronous URB completions in a polling fashion.
656 *
657 * Reaped URBs will be finished by calling the completion callback,
658 * thus there is no return code or input or anything from this function
659 * except for potential state changes elsewhere.
660 *
661 * @returns VINF_SUCCESS if no URBs are pending upon return.
662 * @returns VERR_TIMEOUT if one or more URBs are still in flight upon returning.
663 * @returns Other VBox status code.
664 *
665 * @param pInterface Pointer to this struct.
666 * @param cMillies Number of milliseconds to poll for completion.
667 */
668 DECLR3CALLBACKMEMBER(void, pfnReapAsyncUrbs,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice, RTMSINTERVAL cMillies));
669
670 /**
671 * Cancels and completes - with CRC failure - all URBs queued on an endpoint.
672 * This is done in response to guest URB cancellation.
673 *
674 * @returns VBox status code.
675 * @param pInterface Pointer to this struct.
676 * @param pUrb Pointer to a previously submitted URB.
677 */
678 DECLR3CALLBACKMEMBER(int, pfnCancelUrbsEp,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb));
679
680 /**
681 * Cancels and completes - with CRC failure - all in-flight async URBs.
682 * This is typically done before saving a state.
683 *
684 * @param pInterface Pointer to this struct.
685 */
686 DECLR3CALLBACKMEMBER(void, pfnCancelAllUrbs,(PVUSBIROOTHUBCONNECTOR pInterface));
687
688 /**
689 * Attach the device to the root hub.
690 * The device must not be attached to any hub for this call to succeed.
691 *
692 * @returns VBox status code.
693 * @param pInterface Pointer to this struct.
694 * @param pDevice Pointer to the device (interface) attach.
695 */
696 DECLR3CALLBACKMEMBER(int, pfnAttachDevice,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice));
697
698 /**
699 * Detach the device from the root hub.
700 * The device must already be attached for this call to succeed.
701 *
702 * @returns VBox status code.
703 * @param pInterface Pointer to this struct.
704 * @param pDevice Pointer to the device (interface) to detach.
705 */
706 DECLR3CALLBACKMEMBER(int, pfnDetachDevice,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice));
707
708} VUSBIROOTHUBCONNECTOR;
709/** VUSBIROOTHUBCONNECTOR interface ID. */
710#define VUSBIROOTHUBCONNECTOR_IID "d9a90c59-e3ff-4dff-9754-844557c3f7a0"
711
712
713#ifdef IN_RING3
714/** @copydoc VUSBIROOTHUBCONNECTOR::pfnNewUrb */
715DECLINLINE(PVUSBURB) VUSBIRhNewUrb(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t DstAddress, uint32_t cbData, uint32_t cTds)
716{
717 return pInterface->pfnNewUrb(pInterface, DstAddress, cbData, cTds);
718}
719
720/** @copydoc VUSBIROOTHUBCONNECTOR::pfnSubmitUrb */
721DECLINLINE(int) VUSBIRhSubmitUrb(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb, struct PDMLED *pLed)
722{
723 return pInterface->pfnSubmitUrb(pInterface, pUrb, pLed);
724}
725
726/** @copydoc VUSBIROOTHUBCONNECTOR::pfnReapAsyncUrbs */
727DECLINLINE(void) VUSBIRhReapAsyncUrbs(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice, RTMSINTERVAL cMillies)
728{
729 pInterface->pfnReapAsyncUrbs(pInterface, pDevice, cMillies);
730}
731
732/** @copydoc VUSBIROOTHUBCONNECTOR::pfnCancelAllUrbs */
733DECLINLINE(void) VUSBIRhCancelAllUrbs(PVUSBIROOTHUBCONNECTOR pInterface)
734{
735 pInterface->pfnCancelAllUrbs(pInterface);
736}
737
738/** @copydoc VUSBIROOTHUBCONNECTOR::pfnAttachDevice */
739DECLINLINE(int) VUSBIRhAttachDevice(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice)
740{
741 return pInterface->pfnAttachDevice(pInterface, pDevice);
742}
743
744/** @copydoc VUSBIROOTHUBCONNECTOR::pfnDetachDevice */
745DECLINLINE(int) VUSBIRhDetachDevice(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice)
746{
747 return pInterface->pfnDetachDevice(pInterface, pDevice);
748}
749#endif /* IN_RING3 */
750
751
752
753/** Pointer to a Root Hub Configuration Interface. */
754typedef struct VUSBIRHCONFIG *PVUSBIRHCONFIG;
755/**
756 * Root Hub Configuration Interface (intended for MAIN).
757 * No interface pair.
758 */
759typedef struct VUSBIRHCONFIG
760{
761 /**
762 * Creates a USB proxy device and attaches it to the root hub.
763 *
764 * @returns VBox status code.
765 * @param pInterface Pointer to the root hub configuration interface structure.
766 * @param pUuid Pointer to the UUID for the new device.
767 * @param fRemote Whether the device must use the VRDP backend.
768 * @param pszAddress OS specific device address.
769 * @param pvBackend An opaque pointer for the backend. Only used by
770 * the VRDP backend so far.
771 */
772 DECLR3CALLBACKMEMBER(int, pfnCreateProxyDevice,(PVUSBIRHCONFIG pInterface, PCRTUUID pUuid, bool fRemote, const char *pszAddress, void *pvBackend));
773
774 /**
775 * Removes a USB proxy device from the root hub and destroys it.
776 *
777 * @returns VBox status code.
778 * @param pInterface Pointer to the root hub configuration interface structure.
779 * @param pUuid Pointer to the UUID for the device.
780 */
781 DECLR3CALLBACKMEMBER(int, pfnDestroyProxyDevice,(PVUSBIRHCONFIG pInterface, PCRTUUID pUuid));
782
783} VUSBIRHCONFIG;
784/** VUSBIRHCONFIG interface ID. */
785#define VUSBIRHCONFIG_IID "c354cd97-e85f-465e-bc12-b58798465f52"
786
787
788#ifdef IN_RING3
789/** @copydoc VUSBIRHCONFIG::pfnCreateProxyDevice */
790DECLINLINE(int) VUSBIRhCreateProxyDevice(PVUSBIRHCONFIG pInterface, PCRTUUID pUuid, bool fRemote, const char *pszAddress, void *pvBackend)
791{
792 return pInterface->pfnCreateProxyDevice(pInterface, pUuid, fRemote, pszAddress, pvBackend);
793}
794
795/** @copydoc VUSBIRHCONFIG::pfnDestroyProxyDevice */
796DECLINLINE(int) VUSBIRhDestroyProxyDevice(PVUSBIRHCONFIG pInterface, PCRTUUID pUuid)
797{
798 return pInterface->pfnDestroyProxyDevice(pInterface, pUuid);
799}
800#endif /* IN_RING3 */
801
802#endif /* ! RDESKTOP */
803
804
805/**
806 * VUSB device reset completion callback function.
807 * This is called by the reset thread when the reset has been completed.
808 *
809 * @param pDev Pointer to the virtual USB device core.
810 * @param rc The VBox status code of the reset operation.
811 * @param pvUser User specific argument.
812 *
813 * @thread The reset thread or EMT.
814 */
815typedef DECLCALLBACK(void) FNVUSBRESETDONE(PVUSBIDEVICE pDevice, int rc, void *pvUser);
816/** Pointer to a device reset completion callback function (FNUSBRESETDONE). */
817typedef FNVUSBRESETDONE *PFNVUSBRESETDONE;
818
819/**
820 * The state of a VUSB Device.
821 *
822 * @remark The order of these states is vital.
823 */
824typedef enum VUSBDEVICESTATE
825{
826 VUSB_DEVICE_STATE_INVALID = 0,
827 VUSB_DEVICE_STATE_DETACHED,
828 VUSB_DEVICE_STATE_ATTACHED,
829 VUSB_DEVICE_STATE_POWERED,
830 VUSB_DEVICE_STATE_DEFAULT,
831 VUSB_DEVICE_STATE_ADDRESS,
832 VUSB_DEVICE_STATE_CONFIGURED,
833 VUSB_DEVICE_STATE_SUSPENDED,
834 /** The device is being reset. Don't mess with it.
835 * Next states: VUSB_DEVICE_STATE_DEFAULT, VUSB_DEVICE_STATE_DESTROYED
836 */
837 VUSB_DEVICE_STATE_RESET,
838 /** The device has been destroyed. */
839 VUSB_DEVICE_STATE_DESTROYED,
840 /** The usual 32-bit hack. */
841 VUSB_DEVICE_STATE_32BIT_HACK = 0x7fffffff
842} VUSBDEVICESTATE;
843
844#ifndef RDESKTOP
845
846/**
847 * USB Device Interface (up).
848 * No interface pair.
849 */
850typedef struct VUSBIDEVICE
851{
852 /**
853 * Resets the device.
854 *
855 * Since a device reset shall take at least 10ms from the guest point of view,
856 * it must be performed asynchronously. We create a thread which performs this
857 * operation and ensures it will take at least 10ms.
858 *
859 * At times - like init - a synchronous reset is required, this can be done
860 * by passing NULL for pfnDone.
861 *
862 * -- internal stuff, move it --
863 * While the device is being reset it is in the VUSB_DEVICE_STATE_RESET state.
864 * On completion it will be in the VUSB_DEVICE_STATE_DEFAULT state if successful,
865 * or in the VUSB_DEVICE_STATE_DETACHED state if the rest failed.
866 * -- internal stuff, move it --
867 *
868 * @returns VBox status code.
869 * @param pInterface Pointer to this structure.
870 * @param fResetOnLinux Set if we can permit a real reset and a potential logical
871 * device reconnect on linux hosts.
872 * @param pfnDone Pointer to the completion routine. If NULL a synchronous
873 * reset is preformed not respecting the 10ms.
874 * @param pvUser User argument to the completion routine.
875 * @param pVM Pointer to the VM handle if callback in EMT is required. (optional)
876 */
877 DECLR3CALLBACKMEMBER(int, pfnReset,(PVUSBIDEVICE pInterface, bool fResetOnLinux,
878 PFNVUSBRESETDONE pfnDone, void *pvUser, PVM pVM));
879
880 /**
881 * Powers on the device.
882 *
883 * @returns VBox status code.
884 * @param pInterface Pointer to the device interface structure.
885 */
886 DECLR3CALLBACKMEMBER(int, pfnPowerOn,(PVUSBIDEVICE pInterface));
887
888 /**
889 * Powers off the device.
890 *
891 * @returns VBox status code.
892 * @param pInterface Pointer to the device interface structure.
893 */
894 DECLR3CALLBACKMEMBER(int, pfnPowerOff,(PVUSBIDEVICE pInterface));
895
896 /**
897 * Get the state of the device.
898 *
899 * @returns Device state.
900 * @param pInterface Pointer to the device interface structure.
901 */
902 DECLR3CALLBACKMEMBER(VUSBDEVICESTATE, pfnGetState,(PVUSBIDEVICE pInterface));
903
904 /**
905 * Returns whether the device is completely emulated.
906 *
907 * @returns true if the device is fully emulated and doesn't pass through
908 * a host device, false otherwise.
909 * @param pInterface Pointer to the device interface structure.
910 */
911 DECLR3CALLBACKMEMBER(bool, pfnIsEmulated,(PVUSBIDEVICE pInterface));
912
913 /**
914 * Get the speed the device is operating at.
915 *
916 * @returns Device state.
917 * @param pInterface Pointer to the device interface structure.
918 */
919 DECLR3CALLBACKMEMBER(VUSBSPEED, pfnGetSpeed,(PVUSBIDEVICE pInterface));
920
921} VUSBIDEVICE;
922/** VUSBIDEVICE interface ID. */
923#define VUSBIDEVICE_IID "f3facb2b-edd3-4b5b-b07e-2cc4d52a471e"
924
925
926#ifdef IN_RING3
927/**
928 * Resets the device.
929 *
930 * Since a device reset shall take at least 10ms from the guest point of view,
931 * it must be performed asynchronously. We create a thread which performs this
932 * operation and ensures it will take at least 10ms.
933 *
934 * At times - like init - a synchronous reset is required, this can be done
935 * by passing NULL for pfnDone.
936 *
937 * -- internal stuff, move it --
938 * While the device is being reset it is in the VUSB_DEVICE_STATE_RESET state.
939 * On completion it will be in the VUSB_DEVICE_STATE_DEFAULT state if successful,
940 * or in the VUSB_DEVICE_STATE_DETACHED state if the rest failed.
941 * -- internal stuff, move it --
942 *
943 * @returns VBox status code.
944 * @param pInterface Pointer to the device interface structure.
945 * @param fResetOnLinux Set if we can permit a real reset and a potential logical
946 * device reconnect on linux hosts.
947 * @param pfnDone Pointer to the completion routine. If NULL a synchronous
948 * reset is preformed not respecting the 10ms.
949 * @param pvUser User argument to the completion routine.
950 * @param pVM Pointer to the VM handle if callback in EMT is required. (optional)
951 */
952DECLINLINE(int) VUSBIDevReset(PVUSBIDEVICE pInterface, bool fResetOnLinux, PFNVUSBRESETDONE pfnDone, void *pvUser, PVM pVM)
953{
954 return pInterface->pfnReset(pInterface, fResetOnLinux, pfnDone, pvUser, pVM);
955}
956
957/**
958 * Powers on the device.
959 *
960 * @returns VBox status code.
961 * @param pInterface Pointer to the device interface structure.
962 */
963DECLINLINE(int) VUSBIDevPowerOn(PVUSBIDEVICE pInterface)
964{
965 return pInterface->pfnPowerOn(pInterface);
966}
967
968/**
969 * Powers off the device.
970 *
971 * @returns VBox status code.
972 * @param pInterface Pointer to the device interface structure.
973 */
974DECLINLINE(int) VUSBIDevPowerOff(PVUSBIDEVICE pInterface)
975{
976 return pInterface->pfnPowerOff(pInterface);
977}
978
979/**
980 * Get the state of the device.
981 *
982 * @returns Device state.
983 * @param pInterface Pointer to the device interface structure.
984 */
985DECLINLINE(VUSBDEVICESTATE) VUSBIDevGetState(PVUSBIDEVICE pInterface)
986{
987 return pInterface->pfnGetState(pInterface);
988}
989
990/**
991 * Returns whether the device is completely emulated.
992 *
993 * @returns true if the device is fully emulated and doesn't pass through
994 * a host device, false otherwise.
995 * @param pInterface Pointer to the device interface structure.
996 */
997DECLINLINE(bool) VUSBIDevIsEmulated(PVUSBIDEVICE pInterface)
998{
999 return pInterface->pfnIsEmulated(pInterface);
1000}
1001#endif /* IN_RING3 */
1002
1003#endif /* ! RDESKTOP */
1004
1005/** @name URB
1006 * @{ */
1007
1008/**
1009 * VUSB Transfer status codes.
1010 */
1011typedef enum VUSBSTATUS
1012{
1013 /** Transer was ok. */
1014 VUSBSTATUS_OK = 0,
1015 /** Transfer stalled, endpoint halted. */
1016 VUSBSTATUS_STALL,
1017 /** Device not responding. */
1018 VUSBSTATUS_DNR,
1019 /** CRC error. */
1020 VUSBSTATUS_CRC,
1021 /** Data overrun error. */
1022 VUSBSTATUS_DATA_UNDERRUN,
1023 /** Data overrun error. */
1024 VUSBSTATUS_DATA_OVERRUN,
1025 /** The isochronous buffer hasn't been touched. */
1026 VUSBSTATUS_NOT_ACCESSED,
1027 /** Canceled/undone URB (VUSB internal). */
1028 VUSBSTATUS_UNDO,
1029 /** Invalid status. */
1030 VUSBSTATUS_INVALID = 0x7f
1031} VUSBSTATUS;
1032
1033
1034/**
1035 * VUSB Transfer types.
1036 */
1037typedef enum VUSBXFERTYPE
1038{
1039 /** Control message. Used to represent a single control transfer. */
1040 VUSBXFERTYPE_CTRL = 0,
1041 /* Isochronous transfer. */
1042 VUSBXFERTYPE_ISOC,
1043 /** Bulk transfer. */
1044 VUSBXFERTYPE_BULK,
1045 /** Interrupt transfer. */
1046 VUSBXFERTYPE_INTR,
1047 /** Complete control message. Used to represent an entire control message. */
1048 VUSBXFERTYPE_MSG,
1049 /** Invalid transfer type. */
1050 VUSBXFERTYPE_INVALID = 0x7f
1051} VUSBXFERTYPE;
1052
1053
1054/**
1055 * VUSB transfer direction.
1056 */
1057typedef enum VUSBDIRECTION
1058{
1059 /** Setup */
1060 VUSBDIRECTION_SETUP = 0,
1061#define VUSB_DIRECTION_SETUP VUSBDIRECTION_SETUP
1062 /** In - Device to host. */
1063 VUSBDIRECTION_IN = 1,
1064#define VUSB_DIRECTION_IN VUSBDIRECTION_IN
1065 /** Out - Host to device. */
1066 VUSBDIRECTION_OUT = 2,
1067#define VUSB_DIRECTION_OUT VUSBDIRECTION_OUT
1068 /** Invalid direction */
1069 VUSBDIRECTION_INVALID = 0x7f
1070} VUSBDIRECTION;
1071
1072/**
1073 * The URB states
1074 */
1075typedef enum VUSBURBSTATE
1076{
1077 /** The usual invalid state. */
1078 VUSBURBSTATE_INVALID = 0,
1079 /** The URB is free, i.e. not in use.
1080 * Next state: ALLOCATED */
1081 VUSBURBSTATE_FREE,
1082 /** The URB is allocated, i.e. being prepared for submission.
1083 * Next state: FREE, IN_FLIGHT */
1084 VUSBURBSTATE_ALLOCATED,
1085 /** The URB is in flight.
1086 * Next state: REAPED, CANCELLED */
1087 VUSBURBSTATE_IN_FLIGHT,
1088 /** The URB has been reaped and is being completed.
1089 * Next state: FREE */
1090 VUSBURBSTATE_REAPED,
1091 /** The URB has been cancelled and is awaiting reaping and immediate freeing.
1092 * Next state: FREE */
1093 VUSBURBSTATE_CANCELLED,
1094 /** The end of the valid states (exclusive). */
1095 VUSBURBSTATE_END,
1096 /** The usual 32-bit blow up. */
1097 VUSBURBSTATE_32BIT_HACK = 0x7fffffff
1098} VUSBURBSTATE;
1099
1100
1101/**
1102 * Information about a isochronous packet.
1103 */
1104typedef struct VUSBURBISOCPKT
1105{
1106 /** The size of the packet.
1107 * IN: The packet size. I.e. the number of bytes to the next packet or end of buffer.
1108 * OUT: The actual size transferred. */
1109 uint16_t cb;
1110 /** The offset of the packet. (Relative to VUSBURB::abData[0].)
1111 * OUT: This can be changed by the USB device if it does some kind of buffer squeezing. */
1112 uint16_t off;
1113 /** The status of the transfer.
1114 * IN: VUSBSTATUS_INVALID
1115 * OUT: VUSBSTATUS_INVALID if nothing was done, otherwise the correct status. */
1116 VUSBSTATUS enmStatus;
1117} VUSBURBISOCPKT;
1118/** Pointer to a isochronous packet. */
1119typedef VUSBURBISOCPKT *PVUSBURBISOCPTK;
1120/** Pointer to a const isochronous packet. */
1121typedef const VUSBURBISOCPKT *PCVUSBURBISOCPKT;
1122
1123/**
1124 * Asynchronous USB request descriptor
1125 */
1126typedef struct VUSBURB
1127{
1128 /** URB magic value. */
1129 uint32_t u32Magic;
1130 /** The USR state. */
1131 VUSBURBSTATE enmState;
1132 /** URB description, can be null. intended for logging. */
1133 char *pszDesc;
1134
1135#ifdef RDESKTOP
1136 /** The next URB in rdesktop-vrdp's linked list */
1137 PVUSBURB pNext;
1138 /** The previous URB in rdesktop-vrdp's linked list */
1139 PVUSBURB pPrev;
1140 /** The vrdp handle for the URB */
1141 uint32_t handle;
1142 /** Pointer used to find the usb proxy device */
1143 struct VUSBDEV *pDev;
1144#endif
1145
1146 /** The VUSB data. */
1147 struct VUSBURBVUSB
1148 {
1149 /** URB chain pointer. */
1150 PVUSBURB pNext;
1151 /** URB chain pointer. */
1152 PVUSBURB *ppPrev;
1153 /** Pointer to the original for control messages. */
1154 PVUSBURB pCtrlUrb;
1155 /** Pointer to the VUSB device.
1156 * This may be NULL if the destination address is invalid. */
1157 struct VUSBDEV *pDev;
1158 /** Sepcific to the pfnFree function. */
1159 void *pvFreeCtx;
1160 /**
1161 * Callback which will free the URB once it's reaped and completed.
1162 * @param pUrb The URB.
1163 */
1164 DECLCALLBACKMEMBER(void, pfnFree)(PVUSBURB pUrb);
1165 /** Submit timestamp. (logging only) */
1166 uint64_t u64SubmitTS;
1167 /** The allocated data length. */
1168 uint32_t cbDataAllocated;
1169 /** The allocated TD length. */
1170 uint32_t cTdsAllocated;
1171 } VUsb;
1172
1173 /** The host controller data. */
1174 struct VUSBURBHCI
1175 {
1176 /** The endpoint descriptor address. */
1177 RTGCPHYS32 EdAddr;
1178 /** Number of Tds in the array. */
1179 uint32_t cTds;
1180 /** Pointer to an array of TD info items.*/
1181 struct VUSBURBHCITD
1182 {
1183 /** Type of TD (private) */
1184 uint32_t TdType;
1185 /** The address of the */
1186 RTGCPHYS32 TdAddr;
1187 /** A copy of the TD. */
1188 uint32_t TdCopy[16];
1189 } *paTds;
1190 /** URB chain pointer. */
1191 PVUSBURB pNext;
1192 /** When this URB was created.
1193 * (Used for isochronous frames and for logging.) */
1194 uint32_t u32FrameNo;
1195 /** Flag indicating that the TDs have been unlinked. */
1196 bool fUnlinked;
1197 RTQUEUEATOMICITEM QueueItem;
1198 } Hci;
1199
1200 /** The device data. */
1201 struct VUSBURBDEV
1202 {
1203 /** Pointer to private device specific data. */
1204 void *pvPrivate;
1205 /** Used by the device when linking the URB in some list of its own. */
1206 PVUSBURB pNext;
1207 } Dev;
1208
1209#ifndef RDESKTOP
1210 /** The USB device instance this belongs to.
1211 * This is NULL if the device address is invalid, in which case this belongs to the hub. */
1212 PPDMUSBINS pUsbIns;
1213#endif
1214 /** The device address.
1215 * This is set at allocation time. */
1216 uint8_t DstAddress;
1217
1218 /** The endpoint.
1219 * IN: Must be set before submitting the URB.
1220 * @remark This does not have the high bit (direction) set! */
1221 uint8_t EndPt;
1222 /** The transfer type.
1223 * IN: Must be set before submitting the URB. */
1224 VUSBXFERTYPE enmType;
1225 /** The transfer direction.
1226 * IN: Must be set before submitting the URB. */
1227 VUSBDIRECTION enmDir;
1228 /** Indicates whether it is OK to receive/send less data than requested.
1229 * IN: Must be initialized before submitting the URB. */
1230 bool fShortNotOk;
1231 /** The transfer status.
1232 * OUT: This is set when reaping the URB. */
1233 VUSBSTATUS enmStatus;
1234
1235 /** The number of isochronous packets describe in aIsocPkts.
1236 * This is ignored when enmType isn't VUSBXFERTYPE_ISOC. */
1237 uint32_t cIsocPkts;
1238 /** The iso packets within abData.
1239 * This is ignored when enmType isn't VUSBXFERTYPE_ISOC. */
1240 VUSBURBISOCPKT aIsocPkts[8];
1241
1242 /** The message length.
1243 * IN: The amount of data to send / receive - set at allocation time.
1244 * OUT: The amount of data sent / received. */
1245 uint32_t cbData;
1246 /** The message data.
1247 * IN: On host to device transfers, the data to send.
1248 * OUT: On device to host transfers, the data to received.
1249 * This array has actually a size of VUsb.cbDataAllocated, not 8KB! */
1250 uint8_t abData[8*_1K];
1251} VUSBURB;
1252
1253/** The magic value of a valid VUSBURB. (Murakami Haruki) */
1254#define VUSBURB_MAGIC UINT32_C(0x19490112)
1255
1256/** @} */
1257
1258
1259/** @} */
1260
1261RT_C_DECLS_END
1262
1263#endif
注意: 瀏覽 TracBrowser 來幫助您使用儲存庫瀏覽器

© 2025 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette