VirtualBox

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

Last change on this file since 8539 was 8539, checked in by vboxsync, 16 years ago

Drop the USBDEVICE bits we don't currently need.

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 10.7 KB
Line 
1/** @file
2 * USB - Universal Serial Bus.
3 */
4
5/*
6 * Copyright (C) 2006-2007 Sun Microsystems, Inc.
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 * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
26 * Clara, CA 95054 USA or visit http://www.sun.com if you need
27 * additional information or have any questions.
28 */
29
30#ifndef ___VBox_usb_h
31#define ___VBox_usb_h
32
33#include <VBox/types.h>
34
35__BEGIN_DECLS
36
37#ifdef USBDEVICE_WITH_EVERYTHING
38
39/**
40 * USB device interface endpoint.
41 */
42typedef struct USBENDPOINT
43{
44 /** The address of the endpoint on the USB device described by this descriptor. */
45 uint8_t bEndpointAddress;
46 /** This field describes the endpoint's attributes when it is configured using the bConfigurationValue. */
47 uint8_t bmAttributes;
48 /** Maximum packet size this endpoint is capable of sending or receiving when this configuration is selected. */
49 uint16_t wMaxPacketSize;
50 /** Interval for polling endpoint for data transfers. Expressed in milliseconds.
51 * This is interpreted the bInterval value. */
52 uint16_t u16Interval;
53} USBENDPOINT;
54/** Pointer to a USB device interface endpoint. */
55typedef USBENDPOINT *PUSBENDPOINT;
56/** Pointer to a const USB device interface endpoint. */
57typedef const USBENDPOINT *PCUSBENDPOINT;
58
59/** USBENDPOINT::bmAttributes values.
60 * @{ */
61#define USB_EP_ATTR_CONTROL 0
62#define USB_EP_ATTR_ISOCHRONOUS 1
63#define USB_EP_ATTR_BULK 2
64#define USB_EP_ATTR_INTERRUPT 3
65/** @} */
66
67
68/**
69 * USB device interface.
70 */
71typedef struct USBINTERFACE
72{
73 /** Number of interface. */
74 uint8_t bInterfaceNumber;
75 /** Value used to select alternate setting for the interface identified in the prior field. */
76 uint8_t bAlternateSetting;
77 /** Number of endpoints used by this interface (excluding endpoint zero). */
78 uint8_t bNumEndpoints;
79 /** Pointer to an array of endpoints. */
80 PUSBENDPOINT paEndpoints;
81 /** Interface class. */
82 uint8_t bInterfaceClass;
83 /** Interface subclass. */
84 uint8_t bInterfaceSubClass;
85 /** Protocol code. */
86 uint8_t bInterfaceProtocol;
87 /** Number of alternate settings. */
88 uint8_t cAlts;
89 /** Pointer to an array of alternate interface settings. */
90 struct USBINTERFACE *paAlts;
91 /** String describing this interface. */
92 const char *pszInterface;
93 /** String containing the driver name.
94 * This is a NULL pointer if the interface is not in use. */
95 const char *pszDriver;
96} USBINTERFACE;
97/** Pointer to a USB device interface description. */
98typedef USBINTERFACE *PUSBINTERFACE;
99/** Pointer to a const USB device interface description. */
100typedef const USBINTERFACE *PCUSBINTERFACE;
101
102/**
103 * Device configuration.
104 */
105typedef struct USBCONFIG
106{
107 /** Set if this is the active configuration. */
108 bool fActive;
109 /** Number of interfaces. */
110 uint8_t bNumInterfaces;
111 /** Pointer to an array of interfaces. */
112 PUSBINTERFACE paInterfaces;
113 /** Configuration number. (For SetConfiguration().) */
114 uint8_t bConfigurationValue;
115 /** Configuration description string. */
116 const char *pszConfiguration;
117 /** Configuration characteristics. */
118 uint8_t bmAttributes;
119 /** Maximum power consumption of the USB device in this config.
120 * (This field does NOT need shifting like in the USB config descriptor.) */
121 uint16_t u16MaxPower;
122} USBCONFIG;
123/** Pointer to a USB configuration. */
124typedef USBCONFIG *PUSBCONFIG;
125/** Pointer to a const USB configuration. */
126typedef const USBCONFIG *PCUSBCONFIG;
127
128#endif /* USBDEVICE_WITH_EVERYTHING */
129
130
131/**
132 * The USB host device state.
133 */
134typedef enum USBDEVICESTATE
135{
136 /** The device is unsupported. */
137 USBDEVICESTATE_UNSUPPORTED = 1,
138 /** The device is in use by the host. */
139 USBDEVICESTATE_USED_BY_HOST,
140 /** The device is in use by the host but could perhaps be captured even so. */
141 USBDEVICESTATE_USED_BY_HOST_CAPTURABLE,
142 /** The device is not used by the host or any guest. */
143 USBDEVICESTATE_UNUSED,
144 /** The device is held by the proxy for later guest usage. */
145 USBDEVICESTATE_HELD_BY_PROXY,
146 /** The device in use by a guest. */
147 USBDEVICESTATE_USED_BY_GUEST,
148 /** The usual 32-bit hack. */
149 USBDEVICESTATE_32BIT_HACK = 0x7fffffff
150} USBDEVICESTATE;
151
152
153/**
154 * The USB device speed.
155 */
156typedef enum USBDEVICESPEED
157{
158 /** Unknown. */
159 USBDEVICESPEED_UNKNOWN = 0,
160 /** Low speed (1.5 Mbit/s). */
161 USBDEVICESPEED_LOW,
162 /** Full speed (12 Mbit/s). */
163 USBDEVICESPEED_FULL,
164 /** High speed (480 Mbit/s). */
165 USBDEVICESPEED_HIGH,
166 /** Variable speed - USB 2.5 / wireless. */
167 USBDEVICESPEED_VARIABLE,
168 /** The usual 32-bit hack. */
169 USBDEVICESPEED_32BIT_HACK = 0x7fffffff
170} USBDEVICESPEED;
171
172
173/**
174 * USB host device description.
175 * Used for enumeration of USB devices.
176 */
177typedef struct USBDEVICE
178{
179 /** If linked, this is the pointer to the next device in the list. */
180 struct USBDEVICE *pNext;
181 /** If linked doubly, this is the pointer to the prev device in the list. */
182 struct USBDEVICE *pPrev;
183 /** Manufacturer string. */
184 const char *pszManufacturer;
185 /** Product string. */
186 const char *pszProduct;
187 /** Serial number string. */
188 const char *pszSerialNumber;
189 /** The address of the device. */
190 const char *pszAddress;
191
192 /** Vendor ID. */
193 uint16_t idVendor;
194 /** Product ID. */
195 uint16_t idProduct;
196 /** Revision, integer part. */
197 uint16_t bcdDevice;
198 /** USB version number. */
199 uint16_t bcdUSB;
200 /** Device class. */
201 uint8_t bDeviceClass;
202 /** Device subclass. */
203 uint8_t bDeviceSubClass;
204 /** Device protocol */
205 uint8_t bDeviceProtocol;
206 /** Number of configurations. */
207 uint8_t bNumConfigurations;
208 /** The device state. */
209 USBDEVICESTATE enmState;
210 /** The device speed. */
211 USBDEVICESPEED enmSpeed;
212 /** Serial hash. */
213 uint64_t u64SerialHash;
214 /** The USB Bus number. */
215 uint8_t bBus;
216 /** The port number. */
217 uint8_t bPort;
218#if defined(RT_OS_LINUX)
219 /** Device number. */
220 uint8_t bDevNum;
221#endif
222#ifdef USBDEVICE_WITH_EVERYTHING
223 /** Parent device number. */
224 uint8_t bDevNumParent;
225 /** The level in topologly for this bus. */
226 uint8_t bLevel;
227 /** Number of devices on this level. */
228 uint8_t bNumDevices;
229 /** Maximum number of children. */
230 uint8_t bMaxChildren;
231 /** Pointer to an array of configurations. */
232 PUSBCONFIG paConfigurations;
233#endif
234} USBDEVICE;
235/** Pointer to a USB device. */
236typedef USBDEVICE *PUSBDEVICE;
237/** Pointer to a const USB device. */
238typedef USBDEVICE *PCUSBDEVICE;
239
240
241#ifdef VBOX_USB_H_INCL_DESCRIPTORS /* for the time being, since this may easily conflict with system headers */
242
243/**
244 * USB device descriptor.
245 */
246#pragma pack(1)
247typedef struct USBDESCHDR
248{
249 /** The descriptor length. */
250 uint8_t bLength;
251 /** The descriptor type. */
252 uint8_t bDescriptorType;
253} USBDESCHDR;
254#pragma pack()
255/** Pointer to an USB descriptor header. */
256typedef USBDESCHDR *PUSBDESCHDR;
257
258/** @name Descriptor Type values (bDescriptorType)
259 * {@ */
260#if !defined(USB_DT_DEVICE) && !defined(USB_DT_ENDPOINT)
261# define USB_DT_DEVICE 0x01
262# define USB_DT_CONFIG 0x02
263# define USB_DT_STRING 0x03
264# define USB_DT_INTERFACE 0x04
265# define USB_DT_ENDPOINT 0x05
266
267# define USB_DT_HID 0x21
268# define USB_DT_REPORT 0x22
269# define USB_DT_PHYSICAL 0x23
270# define USB_DT_HUB 0x29
271#endif
272/** @} */
273
274
275/**
276 * USB device descriptor.
277 */
278#pragma pack(1)
279typedef struct USBDEVICEDESC
280{
281 /** The descriptor length. (Usually sizeof(USBDEVICEDESC).) */
282 uint8_t bLength;
283 /** The descriptor type. (USB_DT_DEVICE) */
284 uint8_t bDescriptorType;
285 /** USB version number. */
286 uint16_t bcdUSB;
287 /** Device class. */
288 uint8_t bDeviceClass;
289 /** Device subclass. */
290 uint8_t bDeviceSubClass;
291 /** Device protocol */
292 uint8_t bDeviceProtocol;
293 /** The max packet size of the default control pipe. */
294 uint8_t bMaxPacketSize0;
295 /** Vendor ID. */
296 uint16_t idVendor;
297 /** Product ID. */
298 uint16_t idProduct;
299 /** Revision, integer part. */
300 uint16_t bcdDevice;
301 /** Manufacturer string index. */
302 uint8_t iManufacturer;
303 /** Product string index. */
304 uint8_t iProduct;
305 /** Serial number string index. */
306 uint8_t iSerialNumber;
307 /** Number of configurations. */
308 uint8_t bNumConfigurations;
309} USBDEVICEDESC;
310#pragma pack()
311/** Pointer to an USB device descriptor. */
312typedef USBDEVICEDESC *PUSBDEVICEDESC;
313
314/** @name Class codes (bDeviceClass)
315 * @{ */
316#ifndef USB_HUB_CLASSCODE
317# define USB_HUB_CLASSCODE 0x09
318#endif
319/** @} */
320
321/**
322 * USB configuration descriptor.
323 */
324#pragma pack(1)
325typedef struct USBCONFIGDESC
326{
327 /** The descriptor length. (Usually sizeof(USBCONFIGDESC).) */
328 uint8_t bLength;
329 /** The descriptor type. (USB_DT_CONFIG) */
330 uint8_t bDescriptorType;
331 /** The length of the configuration descriptor plus all associated descriptors. */
332 uint16_t wTotalLength;
333 /** Number of interfaces. */
334 uint8_t bNumInterfaces;
335 /** Configuration number. (For SetConfiguration().) */
336 uint8_t bConfigurationValue;
337 /** Configuration description string. */
338 uint8_t iConfiguration;
339 /** Configuration characteristics. */
340 uint8_t bmAttributes;
341 /** Maximum power consumption of the USB device in this config. */
342 uint8_t MaxPower;
343} USBCONFIGDESC;
344#pragma pack()
345/** Pointer to an USB configuration descriptor. */
346typedef USBCONFIGDESC *PUSBCONFIGDESC;
347
348#endif /* VBOX_USB_H_INCL_DESCRIPTORS */
349
350__END_DECLS
351
352#endif
353
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use