VirtualBox

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

Last change on this file since 85704 was 82968, checked in by vboxsync, 5 years ago

Copyright year updates by scm.

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