VirtualBox

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

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

The Big Sun Rebranding Header Change

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

© 2023 Oracle
ContactPrivacy policyTerms of Use