PDMDevice.cpp revision 179928f57e0eacfa27596cb5cf5f366a1c7840ec
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * PDM - Pluggable Device and Driver Manager, Device parts.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Copyright (C) 2006-2010 Oracle Corporation
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * available from http://www.virtualbox.org. This file is free software;
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * you can redistribute it and/or modify it under the terms of the GNU
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * General Public License (GPL) as published by the Free Software
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync/*******************************************************************************
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync* Header Files *
a5e7ae69e440f6816420fc99599f044e79e716b6vboxsync*******************************************************************************/
typedef struct PDMDEVREGCBINT
static int pdmR3DevLoad(PVM pVM, PPDMDEVREGCBINT pRegCB, const char *pszFilename, const char *pszName);
AssertRelease(sizeof(pVM->pdm.s.pDevInstances->Internal.s) <= sizeof(pVM->pdm.s.pDevInstances->Internal.padding));
return rc;
#ifdef VBOX_WITH_USB
return rc;
rc = PDMR3QueueCreateInternal(pVM, sizeof(PDMDEVHLPTASK), 8, 0, pdmR3DevHlpQueueConsumer, true, "DevHlp",
unsigned cDevs = 0;
for (pInstanceNode = CFGMR3GetFirstChild(pCur); pInstanceNode; pInstanceNode = CFGMR3GetNextChild(pInstanceNode))
cDevs++;
if (!cDevs)
return VINF_SUCCESS;
struct DEVORDER
} *paDevs = (struct DEVORDER *)alloca(sizeof(paDevs[0]) * (cDevs + 1)); /* (One extra for swapping) */
AssertMsgRCReturn(rc, ("Configuration error: device name is too long (or something)! rc=%Rrc\n", rc), rc);
AssertLogRelMsgReturn(pDev, ("Configuration error: device '%s' not found!\n", szName), VERR_PDM_DEVICE_NOT_FOUND);
AssertMsgRCReturn(rc, ("Configuration error: reading \"Priority\" for the '%s' device failed rc=%Rrc!\n", szName, rc), rc);
for (pInstanceNode = CFGMR3GetFirstChild(pCur); pInstanceNode; pInstanceNode = CFGMR3GetNextChild(pInstanceNode))
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);
AssertLogRelMsgFailedReturn(("Configuration error: Too many instances of %s was configured: %u, max %u\n",
for (i = 0; i < cDevs; i++)
bool fTrusted;
fTrusted = false;
return rc;
if (!pConfigNode)
return rc;
AssertReturn(paDevs[i].pDev->cInstances < paDevs[i].pDev->pReg->cMaxInstances, VERR_PDM_TOO_MANY_DEVICE_INSTANCES);
rc);
//pDevIns->Internal.s.pNextR3 = NULL;
//pDevIns->Internal.s.pPerDeviceNextR3 = NULL;
//pDevIns->Internal.s.pLunsR3 = NULL;
//pDevIns->Internal.s.pPciDeviceR3 = NULL;
//pDevIns->Internal.s.pPciBusR3 = NULL;
//pDevIns->Internal.s.pPciDeviceR0 = 0;
//pDevIns->Internal.s.pPciBusR0 = 0;
//pDevIns->Internal.s.pPciDeviceRC = 0;
//pDevIns->Internal.s.pPciBusRC = 0;
if (!pPrev1)
if (!pPrev2)
LogRel(("PDM: Failed to construct '%s'/%d! %Rra\n", pDevIns->pReg->szName, pDevIns->iInstance, rc));
#ifdef VBOX_WITH_USB
return rc;
return rc;
return rc;
#ifdef VBOX_WITH_USB
return rc;
return VINF_SUCCESS;
return pDev;
return NULL;
bool fLoadBuiltin;
fLoadBuiltin = true;
return rc;
if (fLoadBuiltin)
if (!pszFilename)
return VERR_NO_TMP_MEMORY;
return rc;
if (!pszFilename)
return VERR_NO_TMP_MEMORY;
return rc;
AssertMsgFailed(("configuration error: The module name is too long, cchName=%zu.\n", CFGMR3GetNameLen(pCur)));
return VERR_PDM_MODULE_NAME_TOO_LONG;
return rc;
return rc;
if (!psz)
return VERR_NO_TMP_MEMORY;
return VERR_FILENAME_TOO_LONG;
return rc;
return VINF_SUCCESS;
static int pdmR3DevLoad(PVM pVM, PPDMDEVREGCBINT pRegCB, const char *pszFilename, const char *pszName)
Log(("PDM: Calling VBoxDevicesRegister (%p) of %s (%s)\n", pfnVBoxDevicesRegister, pszName, pszFilename));
AssertMsgFailed(("VBoxDevicesRegister failed with rc=%Rrc for module %s (%s)\n", rc, pszName, pszFilename));
AssertMsgFailed(("Failed to locate 'VBoxDevicesRegister' in %s (%s) rc=%Rrc\n", pszName, pszFilename, rc));
return rc;
AssertMsgReturn((pReg->fFlags & PDM_DEVREG_FLAGS_HOST_BITS_MASK) == PDM_DEVREG_FLAGS_HOST_BITS_DEFAULT,
AssertMsgReturn(pReg->cbInstance <= (uint32_t)(pReg->fFlags & (PDM_DEVREG_FLAGS_RC | PDM_DEVREG_FLAGS_R0) ? 96 * _1K : _1M),
AssertLogRelMsgReturn((pReg->fFlags & PDM_DEVREG_FLAGS_GUEST_BITS_MASK) == PDM_DEVREG_FLAGS_GUEST_BITS_DEFAULT,
int rc;
if (pDev)
if (pDevPrev)
return VINF_SUCCESS;
return rc;
int pdmR3DevFindLun(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, PPPDMLUN ppLun)
for (PPDMDEVINS pDevIns = pDev->pInstances; pDevIns; pDevIns = pDevIns->Internal.s.pPerDeviceNextR3)
return VINF_SUCCESS;
return VERR_PDM_LUN_NOT_FOUND;
return VERR_PDM_DEVICE_NOT_FOUND;
VMMR3DECL(int) PDMR3DeviceAttach(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, uint32_t fFlags, PPPDMIBASE ppBase)
if (ppBase)
else if (ppBase)
if (ppBase)
return rc;
VMMR3DECL(int) PDMR3DeviceDetach(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, uint32_t fFlags)
return pCritSect;
VMMR3DECL(int) PDMR3DriverAttach(PVM pVM, const char *pszDevice, unsigned iInstance, unsigned iLun, uint32_t fFlags, PPPDMIBASE ppBase)
if (ppBase)
if (!pDrvIns)
: NULL;
if (ppBase)
return rc;
LogFlow(("PDMR3DriverDetach: pszDevice=%p:{%s} iDevIns=%u iLun=%u pszDriver=%p:{%s} iOccurance=%u fFlags=%#x\n",
if (pDrvIns)
if (pszDriver)
while (pDrvIns)
if (iOccurance == 0)
iOccurance--;
if (pDrvIns)
return rc;
return VERR_NOT_IMPLEMENTED;