VirtualBox

Ignore:
Timestamp:
Apr 1, 2011 5:04:35 AM (14 years ago)
Author:
vboxsync
Message:

PCI: sync of interrupts rework

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

Legend:

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

    r36460 r36485  
    189189    int rc;
    190190
    191     /* Bit racy, better check under lock. */
    192     if (pThis->iHostIrq != -1)
    193     {
    194         pPort->pfnUnregisterIrqHandler(pPort, pThis->iHostIrq);
    195         pThis->iHostIrq = -1;
    196     }
    197 
    198     vboxPciDevLock(pThis);
     191    vboxPciDevLock(pThis);
     192   
     193    if (pThis->IrqHandler.pfnIrqHandler)
     194    {
     195        pPort->pfnUnregisterIrqHandler(pPort, pThis->IrqHandler.iHostIrq);
     196        pThis->IrqHandler.iHostIrq = -1;
     197        pThis->IrqHandler.pfnIrqHandler = NULL;
     198    }
    199199
    200200    rc = vboxPciOsDevDeinit(pThis, fFlags);
     
    339339}
    340340
    341 DECLHIDDEN(int) vboxPciDevRegisterIrqHandler(PRAWPCIDEVPORT pPort, PFNRAWPCIISR pfnHandler, void* pIrqContext, int32_t *piHostIrq)
    342 {
    343     PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    344     int rc;
    345 
    346     vboxPciDevLock(pThis);
    347 
    348     pThis->pfnIrqHandler = pfnHandler;
    349     pThis->pIrqContext   = pIrqContext;
    350     rc = vboxPciOsDevRegisterIrqHandler(pThis, pfnHandler, pIrqContext, piHostIrq);
    351     if (RT_FAILURE(rc))
    352     {
    353         pThis->pfnIrqHandler = NULL;
    354         pThis->pIrqContext   = NULL;
    355         pThis->iHostIrq      = -1;
    356         *piHostIrq = -1;
     341DECLHIDDEN(int) vboxPciDevRegisterIrqHandler(PRAWPCIDEVPORT pPort, PFNRAWPCIISR pfnHandler, void* pIrqContext, PCIRAWISRHANDLE *phIsr)
     342{
     343    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
     344    int     rc;
     345    int32_t iHostIrq = 0;   
     346
     347    if (pfnHandler == NULL)
     348        return VERR_INVALID_PARAMETER;
     349
     350    vboxPciDevLock(pThis);
     351
     352    if (pThis->IrqHandler.pfnIrqHandler)
     353    {
     354        rc = VERR_ALREADY_EXISTS;
    357355    }
    358356    else
    359         pThis->iHostIrq      = *piHostIrq;
    360 
    361     vboxPciDevUnlock(pThis);
    362 
    363     return rc;
    364 }
    365 
    366 DECLHIDDEN(int) vboxPciDevUnregisterIrqHandler(PRAWPCIDEVPORT pPort, int32_t iHostIrq)
    367 {
    368     PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
    369     int rc;
    370 
    371     vboxPciDevLock(pThis);
    372 
    373     Assert(iHostIrq == pThis->iHostIrq);
    374     rc = vboxPciOsDevUnregisterIrqHandler(pThis, iHostIrq);
     357    {
     358        rc = vboxPciOsDevRegisterIrqHandler(pThis, pfnHandler, pIrqContext, &iHostIrq);
     359        if (RT_SUCCESS(rc))
     360        {
     361            *phIsr = 0xcafe0000;
     362            pThis->IrqHandler.iHostIrq      = iHostIrq;
     363            pThis->IrqHandler.pfnIrqHandler = pfnHandler;
     364            pThis->IrqHandler.pIrqContext   = pIrqContext;
     365        }
     366    }
     367       
     368    vboxPciDevUnlock(pThis);
     369
     370    return rc;
     371}
     372
     373DECLHIDDEN(int) vboxPciDevUnregisterIrqHandler(PRAWPCIDEVPORT pPort, PCIRAWISRHANDLE hIsr)
     374{
     375    PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort);
     376    int rc;
     377
     378    if (hIsr != 0xcafe0000)
     379        return VERR_INVALID_PARAMETER;
     380
     381    vboxPciDevLock(pThis);
     382
     383    rc = vboxPciOsDevUnregisterIrqHandler(pThis, pThis->IrqHandler.iHostIrq);
    375384    if (RT_SUCCESS(rc))
    376385    {
    377         pThis->pfnIrqHandler = NULL;
    378         pThis->pIrqContext   = NULL;
    379         pThis->iHostIrq = -1;
     386        pThis->IrqHandler.pfnIrqHandler = NULL;
     387        pThis->IrqHandler.pIrqContext   = NULL;
     388        pThis->IrqHandler.iHostIrq = -1;
    380389    }
    381390    vboxPciDevUnlock(pThis);
     
    393402    rc = vboxPciOsDevPowerStateChange(pThis, aState);
    394403
    395     if (aState == PCIRAW_POWER_ON)
    396     {
    397         /*
    398          * Let virtual device know about VM caps.
    399          */
    400         *pu64Param = VBOX_DRV_VMDATA(pThis)->pPerVmData->fVmCaps;
    401     }
    402     else
    403         pu64Param = 0;
     404    switch (aState)
     405    {
     406        case PCIRAW_POWER_ON:
     407            /*
     408             * Let virtual device know about VM caps.
     409             */
     410            *pu64Param = VBOX_DRV_VMDATA(pThis)->pPerVmData->fVmCaps;
     411            break;
     412        default:
     413            pu64Param = 0;
     414            break;
     415    }
    404416
    405417
     
    434446    pNew->pNext                         = NULL;
    435447    pNew->HostPciAddress                = u32HostAddress;
    436     pNew->iHostIrq                      = -1;
    437448    pNew->pVmCtx                        = pVmCtx;
    438449
  • trunk/src/VBox/HostDrivers/VBoxPci/VBoxPciInternal.h

    r36484 r36485  
    2727
    2828#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 35)
    29 //# ifdef DEBUG_nike
    30 #  define VBOX_WITH_IOMMU
    31 //# endif
     29# define VBOX_WITH_IOMMU
    3230#endif
    3331
     
    4543typedef struct VBOXRAWPCIDRVVM   *PVBOXRAWPCIDRVVM;
    4644typedef struct VBOXRAWPCIINS     *PVBOXRAWPCIINS;
     45
     46typedef struct VBOXRAWPCIISRDESC
     47{
     48    /** Handler function. */
     49    PFNRAWPCIISR       pfnIrqHandler;
     50    /** Handler context. */
     51    void              *pIrqContext;
     52    /** Host IRQ. */
     53    int32_t            iHostIrq;
     54} VBOXRAWPCIISRDESC;
     55typedef struct VBOXRAWPCIISRDESC     *PVBOXRAWPCIISRDESC;
    4756
    4857/**
     
    7786    bool               fPad0;
    7887
    79     /** Temporary: host IRQ we were given. Assumes single IRQ devices. */
    80     int32_t            iHostIrq;
    81 
    8288    /** Port, given to the outside world. */
    8389    RAWPCIDEVPORT      DevPort;
    8490
    85     uint32_t           cHandlersCount;
    86     PFNRAWPCIISR       pfnIrqHandler;
    87     void              *pIrqContext;
     91    /** IRQ handler. */
     92    VBOXRAWPCIISRDESC  IrqHandler;
    8893
     94    /** Pointer to per-VM context in hypervisor data. */
    8995    PRAWPCIPERVM       pVmCtx;
    9096} VBOXRAWPCIINS;
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