PDMUsb.cpp revision 82bcaaf8077ba892f39afb721dca149353c63d2c
/* $Id$ */
/** @file
* PDM - Pluggable Device and Driver Manager, USB part.
*/
/*
* Copyright (C) 2006-2007 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define LOG_GROUP LOG_GROUP_PDM_DRIVER
#include "PDMInternal.h"
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
* Internal callback structure pointer.
*
* The main purpose is to define the extra data we associate
* with PDMUSBREGCB so we can find the VM instance and so on.
*/
typedef struct PDMUSBREGCBINT
{
/** The callback structure. */
/** A bit of padding. */
/** VM Handle. */
typedef const PDMUSBREGCBINT *PCPDMUSBREGCBINT;
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
/** @def PDMUSB_ASSERT_USBINS
* Asserts the validity of the USB device instance.
*/
#ifdef VBOX_STRICT
# define PDMUSB_ASSERT_USBINS(pUsbIns) \
do { \
} while (0)
#else
# define PDMUSB_ASSERT_USBINS(pUsbIns) do { } while (0)
#endif
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
/*******************************************************************************
* Global Variables *
*******************************************************************************/
extern const PDMUSBHLP g_pdmR3UsbHlp;
/**
* Registers a USB hub driver.
*
* @returns VBox status code.
* @param pVM The VM handle.
* @param pDrvIns The driver instance of the hub.
* @param fVersions Indicates the kinds of USB devices that can be attached to this HUB.
* @param cPorts The number of ports.
* @param pUsbHubReg The hub callback structure that PDMUsb uses to interact with it.
* @param ppUsbHubHlp The helper callback structure that the hub uses to talk to PDMUsb.
* @thread EMT
*/
int pdmR3UsbRegisterHub(PVM pVM, PPDMDRVINS pDrvIns, uint32_t fVersions, uint32_t cPorts, PCPDMUSBHUBREG pUsbHubReg, PPCPDMUSBHUBHLP ppUsbHubHlp)
{
/*
* Validate input.
*/
/* The driver must be in the USB class. */
{
LogRel(("pdmR3UsbRegisterHub: fClass=%#x expected %#x to be set\n", pDrvIns->pReg->fClass, PDM_DRVREG_CLASS_USB));
return VERR_INVALID_PARAMETER;
}
AssertMsgReturn(!(fVersions & ~(VUSB_STDVER_11 | VUSB_STDVER_20)), ("%#x\n", fVersions), VERR_INVALID_PARAMETER);
/*
* Check for duplicate registration and find the last hub for FIFO registration.
*/
{
return VERR_PDM_USB_HUB_EXISTS;
}
/*
* Create an internal USB hub structure.
*/
if (!pHub)
return VERR_NO_MEMORY;
/* link it */
if (pPrev)
else
return VINF_SUCCESS;
}
/**
* Loads one device module and call the registration entry point.
*
* @returns VBox status code.
* @param pVM VM handle.
* @param pRegCB The registration callback stuff.
* @param pszFilename Module filename.
* @param pszName Module name.
*/
static int pdmR3UsbLoad(PVM pVM, PCPDMUSBREGCBINT pRegCB, const char *pszFilename, const char *pszName)
{
/*
* Load it.
*/
if (RT_SUCCESS(rc))
{
/*
* Get the registration export and call it.
*/
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
else
AssertMsgFailed(("VBoxDevicesRegister failed with rc=%Rrc for module %s (%s)\n", rc, pszName, pszFilename));
}
else
{
AssertMsgFailed(("Failed to locate 'VBoxUsbRegister' in %s (%s) rc=%Rrc\n", pszName, pszFilename, rc));
if (rc == VERR_SYMBOL_NOT_FOUND)
}
}
else
AssertMsgFailed(("Failed to load VBoxDD!\n"));
return rc;
}
/**
* @interface_method_impl{PDMUSBREGCB,pfnRegister}
*/
{
/*
* Validate the registration structure.
*/
AssertMsgReturn(pReg->fFlags == 0, ("fFlags=%#x\n", pReg->fFlags), VERR_PDM_INVALID_USB_REGISTRATION);
/*
* Check for duplicate and find FIFO entry at the same time.
*/
/*
* Allocate new device structure and insert it into the list.
*/
if (pUsb)
{
pUsb->iNextInstance = 0;
if (pUsbPrev)
else
return VINF_SUCCESS;
}
return VERR_NO_MEMORY;
}
/**
* Load USB Device modules.
*
* This is called by pdmR3DevInit() after it has loaded it's device modules.
*
* @returns VBox status code.
* @param pVM The VM handle.
*/
{
LogFlow(("pdmR3UsbLoadModules:\n"));
AssertRelease(sizeof(pVM->pdm.s.pUsbInstances->Internal.s) <= sizeof(pVM->pdm.s.pUsbInstances->Internal.padding));
/*
* Initialize the callback structure.
*/
/*
* Load the builtin module
*/
bool fLoadBuiltin;
fLoadBuiltin = true;
else if (RT_FAILURE(rc))
{
return rc;
}
if (fLoadBuiltin)
{
/* make filename */
if (!pszFilename)
return VERR_NO_TMP_MEMORY;
if (RT_FAILURE(rc))
return rc;
}
/*
* Load additional device modules.
*/
{
/*
* Get the name and path.
*/
char szName[PDMMOD_NAME_LEN];
if (rc == VERR_CFGM_NOT_ENOUGH_SPACE)
{
AssertMsgFailed(("configuration error: The module name is too long, cchName=%zu.\n", CFGMR3GetNameLen(pCur)));
return VERR_PDM_MODULE_NAME_TOO_LONG;
}
else if (RT_FAILURE(rc))
{
return rc;
}
/* the path is optional, if no path the module name + path is used. */
char szFilename[RTPATH_MAX];
if (rc == VERR_CFGM_VALUE_NOT_FOUND)
else if (RT_FAILURE(rc))
{
return rc;
}
/* prepend path? */
if (!RTPathHavePath(szFilename))
{
if (!psz)
return VERR_NO_TMP_MEMORY;
if (cch > sizeof(szFilename))
{
return VERR_FILENAME_TOO_LONG;
}
}
/*
* Load the module and register it's devices.
*/
if (RT_FAILURE(rc))
return rc;
}
return VINF_SUCCESS;
}
/**
* Send the init-complete notification to all the USB devices.
*
* This is called from pdmR3DevInit() after it has do its noficiation round.
*
* @returns VBox status code.
* @param pVM The VM handle.
*/
{
{
{
if (RT_FAILURE(rc))
{
AssertMsgFailed(("InitComplete on USB device '%s'/%d failed with rc=%Rrc\n",
return rc;
}
}
}
return VINF_SUCCESS;
}
/**
* Lookups a device structure by name.
* @internal
*/
{
return pUsb;
return NULL;
}
/**
* Locates a suitable hub for the specified kind of device.
*
* @returns VINF_SUCCESS and *ppHub on success.
* VERR_PDM_NO_USB_HUBS or VERR_PDM_NO_USB_PORTS on failure.
* @param pVM The VM handle.
* @param iUsbVersion The USB device version.
* @param ppHub Where to store the pointer to the USB hub.
*/
{
return VERR_PDM_NO_USB_HUBS;
if ( pCur->cAvailablePorts > 0
{
break;
}
if (*ppHub)
return VINF_SUCCESS;
return VERR_PDM_NO_USB_PORTS;
}
/**
* Creates the device.
*
* @returns VBox status code.
* @param pVM The VM handle.
* @param pUsbDev The USB device emulation.
* @param iInstance -1 if not called by pdmR3UsbInstantiateDevices().
* @param pUuid The UUID for this device.
* @param pInstanceNode The instance CFGM node. NULL if not called by pdmR3UsbInstantiateDevices().
* @param ppConfig Pointer to the device configuration pointer. This is set to NULL if inserted
* into the tree or cleaned up.
*
* In the pdmR3UsbInstantiateDevices() case (pInstanceNode != NULL) this is
* the actual config node and will not be cleaned up.
*
* @parma iUsbVersion The USB version prefered by the device.
*/
static int pdmR3UsbCreateDevice(PVM pVM, PPDMUSBHUB pHub, PPDMUSB pUsbDev, int iInstance, PCRTUUID pUuid, PCFGMNODE pInstanceNode, PCFGMNODE *ppConfig, uint32_t iUsbVersion)
{
int rc;
/*
* If not called by pdmR3UsbInstantiateDevices(), we'll have to fix
* the configuration now.
*/
/* USB device node. */
if (!pDevNode)
{
}
/* The instance node and number. */
if (!pInstanceNode)
{
for (unsigned c = 0; c < _2M; c++)
{
if (rc != VERR_CFGM_NODE_EXISTS)
break;
}
}
else
{
}
/* The instance config node. */
{
}
else if (fAtRuntime)
{
}
else
/* The global device config node. */
if (!pGlobalConfig)
{
if (RT_FAILURE(rc))
{
}
}
/*
* Allocate the device instance.
*/
if (RT_FAILURE(rc))
{
AssertMsgFailed(("Failed to allocate %d bytes of instance data for USB device '%s'. rc=%Rrc\n",
return rc;
}
/*
* Initialize it.
*/
//pUsbIns->Internal.s.pNext = NULL;
//pUsbIns->Internal.s.pPerDeviceNext = NULL;
//pUsbIns->Internal.s.pLuns = NULL;
//pUsbIns->Internal.s.pHub = NULL;
//pUsbIns->Internal.s.pfnAsyncNotify = NULL;
/*
* Link it into all the lists.
*/
/* The global instance FIFO. */
if (!pPrev1)
else
{
{
}
}
/* The per device instance FIFO. */
if (!pPrev2)
else
{
{
}
}
/*
* Call the constructor.
*/
Log(("PDM: Constructing USB device '%s' instance %d...\n", pUsbIns->pReg->szName, pUsbIns->iInstance));
if (RT_SUCCESS(rc))
{
/*
* Attach it to the hub.
*/
Log(("PDM: Attaching it...\n"));
if (RT_SUCCESS(rc))
{
pHub->cAvailablePorts--;
/* Send the hot-plugged notification if applicable. */
Log(("PDM: Successfully attached USB device '%s' instance %d to hub %p\n",
return VINF_SUCCESS;
}
LogRel(("PDM: Failed to attach USB device '%s' instance %d to hub %p: %Rrc\n",
}
else
AssertMsgFailed(("Failed to construct '%s'/%d! %Rra\n", pUsbIns->pReg->szName, pUsbIns->iInstance, rc));
if (fAtRuntime)
/* else: destructors are invoked later. */
return rc;
}
/**
* Instantiate USB devices.
*
* This is called by pdmR3DevInit() after it has instantiated the
* other devices and their drivers. If there aren't any hubs
* around, we'll silently skip the USB devices.
*
* @returns VBox status code.
* @param pVM
*/
{
/*
* Any hubs?
*/
{
Log(("PDM: No USB hubs, skipping USB device instantiation.\n"));
return VINF_SUCCESS;
}
/*
* Count the device instances.
*/
unsigned cUsbDevs = 0;
{
for (pInstanceNode = CFGMR3GetFirstChild(pCur); pInstanceNode; pInstanceNode = CFGMR3GetNextChild(pInstanceNode))
if (pInstanceNode != pGlobal)
cUsbDevs++;
}
if (!cUsbDevs)
{
Log(("PDM: No USB devices were configured!\n"));
return VINF_SUCCESS;
}
/*
* Collect info on each USB device instance.
*/
struct USBDEVORDER
{
/** Configuration node. */
/** Pointer to the USB device. */
/** Init order. */
/** VBox instance number. */
} *paUsbDevs = (struct USBDEVORDER *)alloca(sizeof(paUsbDevs[0]) * (cUsbDevs + 1)); /* (One extra for swapping) */
int rc;
unsigned i = 0;
{
/* Get the device name. */
AssertMsgRCReturn(rc, ("Configuration error: device name is too long (or something)! rc=%Rrc\n", rc), rc);
/* Find the device. */
AssertMsgReturn(pUsbDev, ("Configuration error: device '%s' not found!\n", szName), VERR_PDM_DEVICE_NOT_FOUND);
/* Configured priority or use default? */
if (rc == VERR_CFGM_VALUE_NOT_FOUND)
u32Order = i << 4;
else
AssertMsgRCReturn(rc, ("Configuration error: reading \"Priority\" for the '%s' USB device failed rc=%Rrc!\n", szName, rc), rc);
/* Global config. */
if (!pGlobal)
{
}
/* Enumerate the device instances. */
for (pInstanceNode = CFGMR3GetFirstChild(pCur); pInstanceNode; pInstanceNode = CFGMR3GetNextChild(pInstanceNode))
{
if (pInstanceNode == pGlobal)
continue;
/* Get the instance number. */
char szInstance[32];
AssertMsgRCReturn(rc, ("Configuration error: instance name is too long (or something)! rc=%Rrc\n", rc), rc);
AssertMsgRCReturn(rc, ("Configuration error: RTStrToInt32Ex failed on the instance name '%s'! rc=%Rrc\n", szInstance, rc), rc);
AssertMsgReturn(!*pszNext, ("Configuration error: the instance name '%s' isn't all digits. (%s)\n", szInstance, pszNext), VERR_INVALID_PARAMETER);
/* next instance */
i++;
}
} /* devices */
/*
* Sort the device array ascending on u32Order. (bubble)
*/
unsigned c = cUsbDevs - 1;
while (c)
{
unsigned j = 0;
for (i = 0; i < c; i++)
{
j = i;
}
c = j;
}
/*
* Instantiate the devices.
*/
for (i = 0; i < cUsbDevs; i++)
{
/*
* Make sure there is a config node and mark it as restricted.
*/
if (!pConfigNode)
{
}
/** @todo
* Figure out the USB version from the USB device registration and the configuration.
*/
/*
* Find a suitable hub with free ports.
*/
if (RT_FAILURE(rc))
{
return rc;
}
/*
* Create and attach the device.
*/
rc = pdmR3UsbCreateDevice(pVM, pHub, paUsbDevs[i].pUsbDev, paUsbDevs[i].iInstance, &Uuid, paUsbDevs[i].pNode, &pConfigNode, iUsbVersion);
if (RT_FAILURE(rc))
return rc;
} /* for device instances */
return VINF_SUCCESS;
}
/**
* Creates a USB proxy device instance.
*
* This will find an appropriate HUB for the USB device, create the necessary CFGM stuff
* and try instantiate the proxy device.
*
* @returns VBox status code.
* @param pVM The VM handle.
* @param pUuid The UUID thats to be associated with the device.
* @param fRemote Whether it's a remove or local device.
* @param pszAddress The address string.
* @param pvBackend Pointer to the backend.
* @param iUsbVersion The preferred USB version.
* @param fMaskedIfs The interfaces to hide from the guest.
*/
VMMR3DECL(int) PDMR3USBCreateProxyDevice(PVM pVM, PCRTUUID pUuid, bool fRemote, const char *pszAddress, void *pvBackend,
{
/*
* Validate input.
*/
/*
* Find the USBProxy driver.
*/
if (!pUsbDev)
{
LogRel(("PDMR3USBCreateProxyDevice: The USBProxy device class wasn't found\n"));
return VERR_PDM_NO_USBPROXY;
}
/*
* Find a suitable hub with free ports.
*/
if (RT_FAILURE(rc))
{
return rc;
}
/*
* Create the CFGM configuration node.
*/
do /* break loop */
{
char szUuid[RTUUID_STR_LENGTH];
rc = CFGMR3InsertInteger(pConfig, "Force11Device", !(pHub->fVersions & iUsbVersion)); AssertRCBreak(rc);
} while (0); /* break loop */
if (RT_FAILURE(rc))
{
return rc;
}
/*
* Finally, try create it.
*/
return rc;
}
/**
* Destroys a hot-plugged USB device.
*
* The device must be detached from the HUB at this point.
*
* @param pVM Pointer to the stahred VM structure.
* @param pUsbIns The USB device instance to destroy.
* @thread EMT
*/
{
/*
* Do the unplug notification.
*/
/** @todo what about the drivers? */
/*
* Destroy the luns with their driver chains and call the device destructor.
*/
{
pdmR3DrvDestroyChain(pLun->pTop, PDM_TACH_FLAGS_NOT_HOT_PLUG); /* Hotplugging is handled differently here atm. */
}
/* finally, the device. */
{
Log(("PDM: Destructing USB device '%s' instance %d...\n", pUsbIns->pReg->szName, pUsbIns->iInstance));
}
//TMR3TimerDestroyUsb(pVM, pUsbIns);
//SSMR3DeregisterUsb(pVM, pUsbIns, NULL, 0);
/*
* Unlink it.
*/
/* The global instance FIFO. */
else
{
{
}
if (pPrev)
}
/* The per device instance FIFO. */
else
{
{
}
if (pPrev)
}
/*
* Trash it.
*/
pUsbIns->u32Version = 0;
}
/**
* Detaches and destroys a USB device.
*
* @returns VBox status code.
* @param pVM The VM handle.
* @param pUuid The UUID associated with the device to detach.
* @thread EMT
*/
{
/*
* Validate input.
*/
/*
* Search the global list for it.
*/
break;
if (!pUsbIns)
return VERR_PDM_DEVICE_INSTANCE_NOT_FOUND; /** @todo VERR_PDM_USB_INSTANCE_NOT_FOUND */
/*
* Detach it from the HUB (if it's actually attached to one).
*/
if (pHub)
{
if (RT_FAILURE(rc))
{
LogRel(("PDM: Failed to detach USB device '%s' instance %d from %p: %Rrc\n",
return rc;
}
pHub->cAvailablePorts++;
}
/*
* Notify about unplugging and destroy the device with it's drivers.
*/
return VINF_SUCCESS;
}
/**
* Checks if there are any USB hubs attached.
*
* @returns true / false accordingly.
* @param pVM Pointer to the shared VM structure.
*/
{
}
/** @name USB Device Helpers
* @{
*/
/** @interface_method_impl{PDMUSBHLPR3,pfnDriverAttach} */
static DECLCALLBACK(int) pdmR3UsbHlp_DriverAttach(PPDMUSBINS pUsbIns, RTUINT iLun, PPDMIBASE pBaseInterface, PPDMIBASE *ppBaseInterface, const char *pszDesc)
{
LogFlow(("pdmR3UsbHlp_DriverAttach: caller='%s'/%d: iLun=%d pBaseInterface=%p ppBaseInterface=%p pszDesc=%p:{%s}\n",
pUsbIns->pReg->szName, pUsbIns->iInstance, iLun, pBaseInterface, ppBaseInterface, pszDesc, pszDesc));
/*
* Lookup the LUN, it might already be registered.
*/
break;
/*
* Create the LUN if if wasn't found, else check if driver is already attached to it.
*/
if (!pLun)
{
if ( !pBaseInterface
|| !pszDesc
|| !*pszDesc)
{
return VERR_INVALID_PARAMETER;
}
if (!pLun)
return VERR_NO_MEMORY;
if (!pLunPrev)
else
Log(("pdmR3UsbHlp_DriverAttach: Registered LUN#%d '%s' with device '%s'/%d.\n",
}
{
AssertMsgFailed(("Already attached! The device should keep track of such things!\n"));
LogFlow(("pdmR3UsbHlp_DriverAttach: caller='%s'/%d: returns %Rrc\n", pUsbIns->pReg->szName, pUsbIns->iInstance, VERR_PDM_DRIVER_ALREADY_ATTACHED));
return VERR_PDM_DRIVER_ALREADY_ATTACHED;
}
/*
* Get the attached driver configuration.
*/
int rc;
if (pNode)
else
LogFlow(("pdmR3UsbHlp_DriverAttach: caller='%s'/%d: returns %Rrc\n", pUsbIns->pReg->szName, pUsbIns->iInstance, rc));
return rc;
}
/** @interface_method_impl{PDMUSBHLP,pfnAssertEMT} */
static DECLCALLBACK(bool) pdmR3UsbHlp_AssertEMT(PPDMUSBINS pUsbIns, const char *pszFile, unsigned iLine, const char *pszFunction)
{
return true;
char szMsg[100];
RTStrPrintf(szMsg, sizeof(szMsg), "AssertEMT '%s'/%d\n", pUsbIns->pReg->szName, pUsbIns->iInstance);
return false;
}
/** @interface_method_impl{PDMUSBHLP,pfnAssertOther} */
static DECLCALLBACK(bool) pdmR3UsbHlp_AssertOther(PPDMUSBINS pUsbIns, const char *pszFile, unsigned iLine, const char *pszFunction)
{
return true;
char szMsg[100];
RTStrPrintf(szMsg, sizeof(szMsg), "AssertOther '%s'/%d\n", pUsbIns->pReg->szName, pUsbIns->iInstance);
return false;
}
/** @interface_method_impl{PDMUSBHLP,pfnDBGFStopV} */
static DECLCALLBACK(int) pdmR3UsbHlp_DBGFStopV(PPDMUSBINS pUsbIns, const char *pszFile, unsigned iLine, const char *pszFunction, const char *pszFormat, va_list args)
{
#ifdef LOG_ENABLED
LogFlow(("pdmR3UsbHlp_DBGFStopV: caller='%s'/%d: pszFile=%p:{%s} iLine=%d pszFunction=%p:{%s} pszFormat=%p:{%s} (%N)\n",
pUsbIns->pReg->szName, pUsbIns->iInstance, pszFile, pszFile, iLine, pszFunction, pszFunction, pszFormat, pszFormat, pszFormat, &va2));
#endif
if (rc == VERR_DBGF_NOT_ATTACHED)
rc = VINF_SUCCESS;
LogFlow(("pdmR3UsbHlp_DBGFStopV: caller='%s'/%d: returns %Rrc\n", pUsbIns->pReg->szName, pUsbIns->iInstance, rc));
return rc;
}
/** @interface_method_impl{PDMUSBHLP,pfnDBGFInfoRegister} */
static DECLCALLBACK(int) pdmR3UsbHlp_DBGFInfoRegister(PPDMUSBINS pUsbIns, const char *pszName, const char *pszDesc, PFNDBGFHANDLERUSB pfnHandler)
{
LogFlow(("pdmR3UsbHlp_DBGFInfoRegister: caller='%s'/%d: pszName=%p:{%s} pszDesc=%p:{%s} pfnHandler=%p\n",
/** @todo int rc = DBGFR3InfoRegisterUsb(pVM, pszName, pszDesc, pfnHandler, pUsbIns); */
LogFlow(("pdmR3UsbHlp_DBGFInfoRegister: caller='%s'/%d: returns %Rrc\n", pUsbIns->pReg->szName, pUsbIns->iInstance, rc));
return rc;
}
/** @interface_method_impl{PDMUSBHLP,pfnMMHeapAlloc} */
{
LogFlow(("pdmR3UsbHlp_MMHeapAlloc: caller='%s'/%d: cb=%#x\n", pUsbIns->pReg->szName, pUsbIns->iInstance, cb));
LogFlow(("pdmR3UsbHlp_MMHeapAlloc: caller='%s'/%d: returns %p\n", pUsbIns->pReg->szName, pUsbIns->iInstance, pv));
return pv;
}
/** @interface_method_impl{PDMUSBHLP,pfnMMHeapAllocZ} */
{
LogFlow(("pdmR3UsbHlp_MMHeapAllocZ: caller='%s'/%d: cb=%#x\n", pUsbIns->pReg->szName, pUsbIns->iInstance, cb));
LogFlow(("pdmR3UsbHlp_MMHeapAllocZ: caller='%s'/%d: returns %p\n", pUsbIns->pReg->szName, pUsbIns->iInstance, pv));
return pv;
}
/** @interface_method_impl{PDMUSBHLP,pfnPDMQueueCreate} */
static DECLCALLBACK(int) pdmR3UsbHlp_PDMQueueCreate(PPDMUSBINS pUsbIns, RTUINT cbItem, RTUINT cItems, uint32_t cMilliesInterval,
{
LogFlow(("pdmR3UsbHlp_PDMQueueCreate: caller='%s'/%d: cbItem=%#x cItems=%#x cMilliesInterval=%u pfnCallback=%p pszName=%p:{%s} ppQueue=%p\n",
pUsbIns->pReg->szName, pUsbIns->iInstance, cbItem, cItems, cMilliesInterval, pfnCallback, pszName, pszName, ppQueue));
{
}
/** @todo int rc = PDMR3QueueCreateUsb(pVM, pUsbIns, cbItem, cItems, cMilliesInterval, pfnCallback, fGCEnabled, pszName, ppQueue); */
LogFlow(("pdmR3UsbHlp_PDMQueueCreate: caller='%s'/%d: returns %Rrc *ppQueue=%p\n", pUsbIns->pReg->szName, pUsbIns->iInstance, rc, *ppQueue));
return rc;
}
/** @interface_method_impl{PDMUSBHLP,pfnSSMRegister} */
static DECLCALLBACK(int) pdmR3UsbHlp_SSMRegister(PPDMUSBINS pUsbIns, uint32_t uVersion, size_t cbGuess,
{
LogFlow(("pdmR3UsbHlp_SSMRegister: caller='%s'/%d: uVersion=#x cbGuess=%#x\n"
" pfnLivePrep=%p pfnLiveExec=%p pfnLiveVote=%p pfnSavePrep=%p pfnSaveExec=%p pfnSaveDone=%p pszLoadPrep=%p pfnLoadExec=%p pfnLoadDone=%p\n",
/** @todo
int rc = SSMR3RegisterUsb(pUsbIns->Internal.s.pVM, pUsbIns, pUsbIns->pReg->szName, pUsbIns->iInstance,
uVersion, cbGuess,
pfnLivePrep, pfnLiveExec, pfnLiveVote,
pfnSavePrep, pfnSaveExec, pfnSaveDone,
pfnLoadPrep, pfnLoadExec, pfnLoadDone); */
LogFlow(("pdmR3UsbHlp_SSMRegister: caller='%s'/%d: returns %Rrc\n", pUsbIns->pReg->szName, pUsbIns->iInstance, rc));
return rc;
}
/** @interface_method_impl{PDMUSBHLP,pfnSTAMRegisterV} */
static DECLCALLBACK(void) pdmR3UsbHlp_STAMRegisterV(PPDMUSBINS pUsbIns, void *pvSample, STAMTYPE enmType, STAMVISIBILITY enmVisibility,
{
}
/** @interface_method_impl{PDMUSBHLP,pfnTMTimerCreate} */
static DECLCALLBACK(int) pdmR3UsbHlp_TMTimerCreate(PPDMUSBINS pUsbIns, TMCLOCK enmClock, PFNTMTIMERUSB pfnCallback, void *pvUser,
{
LogFlow(("pdmR3UsbHlp_TMTimerCreate: caller='%s'/%d: enmClock=%d pfnCallback=%p pvUser=%p fFlags=%#x pszDesc=%p:{%s} ppTimer=%p\n",
pUsbIns->pReg->szName, pUsbIns->iInstance, enmClock, pfnCallback, pvUser, fFlags, pszDesc, pszDesc, ppTimer));
{
if (pszDesc2)
}
/** @todo
int rc = TMR3TimerCreateUsb(pVM, pUsbIns, enmClock, pfnCallback, pvUser, fFlags, pszDesc, ppTimer); */
LogFlow(("pdmR3UsbHlp_TMTimerCreate: caller='%s'/%d: returns %Rrc\n", pUsbIns->pReg->szName, pUsbIns->iInstance, rc));
return rc;
}
/** @interface_method_impl{PDMUSBHLP,pfnVMSetErrorV} */
static DECLCALLBACK(int) pdmR3UsbHlp_VMSetErrorV(PPDMUSBINS pUsbIns, int rc, RT_SRC_POS_DECL, const char *pszFormat, va_list va)
{
int rc2 = VMSetErrorV(pUsbIns->Internal.s.pVM, rc, RT_SRC_POS_ARGS, pszFormat, va); Assert(rc2 == rc); NOREF(rc2);
return rc;
}
/** @interface_method_impl{PDMUSBHLP,pfnVMSetRuntimeErrorV} */
static DECLCALLBACK(int) pdmR3UsbHlp_VMSetRuntimeErrorV(PPDMUSBINS pUsbIns, uint32_t fFlags, const char *pszErrorId, const char *pszFormat, va_list va)
{
return rc;
}
/** @interface_method_impl{PDMUSBHLP,pfnVMState} */
{
LogFlow(("pdmR3UsbHlp_VMState: caller='%s'/%d: returns %d (%s)\n", pUsbIns->pReg->szName, pUsbIns->iInstance,
return enmVMState;
}
/** @interface_method_impl{PDMUSBHLP,pfnSetAsyncNotification} */
static DECLCALLBACK(int) pdmR3UsbHlp_SetAsyncNotification(PPDMUSBINS pUsbIns, PFNPDMUSBASYNCNOTIFY pfnAsyncNotify)
{
LogFlow(("pdmR3UsbHlp_SetAsyncNotification: caller='%s'/%d: pfnAsyncNotify=%p\n", pUsbIns->pReg->szName, pUsbIns->iInstance, pfnAsyncNotify));
int rc = VINF_SUCCESS;
AssertStmt(pUsbIns->Internal.s.fVMSuspended || pUsbIns->Internal.s.fVMReset, rc = VERR_WRONG_ORDER);
|| enmVMState == VMSTATE_RESETTING
rc = VERR_INVALID_STATE);
if (RT_SUCCESS(rc))
LogFlow(("pdmR3UsbHlp_SetAsyncNotification: caller='%s'/%d: returns %Rrc\n", pUsbIns->pReg->szName, pUsbIns->iInstance, rc));
return rc;
}
/** @interface_method_impl{PDMUSBHLP,pfnAsyncNotificationCompleted} */
{
if ( enmVMState == VMSTATE_SUSPENDING
|| enmVMState == VMSTATE_RESETTING
{
LogFlow(("pdmR3UsbHlp_AsyncNotificationCompleted: caller='%s'/%d:\n", pUsbIns->pReg->szName, pUsbIns->iInstance));
}
else
LogFlow(("pdmR3UsbHlp_AsyncNotificationCompleted: caller='%s'/%d: enmVMState=%d\n", pUsbIns->pReg->szName, pUsbIns->iInstance, enmVMState));
}
/**
* The USB device helper structure.
*/
const PDMUSBHLP g_pdmR3UsbHlp =
{
};
/** @} */