VirtualBox

source: vbox/trunk/include/VBox/usb.h@ 55461

Last change on this file since 55461 was 52743, checked in by vboxsync, 10 years ago

Main/USB: Fix darwin assertion on Macbooks with USB 3.0 (Superspeed) ports and devices, introduce new device speed enum value for USB 3.0 devices

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.5 KB
Line 
1/** @file
2 * USB - Universal Serial Bus. (DEV,Main?)
3 */
4
5/*
6 * Copyright (C) 2006-2010 Oracle Corporation
7 *
8 * This file is part of VirtualBox Open Source Edition (OSE), as
9 * available from http://www.virtualbox.org. This file is free software;
10 * you can redistribute it and/or modify it under the terms of the GNU
11 * General Public License (GPL) as published by the Free Software
12 * Foundation, in version 2 as it comes in the "COPYING" file of the
13 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
14 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * The contents of this file may alternatively be used under the terms
17 * of the Common Development and Distribution License Version 1.0
18 * (CDDL) only, as it comes in the "COPYING.CDDL" file of the
19 * VirtualBox OSE distribution, in which case the provisions of the
20 * CDDL are applicable instead of those of the GPL.
21 *
22 * You may elect to license modified versions of this file under the
23 * terms and conditions of either the GPL or the CDDL or both.
24 */
25
26#ifndef ___VBox_usb_h
27#define ___VBox_usb_h
28
29#include <VBox/types.h>
30
31RT_C_DECLS_BEGIN
32
33/**
34 * The USB host device state.
35 */
36typedef enum USBDEVICESTATE
37{
38 /** The device is unsupported. */
39 USBDEVICESTATE_UNSUPPORTED = 1,
40 /** The device is in use by the host. */
41 USBDEVICESTATE_USED_BY_HOST,
42 /** The device is in use by the host but could perhaps be captured even so. */
43 USBDEVICESTATE_USED_BY_HOST_CAPTURABLE,
44 /** The device is not used by the host or any guest. */
45 USBDEVICESTATE_UNUSED,
46 /** The device is held by the proxy for later guest usage. */
47 USBDEVICESTATE_HELD_BY_PROXY,
48 /** The device in use by a guest. */
49 USBDEVICESTATE_USED_BY_GUEST,
50 /** The usual 32-bit hack. */
51 USBDEVICESTATE_32BIT_HACK = 0x7fffffff
52} USBDEVICESTATE;
53
54
55/**
56 * The USB device speed.
57 */
58typedef enum USBDEVICESPEED
59{
60 /** Unknown. */
61 USBDEVICESPEED_UNKNOWN = 0,
62 /** Low speed (1.5 Mbit/s). */
63 USBDEVICESPEED_LOW,
64 /** Full speed (12 Mbit/s). */
65 USBDEVICESPEED_FULL,
66 /** High speed (480 Mbit/s). */
67 USBDEVICESPEED_HIGH,
68 /** Variable speed - USB 2.5 / wireless. */
69 USBDEVICESPEED_VARIABLE,
70 /** Super speed - USB 3.0 (5Gbit/s). */
71 USBDEVICESPEED_SUPER,
72 /** The usual 32-bit hack. */
73 USBDEVICESPEED_32BIT_HACK = 0x7fffffff
74} USBDEVICESPEED;
75
76
77/**
78 * USB host device description.
79 * Used for enumeration of USB devices.
80 */
81typedef struct USBDEVICE
82{
83 /** If linked, this is the pointer to the next device in the list. */
84 struct USBDEVICE *pNext;
85 /** If linked doubly, this is the pointer to the prev device in the list. */
86 struct USBDEVICE *pPrev;
87 /** Manufacturer string. */
88 const char *pszManufacturer;
89 /** Product string. */
90 const char *pszProduct;
91 /** Serial number string. */
92 const char *pszSerialNumber;
93 /** The address of the device. */
94 const char *pszAddress;
95
96 /** Vendor ID. */
97 uint16_t idVendor;
98 /** Product ID. */
99 uint16_t idProduct;
100 /** Revision, integer part. */
101 uint16_t bcdDevice;
102 /** USB version number. */
103 uint16_t bcdUSB;
104 /** Device class. */
105 uint8_t bDeviceClass;
106 /** Device subclass. */
107 uint8_t bDeviceSubClass;
108 /** Device protocol */
109 uint8_t bDeviceProtocol;
110 /** Number of configurations. */
111 uint8_t bNumConfigurations;
112 /** The device state. */
113 USBDEVICESTATE enmState;
114 /** The device speed. */
115 USBDEVICESPEED enmSpeed;
116 /** Serial hash. */
117 uint64_t u64SerialHash;
118 /** The USB Bus number. */
119 uint8_t bBus;
120 /** The port number. */
121 uint8_t bPort;
122#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
123 /** Device number. */
124 uint8_t bDevNum;
125#endif
126#ifdef RT_OS_WINDOWS
127 /** Alternate address. Can be NULL. */
128 char *pszAltAddress;
129 /** The hub name. */
130 char *pszHubName;
131#endif
132#ifdef RT_OS_SOLARIS
133 /** The /devices path of the device. */
134 char *pszDevicePath;
135 /** Do we have a partial or full device descriptor here. */
136 bool fPartialDescriptor;
137#endif
138} USBDEVICE;
139/** Pointer to a USB device. */
140typedef USBDEVICE *PUSBDEVICE;
141/** Pointer to a const USB device. */
142typedef USBDEVICE *PCUSBDEVICE;
143
144
145#ifdef VBOX_USB_H_INCL_DESCRIPTORS /* for the time being, since this may easily conflict with system headers */
146
147/**
148 * USB device descriptor.
149 */
150#pragma pack(1)
151typedef struct USBDESCHDR
152{
153 /** The descriptor length. */
154 uint8_t bLength;
155 /** The descriptor type. */
156 uint8_t bDescriptorType;
157} USBDESCHDR;
158#pragma pack()
159/** Pointer to an USB descriptor header. */
160typedef USBDESCHDR *PUSBDESCHDR;
161
162/** @name Descriptor Type values (bDescriptorType)
163 * {@ */
164#if !defined(USB_DT_DEVICE) && !defined(USB_DT_ENDPOINT)
165# define USB_DT_DEVICE 0x01
166# define USB_DT_CONFIG 0x02
167# define USB_DT_STRING 0x03
168# define USB_DT_INTERFACE 0x04
169# define USB_DT_ENDPOINT 0x05
170
171# define USB_DT_HID 0x21
172# define USB_DT_REPORT 0x22
173# define USB_DT_PHYSICAL 0x23
174# define USB_DT_HUB 0x29
175#endif
176/** @} */
177
178
179/**
180 * USB device descriptor.
181 */
182#pragma pack(1)
183typedef struct USBDEVICEDESC
184{
185 /** The descriptor length. (Usually sizeof(USBDEVICEDESC).) */
186 uint8_t bLength;
187 /** The descriptor type. (USB_DT_DEVICE) */
188 uint8_t bDescriptorType;
189 /** USB version number. */
190 uint16_t bcdUSB;
191 /** Device class. */
192 uint8_t bDeviceClass;
193 /** Device subclass. */
194 uint8_t bDeviceSubClass;
195 /** Device protocol */
196 uint8_t bDeviceProtocol;
197 /** The max packet size of the default control pipe. */
198 uint8_t bMaxPacketSize0;
199 /** Vendor ID. */
200 uint16_t idVendor;
201 /** Product ID. */
202 uint16_t idProduct;
203 /** Revision, integer part. */
204 uint16_t bcdDevice;
205 /** Manufacturer string index. */
206 uint8_t iManufacturer;
207 /** Product string index. */
208 uint8_t iProduct;
209 /** Serial number string index. */
210 uint8_t iSerialNumber;
211 /** Number of configurations. */
212 uint8_t bNumConfigurations;
213} USBDEVICEDESC;
214#pragma pack()
215/** Pointer to an USB device descriptor. */
216typedef USBDEVICEDESC *PUSBDEVICEDESC;
217
218/** @name Class codes (bDeviceClass)
219 * @{ */
220#ifndef USB_HUB_CLASSCODE
221# define USB_HUB_CLASSCODE 0x09
222#endif
223/** @} */
224
225/**
226 * USB configuration descriptor.
227 */
228#pragma pack(1)
229typedef struct USBCONFIGDESC
230{
231 /** The descriptor length. (Usually sizeof(USBCONFIGDESC).) */
232 uint8_t bLength;
233 /** The descriptor type. (USB_DT_CONFIG) */
234 uint8_t bDescriptorType;
235 /** The length of the configuration descriptor plus all associated descriptors. */
236 uint16_t wTotalLength;
237 /** Number of interfaces. */
238 uint8_t bNumInterfaces;
239 /** Configuration number. (For SetConfiguration().) */
240 uint8_t bConfigurationValue;
241 /** Configuration description string. */
242 uint8_t iConfiguration;
243 /** Configuration characteristics. */
244 uint8_t bmAttributes;
245 /** Maximum power consumption of the USB device in this config. */
246 uint8_t MaxPower;
247} USBCONFIGDESC;
248#pragma pack()
249/** Pointer to an USB configuration descriptor. */
250typedef USBCONFIGDESC *PUSBCONFIGDESC;
251
252#endif /* VBOX_USB_H_INCL_DESCRIPTORS */
253
254RT_C_DECLS_END
255
256#endif
257
Note: See TracBrowser for help on using the repository browser.

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