From c9202c89653b8dac2ac322c3d3a7389945e1c94c Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Sat, 6 Nov 2004 01:41:47 +0000 Subject: Commit WIP of BSD conversion to core model. Compiles for r128, radeon, but doesn't run yet. Moves the ioctl definitions for these two drivers back to the shared code -- they aren't OS-specific. --- bsd-core/drm_context.c | 64 +++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 34 deletions(-) (limited to 'bsd-core/drm_context.c') diff --git a/bsd-core/drm_context.c b/bsd-core/drm_context.c index aa655297..87185f4e 100644 --- a/bsd-core/drm_context.c +++ b/bsd-core/drm_context.c @@ -32,15 +32,11 @@ #include "drmP.h" -#if !__HAVE_CTX_BITMAP -#error "__HAVE_CTX_BITMAP must be defined" -#endif - /* ================================================================ * Context bitmap support */ -void DRM(ctxbitmap_free)( drm_device_t *dev, int ctx_handle ) +void drm_ctxbitmap_free(drm_device_t *dev, int ctx_handle) { if (ctx_handle < 0 || ctx_handle >= DRM_MAX_CTXBITMAP || dev->ctx_bitmap == NULL) { @@ -56,7 +52,7 @@ void DRM(ctxbitmap_free)( drm_device_t *dev, int ctx_handle ) return; } -int DRM(ctxbitmap_next)( drm_device_t *dev ) +int drm_ctxbitmap_next(drm_device_t *dev) { int bit; @@ -77,7 +73,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev ) if (dev->context_sareas != NULL) { drm_local_map_t **ctx_sareas; - ctx_sareas = DRM(realloc)(dev->context_sareas, + ctx_sareas = drm_realloc(dev->context_sareas, (dev->max_context - 1) * sizeof(*dev->context_sareas), dev->max_context * @@ -92,7 +88,7 @@ int DRM(ctxbitmap_next)( drm_device_t *dev ) dev->context_sareas[bit] = NULL; } else { /* max_context == 1 at this point */ - dev->context_sareas = DRM(alloc)(dev->max_context * + dev->context_sareas = drm_alloc(dev->max_context * sizeof(*dev->context_sareas), DRM_MEM_MAPS); if (dev->context_sareas == NULL) { clear_bit(bit, dev->ctx_bitmap); @@ -106,13 +102,13 @@ int DRM(ctxbitmap_next)( drm_device_t *dev ) return bit; } -int DRM(ctxbitmap_init)( drm_device_t *dev ) +int drm_ctxbitmap_init(drm_device_t *dev) { int i; int temp; DRM_LOCK(); - dev->ctx_bitmap = (atomic_t *)DRM(calloc)(1, PAGE_SIZE, + dev->ctx_bitmap = (atomic_t *)drm_calloc(1, PAGE_SIZE, DRM_MEM_CTXBITMAP); if ( dev->ctx_bitmap == NULL ) { DRM_UNLOCK(); @@ -123,20 +119,20 @@ int DRM(ctxbitmap_init)( drm_device_t *dev ) DRM_UNLOCK(); for ( i = 0 ; i < DRM_RESERVED_CONTEXTS ; i++ ) { - temp = DRM(ctxbitmap_next)( dev ); + temp = drm_ctxbitmap_next(dev); DRM_DEBUG( "drm_ctxbitmap_init : %d\n", temp ); } return 0; } -void DRM(ctxbitmap_cleanup)( drm_device_t *dev ) +void drm_ctxbitmap_cleanup(drm_device_t *dev) { DRM_LOCK(); if (dev->context_sareas != NULL) - DRM(free)(dev->context_sareas, sizeof(*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_free((void *)dev->ctx_bitmap, PAGE_SIZE, DRM_MEM_CTXBITMAP); DRM_UNLOCK(); } @@ -144,7 +140,7 @@ void DRM(ctxbitmap_cleanup)( drm_device_t *dev ) * Per Context SAREA Support */ -int DRM(getsareactx)( DRM_IOCTL_ARGS ) +int drm_getsareactx( DRM_IOCTL_ARGS ) { DRM_DEVICE; drm_ctx_priv_map_t request; @@ -169,7 +165,7 @@ int DRM(getsareactx)( DRM_IOCTL_ARGS ) return 0; } -int DRM(setsareactx)( DRM_IOCTL_ARGS ) +int drm_setsareactx( DRM_IOCTL_ARGS ) { DRM_DEVICE; drm_ctx_priv_map_t request; @@ -202,7 +198,7 @@ bad: * The actual DRM context handling routines */ -int DRM(context_switch)( drm_device_t *dev, int old, int new ) +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" ); @@ -219,7 +215,7 @@ int DRM(context_switch)( drm_device_t *dev, int old, int new ) return 0; } -int DRM(context_switch_complete)( drm_device_t *dev, int new ) +int drm_context_switch_complete(drm_device_t *dev, int new) { dev->last_context = new; /* PRE/POST: This is the _only_ writer. */ @@ -235,7 +231,7 @@ int DRM(context_switch_complete)( drm_device_t *dev, int new ) return 0; } -int DRM(resctx)( DRM_IOCTL_ARGS ) +int drm_resctx(DRM_IOCTL_ARGS) { drm_ctx_res_t res; drm_ctx_t ctx; @@ -259,17 +255,17 @@ int DRM(resctx)( DRM_IOCTL_ARGS ) return 0; } -int DRM(addctx)( DRM_IOCTL_ARGS ) +int drm_addctx(DRM_IOCTL_ARGS) { DRM_DEVICE; drm_ctx_t ctx; DRM_COPY_FROM_USER_IOCTL( ctx, (drm_ctx_t *)data, sizeof(ctx) ); - ctx.handle = DRM(ctxbitmap_next)( dev ); + ctx.handle = drm_ctxbitmap_next(dev); if ( ctx.handle == DRM_KERNEL_CONTEXT ) { /* Skip kernel's context and get a new one. */ - ctx.handle = DRM(ctxbitmap_next)( dev ); + ctx.handle = drm_ctxbitmap_next(dev); } DRM_DEBUG( "%d\n", ctx.handle ); if ( ctx.handle == -1 ) { @@ -278,21 +274,21 @@ int DRM(addctx)( DRM_IOCTL_ARGS ) return DRM_ERR(ENOMEM); } - if ( dev->fn_tbl.context_ctor && ctx.handle != DRM_KERNEL_CONTEXT ) - dev->fn_tbl.context_ctor(dev, ctx.handle); + if (dev->context_ctor && ctx.handle != DRM_KERNEL_CONTEXT) + dev->context_ctor(dev, ctx.handle); DRM_COPY_TO_USER_IOCTL( (drm_ctx_t *)data, ctx, sizeof(ctx) ); return 0; } -int DRM(modctx)( DRM_IOCTL_ARGS ) +int drm_modctx(DRM_IOCTL_ARGS) { /* This does nothing */ return 0; } -int DRM(getctx)( DRM_IOCTL_ARGS ) +int drm_getctx(DRM_IOCTL_ARGS) { drm_ctx_t ctx; @@ -306,7 +302,7 @@ int DRM(getctx)( DRM_IOCTL_ARGS ) return 0; } -int DRM(switchctx)( DRM_IOCTL_ARGS ) +int drm_switchctx(DRM_IOCTL_ARGS) { DRM_DEVICE; drm_ctx_t ctx; @@ -314,10 +310,10 @@ int DRM(switchctx)( DRM_IOCTL_ARGS ) 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 ); + return drm_context_switch(dev, dev->last_context, ctx.handle); } -int DRM(newctx)( DRM_IOCTL_ARGS ) +int drm_newctx(DRM_IOCTL_ARGS) { DRM_DEVICE; drm_ctx_t ctx; @@ -325,12 +321,12 @@ int DRM(newctx)( DRM_IOCTL_ARGS ) 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 ); + drm_context_switch_complete(dev, ctx.handle); return 0; } -int DRM(rmctx)( DRM_IOCTL_ARGS ) +int drm_rmctx(DRM_IOCTL_ARGS) { DRM_DEVICE; drm_ctx_t ctx; @@ -339,10 +335,10 @@ int DRM(rmctx)( DRM_IOCTL_ARGS ) DRM_DEBUG( "%d\n", ctx.handle ); if ( ctx.handle != DRM_KERNEL_CONTEXT ) { - if (dev->fn_tbl.context_dtor) - dev->fn_tbl.context_dtor(dev, ctx.handle); + if (dev->context_dtor) + dev->context_dtor(dev, ctx.handle); - DRM(ctxbitmap_free)( dev, ctx.handle ); + drm_ctxbitmap_free(dev, ctx.handle); } return 0; -- cgit v1.2.3