Init.cpp revision 3d27b794dc7450a9e848b504a701fb139b3f7e66
/* $Revision$ */
/** @file
* VBoxGuestLibR0 - Library initialization.
*/
/*
* Copyright (C) 2006-2007 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.
*
* The contents of this file may alternatively be used under the terms
* of the Common Development and Distribution License Version 1.0
* (CDDL) only, as it comes in the "COPYING.CDDL" file of the
* VirtualBox OSE distribution, in which case the provisions of the
* CDDL are applicable instead of those of the GPL.
*
* You may elect to license modified versions of this file under the
* terms and conditions of either the GPL or the CDDL or both.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#define VBGL_DECL_DATA
#include "VBGLInternal.h"
#include <iprt/semaphore.h>
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** The global VBGL instance data. */
/**
* Used by vbglQueryDriverInfo and VbglInit to try get the host feature mask and
* version information (g_vbgldata::hostVersion).
*
* This was first implemented by the host in 3.1 and we quietly ignore failures
* for that reason.
*/
static void vbglR0QueryHostVersion (void)
{
if (RT_SUCCESS (rc))
{
if (RT_SUCCESS (rc))
{
Log (("vbglR0QueryHostVersion: %u.%u.%ur%u %#x\n",
}
}
}
#ifndef VBGL_VBOXGUEST
/**
* The guest library uses lazy initialization for VMMDev port and memory,
* because these values are provided by the VBoxGuest driver and it might
* be loaded later than other drivers.
*
* The VbglEnter checks the current library status, tries to retrieve these
* values and fails if they are unavailable.
*
*/
static void vbglQueryDriverInfo (void)
{
int rc = VINF_SUCCESS;
if (RT_FAILURE(rc))
return;
{
return;
}
if (RT_SUCCESS(rc))
{
/*
* Try query the port info.
*/
sizeof (port));
if (RT_SUCCESS (rc))
{
}
}
}
#endif /* !VBGL_VBOXGUEST */
/**
* Checks if VBGL has been initialized.
*
* The client library, this will lazily complete the initialization.
*
* @return VINF_SUCCESS or VERR_VBGL_NOT_INITIALIZED.
*/
int vbglR0Enter (void)
{
int rc;
#ifndef VBGL_VBOXGUEST
{
}
#endif
// dprintf(("VbglEnter: rc = %d\n", rc));
return rc;
}
int vbglInitCommon (void)
{
int rc = VINF_SUCCESS;
rc = VbglPhysHeapInit ();
if (RT_SUCCESS(rc))
{
/* other subsystems, none yet */
;
}
else
return rc;
}
DECLVBGL(void) vbglTerminateCommon (void)
{
return;
}
#ifdef VBGL_VBOXGUEST
{
int rc = VINF_SUCCESS;
# ifdef RT_OS_WINDOWS /** @todo r=bird: this doesn't make sense. Is there something special going on on windows? */
{
/* Initialization is already in process. */
return rc;
}
# else
dprintf(("vbglInit: starts\n"));
# endif
rc = vbglInitCommon ();
if (RT_SUCCESS(rc))
{
}
else
{
}
return rc;
}
DECLVBGL(void) VbglTerminate (void)
{
return;
}
#else /* !VBGL_VBOXGUEST */
{
int rc = VINF_SUCCESS;
{
/* Initialization is already in process. */
return rc;
}
rc = vbglInitCommon ();
if (RT_SUCCESS(rc))
{
if (RT_SUCCESS(rc))
{
/* Try to obtain VMMDev port via IOCTL to VBoxGuest main driver. */
# ifdef VBOX_WITH_HGCM
rc = vbglR0HGCMInit ();
# endif /* VBOX_WITH_HGCM */
if (RT_FAILURE(rc))
{
}
}
if (RT_FAILURE(rc))
{
}
}
return rc;
}
DECLVBGL(bool) VbglIsReady(void)
{
}
DECLVBGL(void) VbglTerminate (void)
{
# ifdef VBOX_WITH_HGCM
# endif
/* driver open could fail, which does not prevent VbglInit from succeeding,
* close the driver only if it is opened */
return;
}
{
{
return VERR_TRY_AGAIN;
}
return VINF_SUCCESS;
}
#endif /* !VBGL_VBOXGUEST */