VirtualBox

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

Last change on this file since 2889 was 1, checked in by vboxsync, 55 years ago

import

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 6.5 KB
Line 
1/** @file
2 * USB - Universal Serial Bus.
3 */
4
5/*
6 * Copyright (C) 2006 InnoTek Systemberatung 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 as published by the Free Software Foundation,
12 * in version 2 as it comes in the "COPYING" file of the VirtualBox OSE
13 * distribution. VirtualBox OSE is distributed in the hope that it will
14 * be useful, but WITHOUT ANY WARRANTY of any kind.
15 *
16 * If you received this file as part of a commercial VirtualBox
17 * distribution, then only the terms of your commercial VirtualBox
18 * license agreement apply instead of the previous paragraph.
19 */
20
21
22#ifndef __VBox_usb_h__
23#define __VBox_usb_h__
24
25#include <VBox/types.h>
26
27__BEGIN_DECLS
28
29/**
30 * USB device interface endpoint.
31 */
32typedef struct USBENDPOINT
33{
34 /** The address of the endpoint on the USB device described by this descriptor. */
35 uint8_t bEndpointAddress;
36 /** This field describes the endpoint's attributes when it is configured using the bConfigurationValue. */
37 uint8_t bmAttributes;
38 /** Maximum packet size this endpoint is capable of sending or receiving when this configuration is selected. */
39 uint16_t wMaxPacketSize;
40 /** Interval for polling endpoint for data transfers. Expressed in milliseconds.
41 * This is interpreted the bInterval value. */
42 uint16_t u16Interval;
43} USBENDPOINT;
44/** Pointer to a USB device interface endpoint. */
45typedef USBENDPOINT *PUSBENDPOINT;
46/** Pointer to a const USB device interface endpoint. */
47typedef const USBENDPOINT *PCUSBENDPOINT;
48
49/** USBENDPOINT::bmAttributes values.
50 * @{ */
51#define USB_EP_ATTR_CONTROL 0
52#define USB_EP_ATTR_ISOCHRONOUS 1
53#define USB_EP_ATTR_BULK 2
54#define USB_EP_ATTR_INTERRUPT 3
55/** @} */
56
57
58/**
59 * USB device interface.
60 */
61typedef struct USBINTERFACE
62{
63 /** Number of interface. */
64 uint8_t bInterfaceNumber;
65 /** Value used to select alternate setting for the interface identified in the prior field. */
66 uint8_t bAlternateSetting;
67 /** Number of endpoints used by this interface (excluding endpoint zero). */
68 uint8_t bNumEndpoints;
69 /** Pointer to an array of endpoints. */
70 PUSBENDPOINT paEndpoints;
71 /** Interface class. */
72 uint8_t bInterfaceClass;
73 /** Interface subclass. */
74 uint8_t bInterfaceSubClass;
75 /** Protocol code. */
76 uint8_t bInterfaceProtocol;
77 /** Number of alternate settings. */
78 uint8_t cAlts;
79 /** Pointer to an array of alternate interface settings. */
80 struct USBINTERFACE *paAlts;
81 /** String describing this interface. */
82 const char *pszInterface;
83 /** String containing the driver name.
84 * This is a NULL pointer if the interface is not in use. */
85 const char *pszDriver;
86} USBINTERFACE;
87/** Pointer to a USB device interface description. */
88typedef USBINTERFACE *PUSBINTERFACE;
89/** Pointer to a const USB device interface description. */
90typedef const USBINTERFACE *PCUSBINTERFACE;
91
92/**
93 * Device configuration.
94 */
95typedef struct USBCONFIG
96{
97 /** Set if this is the active configuration. */
98 bool fActive;
99 /** Number of interfaces. */
100 uint8_t bNumInterfaces;
101 /** Pointer to an array of interfaces. */
102 PUSBINTERFACE paInterfaces;
103 /** Configuration number. (For SetConfiguration().) */
104 uint8_t bConfigurationValue;
105 /** Configuration description string. */
106 const char *pszConfiguration;
107 /** Configuration characteristics. */
108 uint8_t bmAttributes;
109 /** Maximum power consumption of the USB device in this config.
110 * (This field does NOT need shifting like in the USB config descriptor.) */
111 uint16_t u16MaxPower;
112} USBCONFIG;
113/** Pointer to a USB configuration. */
114typedef USBCONFIG *PUSBCONFIG;
115/** Pointer to a const USB configuration. */
116typedef const USBCONFIG *PCUSBCONFIG;
117
118
119/**
120 * The USB host device state.
121 */
122typedef enum USBDEVICESTATE
123{
124 /** The device is unsupported. */
125 USBDEVICESTATE_UNSUPPORTED = 1,
126 /** The device is in use by the host. */
127 USBDEVICESTATE_USED_BY_HOST,
128 /** The device is in use by the host but could perhaps be captured even so. */
129 USBDEVICESTATE_USED_BY_HOST_CAPTURABLE,
130 /** The device is not used by the host or any guest. */
131 USBDEVICESTATE_UNUSED,
132 /** The device is held by the proxy for later guest usage. */
133 USBDEVICESTATE_HELD_BY_PROXY,
134 /** The device in use by a guest. */
135 USBDEVICESTATE_USED_BY_GUEST,
136 /** The usual 32-bit hack. */
137 USBDEVICESTATE_32BIT_HACK = 0x7fffffff
138} USBDEVICESTATE;
139
140
141/**
142 * USB host device description.
143 * Used for enumeration of USB devices.
144 */
145typedef struct USBDEVICE
146{
147 /** USB version number. */
148 uint16_t bcdUSB;
149 /** Device class. */
150 uint8_t bDeviceClass;
151 /** Device subclass. */
152 uint8_t bDeviceSubClass;
153 /** Device protocol */
154 uint8_t bDeviceProtocol;
155 /** Vendor ID. */
156 uint16_t idVendor;
157 /** Product ID. */
158 uint16_t idProduct;
159 /** Revision, integer part. */
160 uint16_t bcdDevice;
161 /** Manufacturer string. */
162 const char *pszManufacturer;
163 /** Product string. */
164 const char *pszProduct;
165 /** Serial number string. */
166 const char *pszSerialNumber;
167 /** Serial hash. */
168 uint64_t u64SerialHash;
169 /** Number of configurations. */
170 uint8_t bNumConfigurations;
171 /** Pointer to an array of configurations. */
172 PUSBCONFIG paConfigurations;
173 /** The device state. */
174 USBDEVICESTATE enmState;
175 /** The address of the device. */
176 const char *pszAddress;
177
178 /** The USB Bus number. */
179 uint8_t bBus;
180 /** The level in topologly for this bus. */
181 uint8_t bLevel;
182 /** Device number. */
183 uint8_t bDevNum;
184 /** Parent device number. */
185 uint8_t bDevNumParent;
186 /** The port number. */
187 uint8_t bPort;
188 /** Number of devices on this level. */
189 uint8_t bNumDevices;
190 /** Maximum number of children. */
191 uint8_t bMaxChildren;
192
193 /** If linked, this is the pointer to the next device in the list. */
194 struct USBDEVICE *pNext;
195 /** If linked doubly, this is the pointer to the prev device in the list. */
196 struct USBDEVICE *pPrev;
197} USBDEVICE;
198/** Pointer to a USB device. */
199typedef USBDEVICE *PUSBDEVICE;
200/** Pointer to a const USB device. */
201typedef USBDEVICE *PCUSBDEVICE;
202
203__END_DECLS
204
205#endif
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