crservice.cpp revision 0c0e78bbdcbeec81f856e8aa1097a9504c16bb1c
/* $Id$ */
/** @file
* VBox crOpenGL: Host service entry points.
*/
/*
* Copyright (C) 2006-2008 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.
*/
#define __STDC_CONSTANT_MACROS /* needed for a definition in iprt/string.h */
#ifdef RT_OS_WINDOWS
#include "cr_server.h"
#define LOG_GROUP LOG_GROUP_SHARED_CROPENGL
#else
#include "cr_server.h"
#define LOG_GROUP LOG_GROUP_SHARED_CROPENGL
#endif /* RT_OS_WINDOWS */
#ifndef RT_OS_WINDOWS
#define DWORD int
#define WINAPI
#endif
static const char* gszVBoxOGLSSMMagic = "***OpenGL state data***";
#define SHCROGL_SSM_VERSION 19
static DECLCALLBACK(int) svcUnload (void *)
{
int rc = VINF_SUCCESS;
Log(("SHARED_CROPENGL svcUnload\n"));
return rc;
}
{
int rc = VINF_SUCCESS;
return rc;
}
{
int rc = VINF_SUCCESS;
return rc;
}
static DECLCALLBACK(int) svcSaveState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM)
{
int rc = VINF_SUCCESS;
/* Start*/
/* Version */
/* The state itself */
/* End */
return VINF_SUCCESS;
}
static DECLCALLBACK(int) svcLoadState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM)
{
int rc = VINF_SUCCESS;
char psz[2000];
/* Start of data */
return VERR_SSM_UNEXPECTED_DATA;
/* Version */
if ((SHCROGL_SSM_VERSION != ui32)
{
/*@todo: add some warning here*/
/*@todo: in many cases saved states would be made without any opengl guest app running.
* that means we could safely restore the default context.
*/
return rc;
}
/* The state itself */
/* End of data */
return VERR_SSM_UNEXPECTED_DATA;
return VINF_SUCCESS;
}
{
/*MS's opengl32 tryes to load our ICD around 30 times on failure...this is to prevent unnecessary spam*/
static int shown = 0;
{
"An attempt by the virtual machine to use hardware 3D acceleration failed. "
"The version of the Guest Additions installed in the virtual machine does not match the "
"version of VirtualBox on the host. Please install appropriate Guest Additions to fix this issue");
shown = 1;
}
}
static DECLCALLBACK(void) svcPresentFBO(void *data, int32_t screenId, int32_t x, int32_t y, uint32_t w, uint32_t h)
{
#if 0
int i,j;
for (i=0; i<100; i+=2)
{
for (j=0; j<100; ++j)
{
}
}
#endif
}
static DECLCALLBACK(void) svcCall (void *, VBOXHGCMCALLHANDLE callHandle, uint32_t u32ClientID, void *pvClient, uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[])
{
int rc = VINF_SUCCESS;
Log(("SHARED_CROPENGL svcCall: u32ClientID = %d, fn = %d, cParms = %d, pparms = %d\n", u32ClientID, u32Function, cParms, paParms));
#ifdef DEBUG
uint32_t i;
for (i = 0; i < cParms; i++)
{
/** @todo parameters other than 32 bit */
}
#endif
switch (u32Function)
{
case SHCRGL_GUEST_FN_WRITE:
{
Log(("svcCall: SHCRGL_GUEST_FN_WRITE\n"));
/* Verify parameter count and types. */
if (cParms != SHCRGL_CPARMS_WRITE)
{
}
else
)
{
}
else
{
/* Fetch parameters. */
/* Execute the function. */
if (!RT_SUCCESS(rc))
{
svcClientVersionUnsupported(0, 0);
}
}
break;
}
case SHCRGL_GUEST_FN_INJECT:
{
Log(("svcCall: SHCRGL_GUEST_FN_INJECT\n"));
/* Verify parameter count and types. */
if (cParms != SHCRGL_CPARMS_INJECT)
{
}
else
)
{
}
else
{
/* Fetch parameters. */
/* Execute the function. */
if (!RT_SUCCESS(rc))
{
svcClientVersionUnsupported(0, 0);
}
}
break;
}
case SHCRGL_GUEST_FN_READ:
{
Log(("svcCall: SHCRGL_GUEST_FN_READ\n"));
/* Verify parameter count and types. */
if (cParms != SHCRGL_CPARMS_READ)
{
}
else
)
{
}
/* Fetch parameters. */
/* Execute the function. */
if (RT_SUCCESS(rc))
{
/* Update parameters.*/
} else if (VERR_NOT_SUPPORTED==rc)
{
svcClientVersionUnsupported(0, 0);
}
/* Return the required buffer size always */
break;
}
{
Log(("svcCall: SHCRGL_GUEST_FN_WRITE_READ\n"));
/* Verify parameter count and types. */
if (cParms != SHCRGL_CPARMS_WRITE_READ)
{
}
else
)
{
}
else
{
/* Fetch parameters. */
/* Execute the function. */
if (!RT_SUCCESS(rc))
{
svcClientVersionUnsupported(0, 0);
}
if (RT_SUCCESS(rc))
{
/* Update parameters.*/
}
/* Return the required buffer size always */
}
break;
}
{
Log(("svcCall: SHCRGL_GUEST_FN_SET_VERSION\n"));
/* Verify parameter count and types. */
if (cParms != SHCRGL_CPARMS_SET_VERSION)
{
}
else
)
{
}
else
{
/* Fetch parameters. */
/* Execute the function. */
if (!RT_SUCCESS(rc))
{
}
}
break;
}
default:
{
}
}
}
/*
* We differentiate between a function handler for the guest and one for the host.
*/
static DECLCALLBACK(int) svcHostCall (void *, uint32_t u32Function, uint32_t cParms, VBOXHGCMSVCPARM paParms[])
{
int rc = VINF_SUCCESS;
Log(("SHARED_CROPENGL svcHostCall: fn = %d, cParms = %d, pparms = %d\n", u32Function, cParms, paParms));
#ifdef DEBUG
uint32_t i;
for (i = 0; i < cParms; i++)
{
/** @todo parameters other than 32 bit */
}
#endif
switch (u32Function)
{
{
Log(("svcCall: SHCRGL_HOST_FN_SET_DISPLAY\n"));
/* Verify parameter count and types. */
if (cParms != SHCRGL_CPARMS_SET_CONSOLE)
{
}
{
}
else
{
/* Fetch parameters. */
/* Verify parameters values. */
{
}
else if (!pConsole)
{
}
else /* Execute the function. */
{
ULONG monitorCount, i, w, h;
for (i=0; i<monitorCount; ++i)
{
if (!pDisplay)
{
rc = crVBoxServerUnmapScreen(i);
}
else
{
}
}
rc = VINF_SUCCESS;
}
}
break;
}
case SHCRGL_HOST_FN_SET_VM:
{
Log(("svcCall: SHCRGL_HOST_FN_SET_VM\n"));
/* Verify parameter count and types. */
if (cParms != SHCRGL_CPARMS_SET_VM)
{
}
{
}
else
{
/* Fetch parameters. */
/* Verify parameters values. */
{
}
else
{
/* Execute the function. */
rc = VINF_SUCCESS;
}
}
break;
}
{
Log(("svcCall: SHCRGL_HOST_FN_SET_VISIBLE_REGION\n"));
{
break;
}
)
{
break;
}
break;
}
{
Log(("svcCall: SHCRGL_HOST_FN_SCREEN_CHANGED\n"));
/* Verify parameter count and types. */
if (cParms != SHCRGL_CPARMS_SCREEN_CHANGED)
{
}
{
}
else
{
/* Fetch parameters. */
/* Execute the function. */
ULONG w, h;
if (!pFramebuffer)
{
}
else
{
}
rc = VINF_SUCCESS;
}
break;
}
default:
break;
}
return rc;
}
{
int rc = VINF_SUCCESS;
if (!ptable)
{
}
else
{
Log(("VBoxHGCMSvcLoad: ptable->cbSize = %d, ptable->u32Version = 0x%08X\n", ptable->cbSize, ptable->u32Version));
{
}
else
{
if (!crVBoxServerInit())
return VERR_NOT_SUPPORTED;
}
}
return rc;
}