usb.h revision 06642a40c2b51f038e46bb1ded79cbb35b89b4b0
/** @file
* USB - Universal Serial Bus.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#ifndef ___VBox_usb_h
#define ___VBox_usb_h
#ifdef USBDEVICE_WITH_EVERYTHING
/**
* USB device interface endpoint.
*/
typedef struct USBENDPOINT
{
/** The address of the endpoint on the USB device described by this descriptor. */
/** This field describes the endpoint's attributes when it is configured using the bConfigurationValue. */
/** Maximum packet size this endpoint is capable of sending or receiving when this configuration is selected. */
/** Interval for polling endpoint for data transfers. Expressed in milliseconds.
* This is interpreted the bInterval value. */
} USBENDPOINT;
/** Pointer to a USB device interface endpoint. */
typedef USBENDPOINT *PUSBENDPOINT;
/** Pointer to a const USB device interface endpoint. */
typedef const USBENDPOINT *PCUSBENDPOINT;
/** USBENDPOINT::bmAttributes values.
* @{ */
#define USB_EP_ATTR_CONTROL 0
#define USB_EP_ATTR_ISOCHRONOUS 1
#define USB_EP_ATTR_BULK 2
#define USB_EP_ATTR_INTERRUPT 3
/** @} */
/**
* USB device interface.
*/
typedef struct USBINTERFACE
{
/** Number of interface. */
/** Value used to select alternate setting for the interface identified in the prior field. */
/** Number of endpoints used by this interface (excluding endpoint zero). */
/** Pointer to an array of endpoints. */
/** Interface class. */
/** Interface subclass. */
/** Protocol code. */
/** Number of alternate settings. */
/** Pointer to an array of alternate interface settings. */
struct USBINTERFACE *paAlts;
/** String describing this interface. */
const char *pszInterface;
/** String containing the driver name.
* This is a NULL pointer if the interface is not in use. */
const char *pszDriver;
} USBINTERFACE;
/** Pointer to a USB device interface description. */
typedef USBINTERFACE *PUSBINTERFACE;
/** Pointer to a const USB device interface description. */
typedef const USBINTERFACE *PCUSBINTERFACE;
/**
* Device configuration.
*/
typedef struct USBCONFIG
{
/** Set if this is the active configuration. */
bool fActive;
/** Number of interfaces. */
/** Pointer to an array of interfaces. */
/** Configuration number. (For SetConfiguration().) */
/** Configuration description string. */
const char *pszConfiguration;
/** Configuration characteristics. */
/** Maximum power consumption of the USB device in this config.
* (This field does NOT need shifting like in the USB config descriptor.) */
} USBCONFIG;
/** Pointer to a USB configuration. */
typedef USBCONFIG *PUSBCONFIG;
/** Pointer to a const USB configuration. */
typedef const USBCONFIG *PCUSBCONFIG;
#endif /* USBDEVICE_WITH_EVERYTHING */
/**
* The USB host device state.
*/
typedef enum USBDEVICESTATE
{
/** The device is unsupported. */
/** The device is in use by the host. */
/** The device is in use by the host but could perhaps be captured even so. */
/** The device is not used by the host or any guest. */
/** The device is held by the proxy for later guest usage. */
/** The device in use by a guest. */
/** The usual 32-bit hack. */
USBDEVICESTATE_32BIT_HACK = 0x7fffffff
/**
* The USB device speed.
*/
typedef enum USBDEVICESPEED
{
/** Unknown. */
/** Low speed (1.5 Mbit/s). */
/** Full speed (12 Mbit/s). */
/** High speed (480 Mbit/s). */
/** Variable speed - USB 2.5 / wireless. */
/** The usual 32-bit hack. */
USBDEVICESPEED_32BIT_HACK = 0x7fffffff
/**
* USB host device description.
* Used for enumeration of USB devices.
*/
typedef struct USBDEVICE
{
/** If linked, this is the pointer to the next device in the list. */
/** If linked doubly, this is the pointer to the prev device in the list. */
/** Manufacturer string. */
const char *pszManufacturer;
/** Product string. */
const char *pszProduct;
/** Serial number string. */
const char *pszSerialNumber;
/** The address of the device. */
const char *pszAddress;
/** Vendor ID. */
/** Product ID. */
/** Revision, integer part. */
/** USB version number. */
/** Device class. */
/** Device subclass. */
/** Device protocol */
/** Number of configurations. */
/** The device state. */
/** The device speed. */
/** Serial hash. */
/** The USB Bus number. */
/** The port number. */
#if defined(RT_OS_LINUX)
/** Device number. */
#endif
#ifdef USBDEVICE_WITH_EVERYTHING
/** Parent device number. */
/** The level in topologly for this bus. */
/** Number of devices on this level. */
/** Maximum number of children. */
/** Pointer to an array of configurations. */
#endif
} USBDEVICE;
/** Pointer to a USB device. */
typedef USBDEVICE *PUSBDEVICE;
/** Pointer to a const USB device. */
typedef USBDEVICE *PCUSBDEVICE;
#ifdef VBOX_USB_H_INCL_DESCRIPTORS /* for the time being, since this may easily conflict with system headers */
/**
* USB device descriptor.
*/
#pragma pack(1)
typedef struct USBDESCHDR
{
/** The descriptor length. */
/** The descriptor type. */
} USBDESCHDR;
#pragma pack()
/** Pointer to an USB descriptor header. */
typedef USBDESCHDR *PUSBDESCHDR;
/** @name Descriptor Type values (bDescriptorType)
* {@ */
#if !defined(USB_DT_DEVICE) && !defined(USB_DT_ENDPOINT)
# define USB_DT_DEVICE 0x01
# define USB_DT_CONFIG 0x02
# define USB_DT_STRING 0x03
# define USB_DT_INTERFACE 0x04
# define USB_DT_ENDPOINT 0x05
# define USB_DT_HID 0x21
# define USB_DT_REPORT 0x22
# define USB_DT_PHYSICAL 0x23
# define USB_DT_HUB 0x29
#endif
/** @} */
/**
* USB device descriptor.
*/
#pragma pack(1)
typedef struct USBDEVICEDESC
{
/** The descriptor length. (Usually sizeof(USBDEVICEDESC).) */
/** The descriptor type. (USB_DT_DEVICE) */
/** USB version number. */
/** Device class. */
/** Device subclass. */
/** Device protocol */
/** The max packet size of the default control pipe. */
/** Vendor ID. */
/** Product ID. */
/** Revision, integer part. */
/** Manufacturer string index. */
/** Product string index. */
/** Serial number string index. */
/** Number of configurations. */
#pragma pack()
/** Pointer to an USB device descriptor. */
typedef USBDEVICEDESC *PUSBDEVICEDESC;
/** @name Class codes (bDeviceClass)
* @{ */
#ifndef USB_HUB_CLASSCODE
# define USB_HUB_CLASSCODE 0x09
#endif
/** @} */
/**
* USB configuration descriptor.
*/
#pragma pack(1)
typedef struct USBCONFIGDESC
{
/** The descriptor length. (Usually sizeof(USBCONFIGDESC).) */
/** The descriptor type. (USB_DT_CONFIG) */
/** The length of the configuration descriptor plus all associated descriptors. */
/** Number of interfaces. */
/** Configuration number. (For SetConfiguration().) */
/** Configuration description string. */
/** Configuration characteristics. */
/** Maximum power consumption of the USB device in this config. */
#pragma pack()
/** Pointer to an USB configuration descriptor. */
typedef USBCONFIGDESC *PUSBCONFIGDESC;
#endif /* VBOX_USB_H_INCL_DESCRIPTORS */
#endif