VBVABase.cpp revision 0fc8a97f9a19a44f1ad4670454edf26d80c42281
/* $Id$ */
/** @file
* VirtualBox Video driver, common code - VBVA initialisation and helper
* functions.
*/
/*
* Copyright (C) 2006-2010 Oracle Corporation
*
* 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.
*/
#include <VBox/VBoxVideoGuest.h>
#include <VBox/VBoxVideo.h>
/*
* There is a hardware ring buffer in the graphics device video RAM, formerly
* in the VBox VMMDev PCI memory space.
* All graphics commands go there serialized by VBoxVBVABufferBeginUpdate.
* and vboxHwBufferEndUpdate.
*
* off32Free is writing position. off32Data is reading position.
* off32Free == off32Data means buffer is empty.
* There must be always gap between off32Data and off32Free when data
* are in the buffer.
* Guest only changes off32Free, host changes off32Data.
*/
/* Forward declarations of internal functions. */
{
bool bRc = false;
#if 0 /* All callers check this */
if (ppdev->bHGSMISupported)
#endif
{
void *p = VBoxHGSMIBufferAlloc(pHGSMICtx,
sizeof (VBVAENABLE_EX),
if (!p)
{
LogFunc(("HGSMIHeapAlloc failed\n"));
}
else
{
if (cScreen >= 0)
{
}
if (bEnable)
{
}
else
{
bRc = true;
}
}
}
return bRc;
}
/*
* Public hardware buffer methods.
*/
{
bool bRc = false;
#if 0 /* All callers check this */
if (ppdev->bHGSMISupported)
#endif
{
pVBVA->indexRecordFirst = 0;
pVBVA->indexRecordFree = 0;
pCtx->fHwBufferOverflow = false;
}
if (!bRc)
{
}
return bRc;
}
{
LogFlowFunc(("\n"));
pCtx->fHwBufferOverflow = false;
return;
}
{
bool bRc = false;
// LogFunc(("flags = 0x%08X\n", pCtx->pVBVA? pCtx->pVBVA->u32HostEvents: -1));
{
{
/* All slots in the records queue are used. */
}
{
/* Even after flush there is no place. Fail the request. */
LogFunc(("no space in the queue of records!!! first %d, last %d\n",
}
else
{
/* Initialize the record. */
// LogFunc(("indexRecordNext = %d\n", indexRecordNext));
/* Remember which record we are using. */
bRc = true;
}
}
return bRc;
}
{
// LogFunc(("\n"));
/* Mark the record completed. */
pCtx->fHwBufferOverflow = false;
return;
}
/*
* Private operations.
*/
{
}
{
/* Issue the flush command. */
void *p = VBoxHGSMIBufferAlloc(pCtx,
sizeof (VBVAFLUSH),
if (!p)
{
LogFunc(("HGSMIHeapAlloc failed\n"));
}
else
{
pFlush->u32Reserved = 0;
VBoxHGSMIBufferFree(pCtx, p);
}
return;
}
{
if (i32Diff <= 0)
{
/* Chunk will not cross buffer boundary. */
}
else
{
/* Chunk crosses buffer boundary. */
}
return;
}
{
{
return false;
}
while (cb > 0)
{
// LogFunc(("pVBVA->off32Free %d, pRecord->cbRecord 0x%08X, cbHwBufferAvail %d, cb %d, cbWritten %d\n",
// pVBVA->off32Free, pRecord->cbRecord, cbHwBufferAvail, cb, cbWritten));
if (cbChunk >= cbHwBufferAvail)
{
if (cbChunk >= cbHwBufferAvail)
{
LogFunc(("no place for %d bytes. Only %d bytes available after flush. Going to partial writes.\n",
cb, cbHwBufferAvail));
{
LogFunc(("Buffer overflow!!!\n"));
pCtx->fHwBufferOverflow = true;
Assert(false);
return false;
}
}
}
}
return true;
}
/*
* Public writer to the hardware buffer.
*/
{
}
{
if (!pVBVA)
{
return false;
}
{
return true;
}
return false;
}
{
}