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