diff options
author | Eric Anholt <anholt@freebsd.org> | 2002-06-27 22:41:08 +0000 |
---|---|---|
committer | Eric Anholt <anholt@freebsd.org> | 2002-06-27 22:41:08 +0000 |
commit | 563bc3158dfc6260a5ae159deab575b469be1167 (patch) | |
tree | c246c3cd09d8188921481139ecd2248f85cb2d1d /bsd | |
parent | 54fca8169634fbcb41cbf12007946777bcb8623e (diff) |
os-independent interface name changes (mostly DRM_OS_* -> DRM_)
Suggested by: keithw
Diffstat (limited to 'bsd')
-rw-r--r-- | bsd/ati_pcigart.h | 2 | ||||
-rw-r--r-- | bsd/drmP.h | 14 | ||||
-rw-r--r-- | bsd/drm_agpsupport.h | 44 | ||||
-rw-r--r-- | bsd/drm_auth.h | 42 | ||||
-rw-r--r-- | bsd/drm_bufs.h | 274 | ||||
-rw-r--r-- | bsd/drm_context.h | 188 | ||||
-rw-r--r-- | bsd/drm_dma.h | 66 | ||||
-rw-r--r-- | bsd/drm_drawable.h | 6 | ||||
-rw-r--r-- | bsd/drm_drv.h | 106 | ||||
-rw-r--r-- | bsd/drm_fops.h | 22 | ||||
-rw-r--r-- | bsd/drm_ioctl.h | 76 | ||||
-rw-r--r-- | bsd/drm_lists.h | 36 | ||||
-rw-r--r-- | bsd/drm_lock.h | 14 | ||||
-rw-r--r-- | bsd/drm_memory.h | 84 | ||||
-rw-r--r-- | bsd/drm_os_freebsd.h | 96 | ||||
-rw-r--r-- | bsd/drm_os_netbsd.h | 78 | ||||
-rw-r--r-- | bsd/drm_scatter.h | 22 | ||||
-rw-r--r-- | bsd/drm_sysctl.h | 24 | ||||
-rw-r--r-- | bsd/drm_vm.h | 10 | ||||
-rw-r--r-- | bsd/gamma_dma.c | 56 | ||||
-rw-r--r-- | bsd/gamma_drv.h | 6 | ||||
-rw-r--r-- | bsd/i810_dma.c | 116 | ||||
-rw-r--r-- | bsd/i810_drv.h | 18 | ||||
-rw-r--r-- | bsd/sis_drm.h | 10 |
24 files changed, 704 insertions, 706 deletions
diff --git a/bsd/ati_pcigart.h b/bsd/ati_pcigart.h index ca61e6dd..28723f56 100644 --- a/bsd/ati_pcigart.h +++ b/bsd/ati_pcigart.h @@ -122,7 +122,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev, ret = 1; - DRM_OS_READMEMORYBARRIER(); + DRM_READMEMORYBARRIER(); done: *addr = address; @@ -243,8 +243,8 @@ typedef struct drm_waitlist { drm_buf_t **rp; /* Read pointer */ drm_buf_t **wp; /* Write pointer */ drm_buf_t **end; /* End pointer */ - DRM_OS_SPINTYPE read_lock; - DRM_OS_SPINTYPE write_lock; + DRM_SPINTYPE read_lock; + DRM_SPINTYPE write_lock; } drm_waitlist_t; typedef struct drm_freelist { @@ -256,7 +256,7 @@ typedef struct drm_freelist { int low_mark; /* Low water mark */ int high_mark; /* High water mark */ atomic_t wfh; /* If waiting for high mark */ - DRM_OS_SPINTYPE lock; + DRM_SPINTYPE lock; } drm_freelist_t; typedef struct drm_buf_entry { @@ -410,7 +410,7 @@ struct drm_device { int writable; /* Opened with FWRITE */ /* Locks */ - DRM_OS_SPINTYPE count_lock; /* For inuse, open_count, buf_use */ + DRM_SPINTYPE count_lock; /* For inuse, open_count, buf_use */ struct lock dev_lock; /* For others */ /* Usage Counters */ int open_count; /* Outstanding files open */ @@ -510,7 +510,7 @@ extern int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, extern int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic); /* Driver support (drm_drv.h) */ -extern int DRM(version)( DRM_OS_IOCTL ); +extern int DRM(version)( DRM_IOCTL_ARGS ); extern int DRM(write_string)(drm_device_t *dev, const char *s); /* Memory management support (drm_memory.h) */ @@ -578,9 +578,9 @@ extern int DRM(dma_get_buffers)(drm_device_t *dev, drm_dma_t *dma); #if __HAVE_DMA_IRQ extern int DRM(irq_install)( drm_device_t *dev, int irq ); extern int DRM(irq_uninstall)( drm_device_t *dev ); -extern void DRM(dma_service)( DRM_OS_IRQ_ARGS ); +extern void DRM(dma_service)( DRM_IRQ_ARGS ); #if __HAVE_DMA_IRQ_BH -extern void DRM(dma_immediate_bh)( DRM_OS_TASKQUEUE_ARGS ); +extern void DRM(dma_immediate_bh)( DRM_TASKQUEUE_ARGS ); #endif #endif #if DRM_DMA_HISTOGRAM diff --git a/bsd/drm_agpsupport.h b/bsd/drm_agpsupport.h index 4958fd5f..66de1053 100644 --- a/bsd/drm_agpsupport.h +++ b/bsd/drm_agpsupport.h @@ -31,9 +31,9 @@ #include "drmP.h" -int DRM(agp_info)(DRM_OS_IOCTL) +int DRM(agp_info)(DRM_IOCTL_ARGS) { - DRM_OS_DEVICE; + DRM_DEVICE; struct agp_info *kern; drm_agp_info_t info; @@ -55,9 +55,9 @@ int DRM(agp_info)(DRM_OS_IOCTL) return 0; } -int DRM(agp_acquire)(DRM_OS_IOCTL) +int DRM(agp_acquire)(DRM_IOCTL_ARGS) { - DRM_OS_DEVICE; + DRM_DEVICE; int retcode; if (!dev->agp || dev->agp->acquired) return EINVAL; @@ -67,9 +67,9 @@ int DRM(agp_acquire)(DRM_OS_IOCTL) return 0; } -int DRM(agp_release)(DRM_OS_IOCTL) +int DRM(agp_release)(DRM_IOCTL_ARGS) { - DRM_OS_DEVICE; + DRM_DEVICE; if (!dev->agp || !dev->agp->acquired) return EINVAL; @@ -83,14 +83,14 @@ void DRM(agp_do_release)(void) { device_t agpdev; - agpdev = DRM_OS_AGP_FIND_DEVICE(); + agpdev = DRM_AGP_FIND_DEVICE(); if (agpdev) agp_release(agpdev); } -int DRM(agp_enable)(DRM_OS_IOCTL) +int DRM(agp_enable)(DRM_IOCTL_ARGS) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_agp_mode_t mode; if (!dev->agp || !dev->agp->acquired) return EINVAL; @@ -104,9 +104,9 @@ int DRM(agp_enable)(DRM_OS_IOCTL) return 0; } -int DRM(agp_alloc)(DRM_OS_IOCTL) +int DRM(agp_alloc)(DRM_IOCTL_ARGS) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_agp_buffer_t request; drm_agp_mem_t *entry; void *handle; @@ -159,9 +159,9 @@ static drm_agp_mem_t * DRM(agp_lookup_entry)(drm_device_t *dev, void *handle) return NULL; } -int DRM(agp_unbind)(DRM_OS_IOCTL) +int DRM(agp_unbind)(DRM_IOCTL_ARGS) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_agp_binding_t request; drm_agp_mem_t *entry; int retcode; @@ -181,9 +181,9 @@ int DRM(agp_unbind)(DRM_OS_IOCTL) return retcode; } -int DRM(agp_bind)(DRM_OS_IOCTL) +int DRM(agp_bind)(DRM_IOCTL_ARGS) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_agp_binding_t request; drm_agp_mem_t *entry; int retcode; @@ -203,9 +203,9 @@ int DRM(agp_bind)(DRM_OS_IOCTL) return 0; } -int DRM(agp_free)(DRM_OS_IOCTL) +int DRM(agp_free)(DRM_IOCTL_ARGS) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_agp_buffer_t request; drm_agp_mem_t *entry; @@ -229,7 +229,7 @@ drm_agp_head_t *DRM(agp_init)(void) drm_agp_head_t *head = NULL; int agp_available = 1; - agpdev = DRM_OS_AGP_FIND_DEVICE(); + agpdev = DRM_AGP_FIND_DEVICE(); if (!agpdev) agp_available = 0; @@ -278,7 +278,7 @@ agp_memory *DRM(agp_allocate_memory)(size_t pages, u32 type) { device_t agpdev; - agpdev = DRM_OS_AGP_FIND_DEVICE(); + agpdev = DRM_AGP_FIND_DEVICE(); if (!agpdev) return NULL; @@ -289,7 +289,7 @@ int DRM(agp_free_memory)(agp_memory *handle) { device_t agpdev; - agpdev = DRM_OS_AGP_FIND_DEVICE(); + agpdev = DRM_AGP_FIND_DEVICE(); if (!agpdev || !handle) return 0; @@ -301,7 +301,7 @@ int DRM(agp_bind_memory)(agp_memory *handle, off_t start) { device_t agpdev; - agpdev = DRM_OS_AGP_FIND_DEVICE(); + agpdev = DRM_AGP_FIND_DEVICE(); if (!agpdev || !handle) return EINVAL; @@ -312,7 +312,7 @@ int DRM(agp_unbind_memory)(agp_memory *handle) { device_t agpdev; - agpdev = DRM_OS_AGP_FIND_DEVICE(); + agpdev = DRM_AGP_FIND_DEVICE(); if (!agpdev || !handle) return EINVAL; diff --git a/bsd/drm_auth.h b/bsd/drm_auth.h index c08f8cb3..0b411d14 100644 --- a/bsd/drm_auth.h +++ b/bsd/drm_auth.h @@ -42,14 +42,14 @@ static drm_file_t *DRM(find_file)(drm_device_t *dev, drm_magic_t magic) drm_magic_entry_t *pt; int hash = DRM(hash_magic)(magic); - DRM_OS_LOCK; + DRM_LOCK; for (pt = dev->magiclist[hash].head; pt; pt = pt->next) { if (pt->magic == magic) { retval = pt->priv; break; } } - DRM_OS_UNLOCK; + DRM_UNLOCK; return retval; } @@ -62,13 +62,13 @@ int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic) hash = DRM(hash_magic)(magic); entry = (drm_magic_entry_t*) DRM(alloc)(sizeof(*entry), DRM_MEM_MAGIC); - if (!entry) DRM_OS_RETURN(ENOMEM); + if (!entry) return DRM_ERR(ENOMEM); memset(entry, 0, sizeof(*entry)); entry->magic = magic; entry->priv = priv; entry->next = NULL; - DRM_OS_LOCK; + DRM_LOCK; if (dev->magiclist[hash].tail) { dev->magiclist[hash].tail->next = entry; dev->magiclist[hash].tail = entry; @@ -76,7 +76,7 @@ int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, drm_magic_t magic) dev->magiclist[hash].head = entry; dev->magiclist[hash].tail = entry; } - DRM_OS_UNLOCK; + DRM_UNLOCK; return 0; } @@ -90,7 +90,7 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic) DRM_DEBUG("%d\n", magic); hash = DRM(hash_magic)(magic); - DRM_OS_LOCK; + DRM_LOCK; for (pt = dev->magiclist[hash].head; pt; prev = pt, pt = pt->next) { if (pt->magic == magic) { if (dev->magiclist[hash].head == pt) { @@ -102,27 +102,27 @@ int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic) if (prev) { prev->next = pt->next; } - DRM_OS_UNLOCK; + DRM_UNLOCK; return 0; } } - DRM_OS_UNLOCK; + DRM_UNLOCK; DRM(free)(pt, sizeof(*pt), DRM_MEM_MAGIC); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } -int DRM(getmagic)(DRM_OS_IOCTL) +int DRM(getmagic)(DRM_IOCTL_ARGS) { static drm_magic_t sequence = 0; drm_auth_t auth; - static DRM_OS_SPINTYPE lock; + static DRM_SPINTYPE lock; static int first = 1; - DRM_OS_DEVICE; - DRM_OS_PRIV; + DRM_DEVICE; + DRM_PRIV; if (first) { - DRM_OS_SPININIT(lock, "drm getmagic"); + DRM_SPININIT(lock, "drm getmagic"); first = 0; } @@ -131,10 +131,10 @@ int DRM(getmagic)(DRM_OS_IOCTL) auth.magic = priv->magic; } else { do { - DRM_OS_SPINLOCK(&lock); + DRM_SPINLOCK(&lock); if (!sequence) ++sequence; /* reserve 0 */ auth.magic = sequence++; - DRM_OS_SPINUNLOCK(&lock); + DRM_SPINUNLOCK(&lock); } while (DRM(find_file)(dev, auth.magic)); priv->magic = auth.magic; DRM(add_magic)(dev, priv, auth.magic); @@ -142,18 +142,18 @@ int DRM(getmagic)(DRM_OS_IOCTL) DRM_DEBUG("%u\n", auth.magic); - DRM_OS_KRNTOUSR((drm_auth_t *)data, auth, sizeof(auth)); + DRM_COPY_TO_USER_IOCTL((drm_auth_t *)data, auth, sizeof(auth)); return 0; } -int DRM(authmagic)(DRM_OS_IOCTL) +int DRM(authmagic)(DRM_IOCTL_ARGS) { drm_auth_t auth; drm_file_t *file; - DRM_OS_DEVICE; + DRM_DEVICE; - DRM_OS_KRNFROMUSR(auth, (drm_auth_t *)data, sizeof(auth)); + DRM_COPY_FROM_USER_IOCTL(auth, (drm_auth_t *)data, sizeof(auth)); DRM_DEBUG("%u\n", auth.magic); if ((file = DRM(find_file)(dev, auth.magic))) { @@ -161,5 +161,5 @@ int DRM(authmagic)(DRM_OS_IOCTL) DRM(remove_magic)(dev, auth.magic); return 0; } - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } diff --git a/bsd/drm_bufs.h b/bsd/drm_bufs.h index 5f813bd8..46dc1c9a 100644 --- a/bsd/drm_bufs.h +++ b/bsd/drm_bufs.h @@ -66,18 +66,18 @@ int DRM(order)( unsigned long size ) return order; } -int DRM(addmap)( DRM_OS_IOCTL ) +int DRM(addmap)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_map_t *map; drm_map_list_entry_t *list; if (!(dev->flags & (FREAD|FWRITE))) - DRM_OS_RETURN(EACCES); /* Require read/write */ + return DRM_ERR(EACCES); /* Require read/write */ map = (drm_map_t *) DRM(alloc)( sizeof(*map), DRM_MEM_MAPS ); if ( !map ) - DRM_OS_RETURN(ENOMEM); + return DRM_ERR(ENOMEM); *map = *(drm_map_t *)data; @@ -87,13 +87,13 @@ int DRM(addmap)( DRM_OS_IOCTL ) */ if ( (map->flags & _DRM_REMOVABLE) && map->type != _DRM_SHM ) { DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } DRM_DEBUG( "offset = 0x%08lx, size = 0x%08lx, type = %d\n", map->offset, map->size, map->type ); if ( (map->offset & PAGE_MASK) || (map->size & PAGE_MASK) ) { DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } map->mtrr = -1; map->handle = 0; @@ -105,7 +105,7 @@ int DRM(addmap)( DRM_OS_IOCTL ) if ( map->offset + map->size < map->offset ) { DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } #endif #ifdef __alpha__ @@ -148,7 +148,7 @@ int DRM(addmap)( DRM_OS_IOCTL ) map->size, DRM(order)( map->size ), map->handle ); if ( !map->handle ) { DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); - DRM_OS_RETURN(ENOMEM); + return DRM_ERR(ENOMEM); } map->offset = (unsigned long)map->handle; if ( map->flags & _DRM_CONTAINS_LOCK ) { @@ -167,27 +167,27 @@ int DRM(addmap)( DRM_OS_IOCTL ) case _DRM_SCATTER_GATHER: if (!dev->sg) { DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } map->offset = map->offset + dev->sg->handle; break; default: DRM(free)( map, sizeof(*map), DRM_MEM_MAPS ); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } list = DRM(alloc)(sizeof(*list), DRM_MEM_MAPS); if(!list) { DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } memset(list, 0, sizeof(*list)); list->map = map; - DRM_OS_LOCK; + DRM_LOCK; TAILQ_INSERT_TAIL(dev->maplist, list, link); - DRM_OS_UNLOCK; + DRM_UNLOCK; *(drm_map_t *)data = *map; @@ -202,17 +202,17 @@ int DRM(addmap)( DRM_OS_IOCTL ) * isn't in use. */ -int DRM(rmmap)( DRM_OS_IOCTL ) +int DRM(rmmap)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_map_list_entry_t *list; drm_map_t *map; drm_map_t request; int found_maps = 0; - DRM_OS_KRNFROMUSR( request, (drm_map_t *)data, sizeof(request) ); + DRM_COPY_FROM_USER_IOCTL( request, (drm_map_t *)data, sizeof(request) ); - DRM_OS_LOCK; + DRM_LOCK; TAILQ_FOREACH(list, dev->maplist, link) { map = list->map; if(map->handle == request.handle && @@ -223,8 +223,8 @@ int DRM(rmmap)( DRM_OS_IOCTL ) * find anything. */ if(list == NULL) { - DRM_OS_UNLOCK; - DRM_OS_RETURN(EINVAL); + DRM_UNLOCK; + return DRM_ERR(EINVAL); } TAILQ_REMOVE(dev->maplist, list, link); DRM(free)(list, sizeof(*list), DRM_MEM_MAPS); @@ -270,7 +270,7 @@ int DRM(rmmap)( DRM_OS_IOCTL ) } DRM(free)(map, sizeof(*map), DRM_MEM_MAPS); } - DRM_OS_UNLOCK; + DRM_UNLOCK; return 0; } @@ -317,9 +317,9 @@ static void DRM(cleanup_buf_error)(drm_buf_entry_t *entry) } #if __REALLY_HAVE_AGP -int DRM(addbufs_agp)( DRM_OS_IOCTL ) +int DRM(addbufs_agp)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_device_dma_t *dma = dev->dma; drm_buf_desc_t request; drm_buf_entry_t *entry; @@ -336,9 +336,9 @@ int DRM(addbufs_agp)( DRM_OS_IOCTL ) int i; drm_buf_t **temp_buflist; - if ( !dma ) DRM_OS_RETURN(EINVAL); + if ( !dma ) return DRM_ERR(EINVAL); - DRM_OS_KRNFROMUSR( request, (drm_buf_desc_t *)data, sizeof(request) ); + DRM_COPY_FROM_USER_IOCTL( request, (drm_buf_desc_t *)data, sizeof(request) ); count = request.count; order = DRM(order)( request.size ); @@ -361,38 +361,38 @@ int DRM(addbufs_agp)( DRM_OS_IOCTL ) DRM_DEBUG( "total: %d\n", total ); if ( order < DRM_MIN_ORDER || order > DRM_MAX_ORDER ) - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); if ( dev->queue_count ) - DRM_OS_RETURN(EBUSY); /* Not while in use */ + return DRM_ERR(EBUSY); /* Not while in use */ - DRM_OS_SPINLOCK( &dev->count_lock ); + DRM_SPINLOCK( &dev->count_lock ); if ( dev->buf_use ) { - DRM_OS_SPINUNLOCK( &dev->count_lock ); - DRM_OS_RETURN(EBUSY); + DRM_SPINUNLOCK( &dev->count_lock ); + return DRM_ERR(EBUSY); } atomic_inc( &dev->buf_alloc ); - DRM_OS_SPINUNLOCK( &dev->count_lock ); + DRM_SPINUNLOCK( &dev->count_lock ); - DRM_OS_LOCK; + DRM_LOCK; entry = &dma->bufs[order]; if ( entry->buf_count ) { - DRM_OS_UNLOCK; + DRM_UNLOCK; atomic_dec( &dev->buf_alloc ); - DRM_OS_RETURN(ENOMEM); /* May only call once for each order */ + return DRM_ERR(ENOMEM); /* May only call once for each order */ } if (count < 0 || count > 4096) { - DRM_OS_UNLOCK; + DRM_UNLOCK; atomic_dec( &dev->buf_alloc ); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } entry->buflist = DRM(alloc)( count * sizeof(*entry->buflist), DRM_MEM_BUFS ); if ( !entry->buflist ) { - DRM_OS_UNLOCK; + DRM_UNLOCK; atomic_dec( &dev->buf_alloc ); - DRM_OS_RETURN(ENOMEM); + return DRM_ERR(ENOMEM); } memset( entry->buflist, 0, count * sizeof(*entry->buflist) ); @@ -449,9 +449,9 @@ int DRM(addbufs_agp)( DRM_OS_IOCTL ) if(!temp_buflist) { /* Free the entry because it isn't valid */ DRM(cleanup_buf_error)(entry); - DRM_OS_UNLOCK; + DRM_UNLOCK; atomic_dec( &dev->buf_alloc ); - DRM_OS_RETURN(ENOMEM); + return DRM_ERR(ENOMEM); } dma->buflist = temp_buflist; @@ -471,12 +471,12 @@ int DRM(addbufs_agp)( DRM_OS_IOCTL ) DRM(freelist_put)( dev, &entry->freelist, &entry->buflist[i] ); } #endif - DRM_OS_UNLOCK; + DRM_UNLOCK; request.count = entry->buf_count; request.size = size; - DRM_OS_KRNTOUSR( (drm_buf_desc_t *)data, request, sizeof(request) ); + DRM_COPY_TO_USER_IOCTL( (drm_buf_desc_t *)data, request, sizeof(request) ); dma->flags = _DRM_DMA_USE_AGP; @@ -486,9 +486,9 @@ int DRM(addbufs_agp)( DRM_OS_IOCTL ) #endif /* __REALLY_HAVE_AGP */ #if __HAVE_PCI_DMA -int DRM(addbufs_pci)( DRM_OS_IOCTL ) +int DRM(addbufs_pci)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_device_dma_t *dma = dev->dma; drm_buf_desc_t request; int count; @@ -507,9 +507,9 @@ int DRM(addbufs_pci)( DRM_OS_IOCTL ) unsigned long *temp_pagelist; drm_buf_t **temp_buflist; - if ( !dma ) DRM_OS_RETURN(EINVAL); + if ( !dma ) return DRM_ERR(EINVAL); - DRM_OS_KRNFROMUSR( request, (drm_buf_desc_t *)data, sizeof(request) ); + DRM_COPY_FROM_USER_IOCTL( request, (drm_buf_desc_t *)data, sizeof(request) ); count = request.count; order = DRM(order)( request.size ); @@ -520,43 +520,43 @@ int DRM(addbufs_pci)( DRM_OS_IOCTL ) order, dev->queue_count ); if ( order < DRM_MIN_ORDER || order > DRM_MAX_ORDER ) - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); if ( dev->queue_count ) - DRM_OS_RETURN(EBUSY); /* Not while in use */ + return DRM_ERR(EBUSY); /* Not while in use */ alignment = (request.flags & _DRM_PAGE_ALIGN) ? round_page(size) : size; page_order = order - PAGE_SHIFT > 0 ? order - PAGE_SHIFT : 0; total = PAGE_SIZE << page_order; - DRM_OS_SPINLOCK( &dev->count_lock ); + DRM_SPINLOCK( &dev->count_lock ); if ( dev->buf_use ) { - DRM_OS_SPINUNLOCK( &dev->count_lock ); - DRM_OS_RETURN(EBUSY); + DRM_SPINUNLOCK( &dev->count_lock ); + return DRM_ERR(EBUSY); } atomic_inc( &dev->buf_alloc ); - DRM_OS_SPINUNLOCK( &dev->count_lock ); + DRM_SPINUNLOCK( &dev->count_lock ); - DRM_OS_LOCK; + DRM_LOCK; entry = &dma->bufs[order]; if ( entry->buf_count ) { - DRM_OS_UNLOCK; + DRM_UNLOCK; atomic_dec( &dev->buf_alloc ); - DRM_OS_RETURN(ENOMEM); /* May only call once for each order */ + return DRM_ERR(ENOMEM); /* May only call once for each order */ } if (count < 0 || count > 4096) { - DRM_OS_UNLOCK; + DRM_UNLOCK; atomic_dec( &dev->buf_alloc ); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } entry->buflist = DRM(alloc)( count * sizeof(*entry->buflist), DRM_MEM_BUFS ); if ( !entry->buflist ) { - DRM_OS_UNLOCK; + DRM_UNLOCK; atomic_dec( &dev->buf_alloc ); - DRM_OS_RETURN(ENOMEM); + return DRM_ERR(ENOMEM); } memset( entry->buflist, 0, count * sizeof(*entry->buflist) ); @@ -566,9 +566,9 @@ int DRM(addbufs_pci)( DRM_OS_IOCTL ) DRM(free)( entry->buflist, count * sizeof(*entry->buflist), DRM_MEM_BUFS ); - DRM_OS_UNLOCK; + DRM_UNLOCK; atomic_dec( &dev->buf_alloc ); - DRM_OS_RETURN(ENOMEM); + return DRM_ERR(ENOMEM); } memset( entry->seglist, 0, count * sizeof(*entry->seglist) ); @@ -584,9 +584,9 @@ int DRM(addbufs_pci)( DRM_OS_IOCTL ) DRM(free)( entry->seglist, count * sizeof(*entry->seglist), DRM_MEM_SEGS ); - DRM_OS_UNLOCK; + DRM_UNLOCK; atomic_dec( &dev->buf_alloc ); - DRM_OS_RETURN(ENOMEM); + return DRM_ERR(ENOMEM); } dma->pagelist = temp_pagelist; @@ -644,9 +644,9 @@ int DRM(addbufs_pci)( DRM_OS_IOCTL ) if(!temp_buflist) { /* Free the entry because it isn't valid */ DRM(cleanup_buf_error)(entry); - DRM_OS_UNLOCK; + DRM_UNLOCK; atomic_dec( &dev->buf_alloc ); - DRM_OS_RETURN(ENOMEM); + return DRM_ERR(ENOMEM); } dma->buflist = temp_buflist; @@ -665,12 +665,12 @@ int DRM(addbufs_pci)( DRM_OS_IOCTL ) DRM(freelist_put)( dev, &entry->freelist, &entry->buflist[i] ); } #endif - DRM_OS_UNLOCK; + DRM_UNLOCK; request.count = entry->buf_count; request.size = size; - DRM_OS_KRNTOUSR( (drm_buf_desc_t *)data, request, sizeof(request) ); + DRM_COPY_TO_USER_IOCTL( (drm_buf_desc_t *)data, request, sizeof(request) ); atomic_dec( &dev->buf_alloc ); return 0; @@ -679,9 +679,9 @@ int DRM(addbufs_pci)( DRM_OS_IOCTL ) #endif /* __HAVE_PCI_DMA */ #if __REALLY_HAVE_SG -int DRM(addbufs_sg)( DRM_OS_IOCTL ) +int DRM(addbufs_sg)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_device_dma_t *dma = dev->dma; drm_buf_desc_t request; drm_buf_entry_t *entry; @@ -698,9 +698,9 @@ int DRM(addbufs_sg)( DRM_OS_IOCTL ) int i; drm_buf_t **temp_buflist; - if ( !dma ) DRM_OS_RETURN(EINVAL); + if ( !dma ) return DRM_ERR(EINVAL); - DRM_OS_KRNFROMUSR( request, (drm_buf_desc_t *)data, sizeof(request) ); + DRM_COPY_FROM_USER_IOCTL( request, (drm_buf_desc_t *)data, sizeof(request) ); count = request.count; order = DRM(order)( request.size ); @@ -723,37 +723,37 @@ int DRM(addbufs_sg)( DRM_OS_IOCTL ) DRM_DEBUG( "total: %d\n", total ); if ( order < DRM_MIN_ORDER || order > DRM_MAX_ORDER ) - DRM_OS_RETURN(EINVAL); - if ( dev->queue_count ) DRM_OS_RETURN(EBUSY); /* Not while in use */ + return DRM_ERR(EINVAL); + if ( dev->queue_count ) return DRM_ERR(EBUSY); /* Not while in use */ - DRM_OS_SPINLOCK( &dev->count_lock ); + DRM_SPINLOCK( &dev->count_lock ); if ( dev->buf_use ) { - DRM_OS_SPINUNLOCK( &dev->count_lock ); - DRM_OS_RETURN(EBUSY); + DRM_SPINUNLOCK( &dev->count_lock ); + return DRM_ERR(EBUSY); } atomic_inc( &dev->buf_alloc ); - DRM_OS_SPINUNLOCK( &dev->count_lock ); + DRM_SPINUNLOCK( &dev->count_lock ); - DRM_OS_LOCK; + DRM_LOCK; entry = &dma->bufs[order]; if ( entry->buf_count ) { - DRM_OS_UNLOCK; + DRM_UNLOCK; atomic_dec( &dev->buf_alloc ); - DRM_OS_RETURN(ENOMEM); /* May only call once for each order */ + return DRM_ERR(ENOMEM); /* May only call once for each order */ } if (count < 0 || count > 4096) { - DRM_OS_UNLOCK; + DRM_UNLOCK; atomic_dec( &dev->buf_alloc ); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } entry->buflist = DRM(alloc)( count * sizeof(*entry->buflist), DRM_MEM_BUFS ); if ( !entry->buflist ) { - DRM_OS_UNLOCK; + DRM_UNLOCK; atomic_dec( &dev->buf_alloc ); - DRM_OS_RETURN(ENOMEM); + return DRM_ERR(ENOMEM); } memset( entry->buflist, 0, count * sizeof(*entry->buflist) ); @@ -785,9 +785,9 @@ int DRM(addbufs_sg)( DRM_OS_IOCTL ) /* Set count correctly so we free the proper amount. */ entry->buf_count = count; DRM(cleanup_buf_error)(entry); - DRM_OS_UNLOCK; + DRM_UNLOCK; atomic_dec( &dev->buf_alloc ); - DRM_OS_RETURN(ENOMEM); + return DRM_ERR(ENOMEM); } memset( buf->dev_private, 0, buf->dev_priv_size ); @@ -816,9 +816,9 @@ int DRM(addbufs_sg)( DRM_OS_IOCTL ) if(!temp_buflist) { /* Free the entry because it isn't valid */ DRM(cleanup_buf_error)(entry); - DRM_OS_UNLOCK; + DRM_UNLOCK; atomic_dec( &dev->buf_alloc ); - DRM_OS_RETURN(ENOMEM); + return DRM_ERR(ENOMEM); } dma->buflist = temp_buflist; @@ -838,12 +838,12 @@ int DRM(addbufs_sg)( DRM_OS_IOCTL ) DRM(freelist_put)( dev, &entry->freelist, &entry->buflist[i] ); } #endif - DRM_OS_UNLOCK; + DRM_UNLOCK; request.count = entry->buf_count; request.size = size; - DRM_OS_KRNTOUSR( (drm_buf_desc_t *)data, request, sizeof(request) ); + DRM_COPY_TO_USER_IOCTL( (drm_buf_desc_t *)data, request, sizeof(request) ); dma->flags = _DRM_DMA_USE_SG; @@ -852,11 +852,11 @@ int DRM(addbufs_sg)( DRM_OS_IOCTL ) } #endif /* __REALLY_HAVE_SG */ -int DRM(addbufs)( DRM_OS_IOCTL ) +int DRM(addbufs)( DRM_IOCTL_ARGS ) { drm_buf_desc_t request; - DRM_OS_KRNFROMUSR( request, (drm_buf_desc_t *)data, sizeof(request) ); + DRM_COPY_FROM_USER_IOCTL( request, (drm_buf_desc_t *)data, sizeof(request) ); #if __REALLY_HAVE_AGP if ( request.flags & _DRM_AGP_BUFFER ) @@ -871,29 +871,29 @@ int DRM(addbufs)( DRM_OS_IOCTL ) #if __HAVE_PCI_DMA return DRM(addbufs_pci)( kdev, cmd, data, flags, p ); #else - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); #endif } -int DRM(infobufs)( DRM_OS_IOCTL ) +int DRM(infobufs)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_device_dma_t *dma = dev->dma; drm_buf_info_t request; int i; int count; - if ( !dma ) DRM_OS_RETURN(EINVAL); + if ( !dma ) return DRM_ERR(EINVAL); - DRM_OS_SPINLOCK( &dev->count_lock ); + DRM_SPINLOCK( &dev->count_lock ); if ( atomic_read( &dev->buf_alloc ) ) { - DRM_OS_SPINUNLOCK( &dev->count_lock ); - DRM_OS_RETURN(EBUSY); + DRM_SPINUNLOCK( &dev->count_lock ); + return DRM_ERR(EBUSY); } ++dev->buf_use; /* Can't allocate more after this call */ - DRM_OS_SPINUNLOCK( &dev->count_lock ); + DRM_SPINUNLOCK( &dev->count_lock ); - DRM_OS_KRNFROMUSR( request, (drm_buf_info_t *)data, sizeof(request) ); + DRM_COPY_FROM_USER_IOCTL( request, (drm_buf_info_t *)data, sizeof(request) ); for ( i = 0, count = 0 ; i < DRM_MAX_ORDER + 1 ; i++ ) { if ( dma->bufs[i].buf_count ) ++count; @@ -907,19 +907,19 @@ int DRM(infobufs)( DRM_OS_IOCTL ) drm_buf_desc_t *to = &request.list[count]; drm_buf_entry_t *from = &dma->bufs[i]; drm_freelist_t *list = &dma->bufs[i].freelist; - if ( DRM_OS_COPYTOUSR( &to->count, + if ( DRM_COPY_TO_USER( &to->count, &from->buf_count, sizeof(from->buf_count) ) || - DRM_OS_COPYTOUSR( &to->size, + DRM_COPY_TO_USER( &to->size, &from->buf_size, sizeof(from->buf_size) ) || - DRM_OS_COPYTOUSR( &to->low_mark, + DRM_COPY_TO_USER( &to->low_mark, &list->low_mark, sizeof(list->low_mark) ) || - DRM_OS_COPYTOUSR( &to->high_mark, + DRM_COPY_TO_USER( &to->high_mark, &list->high_mark, sizeof(list->high_mark) ) ) - DRM_OS_RETURN(EFAULT); + return DRM_ERR(EFAULT); DRM_DEBUG( "%d %d %d %d %d\n", i, @@ -933,34 +933,34 @@ int DRM(infobufs)( DRM_OS_IOCTL ) } request.count = count; - DRM_OS_KRNTOUSR( (drm_buf_info_t *)data, request, sizeof(request) ); + DRM_COPY_TO_USER_IOCTL( (drm_buf_info_t *)data, request, sizeof(request) ); return 0; } -int DRM(markbufs)( DRM_OS_IOCTL ) +int DRM(markbufs)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_device_dma_t *dma = dev->dma; drm_buf_desc_t request; int order; drm_buf_entry_t *entry; - if ( !dma ) DRM_OS_RETURN(EINVAL); + if ( !dma ) return DRM_ERR(EINVAL); - DRM_OS_KRNFROMUSR( request, (drm_buf_desc_t *)data, sizeof(request) ); + DRM_COPY_FROM_USER_IOCTL( request, (drm_buf_desc_t *)data, sizeof(request) ); DRM_DEBUG( "%d, %d, %d\n", request.size, request.low_mark, request.high_mark ); order = DRM(order)( request.size ); if ( order < DRM_MIN_ORDER || order > DRM_MAX_ORDER ) - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); entry = &dma->bufs[order]; if ( request.low_mark < 0 || request.low_mark > entry->buf_count ) - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); if ( request.high_mark < 0 || request.high_mark > entry->buf_count ) - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); entry->freelist.low_mark = request.low_mark; entry->freelist.high_mark = request.high_mark; @@ -968,35 +968,35 @@ int DRM(markbufs)( DRM_OS_IOCTL ) return 0; } -int DRM(freebufs)( DRM_OS_IOCTL ) +int DRM(freebufs)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_device_dma_t *dma = dev->dma; drm_buf_free_t request; int i; int idx; drm_buf_t *buf; - if ( !dma ) DRM_OS_RETURN(EINVAL); + if ( !dma ) return DRM_ERR(EINVAL); - DRM_OS_KRNFROMUSR( request, (drm_buf_free_t *)data, sizeof(request) ); + DRM_COPY_FROM_USER_IOCTL( request, (drm_buf_free_t *)data, sizeof(request) ); DRM_DEBUG( "%d\n", request.count ); for ( i = 0 ; i < request.count ; i++ ) { - if ( DRM_OS_COPYFROMUSR( &idx, + if ( DRM_COPY_FROM_USER( &idx, &request.list[i], sizeof(idx) ) ) - DRM_OS_RETURN(EFAULT); + return DRM_ERR(EFAULT); if ( idx < 0 || idx >= dma->buf_count ) { DRM_ERROR( "Index %d (of %d max)\n", idx, dma->buf_count - 1 ); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } buf = dma->buflist[idx]; - if ( buf->pid != DRM_OS_CURRENTPID ) { + if ( buf->pid != DRM_CURRENTPID ) { DRM_ERROR( "Process %d freeing buffer owned by %d\n", - DRM_OS_CURRENTPID, buf->pid ); - DRM_OS_RETURN(EINVAL); + DRM_CURRENTPID, buf->pid ); + return DRM_ERR(EINVAL); } DRM(free_buffer)( dev, buf ); } @@ -1004,9 +1004,9 @@ int DRM(freebufs)( DRM_OS_IOCTL ) return 0; } -int DRM(mapbufs)( DRM_OS_IOCTL ) +int DRM(mapbufs)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_device_dma_t *dma = dev->dma; int retcode = 0; const int zero = 0; @@ -1025,17 +1025,17 @@ int DRM(mapbufs)( DRM_OS_IOCTL ) drm_buf_map_t request; int i; - if ( !dma ) DRM_OS_RETURN(EINVAL); + if ( !dma ) return DRM_ERR(EINVAL); - DRM_OS_SPINLOCK( &dev->count_lock ); + DRM_SPINLOCK( &dev->count_lock ); if ( atomic_read( &dev->buf_alloc ) ) { - DRM_OS_SPINUNLOCK( &dev->count_lock ); - DRM_OS_RETURN(EBUSY); + DRM_SPINUNLOCK( &dev->count_lock ); + return DRM_ERR(EBUSY); } dev->buf_use++; /* Can't allocate more after this call */ - DRM_OS_SPINUNLOCK( &dev->count_lock ); + DRM_SPINUNLOCK( &dev->count_lock ); - DRM_OS_KRNFROMUSR( request, (drm_buf_map_t *)data, sizeof(request) ); + DRM_COPY_FROM_USER_IOCTL( request, (drm_buf_map_t *)data, sizeof(request) ); #ifdef __NetBSD__ if(!vfinddev(kdev, VCHR, &vn)) @@ -1097,26 +1097,26 @@ int DRM(mapbufs)( DRM_OS_IOCTL ) request.virtual = (void *)virtual; for ( i = 0 ; i < dma->buf_count ; i++ ) { - if ( DRM_OS_COPYTOUSR( &request.list[i].idx, + if ( DRM_COPY_TO_USER( &request.list[i].idx, &dma->buflist[i]->idx, sizeof(request.list[0].idx) ) ) { retcode = EFAULT; goto done; } - if ( DRM_OS_COPYTOUSR( &request.list[i].total, + if ( DRM_COPY_TO_USER( &request.list[i].total, &dma->buflist[i]->total, sizeof(request.list[0].total) ) ) { retcode = EFAULT; goto done; } - if ( DRM_OS_COPYTOUSR( &request.list[i].used, + if ( DRM_COPY_TO_USER( &request.list[i].used, &zero, sizeof(zero) ) ) { retcode = EFAULT; goto done; } address = virtual + dma->buflist[i]->offset; /* *** */ - if ( DRM_OS_COPYTOUSR( &request.list[i].address, + if ( DRM_COPY_TO_USER( &request.list[i].address, &address, sizeof(address) ) ) { retcode = EFAULT; @@ -1129,9 +1129,9 @@ int DRM(mapbufs)( DRM_OS_IOCTL ) DRM_DEBUG( "%d buffers, retcode = %d\n", request.count, retcode ); - DRM_OS_KRNTOUSR( (drm_buf_map_t *)data, request, sizeof(request) ); + DRM_COPY_TO_USER_IOCTL( (drm_buf_map_t *)data, request, sizeof(request) ); - DRM_OS_RETURN(retcode); + return DRM_ERR(retcode); } #endif /* __HAVE_DMA */ 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 diff --git a/bsd/drm_dma.h b/bsd/drm_dma.h index 0087f4f1..3e4a5e17 100644 --- a/bsd/drm_dma.h +++ b/bsd/drm_dma.h @@ -55,7 +55,7 @@ int DRM(dma_setup)( drm_device_t *dev ) dev->dma = DRM(alloc)( sizeof(*dev->dma), DRM_MEM_DRIVER ); if ( !dev->dma ) - DRM_OS_RETURN(ENOMEM); + return DRM_ERR(ENOMEM); memset( dev->dma, 0, sizeof(*dev->dma) ); @@ -244,7 +244,7 @@ void DRM(clear_next_buffer)(drm_device_t *dev) dma->next_buffer = NULL; if (dma->next_queue && !DRM_BUFCOUNT(&dma->next_queue->waitlist)) { - DRM_OS_WAKEUP_INT(&dma->next_queue->flush_queue); + DRM_WAKEUP_INT(&dma->next_queue->flush_queue); } dma->next_queue = NULL; } @@ -336,7 +336,7 @@ int DRM(dma_enqueue)(drm_device_t *dev, drm_dma_t *d) if (!_DRM_LOCK_IS_HELD(context)) { DRM_ERROR("No lock held during \"while locked\"" " request\n"); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } if (d->context != _DRM_LOCKING_CONTEXT(context) && _DRM_LOCKING_CONTEXT(context) != DRM_KERNEL_CONTEXT) { @@ -344,7 +344,7 @@ int DRM(dma_enqueue)(drm_device_t *dev, drm_dma_t *d) " \"while locked\" request\n", _DRM_LOCKING_CONTEXT(context), d->context); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } q = dev->queuelist[DRM_KERNEL_CONTEXT]; while_locked = 1; @@ -374,19 +374,19 @@ int DRM(dma_enqueue)(drm_device_t *dev, drm_dma_t *d) atomic_dec(&q->use_count); DRM_ERROR("Index %d (of %d max)\n", d->send_indices[i], dma->buf_count - 1); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } buf = dma->buflist[ idx ]; - if (buf->pid != DRM_OS_CURRENTPID) { + if (buf->pid != DRM_CURRENTPID) { atomic_dec(&q->use_count); DRM_ERROR("Process %d using buffer owned by %d\n", - DRM_OS_CURRENTPID, buf->pid); - DRM_OS_RETURN(EINVAL); + DRM_CURRENTPID, buf->pid); + return DRM_ERR(EINVAL); } if (buf->list != DRM_LIST_NONE) { atomic_dec(&q->use_count); DRM_ERROR("Process %d using buffer %d on list %d\n", - DRM_OS_CURRENTPID, buf->idx, buf->list); + DRM_CURRENTPID, buf->idx, buf->list); } buf->used = d->send_sizes[i]; buf->while_locked = while_locked; @@ -399,14 +399,14 @@ int DRM(dma_enqueue)(drm_device_t *dev, drm_dma_t *d) DRM_ERROR("Queueing pending buffer:" " buffer %d, offset %d\n", d->send_indices[i], i); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } if (buf->waiting) { atomic_dec(&q->use_count); DRM_ERROR("Queueing waiting buffer:" " buffer %d, offset %d\n", d->send_indices[i], i); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } buf->waiting = 1; if (atomic_read(&q->use_count) == 1 @@ -440,16 +440,16 @@ static int DRM(dma_get_buffers_of_order)(drm_device_t *dev, drm_dma_t *d, buf->waiting, buf->pending); } - buf->pid = DRM_OS_CURRENTPID; - if (DRM_OS_COPYTOUSR(&d->request_indices[i], + buf->pid = DRM_CURRENTPID; + if (DRM_COPY_TO_USER(&d->request_indices[i], &buf->idx, sizeof(buf->idx))) - DRM_OS_RETURN(EFAULT); + return DRM_ERR(EFAULT); - if (DRM_OS_COPYTOUSR(&d->request_sizes[i], + if (DRM_COPY_TO_USER(&d->request_sizes[i], &buf->total, sizeof(buf->total))) - DRM_OS_RETURN(EFAULT); + return DRM_ERR(EFAULT); ++d->granted_count; } @@ -507,15 +507,15 @@ int DRM(irq_install)( drm_device_t *dev, int irq ) int retcode; if ( !irq ) - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); - DRM_OS_LOCK; + DRM_LOCK; if ( dev->irq ) { - DRM_OS_UNLOCK; - DRM_OS_RETURN(EBUSY); + DRM_UNLOCK; + return DRM_ERR(EBUSY); } dev->irq = irq; - DRM_OS_UNLOCK; + DRM_UNLOCK; DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, irq ); @@ -544,10 +544,10 @@ int DRM(irq_install)( drm_device_t *dev, int irq ) retcode = bus_setup_intr(dev->device, dev->irqr, INTR_TYPE_TTY, DRM(dma_service), dev, &dev->irqh); if ( retcode ) { - DRM_OS_LOCK; + DRM_LOCK; bus_release_resource(dev->device, SYS_RES_IRQ, 0, dev->irqr); dev->irq = 0; - DRM_OS_UNLOCK; + DRM_UNLOCK; return retcode; } @@ -561,13 +561,13 @@ int DRM(irq_uninstall)( drm_device_t *dev ) { int irq; - DRM_OS_LOCK; + DRM_LOCK; irq = dev->irq; dev->irq = 0; - DRM_OS_UNLOCK; + DRM_UNLOCK; if ( !irq ) - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); DRM_DEBUG( "%s: irq=%d\n", __FUNCTION__, irq ); @@ -579,12 +579,12 @@ int DRM(irq_uninstall)( drm_device_t *dev ) return 0; } -int DRM(control)( DRM_OS_IOCTL ) +int DRM(control)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_control_t ctl; - DRM_OS_KRNFROMUSR( ctl, (drm_control_t *) data, sizeof(ctl) ); + DRM_COPY_FROM_USER_IOCTL( ctl, (drm_control_t *) data, sizeof(ctl) ); switch ( ctl.func ) { case DRM_INST_HANDLER: @@ -592,24 +592,24 @@ int DRM(control)( DRM_OS_IOCTL ) case DRM_UNINST_HANDLER: return DRM(irq_uninstall)( dev ); default: - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } } #else -int DRM(control)( DRM_OS_IOCTL ) +int DRM(control)( DRM_IOCTL_ARGS ) { drm_control_t ctl; - DRM_OS_KRNFROMUSR( ctl, (drm_control_t *) data, sizeof(ctl) ); + DRM_COPY_FROM_USER_IOCTL( ctl, (drm_control_t *) data, sizeof(ctl) ); switch ( ctl.func ) { case DRM_INST_HANDLER: case DRM_UNINST_HANDLER: return 0; default: - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } } diff --git a/bsd/drm_drawable.h b/bsd/drm_drawable.h index f43149d6..30841067 100644 --- a/bsd/drm_drawable.h +++ b/bsd/drm_drawable.h @@ -31,19 +31,19 @@ #include "drmP.h" -int DRM(adddraw)( DRM_OS_IOCTL ) +int DRM(adddraw)( DRM_IOCTL_ARGS ) { drm_draw_t draw; draw.handle = 0; /* NOOP */ DRM_DEBUG("%d\n", draw.handle); - DRM_OS_KRNTOUSR( (drm_draw_t *)data, draw, sizeof(draw) ); + DRM_COPY_TO_USER_IOCTL( (drm_draw_t *)data, draw, sizeof(draw) ); return 0; } -int DRM(rmdraw)( DRM_OS_IOCTL ) +int DRM(rmdraw)( DRM_IOCTL_ARGS ) { return 0; /* NOOP */ } diff --git a/bsd/drm_drv.h b/bsd/drm_drv.h index 06f1578a..8d2e5864 100644 --- a/bsd/drm_drv.h +++ b/bsd/drm_drv.h @@ -426,7 +426,7 @@ static int DRM(setup)( drm_device_t *dev ) dev->maplist = DRM(alloc)(sizeof(*dev->maplist), DRM_MEM_MAPS); - if(dev->maplist == NULL) DRM_OS_RETURN(ENOMEM); + if(dev->maplist == NULL) return DRM_ERR(ENOMEM); memset(dev->maplist, 0, sizeof(*dev->maplist)); TAILQ_INIT(dev->maplist); dev->map_count = 0; @@ -495,7 +495,7 @@ static int DRM(takedown)( drm_device_t *dev ) if ( dev->irq ) DRM(irq_uninstall)( dev ); #endif - DRM_OS_LOCK; + DRM_LOCK; callout_stop( &dev->timer ); if ( dev->devname ) { @@ -580,7 +580,7 @@ static int DRM(takedown)( drm_device_t *dev ) /*mtrrmap.owner = p->p_pid;*/ /* XXX: Use curproc here? */ retcode = mtrr_set( &mtrrmap, &one, - DRM_OS_CURPROC, MTRR_GETSET_KERNEL); + DRM_CURPROC, MTRR_GETSET_KERNEL); #endif DRM_DEBUG( "mtrr_del=%d\n", retcode ); } @@ -643,9 +643,9 @@ static int DRM(takedown)( drm_device_t *dev ) if ( dev->lock.hw_lock ) { dev->lock.hw_lock = NULL; /* SHM removed */ dev->lock.pid = 0; - DRM_OS_WAKEUP_INT((void *)&dev->lock.lock_queue); + DRM_WAKEUP_INT((void *)&dev->lock.lock_queue); } - DRM_OS_UNLOCK; + DRM_UNLOCK; return 0; } @@ -684,7 +684,7 @@ static int DRM(init)( drm_device_t *dev ) #elif defined(__NetBSD__) unit = minor(dev->device.dv_unit); #endif - DRM_OS_SPININIT(dev->count_lock, "drm device"); + DRM_SPININIT(dev->count_lock, "drm device"); lockinit(&dev->dev_lock, PZERO, "drmlk", 0, 0); dev->name = DRIVER_NAME; DRM(mem_init)(); @@ -701,7 +701,7 @@ static int DRM(init)( drm_device_t *dev ) destroy_dev(dev->devnode); #endif DRM(takedown)( dev ); - DRM_OS_RETURN(ENOMEM); + return DRM_ERR(ENOMEM); } #endif /* __MUST_HAVE_AGP */ #if __REALLY_HAVE_MTRR @@ -813,20 +813,20 @@ static void DRM(cleanup)(drm_device_t *dev) } -int DRM(version)( DRM_OS_IOCTL ) +int DRM(version)( DRM_IOCTL_ARGS ) { drm_version_t version; int len; - DRM_OS_KRNFROMUSR( version, (drm_version_t *)data, sizeof(version) ); + DRM_COPY_FROM_USER_IOCTL( version, (drm_version_t *)data, sizeof(version) ); #define DRM_COPY( name, value ) \ len = strlen( value ); \ if ( len > name##_len ) len = name##_len; \ name##_len = strlen( value ); \ if ( len && name ) { \ - if ( DRM_OS_COPYTOUSR( name, value, len ) ) \ - DRM_OS_RETURN(EFAULT); \ + if ( DRM_COPY_TO_USER( name, value, len ) ) \ + return DRM_ERR(EFAULT); \ } version.version_major = DRIVER_MAJOR; @@ -837,12 +837,12 @@ int DRM(version)( DRM_OS_IOCTL ) DRM_COPY( version.date, DRIVER_DATE ); DRM_COPY( version.desc, DRIVER_DESC ); - DRM_OS_KRNTOUSR( (drm_version_t *)data, version, sizeof(version) ); + DRM_COPY_TO_USER_IOCTL( (drm_version_t *)data, version, sizeof(version) ); return 0; } -int DRM(open)(dev_t kdev, int flags, int fmt, DRM_OS_STRUCTPROC *p) +int DRM(open)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p) { drm_device_t *dev = NULL; int retcode = 0; @@ -858,13 +858,13 @@ int DRM(open)(dev_t kdev, int flags, int fmt, DRM_OS_STRUCTPROC *p) if ( !retcode ) { atomic_inc( &dev->counts[_DRM_STAT_OPENS] ); - DRM_OS_SPINLOCK( &dev->count_lock ); + DRM_SPINLOCK( &dev->count_lock ); if ( !dev->open_count++ ) { retcode = DRM(setup)( dev ); - DRM_OS_SPINUNLOCK( &dev->count_lock ); + DRM_SPINUNLOCK( &dev->count_lock ); return retcode; } - DRM_OS_SPINUNLOCK( &dev->count_lock ); + DRM_SPINUNLOCK( &dev->count_lock ); } #ifdef __FreeBSD__ device_unbusy(dev->device); @@ -873,10 +873,10 @@ int DRM(open)(dev_t kdev, int flags, int fmt, DRM_OS_STRUCTPROC *p) return retcode; } -int DRM(close)(dev_t kdev, int flags, int fmt, DRM_OS_STRUCTPROC *p) +int DRM(close)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p) { drm_file_t *priv; - DRM_OS_DEVICE; + DRM_DEVICE; int retcode = 0; DRM_DEBUG( "open_count = %d\n", dev->open_count ); @@ -894,16 +894,16 @@ int DRM(close)(dev_t kdev, int flags, int fmt, DRM_OS_STRUCTPROC *p) #ifdef __FreeBSD__ DRM_DEBUG( "pid = %d, device = 0x%lx, open_count = %d\n", - DRM_OS_CURRENTPID, (long)dev->device, dev->open_count ); + DRM_CURRENTPID, (long)dev->device, dev->open_count ); #elif defined(__NetBSD__) DRM_DEBUG( "pid = %d, device = 0x%lx, open_count = %d\n", - DRM_OS_CURRENTPID, (long)&dev->device, dev->open_count); + DRM_CURRENTPID, (long)&dev->device, dev->open_count); #endif if (dev->lock.hw_lock && _DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) - && dev->lock.pid == DRM_OS_CURRENTPID) { + && dev->lock.pid == DRM_CURRENTPID) { DRM_DEBUG("Process %d dead, freeing lock for context %d\n", - DRM_OS_CURRENTPID, + DRM_CURRENTPID, _DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock)); #if HAVE_DRIVER_RELEASE DRIVER_RELEASE(); @@ -962,7 +962,7 @@ int DRM(close)(dev_t kdev, int flags, int fmt, DRM_OS_STRUCTPROC *p) dev->buf_pgid = 0; #endif /* __NetBSD__ */ - DRM_OS_LOCK; + DRM_LOCK; priv = DRM(find_file_by_proc)(dev, p); if (priv) { priv->refs--; @@ -970,7 +970,7 @@ int DRM(close)(dev_t kdev, int flags, int fmt, DRM_OS_STRUCTPROC *p) TAILQ_REMOVE(&dev->files, priv, link); } } - DRM_OS_UNLOCK; + DRM_UNLOCK; DRM(free)( priv, sizeof(*priv), DRM_MEM_FILES ); @@ -979,36 +979,36 @@ int DRM(close)(dev_t kdev, int flags, int fmt, DRM_OS_STRUCTPROC *p) */ atomic_inc( &dev->counts[_DRM_STAT_CLOSES] ); - DRM_OS_SPINLOCK( &dev->count_lock ); + DRM_SPINLOCK( &dev->count_lock ); if ( !--dev->open_count ) { if ( atomic_read( &dev->ioctl_count ) || dev->blocked ) { DRM_ERROR( "Device busy: %ld %d\n", (unsigned long)atomic_read( &dev->ioctl_count ), dev->blocked ); - DRM_OS_SPINUNLOCK( &dev->count_lock ); - DRM_OS_RETURN(EBUSY); + DRM_SPINUNLOCK( &dev->count_lock ); + return DRM_ERR(EBUSY); } - DRM_OS_SPINUNLOCK( &dev->count_lock ); + DRM_SPINUNLOCK( &dev->count_lock ); return DRM(takedown)( dev ); } - DRM_OS_SPINUNLOCK( &dev->count_lock ); + DRM_SPINUNLOCK( &dev->count_lock ); #ifdef __FreeBSD__ device_unbusy(dev->device); #endif - DRM_OS_RETURN(retcode); + return DRM_ERR(retcode); } /* DRM(ioctl) is called whenever a process performs an ioctl on /dev/drm. */ -int DRM(ioctl)( DRM_OS_IOCTL ) +int DRM(ioctl)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; int retcode = 0; drm_ioctl_desc_t *ioctl; d_ioctl_t *func; int nr = DRM_IOCTL_NR(cmd); - DRM_OS_PRIV; + DRM_PRIV; atomic_inc( &dev->ioctl_count ); atomic_inc( &dev->counts[_DRM_STAT_IOCTLS] ); @@ -1016,10 +1016,10 @@ int DRM(ioctl)( DRM_OS_IOCTL ) #ifdef __FreeBSD__ DRM_DEBUG( "pid=%d, cmd=0x%02lx, nr=0x%02x, dev 0x%lx, auth=%d\n", - DRM_OS_CURRENTPID, cmd, nr, (long)dev->device, priv->authenticated ); + DRM_CURRENTPID, cmd, nr, (long)dev->device, priv->authenticated ); #elif defined(__NetBSD__) DRM_DEBUG( "pid=%d, cmd=0x%02lx, nr=0x%02x, dev 0x%lx, auth=%d\n", - DRM_OS_CURRENTPID, cmd, nr, (long)&dev->device, priv->authenticated ); + DRM_CURRENTPID, cmd, nr, (long)&dev->device, priv->authenticated ); #endif switch (cmd) { @@ -1064,7 +1064,7 @@ int DRM(ioctl)( DRM_OS_IOCTL ) if ( !func ) { DRM_DEBUG( "no function\n" ); retcode = EINVAL; - } else if ( ( ioctl->root_only && DRM_OS_SUSER(p) ) + } else if ( ( ioctl->root_only && DRM_SUSER(p) ) || ( ioctl->auth_needed && !priv->authenticated ) ) { retcode = EACCES; } else { @@ -1073,12 +1073,12 @@ int DRM(ioctl)( DRM_OS_IOCTL ) } atomic_dec( &dev->ioctl_count ); - DRM_OS_RETURN(retcode); + return DRM_ERR(retcode); } -int DRM(lock)( DRM_OS_IOCTL ) +int DRM(lock)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_lock_t lock; int ret = 0; #if __HAVE_MULTIPLE_DMA_QUEUES @@ -1090,24 +1090,24 @@ int DRM(lock)( DRM_OS_IOCTL ) dev->lck_start = start = get_cycles(); #endif - DRM_OS_KRNFROMUSR( lock, (drm_lock_t *)data, sizeof(lock) ); + DRM_COPY_FROM_USER_IOCTL( lock, (drm_lock_t *)data, sizeof(lock) ); if ( lock.context == DRM_KERNEL_CONTEXT ) { DRM_ERROR( "Process %d using kernel context %d\n", - DRM_OS_CURRENTPID, lock.context ); - DRM_OS_RETURN(EINVAL); + DRM_CURRENTPID, lock.context ); + return DRM_ERR(EINVAL); } DRM_DEBUG( "%d (pid %d) requests lock (0x%08x), flags = 0x%08x\n", - lock.context, DRM_OS_CURRENTPID, + lock.context, DRM_CURRENTPID, dev->lock.hw_lock->lock, lock.flags ); #if __HAVE_DMA_QUEUE if ( lock.context < 0 ) - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); #elif __HAVE_MULTIPLE_DMA_QUEUES if ( lock.context < 0 || lock.context >= dev->queue_count ) - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); q = dev->queuelist[lock.context]; #endif @@ -1123,7 +1123,7 @@ int DRM(lock)( DRM_OS_IOCTL ) } if ( DRM(lock_take)( &dev->lock.hw_lock->lock, lock.context ) ) { - dev->lock.pid = DRM_OS_CURRENTPID; + dev->lock.pid = DRM_CURRENTPID; dev->lock.lock_time = jiffies; atomic_inc( &dev->counts[_DRM_STAT_LOCKS] ); break; /* Got lock */ @@ -1169,21 +1169,21 @@ int DRM(lock)( DRM_OS_IOCTL ) atomic_inc(&dev->histo.lacq[DRM(histogram_slot)(get_cycles()-start)]); #endif - DRM_OS_RETURN(ret); + return DRM_ERR(ret); } -int DRM(unlock)( DRM_OS_IOCTL ) +int DRM(unlock)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_lock_t lock; - DRM_OS_KRNFROMUSR( lock, (drm_lock_t *)data, sizeof(lock) ) ; + DRM_COPY_FROM_USER_IOCTL( lock, (drm_lock_t *)data, sizeof(lock) ) ; if ( lock.context == DRM_KERNEL_CONTEXT ) { DRM_ERROR( "Process %d using kernel context %d\n", - DRM_OS_CURRENTPID, lock.context ); - DRM_OS_RETURN(EINVAL); + DRM_CURRENTPID, lock.context ); + return DRM_ERR(EINVAL); } atomic_inc( &dev->counts[_DRM_STAT_UNLOCKS] ); @@ -1236,7 +1236,7 @@ SYSUNINIT(DRM( unregister), SI_SUB_KLD, SI_ORDER_MIDDLE, linux_ioctl_unregister_ * Linux emulation IOCTL */ static int -DRM(linux_ioctl)(DRM_OS_STRUCTPROC *p, struct linux_ioctl_args* args) +DRM(linux_ioctl)(DRM_STRUCTPROC *p, struct linux_ioctl_args* args) { #if (__FreeBSD_version >= 500000) struct file *fp = p->td_proc->p_fd->fd_ofiles[args->fd]; diff --git a/bsd/drm_fops.h b/bsd/drm_fops.h index ee29e3a0..ed85a8de 100644 --- a/bsd/drm_fops.h +++ b/bsd/drm_fops.h @@ -32,7 +32,7 @@ #include "drmP.h" -drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_OS_STRUCTPROC *p) +drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_STRUCTPROC *p) { #if __FreeBSD_version >= 500021 uid_t uid = p->td_proc->p_ucred->cr_svuid; @@ -51,7 +51,7 @@ drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, DRM_OS_STRUCTPROC *p) /* DRM(open) is called whenever a process opens /dev/drm. */ -int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_OS_STRUCTPROC *p, +int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_STRUCTPROC *p, drm_device_t *dev) { int m = minor(kdev); @@ -61,9 +61,9 @@ int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_OS_STRUCTPROC *p, return EBUSY; /* No exclusive opens */ dev->flags = flags; if (!DRM(cpu_valid)()) - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); - DRM_DEBUG("pid = %d, minor = %d\n", DRM_OS_CURRENTPID, m); + DRM_DEBUG("pid = %d, minor = %d\n", DRM_CURRENTPID, m); /* FIXME: linux mallocs and bzeros here */ priv = (drm_file_t *) DRM(find_file_by_proc)(dev, p); @@ -84,10 +84,10 @@ int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_OS_STRUCTPROC *p, priv->minor = m; priv->devXX = dev; priv->ioctl_count = 0; - priv->authenticated = !DRM_OS_SUSER(p); - DRM_OS_LOCK; + priv->authenticated = !DRM_SUSER(p); + DRM_LOCK; TAILQ_INSERT_TAIL(&dev->files, priv, link); - DRM_OS_UNLOCK; + DRM_UNLOCK; } #ifdef __FreeBSD__ kdev->si_drv1 = dev; @@ -102,7 +102,7 @@ int DRM(open_helper)(dev_t kdev, int flags, int fmt, DRM_OS_STRUCTPROC *p, ssize_t DRM(read)(dev_t kdev, struct uio *uio, int ioflag) { - DRM_OS_DEVICE; + DRM_DEVICE; int left; int avail; int send; @@ -207,9 +207,9 @@ int DRM(write_string)(drm_device_t *dev, const char *s) return 0; } -int DRM(poll)(dev_t kdev, int events, DRM_OS_STRUCTPROC *p) +int DRM(poll)(dev_t kdev, int events, DRM_STRUCTPROC *p) { - DRM_OS_DEVICE; + DRM_DEVICE; int s; int revents = 0; @@ -229,7 +229,7 @@ int DRM(poll)(dev_t kdev, int events, DRM_OS_STRUCTPROC *p) int DRM(write)(dev_t kdev, struct uio *uio, int ioflag) { #if DRM_DEBUG_CODE - DRM_OS_DEVICE; + DRM_DEVICE; #endif #ifdef __FreeBSD__ DRM_DEBUG("pid = %d, device = %p, open_count = %d\n", diff --git a/bsd/drm_ioctl.h b/bsd/drm_ioctl.h index 19b1121b..63562fef 100644 --- a/bsd/drm_ioctl.h +++ b/bsd/drm_ioctl.h @@ -31,7 +31,7 @@ #include "drmP.h" -int DRM(irq_busid)( DRM_OS_IOCTL ) +int DRM(irq_busid)( DRM_IOCTL_ARGS ) { #ifdef __FreeBSD__ drm_irq_busid_t id; @@ -40,7 +40,7 @@ int DRM(irq_busid)( DRM_OS_IOCTL ) device_t *kids; int error, i, num_kids; - DRM_OS_KRNFROMUSR( id, (drm_irq_busid_t *)data, sizeof(id) ); + DRM_COPY_FROM_USER_IOCTL( id, (drm_irq_busid_t *)data, sizeof(id) ); pci = devclass_find("pci"); if (!pci) @@ -69,7 +69,7 @@ int DRM(irq_busid)( DRM_OS_IOCTL ) DRM_DEBUG("%d:%d:%d => IRQ %d\n", id.busnum, id.devnum, id.funcnum, id.irq); - DRM_OS_KRNTOUSR( (drm_irq_busid_t *)data, id, sizeof(id) ); + DRM_COPY_TO_USER_IOCTL( (drm_irq_busid_t *)data, id, sizeof(id) ); return 0; #else @@ -78,44 +78,44 @@ int DRM(irq_busid)( DRM_OS_IOCTL ) #endif } -int DRM(getunique)( DRM_OS_IOCTL ) +int DRM(getunique)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_unique_t u; - DRM_OS_KRNFROMUSR( u, (drm_unique_t *)data, sizeof(u) ); + DRM_COPY_FROM_USER_IOCTL( u, (drm_unique_t *)data, sizeof(u) ); if (u.unique_len >= dev->unique_len) { - if (DRM_OS_COPYTOUSR(u.unique, dev->unique, dev->unique_len)) - DRM_OS_RETURN(EFAULT); + if (DRM_COPY_TO_USER(u.unique, dev->unique, dev->unique_len)) + return DRM_ERR(EFAULT); } u.unique_len = dev->unique_len; - DRM_OS_KRNTOUSR( (drm_unique_t *)data, u, sizeof(u) ); + DRM_COPY_TO_USER_IOCTL( (drm_unique_t *)data, u, sizeof(u) ); return 0; } -int DRM(setunique)( DRM_OS_IOCTL ) +int DRM(setunique)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_unique_t u; if (dev->unique_len || dev->unique) - DRM_OS_RETURN(EBUSY); + return DRM_ERR(EBUSY); - DRM_OS_KRNFROMUSR( u, (drm_unique_t *)data, sizeof(u) ); + DRM_COPY_FROM_USER_IOCTL( u, (drm_unique_t *)data, sizeof(u) ); if (!u.unique_len || u.unique_len > 1024) - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); dev->unique_len = u.unique_len; dev->unique = DRM(alloc)(u.unique_len + 1, DRM_MEM_DRIVER); - if(!dev->unique) DRM_OS_RETURN(ENOMEM); + if(!dev->unique) return DRM_ERR(ENOMEM); - if (DRM_OS_COPYFROMUSR(dev->unique, u.unique, dev->unique_len)) - DRM_OS_RETURN(EFAULT); + if (DRM_COPY_FROM_USER(dev->unique, u.unique, dev->unique_len)) + return DRM_ERR(EFAULT); dev->unique[dev->unique_len] = '\0'; @@ -123,7 +123,7 @@ int DRM(setunique)( DRM_OS_IOCTL ) DRM_MEM_DRIVER); if(!dev->devname) { DRM(free)(dev->devname, sizeof(*dev->devname), DRM_MEM_DRIVER); - DRM_OS_RETURN(ENOMEM); + return DRM_ERR(ENOMEM); } sprintf(dev->devname, "%s@%s", dev->name, dev->unique); @@ -132,23 +132,23 @@ int DRM(setunique)( DRM_OS_IOCTL ) } -int DRM(getmap)( DRM_OS_IOCTL ) +int DRM(getmap)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_map_t map; drm_map_t *mapinlist; drm_map_list_entry_t *list; int idx; int i = 0; - DRM_OS_KRNFROMUSR( map, (drm_map_t *)data, sizeof(map) ); + DRM_COPY_FROM_USER_IOCTL( map, (drm_map_t *)data, sizeof(map) ); idx = map.offset; - DRM_OS_LOCK; + DRM_LOCK; if (idx < 0 || idx >= dev->map_count) { - DRM_OS_UNLOCK; - DRM_OS_RETURN(EINVAL); + DRM_UNLOCK; + return DRM_ERR(EINVAL); } TAILQ_FOREACH(list, dev->maplist, link) { @@ -165,28 +165,28 @@ int DRM(getmap)( DRM_OS_IOCTL ) i++; } - DRM_OS_UNLOCK; + DRM_UNLOCK; if (!list) return EINVAL; - DRM_OS_KRNTOUSR( (drm_map_t *)data, map, sizeof(map) ); + DRM_COPY_TO_USER_IOCTL( (drm_map_t *)data, map, sizeof(map) ); return 0; } -int DRM(getclient)( DRM_OS_IOCTL ) +int DRM(getclient)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_client_t client; drm_file_t *pt; int idx; int i = 0; - DRM_OS_KRNFROMUSR( client, (drm_client_t *)data, sizeof(client) ); + DRM_COPY_FROM_USER_IOCTL( client, (drm_client_t *)data, sizeof(client) ); idx = client.idx; - DRM_OS_LOCK; + DRM_LOCK; TAILQ_FOREACH(pt, &dev->files, link) { if (i==idx) { @@ -195,29 +195,29 @@ int DRM(getclient)( DRM_OS_IOCTL ) client.uid = pt->uid; client.magic = pt->magic; client.iocs = pt->ioctl_count; - DRM_OS_UNLOCK; + DRM_UNLOCK; *(drm_client_t *)data = client; return 0; } i++; } - DRM_OS_UNLOCK; + DRM_UNLOCK; - DRM_OS_KRNTOUSR( (drm_client_t *)data, client, sizeof(client) ); + DRM_COPY_TO_USER_IOCTL( (drm_client_t *)data, client, sizeof(client) ); return 0; } -int DRM(getstats)( DRM_OS_IOCTL ) +int DRM(getstats)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_stats_t stats; int i; memset(&stats, 0, sizeof(stats)); - DRM_OS_LOCK; + DRM_LOCK; for (i = 0; i < dev->counters; i++) { if (dev->types[i] == _DRM_STAT_LOCK) @@ -231,9 +231,9 @@ int DRM(getstats)( DRM_OS_IOCTL ) stats.count = dev->counters; - DRM_OS_UNLOCK; + DRM_UNLOCK; - DRM_OS_KRNTOUSR( (drm_stats_t *)data, stats, sizeof(stats) ); + DRM_COPY_TO_USER_IOCTL( (drm_stats_t *)data, stats, sizeof(stats) ); return 0; } diff --git a/bsd/drm_lists.h b/bsd/drm_lists.h index f85bd650..1ab55f90 100644 --- a/bsd/drm_lists.h +++ b/bsd/drm_lists.h @@ -36,12 +36,12 @@ int DRM(waitlist_create)(drm_waitlist_t *bl, int count) { if (bl->count) - DRM_OS_RETURN( EINVAL ); + return DRM_ERR( EINVAL ); bl->bufs = DRM(alloc)((bl->count + 2) * sizeof(*bl->bufs), DRM_MEM_BUFLISTS); - if(!bl->bufs) DRM_OS_RETURN(ENOMEM); + if(!bl->bufs) return DRM_ERR(ENOMEM); memset(bl->bufs, 0, sizeof(*bl->bufs)); @@ -49,15 +49,15 @@ int DRM(waitlist_create)(drm_waitlist_t *bl, int count) bl->rp = bl->bufs; bl->wp = bl->bufs; bl->end = &bl->bufs[bl->count+1]; - DRM_OS_SPININIT( bl->write_lock, "writelock" ); - DRM_OS_SPININIT( bl->read_lock, "readlock" ); + DRM_SPININIT( bl->write_lock, "writelock" ); + DRM_SPININIT( bl->read_lock, "readlock" ); return 0; } int DRM(waitlist_destroy)(drm_waitlist_t *bl) { if (bl->rp != bl->wp) - DRM_OS_RETURN( EINVAL ); + return DRM_ERR( EINVAL ); if (bl->bufs) DRM(free)(bl->bufs, (bl->count + 2) * sizeof(*bl->bufs), DRM_MEM_BUFLISTS); @@ -77,19 +77,19 @@ int DRM(waitlist_put)(drm_waitlist_t *bl, drm_buf_t *buf) if (!left) { DRM_ERROR("Overflow while adding buffer %d from pid %d\n", buf->idx, buf->pid); - DRM_OS_RETURN( EINVAL ); + return DRM_ERR( EINVAL ); } #if __HAVE_DMA_HISTOGRAM getnanotime(&buf->time_queued); #endif buf->list = DRM_LIST_WAIT; - DRM_OS_SPINLOCK(&bl->write_lock); + DRM_SPINLOCK(&bl->write_lock); s = spldrm(); *bl->wp = buf; if (++bl->wp >= bl->end) bl->wp = bl->bufs; splx(s); - DRM_OS_SPINUNLOCK(&bl->write_lock); + DRM_SPINUNLOCK(&bl->write_lock); return 0; } @@ -99,17 +99,17 @@ drm_buf_t *DRM(waitlist_get)(drm_waitlist_t *bl) drm_buf_t *buf; int s; - DRM_OS_SPINLOCK(&bl->read_lock); + DRM_SPINLOCK(&bl->read_lock); s = spldrm(); buf = *bl->rp; if (bl->rp == bl->wp) { splx(s); - DRM_OS_SPINUNLOCK(&bl->read_lock); + DRM_SPINUNLOCK(&bl->read_lock); return NULL; } if (++bl->rp >= bl->end) bl->rp = bl->bufs; splx(s); - DRM_OS_SPINUNLOCK(&bl->read_lock); + DRM_SPINUNLOCK(&bl->read_lock); return buf; } @@ -128,7 +128,7 @@ int DRM(freelist_create)(drm_freelist_t *bl, int count) bl->low_mark = 0; bl->high_mark = 0; atomic_set(&bl->wfh, 0); - DRM_OS_SPININIT( bl->lock, "freelistlock" ); + DRM_SPININIT( bl->lock, "freelistlock" ); ++bl->initialized; return 0; } @@ -160,10 +160,10 @@ int DRM(freelist_put)(drm_device_t *dev, drm_freelist_t *bl, drm_buf_t *buf) #endif buf->list = DRM_LIST_FREE; - DRM_OS_SPINLOCK( &bl->lock ); + DRM_SPINLOCK( &bl->lock ); buf->next = bl->next; bl->next = buf; - DRM_OS_SPINUNLOCK( &bl->lock ); + DRM_SPINUNLOCK( &bl->lock ); atomic_inc(&bl->count); if (atomic_read(&bl->count) > dma->buf_count) { @@ -175,7 +175,7 @@ int DRM(freelist_put)(drm_device_t *dev, drm_freelist_t *bl, drm_buf_t *buf) /* Check for high water mark */ if (atomic_read(&bl->wfh) && atomic_read(&bl->count)>=bl->high_mark) { atomic_set(&bl->wfh, 0); - DRM_OS_WAKEUP_INT(&bl->waiting); + DRM_WAKEUP_INT(&bl->waiting); } return 0; } @@ -187,14 +187,14 @@ static drm_buf_t *DRM(freelist_try)(drm_freelist_t *bl) if (!bl) return NULL; /* Get buffer */ - DRM_OS_SPINLOCK(&bl->lock); + DRM_SPINLOCK(&bl->lock); if (!bl->next) { - DRM_OS_SPINUNLOCK(&bl->lock); + DRM_SPINUNLOCK(&bl->lock); return NULL; } buf = bl->next; bl->next = bl->next->next; - DRM_OS_SPINUNLOCK(&bl->lock); + DRM_SPINUNLOCK(&bl->lock); atomic_dec(&bl->count); buf->next = NULL; diff --git a/bsd/drm_lock.h b/bsd/drm_lock.h index 305aad96..5e9294bc 100644 --- a/bsd/drm_lock.h +++ b/bsd/drm_lock.h @@ -31,13 +31,13 @@ #include "drmP.h" -int DRM(block)( DRM_OS_IOCTL ) +int DRM(block)( DRM_IOCTL_ARGS ) { DRM_DEBUG("\n"); return 0; } -int DRM(unblock)( DRM_OS_IOCTL ) +int DRM(unblock)( DRM_IOCTL_ARGS ) { DRM_DEBUG("\n"); return 0; @@ -108,7 +108,7 @@ int DRM(lock_free)(drm_device_t *dev, pid); return 1; } - DRM_OS_WAKEUP_INT((void *)&dev->lock.lock_queue); + DRM_WAKEUP_INT((void *)&dev->lock.lock_queue); return 0; } @@ -146,7 +146,7 @@ static int DRM(flush_unblock_queue)(drm_device_t *dev, int context) if (atomic_read(&q->use_count) > 1) { if (atomic_read(&q->block_write)) { atomic_dec(&q->block_write); - DRM_OS_WAKEUP_INT((void *)&q->write_queue); + DRM_WAKEUP_INT((void *)&q->write_queue); } } atomic_dec(&q->use_count); @@ -193,15 +193,15 @@ int DRM(flush_unblock)(drm_device_t *dev, int context, drm_lock_flags_t flags) return ret; } -int DRM(finish)( DRM_OS_IOCTL ) +int DRM(finish)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; int ret = 0; drm_lock_t lock; DRM_DEBUG("\n"); - DRM_OS_KRNFROMUSR( lock, (drm_lock_t *)data, sizeof(lock) ); + DRM_COPY_FROM_USER_IOCTL( lock, (drm_lock_t *)data, sizeof(lock) ); ret = DRM(flush_block_and_flush)(dev, lock.context, lock.flags); DRM(flush_unblock)(dev, lock.context, lock.flags); diff --git a/bsd/drm_memory.h b/bsd/drm_memory.h index 06301696..f7dc547a 100644 --- a/bsd/drm_memory.h +++ b/bsd/drm_memory.h @@ -49,7 +49,7 @@ typedef struct drm_mem_stats { unsigned long bytes_freed; } drm_mem_stats_t; -static DRM_OS_SPINTYPE DRM(mem_lock); +static DRM_SPINTYPE DRM(mem_lock); static unsigned long DRM(ram_available) = 0; /* In pages */ static unsigned long DRM(ram_used) = 0; static drm_mem_stats_t DRM(mem_stats)[] = { @@ -81,7 +81,7 @@ void DRM(mem_init)(void) { drm_mem_stats_t *mem; - DRM_OS_SPININIT(DRM(mem_lock), "drm memory"); + DRM_SPININIT(DRM(mem_lock), "drm memory"); for (mem = DRM(mem_stats); mem->name; ++mem) { mem->succeed_count = 0; @@ -133,9 +133,9 @@ int DRM(mem_info) DRM_SYSCTL_HANDLER_ARGS { int ret; - DRM_OS_SPINLOCK(&DRM(mem_lock)); + DRM_SPINLOCK(&DRM(mem_lock)); ret = DRM(_mem_info)(oidp, arg1, arg2, req); - DRM_OS_SPINUNLOCK(&DRM(mem_lock)); + DRM_SPINUNLOCK(&DRM(mem_lock)); return ret; } #endif @@ -154,15 +154,15 @@ void *DRM(alloc)(size_t size, int area) #elif defined(__NetBSD__) if (!(pt = malloc(size, M_DEVBUF, M_NOWAIT))) { #endif - DRM_OS_SPINLOCK(&DRM(mem_lock)); + DRM_SPINLOCK(&DRM(mem_lock)); ++DRM(mem_stats)[area].fail_count; - DRM_OS_SPINUNLOCK(&DRM(mem_lock)); + DRM_SPINUNLOCK(&DRM(mem_lock)); return NULL; } - DRM_OS_SPINLOCK(&DRM(mem_lock)); + DRM_SPINLOCK(&DRM(mem_lock)); ++DRM(mem_stats)[area].succeed_count; DRM(mem_stats)[area].bytes_allocated += size; - DRM_OS_SPINUNLOCK(&DRM(mem_lock)); + DRM_SPINUNLOCK(&DRM(mem_lock)); return pt; } @@ -210,11 +210,11 @@ void DRM(free)(void *pt, size_t size, int area) #elif defined(__NetBSD__) free(pt, M_DEVBUF); #endif - DRM_OS_SPINLOCK(&DRM(mem_lock)); + DRM_SPINLOCK(&DRM(mem_lock)); DRM(mem_stats)[area].bytes_freed += size; free_count = ++DRM(mem_stats)[area].free_count; alloc_count = DRM(mem_stats)[area].succeed_count; - DRM_OS_SPINUNLOCK(&DRM(mem_lock)); + DRM_SPINUNLOCK(&DRM(mem_lock)); if (free_count > alloc_count) { DRM_MEM_ERROR(area, "Excess frees: %d frees, %d allocs\n", free_count, alloc_count); @@ -232,15 +232,15 @@ void *DRM(ioremap)(unsigned long offset, unsigned long size) } if (!(pt = pmap_mapdev(offset, size))) { - DRM_OS_SPINLOCK(&DRM(mem_lock)); + DRM_SPINLOCK(&DRM(mem_lock)); ++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count; - DRM_OS_SPINUNLOCK(&DRM(mem_lock)); + DRM_SPINUNLOCK(&DRM(mem_lock)); return NULL; } - DRM_OS_SPINLOCK(&DRM(mem_lock)); + DRM_SPINLOCK(&DRM(mem_lock)); ++DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count; DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_allocated += size; - DRM_OS_SPINUNLOCK(&DRM(mem_lock)); + DRM_SPINUNLOCK(&DRM(mem_lock)); return pt; } @@ -258,15 +258,15 @@ void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size) /* FIXME FOR BSD */ if (!(pt = ioremap_nocache(offset, size))) { - DRM_OS_SPINLOCK(&DRM(mem_lock)); + DRM_SPINLOCK(&DRM(mem_lock)); ++DRM(mem_stats)[DRM_MEM_MAPPINGS].fail_count; - DRM_OS_SPINUNLOCK(&DRM(mem_lock)); + DRM_SPINUNLOCK(&DRM(mem_lock)); return NULL; } - DRM_OS_SPINLOCK(&DRM(mem_lock)); + DRM_SPINLOCK(&DRM(mem_lock)); ++DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count; DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_allocated += size; - DRM_OS_SPINUNLOCK(&DRM(mem_lock)); + DRM_SPINUNLOCK(&DRM(mem_lock)); return pt; } #endif @@ -282,11 +282,11 @@ void DRM(ioremapfree)(void *pt, unsigned long size) else pmap_unmapdev((vm_offset_t) pt, size); - DRM_OS_SPINLOCK(&DRM(mem_lock)); + DRM_SPINLOCK(&DRM(mem_lock)); DRM(mem_stats)[DRM_MEM_MAPPINGS].bytes_freed += size; free_count = ++DRM(mem_stats)[DRM_MEM_MAPPINGS].free_count; alloc_count = DRM(mem_stats)[DRM_MEM_MAPPINGS].succeed_count; - DRM_OS_SPINUNLOCK(&DRM(mem_lock)); + DRM_SPINUNLOCK(&DRM(mem_lock)); if (free_count > alloc_count) { DRM_MEM_ERROR(DRM_MEM_MAPPINGS, "Excess frees: %d frees, %d allocs\n", @@ -305,16 +305,16 @@ agp_memory *DRM(alloc_agp)(int pages, u32 type) } if ((handle = DRM(agp_allocate_memory)(pages, type))) { - DRM_OS_SPINLOCK(&DRM(mem_lock)); + DRM_SPINLOCK(&DRM(mem_lock)); ++DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count; DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_allocated += pages << PAGE_SHIFT; - DRM_OS_SPINUNLOCK(&DRM(mem_lock)); + DRM_SPINUNLOCK(&DRM(mem_lock)); return handle; } - DRM_OS_SPINLOCK(&DRM(mem_lock)); + DRM_SPINLOCK(&DRM(mem_lock)); ++DRM(mem_stats)[DRM_MEM_TOTALAGP].fail_count; - DRM_OS_SPINUNLOCK(&DRM(mem_lock)); + DRM_SPINUNLOCK(&DRM(mem_lock)); return NULL; } @@ -326,16 +326,16 @@ int DRM(free_agp)(agp_memory *handle, int pages) if (!handle) { DRM_MEM_ERROR(DRM_MEM_TOTALAGP, "Attempt to free NULL AGP handle\n"); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } if (DRM(agp_free_memory)(handle)) { - DRM_OS_SPINLOCK(&DRM(mem_lock)); + DRM_SPINLOCK(&DRM(mem_lock)); free_count = ++DRM(mem_stats)[DRM_MEM_TOTALAGP].free_count; alloc_count = DRM(mem_stats)[DRM_MEM_TOTALAGP].succeed_count; DRM(mem_stats)[DRM_MEM_TOTALAGP].bytes_freed += pages << PAGE_SHIFT; - DRM_OS_SPINUNLOCK(&DRM(mem_lock)); + DRM_SPINUNLOCK(&DRM(mem_lock)); if (free_count > alloc_count) { DRM_MEM_ERROR(DRM_MEM_TOTALAGP, "Excess frees: %d frees, %d allocs\n", @@ -343,13 +343,13 @@ int DRM(free_agp)(agp_memory *handle, int pages) } return 0; } - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } int DRM(bind_agp)(agp_memory *handle, unsigned int start) { int retcode; - device_t dev = DRM_OS_AGP_FIND_DEVICE(); + device_t dev = DRM_AGP_FIND_DEVICE(); struct agp_memory_info info; if (!dev) @@ -358,22 +358,22 @@ int DRM(bind_agp)(agp_memory *handle, unsigned int start) if (!handle) { DRM_MEM_ERROR(DRM_MEM_BOUNDAGP, "Attempt to bind NULL AGP handle\n"); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } if (!(retcode = DRM(agp_bind_memory)(handle, start))) { - DRM_OS_SPINLOCK(&DRM(mem_lock)); + DRM_SPINLOCK(&DRM(mem_lock)); ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count; agp_memory_info(dev, handle, &info); DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_allocated += info.ami_size; - DRM_OS_SPINUNLOCK(&DRM(mem_lock)); - DRM_OS_RETURN(0); + DRM_SPINUNLOCK(&DRM(mem_lock)); + return DRM_ERR(0); } - DRM_OS_SPINLOCK(&DRM(mem_lock)); + DRM_SPINLOCK(&DRM(mem_lock)); ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].fail_count; - DRM_OS_SPINUNLOCK(&DRM(mem_lock)); - DRM_OS_RETURN(retcode); + DRM_SPINUNLOCK(&DRM(mem_lock)); + return DRM_ERR(retcode); } int DRM(unbind_agp)(agp_memory *handle) @@ -381,7 +381,7 @@ int DRM(unbind_agp)(agp_memory *handle) int alloc_count; int free_count; int retcode = EINVAL; - device_t dev = DRM_OS_AGP_FIND_DEVICE(); + device_t dev = DRM_AGP_FIND_DEVICE(); struct agp_memory_info info; if (!dev) @@ -390,25 +390,25 @@ int DRM(unbind_agp)(agp_memory *handle) if (!handle) { DRM_MEM_ERROR(DRM_MEM_BOUNDAGP, "Attempt to unbind NULL AGP handle\n"); - DRM_OS_RETURN(retcode); + return DRM_ERR(retcode); } agp_memory_info(dev, handle, &info); if ((retcode = DRM(agp_unbind_memory)(handle))) - DRM_OS_RETURN(retcode); + return DRM_ERR(retcode); - DRM_OS_SPINLOCK(&DRM(mem_lock)); + DRM_SPINLOCK(&DRM(mem_lock)); free_count = ++DRM(mem_stats)[DRM_MEM_BOUNDAGP].free_count; alloc_count = DRM(mem_stats)[DRM_MEM_BOUNDAGP].succeed_count; DRM(mem_stats)[DRM_MEM_BOUNDAGP].bytes_freed += info.ami_size; - DRM_OS_SPINUNLOCK(&DRM(mem_lock)); + DRM_SPINUNLOCK(&DRM(mem_lock)); if (free_count > alloc_count) { DRM_MEM_ERROR(DRM_MEM_BOUNDAGP, "Excess frees: %d frees, %d allocs\n", free_count, alloc_count); } - DRM_OS_RETURN(retcode); + return DRM_ERR(retcode); } #endif diff --git a/bsd/drm_os_freebsd.h b/bsd/drm_os_freebsd.h index 83c246ae..2f5345db 100644 --- a/bsd/drm_os_freebsd.h +++ b/bsd/drm_os_freebsd.h @@ -74,47 +74,48 @@ #define CDEV_MAJOR 145 #if __FreeBSD_version >= 500000 -#define DRM_OS_SPINTYPE struct mtx -#define DRM_OS_SPININIT(l,name) mtx_init(&l, name, NULL, MTX_DEF) -#define DRM_OS_SPINLOCK(l) mtx_lock(l) -#define DRM_OS_SPINUNLOCK(u) mtx_unlock(u); -#define DRM_OS_CURPROC curthread -#define DRM_OS_STRUCTPROC struct thread -#define DRM_OS_CURRENTPID curthread->td_proc->p_pid +#define DRM_CURPROC curthread +#define DRM_STRUCTPROC struct thread +#define DRM_SPINTYPE struct mtx +#define DRM_SPININIT(l,name) mtx_init(&l, name, NULL, MTX_DEF) +#define DRM_SPINLOCK(l) mtx_lock(l) +#define DRM_SPINUNLOCK(u) mtx_unlock(u); +#define DRM_CURRENTPID curthread->td_proc->p_pid #else -#define DRM_OS_CURPROC curproc -#define DRM_OS_STRUCTPROC struct proc -#define DRM_OS_SPINTYPE struct simplelock -#define DRM_OS_SPININIT(l,name) simple_lock_init(&l) -#define DRM_OS_SPINLOCK(l) simple_lock(l) -#define DRM_OS_SPINUNLOCK(u) simple_unlock(u); -#define DRM_OS_CURRENTPID curproc->p_pid +#define DRM_CURPROC curproc +#define DRM_STRUCTPROC struct proc +#define DRM_SPINTYPE struct simplelock +#define DRM_SPININIT(l,name) simple_lock_init(&l) +#define DRM_SPINLOCK(l) simple_lock(l) +#define DRM_SPINUNLOCK(u) simple_unlock(u); +#define DRM_CURRENTPID curproc->p_pid #endif -#define DRM_OS_IOCTL dev_t kdev, u_long cmd, caddr_t data, int flags, DRM_OS_STRUCTPROC *p -#define DRM_OS_LOCK lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, DRM_OS_CURPROC) -#define DRM_OS_UNLOCK lockmgr(&dev->dev_lock, LK_RELEASE, 0, DRM_OS_CURPROC) -#define DRM_OS_SUSER(p) suser(p) -#define DRM_OS_TASKQUEUE_ARGS void *dev, int pending -#define DRM_OS_IRQ_ARGS void *device -#define DRM_OS_DEVICE drm_device_t *dev = kdev->si_drv1 -#define DRM_OS_MALLOC(size) malloc( size, DRM(M_DRM), M_NOWAIT ) -#define DRM_OS_FREE(pt) free( pt, DRM(M_DRM) ) -#define DRM_OS_VTOPHYS(addr) vtophys(addr) -#define DRM_OS_READ8(addr) *((volatile char *)(addr)) -#define DRM_OS_READ32(addr) *((volatile long *)(addr)) -#define DRM_OS_WRITE8(addr, val) *((volatile char *)(addr)) = (val) -#define DRM_OS_WRITE32(addr, val) *((volatile long *)(addr)) = (val) -#define DRM_OS_AGP_FIND_DEVICE() agp_find_device() - -#define DRM_OS_PRIV \ +#define DRM_IOCTL_ARGS dev_t kdev, u_long cmd, caddr_t data, int flags, DRM_STRUCTPROC *p +#define DRM_LOCK lockmgr(&dev->dev_lock, LK_EXCLUSIVE, 0, DRM_CURPROC) +#define DRM_UNLOCK lockmgr(&dev->dev_lock, LK_RELEASE, 0, DRM_CURPROC) +#define DRM_SUSER(p) suser(p) +#define DRM_TASKQUEUE_ARGS void *dev, int pending +#define DRM_IRQ_ARGS void *device +#define DRM_DEVICE drm_device_t *dev = kdev->si_drv1 +#define DRM_MALLOC(size) malloc( size, DRM(M_DRM), M_NOWAIT ) +#define DRM_FREE(pt) free( pt, DRM(M_DRM) ) +#define DRM_VTOPHYS(addr) vtophys(addr) +#define DRM_READ8(addr) *((volatile char *)(addr)) +#define DRM_READ32(addr) *((volatile long *)(addr)) +#define DRM_WRITE8(addr, val) *((volatile char *)(addr)) = (val) +#define DRM_WRITE32(addr, val) *((volatile long *)(addr)) = (val) +#define DRM_AGP_FIND_DEVICE() agp_find_device() +#define DRM_ERR(v) v + +#define DRM_PRIV \ drm_file_t *priv = (drm_file_t *) DRM(find_file_by_proc)(dev, p); \ if (!priv) { \ DRM_DEBUG("can't find authenticator\n"); \ return EINVAL; \ } -#define DRM_OS_DELAY( udelay ) \ +#define DRM_UDELAY( udelay ) \ do { \ struct timeval tv1, tv2; \ microtime(&tv1); \ @@ -124,7 +125,7 @@ do { \ while (((tv2.tv_sec-tv1.tv_sec)*1000000 + tv2.tv_usec - tv1.tv_usec) < udelay ); \ } while (0) -#define DRM_OS_GETSAREA() \ +#define DRM_GETSAREA() \ do { \ drm_map_list_entry_t *listentry; \ TAILQ_FOREACH(listentry, dev->maplist, link) { \ @@ -137,41 +138,38 @@ do { \ } \ } while (0) -#define DRM_OS_RETURN(v) return v; -#define DRM_OS_ERR(v) v - -#define DRM_OS_KRNTOUSR(arg1, arg2, arg3) \ +#define DRM_COPY_TO_USER_IOCTL(arg1, arg2, arg3) \ *arg1 = arg2 -#define DRM_OS_KRNFROMUSR(arg1, arg2, arg3) \ +#define DRM_COPY_FROM_USER_IOCTL(arg1, arg2, arg3) \ arg1 = *arg2 -#define DRM_OS_COPYTOUSR(arg1, arg2, arg3) \ +#define DRM_COPY_TO_USER(arg1, arg2, arg3) \ copyout(arg2, arg1, arg3) -#define DRM_OS_COPYFROMUSR(arg1, arg2, arg3) \ +#define DRM_COPY_FROM_USER(arg1, arg2, arg3) \ copyin(arg2, arg1, arg3) /* Macros for userspace access with checking readability once */ /* FIXME: can't find equivalent functionality for nocheck yet. * It's be slower than linux, but should be correct. */ -#define DRM_OS_VERIFYAREA_READ( uaddr, size ) \ +#define DRM_VERIFYAREA_READ( uaddr, size ) \ (!useracc((caddr_t)uaddr, size, VM_PROT_READ)) -#define DRM_OS_COPYFROMUSR_NC(arg1, arg2, arg3) \ +#define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \ copyin(arg2, arg1, arg3) -#define DRM_OS_FETCHU_32_NC(val, uaddr) \ +#define DRM_GET_USER_UNCHECKED(val, uaddr) \ ((val) = fuword(uaddr), 0) /* From machine/bus_at386.h on i386 */ -#define DRM_OS_READMEMORYBARRIER() \ +#define DRM_READMEMORYBARRIER() \ do { \ __asm __volatile("lock; addl $0,0(%%esp)" : : : "memory"); \ } while (0) -#define DRM_OS_WRITEMEMORYBARRIER() \ +#define DRM_WRITEMEMORYBARRIER() \ do { \ __asm __volatile("" : : : "memory"); \ } while (0) -#define DRM_OS_WAKEUP(w) wakeup(w) -#define DRM_OS_WAKEUP_INT(w) wakeup(w) +#define DRM_WAKEUP(w) wakeup(w) +#define DRM_WAKEUP_INT(w) wakeup(w) #define PAGE_ALIGN(addr) round_page(addr) @@ -347,9 +345,9 @@ extern d_write_t DRM(write); extern d_poll_t DRM(poll); extern d_mmap_t DRM(mmap); extern int DRM(open_helper)(dev_t kdev, int flags, int fmt, - DRM_OS_STRUCTPROC *p, drm_device_t *dev); + DRM_STRUCTPROC *p, drm_device_t *dev); extern drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, - DRM_OS_STRUCTPROC *p); + DRM_STRUCTPROC *p); /* Misc. IOCTL support (drm_ioctl.h) */ extern d_ioctl_t DRM(irq_busid); diff --git a/bsd/drm_os_netbsd.h b/bsd/drm_os_netbsd.h index 5470d428..2082c047 100644 --- a/bsd/drm_os_netbsd.h +++ b/bsd/drm_os_netbsd.h @@ -59,38 +59,38 @@ extern struct cfdriver DRM(_cd); #define DRM_DEV_GID 0 #define CDEV_MAJOR 90 -#define DRM_OS_CURPROC curproc -#define DRM_OS_STRUCTPROC struct proc -#define DRM_OS_SPINTYPE struct simplelock -#define DRM_OS_SPININIT(l,name) simple_lock_init(&l) -#define DRM_OS_SPINLOCK(l) simple_lock(l) -#define DRM_OS_SPINUNLOCK(u) simple_unlock(u); -#define DRM_OS_CURRENTPID curproc->p_pid - -#define DRM_OS_IOCTL dev_t kdev, u_long cmd, caddr_t data, int flags, DRM_OS_STRUCTPROC *p -#define DRM_OS_LOCK lockmgr(&dev->dev_lock, LK_EXCLUSIVE, NULL) -#define DRM_OS_UNLOCK lockmgr(&dev->dev_lock, LK_RELEASE, NULL) -#define DRM_OS_SUSER(p) suser(p->p_ucred, &p->p_acflag) -#define DRM_OS_TASKQUEUE_ARGS void *dev, int pending -#define DRM_OS_IRQ_ARGS void *device -#define DRM_OS_DEVICE drm_device_t *dev = device_lookup(&DRM(_cd), minor(kdev)) -#define DRM_OS_MALLOC(size) malloc( size, DRM(M_DRM), M_NOWAIT ) -#define DRM_OS_FREE(pt) free( pt, DRM(M_DRM) ) -#define DRM_OS_VTOPHYS(addr) vtophys(addr) -#define DRM_OS_READ8(addr) *((volatile char *)(addr)) -#define DRM_OS_READ32(addr) *((volatile long *)(addr)) -#define DRM_OS_WRITE8(addr, val) *((volatile char *)(addr)) = (val) -#define DRM_OS_WRITE32(addr, val) *((volatile long *)(addr)) = (val) -#define DRM_OS_AGP_FIND_DEVICE() - -#define DRM_OS_PRIV \ +#define DRM_CURPROC curproc +#define DRM_STRUCTPROC struct proc +#define DRM_SPINTYPE struct simplelock +#define DRM_SPININIT(l,name) simple_lock_init(&l) +#define DRM_SPINLOCK(l) simple_lock(l) +#define DRM_SPINUNLOCK(u) simple_unlock(u); +#define DRM_CURRENTPID curproc->p_pid + +#define DRM_IOCTL_ARGS dev_t kdev, u_long cmd, caddr_t data, int flags, DRM_STRUCTPROC *p +#define DRM_LOCK lockmgr(&dev->dev_lock, LK_EXCLUSIVE, NULL) +#define DRM_UNLOCK lockmgr(&dev->dev_lock, LK_RELEASE, NULL) +#define DRM_SUSER(p) suser(p->p_ucred, &p->p_acflag) +#define DRM_TASKQUEUE_ARGS void *dev, int pending +#define DRM_IRQ_ARGS void *device +#define DRM_DEVICE drm_device_t *dev = device_lookup(&DRM(_cd), minor(kdev)) +#define DRM_MALLOC(size) malloc( size, DRM(M_DRM), M_NOWAIT ) +#define DRM_FREE(pt) free( pt, DRM(M_DRM) ) +#define DRM_VTOPHYS(addr) vtophys(addr) +#define DRM_READ8(addr) *((volatile char *)(addr)) +#define DRM_READ32(addr) *((volatile long *)(addr)) +#define DRM_WRITE8(addr, val) *((volatile char *)(addr)) = (val) +#define DRM_WRITE32(addr, val) *((volatile long *)(addr)) = (val) +#define DRM_AGP_FIND_DEVICE() + +#define DRM_PRIV \ drm_file_t *priv = (drm_file_t *) DRM(find_file_by_proc)(dev, p); \ if (!priv) { \ DRM_DEBUG("can't find authenticator\n"); \ return EINVAL; \ } -#define DRM_OS_DELAY( udelay ) \ +#define DRM_UDELAY( udelay ) \ do { \ struct timeval tv1, tv2; \ microtime(&tv1); \ @@ -100,7 +100,7 @@ do { \ while (((tv2.tv_sec-tv1.tv_sec)*1000000 + tv2.tv_usec - tv1.tv_usec) < udelay ); \ } while (0) -#define DRM_OS_GETSAREA() \ +#define DRM_GETSAREA() \ do { \ drm_map_list_entry_t *listentry; \ TAILQ_FOREACH(listentry, dev->maplist, link) { \ @@ -113,19 +113,19 @@ do { \ } \ } while (0) -#define DRM_OS_RETURN(v) return v; -#define DRM_OS_ERR(v) v +#define return DRM_ERR(v) return v; +#define DRM_ERR(v) v -#define DRM_OS_KRNTOUSR(arg1, arg2, arg3) \ +#define DRM_COPY_TO_USER_IOCTL(arg1, arg2, arg3) \ *arg1 = arg2 -#define DRM_OS_KRNFROMUSR(arg1, arg2, arg3) \ +#define DRM_COPY_FROM_USER_IOCTL(arg1, arg2, arg3) \ arg1 = *arg2 -#define DRM_OS_COPYTOUSR(arg1, arg2, arg3) \ +#define DRM_COPY_TO_USER(arg1, arg2, arg3) \ copyout(arg2, arg1, arg3) -#define DRM_OS_COPYFROMUSR(arg1, arg2, arg3) \ +#define DRM_COPY_FROM_USER(arg1, arg2, arg3) \ copyin(arg2, arg1, arg3) -#define DRM_OS_READMEMORYBARRIER \ +#define DRM_READMEMORYBARRIER \ { \ int xchangeDummy; \ DRM_DEBUG("%s\n", __FUNCTION__); \ @@ -135,10 +135,10 @@ do { \ " pop %%eax" : /* no outputs */ : /* no inputs */ ); \ } while (0); -#define DRM_OS_WRITEMEMORYBARRIER DRM_OS_READMEMORYBARRIER +#define DRM_WRITEMEMORYBARRIER DRM_READMEMORYBARRIER -#define DRM_OS_WAKEUP(w) wakeup(w) -#define DRM_OS_WAKEUP_INT(w) wakeup(w) +#define DRM_WAKEUP(w) wakeup(w) +#define DRM_WAKEUP_INT(w) wakeup(w) #define PAGE_ALIGN(addr) (((addr)+PAGE_SIZE-1)&PAGE_MASK) @@ -300,9 +300,9 @@ extern dev_type_write(DRM(write)); extern dev_type_poll(DRM(poll)); extern dev_type_mmap(DRM(mmap)); extern int DRM(open_helper)(dev_t kdev, int flags, int fmt, - DRM_OS_STRUCTPROC *p, drm_device_t *dev); + DRM_STRUCTPROC *p, drm_device_t *dev); extern drm_file_t *DRM(find_file_by_proc)(drm_device_t *dev, - DRM_OS_STRUCTPROC *p); + DRM_STRUCTPROC *p); /* Misc. IOCTL support (drm_ioctl.h) */ extern dev_type_ioctl(DRM(irq_busid)); diff --git a/bsd/drm_scatter.h b/bsd/drm_scatter.h index 17c9998d..c16b7c05 100644 --- a/bsd/drm_scatter.h +++ b/bsd/drm_scatter.h @@ -48,9 +48,9 @@ void DRM(sg_cleanup)( drm_sg_mem_t *entry ) DRM_MEM_SGLISTS ); } -int DRM(sg_alloc)( DRM_OS_IOCTL ) +int DRM(sg_alloc)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_scatter_gather_t request; drm_sg_mem_t *entry; unsigned long pages; @@ -60,7 +60,7 @@ int DRM(sg_alloc)( DRM_OS_IOCTL ) if ( dev->sg ) return EINVAL; - DRM_OS_KRNFROMUSR(request, (drm_scatter_gather_t *)data, + DRM_COPY_FROM_USER_IOCTL(request, (drm_scatter_gather_t *)data, sizeof(request) ); entry = DRM(alloc)( sizeof(*entry), DRM_MEM_SGLISTS ); @@ -118,7 +118,7 @@ int DRM(sg_alloc)( DRM_OS_IOCTL ) request.handle = entry->handle; - DRM_OS_KRNTOUSR( (drm_scatter_gather_t *)data, + DRM_COPY_TO_USER_IOCTL( (drm_scatter_gather_t *)data, request, sizeof(request) ); @@ -170,13 +170,13 @@ int DRM(sg_alloc)( DRM_OS_IOCTL ) return ENOMEM; } -int DRM(sg_free)( DRM_OS_IOCTL ) +int DRM(sg_free)( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_scatter_gather_t request; drm_sg_mem_t *entry; - DRM_OS_KRNFROMUSR( request, (drm_scatter_gather_t *)data, + DRM_COPY_FROM_USER_IOCTL( request, (drm_scatter_gather_t *)data, sizeof(request) ); entry = dev->sg; @@ -194,13 +194,13 @@ int DRM(sg_free)( DRM_OS_IOCTL ) #else /* __REALLY_HAVE_SG */ -int DRM(sg_alloc)( DRM_OS_IOCTL ) +int DRM(sg_alloc)( DRM_IOCTL_ARGS ) { - return DRM_OS_ERR(EINVAL); + return DRM_ERR(EINVAL); } -int DRM(sg_free)( DRM_OS_IOCTL ) +int DRM(sg_free)( DRM_IOCTL_ARGS ) { - return DRM_OS_ERR(EINVAL); + return DRM_ERR(EINVAL); } #endif diff --git a/bsd/drm_sysctl.h b/bsd/drm_sysctl.h index 82ca2833..c8aa9914 100644 --- a/bsd/drm_sysctl.h +++ b/bsd/drm_sysctl.h @@ -168,9 +168,9 @@ static int DRM(vm_info)DRM_SYSCTL_HANDLER_ARGS drm_device_t *dev = arg1; int ret; - DRM_OS_LOCK; + DRM_LOCK; ret = DRM(_vm_info)(oidp, arg1, arg2, req); - DRM_OS_UNLOCK; + DRM_UNLOCK; return ret; } @@ -219,9 +219,9 @@ static int DRM(queues_info) DRM_SYSCTL_HANDLER_ARGS drm_device_t *dev = arg1; int ret; - DRM_OS_LOCK; + DRM_LOCK; ret = DRM(_queues_info)(oidp, arg1, arg2, req); - DRM_OS_UNLOCK; + DRM_UNLOCK; return ret; } @@ -269,9 +269,9 @@ static int DRM(bufs_info) DRM_SYSCTL_HANDLER_ARGS drm_device_t *dev = arg1; int ret; - DRM_OS_LOCK; + DRM_LOCK; ret = DRM(_bufs_info)(oidp, arg1, arg2, req); - DRM_OS_UNLOCK; + DRM_UNLOCK; return ret; } @@ -303,9 +303,9 @@ static int DRM(clients_info)DRM_SYSCTL_HANDLER_ARGS drm_device_t *dev = arg1; int ret; - DRM_OS_LOCK; + DRM_LOCK; ret = DRM(_clients_info)(oidp, arg1, arg2, req); - DRM_OS_UNLOCK; + DRM_UNLOCK; return ret; } @@ -388,9 +388,9 @@ static int DRM(vma_info)DRM_SYSCTL_HANDLER_ARGS drm_device_t *dev = arg1; int ret; - DRM_OS_LOCK; + DRM_LOCK; ret = DRM(_vma_info)(oidp, arg1, arg2, req); - DRM_OS_UNLOCK; + DRM_UNLOCK; return ret; } #endif @@ -517,9 +517,9 @@ static int DRM(histo_info)DRM_SYSCTL_HANDLER_ARGS drm_device_t *dev = arg1; int ret; - DRM_OS_LOCK; + DRM_LOCK; ret = _drm_histo_info(oidp, arg1, arg2, req); - DRM_OS_UNLOCK; + DRM_UNLOCK; return ret; } #endif diff --git a/bsd/drm_vm.h b/bsd/drm_vm.h index ada9f1eb..70a5b0e6 100644 --- a/bsd/drm_vm.h +++ b/bsd/drm_vm.h @@ -5,7 +5,7 @@ static int DRM(dma_mmap)(dev_t kdev, vm_offset_t offset, int prot) static paddr_t DRM(dma_mmap)(dev_t kdev, vm_offset_t offset, int prot) #endif { - DRM_OS_DEVICE; + DRM_DEVICE; drm_device_dma_t *dma = dev->dma; unsigned long physical; unsigned long page; @@ -26,20 +26,20 @@ int DRM(mmap)(dev_t kdev, vm_offset_t offset, int prot) paddr_t DRM(mmap)(dev_t kdev, off_t offset, int prot) #endif { - DRM_OS_DEVICE; + DRM_DEVICE; drm_map_t *map = NULL; drm_map_list_entry_t *listentry=NULL; drm_file_t *priv; /* DRM_DEBUG("offset = 0x%x\n", offset);*/ - priv = DRM(find_file_by_proc)(dev, DRM_OS_CURPROC); + priv = DRM(find_file_by_proc)(dev, DRM_CURPROC); if (!priv) { DRM_DEBUG("can't find authenticator\n"); return EINVAL; } - if (!priv->authenticated) DRM_OS_RETURN(EACCES); + if (!priv->authenticated) return DRM_ERR(EACCES); if (dev->dma && offset >= 0 @@ -64,7 +64,7 @@ paddr_t DRM(mmap)(dev_t kdev, off_t offset, int prot) DRM_DEBUG("can't find map\n"); return -1; } - if (((map->flags&_DRM_RESTRICTED) && DRM_OS_SUSER(DRM_OS_CURPROC))) { + if (((map->flags&_DRM_RESTRICTED) && DRM_SUSER(DRM_CURPROC))) { DRM_DEBUG("restricted map\n"); return -1; } diff --git a/bsd/gamma_dma.c b/bsd/gamma_dma.c index c9ac0530..e7ca0695 100644 --- a/bsd/gamma_dma.c +++ b/bsd/gamma_dma.c @@ -44,7 +44,7 @@ static __inline__ void gamma_dma_dispatch(drm_device_t *dev, unsigned long addre drm_gamma_private_t *dev_priv = (drm_gamma_private_t *)dev->dev_private; - GAMMA_WRITE(GAMMA_DMAADDRESS, DRM_OS_VTOPHYS((void *)address)); + GAMMA_WRITE(GAMMA_DMAADDRESS, DRM_VTOPHYS((void *)address)); while (GAMMA_READ(GAMMA_GCOMMANDSTATUS) != 4) ; GAMMA_WRITE(GAMMA_DMACOUNT, length / 4); @@ -114,7 +114,7 @@ static __inline__ int gamma_dma_is_ready(drm_device_t *dev) return !GAMMA_READ(GAMMA_DMACOUNT); } -void gamma_dma_service( DRM_OS_IRQ_ARGS) +void gamma_dma_service( DRM_IRQ_ARGS) { drm_device_t *dev = (drm_device_t *)device; drm_device_dma_t *dma = dev->dma; @@ -150,7 +150,7 @@ static int gamma_do_dma(drm_device_t *dev, int locked) cycles_t dma_start, dma_stop; #endif - if (test_and_set_bit(0, &dev->dma_flag)) DRM_OS_RETURN( EBUSY ); + if (test_and_set_bit(0, &dev->dma_flag)) return DRM_ERR( EBUSY ); #if DRM_DMA_HISTOGRAM dma_start = get_cycles(); @@ -159,7 +159,7 @@ static int gamma_do_dma(drm_device_t *dev, int locked) if (!dma->next_buffer) { DRM_ERROR("No next_buffer\n"); clear_bit(0, &dev->dma_flag); - DRM_OS_RETURN( EINVAL ); + return DRM_ERR( EINVAL ); } buf = dma->next_buffer; @@ -173,7 +173,7 @@ static int gamma_do_dma(drm_device_t *dev, int locked) gamma_clear_next_buffer(dev); gamma_free_buffer(dev, buf); clear_bit(0, &dev->dma_flag); - DRM_OS_RETURN( EINVAL ); + return DRM_ERR( EINVAL ); } if (!length) { @@ -186,7 +186,7 @@ static int gamma_do_dma(drm_device_t *dev, int locked) if (!gamma_dma_is_ready(dev)) { clear_bit(0, &dev->dma_flag); - DRM_OS_RETURN( EBUSY ); + return DRM_ERR( EBUSY ); } if (buf->while_locked) { @@ -199,7 +199,7 @@ static int gamma_do_dma(drm_device_t *dev, int locked) if (!locked && !gamma_lock_take(&dev->lock.hw_lock->lock, DRM_KERNEL_CONTEXT)) { clear_bit(0, &dev->dma_flag); - DRM_OS_RETURN( EBUSY ); + return DRM_ERR( EBUSY ); } } @@ -252,7 +252,7 @@ cleanup: atomic_inc(&dev->histo.dma[gamma_histogram_slot(dma_stop - dma_start)]); #endif - DRM_OS_RETURN( retcode ); + return DRM_ERR( retcode ); } static void gamma_dma_timer_bh(unsigned long dev) @@ -260,7 +260,7 @@ static void gamma_dma_timer_bh(unsigned long dev) gamma_dma_schedule((drm_device_t *)dev, 0); } -void gamma_dma_immediate_bh(DRM_OS_TASKQUEUE_ARGS) +void gamma_dma_immediate_bh(DRM_TASKQUEUE_ARGS) { gamma_dma_schedule(dev, 0); } @@ -282,7 +282,7 @@ int gamma_dma_schedule(drm_device_t *dev, int locked) if (test_and_set_bit(0, &dev->interrupt_flag)) { /* Not reentrant */ atomic_inc(&dev->counts[10]); /* _DRM_STAT_MISSED */ - DRM_OS_RETURN( EBUSY ); + return DRM_ERR( EBUSY ); } missed = atomic_read(&dev->counts[10]); @@ -293,7 +293,7 @@ int gamma_dma_schedule(drm_device_t *dev, int locked) again: if (dev->context_flag) { clear_bit(0, &dev->interrupt_flag); - DRM_OS_RETURN( EBUSY ); + return DRM_ERR( EBUSY ); } if (dma->next_buffer) { /* Unsent buffer that was previously @@ -379,15 +379,15 @@ static int gamma_dma_priority(drm_device_t *dev, drm_dma_t *d) continue; } buf = dma->buflist[ idx ]; - if (buf->pid != DRM_OS_CURRENTPID) { + if (buf->pid != DRM_CURRENTPID) { DRM_ERROR("Process %d using buffer owned by %d\n", - DRM_OS_CURRENTPID, buf->pid); + DRM_CURRENTPID, buf->pid); retcode = EINVAL; goto cleanup; } if (buf->list != DRM_LIST_NONE) { DRM_ERROR("Process %d using %d's buffer on list %d\n", - DRM_OS_CURRENTPID, buf->pid, buf->list); + DRM_CURRENTPID, buf->pid, buf->list); retcode = EINVAL; goto cleanup; } @@ -471,7 +471,7 @@ cleanup: } } clear_bit(0, &dev->interrupt_flag); - DRM_OS_RETURN( retcode ); + return DRM_ERR( retcode ); } static int gamma_dma_send_buffers(drm_device_t *dev, drm_dma_t *d) @@ -494,7 +494,7 @@ static int gamma_dma_send_buffers(drm_device_t *dev, drm_dma_t *d) gamma_dma_schedule(dev, 0); if (d->flags & _DRM_DMA_BLOCK) { - DRM_DEBUG("%d waiting\n", DRM_OS_CURRENTPID); + DRM_DEBUG("%d waiting\n", DRM_CURRENTPID); for (;;) { retcode = tsleep(&last_buf->dma_wait, PZERO|PCATCH, "gamdw", 0); @@ -505,7 +505,7 @@ static int gamma_dma_send_buffers(drm_device_t *dev, drm_dma_t *d) break; } atomic_dec(&last_buf->dma_wait); - DRM_DEBUG("%d running\n", DRM_OS_CURRENTPID); + DRM_DEBUG("%d running\n", DRM_CURRENTPID); if (!retcode || (last_buf->list==DRM_LIST_PEND && !last_buf->pending)) { if (!last_buf->dma_wait) { @@ -521,31 +521,31 @@ static int gamma_dma_send_buffers(drm_device_t *dev, drm_dma_t *d) last_buf->idx, last_buf->list, last_buf->pid, - DRM_OS_CURRENTPID); + DRM_CURRENTPID); } } - DRM_OS_RETURN( retcode ); + return DRM_ERR( retcode ); } -int gamma_dma( DRM_OS_IOCTL ) +int gamma_dma( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_device_dma_t *dma = dev->dma; int retcode = 0; drm_dma_t d; - DRM_OS_KRNFROMUSR(d, (drm_dma_t *) data, sizeof(d)); + DRM_COPY_FROM_USER_IOCTL(d, (drm_dma_t *) data, sizeof(d)); if (d.send_count < 0 || d.send_count > dma->buf_count) { DRM_ERROR("Process %d trying to send %d buffers (of %d max)\n", - DRM_OS_CURRENTPID, d.send_count, dma->buf_count); - DRM_OS_RETURN( EINVAL ); + DRM_CURRENTPID, d.send_count, dma->buf_count); + return DRM_ERR( EINVAL ); } if (d.request_count < 0 || d.request_count > dma->buf_count) { DRM_ERROR("Process %d trying to get %d buffers (of %d max)\n", - DRM_OS_CURRENTPID, d.request_count, dma->buf_count); - DRM_OS_RETURN( EINVAL ); + DRM_CURRENTPID, d.request_count, dma->buf_count); + return DRM_ERR( EINVAL ); } if (d.send_count) { @@ -562,8 +562,8 @@ int gamma_dma( DRM_OS_IOCTL ) } DRM_DEBUG("%d returning, granted = %d\n", - DRM_OS_CURRENTPID, d.granted_count); - DRM_OS_KRNTOUSR((drm_dma_t *) data, d, sizeof(d)); + DRM_CURRENTPID, d.granted_count); + DRM_COPY_TO_USER_IOCTL((drm_dma_t *) data, d, sizeof(d)); return retcode; } diff --git a/bsd/gamma_drv.h b/bsd/gamma_drv.h index f8665516..69250b9e 100644 --- a/bsd/gamma_drv.h +++ b/bsd/gamma_drv.h @@ -44,10 +44,10 @@ typedef struct drm_gamma_private { #define LOCK_TEST_WITH_RETURN( dev ) \ do { \ if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \ - dev->lock.pid != DRM_OS_CURRENTPID ) { \ + dev->lock.pid != DRM_CURRENTPID ) { \ DRM_ERROR( "%s called without lock held\n", \ __FUNCTION__ ); \ - DRM_OS_RETURN( EINVAL ); \ + return DRM_ERR( EINVAL ); \ } \ } while (0) @@ -58,7 +58,7 @@ extern void gamma_dma_quiescent_dual(drm_device_t *dev); /* gamma_dma.c */ extern int gamma_dma_schedule(drm_device_t *dev, int locked); -extern int gamma_dma( DRM_OS_IOCTL ); +extern int gamma_dma( DRM_IOCTL_ARGS ); extern int gamma_find_devices(void); extern int gamma_found(void); diff --git a/bsd/i810_dma.c b/bsd/i810_dma.c index 4310851a..d860fafe 100644 --- a/bsd/i810_dma.c +++ b/bsd/i810_dma.c @@ -121,7 +121,7 @@ static int i810_freelist_put(drm_device_t *dev, drm_buf_t *buf) _DRM_CAS(buf_priv->in_use, I810_BUF_CLIENT, I810_BUF_FREE, failed); if(failed) { DRM_ERROR("Freeing buffer thats not in use : %d\n", buf->idx); - DRM_OS_RETURN( EINVAL ); + return DRM_ERR( EINVAL ); } return 0; @@ -130,7 +130,7 @@ static int i810_freelist_put(drm_device_t *dev, drm_buf_t *buf) #if 0 int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_i810_private_t *dev_priv; drm_buf_t *buf; drm_i810_buf_priv_t *buf_priv; @@ -149,20 +149,20 @@ int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma) if (remap_page_range(vma->vm_start, VM_OFFSET(vma), vma->vm_end - vma->vm_start, - vma->vm_page_prot)) DRM_OS_RETURN(EAGAIN); + vma->vm_page_prot)) return DRM_ERR(EAGAIN); return 0; } #endif static int i810_map_buffer(drm_buf_t *buf, struct file *filp) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_i810_buf_priv_t *buf_priv = buf->dev_private; drm_i810_private_t *dev_priv = dev->dev_private; struct file_operations *old_fops; int retcode = 0; - if(buf_priv->currently_mapped == I810_BUF_MAPPED) DRM_OS_RETURN(EINVAL); + if(buf_priv->currently_mapped == I810_BUF_MAPPED) return DRM_ERR(EINVAL); if(VM_DONTCOPY != 0) { #if LINUX_VERSION_CODE <= 0x020402 @@ -204,7 +204,7 @@ static int i810_unmap_buffer(drm_buf_t *buf) if(VM_DONTCOPY != 0) { if(buf_priv->currently_mapped != I810_BUF_MAPPED) - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); #if LINUX_VERSION_CODE <= 0x020402 down( ¤t->mm->mmap_sem ); #else @@ -237,7 +237,7 @@ static int i810_dma_get_buffer(drm_device_t *dev, drm_i810_dma_t *d, if (!buf) { retcode = -ENOMEM; DRM_DEBUG("retcode=%d\n", retcode); - DRM_OS_RETURN(retcode); + return DRM_ERR(retcode); } retcode = i810_map_buffer(buf, filp); @@ -277,7 +277,7 @@ static void i810_free_page(drm_device_t *dev, unsigned long page) atomic_dec(&virt_to_page(page)->count); clear_bit(PG_locked, &virt_to_page(page)->flags); - DRM_OS_WAKEUP(&virt_to_page(page)->wait); + DRM_WAKEUP(&virt_to_page(page)->wait); free_page(page); return; } @@ -366,7 +366,7 @@ static int i810_freelist_init(drm_device_t *dev, drm_i810_private_t *dev_priv) if(dma->buf_count > 1019) { /* Not enough space in the status page for the freelist */ - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } for (i = 0; i < dma->buf_count; i++) { @@ -406,21 +406,21 @@ static int i810_dma_initialize(drm_device_t *dev, dev->dev_private = (void *)dev_priv; i810_dma_cleanup(dev); DRM_ERROR("can not find sarea!\n"); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } DRM_FIND_MAP( dev_priv->mmio_map, init->mmio_offset ); if(!dev_priv->mmio_map) { dev->dev_private = (void *)dev_priv; i810_dma_cleanup(dev); DRM_ERROR("can not find mmio map!\n"); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } DRM_FIND_MAP( dev_priv->buffer_map, init->buffers_offset ); if(!dev_priv->buffer_map) { dev->dev_private = (void *)dev_priv; i810_dma_cleanup(dev); DRM_ERROR("can not find dma buffer map!\n"); - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } dev_priv->sarea_priv = (drm_i810_sarea_t *) @@ -443,7 +443,7 @@ static int i810_dma_initialize(drm_device_t *dev, i810_dma_cleanup(dev); DRM_ERROR("can not ioremap virtual address for" " ring buffer\n"); - DRM_OS_RETURN(ENOMEM); + return DRM_ERR(ENOMEM); } dev_priv->ring.tail_mask = dev_priv->ring.Size - 1; @@ -464,7 +464,7 @@ static int i810_dma_initialize(drm_device_t *dev, dev->dev_private = (void *)dev_priv; i810_dma_cleanup(dev); DRM_ERROR("Can not allocate hardware status page\n"); - DRM_OS_RETURN(ENOMEM); + return DRM_ERR(ENOMEM); } memset((void *) dev_priv->hw_status_page, 0, PAGE_SIZE); DRM_DEBUG("hw status page @ %lx\n", dev_priv->hw_status_page); @@ -478,27 +478,27 @@ static int i810_dma_initialize(drm_device_t *dev, i810_dma_cleanup(dev); DRM_ERROR("Not enough space in the status page for" " the freelist\n"); - DRM_OS_RETURN(ENOMEM); + return DRM_ERR(ENOMEM); } dev->dev_private = (void *)dev_priv; return 0; } -int i810_dma_init( DRM_OS_IOCTL ) +int i810_dma_init( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_i810_private_t *dev_priv; drm_i810_init_t init; int retcode = 0; - DRM_OS_KRNFROMUSR( init, (drm_i810_init_t *) data, sizeof(init) ); + DRM_COPY_FROM_USER_IOCTL( init, (drm_i810_init_t *) data, sizeof(init) ); switch(init.func) { case I810_INIT_DMA: dev_priv = DRM(alloc)(sizeof(drm_i810_private_t), DRM_MEM_DRIVER); - if(dev_priv == NULL) DRM_OS_RETURN(ENOMEM); + if(dev_priv == NULL) return DRM_ERR(ENOMEM); retcode = i810_dma_initialize(dev, dev_priv, &init); break; case I810_CLEANUP_DMA: @@ -509,7 +509,7 @@ int i810_dma_init( DRM_OS_IOCTL ) break; } - DRM_OS_RETURN(retcode); + return DRM_ERR(retcode); } @@ -899,7 +899,7 @@ void i810_dma_immediate_bh(void *device) drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; atomic_set(&dev_priv->flush_done, 1); - DRM_OS_WAKEUP_INT(&dev_priv->flush_queue); + DRM_WAKEUP_INT(&dev_priv->flush_queue); } static inline void i810_dma_emit_flush(drm_device_t *dev) @@ -916,7 +916,7 @@ static inline void i810_dma_emit_flush(drm_device_t *dev) /* i810_wait_ring( dev, dev_priv->ring.Size - 8 ); */ /* atomic_set(&dev_priv->flush_done, 1); */ -/* DRM_OS_WAKEUP_INT(&dev_priv->flush_queue); */ +/* DRM_WAKEUP_INT(&dev_priv->flush_queue); */ } static inline void i810_dma_quiescent_emit(drm_device_t *dev) @@ -935,7 +935,7 @@ static inline void i810_dma_quiescent_emit(drm_device_t *dev) /* i810_wait_ring( dev, dev_priv->ring.Size - 8 ); */ /* atomic_set(&dev_priv->flush_done, 1); */ -/* DRM_OS_WAKEUP_INT(&dev_priv->flush_queue); */ +/* DRM_WAKEUP_INT(&dev_priv->flush_queue); */ } void i810_dma_quiescent(drm_device_t *dev) @@ -1051,14 +1051,14 @@ void i810_reclaim_buffers(drm_device_t *dev, pid_t pid) } } -int i810_flush_ioctl( DRM_OS_IOCTL ) +int i810_flush_ioctl( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; DRM_DEBUG("i810_flush_ioctl\n"); if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("i810_flush_ioctl called without lock held\n"); - DRM_OS_RETURN( EINVAL ); + return DRM_ERR( EINVAL ); } i810_flush_queue(dev); @@ -1066,9 +1066,9 @@ int i810_flush_ioctl( DRM_OS_IOCTL ) } -int i810_dma_vertex( DRM_OS_IOCTL ) +int i810_dma_vertex( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_device_dma_t *dma = dev->dma; drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; u32 *hw_status = (u32 *)dev_priv->hw_status_page; @@ -1076,17 +1076,17 @@ int i810_dma_vertex( DRM_OS_IOCTL ) dev_priv->sarea_priv; drm_i810_vertex_t vertex; - DRM_OS_KRNFROMUSR( vertex, (drm_i810_vertex_t *) data, sizeof(vertex) ); + DRM_COPY_FROM_USER_IOCTL( vertex, (drm_i810_vertex_t *) data, sizeof(vertex) ); if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("i810_dma_vertex called without lock held\n"); - DRM_OS_RETURN( EINVAL ); + return DRM_ERR( EINVAL ); } DRM_DEBUG("i810 dma vertex, idx %d used %d discard %d\n", vertex.idx, vertex.used, vertex.discard); - if(vertex.idx < 0 || vertex.idx > dma->buf_count) DRM_OS_RETURN(EINVAL); + if(vertex.idx < 0 || vertex.idx > dma->buf_count) return DRM_ERR(EINVAL); i810_dma_dispatch_vertex( dev, dma->buflist[ vertex.idx ], @@ -1102,21 +1102,21 @@ int i810_dma_vertex( DRM_OS_IOCTL ) -int i810_clear_bufs( DRM_OS_IOCTL ) +int i810_clear_bufs( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_i810_clear_t clear; - DRM_OS_KRNFROMUSR( clear, (drm_i810_clear_t *) data, sizeof(clear) ); + DRM_COPY_FROM_USER_IOCTL( clear, (drm_i810_clear_t *) data, sizeof(clear) ); if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("i810_clear_bufs called without lock held\n"); - DRM_OS_RETURN( EINVAL ); + return DRM_ERR( EINVAL ); } /* GH: Someone's doing nasty things... */ if (!dev->dev_private) { - DRM_OS_RETURN(EINVAL); + return DRM_ERR(EINVAL); } i810_dma_dispatch_clear( dev, clear.flags, @@ -1125,24 +1125,24 @@ int i810_clear_bufs( DRM_OS_IOCTL ) return 0; } -int i810_swap_bufs( DRM_OS_IOCTL ) +int i810_swap_bufs( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; DRM_DEBUG("i810_swap_bufs\n"); if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("i810_swap_buf called without lock held\n"); - DRM_OS_RETURN( EINVAL ); + return DRM_ERR( EINVAL ); } i810_dma_dispatch_swap( dev ); return 0; } -int i810_getage( DRM_OS_IOCTL ) +int i810_getage( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; u32 *hw_status = (u32 *)dev_priv->hw_status_page; drm_i810_sarea_t *sarea_priv = (drm_i810_sarea_t *) @@ -1152,9 +1152,9 @@ int i810_getage( DRM_OS_IOCTL ) return 0; } -int i810_getbuf( DRM_OS_IOCTL ) +int i810_getbuf( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; int retcode = 0; drm_i810_dma_t d; drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; @@ -1163,11 +1163,11 @@ int i810_getbuf( DRM_OS_IOCTL ) dev_priv->sarea_priv; DRM_DEBUG("getbuf\n"); - DRM_OS_KRNFROMUSR( d, (drm_i810_dma_t *) data, sizeof(d) ); + DRM_COPY_FROM_USER_IOCTL( d, (drm_i810_dma_t *) data, sizeof(d) ); if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("i810_dma called without lock held\n"); - DRM_OS_RETURN( EINVAL ); + return DRM_ERR( EINVAL ); } d.granted = 0; @@ -1175,17 +1175,17 @@ int i810_getbuf( DRM_OS_IOCTL ) retcode = i810_dma_get_buffer(dev, &d, filp); DRM_DEBUG("i810_dma: %d returning %d, granted = %d\n", - DRM_OS_CURRENTPID, retcode, d.granted); + DRM_CURRENTPID, retcode, d.granted); - DRM_OS_KRNTOUSR( (drm_dma_t *) data, d, sizeof(d) ); + DRM_COPY_TO_USER_IOCTL( (drm_dma_t *) data, d, sizeof(d) ); sarea_priv->last_dispatch = (int) hw_status[5]; - DRM_OS_RETURN(retcode); + return DRM_ERR(retcode); } -int i810_copybuf( DRM_OS_IOCTL ) +int i810_copybuf( DRM_IOCTL_ARGS ) { - DRM_OS_DEVICE; + DRM_DEVICE; drm_i810_copy_t d; drm_i810_private_t *dev_priv = (drm_i810_private_t *)dev->dev_private; u32 *hw_status = (u32 *)dev_priv->hw_status_page; @@ -1197,26 +1197,26 @@ int i810_copybuf( DRM_OS_IOCTL ) if(!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock)) { DRM_ERROR("i810_dma called without lock held\n"); - DRM_OS_RETURN( EINVAL ); + return DRM_ERR( EINVAL ); } - DRM_OS_KRNFROMUSR( d, (drm_i810_copy_t *) data, sizeof(d) ); + DRM_COPY_FROM_USER_IOCTL( d, (drm_i810_copy_t *) data, sizeof(d) ); - if(d.idx < 0 || d.idx > dma->buf_count) DRM_OS_RETURN(EINVAL); + if(d.idx < 0 || d.idx > dma->buf_count) return DRM_ERR(EINVAL); buf = dma->buflist[ d.idx ]; buf_priv = buf->dev_private; - if (buf_priv->currently_mapped != I810_BUF_MAPPED) DRM_OS_RETURN(EPERM); - if(d.used < 0 || d.used > buf->total) DRM_OS_RETURN(EINVAL); + if (buf_priv->currently_mapped != I810_BUF_MAPPED) return DRM_ERR(EPERM); + if(d.used < 0 || d.used > buf->total) return DRM_ERR(EINVAL); - if (DRM_OS_COPYFROMUSR(buf_priv->virtual, d.address, d.used)) - DRM_OS_RETURN( EFAULT ); + if (DRM_COPY_FROM_USER(buf_priv->virtual, d.address, d.used)) + return DRM_ERR( EFAULT ); sarea_priv->last_dispatch = (int) hw_status[5]; return 0; } -int i810_docopy( DRM_OS_IOCTL ) +int i810_docopy( DRM_IOCTL_ARGS ) { if(VM_DONTCOPY == 0) return 1; return 0; diff --git a/bsd/i810_drv.h b/bsd/i810_drv.h index 7f65f1e8..ae7018d2 100644 --- a/bsd/i810_drv.h +++ b/bsd/i810_drv.h @@ -79,22 +79,22 @@ typedef struct drm_i810_private { /* i810_dma.c */ extern int i810_dma_schedule(drm_device_t *dev, int locked); -extern int i810_getbuf( DRM_OS_IOCTL ); -extern int i810_dma_init( DRM_OS_IOCTL ); -extern int i810_flush_ioctl( DRM_OS_IOCTL ); -extern int i810_getage( DRM_OS_IOCTL ); +extern int i810_getbuf( DRM_IOCTL_ARGS ); +extern int i810_dma_init( DRM_IOCTL_ARGS ); +extern int i810_flush_ioctl( DRM_IOCTL_ARGS ); +extern int i810_getage( DRM_IOCTL_ARGS ); extern int i810_mmap_buffers(struct file *filp, struct vm_area_struct *vma); -extern int i810_copybuf( DRM_OS_IOCTL ); -extern int i810_docopy( DRM_OS_IOCTL ); +extern int i810_copybuf( DRM_IOCTL_ARGS ); +extern int i810_docopy( DRM_IOCTL_ARGS ); extern void i810_dma_quiescent(drm_device_t *dev); #define I810_VERBOSE 0 -int i810_dma_vertex( DRM_OS_IOCTL ); -int i810_swap_bufs( DRM_OS_IOCTL ); -int i810_clear_bufs( DRM_OS_IOCTL ); +int i810_dma_vertex( DRM_IOCTL_ARGS ); +int i810_swap_bufs( DRM_IOCTL_ARGS ); +int i810_clear_bufs( DRM_IOCTL_ARGS ); #define I810_BASE(reg) ((unsigned long) \ dev_priv->mmio_map->handle) diff --git a/bsd/sis_drm.h b/bsd/sis_drm.h index 21b66350..8b88c507 100644 --- a/bsd/sis_drm.h +++ b/bsd/sis_drm.h @@ -29,11 +29,11 @@ typedef struct { #if defined(__KERNEL__) || defined(_KERNEL) -int sis_fb_alloc(DRM_OS_IOCTL); -int sis_fb_free(DRM_OS_IOCTL); -int sisp_agp_init(DRM_OS_IOCTL); -int sisp_agp_alloc(DRM_OS_IOCTL); -int sisp_agp_free(DRM_OS_IOCTL); +int sis_fb_alloc(DRM_IOCTL_ARGS); +int sis_fb_free(DRM_IOCTL_ARGS); +int sisp_agp_init(DRM_IOCTL_ARGS); +int sisp_agp_alloc(DRM_IOCTL_ARGS); +int sisp_agp_free(DRM_IOCTL_ARGS); #endif |