VirtualBox

source: vbox/trunk/src/VBox/Devices/USB/USBProxyDevice.h@ 33000

Last change on this file since 33000 was 32472, checked in by vboxsync, 14 years ago

RDP/client: use sysfs for USB device enumeration and switch to using real iprt

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.3 KB
Line 
1/* $Id: USBProxyDevice.h 32472 2010-09-14 10:26:19Z vboxsync $ */
2/** @file
3 * USBPROXY - USB proxy header
4 */
5
6/*
7 * Copyright (C) 2006-2007 Oracle Corporation
8 *
9 * This file is part of VirtualBox Open Source Edition (OSE), as
10 * available from http://www.virtualbox.org. This file is free software;
11 * you can redistribute it and/or modify it under the terms of the GNU
12 * General Public License (GPL) as published by the Free Software
13 * Foundation, in version 2 as it comes in the "COPYING" file of the
14 * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
15 * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
16 */
17
18#ifndef ___USBProxyDevice_h
19#define ___USBProxyDevice_h
20
21#include <VBox/cdefs.h>
22#include <VBox/vusb.h>
23
24RT_C_DECLS_BEGIN
25
26
27/**
28 * Arguments passed to the USB proxy device constructor.
29 */
30typedef struct USBPROXYDEVARGS
31{
32 /** Whether this is a remote (VRDP) or local (Host) device. */
33 bool fRemote;
34 /** Host specific USB device address. */
35 const char *pszAddress;
36 /** Pointer to backend specific data. */
37 void *pvBackend;
38} USBPROXYDEVARGS;
39/** Pointer to proxy device creation structure. */
40typedef USBPROXYDEVARGS *PUSBPROXYDEVARGS;
41
42
43/** Pointer to a USB proxy device. */
44typedef struct USBPROXYDEV *PUSBPROXYDEV;
45
46/**
47 * USB Proxy Device Backend
48 */
49typedef struct USBPROXYBACK
50{
51 /** Name of the backend. */
52 const char *pszName;
53
54 /**
55 * Opens the USB device specfied by pszAddress.
56 *
57 * This method will initialize backend private data. If the backend has
58 * already selected a configuration for the device, this must be indicated
59 * in USBPROXYDEV::iActiveCfg.
60 *
61 * @returns VBox status code.
62 * @param pProxyDev The USB Proxy Device instance.
63 * @param pszAddress Host specific USB device address.
64 * @param pvBackend Pointer to backend specific data.
65 */
66 int (* pfnOpen)(PUSBPROXYDEV pProxyDev, const char *pszAddress, void *pvBackend);
67
68 /**
69 * Optional callback for initalizing the device after the configuration
70 * has been established.
71 *
72 * @returns VBox status code.
73 * @param pProxyDev The USB Proxy Device instance.
74 */
75 int (* pfnInit)(PUSBPROXYDEV pProxyDev);
76
77 /** Closes handle to the host USB device.
78 *
79 * @param pDev The USB Proxy Device instance.
80 */
81 void (* pfnClose)(PUSBPROXYDEV pProxyDev);
82
83 /**
84 * Reset a device.
85 *
86 * The backend must update iActualCfg and fIgnoreEqualSetConfig.
87 *
88 * @returns VBox status code.
89 * @param pDev The device to reset.
90 * @param fResetOnLinux It's safe to do reset on linux, we can deal with devices
91 * being logically reconnected.
92 */
93 int (* pfnReset)(PUSBPROXYDEV pProxyDev, bool fResetOnLinux);
94
95 /** @todo make it return a VBox status code! */
96 int (* pfnSetConfig)(PUSBPROXYDEV pProxyDev, int iCfg);
97
98 /** @todo make it return a VBox status code! */
99 int (* pfnClaimInterface)(PUSBPROXYDEV pProxyDev, int iIf);
100
101 /** @todo make it return a VBox status code! */
102 int (* pfnReleaseInterface)(PUSBPROXYDEV pProxyDev, int iIf);
103
104 /** @todo make it return a VBox status code! */
105 int (* pfnSetInterface)(PUSBPROXYDEV pProxyDev, int iIf, int setting);
106
107 /** @todo make it return a VBox status code! */
108 bool (* pfnClearHaltedEndpoint)(PUSBPROXYDEV pDev, unsigned int iEp);
109
110 /** @todo make it return a VBox status code! Add pDev. */
111 int (* pfnUrbQueue)(PVUSBURB pUrb);
112
113 /**
114 * Cancel an in-flight URB.
115 *
116 * @param pUrb The URB to cancel.
117 * @todo make it return a VBox status code! Add pDev.
118 */
119 void (* pfnUrbCancel)(PVUSBURB pUrb);
120
121 /**
122 * Reap URBs in-flight on a device.
123 *
124 * @returns Pointer to a completed URB.
125 * @returns NULL if no URB was completed.
126 * @param pDev The device.
127 * @param cMillies Number of milliseconds to wait. Use 0 to not
128 * wait at all.
129 */
130 PVUSBURB (* pfnUrbReap)(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies);
131
132 /** Dummy entry for making sure we've got all members initialized. */
133 uint32_t uDummy;
134} USBPROXYBACK;
135/** Pointer to a USB Proxy Device Backend. */
136typedef USBPROXYBACK *PUSBPROXYBACK;
137/** Pointer to a const USB Proxy Device Backend. */
138typedef const USBPROXYBACK *PCUSBPROXYBACK;
139
140/** The Host backend. */
141extern const USBPROXYBACK g_USBProxyDeviceHost;
142#ifdef VBOX_WITH_VRDP
143/** The VRDP backend. */
144extern const USBPROXYBACK g_USBProxyDeviceVRDP;
145#endif /* VBOX_WITH_VRDP */
146
147#ifdef RDESKTOP
148typedef struct VUSBDEV
149{
150 char* pszName;
151} VUSBDEV, *PVUSBDEV;
152#endif
153
154/**
155 * USB Proxy device.
156 */
157typedef struct USBPROXYDEV
158{
159#ifdef RDESKTOP
160 /** The VUSB device structure - must be the first structure member. */
161 VUSBDEV Dev;
162 /** The next device in rdesktop-vrdp's linked list */
163 PUSBPROXYDEV pNext;
164 /** The previous device in rdesktop-vrdp's linked list */
165 PUSBPROXYDEV pPrev;
166 /** The vrdp device ID */
167 uint32_t devid;
168 /** Linked list of in-flight URBs */
169 PVUSBURB pUrbs;
170#endif
171 /** The device descriptor. */
172 VUSBDESCDEVICE DevDesc;
173 /** The configuration descriptor array. */
174 PVUSBDESCCONFIGEX paCfgDescs;
175#ifndef RDESKTOP
176 /** The descriptor cache.
177 * Contains &DevDesc and paConfigDescs. */
178 PDMUSBDESCCACHE DescCache;
179 /** Pointer to the PDM USB device instance. */
180 PPDMUSBINS pUsbIns;
181#endif
182
183 /** Pointer to the backend. */
184 PCUSBPROXYBACK pOps;
185 /** The currently active configration.
186 * It's -1 if no configuration is active. This is set to -1 before open and reset,
187 * the backend will change it if open or reset implies SET_CONFIGURATION. */
188 int iActiveCfg;
189 /** Ignore one or two SET_CONFIGURATION operation.
190 * See usbProxyDevSetCfg for details. */
191 int cIgnoreSetConfigs;
192 /** Mask of the interfaces that the guest shall doesn't see.
193 * This is experimental!
194 */
195 uint32_t fMaskedIfs;
196 /** Whether we've opened the device or not.
197 * For dealing with failed construction (the destruct method is always called). */
198 bool fOpened;
199 /** Whether we've called pfnInit or not.
200 * For dealing with failed construction (the destruct method is always called). */
201 bool fInited;
202 /** Whether the device has been detached.
203 * This is hack for making PDMUSBREG::pfnUsbQueue return the right status code. */
204 bool fDetached;
205 /** Backend specific data */
206 union USBPROXYBACKENDDATA
207 {
208 /** Pointer to some backend data.
209 * The Linux and Darwin backends are making use of this. */
210 void *pv;
211 RTFILE File;
212 int fd;
213#ifdef VBOX_WITH_VRDP
214 struct vrdp_priv
215 {
216 void *pCallback;
217 void *pDevice;
218 } vrdp;
219#endif /* VBOX_WITH_VRDP */
220 } Backend;
221} USBPROXYDEV;
222
223static inline char *usbProxyGetName(PUSBPROXYDEV pProxyDev)
224{
225#ifndef RDESKTOP
226 return pProxyDev->pUsbIns->pszName;
227#else
228 return pProxyDev->Dev.pszName;
229#endif
230}
231
232#ifdef RDESKTOP
233static inline PUSBPROXYDEV usbProxyFromVusbDev(PVUSBDEV pDev)
234{
235 return (PUSBPROXYDEV)pDev;
236}
237#endif
238
239#ifdef RT_OS_LINUX
240RTDECL(int) USBProxyDeviceLinuxGetFD(PUSBPROXYDEV pProxyDev);
241#endif
242
243RT_C_DECLS_END
244
245#endif
246
Note: See TracBrowser for help on using the repository browser.

© 2023 Oracle
ContactPrivacy policyTerms of Use