DECLCALLBACK(int) vmmdevVideoModeSupported(PPDMIVMMDEVCONNECTOR pInterface, uint32_t display, uint32_t width, uint32_t height, uint32_t bpp, bool *fSupported) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); Console *pConsole = pDrv->pVMMDev->getParent(); if (!fSupported) return VERR_INVALID_PARAMETER; #ifdef DEBUG_sunlover Log(("vmmdevVideoModeSupported: [%d]: %dx%dx%d\n", display, width, height, bpp)); #endif IFramebuffer *framebuffer = NULL; LONG xOrigin = 0; LONG yOrigin = 0; HRESULT hrc = pConsole->getDisplay()->GetFramebuffer(display, &framebuffer, &xOrigin, &yOrigin); if (SUCCEEDED(hrc) && framebuffer) { framebuffer->VideoModeSupported(width, height, bpp, (BOOL*)fSupported); framebuffer->Release(); } else { #ifdef DEBUG_sunlover Log(("vmmdevVideoModeSupported: hrc %x, framebuffer %p!!!\n", hrc, framebuffer)); #endif *fSupported = true; } return VINF_SUCCESS; }
DECLCALLBACK(int) vmmdevSetCredentialsJudgementResult(PPDMIVMMDEVCONNECTOR pInterface, uint32_t u32Flags) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); if (pDrv->pVMMDev) return pDrv->pVMMDev->SetCredentialsJudgementResult (u32Flags); return VERR_GENERAL_FAILURE; }
DECLCALLBACK(int) VMMDev::QueryBalloonSize(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pu32BalloonSize) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); (void)pDrv; AssertPtr(pu32BalloonSize); *pu32BalloonSize = 0; return VINF_SUCCESS; }
DECLCALLBACK(int) vmmdevQueryVisibleRegion(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcRect, PRTRECT pRect) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); Console *pConsole = pDrv->pVMMDev->getParent(); /* Forward to Display, which calls corresponding framebuffers. */ pConsole->getDisplay()->handleQueryVisibleRegion(pcRect, pRect); return VINF_SUCCESS; }
DECLCALLBACK(int) VMMDev::GetHeightReduction(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *heightReduction) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); (void)pDrv; if (!heightReduction) return VERR_INVALID_PARAMETER; /* XXX hard-coded */ *heightReduction = 18; return VINF_SUCCESS; }
DECLCALLBACK(int) VMMDev::VideoModeSupported(PPDMIVMMDEVCONNECTOR pInterface, uint32_t display, uint32_t width, uint32_t height, uint32_t bpp, bool *fSupported) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); (void)pDrv; if (!fSupported) return VERR_INVALID_PARAMETER; *fSupported = true; return VINF_SUCCESS; }
DECLCALLBACK(void) iface_VideoAccelFlush(PPDMIVMMDEVCONNECTOR pInterface) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); Console *pConsole = pDrv->pVMMDev->getParent(); Display *display = pConsole->getDisplay(); if (display) { LogSunlover(("MAIN::VMMDevInterface::iface_VideoAccelFlush\n")); display->VideoAccelFlush (); } }
/** * Update the mouse capabilities. * This is called when the mouse capabilities change. The new capabilities * are given and the connector should update its internal state. * * @param pInterface Pointer to this interface. * @param newCapabilities New capabilities. * @thread The emulation thread. */ DECLCALLBACK(void) vmmdevUpdateMouseCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t fNewCaps) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); Console *pConsole = pDrv->pVMMDev->getParent(); /* * Tell the console interface about the event * so that it can notify its consumers. */ Mouse *pMouse = pConsole->getMouse(); if (pMouse) /** @todo and if not? Can that actually happen? */ pMouse->onVMMDevGuestCapsChange(fNewCaps & VMMDEV_MOUSE_GUEST_MASK); }
DECLCALLBACK(int) vmmdevGetHeightReduction(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *heightReduction) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); Console *pConsole = pDrv->pVMMDev->getParent(); if (!heightReduction) return VERR_INVALID_PARAMETER; IFramebuffer *framebuffer = pConsole->getDisplay()->getFramebuffer(); if (framebuffer) framebuffer->COMGETTER(HeightReduction)((ULONG*)heightReduction); else *heightReduction = 0; return VINF_SUCCESS; }
DECLCALLBACK(int) iface_VideoAccelEnable(PPDMIVMMDEVCONNECTOR pInterface, bool fEnable, VBVAMEMORY *pVbvaMemory) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); Console *pConsole = pDrv->pVMMDev->getParent(); Display *display = pConsole->getDisplay(); if (display) { LogSunlover(("MAIN::VMMDevInterface::iface_VideoAccelEnable: %d, %p\n", fEnable, pVbvaMemory)); return display->VideoAccelEnable(fEnable, pVbvaMemory); } return VERR_NOT_SUPPORTED; }
/** * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateGuestStatus} */ DECLCALLBACK(void) vmmdevUpdateGuestStatus(PPDMIVMMDEVCONNECTOR pInterface, uint32_t uFacility, uint16_t uStatus, uint32_t fFlags, PCRTTIMESPEC pTimeSpecTS) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); Console *pConsole = pDrv->pVMMDev->getParent(); /* Store that information in IGuest */ Guest* guest = pConsole->getGuest(); Assert(guest); if (!guest) return; guest->setAdditionsStatus((VBoxGuestFacilityType)uFacility, (VBoxGuestFacilityStatus)uStatus, fFlags, pTimeSpecTS); pConsole->onAdditionsStateChange(); }
/** * Reports Guest Additions API and OS version. * * Called whenever the Additions issue a guest version report request or the VM * is reset. * * @param pInterface Pointer to this interface. * @param guestInfo Pointer to guest information structure. * @thread The emulation thread. */ DECLCALLBACK(void) vmmdevUpdateGuestInfo(PPDMIVMMDEVCONNECTOR pInterface, const VBoxGuestInfo *guestInfo) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); Assert(guestInfo); if (!guestInfo) return; Console *pConsole = pDrv->pVMMDev->getParent(); /* Store that information in IGuest */ Guest* guest = pConsole->getGuest(); Assert(guest); if (!guest) return; if (guestInfo->interfaceVersion != 0) { char version[16]; RTStrPrintf(version, sizeof(version), "%d", guestInfo->interfaceVersion); guest->setAdditionsInfo(Bstr(version), guestInfo->osType); /* * Tell the console interface about the event * so that it can notify its consumers. */ pConsole->onAdditionsStateChange(); if (guestInfo->interfaceVersion < VMMDEV_VERSION) pConsole->onAdditionsOutdated(); } else { /* * The guest additions was disabled because of a reset * or driver unload. */ guest->setAdditionsInfo(Bstr(), guestInfo->osType); /* Clear interface version + OS type. */ /** @todo Would be better if GuestImpl.cpp did all this in the above method call * while holding down the. */ guest->setAdditionsInfo2(0, "", 0, 0); /* Clear Guest Additions version. */ RTTIMESPEC TimeSpecTS; RTTimeNow(&TimeSpecTS); guest->setAdditionsStatus(VBoxGuestFacilityType_All, VBoxGuestFacilityStatus_Inactive, 0 /*fFlags*/, &TimeSpecTS); pConsole->onAdditionsStateChange(); } }
/** * Report new guest statistics * * @returns VBox status code. * @param pInterface Pointer to this interface. * @param pGuestStats Guest statistics * @thread The emulation thread. */ DECLCALLBACK(int) vmmdevReportStatistics(PPDMIVMMDEVCONNECTOR pInterface, VBoxGuestStatistics *pGuestStats) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); Console *pConsole = pDrv->pVMMDev->getParent(); Assert(pGuestStats); if (!pGuestStats) return VERR_INVALID_POINTER; /* store that information in IGuest */ Guest* guest = pConsole->getGuest(); Assert(guest); if (!guest) return VERR_GENERAL_FAILURE; if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_IDLE) guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUIDLE, pGuestStats->u32CpuLoad_Idle); if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_KERNEL) guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUKERNEL, pGuestStats->u32CpuLoad_Kernel); if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_CPU_LOAD_USER) guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_CPUUSER, pGuestStats->u32CpuLoad_User); /** @todo r=bird: Convert from 4KB to 1KB units? * CollectorGuestHAL::getGuestMemLoad says it returns KB units to * preCollect(). I might be wrong ofc, this is convoluted code... */ if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_TOTAL) guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMTOTAL, pGuestStats->u32PhysMemTotal); if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_AVAIL) guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMFREE, pGuestStats->u32PhysMemAvail); if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PHYS_MEM_BALLOON) guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMBALLOON, pGuestStats->u32PhysMemBalloon); if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_MEM_SYSTEM_CACHE) guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_MEMCACHE, pGuestStats->u32MemSystemCache); if (pGuestStats->u32StatCaps & VBOX_GUEST_STAT_PAGE_FILE_SIZE) guest->setStatistic(pGuestStats->u32CpuId, GUESTSTATTYPE_PAGETOTAL, pGuestStats->u32PageFileSize); return VINF_SUCCESS; }
/** * Query the current page fusion setting * * @returns VBox status code. * @param pInterface Pointer to this interface. * @param pfPageFusionEnabled Pointer to boolean * @thread The emulation thread. */ DECLCALLBACK(int) vmmdevIsPageFusionEnabled(PPDMIVMMDEVCONNECTOR pInterface, bool *pfPageFusionEnabled) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); Console *pConsole = pDrv->pVMMDev->getParent(); BOOL val = 0; if (!pfPageFusionEnabled) return VERR_INVALID_POINTER; /* store that information in IGuest */ Guest* guest = pConsole->getGuest(); Assert(guest); if (!guest) return VERR_GENERAL_FAILURE; *pfPageFusionEnabled = !!guest->isPageFusionEnabled(); return VINF_SUCCESS; }
/** * Query the current balloon size * * @returns VBox status code. * @param pInterface Pointer to this interface. * @param pcbBalloon Balloon size * @thread The emulation thread. */ DECLCALLBACK(int) vmmdevQueryBalloonSize(PPDMIVMMDEVCONNECTOR pInterface, uint32_t *pcbBalloon) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); Console *pConsole = pDrv->pVMMDev->getParent(); ULONG val = 0; if (!pcbBalloon) return VERR_INVALID_POINTER; /* store that information in IGuest */ Guest* guest = pConsole->getGuest(); Assert(guest); if (!guest) return VERR_GENERAL_FAILURE; guest->COMGETTER(MemoryBalloonSize)(&val); *pcbBalloon = val; return VINF_SUCCESS; }
/** * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateGuestUserState} */ DECLCALLBACK(void) vmmdevUpdateGuestUserState(PPDMIVMMDEVCONNECTOR pInterface, const char *pszUser, const char *pszDomain, uint32_t uState, const uint8_t *puDetails, uint32_t cbDetails) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); AssertPtr(pDrv); Console *pConsole = pDrv->pVMMDev->getParent(); AssertPtr(pConsole); /* Store that information in IGuest. */ Guest* pGuest = pConsole->getGuest(); AssertPtr(pGuest); if (!pGuest) return; pGuest->onUserStateChange(Bstr(pszUser), Bstr(pszDomain), (VBoxGuestUserState)uState, puDetails, cbDetails); }
/** * Update the pointer shape or visibility. * * This is called when the mouse pointer shape changes or pointer is hidden/displaying. * The new shape is passed as a caller allocated buffer that will be freed after returning. * * @param pInterface Pointer to this interface. * @param fVisible Whether the pointer is visible or not. * @param fAlpha Alpha channel information is present. * @param xHot Horizontal coordinate of the pointer hot spot. * @param yHot Vertical coordinate of the pointer hot spot. * @param width Pointer width in pixels. * @param height Pointer height in pixels. * @param pShape The shape buffer. If NULL, then only pointer visibility is being changed. * @thread The emulation thread. */ DECLCALLBACK(void) vmmdevUpdatePointerShape(PPDMIVMMDEVCONNECTOR pInterface, bool fVisible, bool fAlpha, uint32_t xHot, uint32_t yHot, uint32_t width, uint32_t height, void *pShape) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); Console *pConsole = pDrv->pVMMDev->getParent(); /* tell the console about it */ size_t cbShapeSize = 0; if (pShape) { cbShapeSize = (width + 7) / 8 * height; /* size of the AND mask */ cbShapeSize = ((cbShapeSize + 3) & ~3) + width * 4 * height; /* + gap + size of the XOR mask */ } com::SafeArray<BYTE> shapeData(cbShapeSize); if (pShape) ::memcpy(shapeData.raw(), pShape, cbShapeSize); pConsole->onMousePointerShapeChange(fVisible, fAlpha, xHot, yHot, width, height, ComSafeArrayAsInParam(shapeData)); }
/** * @interface_method_impl{PDMIVMMDEVCONNECTOR,pfnUpdateGuestInfo2} */ DECLCALLBACK(void) vmmdevUpdateGuestInfo2(PPDMIVMMDEVCONNECTOR pInterface, uint32_t uFullVersion, const char *pszName, uint32_t uRevision, uint32_t fFeatures) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); AssertPtr(pszName); Assert(uFullVersion); /* Store that information in IGuest. */ Guest *pGuest = pDrv->pVMMDev->getParent()->getGuest(); Assert(pGuest); if (!pGuest) return; /* Just pass it on... */ pGuest->setAdditionsInfo2(uFullVersion, pszName, uRevision, fFeatures); /* * No need to tell the console interface about the update; * vmmdevUpdateGuestInfo takes care of that when called as the * last event in the chain. */ }
/** * Update the guest additions capabilities. * This is called when the guest additions capabilities change. The new capabilities * are given and the connector should update its internal state. * * @param pInterface Pointer to this interface. * @param newCapabilities New capabilities. * @thread The emulation thread. */ DECLCALLBACK(void) vmmdevUpdateGuestCapabilities(PPDMIVMMDEVCONNECTOR pInterface, uint32_t newCapabilities) { PDRVMAINVMMDEV pDrv = PDMIVMMDEVCONNECTOR_2_MAINVMMDEV(pInterface); AssertPtr(pDrv); Console *pConsole = pDrv->pVMMDev->getParent(); /* store that information in IGuest */ Guest* pGuest = pConsole->getGuest(); AssertPtr(pGuest); if (!pGuest) return; /* * Report our current capabilities (and assume none is active yet). */ pGuest->setSupportedFeatures(newCapabilities); /* * Tell the console interface about the event * so that it can notify its consumers. */ pConsole->onAdditionsStateChange(); }