VirtualBox

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

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

The Giant CDDL Dual-License Header Change.

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