vboxvideo_drm.c revision 26456d1900aba0e903e6e1beec552396618322e2
/* $Id$ */
/** @file
* vboxvideo_drm - Direct Rendering Module, Solaris Specific Code.
*/
/*
* Copyright (C) 2009 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.
*/
/*******************************************************************************
* Header Files *
*******************************************************************************/
#include <sys/ddi_intr.h>
#undef u /* /usr/include/sys/user.h:249:1 is where this is defined to (curproc->p_user). very cool. */
/*******************************************************************************
* Defined Constants And Macros *
*******************************************************************************/
#define VBOXSOLQUOTE2(x) #x
#define VBOXSOLQUOTE(x) VBOXSOLQUOTE2(x)
/** The module name. */
#define DEVICE_NAME "vboxvideo"
/** The module description as seen in 'modinfo'. */
#define DEVICE_DESC_DRV "VirtualBox DRM"
/** DRM Specific defines */
#define DRIVER_AUTHOR "Sun Microsystems Inc."
#define DRIVER_NAME DEVICE_NAME
#define DRIVER_DESC DEVICE_DESC_DRV
#define DRIVER_DATE "20090317"
#define DRIVER_MAJOR 1
#define DRIVER_MINOR 0
#define DRIVER_PATCHLEVEL 0
{ 0, 0, 0, NULL }
/*******************************************************************************
* Internal Functions *
*******************************************************************************/
static int VBoxVideoSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pvArg, void **ppvResult);
/*******************************************************************************
* Structures and Typedefs *
*******************************************************************************/
/**
*/
static struct cb_ops g_VBoxVideoSolarisCbOps =
{
nodev, /* c open */
nodev, /* c close */
nodev, /* b strategy */
nodev, /* b dump */
nodev, /* b print */
nodev, /* c read */
nodev, /* c write*/
nodev, /* ioctl */
nodev, /* c devmap */
nodev, /* c mmap */
nodev, /* c segmap */
nochpoll, /* c poll */
ddi_prop_op, /* property ops */
NULL, /* streamtab */
CB_REV /* revision */
};
/**
* dev_ops: for driver device operations
*/
static struct dev_ops g_VBoxVideoSolarisDevOps =
{
DEVO_REV, /* driver build revision */
0, /* ref count */
nulldev, /* identify */
nulldev, /* probe */
nodev, /* reset */
(struct bus_ops *)0,
nodev /* power */
};
/**
* modldrv: export driver specifics to the kernel
*/
static struct modldrv g_VBoxVideoSolarisModule =
{
&mod_driverops, /* extern from kernel */
};
/**
*/
static struct modlinkage g_VBoxVideoSolarisModLinkage =
{
MODREV_1, /* loadable module system revision */
NULL /* terminate array of linkage structures */
};
/* VBoxVideo device PCI ID */
static drm_pci_id_list_t vboxvideo_pciidlist[] = {
};
/** DRM Driver */
static drm_driver_t g_VBoxVideoSolarisDRMDriver = { 0 };
/*******************************************************************************
* Global Variables *
*******************************************************************************/
/** Device handle (we support only one instance). */
static dev_info_t *g_pDip;
/** Soft state. */
static void *g_pVBoxVideoSolarisState;
/** GCC C++ hack. */
unsigned __gxx_personality_v0 = 0xdecea5ed;
/**
* Kernel entry points
*/
int _init(void)
{
if (!rc)
return mod_install(&g_VBoxVideoSolarisModLinkage);
else
}
int _fini(void)
{
return rc;
}
{
}
/**
* Attach entry point, to attach a device to the system or resume it.
*
* @param pDip The module structure instance.
*
* @returns corresponding solaris error code.
*/
{
int rc = -1;
switch (enmCmd)
{
case DDI_ATTACH:
{
if (rc == DDI_SUCCESS)
{
/*
* Register using the DRM module which will create the minor nodes
*/
if (pDRMHandle)
{
/*
* Probe with our pci-id.
* -XXX- is probing really required???
*/
if (rc == DDI_SUCCESS)
{
/*
* Call the common attach DRM routine.
*/
if (rc == DDI_SUCCESS)
{
return DDI_SUCCESS;
}
else
}
else
}
else
}
else
return DDI_FAILURE;
}
case DDI_RESUME:
{
/* Nothing to do here... */
return DDI_SUCCESS;
}
}
return DDI_FAILURE;
}
/**
* Detach entry point, to detach a device to the system or suspend it.
*
* @param pDip The module structure instance.
*
* @returns corresponding solaris error code.
*/
{
switch (enmCmd)
{
case DDI_DETACH:
{
if (pState)
{
return DDI_SUCCESS;
}
else
return DDI_FAILURE;
}
case DDI_RESUME:
{
/* Nothing to do here... */
return DDI_SUCCESS;
}
}
return DDI_FAILURE;
}
/*
* Info entry point, called by solaris kernel for obtaining driver info.
*
* @param pDip The module structure instance (do not use).
* @param enmCmd Information request type.
* @param pvArg Type specific argument.
* @param ppvResult Where to store the requested info.
*
* @return corresponding solaris error code.
*/
static int VBoxVideoSolarisGetInfo(dev_info_t *pDip, ddi_info_cmd_t enmCmd, void *pvArg, void **ppvResult)
{
int rc = DDI_FAILURE;
switch (enmCmd)
{
case DDI_INFO_DEVT2DEVINFO:
{
if ( pState
{
rc = DDI_SUCCESS;
}
else
{
rc = DDI_FAILURE;
}
break;
}
case DDI_INFO_DEVT2INSTANCE:
{
rc = DDI_SUCCESS;
break;
}
default:
{
rc = DDI_FAILURE;
break;
}
}
return rc;
}
{
return 0;
}
{
return 0;
}
{
return 0;
}
{
/*
* DRM entry points, use the common DRM extension wherever possible.
*/
#if 0
#endif
}