Changeset 50228 in vbox for trunk/src/VBox/Devices/USB/solaris
- Timestamp:
- Jan 24, 2014 9:16:37 PM (11 years ago)
- svn:sync-xref-src-repo-rev:
- 91829
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/USB/solaris/USBProxyDevice-solaris.cpp
r49816 r50228 5 5 6 6 /* 7 * Copyright (C) 2009-201 3Oracle Corporation7 * Copyright (C) 2009-2014 Oracle Corporation 8 8 * 9 9 * This file is part of VirtualBox Open Source Edition (OSE), as … … 92 92 /** The tail of the landed solaris URBs. */ 93 93 PUSBPROXYURBSOL pTaxingTail; 94 /** Pipe handle for wa iking up - writing end. */94 /** Pipe handle for waking up - writing end. */ 95 95 RTPIPE hPipeWakeupW; 96 /** Pipe handle for wa iking up - reading end. */96 /** Pipe handle for waking up - reading end. */ 97 97 RTPIPE hPipeWakeupR; 98 98 } USBPROXYDEVSOL, *PUSBPROXYDEVSOL; … … 288 288 * @param pvBackend Backend specific pointer, unused for the solaris backend. 289 289 */ 290 static int usbProxySolarisOpen(PUSBPROXYDEV pProxyDev, const char *pszAddress, void *pvBackend) 291 { 290 static DECLCALLBACK(int) usbProxySolarisOpen(PUSBPROXYDEV pProxyDev, const char *pszAddress, void *pvBackend) 291 { 292 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 293 292 294 LogFlowFunc((USBPROXY ":usbProxySolarisOpen pProxyDev=%p pszAddress=%s pvBackend=%p\n", pProxyDev, pszAddress, pvBackend)); 293 295 … … 301 303 * Allocate and initialize the solaris backend data. 302 304 */ 303 PUSBPROXYDEVSOL pDevSol = (PUSBPROXYDEVSOL)RTMemAllocZ(sizeof(*pDevSol)); 304 if (RT_LIKELY(pDevSol)) 305 AssertCompile(PATH_MAX >= MAXPATHLEN); 306 char szDeviceIdent[PATH_MAX+48]; 307 rc = RTStrPrintf(szDeviceIdent, sizeof(szDeviceIdent), "%s", pszAddress); 308 if (RT_SUCCESS(rc)) 305 309 { 306 AssertCompile(PATH_MAX >= MAXPATHLEN); 307 char szDeviceIdent[PATH_MAX+48]; 308 rc = RTStrPrintf(szDeviceIdent, sizeof(szDeviceIdent), "%s", pszAddress); 310 rc = RTCritSectInit(&pDevSol->CritSect); 309 311 if (RT_SUCCESS(rc)) 310 312 { 311 rc = RTCritSectInit(&pDevSol->CritSect); 313 /* 314 * Create wakeup pipe. 315 */ 316 rc = RTPipeCreate(&pDevSol->hPipeWakeupR, &pDevSol->hPipeWakeupW, 0); 312 317 if (RT_SUCCESS(rc)) 313 318 { 314 pProxyDev->Backend.pv = pDevSol; 315 316 /* 317 * Create wakeup pipe. 318 */ 319 rc = RTPipeCreate(&pDevSol->hPipeWakeupR, &pDevSol->hPipeWakeupW, 0); 319 int Instance; 320 char *pszDevicePath = NULL; 321 rc = USBLibGetClientInfo(szDeviceIdent, &pszDevicePath, &Instance); 320 322 if (RT_SUCCESS(rc)) 321 323 { 322 int Instance; 323 char *pszDevicePath = NULL; 324 rc = USBLibGetClientInfo(szDeviceIdent, &pszDevicePath, &Instance); 324 pDevSol->pszDevicePath = pszDevicePath; 325 326 /* 327 * Open the client driver. 328 */ 329 RTFILE hFile; 330 rc = RTFileOpen(&hFile, pDevSol->pszDevicePath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 325 331 if (RT_SUCCESS(rc)) 326 332 { 327 pDevSol->pszDevicePath = pszDevicePath; 333 pDevSol->hFile = hFile; 334 pDevSol->pProxyDev = pProxyDev; 328 335 329 336 /* 330 * Open the client driver.337 * Verify client driver version. 331 338 */ 332 RTFILE hFile; 333 rc = RTFileOpen(&hFile, pDevSol->pszDevicePath, RTFILE_O_READWRITE | RTFILE_O_OPEN | RTFILE_O_DENY_NONE); 339 VBOXUSBREQ_GET_VERSION GetVersionReq; 340 bzero(&GetVersionReq, sizeof(GetVersionReq)); 341 rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_GET_VERSION, &GetVersionReq, sizeof(GetVersionReq)); 334 342 if (RT_SUCCESS(rc)) 335 343 { 336 pDevSol->hFile = hFile; 337 pDevSol->pProxyDev = pProxyDev; 338 339 /* 340 * Verify client driver version. 341 */ 342 VBOXUSBREQ_GET_VERSION GetVersionReq; 343 bzero(&GetVersionReq, sizeof(GetVersionReq)); 344 rc = usbProxySolarisIOCtl(pDevSol, VBOXUSB_IOCTL_GET_VERSION, &GetVersionReq, sizeof(GetVersionReq)); 345 if (RT_SUCCESS(rc)) 344 if ( GetVersionReq.u32Major == VBOXUSB_VERSION_MAJOR 345 && GetVersionReq.u32Minor >= VBOXUSB_VERSION_MINOR) 346 346 { 347 if ( GetVersionReq.u32Major == VBOXUSB_VERSION_MAJOR 348 && GetVersionReq.u32Minor >= VBOXUSB_VERSION_MINOR) 349 { 350 /* 351 * Try & get the current cached config from Solaris. 352 */ 353 usbProxySolarisGetActiveConfig(pDevSol); 354 return VINF_SUCCESS; 355 } 356 else 357 { 358 LogRel((USBPROXY ":version mismatch! driver v%d.%d expecting ~v%d.%d\n", GetVersionReq.u32Major, 359 GetVersionReq.u32Minor, VBOXUSB_VERSION_MAJOR, VBOXUSB_VERSION_MINOR)); 360 rc = VERR_VERSION_MISMATCH; 361 } 347 /* 348 * Try & get the current cached config from Solaris. 349 */ 350 usbProxySolarisGetActiveConfig(pDevSol); 351 return VINF_SUCCESS; 362 352 } 363 353 else 364 354 { 365 LogRel((USBPROXY ":failed to query driver version. rc=%Rrc\n", rc)); 355 LogRel((USBPROXY ":version mismatch! driver v%d.%d expecting ~v%d.%d\n", GetVersionReq.u32Major, 356 GetVersionReq.u32Minor, VBOXUSB_VERSION_MAJOR, VBOXUSB_VERSION_MINOR)); 357 rc = VERR_VERSION_MISMATCH; 366 358 } 367 368 RTFileClose(pDevSol->hFile);369 pDevSol->hFile = NIL_RTFILE;370 pDevSol->pProxyDev = NULL;371 359 } 372 360 else 373 LogRel((USBPROXY ":failed to open device. rc=%Rrc pszDevicePath=%s\n", rc, pDevSol->pszDevicePath)); 374 375 RTStrFree(pDevSol->pszDevicePath); 376 pDevSol->pszDevicePath = NULL; 361 LogRel((USBPROXY ":failed to query driver version. rc=%Rrc\n", rc)); 362 363 RTFileClose(pDevSol->hFile); 364 pDevSol->hFile = NIL_RTFILE; 365 pDevSol->pProxyDev = NULL; 377 366 } 378 367 else 379 { 380 LogRel((USBPROXY ":failed to get client info. rc=%Rrc pszDevicePath=%s\n", rc, pDevSol->pszDevicePath)); 381 if (rc == VERR_NOT_FOUND) 382 rc = VERR_OPEN_FAILED; 383 } 384 RTPipeClose(pDevSol->hPipeWakeupR); 385 RTPipeClose(pDevSol->hPipeWakeupW); 368 LogRel((USBPROXY ":failed to open device. rc=%Rrc pszDevicePath=%s\n", rc, pDevSol->pszDevicePath)); 369 370 RTStrFree(pDevSol->pszDevicePath); 371 pDevSol->pszDevicePath = NULL; 386 372 } 387 388 RTCritSectDelete(&pDevSol->CritSect); 373 else 374 { 375 LogRel((USBPROXY ":failed to get client info. rc=%Rrc pszDevicePath=%s\n", rc, pDevSol->pszDevicePath)); 376 if (rc == VERR_NOT_FOUND) 377 rc = VERR_OPEN_FAILED; 378 } 379 RTPipeClose(pDevSol->hPipeWakeupR); 380 RTPipeClose(pDevSol->hPipeWakeupW); 389 381 } 390 else 391 LogRel((USBPROXY ":RTCritSectInit failed. rc=%Rrc pszAddress=%s\n", rc, pszAddress));382 383 RTCritSectDelete(&pDevSol->CritSect); 392 384 } 393 385 else 394 LogRel((USBPROXY ":RTStrAPrintf failed. rc=%Rrc pszAddress=%s\n", rc, pszAddress)); 395 396 RTMemFree(pDevSol); 397 pDevSol = NULL; 386 LogRel((USBPROXY ":RTCritSectInit failed. rc=%Rrc pszAddress=%s\n", rc, pszAddress)); 398 387 } 399 388 else 400 rc = VERR_NO_MEMORY;389 LogRel((USBPROXY ":RTStrAPrintf failed. rc=%Rrc pszAddress=%s\n", rc, pszAddress)); 401 390 } 402 391 else … … 404 393 405 394 USBLibTerm(); 406 pProxyDev->Backend.pv = NULL;407 395 return rc; 408 396 } … … 414 402 * @param pProxyDev The device instance. 415 403 */ 416 static voidusbProxySolarisClose(PUSBPROXYDEV pProxyDev)404 static DECLCALLBACK(void) usbProxySolarisClose(PUSBPROXYDEV pProxyDev) 417 405 { 418 406 LogFlow((USBPROXY ":usbProxySolarisClose: pProxyDev=%p\n", pProxyDev)); 419 407 420 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;408 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 421 409 422 410 /* Close the device (do not re-enumerate). */ … … 452 440 pDevSol->pszDevicePath = NULL; 453 441 454 RTMemFree(pDevSol);455 pProxyDev->Backend.pv = NULL;456 457 442 USBLibTerm(); 458 443 } … … 466 451 * @param fRootHubReset Is this a root hub reset or device specific reset request. 467 452 */ 468 static intusbProxySolarisReset(PUSBPROXYDEV pProxyDev, bool fRootHubReset)453 static DECLCALLBACK(int) usbProxySolarisReset(PUSBPROXYDEV pProxyDev, bool fRootHubReset) 469 454 { 470 455 LogFlowFunc((USBPROXY ":usbProxySolarisReset pProxyDev=%s fRootHubReset=%d\n", pProxyDev->pUsbIns->pszName, fRootHubReset)); 471 456 472 457 /** Pass all resets to the device. The Trekstor USB (1.1) stick requires this to work. */ 473 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;458 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 474 459 475 460 /* Soft reset the device. */ … … 499 484 * @param iCfg The configuration value to set. 500 485 */ 501 static intusbProxySolarisSetConfig(PUSBPROXYDEV pProxyDev, int iCfg)486 static DECLCALLBACK(int) usbProxySolarisSetConfig(PUSBPROXYDEV pProxyDev, int iCfg) 502 487 { 503 488 LogFlowFunc((USBPROXY ":usbProxySolarisSetConfig: pProxyDev=%p iCfg=%#x\n", pProxyDev, iCfg)); 504 489 505 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;490 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 506 491 AssertPtrReturn(pDevSol, VERR_INVALID_POINTER); 507 492 … … 527 512 * @returns success indicator (always true). 528 513 */ 529 static intusbProxySolarisClaimInterface(PUSBPROXYDEV pProxyDev, int iIf)514 static DECLCALLBACK(int) usbProxySolarisClaimInterface(PUSBPROXYDEV pProxyDev, int iIf) 530 515 { 531 516 return true; … … 541 526 * @returns success indicator. 542 527 */ 543 static intusbProxySolarisReleaseInterface(PUSBPROXYDEV pProxyDev, int iIf)528 static DECLCALLBACK(int) usbProxySolarisReleaseInterface(PUSBPROXYDEV pProxyDev, int iIf) 544 529 { 545 530 return true; … … 552 537 * @returns success indicator. 553 538 */ 554 static intusbProxySolarisSetInterface(PUSBPROXYDEV pProxyDev, int iIf, int iAlt)539 static DECLCALLBACK(int) usbProxySolarisSetInterface(PUSBPROXYDEV pProxyDev, int iIf, int iAlt) 555 540 { 556 541 LogFlowFunc((USBPROXY ":usbProxySolarisSetInterface: pProxyDev=%p iIf=%d iAlt=%d\n", pProxyDev, iIf, iAlt)); 557 542 558 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;543 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 559 544 AssertPtrReturn(pDevSol, VERR_INVALID_POINTER); 560 545 … … 576 561 * Clears the halted endpoint 'EndPt'. 577 562 */ 578 static boolusbProxySolarisClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt)563 static DECLCALLBACK(bool) usbProxySolarisClearHaltedEp(PUSBPROXYDEV pProxyDev, unsigned int EndPt) 579 564 { 580 565 LogFlowFunc((USBPROXY ":usbProxySolarisClearHaltedEp pProxyDev=%p EndPt=%#x\n", pProxyDev, EndPt)); 581 566 582 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;567 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 583 568 AssertPtrReturn(pDevSol, VERR_INVALID_POINTER); 584 569 … … 599 584 * @copydoc USBPROXYBACK::pfnUrbQueue 600 585 */ 601 static intusbProxySolarisUrbQueue(PVUSBURB pUrb)586 static DECLCALLBACK(int) usbProxySolarisUrbQueue(PVUSBURB pUrb) 602 587 { 603 588 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); 604 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;589 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 605 590 606 591 LogFlowFunc((USBPROXY ": usbProxySolarisUrbQueue: pProxyDev=%s pUrb=%p EndPt=%#x enmDir=%d cbData=%d pvData=%p\n", … … 665 650 * on Solaris. So we just abort pending URBs on the pipe. 666 651 */ 667 static voidusbProxySolarisUrbCancel(PVUSBURB pUrb)652 static DECLCALLBACK(void) usbProxySolarisUrbCancel(PVUSBURB pUrb) 668 653 { 669 654 PUSBPROXYURBSOL pUrbSol = (PUSBPROXYURBSOL)pUrb->Dev.pvPrivate; 670 655 671 656 PUSBPROXYDEV pProxyDev = PDMINS_2_DATA(pUrb->pUsbIns, PUSBPROXYDEV); 672 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;657 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 673 658 AssertPtrReturnVoid(pDevSol); 674 659 … … 701 686 * @param cMillies Number of milliseconds to wait. Use 0 to not wait at all. 702 687 */ 703 static PVUSBURBusbProxySolarisUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies)688 static DECLCALLBACK(PVUSBURB) usbProxySolarisUrbReap(PUSBPROXYDEV pProxyDev, RTMSINTERVAL cMillies) 704 689 { 705 690 //LogFlowFunc((USBPROXY ":usbProxySolarisUrbReap pProxyDev=%p cMillies=%u\n", pProxyDev, cMillies)); 706 691 707 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;692 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 708 693 709 694 /* … … 805 790 * @param pDevSol The Solaris device instance. 806 791 */ 807 PVUSBURB usbProxySolarisUrbComplete(PUSBPROXYDEVSOL pDevSol)792 static PVUSBURB usbProxySolarisUrbComplete(PUSBPROXYDEVSOL pDevSol) 808 793 { 809 794 LogFlowFunc((USBPROXY ":usbProxySolarisUrbComplete pDevSol=%p\n", pDevSol)); … … 895 880 static DECLCALLBACK(int) usbProxySolarisWakeup(PUSBPROXYDEV pProxyDev) 896 881 { 897 PUSBPROXYDEV SOL pDevSol = (PUSBPROXYDEVSOL)pProxyDev->Backend.pv;882 PUSBPROXYDEVFBSD pDevSol = USBPROXYDEV_2_DATA(pProxyDev, PUSBPROXYDEVSOL); 898 883 size_t cbIgnored; 899 884 … … 909 894 extern const USBPROXYBACK g_USBProxyDeviceHost = 910 895 { 896 /* pszName */ 911 897 "host", 898 /* cbBackend */ 899 sizeof(USBPROXYDEVSOL), 912 900 usbProxySolarisOpen, 913 901 NULL,
Note:
See TracChangeset
for help on using the changeset viewer.