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