SysHlp.cpp revision cca8c8c55206ccd60f1b32843a67ce737447ac60
/** @file
*
* VBoxGuestLib - A support library for VirtualBox guest additions:
* Physical memory heap
*/
/*
* 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.
*/
#define LOG_GROUP LOG_GROUP_HGCM
#include <VBox/VBoxGuestLib.h>
#include "SysHlp.h"
#if !defined(RT_OS_WINDOWS) && !defined(RT_OS_LINUX)
#endif
{
int rc = VINF_SUCCESS;
#ifdef RT_OS_WINDOWS
{
}
else
{
__try {
}
}
#elif defined(RT_OS_LINUX) || defined(RT_OS_FREEBSD) /** @todo r=bird: I don't think FreeBSD shouldn't go here, solaris and OS/2 doesn't
* (ignore linux as it's not using the same ioctl code).
* That said, the assumption below might be wrong for in kernel calls... */
#else
/* Default to IPRT - this ASSUMES that it is USER addresses we're locking. */
if (RT_SUCCESS(rc))
else
*ppvCtx = NIL_RTR0MEMOBJ;
#endif
return rc;
}
{
#ifdef RT_OS_WINDOWS
{
}
#else
/* default to IPRT */
#endif
}
#ifndef VBGL_VBOXGUEST
#if defined (RT_OS_LINUX) && !defined (__KERNEL__)
# include <unistd.h>
# include <errno.h>
#endif
#ifdef RT_OS_LINUX
extern DECLVBGL(void *) vboxadd_cmc_open (void);
extern DECLVBGL(void) vboxadd_cmc_close (void *);
#endif /* RT_OS_LINUX */
#ifdef RT_OS_OS2
/*
* On OS/2 we'll do the connecting in the assembly code of the
* client driver, exporting a g_VBoxGuestIDC symbol containing
* the connection information obtained from the 16-bit IDC.
*/
extern VBOXGUESTOS2IDCCONNECT g_VBoxGuestIDC;
#endif
#ifdef RT_OS_SOLARIS
extern DECLVBGL(int) VBoxGuestSolarisServiceCall (void *pvOpaque, unsigned int iCmd, void *pvData, size_t cbSize, size_t *pcbReturn);
#elif defined (RT_OS_FREEBSD)
extern DECLVBGL(int) VBoxGuestFreeBSDServiceCall (void *pvOpaque, unsigned int iCmd, void *pvData, size_t cbSize, size_t *pcbReturn);
#endif
{
#ifdef RT_OS_WINDOWS
&pFileObject, &pDeviceObject);
if (NT_SUCCESS (rc))
{
return VINF_SUCCESS;
}
/** @todo return RTErrConvertFromNtStatus(rc)! */
return rc;
#elif defined (RT_OS_LINUX)
void *opaque;
opaque = (void *) vboxadd_cmc_open ();
if (!opaque)
{
return VERR_NOT_IMPLEMENTED;
}
return VINF_SUCCESS;
/*
* Just check whether the connection was made or not.
*/
{
return VINF_SUCCESS;
}
Log(("vbglDriverOpen: failed\n"));
return VERR_FILE_NOT_FOUND;
#elif defined (RT_OS_SOLARIS)
&& u32VMMDevVersion == VMMDEV_VERSION)
return VINF_SUCCESS;
Log(("vbglDriverOpen: failed\n"));
return VERR_FILE_NOT_FOUND;
#elif defined (RT_OS_FREEBSD)
return VINF_SUCCESS;
Log(("vbglDriverOpen: failed\n"));
return VERR_FILE_NOT_FOUND;
#else
# error "Port me"
#endif
}
#ifdef RT_OS_WINDOWS
{
return STATUS_MORE_PROCESSING_REQUIRED;
}
#endif
{
Log(("vbglDriverIOCtl: pDriver: %p, Func: %x, pvData: %p, cbData: %d\n", pDriver, u32Function, pvData, cbData));
#ifdef RT_OS_WINDOWS
/* Have to use the IoAllocateIRP method because this code is generic and
* must work in any thread context.
* The IoBuildDeviceIoControlRequest, which was used here, does not work
* when APCs are disabled, for example.
*/
{
Log(("vbglDriverIOCtl: IRP allocation failed!\n"));
return VERR_NO_MEMORY;
}
/*
* Setup the IRP_MJ_DEVICE_CONTROL IRP.
*/
nextStack->MinorFunction = 0;
/* A completion routine is required to signal the Event. */
if (NT_SUCCESS (rc))
{
/* Wait the event to be signalled by the completion routine. */
NULL);
}
if (rc != STATUS_SUCCESS)
#elif defined (RT_OS_LINUX)
if ( pDriver->u32Session
Log(("vbglDriverIOCtl: No connection\n"));
return VERR_WRONG_ORDER;
#elif defined (RT_OS_SOLARIS)
#elif defined (RT_OS_FREEBSD)
#else
# error "Port me"
#endif
}
{
#ifdef RT_OS_WINDOWS
#elif defined (RT_OS_LINUX)
pDriver->u32Session = 0;
#elif defined (RT_OS_SOLARIS)
#elif defined (RT_OS_FREEBSD)
#else
# error "Port me"
#endif
}
#endif /* !VBGL_VBOXGUEST */