VirtualBox

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

Last change on this file since 45733 was 44528, checked in by vboxsync, 12 years ago

header (C) fixes

  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 7.2 KB
Line 
1/* $Id: USBProxyDevice.h 44528 2013-02-04 14:27:54Z vboxsync $ */
2/** @file
3 * USBPROXY - USB proxy header
4 */
5
6/*
7 * Copyright (C) 2006-2011 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 initializing 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/** The remote desktop backend. */
143extern const USBPROXYBACK g_USBProxyDeviceVRDP;
144
145#ifdef RDESKTOP
146typedef struct VUSBDEV
147{
148 char* pszName;
149} VUSBDEV, *PVUSBDEV;
150#endif
151
152/**
153 * USB Proxy device.
154 */
155typedef struct USBPROXYDEV
156{
157#ifdef RDESKTOP
158 /** The VUSB device structure - must be the first structure member. */
159 VUSBDEV Dev;
160 /** The next device in rdesktop-vrdp's linked list */
161 PUSBPROXYDEV pNext;
162 /** The previous device in rdesktop-vrdp's linked list */
163 PUSBPROXYDEV pPrev;
164 /** The vrdp device ID */
165 uint32_t devid;
166 /** Linked list of in-flight URBs */
167 PVUSBURB pUrbs;
168#endif
169 /** The device descriptor. */
170 VUSBDESCDEVICE DevDesc;
171 /** The configuration descriptor array. */
172 PVUSBDESCCONFIGEX paCfgDescs;
173#ifndef RDESKTOP
174 /** The descriptor cache.
175 * Contains &DevDesc and paConfigDescs. */
176 PDMUSBDESCCACHE DescCache;
177 /** Pointer to the PDM USB device instance. */
178 PPDMUSBINS pUsbIns;
179#endif
180
181 /** Pointer to the backend. */
182 PCUSBPROXYBACK pOps;
183 /** The currently active configuration.
184 * It's -1 if no configuration is active. This is set to -1 before open and reset,
185 * the backend will change it if open or reset implies SET_CONFIGURATION. */
186 int iActiveCfg;
187 /** Ignore one or two SET_CONFIGURATION operation.
188 * See usbProxyDevSetCfg for details. */
189 int cIgnoreSetConfigs;
190 /** Mask of the interfaces that the guest shall doesn't see.
191 * This is experimental!
192 */
193 uint32_t fMaskedIfs;
194 /** Whether we've opened the device or not.
195 * For dealing with failed construction (the destruct method is always called). */
196 bool fOpened;
197 /** Whether we've called pfnInit or not.
198 * For dealing with failed construction (the destruct method is always called). */
199 bool fInited;
200 /** Whether the device has been detached.
201 * This is hack for making PDMUSBREG::pfnUsbQueue return the right status code. */
202 bool fDetached;
203 /** Backend specific data */
204 union USBPROXYBACKENDDATA
205 {
206 /** Pointer to some backend data.
207 * The Linux and Darwin backends are making use of this. */
208 void *pv;
209 RTFILE hFile;
210 int fd;
211 struct vrdp_priv
212 {
213 void *pCallback;
214 void *pDevice;
215 } vrdp;
216 } Backend;
217} USBPROXYDEV;
218
219static inline char *usbProxyGetName(PUSBPROXYDEV pProxyDev)
220{
221#ifndef RDESKTOP
222 return pProxyDev->pUsbIns->pszName;
223#else
224 return pProxyDev->Dev.pszName;
225#endif
226}
227
228#ifdef RDESKTOP
229static inline PUSBPROXYDEV usbProxyFromVusbDev(PVUSBDEV pDev)
230{
231 return (PUSBPROXYDEV)pDev;
232}
233#endif
234
235#ifdef RT_OS_LINUX
236RTDECL(int) USBProxyDeviceLinuxGetFD(PUSBPROXYDEV pProxyDev);
237#endif
238
239RT_C_DECLS_END
240
241#endif
242
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