コード例 #1
0
/**
 * Checks whether the host supports physical page lists or not.
 *
 * @returns true if it does, false if it doesn't.
 */
DECLR0VBGL(bool) VbglR0CanUsePhysPageList(void)
{
    /* a_fLocked is false, because the actual capability of the host is requested.
     * See VBGLR0_CAN_USE_PHYS_PAGE_LIST definition.
     */
    int rc = vbglR0Enter();
    return RT_SUCCESS(rc)
        && VBGLR0_CAN_USE_PHYS_PAGE_LIST(/*a_fLocked =*/ false);
}
コード例 #2
0
DECLVBGL(int) VbglR0QueryVMMDevMemory(VMMDevMemory **ppVMMDevMemory)
{
    int rc = vbglR0Enter();
    if (RT_FAILURE(rc))
        return rc;

    /* If the memory was not found, return an error. */
    if (!g_vbgldata.pVMMDevMemory)
        return VERR_NOT_SUPPORTED;

    *ppVMMDevMemory = g_vbgldata.pVMMDevMemory;
    return rc;
}
DECLR0VBGL(int) VbglR0GRPerform(VMMDevRequestHeader *pReq)
{
    int rc = vbglR0Enter();
    if (RT_SUCCESS(rc))
    {
        if (pReq)
        {
            RTCCPHYS PhysAddr = VbglR0PhysHeapGetPhysAddr(pReq);
            if (   PhysAddr != 0
                && PhysAddr < _4G) /* Port IO is 32 bit. */
            {
                ASMOutU32(g_vbgldata.portVMMDev + VMMDEV_PORT_OFF_REQUEST, (uint32_t)PhysAddr);
                /* Make the compiler aware that the host has changed memory. */
                ASMCompilerBarrier();
                rc = pReq->rc;
            }
            else
                rc = VERR_VBGL_INVALID_ADDR;
        }
        else
            rc = VERR_INVALID_PARAMETER;
    }
    return rc;
}
DECLR0VBGL(int) VbglR0GRAlloc(VMMDevRequestHeader **ppReq, size_t cbReq, VMMDevRequestType enmReqType)
{
    int rc = vbglR0Enter();
    if (RT_SUCCESS(rc))
    {
        if (   ppReq
            && cbReq >= sizeof(VMMDevRequestHeader)
            && cbReq == (uint32_t)cbReq)
        {
            VMMDevRequestHeader *pReq = (VMMDevRequestHeader *)VbglR0PhysHeapAlloc((uint32_t)cbReq);
            AssertMsgReturn(pReq, ("VbglR0GRAlloc: no memory (cbReq=%u)\n", cbReq), VERR_NO_MEMORY);
            memset(pReq, 0xAA, cbReq);

            pReq->size        = (uint32_t)cbReq;
            pReq->version     = VMMDEV_REQUEST_HEADER_VERSION;
            pReq->requestType = enmReqType;
            pReq->rc          = VERR_GENERAL_FAILURE;
            pReq->reserved1   = 0;
#ifdef VBGL_VBOXGUEST
            pReq->fRequestor  = VMMDEV_REQUESTOR_KERNEL        | VMMDEV_REQUESTOR_USR_DRV
#else
            pReq->fRequestor  = VMMDEV_REQUESTOR_KERNEL        | VMMDEV_REQUESTOR_USR_DRV_OTHER
#endif

                              | VMMDEV_REQUESTOR_CON_DONT_KNOW | VMMDEV_REQUESTOR_TRUST_NOT_GIVEN;
            *ppReq = pReq;
            rc = VINF_SUCCESS;
        }
        else
        {
            dprintf(("VbglR0GRAlloc: Invalid parameter: ppReq=%p cbReq=%u\n", ppReq, cbReq));
            rc = VERR_INVALID_PARAMETER;
        }
    }
    return rc;
}
DECLR0VBGL(void) VbglR0GRFree(VMMDevRequestHeader *pReq)
{
    int rc = vbglR0Enter();
    if (RT_SUCCESS(rc))
        VbglR0PhysHeapFree(pReq);
}
コード例 #6
0
/**
 * Checks whether the host supports physical page lists or not.
 *
 * @returns true if it does, false if it doesn't.
 */
DECLR0VBGL(bool) VbglR0CanUsePhysPageList(void)
{
    int rc = vbglR0Enter();
    return RT_SUCCESS(rc)
        && VBGLR0_CAN_USE_PHYS_PAGE_LIST();
}