VirtualBox

Ignore:
Timestamp:
Oct 26, 2007 4:29:13 PM (17 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
25737
Message:

PDMUsb

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Main/ConsoleImpl.cpp

    r5390 r5520  
    6969#include <VBox/ssm.h>
    7070#include <VBox/version.h>
     71#ifdef VBOX_WITH_USB
     72#   include <VBox/pdmusb.h>
     73#endif
    7174
    7275#include <VBox/VBoxDev.h>
     
    33913394    }
    33923395
    3393 #if 1
     3396#ifndef VBOX_WITH_PDMUSB
    33943397    /* Don't proceed unless we've found the usb controller. */
    33953398    PPDMIBASE pBase = NULL;
     
    34073410    HRESULT rc = attachUSBDevice (aDevice, pRhConfig);
    34083411#else /* PDMUsb */
    3409     /* Don't proceed unless there's a USB hub. */
    3410     if (!PDMR3USBHasHub (m_VM))
     3412    /* Don't proceed unless there's at least one USB hub. */
     3413    if (!PDMR3USBHasHub (mpVM))
    34113414    {
    34123415        LogFlowThisFunc (("Attach request ignored (no USB controller).\n"));
     
    39233926        alock.enter();
    39243927    }
    3925    
    3926    
     3928
     3929
    39273930#ifdef VBOX_HGCM
    39283931    /*
     
    46904693 *  @note Must be called from under this object's lock.
    46914694 */
    4692 #if 1
     4695#ifndef VBOX_WITH_PDMUSB
    46934696HRESULT Console::attachUSBDevice (IUSBDevice *aHostDevice, PVUSBIRHCONFIG aConfig)
    46944697{
     
    47224725
    47234726    BOOL fRemote = FALSE;
     4727#ifndef VBOX_WITH_PDMUSB
    47244728    void *pvRemote = NULL;
     4729#endif
    47254730
    47264731    hrc = aHostDevice->COMGETTER (Remote) (&fRemote);
     
    47374742    alock.leave();
    47384743
    4739 #if 1
     4744#ifndef VBOX_WITH_PDMUSB
    47404745    PVMREQ pReq = NULL;
    47414746    int vrc = VMR3ReqCall (mpVM, &pReq, RT_INDEFINITE_WAIT,
     
    47444749                           aConfig, Uuid.ptr(), fRemote, Address.raw(), pvRemote);
    47454750#else /* PDMUsb */
     4751/**@todo just do everything here */
    47464752    PVMREQ pReq = NULL;
    47474753    int vrc = VMR3ReqCall (mpVM, &pReq, RT_INDEFINITE_WAIT,
    4748                            (PFNRT) usbAttachCallback, 5, this, aHostDevice, aConfig, Uuid.ptr(), fRemote, Address.raw());
     4754                           (PFNRT) usbAttachCallback, 5, this, aHostDevice, Uuid.ptr(), fRemote, Address.raw());
    47494755#endif /* PDMUsb */
    47504756    if (VBOX_SUCCESS (vrc))
     
    47914797 *  @note Locks the console object for writing.
    47924798 */
    4793 #if 1
     4799#ifndef VBOX_WITH_PDMUSB
    47944800DECLCALLBACK(int)
    47954801Console::usbAttachCallback (Console *that, IUSBDevice *aHostDevice,
     
    48514857    LogFlowFunc (("that={%p}\n", that));
    48524858
    4853     AssertReturn (that && aConfig && aUuid, VERR_INVALID_PARAMETER);
    4854 
     4859    AssertReturn (that && aUuid, VERR_INVALID_PARAMETER);
     4860
     4861    void *pvRemoteBackend = NULL;
    48554862    if (aRemote)
    48564863    {
     
    48584865        Guid guid (*aUuid);
    48594866
    4860         aRemoteBackend = that->consoleVRDPServer ()->USBBackendRequestPointer (pRemoteUSBDevice->clientId (), &guid);
    4861         if (!aRemoteBackend)
     4867        pvRemoteBackend = that->consoleVRDPServer ()->USBBackendRequestPointer (pRemoteUSBDevice->clientId (), &guid);
     4868        if (!pvRemoteBackend)
    48624869            return VERR_INVALID_PARAMETER;  /* The clientId is invalid then. */
    48634870    }
    4864 
    4865     int vrc = PDMR3USBCreateProxyDevice (mVM, aUuid, aRemote, aAddress, aRemoteBackend);
     4871    ULONG ulUSBVersion = 0x00010001; /* 1.1 */
     4872#if 0
     4873    HRESULT hrc = aHostDevice->GetUSBVersion(&ulUSBVersion);
     4874    AssertComRCReturn(hrc, VERR_GENERAL_FAILURE);
     4875#endif
     4876    Assert(ulUSBVersion == 0x00010001 || ulUSBVersion == 0x00020000);
     4877
     4878    int vrc = PDMR3USBCreateProxyDevice (that->mpVM, aUuid, aRemote, aAddress, pvRemoteBackend,
     4879                                         ulUSBVersion == 0x00010001 ? VUSB_STDVER_11 : VUSB_STDVER_20);
    48664880    if (VBOX_SUCCESS (vrc))
    48674881    {
     
    49074921    CheckComRCReturnRC (autoVMCaller.rc());
    49084922
     4923#ifndef VBOX_WITH_PDMUSB
    49094924    PPDMIBASE pBase = NULL;
    49104925    int vrc = PDMR3QueryLun (mpVM, "usb-ohci", 0, 0, &pBase);
     
    49164931        pfnQueryInterface (pBase, PDMINTERFACE_VUSB_RH_CONFIG);
    49174932    AssertReturn (pRhConfig, E_FAIL);
     4933#else
     4934    /* if the device is attached, then there must at least one USB hub. */
     4935    AssertReturn (PDMR3USBHasHub (mpVM), E_FAIL);
     4936#endif
    49184937
    49194938    LogFlowThisFunc (("Detaching USB proxy device {%Vuuid}...\n",
     
    49244943
    49254944    PVMREQ pReq;
     4945#ifndef VBOX_WITH_PDMUSB
    49264946    vrc = VMR3ReqCall (mpVM, &pReq, RT_INDEFINITE_WAIT,
    49274947                       (PFNRT) usbDetachCallback, 5,
    49284948                       this, &aIt, pRhConfig, (*aIt)->id().raw());
     4949#else
     4950/** @todo just do everything here */
     4951    int vrc = VMR3ReqCall (mpVM, &pReq, RT_INDEFINITE_WAIT,
     4952                           (PFNRT) usbDetachCallback, 4,
     4953                           this, &aIt, (*aIt)->id().raw());
     4954#endif
    49294955    if (VBOX_SUCCESS (vrc))
    49304956        vrc = pReq->iStatus;
     
    49454971 *  @note Locks the console object for writing.
    49464972 */
     4973#ifndef VBOX_WITH_PDMUSB
    49474974//static
    49484975DECLCALLBACK(int)
     
    49885015    return vrc;
    49895016}
     5017#else /* VBOX_WITH_PDMUSB */
     5018//static
     5019DECLCALLBACK(int)
     5020Console::usbDetachCallback (Console *that, USBDeviceList::iterator *aIt, PCRTUUID aUuid)
     5021{
     5022    LogFlowFuncEnter();
     5023    LogFlowFunc (("that={%p}\n", that));
     5024
     5025    AssertReturn (that && aUuid, VERR_INVALID_PARAMETER);
     5026
     5027    /*
     5028     * If that was a remote device, release the backend pointer.
     5029     * The pointer was requested in usbAttachCallback.
     5030     */
     5031    BOOL fRemote = FALSE;
     5032
     5033    HRESULT hrc2 = (**aIt)->COMGETTER (Remote) (&fRemote);
     5034    ComAssertComRC (hrc2);
     5035
     5036    if (fRemote)
     5037    {
     5038        Guid guid (*aUuid);
     5039        that->consoleVRDPServer ()->USBBackendReleasePointer (&guid);
     5040    }
     5041
     5042    int vrc = PDMR3USBDetachDevice (that->mpVM, aUuid);
     5043
     5044    if (VBOX_SUCCESS (vrc))
     5045    {
     5046        AutoLock alock (that);
     5047
     5048        /* Remove the device from the collection */
     5049        that->mUSBDevices.erase (*aIt);
     5050        LogFlowFunc (("Detached device {%Vuuid}\n", (**aIt)->id().raw()));
     5051
     5052        /* notify callbacks */
     5053        that->onUSBDeviceStateChange (**aIt, false /* aAttached */, NULL);
     5054    }
     5055
     5056    LogFlowFunc (("vrc=%Vrc\n", vrc));
     5057    LogFlowFuncLeave();
     5058    return vrc;
     5059}
     5060#endif /* VBOX_WITH_PDMUSB */
    49905061
    49915062/**
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette