summaryrefslogtreecommitdiff
path: root/bsd/drm_context.h
diff options
context:
space:
mode:
Diffstat (limited to 'bsd/drm_context.h')
-rw-r--r--bsd/drm_context.h188
1 files changed, 94 insertions, 94 deletions
diff --git a/bsd/drm_context.h b/bsd/drm_context.h
index d572a9de..0274a8b7 100644
--- a/bsd/drm_context.h
+++ b/bsd/drm_context.h
@@ -43,10 +43,10 @@ void DRM(ctxbitmap_free)( drm_device_t *dev, int ctx_handle )
if ( !dev->ctx_bitmap ) goto failed;
if ( ctx_handle < DRM_MAX_CTXBITMAP ) {
- DRM_OS_LOCK;
+ DRM_LOCK;
clear_bit( ctx_handle, dev->ctx_bitmap );
dev->context_sareas[ctx_handle] = NULL;
- DRM_OS_UNLOCK;
+ DRM_UNLOCK;
return;
}
failed:
@@ -61,7 +61,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
if(!dev->ctx_bitmap) return -1;
- DRM_OS_LOCK;
+ DRM_LOCK;
bit = find_first_zero_bit( dev->ctx_bitmap, DRM_MAX_CTXBITMAP );
if ( bit < DRM_MAX_CTXBITMAP ) {
set_bit( bit, dev->ctx_bitmap );
@@ -79,7 +79,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
DRM_MEM_MAPS);
if(!ctx_sareas) {
clear_bit(bit, dev->ctx_bitmap);
- DRM_OS_UNLOCK;
+ DRM_UNLOCK;
return -1;
}
dev->context_sareas = ctx_sareas;
@@ -92,16 +92,16 @@ int DRM(ctxbitmap_next)( drm_device_t *dev )
DRM_MEM_MAPS);
if(!dev->context_sareas) {
clear_bit(bit, dev->ctx_bitmap);
- DRM_OS_UNLOCK;
+ DRM_UNLOCK;
return -1;
}
dev->context_sareas[bit] = NULL;
}
}
- DRM_OS_UNLOCK;
+ DRM_UNLOCK;
return bit;
}
- DRM_OS_UNLOCK;
+ DRM_UNLOCK;
return -1;
}
@@ -110,17 +110,17 @@ int DRM(ctxbitmap_init)( drm_device_t *dev )
int i;
int temp;
- DRM_OS_LOCK;
+ DRM_LOCK;
dev->ctx_bitmap = (atomic_t *) DRM(alloc)( PAGE_SIZE,
DRM_MEM_CTXBITMAP );
if ( dev->ctx_bitmap == NULL ) {
- DRM_OS_UNLOCK;
- DRM_OS_RETURN(ENOMEM);
+ DRM_UNLOCK;
+ return DRM_ERR(ENOMEM);
}
memset( (void *)dev->ctx_bitmap, 0, PAGE_SIZE );
dev->context_sareas = NULL;
dev->max_context = -1;
- DRM_OS_UNLOCK;
+ DRM_UNLOCK;
for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) {
temp = DRM(ctxbitmap_next)( dev );
@@ -132,55 +132,55 @@ int DRM(ctxbitmap_init)( drm_device_t *dev )
void DRM(ctxbitmap_cleanup)( drm_device_t *dev )
{
- DRM_OS_LOCK;
+ DRM_LOCK;
if( dev->context_sareas ) DRM(free)( dev->context_sareas,
sizeof(*dev->context_sareas) *
dev->max_context,
DRM_MEM_MAPS );
DRM(free)( (void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP );
- DRM_OS_UNLOCK;
+ DRM_UNLOCK;
}
/* ================================================================
* Per Context SAREA Support
*/
-int DRM(getsareactx)( DRM_OS_IOCTL )
+int DRM(getsareactx)( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_ctx_priv_map_t request;
drm_map_t *map;
- DRM_OS_KRNFROMUSR( request, (drm_ctx_priv_map_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( request, (drm_ctx_priv_map_t *)data,
sizeof(request) );
- DRM_OS_LOCK;
+ DRM_LOCK;
if (dev->max_context < 0 || request.ctx_id >= (unsigned) dev->max_context) {
- DRM_OS_UNLOCK;
- DRM_OS_RETURN(EINVAL);
+ DRM_UNLOCK;
+ return DRM_ERR(EINVAL);
}
map = dev->context_sareas[request.ctx_id];
- DRM_OS_UNLOCK;
+ DRM_UNLOCK;
request.handle = map->handle;
- DRM_OS_KRNTOUSR( (drm_ctx_priv_map_t *)data, request, sizeof(request) );
+ DRM_COPY_TO_USER_IOCTL( (drm_ctx_priv_map_t *)data, request, sizeof(request) );
return 0;
}
-int DRM(setsareactx)( DRM_OS_IOCTL )
+int DRM(setsareactx)( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_ctx_priv_map_t request;
drm_map_t *map = NULL;
drm_map_list_entry_t *list;
- DRM_OS_KRNFROMUSR( request, (drm_ctx_priv_map_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( request, (drm_ctx_priv_map_t *)data,
sizeof(request) );
- DRM_OS_LOCK;
+ DRM_LOCK;
TAILQ_FOREACH(list, dev->maplist, link) {
map=list->map;
if(map->handle == request.handle)
@@ -188,8 +188,8 @@ int DRM(setsareactx)( DRM_OS_IOCTL )
}
bad:
- DRM_OS_UNLOCK;
- return DRM_OS_ERR(EINVAL);
+ DRM_UNLOCK;
+ return DRM_ERR(EINVAL);
found:
map = list->map;
@@ -199,7 +199,7 @@ found:
if (request.ctx_id >= (unsigned) dev->max_context)
goto bad;
dev->context_sareas[request.ctx_id] = map;
- DRM_OS_UNLOCK;
+ DRM_UNLOCK;
return 0;
}
@@ -213,7 +213,7 @@ int DRM(context_switch)( drm_device_t *dev, int old, int new )
if ( test_and_set_bit( 0, &dev->context_flag ) ) {
DRM_ERROR( "Reentering -- FIXME\n" );
- DRM_OS_RETURN(EBUSY);
+ return DRM_ERR(EBUSY);
}
#if __HAVE_DMA_HISTOGRAM
@@ -255,41 +255,41 @@ int DRM(context_switch_complete)( drm_device_t *dev, int new )
#endif
clear_bit( 0, &dev->context_flag );
- DRM_OS_WAKEUP( (void *)&dev->context_wait );
+ DRM_WAKEUP( (void *)&dev->context_wait );
return 0;
}
-int DRM(resctx)( DRM_OS_IOCTL )
+int DRM(resctx)( DRM_IOCTL_ARGS )
{
drm_ctx_res_t res;
drm_ctx_t ctx;
int i;
- DRM_OS_KRNFROMUSR( res, (drm_ctx_res_t *)data, sizeof(res) );
+ DRM_COPY_FROM_USER_IOCTL( res, (drm_ctx_res_t *)data, sizeof(res) );
if ( res.count >= DRM_RESERVED_CONTEXTS ) {
memset( &ctx, 0, sizeof(ctx) );
for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) {
ctx.handle = i;
- if ( DRM_OS_COPYTOUSR( &res.contexts[i],
+ if ( DRM_COPY_TO_USER( &res.contexts[i],
&i, sizeof(i) ) )
- DRM_OS_RETURN(EFAULT);
+ return DRM_ERR(EFAULT);
}
}
res.count = DRM_RESERVED_CONTEXTS;
- DRM_OS_KRNTOUSR( (drm_ctx_res_t *)data, res, sizeof(res) );
+ DRM_COPY_TO_USER_IOCTL( (drm_ctx_res_t *)data, res, sizeof(res) );
return 0;
}
-int DRM(addctx)( DRM_OS_IOCTL )
+int DRM(addctx)( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_ctx_t ctx;
- DRM_OS_KRNFROMUSR( ctx, (drm_ctx_t *)data, sizeof(ctx) );
+ DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
ctx.handle = DRM(ctxbitmap_next)( dev );
if ( ctx.handle == DRM_KERNEL_CONTEXT ) {
@@ -300,51 +300,51 @@ int DRM(addctx)( DRM_OS_IOCTL )
if ( ctx.handle == -1 ) {
DRM_DEBUG( "Not enough free contexts.\n" );
/* Should this return -EBUSY instead? */
- DRM_OS_RETURN(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
- DRM_OS_KRNTOUSR( (drm_ctx_t *)data, ctx, sizeof(ctx) );
+ DRM_COPY_TO_USER_IOCTL( (drm_ctx_t *)data, ctx, sizeof(ctx) );
return 0;
}
-int DRM(modctx)( DRM_OS_IOCTL )
+int DRM(modctx)( DRM_IOCTL_ARGS )
{
/* This does nothing */
return 0;
}
-int DRM(getctx)( DRM_OS_IOCTL )
+int DRM(getctx)( DRM_IOCTL_ARGS )
{
drm_ctx_t ctx;
- DRM_OS_KRNFROMUSR( ctx, (drm_ctx_t *)data, sizeof(ctx) );
+ DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
/* This is 0, because we don't handle any context flags */
ctx.flags = 0;
- DRM_OS_KRNTOUSR( (drm_ctx_t *)data, ctx, sizeof(ctx) );
+ DRM_COPY_TO_USER_IOCTL( (drm_ctx_t *)data, ctx, sizeof(ctx) );
return 0;
}
-int DRM(switchctx)( DRM_OS_IOCTL )
+int DRM(switchctx)( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_ctx_t ctx;
- DRM_OS_KRNFROMUSR( ctx, (drm_ctx_t *)data, sizeof(ctx) );
+ DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
DRM_DEBUG( "%d\n", ctx.handle );
return DRM(context_switch)( dev, dev->last_context, ctx.handle );
}
-int DRM(newctx)( DRM_OS_IOCTL )
+int DRM(newctx)( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_ctx_t ctx;
- DRM_OS_KRNFROMUSR( ctx, (drm_ctx_t *)data, sizeof(ctx) );
+ DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
DRM_DEBUG( "%d\n", ctx.handle );
DRM(context_switch_complete)( dev, ctx.handle );
@@ -352,12 +352,12 @@ int DRM(newctx)( DRM_OS_IOCTL )
return 0;
}
-int DRM(rmctx)( DRM_OS_IOCTL )
+int DRM(rmctx)( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_ctx_t ctx;
- DRM_OS_KRNFROMUSR( ctx, (drm_ctx_t *)data, sizeof(ctx) );
+ DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
DRM_DEBUG( "%d\n", ctx.handle );
if ( ctx.handle != DRM_KERNEL_CONTEXT ) {
@@ -386,7 +386,7 @@ int DRM(context_switch)(drm_device_t *dev, int old, int new)
if (test_and_set_bit(0, &dev->context_flag)) {
DRM_ERROR("Reentering -- FIXME\n");
- DRM_OS_RETURN(EBUSY);
+ return DRM_ERR(EBUSY);
}
#if __HAVE_DMA_HISTOGRAM
@@ -397,7 +397,7 @@ int DRM(context_switch)(drm_device_t *dev, int old, int new)
if (new >= dev->queue_count) {
clear_bit(0, &dev->context_flag);
- DRM_OS_RETURN(EINVAL);
+ return DRM_ERR(EINVAL);
}
if (new == dev->last_context) {
@@ -410,7 +410,7 @@ int DRM(context_switch)(drm_device_t *dev, int old, int new)
if (atomic_read(&q->use_count) == 1) {
atomic_dec(&q->use_count);
clear_bit(0, &dev->context_flag);
- DRM_OS_RETURN(EINVAL);
+ return DRM_ERR(EINVAL);
}
if (DRM(flags) & DRM_FLAG_NOCTX) {
@@ -449,7 +449,7 @@ int DRM(context_switch_complete)(drm_device_t *dev, int new)
#endif
clear_bit(0, &dev->context_flag);
- DRM_OS_WAKEUP_INT(&dev->context_wait);
+ DRM_WAKEUP_INT(&dev->context_wait);
return 0;
}
@@ -513,7 +513,7 @@ static int DRM(alloc_queue)(drm_device_t *dev)
atomic_dec(&dev->queuelist[i]->use_count);
}
/* Allocate a new queue */
- DRM_OS_LOCK;
+ DRM_LOCK;
queue = gamma_alloc(sizeof(*queue), DRM_MEM_QUEUES);
memset(queue, 0, sizeof(*queue));
@@ -531,19 +531,19 @@ static int DRM(alloc_queue)(drm_device_t *dev)
newslots,
DRM_MEM_QUEUES);
if (!dev->queuelist) {
- DRM_OS_UNLOCK;
+ DRM_UNLOCK;
DRM_DEBUG("out of memory\n");
- DRM_OS_RETURN(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
}
dev->queuelist[dev->queue_count-1] = queue;
- DRM_OS_UNLOCK;
+ DRM_UNLOCK;
DRM_DEBUG("%d (new)\n", dev->queue_count - 1);
return dev->queue_count - 1;
}
-int DRM(resctx)( DRM_OS_IOCTL )
+int DRM(resctx)( DRM_IOCTL_ARGS )
{
drm_ctx_res_t res;
drm_ctx_t ctx;
@@ -551,31 +551,31 @@ int DRM(resctx)( DRM_OS_IOCTL )
DRM_DEBUG("%d\n", DRM_RESERVED_CONTEXTS);
- DRM_OS_KRNFROMUSR( res, (drm_ctx_res_t *)data, sizeof(res) );
+ DRM_COPY_FROM_USER_IOCTL( res, (drm_ctx_res_t *)data, sizeof(res) );
if (res.count >= DRM_RESERVED_CONTEXTS) {
memset(&ctx, 0, sizeof(ctx));
for (i = 0; i < DRM_RESERVED_CONTEXTS; i++) {
ctx.handle = i;
- if (DRM_OS_COPYTOUSR(&res.contexts[i],
+ if (DRM_COPY_TO_USER(&res.contexts[i],
&i,
sizeof(i)))
- DRM_OS_RETURN(EFAULT);
+ return DRM_ERR(EFAULT);
}
}
res.count = DRM_RESERVED_CONTEXTS;
- DRM_OS_KRNTOUSR( (drm_ctx_res_t *)data, res, sizeof(res) );
+ DRM_COPY_TO_USER_IOCTL( (drm_ctx_res_t *)data, res, sizeof(res) );
return 0;
}
-int DRM(addctx)( DRM_OS_IOCTL )
+int DRM(addctx)( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_ctx_t ctx;
- DRM_OS_KRNFROMUSR( ctx, (drm_ctx_t *)data, sizeof(ctx) );
+ DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
if ((ctx.handle = DRM(alloc_queue)(dev)) == DRM_KERNEL_CONTEXT) {
/* Init kernel's context and get a new one. */
@@ -585,35 +585,35 @@ int DRM(addctx)( DRM_OS_IOCTL )
DRM(init_queue)(dev, dev->queuelist[ctx.handle], &ctx);
DRM_DEBUG("%d\n", ctx.handle);
- DRM_OS_KRNTOUSR( (drm_ctx_t *)data, ctx, sizeof(ctx) );
+ DRM_COPY_TO_USER_IOCTL( (drm_ctx_t *)data, ctx, sizeof(ctx) );
return 0;
}
-int DRM(modctx)( DRM_OS_IOCTL )
+int DRM(modctx)( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_ctx_t ctx;
drm_queue_t *q;
- DRM_OS_KRNFROMUSR( ctx, (drm_ctx_t *)data, sizeof(ctx) );
+ DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
DRM_DEBUG("%d\n", ctx.handle);
if (ctx.handle < 0 || ctx.handle >= dev->queue_count)
- DRM_OS_RETURN(EINVAL);
+ return DRM_ERR(EINVAL);
q = dev->queuelist[ctx.handle];
atomic_inc(&q->use_count);
if (atomic_read(&q->use_count) == 1) {
/* No longer in use */
atomic_dec(&q->use_count);
- DRM_OS_RETURN(EINVAL);
+ return DRM_ERR(EINVAL);
}
if (DRM_BUFCOUNT(&q->waitlist)) {
atomic_dec(&q->use_count);
- DRM_OS_RETURN(EBUSY);
+ return DRM_ERR(EBUSY);
}
q->flags = ctx.flags;
@@ -622,52 +622,52 @@ int DRM(modctx)( DRM_OS_IOCTL )
return 0;
}
-int DRM(getctx)( DRM_OS_IOCTL )
+int DRM(getctx)( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_ctx_t ctx;
drm_queue_t *q;
- DRM_OS_KRNFROMUSR( ctx, (drm_ctx_t *)data, sizeof(ctx) );
+ DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
DRM_DEBUG("%d\n", ctx.handle);
if (ctx.handle >= dev->queue_count)
- DRM_OS_RETURN(EINVAL);
+ return DRM_ERR(EINVAL);
q = dev->queuelist[ctx.handle];
atomic_inc(&q->use_count);
if (atomic_read(&q->use_count) == 1) {
/* No longer in use */
atomic_dec(&q->use_count);
- DRM_OS_RETURN(EINVAL);
+ return DRM_ERR(EINVAL);
}
ctx.flags = q->flags;
atomic_dec(&q->use_count);
- DRM_OS_KRNTOUSR( (drm_ctx_t *)data, ctx, sizeof(ctx) );
+ DRM_COPY_TO_USER_IOCTL( (drm_ctx_t *)data, ctx, sizeof(ctx) );
return 0;
}
-int DRM(switchctx)( DRM_OS_IOCTL )
+int DRM(switchctx)( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_ctx_t ctx;
- DRM_OS_KRNFROMUSR( ctx, (drm_ctx_t *)data, sizeof(ctx) );
+ DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
DRM_DEBUG("%d\n", ctx.handle);
return DRM(context_switch)(dev, dev->last_context, ctx.handle);
}
-int DRM(newctx)( DRM_OS_IOCTL )
+int DRM(newctx)( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_ctx_t ctx;
- DRM_OS_KRNFROMUSR( ctx, (drm_ctx_t *)data, sizeof(ctx) );
+ DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
DRM_DEBUG("%d\n", ctx.handle);
DRM(context_switch_complete)(dev, ctx.handle);
@@ -675,25 +675,25 @@ int DRM(newctx)( DRM_OS_IOCTL )
return 0;
}
-int DRM(rmctx)( DRM_OS_IOCTL )
+int DRM(rmctx)( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_ctx_t ctx;
drm_queue_t *q;
drm_buf_t *buf;
- DRM_OS_KRNFROMUSR( ctx, (drm_ctx_t *)data, sizeof(ctx) );
+ DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) );
DRM_DEBUG("%d\n", ctx.handle);
- if (ctx.handle >= dev->queue_count) DRM_OS_RETURN(EINVAL);
+ if (ctx.handle >= dev->queue_count) return DRM_ERR(EINVAL);
q = dev->queuelist[ctx.handle];
atomic_inc(&q->use_count);
if (atomic_read(&q->use_count) == 1) {
/* No longer in use */
atomic_dec(&q->use_count);
- DRM_OS_RETURN(EINVAL);
+ return DRM_ERR(EINVAL);
}
atomic_inc(&q->finalization); /* Mark queue in finalization state */
@@ -716,7 +716,7 @@ int DRM(rmctx)( DRM_OS_IOCTL )
/* Wakeup blocked processes */
wakeup( &q->block_read );
wakeup( &q->block_write );
- DRM_OS_WAKEUP_INT( &q->flush_queue );
+ DRM_WAKEUP_INT( &q->flush_queue );
/* Finalization over. Queue is made
available when both use_count and
finalization become 0, which won't