VirtualBox

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

Last change on this file since 12986 was 9158, checked in by vboxsync, 17 years ago

Solaris USB stuff. More untested code.

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