static DECLCALLBACK(int) vboxPciDevPowerStateChange(PRAWPCIDEVPORT pPort, PCIRAWPOWERSTATE aState, uint64_t *pu64Param) { PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); int rc; RTSPINLOCKTMP aTmp; vboxPciDevLock(pThis, &aTmp); rc = vboxPciOsDevPowerStateChange(pThis, aState); switch (aState) { case PCIRAW_POWER_ON: /* * Let virtual device know about VM caps. */ *pu64Param = VBOX_DRV_VMDATA(pThis)->pPerVmData->fVmCaps; break; default: pu64Param = 0; break; } vboxPciDevUnlock(pThis, &aTmp); return rc; }
static DECLCALLBACK(int) vboxPciDevRegisterIrqHandler(PRAWPCIDEVPORT pPort, PFNRAWPCIISR pfnHandler, void* pIrqContext, PCIRAWISRHANDLE *phIsr) { PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); int rc; int32_t iHostIrq = 0; RTSPINLOCKTMP aTmp; if (pfnHandler == NULL) return VERR_INVALID_PARAMETER; vboxPciDevLock(pThis, &aTmp); if (pThis->IrqHandler.pfnIrqHandler) { rc = VERR_ALREADY_EXISTS; } else { rc = vboxPciOsDevRegisterIrqHandler(pThis, pfnHandler, pIrqContext, &iHostIrq); if (RT_SUCCESS(rc)) { *phIsr = 0xcafe0000; pThis->IrqHandler.iHostIrq = iHostIrq; pThis->IrqHandler.pfnIrqHandler = pfnHandler; pThis->IrqHandler.pIrqContext = pIrqContext; } } vboxPciDevUnlock(pThis, &aTmp); return rc; }
/** * @copydoc RAWPCIDEVPORT:: pfnInit */ static DECLCALLBACK(int) vboxPciDevInit(PRAWPCIDEVPORT pPort, uint32_t fFlags) { PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); int rc; vboxPciDevLock(pThis); rc = vboxPciOsDevInit(pThis, fFlags); vboxPciDevUnlock(pThis); return rc; }
/** * @copydoc RAWPCIDEVPORT:: pfnPciCfgWrite */ static DECLCALLBACK(int) vboxPciDevPciCfgWrite(PRAWPCIDEVPORT pPort, uint32_t Register, PCIRAWMEMLOC *pValue) { PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); int rc; vboxPciDevLock(pThis); rc = vboxPciOsDevPciCfgWrite(pThis, Register, pValue); vboxPciDevUnlock(pThis); return rc; }
/** * @copydoc RAWPCIDEVPORT:: pfnPciCfgRead */ static DECLCALLBACK(int) vboxPciDevPciCfgRead(PRAWPCIDEVPORT pPort, uint32_t Register, PCIRAWMEMLOC *pValue) { PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); RTSPINLOCKTMP aTmp; int rc; vboxPciDevLock(pThis, &aTmp); rc = vboxPciOsDevPciCfgRead(pThis, Register, pValue); vboxPciDevUnlock(pThis, &aTmp); return rc; }
/** * @copydoc RAWPCIDEVPORT:: pfnUnapRegion */ static DECLCALLBACK(int) vboxPciDevUnmapRegion(PRAWPCIDEVPORT pPort, int32_t iRegion, RTHCPHYS RegionStart, uint64_t u64RegionSize, RTR0PTR RegionBase) { PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); int rc; vboxPciDevLock(pThis); rc = vboxPciOsDevUnmapRegion(pThis, iRegion, RegionStart, u64RegionSize, RegionBase); vboxPciDevUnlock(pThis); return rc; }
/** * @copydoc RAWPCIDEVPORT:: pfnMapRegion */ static DECLCALLBACK(int) vboxPciDevMapRegion(PRAWPCIDEVPORT pPort, int32_t iRegion, RTHCPHYS RegionStart, uint64_t u64RegionSize, int32_t fFlags, RTR0PTR *pRegionBase) { PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); int rc; RTSPINLOCKTMP aTmp; vboxPciDevLock(pThis, &aTmp); rc = vboxPciOsDevMapRegion(pThis, iRegion, RegionStart, u64RegionSize, fFlags, pRegionBase); vboxPciDevUnlock(pThis, &aTmp); return rc; }
/** * @copydoc RAWPCIDEVPORT:: pfnGetRegionInfo */ static DECLCALLBACK(int) vboxPciDevGetRegionInfo(PRAWPCIDEVPORT pPort, int32_t iRegion, RTHCPHYS *pRegionStart, uint64_t *pu64RegionSize, bool *pfPresent, uint32_t *pfFlags) { PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); int rc; vboxPciDevLock(pThis); rc = vboxPciOsDevGetRegionInfo(pThis, iRegion, pRegionStart, pu64RegionSize, pfPresent, pfFlags); vboxPciDevUnlock(pThis); return rc; }
/** * @copydoc RAWPCIDEVPORT:: pfnDeinit */ static DECLCALLBACK(int) vboxPciDevDeinit(PRAWPCIDEVPORT pPort, uint32_t fFlags) { PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); int rc; vboxPciDevLock(pThis); if (pThis->IrqHandler.pfnIrqHandler) { vboxPciOsDevUnregisterIrqHandler(pThis, pThis->IrqHandler.iHostIrq); pThis->IrqHandler.iHostIrq = 0; pThis->IrqHandler.pfnIrqHandler = NULL; } rc = vboxPciOsDevDeinit(pThis, fFlags); vboxPciDevUnlock(pThis); return rc; }
static DECLCALLBACK(int) vboxPciDevUnregisterIrqHandler(PRAWPCIDEVPORT pPort, PCIRAWISRHANDLE hIsr) { PVBOXRAWPCIINS pThis = DEVPORT_2_VBOXRAWPCIINS(pPort); int rc; if (hIsr != 0xcafe0000) return VERR_INVALID_PARAMETER; vboxPciDevLock(pThis); rc = vboxPciOsDevUnregisterIrqHandler(pThis, pThis->IrqHandler.iHostIrq); if (RT_SUCCESS(rc)) { pThis->IrqHandler.pfnIrqHandler = NULL; pThis->IrqHandler.pIrqContext = NULL; pThis->IrqHandler.iHostIrq = 0; } vboxPciDevUnlock(pThis); return rc; }