VirtualBox

Changeset 36329 in vbox for trunk/src/VBox/HostDrivers


Ignore:
Timestamp:
Mar 21, 2011 4:47:48 PM (14 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
70660
Message:

PCI: per-VM initialization (for IOMMU domains)

Location:
trunk/src/VBox/HostDrivers/VBoxPci
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/HostDrivers/VBoxPci/VBoxPci.c

    r36260 r36329  
    201201    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    202202    int rc;
    203    
     203
    204204    rc = vboxPciOsDevDestroy(pThis);
    205205    if (rc == VINF_SUCCESS)
     
    210210            pThis->hFastMtx = NIL_RTSEMFASTMUTEX;
    211211        }
    212        
     212
    213213        if (pThis->hSpinlock)
    214214        {
     
    216216            pThis->hSpinlock = NIL_RTSPINLOCK;
    217217        }
    218        
     218
    219219        vboxPciGlobalsLock(pThis->pGlobals);
    220220        vboxPciUnlinkInstanceLocked(pThis->pGlobals, pThis);
     
    486486}
    487487
     488/**
     489 * @copydoc RAWPCIFACTORY::pfnInitVm
     490 */
     491static DECLCALLBACK(int)  vboxPciFactoryInitVm(PRAWPCIFACTORY       pFactory,
     492                                               PVM                  pVM,
     493                                               PRAWPCIVM            pPciData)
     494{
     495    PVBOXRAWPCIVM pThis = (PVBOXRAWPCIVM)RTMemAllocZ(sizeof(VBOXRAWPCIVM));
     496    int rc;
     497
     498    if (!pThis)
     499         return VERR_NO_MEMORY;
     500
     501    rc = RTSemFastMutexCreate(&pThis->hFastMtx);
     502    if (RT_SUCCESS(rc))
     503    {
     504        rc = vboxPciOsInitVm(pThis, pVM);
     505
     506        if (RT_SUCCESS(rc))
     507        {
     508            pPciData->pDriverData = pThis;
     509            return VINF_SUCCESS;
     510        }
     511
     512        RTSemFastMutexDestroy(pThis->hFastMtx);
     513        pThis->hFastMtx = NIL_RTSEMFASTMUTEX;
     514        RTMemFree(pThis);
     515    }
     516
     517    return rc;
     518}
     519
     520/**
     521 * @copydoc RAWPCIFACTORY::pfnDeinitVm
     522 */
     523static DECLCALLBACK(void)  vboxPciFactoryDeinitVm(PRAWPCIFACTORY       pFactory,
     524                                                  PVM                  pVM,
     525                                                  PRAWPCIVM            pPciData)
     526{
     527    if (pPciData->pDriverData)
     528    {
     529        PVBOXRAWPCIVM pThis = pPciData->pDriverData;
     530
     531        vboxPciOsDeinitVm(pThis, pVM);
     532
     533        if (pThis->hFastMtx)
     534        {
     535            RTSemFastMutexDestroy(pThis->hFastMtx);
     536            pThis->hFastMtx = NIL_RTSEMFASTMUTEX;
     537        }
     538
     539        RTMemFree(pThis);
     540        pPciData->pDriverData = NULL;
     541    }
     542}
     543
     544
    488545static DECLHIDDEN(bool) vboxPciCanUnload(PVBOXRAWPCIGLOBALS pGlobals)
    489546{
     
    579636        pGlobals->RawPciFactory.pfnRelease = vboxPciFactoryRelease;
    580637        pGlobals->RawPciFactory.pfnCreateAndConnect = vboxPciFactoryCreateAndConnect;
     638        pGlobals->RawPciFactory.pfnInitVm = vboxPciFactoryInitVm;
     639        pGlobals->RawPciFactory.pfnDeinitVm = vboxPciFactoryDeinitVm;
    581640        memcpy(pGlobals->SupDrvFactory.szName, "VBoxRawPci", sizeof("VBoxRawPci"));
    582641        pGlobals->SupDrvFactory.pfnQueryFactoryInterface = vboxPciQueryFactoryInterface;
  • trunk/src/VBox/HostDrivers/VBoxPci/VBoxPciInternal.h

    r36260 r36329  
    4242/* Forward declaration. */
    4343typedef struct VBOXRAWPCIGLOBALS *PVBOXRAWPCIGLOBALS;
     44typedef struct VBOXRAWPCIVM      *PVBOXRAWPCIVM;
    4445typedef struct VBOXRAWPCIINS     *PVBOXRAWPCIINS;
    4546
     
    8788
    8889/**
     90 * Per-VM data of the VBox PCI driver. Pointed to by pVM->rawpci.s.pOsData.
     91 *
     92 */
     93typedef struct VBOXRAWPCIVM
     94{
     95    /** Mutex protecting state changes. */
     96    RTSEMFASTMUTEX hFastMtx;
     97
     98#ifdef RT_OS_LINUX
     99# ifdef VBOX_WITH_IOMMU
     100    struct iommu_domain* iommu_domain;
     101# endif
     102#endif
     103} VBOXRAWPCIVM;
     104
     105/**
    89106 * The global data of the VBox PCI driver.
    90107 *
     
    114131    struct module    * pciStubModule;
    115132#endif
    116 
    117133} VBOXRAWPCIGLOBALS;
    118134
    119135DECLHIDDEN(int)  vboxPciInit(PVBOXRAWPCIGLOBALS pGlobals);
    120136DECLHIDDEN(void) vboxPciShutdown(PVBOXRAWPCIGLOBALS pGlobals);
     137
     138DECLHIDDEN(int)  vboxPciOsInitVm(PVBOXRAWPCIVM pThis,   PVM pVM);
     139DECLHIDDEN(void) vboxPciOsDeinitVm(PVBOXRAWPCIVM pThis, PVM pVM);
    121140
    122141DECLHIDDEN(int)  vboxPciOsDevInit  (PVBOXRAWPCIINS pIns, uint32_t fFlags);
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