VirtualBox

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

Last change on this file since 78307 was 76585, checked in by vboxsync, 6 years ago

*: scm --fix-header-guard-endif

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.7 KB
Line 
1/** @file
2 * USB - Universal Serial Bus. (DEV,Main?)
3 */
4
5/*
6 * Copyright (C) 2006-2019 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#if defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD)
133 /** Device number. */
134 uint8_t bDevNum;
135#endif
136#ifdef RT_OS_WINDOWS
137 /** Alternate address. Can be NULL. */
138 char *pszAltAddress;
139 /** The hub name. */
140 char *pszHubName;
141#endif
142#ifdef RT_OS_SOLARIS
143 /** The /devices path of the device. */
144 char *pszDevicePath;
145 /** Do we have a partial or full device descriptor here. */
146 bool fPartialDescriptor;
147#endif
148} USBDEVICE;
149/** Pointer to a USB device. */
150typedef USBDEVICE *PUSBDEVICE;
151/** Pointer to a const USB device. */
152typedef USBDEVICE *PCUSBDEVICE;
153
154
155#ifdef VBOX_USB_H_INCL_DESCRIPTORS /* for the time being, since this may easily conflict with system headers */
156
157/**
158 * USB device descriptor.
159 */
160#pragma pack(1)
161typedef struct USBDESCHDR
162{
163 /** The descriptor length. */
164 uint8_t bLength;
165 /** The descriptor type. */
166 uint8_t bDescriptorType;
167} USBDESCHDR;
168#pragma pack()
169/** Pointer to an USB descriptor header. */
170typedef USBDESCHDR *PUSBDESCHDR;
171
172/** @name Descriptor Type values (bDescriptorType)
173 * {@ */
174#if !defined(USB_DT_DEVICE) && !defined(USB_DT_ENDPOINT)
175# define USB_DT_DEVICE 0x01
176# define USB_DT_CONFIG 0x02
177# define USB_DT_STRING 0x03
178# define USB_DT_INTERFACE 0x04
179# define USB_DT_ENDPOINT 0x05
180
181# define USB_DT_HID 0x21
182# define USB_DT_REPORT 0x22
183# define USB_DT_PHYSICAL 0x23
184# define USB_DT_HUB 0x29
185#endif
186/** @} */
187
188
189/**
190 * USB device descriptor.
191 */
192#pragma pack(1)
193typedef struct USBDEVICEDESC
194{
195 /** The descriptor length. (Usually sizeof(USBDEVICEDESC).) */
196 uint8_t bLength;
197 /** The descriptor type. (USB_DT_DEVICE) */
198 uint8_t bDescriptorType;
199 /** USB version number. */
200 uint16_t bcdUSB;
201 /** Device class. */
202 uint8_t bDeviceClass;
203 /** Device subclass. */
204 uint8_t bDeviceSubClass;
205 /** Device protocol */
206 uint8_t bDeviceProtocol;
207 /** The max packet size of the default control pipe. */
208 uint8_t bMaxPacketSize0;
209 /** Vendor ID. */
210 uint16_t idVendor;
211 /** Product ID. */
212 uint16_t idProduct;
213 /** Revision, integer part. */
214 uint16_t bcdDevice;
215 /** Manufacturer string index. */
216 uint8_t iManufacturer;
217 /** Product string index. */
218 uint8_t iProduct;
219 /** Serial number string index. */
220 uint8_t iSerialNumber;
221 /** Number of configurations. */
222 uint8_t bNumConfigurations;
223} USBDEVICEDESC;
224#pragma pack()
225/** Pointer to an USB device descriptor. */
226typedef USBDEVICEDESC *PUSBDEVICEDESC;
227
228/** @name Class codes (bDeviceClass)
229 * @{ */
230#ifndef USB_HUB_CLASSCODE
231# define USB_HUB_CLASSCODE 0x09
232#endif
233/** @} */
234
235/**
236 * USB configuration descriptor.
237 */
238#pragma pack(1)
239typedef struct USBCONFIGDESC
240{
241 /** The descriptor length. (Usually sizeof(USBCONFIGDESC).) */
242 uint8_t bLength;
243 /** The descriptor type. (USB_DT_CONFIG) */
244 uint8_t bDescriptorType;
245 /** The length of the configuration descriptor plus all associated descriptors. */
246 uint16_t wTotalLength;
247 /** Number of interfaces. */
248 uint8_t bNumInterfaces;
249 /** Configuration number. (For SetConfiguration().) */
250 uint8_t bConfigurationValue;
251 /** Configuration description string. */
252 uint8_t iConfiguration;
253 /** Configuration characteristics. */
254 uint8_t bmAttributes;
255 /** Maximum power consumption of the USB device in this config. */
256 uint8_t MaxPower;
257} USBCONFIGDESC;
258#pragma pack()
259/** Pointer to an USB configuration descriptor. */
260typedef USBCONFIGDESC *PUSBCONFIGDESC;
261
262#endif /* VBOX_USB_H_INCL_DESCRIPTORS */
263
264/** @} */
265RT_C_DECLS_END
266
267#endif /* !VBOX_INCLUDED_usb_h */
268
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