vusb.h revision 7b067f3f07310bff46d1d6a4ac94d8b9bb7ccccd
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** @file
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * VUSB - VirtualBox USB. (DEV,VMM)
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/*
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Copyright (C) 2006-2007 Sun Microsystems, Inc.
c7814cf6e1240a519cbec0441e033d0e2470ed00vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * available from http://www.virtualbox.org. This file is free software;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * you can redistribute it and/or modify it under the terms of the GNU
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * General Public License (GPL) as published by the Free Software
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * The contents of this file may alternatively be used under the terms
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * of the Common Development and Distribution License Version 1.0
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * VirtualBox OSE distribution, in which case the provisions of the
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * CDDL are applicable instead of those of the GPL.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * You may elect to license modified versions of this file under the
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * terms and conditions of either the GPL or the CDDL or both.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Clara, CA 95054 USA or visit http://www.sun.com if you need
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * additional information or have any questions.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#ifndef ___VBox_vusb_h
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define ___VBox_vusb_h
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#include <VBox/cdefs.h>
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#include <VBox/types.h>
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsyncRT_C_DECLS_BEGIN
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** @defgroup grp_vusb VBox USB API
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** @defgroup grp_vusb_std Standard Stuff
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @{ */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Frequency of USB bus (from spec). */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_BUS_HZ 12000000
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** @name USB Descriptor types (from spec)
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @{ */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_DT_DEVICE 0x01
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_DT_CONFIG 0x02
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_DT_STRING 0x03
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_DT_INTERFACE 0x04
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_DT_ENDPOINT 0x05
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_DT_DEVICE_QUALIFIER 0x06
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_DT_OTHER_SPEED_CFG 0x07
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_DT_INTERFACE_POWER 0x08
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** @} */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** @name USB Descriptor minimum sizes (from spec)
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @{ */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_DT_DEVICE_MIN_LEN 18
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_DT_CONFIG_MIN_LEN 9
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_DT_CONFIG_STRING_MIN_LEN 2
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_DT_INTERFACE_MIN_LEN 9
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_DT_ENDPOINT_MIN_LEN 7
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** @} */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#pragma pack(1) /* ensure byte packing of the descriptors. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * USB language id descriptor (from specs).
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBDESCLANGID
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bLength;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bDescriptorType;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync} VUSBDESCLANGID;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a USB language id descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef VUSBDESCLANGID *PVUSBDESCLANGID;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a const USB language id descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef const VUSBDESCLANGID *PCVUSBDESCLANGID;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * USB string descriptor (from specs).
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBDESCSTRING
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bLength;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bDescriptorType;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync} VUSBDESCSTRING;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a USB string descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef VUSBDESCSTRING *PVUSBDESCSTRING;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a const USB string descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef const VUSBDESCSTRING *PCVUSBDESCSTRING;
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * USB device descriptor (from spec)
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBDESCDEVICE
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bLength;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bDescriptorType;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint16_t bcdUSB;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bDeviceClass;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bDeviceSubClass;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bDeviceProtocol;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bMaxPacketSize0;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint16_t idVendor;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint16_t idProduct;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint16_t bcdDevice;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t iManufacturer;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t iProduct;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t iSerialNumber;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bNumConfigurations;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync} VUSBDESCDEVICE;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a USB device descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef VUSBDESCDEVICE *PVUSBDESCDEVICE;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a const USB device descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef const VUSBDESCDEVICE *PCVUSBDESCDEVICE;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * USB configuration descriptor (from spec).
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBDESCCONFIG
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bLength;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bDescriptorType;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint16_t wTotalLength; /**< recalculated by VUSB when involved in URB. */
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync uint8_t bNumInterfaces;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bConfigurationValue;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t iConfiguration;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bmAttributes;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t MaxPower;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync} VUSBDESCCONFIG;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a USB configuration descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef VUSBDESCCONFIG *PVUSBDESCCONFIG;
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync/** Pointer to a readonly USB configuration descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef const VUSBDESCCONFIG *PCVUSBDESCCONFIG;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * USB interface descriptor (from spec)
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBDESCINTERFACE
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync{
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync uint8_t bLength;
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync uint8_t bDescriptorType;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bInterfaceNumber;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bAlternateSetting;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bNumEndpoints;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bInterfaceClass;
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync uint8_t bInterfaceSubClass;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bInterfaceProtocol;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t iInterface;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync} VUSBDESCINTERFACE;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to an USB interface descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef VUSBDESCINTERFACE *PVUSBDESCINTERFACE;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a const USB interface descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef const VUSBDESCINTERFACE *PCVUSBDESCINTERFACE;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * USB endpoint descriptor (from spec)
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBDESCENDPOINT
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bLength;
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync uint8_t bDescriptorType;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bEndpointAddress;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bmAttributes;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint16_t wMaxPacketSize;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bInterval;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync} VUSBDESCENDPOINT;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to an USB endpoint descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef VUSBDESCENDPOINT *PVUSBDESCENDPOINT;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a const USB endpoint descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef const VUSBDESCENDPOINT *PCVUSBDESCENDPOINT;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#pragma pack() /* end of the byte packing. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * USB configuration descriptor, the parsed variant used by VUSB.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBDESCCONFIGEX
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /** The USB descriptor data.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @remark The wTotalLength member is recalculated before the data is passed to the guest. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync VUSBDESCCONFIG Core;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /** Pointer to additional descriptor bytes following what's covered by VUSBDESCCONFIG. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync void *pvMore;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /** Pointer to an array of the interfaces referenced in the configuration.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Core.bNumInterfaces in size. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync const struct VUSBINTERFACE *iface;
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync} VUSBDESCCONFIGEX;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a parsed USB configuration descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef VUSBDESCCONFIGEX *PVUSBDESCCONFIGEX;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a const parsed USB configuration descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef const VUSBDESCCONFIGEX *PCVUSBDESCCONFIGEX;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * For tracking the alternate interface settings of a configuration.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBINTERFACE
9cba9a10f12ba5184ad5d2a3ce05b0caba8d09favboxsync{
9cba9a10f12ba5184ad5d2a3ce05b0caba8d09favboxsync /** Pointer to an array of interfaces. */
9cba9a10f12ba5184ad5d2a3ce05b0caba8d09favboxsync const struct VUSBDESCINTERFACEEX *setting;
9cba9a10f12ba5184ad5d2a3ce05b0caba8d09favboxsync /** The number of entries in the array. */
9cba9a10f12ba5184ad5d2a3ce05b0caba8d09favboxsync unsigned int num_settings;
9cba9a10f12ba5184ad5d2a3ce05b0caba8d09favboxsync} VUSBINTERFACE;
9cba9a10f12ba5184ad5d2a3ce05b0caba8d09favboxsync/** Pointer to a VUSBINTERFACE. */
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsynctypedef VUSBINTERFACE *PVUSBINTERFACE;
9cba9a10f12ba5184ad5d2a3ce05b0caba8d09favboxsync/** Pointer to a const VUSBINTERFACE. */
9cba9a10f12ba5184ad5d2a3ce05b0caba8d09favboxsynctypedef const VUSBINTERFACE *PCVUSBINTERFACE;
9cba9a10f12ba5184ad5d2a3ce05b0caba8d09favboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * USB interface descriptor, the parsed variant used by VUSB.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBDESCINTERFACEEX
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /** The USB descriptor data. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync VUSBDESCINTERFACE Core;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /** Pointer to additional descriptor bytes following what's covered by VUSBDESCINTERFACE. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync void *pvMore;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /** Pointer to an array of the endpoints referenced by the interface.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Core.bNumEndpoints in size. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync const struct VUSBDESCENDPOINTEX *endpoint;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync} VUSBDESCINTERFACEEX;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to an prased USB interface descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef VUSBDESCINTERFACEEX *PVUSBDESCINTERFACEEX;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a const parsed USB interface descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef const VUSBDESCINTERFACEEX *PCVUSBDESCINTERFACEEX;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * USB endpoint descriptor, the parsed variant used by VUSB.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBDESCENDPOINTEX
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /** The USB descriptor data.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @remark The wMaxPacketSize member is converted to native endian. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync VUSBDESCENDPOINT Core;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /** Pointer to additional descriptor bytes following what's covered by VUSBDESCENDPOINT. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync void *pvMore;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync} VUSBDESCENDPOINTEX;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a parsed USB endpoint descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef VUSBDESCENDPOINTEX *PVUSBDESCENDPOINTEX;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a const parsed USB endpoint descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef const VUSBDESCENDPOINTEX *PCVUSBDESCENDPOINTEX;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** @name USB Control message recipient codes (from spec)
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync * @{ */
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_TO_DEVICE 0x0
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_TO_INTERFACE 0x1
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_TO_ENDPOINT 0x2
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_TO_OTHER 0x3
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_RECIP_MASK 0x1f
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** @} */
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync/** @name USB control pipe setup packet structure (from spec)
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync * @{ */
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_SHIFT (5)
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_STANDARD (0x0 << VUSB_REQ_SHIFT)
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_CLASS (0x1 << VUSB_REQ_SHIFT)
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_VENDOR (0x2 << VUSB_REQ_SHIFT)
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_RESERVED (0x3 << VUSB_REQ_SHIFT)
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_MASK (0x3 << VUSB_REQ_SHIFT)
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync/** @} */
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_DIR_TO_DEVICE 0x00
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_DIR_TO_HOST 0x80
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_DIR_MASK 0x80
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * USB Setup request (from spec)
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct vusb_setup
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bmRequestType;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint8_t bRequest;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint16_t wValue;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint16_t wIndex;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync uint16_t wLength;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync} VUSBSETUP;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a setup request. */
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsynctypedef VUSBSETUP *PVUSBSETUP;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a const setup request. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef const VUSBSETUP *PCVUSBSETUP;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync/** @name USB Standard device requests (from spec)
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync * @{ */
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_GET_STATUS 0x00
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_CLEAR_FEATURE 0x01
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_SET_FEATURE 0x03
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_SET_ADDRESS 0x05
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_GET_DESCRIPTOR 0x06
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_SET_DESCRIPTOR 0x07
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_GET_CONFIGURATION 0x08
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_SET_CONFIGURATION 0x09
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_GET_INTERFACE 0x0a
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_SET_INTERFACE 0x0b
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_SYNCH_FRAME 0x0c
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync#define VUSB_REQ_MAX 0x0d
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** @} */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** @} */ /* end of grp_vusb_std */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** @name USB Standard version flags.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @{ */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Indicates USB 1.1 support. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_STDVER_11 RT_BIT(1)
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Indicates USB 2.0 support. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#define VUSB_STDVER_20 RT_BIT(2)
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** @} */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a VBox USB device interface. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBIDEVICE *PVUSBIDEVICE;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a VUSB RootHub port interface. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBIROOTHUBPORT *PVUSBIROOTHUBPORT;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to an USB request descriptor. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBURB *PVUSBURB;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * VBox USB port bitmap.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Bit 0 == Port 0, ... , Bit 127 == Port 127.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBPORTBITMAP
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /** 128 bits */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync char ach[16];
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync} VUSBPORTBITMAP;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a VBox USB port bitmap. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef VUSBPORTBITMAP *PVUSBPORTBITMAP;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * The VUSB RootHub port interface provided by the HCI.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBIROOTHUBPORT
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Get the number of avilable ports in the hub.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @returns The number of ports available.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pInterface Pointer to this structure.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pAvailable Bitmap indicating the available ports. Set bit == available port.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync DECLR3CALLBACKMEMBER(unsigned, pfnGetAvailablePorts,(PVUSBIROOTHUBPORT pInterface, PVUSBPORTBITMAP pAvailable));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync /**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Gets the supported USB versions.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @returns The mask of supported USB versions.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pInterface Pointer to this structure.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync DECLR3CALLBACKMEMBER(uint32_t, pfnGetUSBVersions,(PVUSBIROOTHUBPORT pInterface));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * A device is being attached to a port in the roothub.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pInterface Pointer to this structure.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pDev Pointer to the device being attached.
7f581f9444a4d569475da724d7fde45b9a225899vboxsync * @param uPort The port number assigned to the device.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync DECLR3CALLBACKMEMBER(int, pfnAttach,(PVUSBIROOTHUBPORT pInterface, PVUSBIDEVICE pDev, unsigned uPort));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * A device is being detached from a port in the roothub.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pInterface Pointer to this structure.
7f581f9444a4d569475da724d7fde45b9a225899vboxsync * @param pDev Pointer to the device being detached.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param uPort The port number assigned to the device.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync DECLR3CALLBACKMEMBER(void, pfnDetach,(PVUSBIROOTHUBPORT pInterface, PVUSBIDEVICE pDev, unsigned uPort));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Reset the root hub.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @returns VBox status code.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pInterface Pointer to this structure.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pResetOnLinux Whether or not to do real reset on linux.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync DECLR3CALLBACKMEMBER(int, pfnReset,(PVUSBIROOTHUBPORT pInterface, bool fResetOnLinux));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Transfer completion callback routine.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * VUSB will call this when a transfer have been completed
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * in a one or another way.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pInterface Pointer to this structure.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pUrb Pointer to the URB in question.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync DECLR3CALLBACKMEMBER(void, pfnXferCompletion,(PVUSBIROOTHUBPORT pInterface, PVUSBURB urb));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Handle transfer errors.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * VUSB calls this when a transfer attempt failed. This function will respond
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * indicating wheter to retry or complete the URB with failure.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @returns Retry indicator.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pInterface Pointer to this structure.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pUrb Pointer to the URB in question.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync DECLR3CALLBACKMEMBER(bool, pfnXferError,(PVUSBIROOTHUBPORT pInterface, PVUSBURB pUrb));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /** Alignment dummy. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync RTR3PTR Alignment;
7f581f9444a4d569475da724d7fde45b9a225899vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync} VUSBIROOTHUBPORT;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a VUSB RootHub connector interface. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBIROOTHUBCONNECTOR *PVUSBIROOTHUBCONNECTOR;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * The VUSB RootHub connector interface provided by the VBox USB RootHub driver.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBIROOTHUBCONNECTOR
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Allocates a new URB for a transfer.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Either submit using pfnSubmitUrb or free using VUSBUrbFree().
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @returns Pointer to a new URB.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @returns NULL on failure - try again later.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * This will not fail if the device wasn't found. We'll fail it
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * at submit time, since that makes the usage of this api simpler.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pInterface Pointer to this struct.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param DstAddress The destination address of the URB.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param cbData The amount of data space required.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param cTds The amount of TD space.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
b65d53aa41a5d4f584a5ae6833c741dad0a4da43vboxsync DECLR3CALLBACKMEMBER(PVUSBURB, pfnNewUrb,(PVUSBIROOTHUBCONNECTOR pInterface, uint8_t DstAddress, uint32_t cbData, uint32_t cTds));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Submits a URB for transfer.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * The transfer will do asynchronously if possible.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @returns VBox status code.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pInterface Pointer to this struct.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pUrb Pointer to the URB returned by pfnNewUrb.
7f581f9444a4d569475da724d7fde45b9a225899vboxsync * The URB will be freed in case of failure.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pLed Pointer to USB Status LED
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync DECLR3CALLBACKMEMBER(int, pfnSubmitUrb,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb, struct PDMLED *pLed));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Call to service asynchronous URB completions in a polling fashion.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Reaped URBs will be finished by calling the completion callback,
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * thus there is no return code or input or anything from this function
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * except for potential state changes elsewhere.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @returns VINF_SUCCESS if no URBs are pending upon return.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @returns VERR_TIMEOUT if one or more URBs are still in flight upon returning.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @returns Other VBox status code.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pInterface Pointer to this struct.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param cMillies Number of milliseconds to poll for completion.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync DECLR3CALLBACKMEMBER(void, pfnReapAsyncUrbs,(PVUSBIROOTHUBCONNECTOR pInterface, RTMSINTERVAL cMillies));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Cancels and completes - with CRC failure - all in-flight async URBs.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * This is typically done before saving a state.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pInterface Pointer to this struct.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync DECLR3CALLBACKMEMBER(void, pfnCancelAllUrbs,(PVUSBIROOTHUBCONNECTOR pInterface));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
7f581f9444a4d569475da724d7fde45b9a225899vboxsync * Attach the device to the root hub.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * The device must not be attached to any hub for this call to succeed.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @returns VBox status code.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pInterface Pointer to this struct.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pDevice Pointer to the device (interface) attach.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync DECLR3CALLBACKMEMBER(int, pfnAttachDevice,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Detach the device from the root hub.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * The device must already be attached for this call to succeed.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @returns VBox status code.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pInterface Pointer to this struct.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pDevice Pointer to the device (interface) to detach.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync DECLR3CALLBACKMEMBER(int, pfnDetachDevice,(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync} VUSBIROOTHUBCONNECTOR;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#ifdef IN_RING3
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** @copydoc VUSBIROOTHUBCONNECTOR::pfnNewUrb */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsyncDECLINLINE(PVUSBURB) VUSBIRhNewUrb(PVUSBIROOTHUBCONNECTOR pInterface, uint32_t DstAddress, uint32_t cbData, uint32_t cTds)
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync return pInterface->pfnNewUrb(pInterface, DstAddress, cbData, cTds);
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync}
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync/** @copydoc VUSBIROOTHUBCONNECTOR::pfnSubmitUrb */
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsyncDECLINLINE(int) VUSBIRhSubmitUrb(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBURB pUrb, struct PDMLED *pLed)
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync{
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync return pInterface->pfnSubmitUrb(pInterface, pUrb, pLed);
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync}
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync/** @copydoc VUSBIROOTHUBCONNECTOR::pfnReapAsyncUrbs */
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsyncDECLINLINE(void) VUSBIRhReapAsyncUrbs(PVUSBIROOTHUBCONNECTOR pInterface, RTMSINTERVAL cMillies)
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync{
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync pInterface->pfnReapAsyncUrbs(pInterface, cMillies);
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync}
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync/** @copydoc VUSBIROOTHUBCONNECTOR::pfnCancelAllUrbs */
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsyncDECLINLINE(void) VUSBIRhCancelAllUrbs(PVUSBIROOTHUBCONNECTOR pInterface)
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync{
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync pInterface->pfnCancelAllUrbs(pInterface);
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync}
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync/** @copydoc VUSBIROOTHUBCONNECTOR::pfnAttachDevice */
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsyncDECLINLINE(int) VUSBIRhAttachDevice(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice)
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync{
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync return pInterface->pfnAttachDevice(pInterface, pDevice);
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync}
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync/** @copydoc VUSBIROOTHUBCONNECTOR::pfnDetachDevice */
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsyncDECLINLINE(int) VUSBIRhDetachDevice(PVUSBIROOTHUBCONNECTOR pInterface, PVUSBIDEVICE pDevice)
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync{
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync return pInterface->pfnDetachDevice(pInterface, pDevice);
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync}
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#endif /* IN_RING3 */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a Root Hub Configuration Interface. */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBIRHCONFIG *PVUSBIRHCONFIG;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Root Hub Configuration Interface (intended for MAIN).
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBIRHCONFIG
d6e0f6a5d8642c681e6d12d43fc0069da7a5dff6vboxsync{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Creates a USB proxy device and attaches it to the root hub.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @returns VBox status code.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pInterface Pointer to the root hub configuration interface structure.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pUuid Pointer to the UUID for the new device.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param fRemote Whether the device must use the VRDP backend.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pszAddress OS specific device address.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pvBackend An opaque pointer for the backend. Only used by
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * the VRDP backend so far.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
d6e0f6a5d8642c681e6d12d43fc0069da7a5dff6vboxsync DECLR3CALLBACKMEMBER(int, pfnCreateProxyDevice,(PVUSBIRHCONFIG pInterface, PCRTUUID pUuid, bool fRemote, const char *pszAddress, void *pvBackend));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Removes a USB proxy device from the root hub and destroys it.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @returns VBox status code.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pInterface Pointer to the root hub configuration interface structure.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pUuid Pointer to the UUID for the device.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync DECLR3CALLBACKMEMBER(int, pfnDestroyProxyDevice,(PVUSBIRHCONFIG pInterface, PCRTUUID pUuid));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync} VUSBIRHCONFIG;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#ifdef IN_RING3
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** @copydoc VUSBIRHCONFIG::pfnCreateProxyDevice */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsyncDECLINLINE(int) VUSBIRhCreateProxyDevice(PVUSBIRHCONFIG pInterface, PCRTUUID pUuid, bool fRemote, const char *pszAddress, void *pvBackend)
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync return pInterface->pfnCreateProxyDevice(pInterface, pUuid, fRemote, pszAddress, pvBackend);
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync}
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** @copydoc VUSBIRHCONFIG::pfnDestroyProxyDevice */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsyncDECLINLINE(int) VUSBIRhDestroyProxyDevice(PVUSBIRHCONFIG pInterface, PCRTUUID pUuid)
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync return pInterface->pfnDestroyProxyDevice(pInterface, pUuid);
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync}
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#endif /* IN_RING3 */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * VUSB device reset completion callback function.
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync * This is called by the reset thread when the reset has been completed.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pDev Pointer to the virtual USB device core.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param rc The VBox status code of the reset operation.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pvUser User specific argument.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @thread The reset thread or EMT.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef DECLCALLBACK(void) FNVUSBRESETDONE(PVUSBIDEVICE pDevice, int rc, void *pvUser);
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/** Pointer to a device reset completion callback function (FNUSBRESETDONE). */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef FNVUSBRESETDONE *PFNVUSBRESETDONE;
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * The state of a VUSB Device.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @remark The order of these states is vital.
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync */
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsynctypedef enum VUSBDEVICESTATE
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync{
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync VUSB_DEVICE_STATE_INVALID = 0,
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync VUSB_DEVICE_STATE_DETACHED,
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync VUSB_DEVICE_STATE_ATTACHED,
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync VUSB_DEVICE_STATE_POWERED,
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync VUSB_DEVICE_STATE_DEFAULT,
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync VUSB_DEVICE_STATE_ADDRESS,
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync VUSB_DEVICE_STATE_CONFIGURED,
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync VUSB_DEVICE_STATE_SUSPENDED,
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync /** The device is being reset. Don't mess with it.
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync * Next states: VUSB_DEVICE_STATE_DEFAULT, VUSB_DEVICE_STATE_DESTROYED
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync */
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync VUSB_DEVICE_STATE_RESET,
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync /** The device has been destroy. */
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync VUSB_DEVICE_STATE_DESTROYED,
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /** The usual 32-bit hack. */
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync VUSB_DEVICE_STATE_32BIT_HACK = 0x7fffffff
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync} VUSBDEVICESTATE;
938e0729a8e58abec28ef5e9cdb7bf1fabac6b58vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
133ac536a3d32062cf6b4c076da39da9e80f91a5vboxsync/**
133ac536a3d32062cf6b4c076da39da9e80f91a5vboxsync * USB Device Interface.
133ac536a3d32062cf6b4c076da39da9e80f91a5vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsynctypedef struct VUSBIDEVICE
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync{
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
133ac536a3d32062cf6b4c076da39da9e80f91a5vboxsync * Resets the device.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Since a device reset shall take at least 10ms from the guest point of view,
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * it must be performed asynchronously. We create a thread which performs this
133ac536a3d32062cf6b4c076da39da9e80f91a5vboxsync * operation and ensures it will take at least 10ms.
133ac536a3d32062cf6b4c076da39da9e80f91a5vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * At times - like init - a synchronous reset is required, this can be done
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * by passing NULL for pfnDone.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * -- internal stuff, move it --
133ac536a3d32062cf6b4c076da39da9e80f91a5vboxsync * While the device is being reset it is in the VUSB_DEVICE_STATE_RESET state.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * On completion it will be in the VUSB_DEVICE_STATE_DEFAULT state if successful,
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * or in the VUSB_DEVICE_STATE_DETACHED state if the rest failed.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * -- internal stuff, move it --
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @returns VBox status code.
133ac536a3d32062cf6b4c076da39da9e80f91a5vboxsync * @param pInterface Pointer to this structure.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param fResetOnLinux Set if we can permit a real reset and a potential logical
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * device reconnect on linux hosts.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pfnDone Pointer to the completion routine. If NULL a synchronous
133ac536a3d32062cf6b4c076da39da9e80f91a5vboxsync * reset is preformed not respecting the 10ms.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pvUser User argument to the completion routine.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pVM Pointer to the VM handle if callback in EMT is required. (optional)
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
133ac536a3d32062cf6b4c076da39da9e80f91a5vboxsync DECLR3CALLBACKMEMBER(int, pfnReset,(PVUSBIDEVICE pInterface, bool fResetOnLinux,
133ac536a3d32062cf6b4c076da39da9e80f91a5vboxsync PFNVUSBRESETDONE pfnDone, void *pvUser, PVM pVM));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Powers on the device.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
133ac536a3d32062cf6b4c076da39da9e80f91a5vboxsync * @returns VBox status code.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @param pInterface Pointer to the device interface structure.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync DECLR3CALLBACKMEMBER(int, pfnPowerOn,(PVUSBIDEVICE pInterface));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Powers off the device.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @returns VBox status code.
230bd8589bba39933ac5ec21482d6186d675e604vboxsync * @param pInterface Pointer to the device interface structure.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync DECLR3CALLBACKMEMBER(int, pfnPowerOff,(PVUSBIDEVICE pInterface));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync /**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Get the state of the device.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * @returns Device state.
b65d53aa41a5d4f584a5ae6833c741dad0a4da43vboxsync * @param pInterface Pointer to the device interface structure.
b65d53aa41a5d4f584a5ae6833c741dad0a4da43vboxsync */
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync DECLR3CALLBACKMEMBER(VUSBDEVICESTATE, pfnGetState,(PVUSBIDEVICE pInterface));
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync} VUSBIDEVICE;
b6415accd33648174afbfd16edc4dc0f894a6bf2vboxsync
d6e0f6a5d8642c681e6d12d43fc0069da7a5dff6vboxsync
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync#ifdef IN_RING3
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync/**
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync * Resets the device.
dab2041a9c063e43814b7b69538c2856cd78bd18vboxsync *
* Since a device reset shall take at least 10ms from the guest point of view,
* it must be performed asynchronously. We create a thread which performs this
* operation and ensures it will take at least 10ms.
*
* At times - like init - a synchronous reset is required, this can be done
* by passing NULL for pfnDone.
*
* -- internal stuff, move it --
* While the device is being reset it is in the VUSB_DEVICE_STATE_RESET state.
* On completion it will be in the VUSB_DEVICE_STATE_DEFAULT state if successful,
* or in the VUSB_DEVICE_STATE_DETACHED state if the rest failed.
* -- internal stuff, move it --
*
* @returns VBox status code.
* @param pInterface Pointer to the device interface structure.
* @param fResetOnLinux Set if we can permit a real reset and a potential logical
* device reconnect on linux hosts.
* @param pfnDone Pointer to the completion routine. If NULL a synchronous
* reset is preformed not respecting the 10ms.
* @param pvUser User argument to the completion routine.
* @param pVM Pointer to the VM handle if callback in EMT is required. (optional)
*/
DECLINLINE(int) VUSBIDevReset(PVUSBIDEVICE pInterface, bool fResetOnLinux, PFNVUSBRESETDONE pfnDone, void *pvUser, PVM pVM)
{
return pInterface->pfnReset(pInterface, fResetOnLinux, pfnDone, pvUser, pVM);
}
/**
* Powers on the device.
*
* @returns VBox status code.
* @param pInterface Pointer to the device interface structure.
*/
DECLINLINE(int) VUSBIDevPowerOn(PVUSBIDEVICE pInterface)
{
return pInterface->pfnPowerOn(pInterface);
}
/**
* Powers off the device.
*
* @returns VBox status code.
* @param pInterface Pointer to the device interface structure.
*/
DECLINLINE(int) VUSBIDevPowerOff(PVUSBIDEVICE pInterface)
{
return pInterface->pfnPowerOff(pInterface);
}
/**
* Get the state of the device.
*
* @returns Device state.
* @param pInterface Pointer to the device interface structure.
*/
DECLINLINE(VUSBDEVICESTATE) VUSBIDevGetState(PVUSBIDEVICE pInterface)
{
return pInterface->pfnGetState(pInterface);
}
#endif /* IN_RING3 */
/** @name URB
* @{ */
/**
* VUSB Transfer status codes.
*/
typedef enum VUSBSTATUS
{
/** Transer was ok. */
VUSBSTATUS_OK = 0,
/** Transfer stalled, endpoint halted. */
VUSBSTATUS_STALL,
/** Device not responding. */
VUSBSTATUS_DNR,
/** CRC error. */
VUSBSTATUS_CRC,
/** Data overrun error. */
VUSBSTATUS_DATA_UNDERRUN,
/** Data overrun error. */
VUSBSTATUS_DATA_OVERRUN,
/** The isochronous buffer hasn't been touched. */
VUSBSTATUS_NOT_ACCESSED,
/** Invalid status. */
VUSBSTATUS_INVALID = 0x7f
} VUSBSTATUS;
/**
* VUSB Transfer types.
*/
typedef enum VUSBXFERTYPE
{
/** Control message. Used to represent a single control transfer. */
VUSBXFERTYPE_CTRL = 0,
/* Isochronous transfer. */
VUSBXFERTYPE_ISOC,
/** Bulk transfer. */
VUSBXFERTYPE_BULK,
/** Interrupt transfer. */
VUSBXFERTYPE_INTR,
/** Complete control message. Used to represent an entire control message. */
VUSBXFERTYPE_MSG,
/** Invalid transfer type. */
VUSBXFERTYPE_INVALID = 0x7f
} VUSBXFERTYPE;
/**
* VUSB transfer direction.
*/
typedef enum VUSBDIRECTION
{
/** Setup */
VUSBDIRECTION_SETUP = 0,
#define VUSB_DIRECTION_SETUP VUSBDIRECTION_SETUP
/** In - Device to host. */
VUSBDIRECTION_IN = 1,
#define VUSB_DIRECTION_IN VUSBDIRECTION_IN
/** Out - Host to device. */
VUSBDIRECTION_OUT = 2,
#define VUSB_DIRECTION_OUT VUSBDIRECTION_OUT
/** Invalid direction */
VUSBDIRECTION_INVALID = 0x7f
} VUSBDIRECTION;
/**
* The URB states
*/
typedef enum VUSBURBSTATE
{
/** The usual invalid state. */
VUSBURBSTATE_INVALID = 0,
/** The URB is free, i.e. not in use.
* Next state: ALLOCATED */
VUSBURBSTATE_FREE,
/** The URB is allocated, i.e. being prepared for submission.
* Next state: FREE, IN_FLIGHT */
VUSBURBSTATE_ALLOCATED,
/** The URB is in flight.
* Next state: REAPED, CANCELLED */
VUSBURBSTATE_IN_FLIGHT,
/** The URB has been reaped and is being completed.
* Next state: FREE */
VUSBURBSTATE_REAPED,
/** The URB has been cancelled and is awaiting reaping and immediate freeing.
* Next state: FREE */
VUSBURBSTATE_CANCELLED,
/** The end of the valid states (exclusive). */
VUSBURBSTATE_END,
/** The usual 32-bit blow up. */
VUSBURBSTATE_32BIT_HACK = 0x7fffffff
} VUSBURBSTATE;
/**
* Information about a isochronous packet.
*/
typedef struct VUSBURBISOCPKT
{
/** The size of the packet.
* IN: The packet size. I.e. the number of bytes to the next packet or end of buffer.
* OUT: The actual size transfered. */
uint16_t cb;
/** The offset of the packet. (Relative to VUSBURB::abData[0].)
* OUT: This can be changed by the USB device if it does some kind of buffer squeezing. */
uint16_t off;
/** The status of the transfer.
* IN: VUSBSTATUS_INVALID
* OUT: VUSBSTATUS_INVALID if nothing was done, otherwise the correct status. */
VUSBSTATUS enmStatus;
} VUSBURBISOCPKT;
/** Pointer to a isochronous packet. */
typedef VUSBURBISOCPKT *PVUSBURBISOCPTK;
/** Pointer to a const isochronous packet. */
typedef const VUSBURBISOCPKT *PCVUSBURBISOCPKT;
/**
* Asynchronous USB request descriptor
*/
typedef struct VUSBURB
{
/** URB magic value. */
uint32_t u32Magic;
/** The USR state. */
VUSBURBSTATE enmState;
/** URB description, can be null. intended for logging. */
char *pszDesc;
/** The VUSB data. */
struct VUSBURBVUSB
{
/** URB chain pointer. */
PVUSBURB pNext;
/** URB chain pointer. */
PVUSBURB *ppPrev;
/** Pointer to the original for control messages. */
PVUSBURB pCtrlUrb;
/** Pointer to the VUSB device.
* This may be NULL if the destination address is invalid. */
struct VUSBDEV *pDev;
/** Sepcific to the pfnFree function. */
void *pvFreeCtx;
/**
* Callback which will free the URB once it's reaped and completed.
* @param pUrb The URB.
*/
DECLCALLBACKMEMBER(void, pfnFree)(PVUSBURB pUrb);
/** Submit timestamp. (logging only) */
uint64_t u64SubmitTS;
/** The allocated data length. */
uint32_t cbDataAllocated;
/** The allocated TD length. */
uint32_t cTdsAllocated;
} VUsb;
/** The host controller data. */
struct VUSBURBHCI
{
/** The endpoint descriptor address. */
RTGCPHYS32 EdAddr;
/** Number of Tds in the array. */
uint32_t cTds;
/** Pointer to an array of TD info items.*/
struct VUSBURBHCITD
{
/** Type of TD (private) */
uint32_t TdType;
/** The address of the */
RTGCPHYS32 TdAddr;
/** A copy of the TD. */
uint32_t TdCopy[16];
} *paTds;
/** URB chain pointer. */
PVUSBURB pNext;
/** When this URB was created.
* (Used for isochronous frames and for logging.) */
uint32_t u32FrameNo;
/** Flag indicating that the TDs have been unlinked. */
bool fUnlinked;
} Hci;
/** The device data. */
struct VUSBURBDEV
{
/** Pointer to the proxy URB. */
void *pvProxyUrb;
} Dev;
/** The USB device instance this belongs to.
* This is NULL if the device address is invalid, in which case this belongs to the hub. */
PPDMUSBINS pUsbIns;
/** The device address.
* This is set at allocation time. */
uint8_t DstAddress;
/** The endpoint.
* IN: Must be set before submitting the URB.
* @remark This does not have the high bit (direction) set! */
uint8_t EndPt;
/** The transfer type.
* IN: Must be set before submitting the URB. */
VUSBXFERTYPE enmType;
/** The transfer direction.
* IN: Must be set before submitting the URB. */
VUSBDIRECTION enmDir;
/** Indicates whether it is OK to receive/send less data than requested.
* IN: Must be initialized before submitting the URB. */
bool fShortNotOk;
/** The transfer status.
* OUT: This is set when reaping the URB. */
VUSBSTATUS enmStatus;
/** The number of isochronous packets describe in aIsocPkts.
* This is ignored when enmType isn't VUSBXFERTYPE_ISOC. */
uint32_t cIsocPkts;
/** The iso packets within abData.
* This is ignored when enmType isn't VUSBXFERTYPE_ISOC. */
VUSBURBISOCPKT aIsocPkts[8];
/** The message length.
* IN: The amount of data to send / receive - set at allocation time.
* OUT: The amount of data sent / received. */
uint32_t cbData;
/** The message data.
* IN: On host to device transfers, the data to send.
* OUT: On device to host transfers, the data to received. */
uint8_t abData[8*_1K];
} VUSBURB;
/** The magic value of a valid VUSBURB. (Murakami Haruki) */
#define VUSBURB_MAGIC 0x19490112
/** @} */
/** @} */
RT_C_DECLS_END
#endif