VirtualBox

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

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

Solaris/USB: included AP-id field in case we go that route.

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