1 | /* $Id: USBProxyDevice-solaris.cpp 94342 2022-03-23 19:53:21Z vboxsync $ */
|
---|
2 | /** @file
|
---|
3 | * USB device proxy - the Solaris backend.
|
---|
4 | */
|
---|
5 |
|
---|
6 | /*
|
---|
7 | * Copyright (C) 2009-2022 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 |
|
---|
19 | /*********************************************************************************************************************************
|
---|
20 | * Header Files *
|
---|
21 | *********************************************************************************************************************************/
|
---|
22 | #define LOG_GROUP LOG_GROUP_DRV_USBPROXY
|
---|
23 | #include <sys/poll.h>
|
---|
24 | #include <errno.h>
|
---|
25 | #include <strings.h>
|
---|
26 | #include <limits.h>
|
---|
27 |
|
---|
28 | #include <VBox/log.h>
|
---|
29 | #include <VBox/err.h>
|
---|
30 | #include <VBox/vmm/pdm.h>
|
---|
31 |
|
---|
32 | #include <iprt/string.h>
|
---|
33 | #include <iprt/critsect.h>
|
---|
34 | #include <iprt/time.h>
|
---|
35 | #include <iprt/file.h>
|
---|
36 | #include <iprt/mem.h>
|
---|
37 | #include <iprt/pipe.h>
|
---|
38 | #include "../USBProxyDevice.h"
|
---|
39 | #include <VBox/usblib.h>
|
---|
40 |
|
---|
41 |
|
---|
42 | /*********************************************************************************************************************************
|
---|
43 | * Defined Constants And Macros *
|
---|
44 | *********************************************************************************************************************************/
|
---|
45 | /** Log Prefix. */
|
---|
46 | #define USBPROXY "USBProxy"
|
---|
47 |
|
---|
48 |
|
---|
49 | /*********************************************************************************************************************************
|
---|
50 | * Structures and Typedefs *
|
---|
51 | *********************************************************************************************************************************/
|
---|
52 | /**
|
---|
53 | * Wrapper around the solaris urb request structure.
|
---|
54 | * This is required to track in-flight and landed URBs.
|
---|
55 | */
|
---|
56 | typedef struct USBPROXYURBSOL
|
---|
57 | {
|
---|
58 | /** Pointer to the Solaris device. */
|
---|
59 | struct USBPROXYDEVSOL *pDevSol;
|
---|
60 | /** Pointer to the VUSB URB (set to NULL if canceled). */
|
---|
61 | PVUSBURB pVUsbUrb;
|
---|
62 | /** Pointer to the next solaris URB. */
|
---|
63 | struct USBPROXYURBSOL *pNext;
|
---|
64 | /** Pointer to the previous solaris URB. */
|
---|
65 | struct USBPROXYURBSOL *pPrev;
|
---|
66 | } USBPROXYURBSOL, *PUSBPROXYURBSOL;
|
---|
67 |
|
---|
68 | /**
|
---|
69 | * Data for the solaris usb proxy backend.
|
---|
70 | */
|
---|
71 | typedef struct USBPROXYDEVSOL
|
---|
72 | {
|
---|
73 | /** Path of the USB device in the devices tree (persistent). */
|
---|
74 | char *pszDevicePath;
|
---|
75 | /** The connection to the client driver. */
|
---|
76 | RTFILE hFile;
|
---|
77 | /** Pointer to the proxy device instance. */
|
---|
78 | PUSBPROXYDEV pProxyDev;
|
---|
79 | /** Critical section protecting the two lists. */
|
---|
80 | RTCRITSECT CritSect;
|
---|
81 | /** The list of free solaris URBs. Singly linked. */
|
---|
82 | PUSBPROXYURBSOL pFreeHead;
|
---|
83 | /** The list of active solaris URBs. Doubly linked.
|
---|
84 | * We must maintain this so we can properly reap URBs of a detached device.
|
---|
85 | * Only the split head will appear in this list. */
|
---|
86 | PUSBPROXYURBSOL pInFlightHead;
|
---|
87 | /** The list of landed solaris URBs. Doubly linked.
|
---|
88 | * Only the split head will appear in this list. */
|
---|
89 | PUSBPROXYURBSOL pTaxingHead;
|
---|
90 | /** The tail of the landed solaris URBs. */
|
---|
91 | PUSBPROXYURBSOL pTaxingTail;
|
---|
92 | /** Pipe handle for waking up - writing end. */
|
---|
93 | RTPIPE hPipeWakeupW;
|
---|
94 | /** Pipe handle for waking up - reading end. */
|
---|
95 | RTPIPE hPipeWakeupR;
|
---|
96 | } USBPROXYDEVSOL, *PUSBPROXYDEVSOL;
|
---|
97 |
|
---|
98 | static PVUSBURB usbProxySolarisUrbComplete(PUSBPROXYDEVSOL pDevSol);
|
---|
99 |
|
---|
100 |
|
---|
101 | /**
|
---|
102 | * Allocates a Solaris URB request structure.
|
---|
103 | *
|
---|
104 | * @returns Pointer to an active URB request.
|
---|
105 | * @returns NULL on failure.
|
---|
106 | *
|
---|
107 | * @param pDevSol The solaris USB device.
|
---|
108 | */
|
---|
109 | static PUSBPROXYURBSOL usbProxySolarisUrbAlloc(PUSBPROXYDEVSOL pDevSol)
|
---|
110 | {
|
---|
111 | PUSBPROXYURBSOL pUrbSol;
|
---|
112 |
|
---|
113 | RTCritSectEnter(&pDevSol->CritSect);
|
---|
114 |
|
---|
115 | /*
|
---|
116 | * Try remove a Solaris URB from the free list, if none there allocate a new one.
|
---|
117 | */
|
---|
118 | pUrbSol = pDevSol->pFreeHead;
|
---|
119 | if (pUrbSol)
|
---|
120 | pDevSol->pFreeHead = pUrbSol->pNext;
|
---|
121 | else
|
---|
122 | {
|
---|
123 | RTCritSectLeave(&pDevSol->CritSect);
|
---|
124 | pUrbSol = (PUSBPROXYURBSOL)RTMemAlloc(sizeof(*pUrbSol));
|
---|
125 | if (!pUrbSol)
|
---|
126 | return NULL;
|
---|
127 | RTCritSectEnter(&pDevSol->CritSect);
|
---|
128 | }
|
---|
129 | pUrbSol->pVUsbUrb = NULL;
|
---|
130 | pUrbSol->pDevSol = pDevSol;
|
---|
131 |
|
---|
132 | /*
|
---|
133 | * Link it into the active list
|
---|
134 | */
|
---|
135 | pUrbSol->pPrev = NULL;
|
---|
136 | pUrbSol->pNext = pDevSol->pInFlightHead;
|
---|
137 | if (pUrbSol->pNext)
|
---|
138 | pUrbSol->pNext->pPrev = pUrbSol;
|
---|
139 | pDevSol->pInFlightHead = pUrbSol;
|
---|
140 |
|
---|
141 | RTCritSectLeave(&pDevSol->CritSect);
|
---|
142 | return pUrbSol;
|
---|
143 | }
|
---|
144 |
|
---|
145 |
|
---|
146 | /**
|
---|
147 | * Frees a Solaris URB request structure.
|
---|
148 | *
|
---|
149 | * @param pDevSol The Solaris USB device.
|
---|
150 | * @param pUrbSol The Solaris URB to free.
|
---|
151 | */
|
---|
152 | static void usbProxySolarisUrbFree(PUSBPROXYDEVSOL pDevSol, PUSBPROXYURBSOL pUrbSol)
|
---|
153 | {
|
---|
154 | RTCritSectEnter(&pDevSol->CritSect);
|
---|
155 |
|
---|
156 | /*
|
---|
157 | * Remove from the active or taxing list.
|
---|
158 | */
|
---|
159 | if (pUrbSol->pNext)
|
---|
160 | pUrbSol->pNext->pPrev = pUrbSol->pPrev;
|
---|
161 | else if (pDevSol->pTaxingTail == pUrbSol)
|
---|
162 | pDevSol->pTaxingTail = pUrbSol->pPrev;
|
---|
163 |
|
---|
164 | if (pUrbSol->pPrev)
|
---|
165 | pUrbSol->pPrev->pNext = pUrbSol->pNext;
|
---|
166 | else if (pDevSol->pTaxingHead == pUrbSol)
|
---|
167 | pDevSol->pTaxingHead = pUrbSol->pNext;
|
---|
168 | else if (pDevSol->pInFlightHead == pUrbSol)
|
---|
169 | pDevSol->pInFlightHead = pUrbSol->pNext;
|
---|
170 | else
|
---|
171 | AssertFailed();
|
---|
172 |
|
---|
173 | /*
|
---|
174 | * Link it into the free list.
|
---|
175 | */
|
---|
176 | pUrbSol->pPrev = NULL;
|
---|
177 | pUrbSol->pNext = pDevSol->pFreeHead;
|
---|
178 | pDevSol->pFreeHead = pUrbSol;
|
---|
179 |
|
---|
180 | pUrbSol->pVUsbUrb = NULL;
|
---|
181 | pUrbSol->pDevSol = NULL;
|
---|
182 |
|
---|
183 | RTCritSectLeave(&pDevSol->CritSect);
|
---|
184 | }
|
---|
185 |
|
---|
186 |
|
---|
187 | /*
|
---|
188 | * Close the connection to the USB client driver.
|
---|
189 | *
|
---|
190 | * This is required because our userland enumeration relies on drivers/device trees
|
---|
191 | * to recognize active devices, and hence if this device is unplugged we should no
|
---|
192 | * longer keep the client driver loaded.
|
---|
193 | */
|
---|
194 | static void usbProxySolarisCloseFile(PUSBPROXYDEVSOL pDevSol)
|
---|
195 | {
|
---|
196 | RTFileClose(pDevSol->hFile);
|
---|
197 | pDevSol->hFile = NIL_RTFILE;
|
---|
198 | }
|
---|
199 |
|
---|
200 |
|
---|
201 | /**
|
---|
202 | * The client driver IOCtl Wrapper function.
|
---|
203 | *
|
---|
204 | * @returns VBox status code.
|
---|
205 | * @param pDevSol The Solaris device instance.
|
---|
206 | * @param Function The Function.
|
---|
207 | * @param pvData Opaque pointer to the data.
|
---|
208 | * @param cbData Size of the data pointed to by pvData.
|
---|
209 | */
|
---|
210 | static int usbProxySolarisIOCtl(PUSBPROXYDEVSOL pDevSol, unsigned Function, void *pvData, size_t cbData)
|
---|
211 | {
|
---|
212 | if (RT_UNLIKELY(pDevSol->hFile == NIL_RTFILE))
|
---|
213 | {
|
---|
214 | LogFlow((USBPROXY ":usbProxySolarisIOCtl: Connection to driver gone!\n"));
|
---|
215 | return VERR_VUSB_DEVICE_NOT_ATTACHED;
|
---|
216 | }
|
---|
217 |
|
---|
218 | VBOXUSBREQ Req;
|
---|
219 | Req.u32Magic = VBOXUSB_MAGIC;
|
---|
220 | Req.rc = -1;
|
---|
221 | Req.cbData = cbData;
|
---|
222 | Req.pvDataR3 = pvData;
|
---|
223 |
|
---|
224 | int Ret = -1;
|
---|
225 | int rc = RTFileIoCtl(pDevSol->hFile, Function, &Req, sizeof(Req), &Ret);
|
---|
226 | if (RT_SUCCESS(rc))
|
---|
227 | {
|
---|
228 | if (RT_FAILURE(Req.rc))
|
---|
229 | {
|
---|
230 | if (Req.rc == VERR_VUSB_DEVICE_NOT_ATTACHED)
|
---|
231 | {
|
---|
232 | pDevSol->pProxyDev->fDetached = true;
|
---|
233 | usbProxySolarisCloseFile(pDevSol);
|
---|
234 | LogRel((USBPROXY ": Command %#x failed, USB Device '%s' disconnected!\n", Function,
|
---|
235 | pDevSol->pProxyDev->pUsbIns->pszName));
|
---|
236 | }
|
---|
237 | else
|
---|
238 | LogRel((USBPROXY ": Command %#x failed. Req.rc=%Rrc\n", Function, Req.rc));
|
---|
239 | }
|
---|
240 |
|
---|
241 | return Req.rc;
|
---|
242 | }
|
---|
243 |
|
---|
244 | LogRel((USBPROXY ": Function %#x failed. rc=%Rrc\n", Function, rc));
|
---|
245 | return rc;
|
---|
246 | }
|
---|
247 |
|
---|
248 |
|
---|
249 | /**
|
---|
250 | * Get the active configuration from the device. The first time this is called
|
---|
251 | * our client driver would returned the cached configuration since the device is first plugged in.
|
---|
252 | * Subsequent get configuration requests are passed on to the device.
|
---|
253 | *
|
---|
254 | * @returns VBox status code.
|
---|
255 | * @param pDevSol The Solaris device instance.
|
---|
256 | *
|
---|
257 | */
|
---|
258 | static inline int usbProxySolarisGetActiveConfig(PUSBPROXYDEVSOL pDevSol)
|
---|
259 | {
|
---|
260 | VBOXUSBREQ_GET_CONFIG GetConfigReq;
|
---|
261 | bzero(&GetConfigReq, sizeof(GetConfigReq));
|
---|
262 | int rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_GET_CONFIG, &GetConfigReq, sizeof(GetConfigReq));
|
---|
263 | if (RT_SUCCESS(rc))
|
---|
264 | {
|
---|
265 | pDevSol->pProxyDev->iActiveCfg = GetConfigReq.bConfigValue;
|
---|
266 | pDevSol->pProxyDev->cIgnoreSetConfigs = 0;
|
---|
267 | }
|
---|
268 | else
|
---|
269 | {
|
---|
270 | if (rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
|
---|
271 | LogRel((USBPROXY ": Failed to get configuration. rc=%Rrc\n", rc));
|
---|
272 |
|
---|
273 | pDevSol->pProxyDev->iActiveCfg = -1;
|
---|
274 | pDevSol->pProxyDev->cIgnoreSetConfigs = 0;
|
---|
275 | }
|
---|
276 | return rc;
|
---|
277 | }
|
---|
278 |
|
---|
279 |
|
---|
280 | /**
|
---|
281 | * Opens the USB device.
|
---|
282 | *
|
---|
283 | * @returns VBox status code.
|
---|
284 | * @param pProxyDev The device instance.
|
---|
285 | * @param pszAddress The unique device identifier.
|
---|
286 | * The format of this string is "VendorId:ProducIt:Release:StaticPath".
|
---|
287 | */
|
---|
288 | static DECLCALLBACK(int) usbProxySolarisOpen(PUSBPROXYDEV pProxyDev, const char *pszAddress)
|
---|
289 | {
|
---|
290 | PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL);
|
---|
291 |
|
---|
292 | LogFlowFunc((USBPROXY ":usbProxySolarisOpen: pProxyDev=%p pszAddress=%s\n", pProxyDev, pszAddress));
|
---|
293 |
|
---|
294 | /*
|
---|
295 | * Initialize our USB R3 lib.
|
---|
296 | */
|
---|
297 | int rc = USBLibInit();
|
---|
298 | if (RT_SUCCESS(rc))
|
---|
299 | {
|
---|
300 | /*
|
---|
301 | * Allocate and initialize the solaris backend data.
|
---|
302 | */
|
---|
303 | AssertCompile(PATH_MAX >= MAXPATHLEN);
|
---|
304 | char szDeviceIdent[PATH_MAX+48];
|
---|
305 | rc = RTStrPrintf(szDeviceIdent, sizeof(szDeviceIdent), "%s", pszAddress);
|
---|
306 | if (RT_SUCCESS(rc))
|
---|
307 | {
|
---|
308 | rc = RTCritSectInit(&pDevSol->CritSect);
|
---|
309 | if (RT_SUCCESS(rc))
|
---|
310 | {
|
---|
311 | /*
|
---|
312 | * Create wakeup pipe.
|
---|
313 | */
|
---|
314 | rc = RTPipeCreate(&pDevSol->hPipeWakeupR, &pDevSol->hPipeWakeupW, 0);
|
---|
315 | if (RT_SUCCESS(rc))
|
---|
316 | {
|
---|
317 | int Instance;
|
---|
318 | char *pszDevicePath = NULL;
|
---|
319 | rc = USBLibGetClientInfo(szDeviceIdent, &pszDevicePath, &Instance);
|
---|
320 | if (RT_SUCCESS(rc))
|
---|
321 | {
|
---|
322 | pDevSol->pszDevicePath = pszDevicePath;
|
---|
323 |
|
---|
324 | /*
|
---|
325 | * Open the client driver.
|
---|
326 | */
|
---|
327 | RTFILE hFile;
|
---|
328 | rc = RTFileOpen(&hFile, pDevSol->pszDevicePath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE);
|
---|
329 | if (RT_SUCCESS(rc))
|
---|
330 | {
|
---|
331 | pDevSol->hFile = hFile;
|
---|
332 | pDevSol->pProxyDev = pProxyDev;
|
---|
333 |
|
---|
334 | /*
|
---|
335 | * Verify client driver version.
|
---|
336 | */
|
---|
337 | VBOXUSBREQ_GET_VERSION GetVersionReq;
|
---|
338 | bzero(&GetVersionReq, sizeof(GetVersionReq));
|
---|
339 | rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_GET_VERSION, &GetVersionReq, sizeof(GetVersionReq));
|
---|
340 | if (RT_SUCCESS(rc))
|
---|
341 | {
|
---|
342 | if ( GetVersionReq.u32Major == VBOXUSB_VERSION_MAJOR
|
---|
343 | && GetVersionReq.u32Minor >= VBOXUSB_VERSION_MINOR)
|
---|
344 | {
|
---|
345 | /*
|
---|
346 | * Try & get the current cached config from Solaris.
|
---|
347 | */
|
---|
348 | usbProxySolarisGetActiveConfig(pDevSol);
|
---|
349 | return VINF_SUCCESS;
|
---|
350 | }
|
---|
351 | else
|
---|
352 | {
|
---|
353 | LogRel((USBPROXY ": Version mismatch, Driver v%d.%d expecting ~v%d.%d\n", GetVersionReq.u32Major,
|
---|
354 | GetVersionReq.u32Minor, VBOXUSB_VERSION_MAJOR, VBOXUSB_VERSION_MINOR));
|
---|
355 | rc = VERR_VERSION_MISMATCH;
|
---|
356 | }
|
---|
357 | }
|
---|
358 | else
|
---|
359 | LogRel((USBPROXY ": Failed to query driver version. rc=%Rrc\n", rc));
|
---|
360 |
|
---|
361 | RTFileClose(pDevSol->hFile);
|
---|
362 | pDevSol->hFile = NIL_RTFILE;
|
---|
363 | pDevSol->pProxyDev = NULL;
|
---|
364 | }
|
---|
365 | else
|
---|
366 | LogRel((USBPROXY ": Failed to open device. rc=%Rrc pszDevicePath=%s\n", rc, pDevSol->pszDevicePath));
|
---|
367 |
|
---|
368 | RTStrFree(pDevSol->pszDevicePath);
|
---|
369 | pDevSol->pszDevicePath = NULL;
|
---|
370 | }
|
---|
371 | else
|
---|
372 | {
|
---|
373 | LogRel((USBPROXY ": Failed to get client info. rc=%Rrc szDeviceIdent=%s\n", rc, szDeviceIdent));
|
---|
374 | if (rc == VERR_NOT_FOUND)
|
---|
375 | rc = VERR_OPEN_FAILED;
|
---|
376 | }
|
---|
377 | RTPipeClose(pDevSol->hPipeWakeupR);
|
---|
378 | RTPipeClose(pDevSol->hPipeWakeupW);
|
---|
379 | }
|
---|
380 |
|
---|
381 | RTCritSectDelete(&pDevSol->CritSect);
|
---|
382 | }
|
---|
383 | else
|
---|
384 | LogRel((USBPROXY ": RTCritSectInit failed. rc=%Rrc pszAddress=%s\n", rc, pszAddress));
|
---|
385 | }
|
---|
386 | else
|
---|
387 | LogRel((USBPROXY ": RTStrAPrintf failed. rc=%Rrc pszAddress=%s\n", rc, pszAddress));
|
---|
388 | }
|
---|
389 | else
|
---|
390 | LogRel((USBPROXY ": USBLibInit failed. rc=%Rrc\n", rc));
|
---|
391 |
|
---|
392 | USBLibTerm();
|
---|
393 | return rc;
|
---|
394 | }
|
---|
395 |
|
---|
396 |
|
---|
397 | /**
|
---|
398 | * Close the USB device.
|
---|
399 | *
|
---|
400 | * @param pProxyDev The device instance.
|
---|
401 | */
|
---|
402 | static DECLCALLBACK(void) usbProxySolarisClose(PUSBPROXYDEV pProxyDev)
|
---|
403 | {
|
---|
404 | LogFlow((USBPROXY ":usbProxySolarisClose: pProxyDev=%p\n", pProxyDev));
|
---|
405 |
|
---|
406 | PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL);
|
---|
407 |
|
---|
408 | /* Close the device (do not re-enumerate). */
|
---|
409 | VBOXUSBREQ_CLOSE_DEVICE CloseReq;
|
---|
410 | CloseReq.ResetLevel = VBOXUSB_RESET_LEVEL_CLOSE;
|
---|
411 | usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_CLOSE_DEVICE, &CloseReq, sizeof(CloseReq));
|
---|
412 |
|
---|
413 | pProxyDev->fDetached = true;
|
---|
414 | usbProxySolarisCloseFile(pDevSol);
|
---|
415 |
|
---|
416 | /*
|
---|
417 | * Now we can close it and free all the resources.
|
---|
418 | */
|
---|
419 | RTCritSectDelete(&pDevSol->CritSect);
|
---|
420 |
|
---|
421 | PUSBPROXYURBSOL pUrbSol = NULL;
|
---|
422 | while ((pUrbSol = pDevSol->pInFlightHead) != NULL)
|
---|
423 | {
|
---|
424 | pDevSol->pInFlightHead = pUrbSol->pNext;
|
---|
425 | RTMemFree(pUrbSol);
|
---|
426 | }
|
---|
427 |
|
---|
428 | while ((pUrbSol = pDevSol->pFreeHead) != NULL)
|
---|
429 | {
|
---|
430 | pDevSol->pFreeHead = pUrbSol->pNext;
|
---|
431 | RTMemFree(pUrbSol);
|
---|
432 | }
|
---|
433 |
|
---|
434 | RTPipeClose(pDevSol->hPipeWakeupR);
|
---|
435 | RTPipeClose(pDevSol->hPipeWakeupW);
|
---|
436 |
|
---|
437 | RTStrFree(pDevSol->pszDevicePath);
|
---|
438 | pDevSol->pszDevicePath = NULL;
|
---|
439 |
|
---|
440 | USBLibTerm();
|
---|
441 | }
|
---|
442 |
|
---|
443 |
|
---|
444 | /**
|
---|
445 | * Reset the device.
|
---|
446 | *
|
---|
447 | * @returns VBox status code.
|
---|
448 | * @param pProxyDev The device to reset.
|
---|
449 | * @param fRootHubReset Is this a root hub reset or device specific reset request.
|
---|
450 | */
|
---|
451 | static DECLCALLBACK(int) usbProxySolarisReset(PUSBPROXYDEV pProxyDev, bool fRootHubReset)
|
---|
452 | {
|
---|
453 | LogFlowFunc((USBPROXY ": usbProxySolarisReset: pProxyDev=%s fRootHubReset=%d\n", pProxyDev->pUsbIns->pszName, fRootHubReset));
|
---|
454 |
|
---|
455 | /** Pass all resets to the device. The Trekstor USB (1.1) stick requires this to work. */
|
---|
456 | PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL);
|
---|
457 |
|
---|
458 | /* Soft reset the device. */
|
---|
459 | VBOXUSBREQ_CLOSE_DEVICE CloseReq;
|
---|
460 | CloseReq.ResetLevel = VBOXUSB_RESET_LEVEL_SOFT;
|
---|
461 | int rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_CLOSE_DEVICE, &CloseReq, sizeof(CloseReq));
|
---|
462 | if (RT_SUCCESS(rc))
|
---|
463 | {
|
---|
464 | /* Get the active config. Solaris USBA sets a default config. */
|
---|
465 | usbProxySolarisGetActiveConfig(pDevSol);
|
---|
466 | }
|
---|
467 | else if (rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
|
---|
468 | LogRel((USBPROXY ": usbProxySolarisReset: Failed! rc=%d\n", rc));
|
---|
469 |
|
---|
470 | return rc;
|
---|
471 | }
|
---|
472 |
|
---|
473 |
|
---|
474 | /**
|
---|
475 | * Set the active configuration.
|
---|
476 | *
|
---|
477 | * The caller makes sure that it's not called first time after open or reset
|
---|
478 | * with the active interface.
|
---|
479 | *
|
---|
480 | * @returns success indicator.
|
---|
481 | * @param pProxyDev The device instance data.
|
---|
482 | * @param iCfg The configuration value to set.
|
---|
483 | */
|
---|
484 | static DECLCALLBACK(int) usbProxySolarisSetConfig(PUSBPROXYDEV pProxyDev, int iCfg)
|
---|
485 | {
|
---|
486 | LogFlowFunc((USBPROXY ": usbProxySolarisSetConfig: pProxyDev=%p iCfg=%#x\n", pProxyDev, iCfg));
|
---|
487 |
|
---|
488 | PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL);
|
---|
489 | AssertPtrReturn(pDevSol, VERR_INVALID_POINTER);
|
---|
490 |
|
---|
491 | VBOXUSBREQ_SET_CONFIG SetConfigReq;
|
---|
492 | SetConfigReq.bConfigValue = iCfg;
|
---|
493 | int rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_SET_CONFIG, &SetConfigReq, sizeof(SetConfigReq));
|
---|
494 | if ( RT_FAILURE(rc)
|
---|
495 | && rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
|
---|
496 | LogRel((USBPROXY ": usbProxySolarisSetConfig: Failed! rc=%Rrc\n", rc));
|
---|
497 |
|
---|
498 | return rc;
|
---|
499 | }
|
---|
500 |
|
---|
501 |
|
---|
502 | /**
|
---|
503 | * Claims an interface.
|
---|
504 | *
|
---|
505 | * This is a stub on Solaris since we release/claim all interfaces at
|
---|
506 | * as and when required with endpoint opens.
|
---|
507 | *
|
---|
508 | * @returns success indicator (always true).
|
---|
509 | */
|
---|
510 | static DECLCALLBACK(int) usbProxySolarisClaimInterface(PUSBPROXYDEV pProxyDev, int iIf)
|
---|
511 | {
|
---|
512 | return VINF_SUCCESS;
|
---|
513 | }
|
---|
514 |
|
---|
515 |
|
---|
516 | /**
|
---|
517 | * Releases an interface.
|
---|
518 | *
|
---|
519 | * This is a stub on Solaris since we release/claim all interfaces at
|
---|
520 | * as and when required with endpoint opens.
|
---|
521 | *
|
---|
522 | * @returns success indicator.
|
---|
523 | */
|
---|
524 | static DECLCALLBACK(int) usbProxySolarisReleaseInterface(PUSBPROXYDEV pProxyDev, int iIf)
|
---|
525 | {
|
---|
526 | return VINF_SUCCESS;
|
---|
527 | }
|
---|
528 |
|
---|
529 |
|
---|
530 | /**
|
---|
531 | * Specify an alternate setting for the specified interface of the current configuration.
|
---|
532 | *
|
---|
533 | * @returns success indicator.
|
---|
534 | */
|
---|
535 | static DECLCALLBACK(int) usbProxySolarisSetInterface(PUSBPROXYDEV pProxyDev, int bIf, int bAlt)
|
---|
536 | {
|
---|
537 | LogFlowFunc((USBPROXY ": usbProxySolarisSetInterface: pProxyDev=%p bIf=%#x iAlt=%#x\n", pProxyDev, bIf, bAlt));
|
---|
538 |
|
---|
539 | PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL);
|
---|
540 | AssertPtrReturn(pDevSol, VERR_INVALID_POINTER);
|
---|
541 |
|
---|
542 | VBOXUSBREQ_SET_INTERFACE SetInterfaceReq;
|
---|
543 | SetInterfaceReq.bInterface = bIf;
|
---|
544 | SetInterfaceReq.bAlternate = bAlt;
|
---|
545 | int rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_SET_INTERFACE, &SetInterfaceReq, sizeof(SetInterfaceReq));
|
---|
546 | if ( RT_FAILURE(rc)
|
---|
547 | && rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
|
---|
548 | LogRel((USBPROXY ": usbProxySolarisSetInterface: Failed! rc=%Rrc\n", rc));
|
---|
549 |
|
---|
550 | return rc;
|
---|
551 | }
|
---|
552 |
|
---|
553 |
|
---|
554 | /**
|
---|
555 | * Clears the halted endpoint 'EndPt'.
|
---|
556 | */
|
---|
557 | static DECLCALLBACK(int) usbProxySolarisClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt)
|
---|
558 | {
|
---|
559 | LogFlowFunc((USBPROXY ": usbProxySolarisClearHaltedEp: pProxyDev=%p EndPt=%#x\n", pProxyDev, EndPt));
|
---|
560 |
|
---|
561 | PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL);
|
---|
562 | AssertPtrReturn(pDevSol, VERR_INVALID_POINTER);
|
---|
563 |
|
---|
564 | VBOXUSBREQ_CLEAR_EP ClearEpReq;
|
---|
565 | ClearEpReq.bEndpoint = EndPt;
|
---|
566 | int rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_CLEAR_EP, &ClearEpReq, sizeof(ClearEpReq));
|
---|
567 | if ( RT_FAILURE(rc)
|
---|
568 | && rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
|
---|
569 | LogRel((USBPROXY ": usbProxySolarisClearHaltedEp: Failed! rc=%Rrc\n", rc));
|
---|
570 |
|
---|
571 | return rc;
|
---|
572 | }
|
---|
573 |
|
---|
574 |
|
---|
575 | /**
|
---|
576 | * @interface_method_impl{USBPROXYBACK,pfnUrbQueue}
|
---|
577 | */
|
---|
578 | static DECLCALLBACK(int) usbProxySolarisUrbQueue(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb)
|
---|
579 | {
|
---|
580 | PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL);
|
---|
581 |
|
---|
582 | LogFlowFunc((USBPROXY ": usbProxySolarisUrbQueue: pProxyDev=%s pUrb=%p pszDesc=%s EndPt=%#x enmDir=%d cbData=%d pvData=%p\n",
|
---|
583 | pProxyDev->pUsbIns->pszName, pUrb, pUrb->pszDesc, pUrb->EndPt, pUrb->enmDir, pUrb->cbData, pUrb->abData));
|
---|
584 |
|
---|
585 | PUSBPROXYURBSOL pUrbSol = usbProxySolarisUrbAlloc(pDevSol);
|
---|
586 | if (RT_UNLIKELY(!pUrbSol))
|
---|
587 | {
|
---|
588 | LogRel((USBPROXY ": usbProxySolarisUrbQueue: Failed to allocate URB\n"));
|
---|
589 | return VERR_NO_MEMORY;
|
---|
590 | }
|
---|
591 |
|
---|
592 | pUrbSol->pVUsbUrb = pUrb;
|
---|
593 | pUrbSol->pDevSol = pDevSol;
|
---|
594 |
|
---|
595 | uint8_t EndPt = pUrb->EndPt;
|
---|
596 | if (EndPt)
|
---|
597 | EndPt |= pUrb->enmDir == VUSBDIRECTION_IN ? VUSB_DIR_TO_HOST : VUSB_DIR_TO_DEVICE;
|
---|
598 |
|
---|
599 | VBOXUSBREQ_URB UrbReq;
|
---|
600 | UrbReq.pvUrbR3 = pUrbSol;
|
---|
601 | UrbReq.bEndpoint = EndPt;
|
---|
602 | UrbReq.enmType = pUrb->enmType;
|
---|
603 | UrbReq.enmDir = pUrb->enmDir;
|
---|
604 | UrbReq.enmStatus = pUrb->enmStatus;
|
---|
605 | UrbReq.fShortOk = !pUrb->fShortNotOk;
|
---|
606 | UrbReq.cbData = pUrb->cbData;
|
---|
607 | UrbReq.pvData = &pUrb->abData[0];
|
---|
608 |
|
---|
609 | Log6((USBPROXY ": Sending: EndPt=%#x Dir=%d cbData=%u\n", pUrb->EndPt, pUrb->enmDir, pUrb->cbData));
|
---|
610 |
|
---|
611 | if (pUrb->enmType == VUSBXFERTYPE_ISOC)
|
---|
612 | {
|
---|
613 | UrbReq.cIsocPkts = pUrb->cIsocPkts;
|
---|
614 | for (unsigned i = 0; i < pUrb->cIsocPkts; i++)
|
---|
615 | {
|
---|
616 | UrbReq.aIsocPkts[i].cbPkt = pUrb->aIsocPkts[i].cb;
|
---|
617 | UrbReq.aIsocPkts[i].cbActPkt = 0;
|
---|
618 | UrbReq.aIsocPkts[i].enmStatus = VUSBSTATUS_INVALID;
|
---|
619 | }
|
---|
620 | }
|
---|
621 |
|
---|
622 | int rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_SEND_URB, &UrbReq, sizeof(UrbReq));
|
---|
623 | if (RT_SUCCESS(rc))
|
---|
624 | {
|
---|
625 | if (pUrb->enmType == VUSBXFERTYPE_ISOC)
|
---|
626 | LogFlow((USBPROXY ":usbProxySolarisUrbQueue: Success cbData=%d\n", pUrb->cbData));
|
---|
627 | pUrb->Dev.pvPrivate = pUrbSol;
|
---|
628 | return VINF_SUCCESS;
|
---|
629 | }
|
---|
630 |
|
---|
631 | if (rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
|
---|
632 | {
|
---|
633 | LogRel((USBPROXY ": usbProxySolarisUrbQueue: Failed! pProxyDev=%s pUrb=%p EndPt=%#x bEndpoint=%#x enmType=%d "
|
---|
634 | "enmDir=%d cbData=%u rc=%Rrc\n", pProxyDev->pUsbIns->pszName, pUrb, pUrb->EndPt,
|
---|
635 | UrbReq.bEndpoint, pUrb->enmType, pUrb->enmDir, pUrb->cbData, rc));
|
---|
636 | }
|
---|
637 |
|
---|
638 | return rc;
|
---|
639 | }
|
---|
640 |
|
---|
641 |
|
---|
642 | /**
|
---|
643 | * Cancels a URB.
|
---|
644 | *
|
---|
645 | * The URB requires reaping, so we don't change its state.
|
---|
646 | * @remark There isn't any way to cancel a specific asynchronous request
|
---|
647 | * on Solaris. So we just abort pending URBs on the pipe.
|
---|
648 | */
|
---|
649 | static DECLCALLBACK(int) usbProxySolarisUrbCancel(PUSBPROXYDEV pProxyDev, PVUSBURB pUrb)
|
---|
650 | {
|
---|
651 | PUSBPROXYURBSOL pUrbSol = (PUSBPROXYURBSOL)pUrb->Dev.pvPrivate;
|
---|
652 | PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL);
|
---|
653 | AssertPtrReturn(pDevSol, VERR_INVALID_POINTER);
|
---|
654 |
|
---|
655 | LogFlowFunc((USBPROXY ": usbProxySolarisUrbCancel: pUrb=%p pUrbSol=%p pDevSol=%p\n", pUrb, pUrbSol, pUrbSol->pDevSol));
|
---|
656 |
|
---|
657 | /* Aborting the control pipe isn't supported, pretend success. */
|
---|
658 | if (!pUrb->EndPt)
|
---|
659 | return VINF_SUCCESS;
|
---|
660 |
|
---|
661 | VBOXUSBREQ_ABORT_PIPE AbortPipeReq;
|
---|
662 | AbortPipeReq.bEndpoint = pUrb->EndPt | (pUrb->enmDir == VUSBDIRECTION_IN ? VUSB_DIR_TO_HOST : VUSB_DIR_TO_DEVICE);
|
---|
663 | int rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_ABORT_PIPE, &AbortPipeReq, sizeof(AbortPipeReq));
|
---|
664 | if ( RT_FAILURE(rc)
|
---|
665 | && rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
|
---|
666 | LogRel((USBPROXY ": usbProxySolarisUrbCancel: Failed to abort pipe. rc=%Rrc\n", rc));
|
---|
667 |
|
---|
668 | LogFlow((USBPROXY ": usbProxySolarisUrbCancel: returns rc=%Rrc\n", rc));
|
---|
669 | return rc;
|
---|
670 | }
|
---|
671 |
|
---|
672 |
|
---|
673 | /**
|
---|
674 | * Reap URBs in-flight on a device.
|
---|
675 | *
|
---|
676 | * @returns Pointer to a completed URB.
|
---|
677 | * @returns NULL if no URB was completed.
|
---|
678 | * @param pProxyDev The device.
|
---|
679 | * @param cMillies Number of milliseconds to wait. Use 0 to not wait at all.
|
---|
680 | */
|
---|
681 | static DECLCALLBACK(PVUSBURB) usbProxySolarisUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies)
|
---|
682 | {
|
---|
683 | LogFlowFunc((USBPROXY ":usbProxySolarisUrbReap pProxyDev=%p cMillies=%u\n", pProxyDev, cMillies));
|
---|
684 |
|
---|
685 | PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL);
|
---|
686 |
|
---|
687 | /*
|
---|
688 | * Don't block if nothing is in the air.
|
---|
689 | */
|
---|
690 | if (!pDevSol->pInFlightHead)
|
---|
691 | return NULL;
|
---|
692 |
|
---|
693 | /*
|
---|
694 | * Deque URBs inflight or those landed.
|
---|
695 | */
|
---|
696 | if (cMillies > 0)
|
---|
697 | {
|
---|
698 | for (;;)
|
---|
699 | {
|
---|
700 | int cMilliesWait = cMillies == RT_INDEFINITE_WAIT ? -1 : (int)cMillies;
|
---|
701 |
|
---|
702 | struct pollfd aFd[2];
|
---|
703 | size_t const cFds = RT_ELEMENTS(aFd);
|
---|
704 |
|
---|
705 | aFd[0].fd = RTFileToNative(pDevSol->hFile);
|
---|
706 | aFd[0].events = POLLIN;
|
---|
707 | aFd[0].revents = 0;
|
---|
708 |
|
---|
709 | aFd[1].fd = RTPipeToNative(pDevSol->hPipeWakeupR);
|
---|
710 | aFd[1].events = POLLIN;
|
---|
711 | aFd[1].revents = 0;
|
---|
712 |
|
---|
713 | int rc = poll(&aFd[0], cFds, cMilliesWait);
|
---|
714 | if (rc > 0)
|
---|
715 | {
|
---|
716 | if (aFd[0].revents & POLLHUP)
|
---|
717 | {
|
---|
718 | LogRel((USBPROXY ": USB Device '%s' disconnected!\n", pDevSol->pProxyDev->pUsbIns->pszName));
|
---|
719 | pProxyDev->fDetached = true;
|
---|
720 | usbProxySolarisCloseFile(pDevSol);
|
---|
721 | }
|
---|
722 |
|
---|
723 | if (aFd[1].revents & POLLIN)
|
---|
724 | {
|
---|
725 | /* Got woken up, drain pipe. */
|
---|
726 | uint8_t bRead;
|
---|
727 | size_t cbIgnored = 0;
|
---|
728 | RTPipeRead(pDevSol->hPipeWakeupR, &bRead, 1, &cbIgnored);
|
---|
729 |
|
---|
730 | /*
|
---|
731 | * It is possible that we got woken up and have an URB pending
|
---|
732 | * for completion. Do it on the way out. Otherwise return
|
---|
733 | * immediately to the caller.
|
---|
734 | */
|
---|
735 | if (!(aFd[0].revents & POLLIN))
|
---|
736 | return NULL;
|
---|
737 | }
|
---|
738 | break;
|
---|
739 | }
|
---|
740 | else if (rc == 0)
|
---|
741 | return NULL;
|
---|
742 | else if (errno != EAGAIN)
|
---|
743 | {
|
---|
744 | LogFlow((USBPROXY ":usbProxySolarisUrbReap Poll rc=%d errno=%d\n", rc, errno));
|
---|
745 | return NULL;
|
---|
746 | }
|
---|
747 | }
|
---|
748 | }
|
---|
749 |
|
---|
750 | usbProxySolarisUrbComplete(pDevSol);
|
---|
751 |
|
---|
752 | /*
|
---|
753 | * Any URBs pending delivery?
|
---|
754 | */
|
---|
755 | PVUSBURB pUrb = NULL;
|
---|
756 | while ( pDevSol->pTaxingHead
|
---|
757 | && !pUrb)
|
---|
758 | {
|
---|
759 | RTCritSectEnter(&pDevSol->CritSect);
|
---|
760 |
|
---|
761 | PUSBPROXYURBSOL pUrbSol = pDevSol->pTaxingHead;
|
---|
762 | if (pUrbSol)
|
---|
763 | {
|
---|
764 | pUrb = pUrbSol->pVUsbUrb;
|
---|
765 | if (pUrb)
|
---|
766 | {
|
---|
767 | /*
|
---|
768 | * Remove it from the taxing list and move it to the free list.
|
---|
769 | */
|
---|
770 | pUrb->Dev.pvPrivate = NULL;
|
---|
771 | usbProxySolarisUrbFree(pDevSol, pUrbSol);
|
---|
772 | }
|
---|
773 | }
|
---|
774 | RTCritSectLeave(&pDevSol->CritSect);
|
---|
775 | }
|
---|
776 |
|
---|
777 | return pUrb;
|
---|
778 | }
|
---|
779 |
|
---|
780 |
|
---|
781 | /**
|
---|
782 | * Reads a completed/error'd URB from the client driver (no waiting).
|
---|
783 | *
|
---|
784 | * @param pDevSol The Solaris device instance.
|
---|
785 | */
|
---|
786 | static PVUSBURB usbProxySolarisUrbComplete(PUSBPROXYDEVSOL pDevSol)
|
---|
787 | {
|
---|
788 | LogFlowFunc((USBPROXY ": usbProxySolarisUrbComplete: pDevSol=%p\n", pDevSol));
|
---|
789 |
|
---|
790 | VBOXUSBREQ_URB UrbReq;
|
---|
791 | bzero(&UrbReq, sizeof(UrbReq));
|
---|
792 |
|
---|
793 | int rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_REAP_URB, &UrbReq, sizeof(UrbReq));
|
---|
794 | if (RT_SUCCESS(rc))
|
---|
795 | {
|
---|
796 | if (UrbReq.pvUrbR3)
|
---|
797 | {
|
---|
798 | PUSBPROXYURBSOL pUrbSol = (PUSBPROXYURBSOL)UrbReq.pvUrbR3;
|
---|
799 | PVUSBURB pUrb = pUrbSol->pVUsbUrb;
|
---|
800 | if (RT_LIKELY(pUrb))
|
---|
801 | {
|
---|
802 | Assert(pUrb->u32Magic == VUSBURB_MAGIC);
|
---|
803 |
|
---|
804 | /*
|
---|
805 | * Update the URB.
|
---|
806 | */
|
---|
807 | if ( pUrb->enmType == VUSBXFERTYPE_ISOC
|
---|
808 | && pUrb->enmDir == VUSBDIRECTION_IN)
|
---|
809 | {
|
---|
810 | size_t cbData = 0;
|
---|
811 | for (unsigned i = 0; i < UrbReq.cIsocPkts; i++)
|
---|
812 | {
|
---|
813 | pUrb->aIsocPkts[i].cb = UrbReq.aIsocPkts[i].cbActPkt;
|
---|
814 | cbData += UrbReq.aIsocPkts[i].cbActPkt;
|
---|
815 | pUrb->aIsocPkts[i].enmStatus = UrbReq.aIsocPkts[i].enmStatus;
|
---|
816 | }
|
---|
817 |
|
---|
818 | LogFlow((USBPROXY ":usbProxySolarisUrbComplete: Isoc cbData=%d cbActPktSum=%d\n", pUrb->cbData, cbData));
|
---|
819 | pUrb->cbData = cbData;
|
---|
820 | pUrb->enmStatus = UrbReq.enmStatus;
|
---|
821 | }
|
---|
822 | else
|
---|
823 | {
|
---|
824 | pUrb->cbData = UrbReq.cbData;
|
---|
825 | pUrb->enmStatus = UrbReq.enmStatus;
|
---|
826 | }
|
---|
827 |
|
---|
828 | RTCritSectEnter(&pDevSol->CritSect);
|
---|
829 |
|
---|
830 | /*
|
---|
831 | * Remove from the active list.
|
---|
832 | */
|
---|
833 | if (pUrbSol->pNext)
|
---|
834 | pUrbSol->pNext->pPrev = pUrbSol->pPrev;
|
---|
835 | if (pUrbSol->pPrev)
|
---|
836 | pUrbSol->pPrev->pNext = pUrbSol->pNext;
|
---|
837 | else
|
---|
838 | {
|
---|
839 | Assert(pDevSol->pInFlightHead == pUrbSol);
|
---|
840 | pDevSol->pInFlightHead = pUrbSol->pNext;
|
---|
841 | }
|
---|
842 |
|
---|
843 | /*
|
---|
844 | * Add to the tail of the taxing list.
|
---|
845 | */
|
---|
846 | pUrbSol->pNext = NULL;
|
---|
847 | pUrbSol->pPrev = pDevSol->pTaxingTail;
|
---|
848 | if (pDevSol->pTaxingTail)
|
---|
849 | pDevSol->pTaxingTail->pNext = pUrbSol;
|
---|
850 | else
|
---|
851 | pDevSol->pTaxingHead = pUrbSol;
|
---|
852 | pDevSol->pTaxingTail = pUrbSol;
|
---|
853 |
|
---|
854 | RTCritSectLeave(&pDevSol->CritSect);
|
---|
855 |
|
---|
856 | Log6((USBPROXY ": Reaping: EndPt=%#x Dir=%d cbData=%u\n", pUrb->EndPt, pUrb->enmDir, pUrb->cbData));
|
---|
857 | if (pUrb->cbData < 1024)
|
---|
858 | Log6(("%.*Rhxd\n", pUrb->cbData, pUrb->abData));
|
---|
859 | return pUrb;
|
---|
860 | }
|
---|
861 | }
|
---|
862 | }
|
---|
863 | else
|
---|
864 | {
|
---|
865 | if (rc != VERR_VUSB_DEVICE_NOT_ATTACHED)
|
---|
866 | LogRel((USBPROXY ": Reaping URB failed. rc=%Rrc\n", rc));
|
---|
867 | }
|
---|
868 |
|
---|
869 | return NULL;
|
---|
870 | }
|
---|
871 |
|
---|
872 |
|
---|
873 | static DECLCALLBACK(int) usbProxySolarisWakeup(PUSBPROXYDEV pProxyDev)
|
---|
874 | {
|
---|
875 | PUSBPROXYDEVSOL pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL);
|
---|
876 | size_t cbIgnored;
|
---|
877 |
|
---|
878 | LogFlowFunc(("pProxyDev=%p\n", pProxyDev));
|
---|
879 |
|
---|
880 | return RTPipeWrite(pDevSol->hPipeWakeupW, "", 1, &cbIgnored);
|
---|
881 | }
|
---|
882 |
|
---|
883 |
|
---|
884 | /**
|
---|
885 | * The Solaris USB Proxy Backend.
|
---|
886 | */
|
---|
887 | extern const USBPROXYBACK g_USBProxyDeviceHost =
|
---|
888 | {
|
---|
889 | /* pszName */
|
---|
890 | "host",
|
---|
891 | /* cbBackend */
|
---|
892 | sizeof(USBPROXYDEVSOL),
|
---|
893 | usbProxySolarisOpen,
|
---|
894 | NULL,
|
---|
895 | usbProxySolarisClose,
|
---|
896 | usbProxySolarisReset,
|
---|
897 | usbProxySolarisSetConfig,
|
---|
898 | usbProxySolarisClaimInterface,
|
---|
899 | usbProxySolarisReleaseInterface,
|
---|
900 | usbProxySolarisSetInterface,
|
---|
901 | usbProxySolarisClearHaltedEp,
|
---|
902 | usbProxySolarisUrbQueue,
|
---|
903 | usbProxySolarisUrbCancel,
|
---|
904 | usbProxySolarisUrbReap,
|
---|
905 | usbProxySolarisWakeup,
|
---|
906 | 0
|
---|
907 | };
|
---|
908 |
|
---|