crservice.cpp revision fb3ac85af239d7439b5fce70a8608da9d75065f0
/* $Id$ */
/** @file
* VBox crOpenGL: Host service entry points.
*/
/*
* Copyright (C) 2006-2008 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.
*/
#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
#include "render/renderspu.h"
static IFramebuffer* g_pFrameBuffer;
#ifndef RT_OS_WINDOWS
#define DWORD int
#define WINAPI
#endif
#define CR_USE_HGCM
static const char* gszVBoxOGLSSMMagic = "***OpenGL state data***";
#define SHCROGL_SSM_VERSION 3
typedef struct
{
} VBOXOGLCTX, *PVBOXOGLCTX;
/*@todo remove this workaround for crstate "unshareable" data*/
static int crIsThreadWorking=0;
{
CRServerMain(0, NULL);
crIsThreadWorking = 0;
return 0;
}
static DECLCALLBACK(int) svcUnload (void *)
{
int rc = VINF_SUCCESS;
Log(("SHARED_CROPENGL svcUnload\n"));
//vboxglGlobalUnload();
return rc;
}
{
int rc = VINF_SUCCESS;
#ifndef CR_USE_HGCM
if (!crIsThreadWorking)
{
HANDLE h;
//CHECK_ERROR_RET(g_piConsole, COMGETTER(Display)(display.asOutParam()), rc);
//vboxglConnect((PVBOXOGLCTX)pvClient);
if (!h) rc = VERR_MAX_THRDS_REACHED;
}
else
#else
#endif
return rc;
}
{
int rc = VINF_SUCCESS;
#ifndef CR_USE_HGCM
#else
#endif
//vboxglDisconnect((PVBOXOGLCTX)pvClient);
return rc;
}
static DECLCALLBACK(int) svcSaveState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM)
{
int rc;
/* Start*/
/* Version */
/* The state itself */
/* End */
return VINF_SUCCESS;
}
static DECLCALLBACK(int) svcLoadState(void *, uint32_t u32ClientID, void *pvClient, PSSMHANDLE pSSM)
{
char psz[2000];
int rc;
/* Start of data */
return VERR_SSM_UNEXPECTED_DATA;
/* Version */
if (SHCROGL_SSM_VERSION != ui32)
/* The state itself */
/* End of data */
return VERR_SSM_UNEXPECTED_DATA;
return VINF_SUCCESS;
}
{
/*todo add warning window*/
}
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_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))
{
/*@todo, add warning window*/
}
}
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_FRAMEBUFFER\n"));
/* Verify parameter count and types. */
if (cParms != SHCRGL_CPARMS_SET_FRAMEBUFFER)
{
}
{
}
else
{
/* Fetch parameters. */
/* Verify parameters values. */
if (cbData != sizeof (IFramebuffer*))
{
}
else
{
/* Execute the function. */
rc = VINF_SUCCESS;
}
}
break;
}
{
Log(("svcCall: SHCRGL_HOST_FN_SET_VISIBLE_REGION\n"));
{
break;
}
)
{
break;
}
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
{
#ifdef CR_USE_HGCM
if (!crVBoxServerInit())
return VERR_NOT_SUPPORTED;
#endif
}
}
return rc;
}