vbox.c revision 8dccf9f8bae30f5340ef017e5a9a6d87ccb26b6c
/* $Id$ */
/** @file
* Display - VirtualBox Win 2000/XP guest display driver, 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 */
{
// ASMOutU16 (VBE_DISPI_IOPORT_INDEX, VBE_DISPI_INDEX_VBVA_GUEST);
// ASMOutU32 (VBE_DISPI_IOPORT_DATA, offBuffer);
}
{
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::vboxVHWACommandCreate: HGSMIHeapAlloc failed\n"));
}
else
{
}
/* temporary hack */
return pHdr;
}
{
}
static DECLCALLBACK(void) vboxVHWACommandCompletionCallbackEvent(PPDEV ppdev, VBOXVHWACMD * pCmd, void * pContext)
{
}
{
VBOXVHWACMD* pComplCmd = (VBOXVHWACMD*)HGSMIOffsetToPointer (&ppdev->hgsmiDisplayHeap.area, pComplete->offCmd);
return 0;
}
{
int rc = VINF_SUCCESS;
switch(pCmd->customOpCode)
{
# ifdef VBOX_WITH_VIDEOHWACCEL
{
break;
}
# endif
default:
{
Assert(0);
}
}
}
{
if(RT_SUCCESS(rc))
{
{
}
}
}
{
// Assert(0);
pCmd->GuestVBVAReserved2 = 0;
/* complete it asynchronously by setting event */
//TODO: dbg
#if 0
{
/* the command is completed */
}
#endif
}
{
if(brc)
{
NULL /*IN PLARGE_INTEGER pTimeOut*/
);
if(brc)
{
}
}
return brc;
}
/* do not wait for completion */
void vboxVHWACommandSubmitAsynch (PPDEV ppdev, VBOXVHWACMD* pCmd, PFNVBOXVHWACMDCOMPLETION pfnCompletion, void * pContext)
{
// Assert(0);
//TODO: dbg
#if 0
{
/* the command is completed */
}
#endif
}
static DECLCALLBACK(void) vboxVHWAFreeCmdCompletion(PPDEV ppdev, VBOXVHWACMD * pCmd, void * pContext)
{
}
{
// Assert(0);
//TODO: dbg
#if 0
{
/* the command is completed */
}
#endif
}
{
}
{
}
{
VBOXVHWACMD* pCmd = vboxVHWACommandCreate (ppdev, VBOXVHWACMD_TYPE_QUERY_INFO1, sizeof(VBOXVHWACMD_QUERYINFO1));
if (!pCmd)
{
DISPDBG((0, "VBoxDISP::vboxVHWAQueryHostInfo1: vboxVHWACommandCreate failed\n"));
return NULL;
}
if (!pCmd)
{
DISPDBG((0, "VBoxDISP::vboxVHWAQueryHostInfo1: vboxVHWACommandCreate failed\n"));
return NULL;
}
{
{
}
}
return NULL;
}
{
VBOXVHWACMD* pCmd = vboxVHWACommandCreate (ppdev, VBOXVHWACMD_TYPE_QUERY_INFO2, VBOXVHWAINFO2_SIZE(numFourCC));
if (!pCmd)
{
DISPDBG((0, "VBoxDISP::vboxVHWAQueryHostInfo1: vboxVHWACommandCreate failed\n"));
return NULL;
}
{
{
{
return pInfo2;
}
}
}
return NULL;
}
{
if(!pInfo)
{
return VERR_OUT_OF_RESOURCES;
}
return VINF_SUCCESS;
}
{
int rc = VINF_SUCCESS;
if(!pInfo)
return VERR_OUT_OF_RESOURCES;
{
}
else
{
Assert(0);
}
return rc;
}
{
int rc = VERR_GENERAL_FAILURE;
if (!pCmd)
{
DISPDBG((0, "VBoxDISP::vboxVHWAQueryHostInfo1: vboxVHWACommandCreate failed\n"));
return rc;
}
{
{
rc = VINF_SUCCESS;
}
}
return rc;
}
{
int rc = VERR_GENERAL_FAILURE;
if (!pCmd)
{
DISPDBG((0, "VBoxDISP::vboxVHWAQueryHostInfo1: vboxVHWACommandCreate failed\n"));
return rc;
}
{
{
rc = VINF_SUCCESS;
}
}
return rc;
}
# endif
{
}
#endif /* VBOX_WITH_HGSMI */