drm_bufs.c revision e92e3a8694f157faf8a9e44096a70ada86c556bf
/*
* drm_bufs.h -- Generic buffer 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"
/*
* Compute order. Can be made faster.
*/
int
{
int order;
unsigned long tmp;
++order;
return (order);
}
int
{
DRM_DEBUG("drm_addmap: offset = 0x%08llx, size = 0x%08lx, type = %d\n",
/*
* Only allow shared memory to be removable since we only keep enough
* book keeping information about shared memory to allow for removal
* when processes fork.
*/
/*
* Check if this is just another version of a kernel-allocated map, and
* just hand that back if so.
*/
DRM_LOCK();
DRM_DEBUG("drm_addmap: Found kernel map %d\n",
type);
goto done;
}
}
DRM_UNLOCK();
}
/*
* Allocate a new map structure, fill it in, and do any type-specific
* initialization necessary.
*/
if (!map)
case _DRM_REGISTERS:
DRM_DEBUG("drm_addmap: map the Registers");
break;
/* FALLTHROUGH */
case _DRM_FRAME_BUFFER:
break;
case _DRM_SHM:
&map->drm_umem_cookie);
DRM_DEBUG("drm_addmap: size=0x%lx drm_order(size)=%d "
"handle=0x%p\n",
DRM_ERROR("drm_addmap: ddi_umem_alloc failed");
}
/*
* record only low 32-bit of this handle, since 32-bit user
* app is incapable of passing in 64bit offset when doing mmap.
*/
/* Prevent a 2nd X Server from creating a 2nd lock */
DRM_LOCK();
DRM_UNLOCK();
}
DRM_DEBUG("drm_addmap: map shm to hw_lock");
DRM_UNLOCK();
}
break;
case _DRM_SCATTER_GATHER:
}
break;
case _DRM_CONSISTENT:
break;
case _DRM_AGP:
break;
case _DRM_AGP_UMEM:
break;
default:
}
DRM_LOCK();
done:
/* Jumped to, with lock held, when a kernel map is found. */
DRM_UNLOCK();
DRM_DEBUG("drm_addmap: Added map %d 0x%llx/0x%x\n",
DRM_DEBUG("type=%x, offset=%llx, size=%x",
}
return (0);
}
/*ARGSUSED*/
int
{
int err;
(drm_map32_t *)data,
sizeof (drm_map32_t));
} else
sizeof (drm_map_t));
if (err != 0)
return (err);
}
sizeof (drm_map32_t));
} else
sizeof (drm_map_t));
return (0);
}
void
{
case _DRM_REGISTERS:
break;
/* FALLTHROUGH */
case _DRM_FRAME_BUFFER:
break;
case _DRM_SHM:
break;
case _DRM_AGP:
case _DRM_SCATTER_GATHER:
break;
case _DRM_CONSISTENT:
break;
default:
break;
}
}
/*
* Remove a map private from list and deallocate resources if the mapping
* isn't in use.
*/
/*ARGSUSED*/
int
{
(drm_map32_t *)data,
sizeof (drm_map32_t));
} else
sizeof (request));
DRM_LOCK();
break;
}
/* No match found. */
DRM_UNLOCK();
}
DRM_UNLOCK();
return (0);
}
/*ARGSUSED*/
static void
{
int i;
"drm_cleanup_buf_error: not implemented");
}
}
}
}
}
}
}
/*ARGSUSED*/
int
{
DRM_DEBUG("drm_markbufs");
}
/*ARGSUSED*/
int
{
DRM_DEBUG("drm_infobufs");
}
static int
{
unsigned long offset;
unsigned long agp_offset;
int count;
int order;
int size;
int alignment;
int page_order;
int total;
int byte_count;
int i;
if (!dma)
byte_count = 0;
}
offset = 0;
/* Set count correctly so we free the proper amount. */
}
}
if (temp_buflist == NULL) {
/* Free the entry because it isn't valid */
DRM_ERROR(" temp_buflist is NULL");
}
}
DRM_DEBUG("drm_do_addbufs_agp: entry->buf_count : %d\n",
DRM_DEBUG("drm_do_addbufs_agp: add bufs succesfful.");
return (0);
}
static int
{
unsigned long offset;
unsigned long agp_offset;
int count;
int order;
int size;
int alignment;
int page_order;
int total;
int byte_count;
int i;
byte_count = 0;
offset = 0;
/* Set count correctly so we free the proper amount. */
}
DRM_DEBUG("drm_do_addbufs_sg: buffer %d @ %p\n",
}
if (!temp_buflist) {
}
}
DRM_DEBUG("drm_do_addbufs_sg: entry->buf_count: %d\n",
return (0);
}
int
{
}
}
/* No more allocations after first buffer-using ioctl. */
}
/* No more than one allocation per order */
}
return (ret);
}
int
{
}
}
/* No more allocations after first buffer-using ioctl. */
}
/* No more than one allocation per order */
}
return (ret);
}
/*ARGSUSED*/
int
{
int err;
(drm_buf_desc32_t *)data,
sizeof (drm_buf_desc32_t));
} else
sizeof (request));
sizeof (drm_buf_desc32_t));
} else
sizeof (request));
return (err);
}
/*ARGSUSED*/
int
{
int i;
int idx;
int retcode = 0;
DRM_DEBUG("drm_freebufs: ");
(drm_buf_free32_t *)data,
sizeof (drm_buf_free32_t));
} else
sizeof (request));
break;
}
DRM_ERROR("drm_freebufs: Index %d (of %d max)\n",
break;
}
"drm_freebufs: process %d not owning the buffer.\n",
break;
}
}
return (retcode);
}
/*ARGSUSED*/
int
{
int i;
int retcode = 0;
const int zero = 0;
unsigned long vaddr;
unsigned long address;
int ret_tmp;
(drm_buf_map32_t *)data,
sizeof (drm_buf_map32_t));
} else
sizeof (request));
goto done;
DRM_ERROR("drm_mapbufs: request.virtual is NULL");
}
goto done;
}
goto done;
}
sizeof (zero))) {
goto done;
}
sizeof (caddr32_t));
} else
if (ret_tmp) {
goto done;
}
}
done:
DRM_DEBUG("drm_mapbufs: %d buffers, retcode = %d\n",
request32, sizeof (drm_buf_map32_t));
} else
sizeof (request));
}