VirtualBox

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

Last change on this file since 58803 was 58110, checked in by vboxsync, 9 years ago

include,misc: Doxygen grouping adjustments, collecting all the VMM bits under one parent group, ditto for the COM library.

  • 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-2015 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
101 /** Vendor ID. */
102 uint16_t idVendor;
103 /** Product ID. */
104 uint16_t idProduct;
105 /** Revision, integer part. */
106 uint16_t bcdDevice;
107 /** USB version number. */
108 uint16_t bcdUSB;
109 /** Device class. */
110 uint8_t bDeviceClass;
111 /** Device subclass. */
112 uint8_t bDeviceSubClass;
113 /** Device protocol */
114 uint8_t bDeviceProtocol;
115 /** Number of configurations. */
116 uint8_t bNumConfigurations;
117 /** The device state. */
118 USBDEVICESTATE enmState;
119 /** The device speed. */
120 USBDEVICESPEED enmSpeed;
121 /** Serial hash. */
122 uint64_t u64SerialHash;
123 /** The USB Bus number. */
124 uint8_t bBus;
125 /** The port number. */
126 uint8_t bPort;
127#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
128 /** Device number. */
129 uint8_t bDevNum;
130#endif
131#ifdef RT_OS_WINDOWS
132 /** Alternate address. Can be NULL. */
133 char *pszAltAddress;
134 /** The hub name. */
135 char *pszHubName;
136#endif
137#ifdef RT_OS_SOLARIS
138 /** The /devices path of the device. */
139 char *pszDevicePath;
140 /** Do we have a partial or full device descriptor here. */
141 bool fPartialDescriptor;
142#endif
143} USBDEVICE;
144/** Pointer to a USB device. */
145typedef USBDEVICE *PUSBDEVICE;
146/** Pointer to a const USB device. */
147typedef USBDEVICE *PCUSBDEVICE;
148
149
150#ifdef VBOX_USB_H_INCL_DESCRIPTORS /* for the time being, since this may easily conflict with system headers */
151
152/**
153 * USB device descriptor.
154 */
155#pragma pack(1)
156typedef struct USBDESCHDR
157{
158 /** The descriptor length. */
159 uint8_t bLength;
160 /** The descriptor type. */
161 uint8_t bDescriptorType;
162} USBDESCHDR;
163#pragma pack()
164/** Pointer to an USB descriptor header. */
165typedef USBDESCHDR *PUSBDESCHDR;
166
167/** @name Descriptor Type values (bDescriptorType)
168 * {@ */
169#if !defined(USB_DT_DEVICE) && !defined(USB_DT_ENDPOINT)
170# define USB_DT_DEVICE 0x01
171# define USB_DT_CONFIG 0x02
172# define USB_DT_STRING 0x03
173# define USB_DT_INTERFACE 0x04
174# define USB_DT_ENDPOINT 0x05
175
176# define USB_DT_HID 0x21
177# define USB_DT_REPORT 0x22
178# define USB_DT_PHYSICAL 0x23
179# define USB_DT_HUB 0x29
180#endif
181/** @} */
182
183
184/**
185 * USB device descriptor.
186 */
187#pragma pack(1)
188typedef struct USBDEVICEDESC
189{
190 /** The descriptor length. (Usually sizeof(USBDEVICEDESC).) */
191 uint8_t bLength;
192 /** The descriptor type. (USB_DT_DEVICE) */
193 uint8_t bDescriptorType;
194 /** USB version number. */
195 uint16_t bcdUSB;
196 /** Device class. */
197 uint8_t bDeviceClass;
198 /** Device subclass. */
199 uint8_t bDeviceSubClass;
200 /** Device protocol */
201 uint8_t bDeviceProtocol;
202 /** The max packet size of the default control pipe. */
203 uint8_t bMaxPacketSize0;
204 /** Vendor ID. */
205 uint16_t idVendor;
206 /** Product ID. */
207 uint16_t idProduct;
208 /** Revision, integer part. */
209 uint16_t bcdDevice;
210 /** Manufacturer string index. */
211 uint8_t iManufacturer;
212 /** Product string index. */
213 uint8_t iProduct;
214 /** Serial number string index. */
215 uint8_t iSerialNumber;
216 /** Number of configurations. */
217 uint8_t bNumConfigurations;
218} USBDEVICEDESC;
219#pragma pack()
220/** Pointer to an USB device descriptor. */
221typedef USBDEVICEDESC *PUSBDEVICEDESC;
222
223/** @name Class codes (bDeviceClass)
224 * @{ */
225#ifndef USB_HUB_CLASSCODE
226# define USB_HUB_CLASSCODE 0x09
227#endif
228/** @} */
229
230/**
231 * USB configuration descriptor.
232 */
233#pragma pack(1)
234typedef struct USBCONFIGDESC
235{
236 /** The descriptor length. (Usually sizeof(USBCONFIGDESC).) */
237 uint8_t bLength;
238 /** The descriptor type. (USB_DT_CONFIG) */
239 uint8_t bDescriptorType;
240 /** The length of the configuration descriptor plus all associated descriptors. */
241 uint16_t wTotalLength;
242 /** Number of interfaces. */
243 uint8_t bNumInterfaces;
244 /** Configuration number. (For SetConfiguration().) */
245 uint8_t bConfigurationValue;
246 /** Configuration description string. */
247 uint8_t iConfiguration;
248 /** Configuration characteristics. */
249 uint8_t bmAttributes;
250 /** Maximum power consumption of the USB device in this config. */
251 uint8_t MaxPower;
252} USBCONFIGDESC;
253#pragma pack()
254/** Pointer to an USB configuration descriptor. */
255typedef USBCONFIGDESC *PUSBCONFIGDESC;
256
257#endif /* VBOX_USB_H_INCL_DESCRIPTORS */
258
259/** @} */
260RT_C_DECLS_END
261
262#endif
263
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