VirtualBox

Changeset 5764 in vbox


Ignore:
Timestamp:
Nov 15, 2007 7:39:47 PM (17 years ago)
Author:
vboxsync
Message:

Moved the standard USB stuff out of the internal header.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/VBox/vusb.h

    r5722 r5764  
    2727 */
    2828
     29/** @defgroup grp_vusb_std  Standard Stuff
     30 * @{ */
     31
    2932/** Frequency of USB bus (from spec). */
    3033#define VUSB_BUS_HZ                 12000000
     34
     35
     36/** @name USB Descriptor types (from spec)
     37 * @{ */
     38#define VUSB_DT_DEVICE                  0x01
     39#define VUSB_DT_CONFIG                  0x02
     40#define VUSB_DT_STRING                  0x03
     41#define VUSB_DT_INTERFACE               0x04
     42#define VUSB_DT_ENDPOINT                0x05
     43/** @} */
     44
     45/** @name USB Descriptor minimum sizes (from spec)
     46 * @{ */
     47#define VUSB_DT_DEVICE_MIN_LEN          18
     48#define VUSB_DT_CONFIG_MIN_LEN          9
     49#define VUSB_DT_CONFIG_STRING_MIN_LEN   2
     50#define VUSB_DT_INTERFACE_MIN_LEN       9
     51#define VUSB_DT_ENDPOINT_MIN_LEN        7
     52/** @} */
     53
     54
     55#pragma pack(1) /* ensure byte packing of the descriptors. */
     56
     57/**
     58 * USB language id descriptor (from specs).
     59 */
     60typedef struct VUSBDESCLANGID
     61{
     62    uint8_t bLength;
     63    uint8_t bDescriptorType;
     64} VUSBDESCLANGID;
     65/** Pointer to a USB language id descriptor. */
     66typedef VUSBDESCLANGID *PVUSBDESCLANGID;
     67/** Pointer to a const USB language id descriptor. */
     68typedef const VUSBDESCLANGID *PCVUSBDESCLANGID;
     69
     70
     71/**
     72 * USB string descriptor (from specs).
     73 */
     74typedef struct VUSBDESCSTRING
     75{
     76    uint8_t bLength;
     77    uint8_t bDescriptorType;
     78} VUSBDESCSTRING;
     79/** Pointer to a USB string descriptor. */
     80typedef VUSBDESCSTRING *PVUSBDESCSTRING;
     81/** Pointer to a const USB string descriptor. */
     82typedef const VUSBDESCSTRING *PCVUSBDESCSTRING;
     83
     84
     85/**
     86 * USB device descriptor (from spec)
     87 */
     88typedef struct VUSBDESCDEVICE
     89{
     90    uint8_t  bLength;
     91    uint8_t  bDescriptorType;
     92    uint16_t bcdUSB;
     93    uint8_t  bDeviceClass;
     94    uint8_t  bDeviceSubClass;
     95    uint8_t  bDeviceProtocol;
     96    uint8_t  bMaxPacketSize0;
     97    uint16_t idVendor;
     98    uint16_t idProduct;
     99    uint16_t bcdDevice;
     100    uint8_t  iManufacturer;
     101    uint8_t  iProduct;
     102    uint8_t  iSerialNumber;
     103    uint8_t  bNumConfigurations;
     104} VUSBDESCDEVICE;
     105/** Pointer to a USB device descriptor. */
     106typedef VUSBDESCDEVICE *PVUSBDESCDEVICE;
     107/** Pointer to a const USB device descriptor. */
     108typedef const VUSBDESCDEVICE *PCVUSBDESCDEVICE;
     109
     110
     111/**
     112 * USB configuration descriptor (from spec).
     113 */
     114typedef struct VUSBDESCCONFIG
     115{
     116    uint8_t  bLength;
     117    uint8_t  bDescriptorType;
     118    uint16_t wTotalLength; /**< recalculated by VUSB when involved in URB. */
     119    uint8_t  bNumInterfaces;
     120    uint8_t  bConfigurationValue;
     121    uint8_t  iConfiguration;
     122    uint8_t  bmAttributes;
     123    uint8_t  MaxPower;
     124} VUSBDESCCONFIG;
     125/** Pointer to a USB configuration descriptor. */
     126typedef VUSBDESCCONFIG *PVUSBDESCCONFIG;
     127/** Pointer to a readonly USB configuration descriptor. */
     128typedef const VUSBDESCCONFIG *PCVUSBDESCCONFIG;
     129
     130
     131/**
     132 * USB interface descriptor (from spec)
     133 */
     134typedef struct VUSBDESCINTERFACE
     135{
     136    uint8_t  bLength;
     137    uint8_t  bDescriptorType;
     138    uint8_t  bInterfaceNumber;
     139    uint8_t  bAlternateSetting;
     140    uint8_t  bNumEndpoints;
     141    uint8_t  bInterfaceClass;
     142    uint8_t  bInterfaceSubClass;
     143    uint8_t  bInterfaceProtocol;
     144    uint8_t  iInterface;
     145} VUSBDESCINTERFACE;
     146/** Pointer to an USB interface descriptor. */
     147typedef VUSBDESCINTERFACE *PVUSBDESCINTERFACE;
     148/** Pointer to a const USB interface descriptor. */
     149typedef const VUSBDESCINTERFACE *PCVUSBDESCINTERFACE;
     150
     151
     152/**
     153 * USB endpoint descriptor (from spec)
     154 */
     155typedef struct VUSBDESCENDPOINT
     156{
     157    uint8_t  bLength;
     158    uint8_t  bDescriptorType;
     159    uint8_t  bEndpointAddress;
     160    uint8_t  bmAttributes;
     161    uint16_t wMaxPacketSize;
     162    uint8_t  bInterval;
     163} VUSBDESCENDPOINT;
     164/** Pointer to an USB endpoint descriptor. */
     165typedef VUSBDESCENDPOINT *PVUSBDESCENDPOINT;
     166/** Pointer to a const USB endpoint descriptor. */
     167typedef const VUSBDESCENDPOINT *PCVUSBDESCENDPOINT;
     168
     169#pragma pack() /* end of the byte packing. */
     170
     171
     172/**
     173 * USB configuration descriptor, the parsed variant used by VUSB.
     174 */
     175typedef struct VUSBDESCCONFIGEX
     176{
     177    /** The USB descriptor data.
     178     * @remark  The wTotalLength member is recalculated before the data is passed to the guest. */
     179    VUSBDESCCONFIG Core;
     180    /** Pointer to additional descriptor bytes following what's covered by VUSBDESCCONFIG. */
     181    void *extra;
     182    /** Pointer to an array of the interfaces referenced in the configuration.
     183     * Core.bNumInterfaces in size. */
     184    const struct VUSBINTERFACE *iface;
     185} VUSBDESCCONFIGEX;
     186/** Pointer to a parsed USB configuration descriptor. */
     187typedef VUSBDESCCONFIGEX *PVUSBDESCCONFIGEX;
     188/** Pointer to a const parsed USB configuration descriptor. */
     189typedef const VUSBDESCCONFIGEX *PCVUSBDESCCONFIGEX;
     190
     191
     192/**
     193 * For tracking the alternate interface settings of a configuration.
     194 */
     195typedef struct VUSBINTERFACE
     196{
     197    /** Pointer to an array of interfaces. */
     198    const struct VUSBDESCINTERFACEEX *setting;
     199    /** The number of entries in the array. */
     200    unsigned int num_settings;
     201} VUSBINTERFACE;
     202/** Pointer to a VUSBINTERFACE. */
     203typedef VUSBINTERFACE *PVUSBINTERFACE;
     204/** Pointer to a const VUSBINTERFACE. */
     205typedef const VUSBINTERFACE *PCVUSBINTERFACE;
     206
     207
     208/**
     209 * USB interface descriptor, the parsed variant used by VUSB.
     210 */
     211typedef struct VUSBDESCINTERFACEEX
     212{
     213    /** The USB descriptor data. */
     214    VUSBDESCINTERFACE Core;
     215    /** Pointer to additional descriptor bytes following what's covered by VUSBDESCINTERFACE. */
     216    void *extra;
     217    /** Pointer to an array of the endpoints referenced by the interface.
     218     * Core.bNumEndpoints in size. */
     219    const struct VUSBDESCENDPOINTEX *endpoint;
     220} VUSBDESCINTERFACEEX;
     221/** Pointer to an prased USB interface descriptor. */
     222typedef VUSBDESCINTERFACEEX *PVUSBDESCINTERFACEEX;
     223/** Pointer to a const parsed USB interface descriptor. */
     224typedef const VUSBDESCINTERFACEEX *PCVUSBDESCINTERFACEEX;
     225
     226
     227/**
     228 * USB endpoint descriptor, the parsed variant used by VUSB.
     229 */
     230typedef struct VUSBDESCENDPOINTEX
     231{
     232    /** The USB descriptor data.
     233     * @remark The wMaxPacketSize member is converted to native endian. */
     234    VUSBDESCENDPOINT Core;
     235    /** Pointer to additional descriptor bytes following what's covered by VUSBDESCENDPOINT. */
     236    void *extra;
     237} VUSBDESCENDPOINTEX;
     238/** Pointer to a parsed USB endpoint descriptor. */
     239typedef VUSBDESCENDPOINTEX *PVUSBDESCENDPOINTEX;
     240/** Pointer to a const parsed USB endpoint descriptor. */
     241typedef const VUSBDESCENDPOINTEX *PCVUSBDESCENDPOINTEX;
     242
     243
     244/** @name USB Control message recipient codes (from spec)
     245 * @{ */
     246#define VUSB_TO_DEVICE          0x0
     247#define VUSB_TO_INTERFACE       0x1
     248#define VUSB_TO_ENDPOINT        0x2
     249#define VUSB_TO_OTHER           0x3
     250#define VUSB_RECIP_MASK         0x1f
     251/** @} */
     252
     253/** @name USB control pipe setup packet structure (from spec)
     254 * @{ */
     255#define VUSB_REQ_SHIFT          (5)
     256#define VUSB_REQ_STANDARD       (0x0 << VUSB_REQ_SHIFT)
     257#define VUSB_REQ_CLASS          (0x1 << VUSB_REQ_SHIFT)
     258#define VUSB_REQ_VENDOR         (0x2 << VUSB_REQ_SHIFT)
     259#define VUSB_REQ_RESERVED       (0x3 << VUSB_REQ_SHIFT)
     260#define VUSB_REQ_MASK           (0x3 << VUSB_REQ_SHIFT)
     261/** @} */
     262
     263#define VUSB_DIR_TO_HOST        0x80
     264
     265/**
     266 * USB Setup request (from spec)
     267 */
     268typedef struct vusb_setup
     269{
     270    uint8_t  bmRequestType;
     271    uint8_t  bRequest;
     272    uint16_t wValue;
     273    uint16_t wIndex;
     274    uint16_t wLength;
     275} VUSBSETUP;
     276/** Pointer to a setup request. */
     277typedef VUSBSETUP *PVUSBSETUP;
     278/** Pointer to a const setup request. */
     279typedef const VUSBSETUP *PCVUSBSETUP;
     280
     281/** @name USB Standard device requests (from spec)
     282 * @{ */
     283#define VUSB_REQ_GET_STATUS         0x00
     284#define VUSB_REQ_CLEAR_FEATURE      0x01
     285#define VUSB_REQ_SET_FEATURE        0x03
     286#define VUSB_REQ_SET_ADDRESS        0x05
     287#define VUSB_REQ_GET_DESCRIPTOR     0x06
     288#define VUSB_REQ_SET_DESCRIPTOR     0x07
     289#define VUSB_REQ_GET_CONFIGURATION  0x08
     290#define VUSB_REQ_SET_CONFIGURATION  0x09
     291#define VUSB_REQ_GET_INTERFACE      0x0a
     292#define VUSB_REQ_SET_INTERFACE      0x0b
     293#define VUSB_REQ_SYNCH_FRAME        0x0c
     294#define VUSB_REQ_MAX                0x0d
     295/** @} */
     296
     297/** @} */ /* end of grp_vusb_std */
     298
     299
    31300
    32301/** @name USB Standard version flags.
     
    39308
    40309
    41 
    42310/** Pointer to a VBox USB device interface. */
    43311typedef struct VUSBIDEVICE      *PVUSBIDEVICE;
     
    63331/** Pointer to a VBox USB port bitmap. */
    64332typedef VUSBPORTBITMAP *PVUSBPORTBITMAP;
    65 
    66 
    67 
    68333
    69334
Note: See TracChangeset for help on using the changeset viewer.

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