VirtualBox

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

Last change on this file since 30670 was 29766, checked in by vboxsync, 14 years ago

usb.h: Need bDevNum too

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