VirtualBox

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

Last change on this file since 59718 was 59718, checked in by vboxsync, 9 years ago

VUSB: Some structural cleanup (#4 Move the URB allocation from the roothub to the devices in order to optionally allocate the URBs by the device itself later on)

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

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