VirtualBox

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

Last change on this file since 73768 was 69107, checked in by vboxsync, 7 years ago

include/VBox/: (C) year

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

© 2023 Oracle
ContactPrivacy policyTerms of Use