SUPDrv-solaris.c revision af85b6b3c074e563ee6716694aca42ee7b776d57
199767f8919635c4928607450d9e0abb932109ceToomas Soome * VirtualBox Support Driver - Solaris Driver Code.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Copyright (C) 2006-2007 Sun Microsystems, Inc.
199767f8919635c4928607450d9e0abb932109ceToomas Soome * This file is part of VirtualBox Open Source Edition (OSE), as
199767f8919635c4928607450d9e0abb932109ceToomas Soome * available from http://www.virtualbox.org. This file is free software;
199767f8919635c4928607450d9e0abb932109ceToomas Soome * you can redistribute it and/or modify it under the terms of the GNU
199767f8919635c4928607450d9e0abb932109ceToomas Soome * General Public License (GPL) as published by the Free Software
199767f8919635c4928607450d9e0abb932109ceToomas Soome * Foundation, in version 2 as it comes in the "COPYING" file of the
* Clara, CA 95054 USA or visit http://www.sun.com if you need
#undef u /* /usr/include/sys/user.h:249:1 is where this is defined to (curproc->p_user). very cool. */
#include "../SUPDrvInternal.h"
static int VBoxDrvSolarisIOCtl (dev_t Dev, int Cmd, intptr_t pArgs, int mode, cred_t *pCred, int *pVal);
(struct bus_ops *)0,
#ifndef USE_SESSION_HASH
static void *g_pVBoxDrvSolarisState;
int _init(void)
if (!rc)
if (!rc)
return rc;
int _fini(void)
switch (enmCmd)
case DDI_ATTACH:
int rc;
#ifdef USE_SESSION_HASH
return DDI_FAILURE;
#ifdef USE_SESSION_HASH
return DDI_SUCCESS;
RTR0Term();
case DDI_RESUME:
return DDI_SUCCESS;
return DDI_FAILURE;
return DDI_FAILURE;
switch (enmCmd)
case DDI_DETACH:
#ifndef USE_SESSION_HASH
RTR0Term();
return DDI_SUCCESS;
case DDI_SUSPEND:
return DDI_SUCCESS;
return DDI_FAILURE;
int rc;
#ifndef USE_SESSION_HASH
unsigned iOpenInstance;
if (!pState)
return ENXIO;
unsigned iHash;
int instance;
if (pState)
return ENXIO;
#ifndef USE_SESSION_HASH
if (!pState)
return EFAULT;
if (!pSession)
return EFAULT;
dprintf(("VBoxDrvSolarisClose: Dev=%#x pSession=%p pid=%d r0proc=%p thread=%p\n", Dev, pSession, RTProcSelf(), RTR0ProcHandleSelf(), RTThreadNativeSelf() ));
if (pSession)
while (pSession)
if (!pSession)
OSDBGPRINT(("VBoxDrvSolarisClose: WHAT?!? pSession == NULL! This must be a mistake... pid=%d (close)\n",
(int)Process));
return EFAULT;
static int VBoxDrvSolarisIOCtl(dev_t Dev, int Cmd, intptr_t pArgs, int Mode, cred_t *pCred, int *pVal)
#ifndef USE_SESSION_HASH
if (!pState)
return EINVAL;
if (!pSession)
return DDI_SUCCESS;
if (!pSession)
OSDBGPRINT(("VBoxSupDrvIOCtl: WHAT?!? pSession == NULL! This must be a mistake... pid=%d iCmd=%#x\n",
return EINVAL;
#ifndef IOCPARM_LEN
int rc;
OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: iCmd=%#x len %d expected %d\n", iCmd, IOCPARM_LEN(iCmd), sizeof(Hdr)));
return EINVAL;
OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: ddi_copyin(,%#lx,) failed; iCmd=%#x. rc=%d\n", iArg, iCmd, rc));
return EFAULT;
OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: bad header magic %#x; iCmd=%#x\n", Hdr.fFlags & SUPREQHDR_FLAGS_MAGIC_MASK, iCmd));
return EINVAL;
return EINVAL;
OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: failed to allocate buffer of %d bytes for iCmd=%#x.\n", cbBuf, iCmd));
return ENOMEM;
dprintf(("VBoxDrvSolarisIOCtlSlow: copy_from_user(,%#lx, %#x) failed; iCmd=%#x. rc=%d\n", iArg, Hdr.cbIn, iCmd, rc));
return EFAULT;
OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: too much output! %#x > %#x; iCmd=%#x!\n", cbOut, cbBuf, iCmd));
OSDBGPRINT(("VBoxDrvSolarisIOCtlSlow: ddi_copyout(,%p,%d) failed. rc=%d\n", (void *)iArg, cbBuf, rc));
return rc;
return VERR_INVALID_POINTER;
if (pSession)
return VERR_INVALID_PARAMETER;
return VERR_INVALID_PARAMETER;
return VERR_INVALID_PARAMETER;
switch (rc)
return EPERM;
bool VBOXCALL supdrvOSObjCanAccess(PSUPDRVOBJ pObj, PSUPDRVSESSION pSession, const char *pszObjName, int *prc)