DevVGA_VDMA.cpp revision 9b685c2d5884974046643a2f04e20593c860264e
/** @file
* Video DMA (VDMA) support.
*/
/*
* Copyright (C) 2006-2009 Sun Microsystems, Inc.
*
* This file is part of VirtualBox Open Source Edition (OSE), as
* available from http://www.virtualbox.org. This file is free software;
* General Public License (GPL) as published by the Free Software
* Foundation, in version 2 as it comes in the "COPYING" file of the
* VirtualBox OSE distribution. VirtualBox OSE is distributed in the
* hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
*
* Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa
* Clara, CA 95054 USA or visit http://www.sun.com if you need
* additional information or have any questions.
*/
#include <VBox/VBoxVideo.h>
#include <iprt/semaphore.h>
#include "DevVGA.h"
#include "HGSMI/SHGSMIHost.h"
#include "HGSMI/HGSMIHostHlp.h"
typedef enum
{
typedef struct VBOXVDMAPIPE
{
/* critical section for accessing pipe properties */
/* true iff the other end needs Event notification */
bool bNeedNotify;
typedef enum
{
typedef struct VBOXVDMAPIPE_CMD_BODY
{
union
{
void *pvCmd;
} u;
typedef struct VBOXVDMAPIPE_CMD
{
#define VBOXVDMAPIPE_CMD_FROM_ENTRY(_pE) ( (PVBOXVDMAPIPE_CMD)((uint8_t *)(_pE) - RT_OFFSETOF(VBOXVDMAPIPE_CMD, Entry)) )
typedef struct VBOXVDMAPIPE_CMD_POOL
{
typedef struct VBOXVDMAHOST
{
/* to simplify things and to avoid extra backend if modifications we assume the VBOXVDMA_RECTL is the same as VBVACMDHDR */
static int vboxVDMANotifyPrimaryUpdate (PVGASTATE pVGAState, unsigned uScreenId, const VBOXVDMA_RECTL * pRectl)
{
/* Updates the rectangle and sends the command to the VRDP server. */
sizeof (VBOXVDMA_RECTL));
return VINF_SUCCESS;
}
{
/* we do not support color conversion */
/* we do not support stretching */
return VERR_INVALID_FUNCTION;
{
}
else
{
uint32_t offDstLineEnd = ((pDstRectl->left * pDstDesc->bpp + 7) >> 3) + ((pDstDesc->bpp * pDstRectl->width + 7) >> 3);
uint32_t offSrcLineEnd = ((pSrcRectl->left * pSrcDesc->bpp + 7) >> 3) + ((pSrcDesc->bpp * pSrcRectl->width + 7) >> 3);
for (uint32_t i = 0; ; ++i)
{
break;
pvDstStart += cbDstSkip;
pvSrcStart += cbSrcSkip;
}
}
return VINF_SUCCESS;
}
{
else
{
{
}
{
}
}
}
/*
* @return on success the number of bytes the command contained, otherwise - VERR_xxx error code
*/
static int vboxVDMACmdExecBlt(PVBOXVDMAHOST pVdma, const PVBOXVDMACMD_DMA_PRESENT_BLT pBlt, uint32_t cbBuffer)
{
const uint32_t cbBlt = VBOXVDMACMD_BODY_FIELD_OFFSET(uint32_t, VBOXVDMACMD_DMA_PRESENT_BLT, aDstSubRects[pBlt->cDstSubRects]);
return VERR_INVALID_FUNCTION;
/* we do not support stretching for now */
return VERR_INVALID_FUNCTION;
return VERR_INVALID_FUNCTION;
VBOXVDMA_RECTL updateRectl = {0};
if (pBlt->cDstSubRects)
{
{
{
}
{
}
if (!RT_SUCCESS(rc))
return rc;
}
}
else
{
if (!RT_SUCCESS(rc))
return rc;
}
int iView = 0;
/* @todo: fixme: check if update is needed and get iView */
return cbBlt;
}
{
do
{
if (!pvBuffer)
return VERR_INVALID_PARAMETER;
if (cbBuffer < VBOXVDMACMD_HEADER_SIZE())
return VERR_INVALID_PARAMETER;
{
{
if (cbBlt >= 0)
{
return VINF_SUCCESS;
else
{
}
}
else
return cbBlt; /* error */
break;
}
default:
return VERR_INVALID_FUNCTION;
}
} while (1);
/* we should not be here */
return VERR_INVALID_STATE;
}
{
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
pPipe->bNeedNotify = true;
return VINF_SUCCESS;
// RTCritSectDelete(pPipe->hCritSect);
}
}
return rc;
}
{
if (RT_SUCCESS(rc))
{
{
pPipe->bNeedNotify = false;
rc = VINF_SUCCESS;
break;
pPipe->bNeedNotify = false;
break;
default:
break;
}
}
return rc;
}
{
if (RT_SUCCESS(rc))
{
{
rc = VINF_SUCCESS;
break;
break;
default:
break;
}
}
return rc;
}
{
if (RT_SUCCESS(rc))
{
bool bNeedNotify = false;
{
pPipe->bNeedNotify = false;
break;
pPipe->bNeedNotify = false;
break;
break;
default:
break;
}
if (bNeedNotify)
{
}
}
return rc;
}
typedef FNHVBOXVDMARWCB *PFNHVBOXVDMARWCB;
{
if (RT_SUCCESS(rc))
{
do
{
{
if (bProcessing)
{
rc = VINF_SUCCESS;
break;
}
{
break;
}
}
else
{
break;
}
if (!RT_SUCCESS(rc))
break;
if (!RT_SUCCESS(rc))
break;
} while (1);
}
return rc;
}
{
if (RT_SUCCESS(rc))
{
bool bNeedNotify = false;
{
if (bModified)
{
pPipe->bNeedNotify = false;
}
}
else
if (bNeedNotify)
{
}
}
return rc;
}
{
/* ensure the pipe is closed */
return VERR_INVALID_STATE;
return VINF_SUCCESS;
}
{
int rc;
bool bReleaseLocked = false;
do
{
{
}
else
{
{
/* @todo: more advanced mechanism of command buffer proc is actually needed */
break;
}
const void * pvPageBuf;
if (!RT_SUCCESS(rc))
{
/* @todo: if (rc == VERR_PGM_PHYS_PAGE_RESERVED) -> fall back on using PGMPhysRead ?? */
break;
}
bReleaseLocked = true;
}
if (bReleaseLocked)
} while (0);
}
{
}
typedef struct
{
struct VBOXVDMAHOST *pVdma;
bool bHasCmd;
{
if (pEntry)
{
return true;
}
return false;
}
{
if (RT_SUCCESS(rc))
{
do
{
if (RT_SUCCESS(rc))
{
{
{
break;
}
{
break;
}
default:
break;
}
{
rc = VINF_SUCCESS;
break;
}
}
else
break;
} while (1);
}
/* always try to close the pipe to make sure the client side is notified */
return rc;
}
{
int rc;
PVBOXVDMAHOST pVdma = (PVBOXVDMAHOST)RTMemAllocZ (RT_OFFSETOF(VBOXVDMAHOST, CmdPool.aCmds[cPipeElements]));
if (pVdma)
{
if (RT_SUCCESS(rc))
{
rc = RTThreadCreate(&pVdma->hWorkerThread, vboxVDMAWorkerThread, pVdma, 0, RTTHREADTYPE_IO, RTTHREADFLAGS_WAITABLE, "VDMA");
if (RT_SUCCESS(rc))
{
for (uint32_t i = 0; i < cPipeElements; ++i)
{
}
return VINF_SUCCESS;
}
}
}
else
return rc;
}
{
return VINF_SUCCESS;
}
typedef struct
{
struct VBOXVDMAHOST *pVdma;
bool bQueued;
{
if (pEntry)
{
return true;
}
/* @todo: should we try to flush some commands here? */
return false;
}
{
#if 1
{
case VBOXVDMA_CTL_TYPE_ENABLE:
break;
break;
case VBOXVDMA_CTL_TYPE_FLUSH:
break;
default:
}
#else
/* test asinch completion */
if (RT_SUCCESS(rc))
{
{
/* success */
return;
}
}
/* failure */
#endif
}
{
if (RT_SUCCESS(rc))
{
{
/* success */
return;
}
}
/* failure */
}