drm_drv.c revision e92e3a8694f157faf8a9e44096a70ada86c556bf
/*
* drm_drv.h -- Generic driver template -*- linux-c -*-
* Created: Thu Nov 23 03:10:50 2000 by gareth@valinux.com
*/
/*
* Copyright 1999, 2000 Precision Insight, Inc., Cedar Park, Texas.
* Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
* All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the next
* paragraph) shall be included in all copies or substantial portions of the
* Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
* ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
* OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rickard E. (Rik) Faith <faith@valinux.com>
* Gareth Hughes <gareth@valinux.com>
*
*/
/*
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
#pragma ident "%Z%%M% %I% %E% SMI"
#include "drmP.h"
#include "drm.h"
#include "drm_sarea.h"
int drm_debug_flag = 1;
#define DRIVER_IOCTL_COUNT 256
void
{
}
void
drm_init_ioctl_arrays(void)
{
drm_version, 0, 0, "drm_version");
drm_getunique, 0, 0, "drm_getunique");
drm_getmagic, 0, 0, "drm_getmagic");
drm_getmap, 0, 0, "drm_getmap");
drm_getclient, 0, 0, "drm_getclient");
drm_getstats, 0, 0, "drm_getstats");
drm_wait_vblank, 0, 0, "drm_wait_vblank");
}
const char *
{
int i = 0;
}
}
return ((char *)NULL);
}
static int
{
int i;
i = drm_dma_setup(dev);
if (i != 0)
return (i);
}
for (i = 0; i < DRM_HASH_SIZE; i++) {
}
dev->irq_enabled = 0;
dev->context_flag = 0;
dev->last_context = 0;
dev->if_version = 0;
return (DDI_SUCCESS);
}
/* Free resources associated with the DRM on the last close. */
static int
{
int i;
DRM_DEBUG("drm_lastclose");
if (dev->irq_enabled)
(void) drm_irq_uninstall(dev);
dev->unique_len = 0;
}
/* Clear pid list */
for (i = 0; i < DRM_HASH_SIZE; i++) {
}
}
/* Clear AGP information */
/*
* Remove AGP resources, but leave dev->agp
* intact until drm_cleanup is called.
*/
(void) drm_agp_unbind_memory(
}
(void) drm_agp_do_release(dev);
}
}
/* Clean up maps that weren't set up by the driver. */
if (!map->kernel_owned)
}
}
return (0);
}
static int
{
int retcode;
DRM_DEBUG("drm_load: new");
dev->cloneopens = 0;
if (retcode != 0) {
DRM_ERROR("drm_load: dev->load failed\n");
goto error;
}
}
if (drm_device_is_agp(dev))
DRM_ERROR("drm_load: Card isn't AGP,\
or couldn't initialize AGP");
goto error;
}
}
if (retcode != 0) {
DRM_ERROR("drm_load: Cannot allocate memory for ctx bitmap");
goto error;
}
if (drm_init_kstats(dev)) {
DRM_ERROR("drm_attach => drm_load: init kstats error");
goto error;
}
DRM_INFO("!drm: Initialized %s %d.%d.%d %s ",
dev->driver_date);
return (DDI_SUCCESS);
DRM_LOCK();
(void) drm_lastclose(dev);
DRM_UNLOCK();
return (retcode);
}
/* called when cleanup this module */
static void
{
DRM_LOCK();
(void) drm_lastclose(dev);
DRM_UNLOCK();
}
}
DRM_INFO("!drm: drm_unload: cleanup the resource");
}
/*ARGSUSED*/
int
{
int retcode;
if (!retcode) {
DRM_LOCK();
if (!dev->open_count ++)
DRM_UNLOCK();
}
return (retcode);
}
/*ARGSUSED*/
int
{
int retcode = 0;
DRM_LOCK();
if (!priv) {
DRM_UNLOCK();
DRM_ERROR("drm_close: can't find authenticator");
}
DRM_UNLOCK();
/*
* Free memory allocated by drm_add_magic
*/
}
DRM_LOCK();
/*
* Begin inline drm_release
*/
DRM_DEBUG("drm_close :pid = %d , open_count = %d",
DRM_DEBUG("Process %d dead, freeing lock for context %d",
DRM_ERROR("drm_close: "
"retake lock not implemented yet");
}
}
/*
* End inline drm_release
*/
if (--dev->open_count == 0) {
}
DRM_UNLOCK();
return (retcode);
}
/*ARGSUSED*/
int
{
return (DDI_SUCCESS);
}
/*ARGSUSED*/
int
{
return (DDI_SUCCESS);
}
/*ARGSUSED*/
int
{
return (DDI_SUCCESS);
}
/*ARGSUSED*/
int
void **resultp)
{
return (DDI_SUCCESS);
}
int
{
}
int
{
return (DDI_SUCCESS);
}
static int
{
DRM_ERROR("drm_get_businfo: get irq error");
return (DDI_FAILURE);
}
/* XXX Fix domain number (alpha hoses) */
dev->pci_domain = 0;
DRM_ERROR("drm_get_businfo: get bus slot func error ");
return (DDI_FAILURE);
}
DRM_DEBUG("drm_get_businfo: pci bus: %d, pci slot :%d pci func %d",
return (DDI_SUCCESS);
}
int
{
const char *s = NULL;
DRM_DEBUG("drm_probe: vendor is 0x%x, device is 0x%x",
if (s != NULL) {
DRM_DEBUG("drm_probe: probe %s exist",
DRM_ERROR("drm_probe: drm get bus info error");
return (DDI_FAILURE);
}
return (DDI_SUCCESS);
}
return (DDI_FAILURE);
}