vbox.c revision 5f78f19127d8955c64678be9995cc0520382be78
/** @file
*
* VBoxGuest -- VirtualBox Win 2000/XP guest display driver
*
* VBox support functions.
*
* Copyright (C) 2006-2007 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 "driver.h"
#include <VBox/VBoxGuest.h>
/*
* There is a hardware ring buffer in the VBox VMMDev PCI memory space.
* All graphics commands go there serialized by vboxHwBufferBeginUpdate.
* 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. */
#ifndef VBOX_WITH_HGSMI
/*
* Public hardware buffer methods.
*/
{
if (!ghsemHwBuffer)
{
return FALSE;
}
&ulEnable,
sizeof (ulEnable),
&returnedDataLength) == 0)
{
{
/* All have been initialized. */
}
}
if (!bRc)
{
}
return bRc;
}
{
return;
}
{
DISPDBG((1, "VBoxDisp::vboxHwBufferBeginUpdate called flags = 0x%08X\n", pVbvaMemory? pVbvaMemory->fu32ModeFlags: -1));
if ( pVbvaMemory
{
{
/* All slots in the records queue are used. */
}
{
/* Even after flush there is no place. Fail the request. */
DISPDBG((1, "VBoxDisp::vboxHwBufferBeginUpdate no space in the queue of records!!! first %d, last %d\n",
}
else
{
/* Initialize the record. */
/* Remember which record we are using. */
}
}
return bRc;
}
{
/* Mark the record completed. */
return;
}
/*
* Private operations.
*/
{
}
{
return;
}
{
if (i32Diff <= 0)
{
/* Chunk will not cross buffer boundary. */
}
else
{
/* Chunk crosses buffer boundary. */
}
return;
}
{
if (ppdev->fHwBufferOverflow)
{
return FALSE;
}
while (cb > 0)
{
// DISPDBG((1, "VBoxDisp::vboxHwBufferWrite pVbvaMemory->off32Free %d, pRecord->cbRecord 0x%08X, cbHwBufferAvail %d, cb %d, cbWritten %d\n", pVbvaMemory->off32Free, pRecord->cbRecord, cbHwBufferAvail, cb, cbWritten));
if (cbChunk >= cbHwBufferAvail)
{
if (cbChunk >= cbHwBufferAvail)
{
DISPDBG((1, "VBoxDisp::vboxHwBufferWrite: no place for %d bytes. Only %d bytes available after flush. Going to partial writes.\n", cb, cbHwBufferAvail));
{
return FALSE;
}
}
}
}
return TRUE;
}
/*
* Public writer to hardware buffer.
*/
{
}
{
{
/* Order masking enabled. */
{
return TRUE;
}
}
return FALSE;
}
{
NULL,
0,
NULL,
0,
}
#else /* VBOX_WITH_HGSMI */
{
}
{
if (ppdev->bHGSMISupported)
{
sizeof (VBVAENABLE),
if (!p)
{
DISPDBG((0, "VBoxDISP::vboxVBVAInformHost: HGSMIHeapAlloc failed\n"));
}
else
{
vboxHGSMIBufferSubmit (ppdev, p);
}
}
return bRc;
}
/*
* Public hardware buffer methods.
*/
{
if (ppdev->bHGSMISupported)
{
pVBVA->u32HostEvents = 0;
pVBVA->u32SupportedOrders = 0;
pVBVA->indexRecordFirst = 0;
pVBVA->indexRecordFree = 0;
}
if (!bRc)
{
}
return bRc;
}
{
return;
}
{
// DISPDBG((1, "VBoxDisp::vboxHwBufferBeginUpdate called flags = 0x%08X\n",
// ppdev->pVBVA? ppdev->pVBVA->u32HostEvents: -1));
{
{
/* All slots in the records queue are used. */
}
{
/* Even after flush there is no place. Fail the request. */
DISPDBG((1, "VBoxDisp::vboxHwBufferBeginUpdate no space in the queue of records!!! first %d, last %d\n",
}
else
{
/* Initialize the record. */
// DISPDBG((1, "VBoxDisp::vboxHwBufferBeginUpdate indexRecordNext = %d\n", indexRecordNext));
/* Remember which record we are using. */
}
}
return bRc;
}
{
// DISPDBG((1, "VBoxDisp::vboxHwBufferEndUpdate called\n"));
/* Mark the record completed. */
return;
}
/*
* Private operations.
*/
{
}
{
/* Issue the flush command. */
sizeof (VBVA_FLUSH),
if (!p)
{
DISPDBG((0, "VBoxDISP::vboxHwBufferFlush: HGSMIHeapAlloc failed\n"));
}
else
{
pFlush->u32Reserved = 0;
vboxHGSMIBufferSubmit (ppdev, p);
}
return;
}
{
if (i32Diff <= 0)
{
/* Chunk will not cross buffer boundary. */
}
else
{
/* Chunk crosses buffer boundary. */
}
return;
}
{
{
return FALSE;
}
while (cb > 0)
{
// DISPDBG((1, "VBoxDisp::vboxHwBufferWrite 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)
{
DISPDBG((1, "VBoxDisp::vboxHwBufferWrite: no place for %d bytes. Only %d bytes available after flush. Going to partial writes.\n",
cb, cbHwBufferAvail));
{
return FALSE;
}
}
}
}
return TRUE;
}
/*
* Public writer to the hardware buffer.
*/
{
}
{
if (!pVBVA)
{
return FALSE;
}
{
return TRUE;
}
return FALSE;
}
{
if (ppdev->bHGSMISupported)
{
/* Issue the screen info command. */
sizeof (VBVAINFOSCREEN),
if (!p)
{
DISPDBG((0, "VBoxDISP::vboxHwBufferFlush: HGSMIHeapAlloc failed\n"));
}
else
{
vboxHGSMIBufferSubmit (ppdev, p);
}
}
return;
}
# ifdef VBOX_WITH_VIDEOHWACCEL
{
if (!pHdr)
{
DISPDBG((0, "VBoxDISP::vboxVHWACreateCommand: HGSMIHeapAlloc failed\n"));
}
return pHdr;
}
{
}
{
{
}
}
/* do not wait for completion */
{
}
{
Assert(0);
return 0;
}
# endif
DECLCALLBACK(int) vboxVHWACommandHanlder(void *pvHandler, uint16_t u16ChannelInfo, void *pvBuffer, HGSMISIZE cbBuffer)
{
int rc = VINF_SUCCESS;
switch(u16ChannelInfo)
{
# ifdef VBOX_WITH_VIDEOHWACCEL
case VBVAHG_VHWA_CMDCOMPLETE:
{
break;
}
# endif
default:
{
}
}
return rc;
}
#endif /* VBOX_WITH_HGSMI */