VBoxGuest-solaris-streams.c revision 56d0387cf5c041c9f1d5fc1d0a5d707cce674dc1
af062818b47340eef15700d2f0211576ba3506eevboxsync * VirtualBox Guest Additions Driver for Solaris.
af062818b47340eef15700d2f0211576ba3506eevboxsync * Copyright (C) 2012 Oracle Corporation
af062818b47340eef15700d2f0211576ba3506eevboxsync * This file is part of VirtualBox Open Source Edition (OSE), as
af062818b47340eef15700d2f0211576ba3506eevboxsync * available from http://www.virtualbox.org. This file is free software;
af062818b47340eef15700d2f0211576ba3506eevboxsync * you can redistribute it and/or modify it under the terms of the GNU
af062818b47340eef15700d2f0211576ba3506eevboxsync * General Public License (GPL) as published by the Free Software
af062818b47340eef15700d2f0211576ba3506eevboxsync * Foundation, in version 2 as it comes in the "COPYING" file of the
af062818b47340eef15700d2f0211576ba3506eevboxsync * VirtualBox OSE distribution. VirtualBox OSE is distributed in the
af062818b47340eef15700d2f0211576ba3506eevboxsync * hope that it will be useful, but WITHOUT ANY WARRANTY of any kind.
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync/******************************************************************************
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync* Header Files *
b955672b950093ff7416d1269dd4d3b69983bd8fvboxsync******************************************************************************/
af062818b47340eef15700d2f0211576ba3506eevboxsync#undef u /* /usr/include/sys/user.h:249:1 is where this is defined to (curproc->p_user). very cool. */
af062818b47340eef15700d2f0211576ba3506eevboxsync#else /* TESTCASE */
af062818b47340eef15700d2f0211576ba3506eevboxsync#endif /* TESTCASE */
af062818b47340eef15700d2f0211576ba3506eevboxsync#endif /* TESTCASE */
af062818b47340eef15700d2f0211576ba3506eevboxsync/******************************************************************************
af062818b47340eef15700d2f0211576ba3506eevboxsync* Defined Constants And Macros *
af062818b47340eef15700d2f0211576ba3506eevboxsync******************************************************************************/
af062818b47340eef15700d2f0211576ba3506eevboxsync/** The module name. */
af062818b47340eef15700d2f0211576ba3506eevboxsync/** The module description as seen in 'modinfo'. */
af062818b47340eef15700d2f0211576ba3506eevboxsync/******************************************************************************
af062818b47340eef15700d2f0211576ba3506eevboxsync* Internal functions used in global structures *
af062818b47340eef15700d2f0211576ba3506eevboxsync******************************************************************************/
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic int vboxGuestSolarisOpen(queue_t *pReadQueue, dev_t *pDev, int fFlag,
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic int vboxGuestSolarisClose(queue_t *pReadQueue, int fFlag, cred_t *pCred);
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic int vboxGuestSolarisWPut(queue_t *pWriteQueue, mblk_t *pMBlk);
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic int vboxGuestSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pArg, void **ppResult);
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic int vboxGuestSolarisAttach(dev_info_t *pDip, ddi_attach_cmd_t enmCmd);
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic int vboxGuestSolarisDetach(dev_info_t *pDip, ddi_detach_cmd_t enmCmd);
af062818b47340eef15700d2f0211576ba3506eevboxsync/******************************************************************************
af062818b47340eef15700d2f0211576ba3506eevboxsync* Driver global structures *
af062818b47340eef15700d2f0211576ba3506eevboxsync******************************************************************************/
af062818b47340eef15700d2f0211576ba3506eevboxsync#ifndef TESTCASE /* I see no value in including these. */
af062818b47340eef15700d2f0211576ba3506eevboxsync * mod_info: STREAMS module information.
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic struct module_info g_VBoxGuestSolarisModInfo =
af062818b47340eef15700d2f0211576ba3506eevboxsync "vboxguest",
af062818b47340eef15700d2f0211576ba3506eevboxsync 0, /* minimum packet size */
af062818b47340eef15700d2f0211576ba3506eevboxsync * rinit: read queue structure for handling messages coming from below. In
af062818b47340eef15700d2f0211576ba3506eevboxsync * our case this means the host and the virtual hardware, so we do not need
af062818b47340eef15700d2f0211576ba3506eevboxsync * the put and service procedures.
af062818b47340eef15700d2f0211576ba3506eevboxsync * winit: write queue structure for handling messages coming from above. Above
af062818b47340eef15700d2f0211576ba3506eevboxsync * means user space applications: either Guest Additions user space tools or
af062818b47340eef15700d2f0211576ba3506eevboxsync * applications reading pointer input. Messages from the last most likely pass
af062818b47340eef15700d2f0211576ba3506eevboxsync * through at least the "consms" console mouse streams module which multiplexes
af062818b47340eef15700d2f0211576ba3506eevboxsync * hardware pointer drivers to a single virtual pointer.
af062818b47340eef15700d2f0211576ba3506eevboxsync * streamtab: for drivers that support char/block entry points.
af062818b47340eef15700d2f0211576ba3506eevboxsyncstatic struct streamtab g_VBoxGuestSolarisStreamTab =
af062818b47340eef15700d2f0211576ba3506eevboxsync * cb_ops: for drivers that support char/block entry points.
af062818b47340eef15700d2f0211576ba3506eevboxsync * dev_ops: for driver device operations.
af062818b47340eef15700d2f0211576ba3506eevboxsync 0, /* ref count */
(struct bus_ops *)0,
static void *g_VBoxGuestSolarisModLinkage;
unsigned cMinor;
unsigned cMaxScreenX;
unsigned cMaxScreenY;
int _init(void)
if (pModCtl)
if (!rc)
if (rc)
return EINVAL;
return rc;
#ifdef TESTCASE
int _fini(void)
int rc;
if (!rc)
RTR0Term();
return rc;
int rc;
unsigned cInstance;
if (fMode)
return EINVAL;
if (!pState)
return ENXIO;
return EFAULT;
if (!pState)
return EFAULT;
if (!pSession)
return EFAULT;
case M_FLUSH:
case M_IOCTL:
case M_IOCDATA:
if (!err)
enum IOCTLDIRECTION
NONE,
IN,
OUT,
BOTH,
int cCmd;
} s_aVUIDIOCtlDescriptions[] =
switch (cCmdType)
case MSIOC:
case VUIOC:
return EINVAL;
return ENOTTY;
static int vboxGuestSolarisHandleIOCtlData
static int vboxGuestSolarisHandleTransparentIOCtl
static int vboxGuestSolarisHandleIStrIOCtl
cCmd);
int err;
return EINVAL;
return EINVAL;
return EINVAL;
return err;
return EINVAL;
void *pvData;
if (!pMBlkOut)
return EAGAIN;
if (!err)
if (!err)
return err;
int cCmd)
return EINVAL;
if (cbBuffer)
if (err)
return err;
if (!err)
return err;
switch (cCmd)
case VUIDGFORMAT:
*pcbData = sizeof(int);
case VUIDSFORMAT:
case VUIDGADDR:
case VUIDSADDR:
return ENOTTY;
case MSIOGETPARMS:
case MSIOSETPARMS:
case MSIOSRESOLUTION:
case MSIOBUTTONS:
*(int *)pvData = 0;
*pcbData = sizeof(int);
case VUIDGWHEELCOUNT:
*(int *)pvData = 0;
*pcbData = sizeof(int);
case VUIDGWHEELINFO:
case VUIDGWHEELSTATE:
case VUIDSWHEELSTATE:
return EINVAL;
return EINVAL;
return rc;
switch (enmCmd)
case DDI_INFO_DEVT2DEVINFO:
case DDI_INFO_DEVT2INSTANCE:
return rc;
switch (enmCmd)
case DDI_ATTACH:
if (g_pDip)
return DDI_FAILURE;
return DDI_SUCCESS;
return DDI_FAILURE;
case DDI_RESUME:
return DDI_SUCCESS;
return DDI_FAILURE;
switch (enmCmd)
case DDI_DETACH:
return DDI_SUCCESS;
case DDI_SUSPEND:
return DDI_SUCCESS;
return DDI_FAILURE;
int IntrCount = 0;
&& IntrCount > 0)
int IntrAvail = 0;
&& IntrAvail > 0)
if (g_pIntr)
&& IntrAllocated > 0)
for (i = 0; i < IntrAllocated; i++)
IntrAllocated = i;
return rc;
for (i = 0; i < IntrAllocated; i++)
for (i = 0; i < g_cIntrAllocated; i++)
LogRel((DEVICE_NAME "::AddIRQ: failed to get or insufficient available IRQs. rc=%d IntrAvail=%d\n", rc, IntrAvail));
LogRel((DEVICE_NAME "::AddIRQ: failed to get or insufficient number of IRQs. rc=%d IntrCount=%d\n", rc, IntrCount));
return rc;
for (i = 0; i < g_cIntrAllocated; i++)
bool fOurIRQ;
int rc;
if (!pMBlk)
#include "VBoxGuestIDC-unix.c.h"