summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorEric Anholt <anholt@freebsd.org>2002-06-27 22:41:08 +0000
committerEric Anholt <anholt@freebsd.org>2002-06-27 22:41:08 +0000
commit563bc3158dfc6260a5ae159deab575b469be1167 (patch)
treec246c3cd09d8188921481139ecd2248f85cb2d1d
parent54fca8169634fbcb41cbf12007946777bcb8623e (diff)
os-independent interface name changes (mostly DRM_OS_* -> DRM_)
Suggested by: keithw
-rw-r--r--bsd-core/ati_pcigart.c2
-rw-r--r--bsd-core/drmP.h14
-rw-r--r--bsd-core/drm_agpsupport.c44
-rw-r--r--bsd-core/drm_auth.c42
-rw-r--r--bsd-core/drm_bufs.c274
-rw-r--r--bsd-core/drm_context.c188
-rw-r--r--bsd-core/drm_dma.c66
-rw-r--r--bsd-core/drm_drawable.c6
-rw-r--r--bsd-core/drm_drv.c106
-rw-r--r--bsd-core/drm_fops.c22
-rw-r--r--bsd-core/drm_ioctl.c76
-rw-r--r--bsd-core/drm_lock.c14
-rw-r--r--bsd-core/drm_memory.c84
-rw-r--r--bsd-core/drm_os_freebsd.h96
-rw-r--r--bsd-core/drm_os_netbsd.h78
-rw-r--r--bsd-core/drm_scatter.c22
-rw-r--r--bsd-core/drm_sysctl.c24
-rw-r--r--bsd-core/drm_vm.c10
-rw-r--r--bsd/ati_pcigart.h2
-rw-r--r--bsd/drmP.h14
-rw-r--r--bsd/drm_agpsupport.h44
-rw-r--r--bsd/drm_auth.h42
-rw-r--r--bsd/drm_bufs.h274
-rw-r--r--bsd/drm_context.h188
-rw-r--r--bsd/drm_dma.h66
-rw-r--r--bsd/drm_drawable.h6
-rw-r--r--bsd/drm_drv.h106
-rw-r--r--bsd/drm_fops.h22
-rw-r--r--bsd/drm_ioctl.h76
-rw-r--r--bsd/drm_lists.h36
-rw-r--r--bsd/drm_lock.h14
-rw-r--r--bsd/drm_memory.h84
-rw-r--r--bsd/drm_os_freebsd.h96
-rw-r--r--bsd/drm_os_netbsd.h78
-rw-r--r--bsd/drm_scatter.h22
-rw-r--r--bsd/drm_sysctl.h24
-rw-r--r--bsd/drm_vm.h10
-rw-r--r--bsd/gamma_dma.c56
-rw-r--r--bsd/gamma_drv.h6
-rw-r--r--bsd/i810_dma.c116
-rw-r--r--bsd/i810_drv.h18
-rw-r--r--bsd/sis_drm.h10
-rw-r--r--linux-core/drm_os_linux.h51
-rw-r--r--linux/drm_os_linux.h51
-rw-r--r--shared-core/mga_dma.c82
-rw-r--r--shared-core/mga_drv.h36
-rw-r--r--shared-core/mga_state.c60
-rw-r--r--shared-core/mga_warp.c10
-rw-r--r--shared-core/r128_cce.c122
-rw-r--r--shared-core/r128_drv.h54
-rw-r--r--shared-core/r128_state.c264
-rw-r--r--shared-core/radeon_cp.c110
-rw-r--r--shared-core/radeon_drv.h66
-rw-r--r--shared-core/radeon_state.c236
-rw-r--r--shared/mga_dma.c82
-rw-r--r--shared/mga_drv.h36
-rw-r--r--shared/mga_state.c60
-rw-r--r--shared/mga_warp.c10
-rw-r--r--shared/r128_cce.c122
-rw-r--r--shared/r128_drv.h54
-rw-r--r--shared/r128_state.c264
-rw-r--r--shared/radeon_cp.c110
-rw-r--r--shared/radeon_drv.h66
-rw-r--r--shared/radeon_state.c236
64 files changed, 2375 insertions, 2385 deletions
diff --git a/bsd-core/ati_pcigart.c b/bsd-core/ati_pcigart.c
index ca61e6dd..28723f56 100644
--- a/bsd-core/ati_pcigart.c
+++ b/bsd-core/ati_pcigart.c
@@ -122,7 +122,7 @@ int DRM(ati_pcigart_init)( drm_device_t *dev,
ret = 1;
- DRM_OS_READMEMORYBARRIER();
+ DRM_READMEMORYBARRIER();
done:
*addr = address;
diff --git a/bsd-core/drmP.h b/bsd-core/drmP.h
index 69a7f6cb..f323e8ef 100644
--- a/bsd-core/drmP.h
+++ b/bsd-core/drmP.h
@@ -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-core/drm_agpsupport.c b/bsd-core/drm_agpsupport.c
index 4958fd5f..66de1053 100644
--- a/bsd-core/drm_agpsupport.c
+++ b/bsd-core/drm_agpsupport.c
@@ -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-core/drm_auth.c b/bsd-core/drm_auth.c
index c08f8cb3..0b411d14 100644
--- a/bsd-core/drm_auth.c
+++ b/bsd-core/drm_auth.c
@@ -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-core/drm_bufs.c b/bsd-core/drm_bufs.c
index 5f813bd8..46dc1c9a 100644
--- a/bsd-core/drm_bufs.c
+++ b/bsd-core/drm_bufs.c
@@ -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-core/drm_context.c b/bsd-core/drm_context.c
index d572a9de..0274a8b7 100644
--- a/bsd-core/drm_context.c
+++ b/bsd-core/drm_context.c
@@ -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-core/drm_dma.c b/bsd-core/drm_dma.c
index 0087f4f1..3e4a5e17 100644
--- a/bsd-core/drm_dma.c
+++ b/bsd-core/drm_dma.c
@@ -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-core/drm_drawable.c b/bsd-core/drm_drawable.c
index f43149d6..30841067 100644
--- a/bsd-core/drm_drawable.c
+++ b/bsd-core/drm_drawable.c
@@ -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-core/drm_drv.c b/bsd-core/drm_drv.c
index 06f1578a..8d2e5864 100644
--- a/bsd-core/drm_drv.c
+++ b/bsd-core/drm_drv.c
@@ -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-core/drm_fops.c b/bsd-core/drm_fops.c
index ee29e3a0..ed85a8de 100644
--- a/bsd-core/drm_fops.c
+++ b/bsd-core/drm_fops.c
@@ -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-core/drm_ioctl.c b/bsd-core/drm_ioctl.c
index 19b1121b..63562fef 100644
--- a/bsd-core/drm_ioctl.c
+++ b/bsd-core/drm_ioctl.c
@@ -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-core/drm_lock.c b/bsd-core/drm_lock.c
index 305aad96..5e9294bc 100644
--- a/bsd-core/drm_lock.c
+++ b/bsd-core/drm_lock.c
@@ -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-core/drm_memory.c b/bsd-core/drm_memory.c
index 06301696..f7dc547a 100644
--- a/bsd-core/drm_memory.c
+++ b/bsd-core/drm_memory.c
@@ -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-core/drm_os_freebsd.h b/bsd-core/drm_os_freebsd.h
index 83c246ae..2f5345db 100644
--- a/bsd-core/drm_os_freebsd.h
+++ b/bsd-core/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-core/drm_os_netbsd.h b/bsd-core/drm_os_netbsd.h
index 5470d428..2082c047 100644
--- a/bsd-core/drm_os_netbsd.h
+++ b/bsd-core/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-core/drm_scatter.c b/bsd-core/drm_scatter.c
index 17c9998d..c16b7c05 100644
--- a/bsd-core/drm_scatter.c
+++ b/bsd-core/drm_scatter.c
@@ -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-core/drm_sysctl.c b/bsd-core/drm_sysctl.c
index 82ca2833..c8aa9914 100644
--- a/bsd-core/drm_sysctl.c
+++ b/bsd-core/drm_sysctl.c
@@ -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-core/drm_vm.c b/bsd-core/drm_vm.c
index ada9f1eb..70a5b0e6 100644
--- a/bsd-core/drm_vm.c
+++ b/bsd-core/drm_vm.c
@@ -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/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;
diff --git a/bsd/drmP.h b/bsd/drmP.h
index 69a7f6cb..f323e8ef 100644
--- a/bsd/drmP.h
+++ b/bsd/drmP.h
@@ -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( &current->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
diff --git a/linux-core/drm_os_linux.h b/linux-core/drm_os_linux.h
index 7ba5029b..8c073f0b 100644
--- a/linux-core/drm_os_linux.h
+++ b/linux-core/drm_os_linux.h
@@ -1,49 +1,47 @@
#define __NO_VERSION__
-
#include <linux/interrupt.h> /* For task queue support */
#include <linux/delay.h>
-#define DRM_OS_IOCTL struct inode *inode, struct file *filp, unsigned int cmd, unsigned long data
-#define DRM_OS_RETURN(d) return -(d)
-#define DRM_OS_ERR(d) -(d)
-#define DRM_OS_CURRENTPID current->pid
-#define DRM_OS_DELAY(d) udelay(d)
-#define DRM_OS_READ8(addr) readb(addr)
-#define DRM_OS_READ32(addr) readl(addr)
-#define DRM_OS_WRITE8(addr, val) writeb(val, addr)
-#define DRM_OS_WRITE32(addr, val) writel(val, addr)
-#define DRM_OS_READMEMORYBARRIER() mb()
-#define DRM_OS_WRITEMEMORYBARRIER() wmb()
-#define DRM_OS_DEVICE drm_file_t *priv = filp->private_data; \
+#define DRM_IOCTL_ARGS struct inode *inode, struct file *filp, unsigned int cmd, unsigned long data
+#define DRM_ERR(d) -(d)
+#define DRM_CURRENTPID current->pid
+#define DRM_UDELAY(d) udelay(d)
+#define DRM_READ8(addr) readb(addr)
+#define DRM_READ32(addr) readl(addr)
+#define DRM_WRITE8(addr, val) writeb(val, addr)
+#define DRM_WRITE32(addr, val) writel(val, addr)
+#define DRM_READMEMORYBARRIER() mb()
+#define DRM_WRITEMEMORYBARRIER() wmb()
+#define DRM_DEVICE drm_file_t *priv = filp->private_data; \
drm_device_t *dev = priv->dev
/* For data going from/to the kernel through the ioctl argument */
-#define DRM_OS_KRNFROMUSR(arg1, arg2, arg3) \
- if ( copy_from_user(&arg1, arg2, arg3) ) \
+#define DRM_COPY_FROM_USER_IOCTL(arg1, arg2, arg3) \
+ if ( copy_from_user(&arg1, arg2, arg3) ) \
return -EFAULT
-#define DRM_OS_KRNTOUSR(arg1, arg2, arg3) \
- if ( copy_to_user(arg1, &arg2, arg3) ) \
+#define DRM_COPY_TO_USER_IOCTL(arg1, arg2, arg3) \
+ if ( copy_to_user(arg1, &arg2, arg3) ) \
return -EFAULT
/* Other copying of data from/to kernel space */
-#define DRM_OS_COPYFROMUSR(arg1, arg2, arg3) \
+#define DRM_COPY_FROM_USER(arg1, arg2, arg3) \
copy_from_user(arg1, arg2, arg3)
-#define DRM_OS_COPYTOUSR(arg1, arg2, arg3) \
+#define DRM_COPY_TO_USER(arg1, arg2, arg3) \
copy_to_user(arg1, arg2, arg3)
-/* Macros for checking readability once */
-#define DRM_OS_VERIFYAREA_READ( uaddr, size ) \
+/* Macros for copyfrom user, but checking readability only once */
+#define DRM_VERIFYAREA_READ( uaddr, size ) \
verify_area( VERIFY_READ, uaddr, size )
-#define DRM_OS_COPYFROMUSR_NC(arg1, arg2, arg3) \
+#define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \
__copy_from_user(arg1, arg2, arg3)
-#define DRM_OS_FETCHU_32_NC(val, uaddr) \
+#define DRM_GET_USER_UNCHECKED(val, uaddr) \
__get_user(val, uaddr)
/* malloc/free without the overhead of DRM(alloc) */
-#define DRM_OS_MALLOC(x) kmalloc(x, GFP_KERNEL)
-#define DRM_OS_FREE(x) kfree(x)
+#define DRM_MALLOC(x) kmalloc(x, GFP_KERNEL)
+#define DRM_FREE(x) kfree(x)
-#define DRM_OS_GETSAREA() \
+#define DRM_GETSAREA() \
do { \
struct list_head *list; \
list_for_each( list, &dev->maplist->head ) { \
@@ -56,4 +54,3 @@ do { \
} \
} \
} while (0)
-
diff --git a/linux/drm_os_linux.h b/linux/drm_os_linux.h
index 7ba5029b..8c073f0b 100644
--- a/linux/drm_os_linux.h
+++ b/linux/drm_os_linux.h
@@ -1,49 +1,47 @@
#define __NO_VERSION__
-
#include <linux/interrupt.h> /* For task queue support */
#include <linux/delay.h>
-#define DRM_OS_IOCTL struct inode *inode, struct file *filp, unsigned int cmd, unsigned long data
-#define DRM_OS_RETURN(d) return -(d)
-#define DRM_OS_ERR(d) -(d)
-#define DRM_OS_CURRENTPID current->pid
-#define DRM_OS_DELAY(d) udelay(d)
-#define DRM_OS_READ8(addr) readb(addr)
-#define DRM_OS_READ32(addr) readl(addr)
-#define DRM_OS_WRITE8(addr, val) writeb(val, addr)
-#define DRM_OS_WRITE32(addr, val) writel(val, addr)
-#define DRM_OS_READMEMORYBARRIER() mb()
-#define DRM_OS_WRITEMEMORYBARRIER() wmb()
-#define DRM_OS_DEVICE drm_file_t *priv = filp->private_data; \
+#define DRM_IOCTL_ARGS struct inode *inode, struct file *filp, unsigned int cmd, unsigned long data
+#define DRM_ERR(d) -(d)
+#define DRM_CURRENTPID current->pid
+#define DRM_UDELAY(d) udelay(d)
+#define DRM_READ8(addr) readb(addr)
+#define DRM_READ32(addr) readl(addr)
+#define DRM_WRITE8(addr, val) writeb(val, addr)
+#define DRM_WRITE32(addr, val) writel(val, addr)
+#define DRM_READMEMORYBARRIER() mb()
+#define DRM_WRITEMEMORYBARRIER() wmb()
+#define DRM_DEVICE drm_file_t *priv = filp->private_data; \
drm_device_t *dev = priv->dev
/* For data going from/to the kernel through the ioctl argument */
-#define DRM_OS_KRNFROMUSR(arg1, arg2, arg3) \
- if ( copy_from_user(&arg1, arg2, arg3) ) \
+#define DRM_COPY_FROM_USER_IOCTL(arg1, arg2, arg3) \
+ if ( copy_from_user(&arg1, arg2, arg3) ) \
return -EFAULT
-#define DRM_OS_KRNTOUSR(arg1, arg2, arg3) \
- if ( copy_to_user(arg1, &arg2, arg3) ) \
+#define DRM_COPY_TO_USER_IOCTL(arg1, arg2, arg3) \
+ if ( copy_to_user(arg1, &arg2, arg3) ) \
return -EFAULT
/* Other copying of data from/to kernel space */
-#define DRM_OS_COPYFROMUSR(arg1, arg2, arg3) \
+#define DRM_COPY_FROM_USER(arg1, arg2, arg3) \
copy_from_user(arg1, arg2, arg3)
-#define DRM_OS_COPYTOUSR(arg1, arg2, arg3) \
+#define DRM_COPY_TO_USER(arg1, arg2, arg3) \
copy_to_user(arg1, arg2, arg3)
-/* Macros for checking readability once */
-#define DRM_OS_VERIFYAREA_READ( uaddr, size ) \
+/* Macros for copyfrom user, but checking readability only once */
+#define DRM_VERIFYAREA_READ( uaddr, size ) \
verify_area( VERIFY_READ, uaddr, size )
-#define DRM_OS_COPYFROMUSR_NC(arg1, arg2, arg3) \
+#define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \
__copy_from_user(arg1, arg2, arg3)
-#define DRM_OS_FETCHU_32_NC(val, uaddr) \
+#define DRM_GET_USER_UNCHECKED(val, uaddr) \
__get_user(val, uaddr)
/* malloc/free without the overhead of DRM(alloc) */
-#define DRM_OS_MALLOC(x) kmalloc(x, GFP_KERNEL)
-#define DRM_OS_FREE(x) kfree(x)
+#define DRM_MALLOC(x) kmalloc(x, GFP_KERNEL)
+#define DRM_FREE(x) kfree(x)
-#define DRM_OS_GETSAREA() \
+#define DRM_GETSAREA() \
do { \
struct list_head *list; \
list_for_each( list, &dev->maplist->head ) { \
@@ -56,4 +54,3 @@ do { \
} \
} \
} while (0)
-
diff --git a/shared-core/mga_dma.c b/shared-core/mga_dma.c
index 0802ba2f..1d64e1ca 100644
--- a/shared-core/mga_dma.c
+++ b/shared-core/mga_dma.c
@@ -59,14 +59,14 @@ int mga_do_wait_for_idle( drm_mga_private_t *dev_priv )
MGA_WRITE8( MGA_CRTC_INDEX, 0 );
return 0;
}
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if MGA_DMA_DEBUG
DRM_ERROR( "failed!\n" );
DRM_INFO( " status=0x%08x\n", status );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
int mga_do_dma_idle( drm_mga_private_t *dev_priv )
@@ -78,13 +78,13 @@ int mga_do_dma_idle( drm_mga_private_t *dev_priv )
for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) {
status = MGA_READ( MGA_STATUS ) & MGA_DMA_IDLE_MASK;
if ( status == MGA_ENDPRDMASTS ) return 0;
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if MGA_DMA_DEBUG
DRM_ERROR( "failed! status=0x%08x\n", status );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
int mga_do_dma_reset( drm_mga_private_t *dev_priv )
@@ -119,7 +119,7 @@ int mga_do_engine_reset( drm_mga_private_t *dev_priv )
* How about we clean up after ourselves?
*/
MGA_WRITE( MGA_RST, MGA_SOFTRESET );
- DRM_OS_DELAY( 15 ); /* Wait at least 10 usecs */
+ DRM_UDELAY( 15 ); /* Wait at least 10 usecs */
MGA_WRITE( MGA_RST, 0 );
/* Initialize the registers that get clobbered by the soft
@@ -302,7 +302,7 @@ static int mga_freelist_init( drm_device_t *dev, drm_mga_private_t *dev_priv )
dev_priv->head = DRM(alloc)( sizeof(drm_mga_freelist_t),
DRM_MEM_DRIVER );
if ( dev_priv->head == NULL )
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
memset( dev_priv->head, 0, sizeof(drm_mga_freelist_t) );
SET_AGE( &dev_priv->head->age, MGA_BUFFER_USED, 0 );
@@ -314,7 +314,7 @@ static int mga_freelist_init( drm_device_t *dev, drm_mga_private_t *dev_priv )
entry = DRM(alloc)( sizeof(drm_mga_freelist_t),
DRM_MEM_DRIVER );
if ( entry == NULL )
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
memset( entry, 0, sizeof(drm_mga_freelist_t) );
@@ -451,7 +451,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
dev_priv = DRM(alloc)( sizeof(drm_mga_private_t), DRM_MEM_DRIVER );
if ( !dev_priv )
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
memset( dev_priv, 0, sizeof(drm_mga_private_t) );
@@ -481,14 +481,14 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
dev_priv->texture_offset = init->texture_offset[0];
dev_priv->texture_size = init->texture_size[0];
- DRM_OS_GETSAREA();
+ DRM_GETSAREA();
if(!dev_priv->sarea) {
DRM_ERROR( "failed to find sarea!\n" );
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->fb, init->fb_offset );
@@ -497,7 +497,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset );
if(!dev_priv->mmio) {
@@ -505,7 +505,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->status, init->status_offset );
if(!dev_priv->status) {
@@ -513,7 +513,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->warp, init->warp_offset );
@@ -522,7 +522,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->primary, init->primary_offset );
if(!dev_priv->primary) {
@@ -530,7 +530,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
if(!dev_priv->buffers) {
@@ -538,7 +538,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
dev_priv->sarea_priv =
@@ -556,7 +556,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
ret = mga_warp_install_microcode( dev_priv );
@@ -618,7 +618,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
/* Make dev_private visable to others. */
@@ -649,12 +649,12 @@ int mga_do_cleanup_dma( drm_device_t *dev )
return 0;
}
-int mga_dma_init( DRM_OS_IOCTL )
+int mga_dma_init( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_mga_init_t init;
- DRM_OS_KRNFROMUSR( init, (drm_mga_init_t *)data, sizeof(init) );
+ DRM_COPY_FROM_USER_IOCTL( init, (drm_mga_init_t *)data, sizeof(init) );
switch ( init.func ) {
case MGA_INIT_DMA:
@@ -663,7 +663,7 @@ int mga_dma_init( DRM_OS_IOCTL )
return mga_do_cleanup_dma( dev );
}
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
@@ -671,15 +671,15 @@ int mga_dma_init( DRM_OS_IOCTL )
* Primary DMA stream management
*/
-int mga_dma_flush( DRM_OS_IOCTL )
+int mga_dma_flush( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
drm_lock_t lock;
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( lock, (drm_lock_t *)data, sizeof(lock) );
+ DRM_COPY_FROM_USER_IOCTL( lock, (drm_lock_t *)data, sizeof(lock) );
DRM_DEBUG( "%s%s%s\n",
(lock.flags & _DRM_LOCK_FLUSH) ? "flush, " : "",
@@ -706,9 +706,9 @@ int mga_dma_flush( DRM_OS_IOCTL )
}
}
-int mga_dma_reset( DRM_OS_IOCTL )
+int mga_dma_reset( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
LOCK_TEST_WITH_RETURN( dev );
@@ -728,25 +728,25 @@ static int mga_dma_get_buffers( drm_device_t *dev, drm_dma_t *d )
for ( i = d->granted_count ; i < d->request_count ; i++ ) {
buf = mga_freelist_get( dev );
- if ( !buf ) return DRM_OS_ERR(EAGAIN);
+ if ( !buf ) return DRM_ERR(EAGAIN);
- buf->pid = DRM_OS_CURRENTPID;
+ buf->pid = DRM_CURRENTPID;
- if ( DRM_OS_COPYTOUSR( &d->request_indices[i],
+ if ( DRM_COPY_TO_USER( &d->request_indices[i],
&buf->idx, sizeof(buf->idx) ) )
- return DRM_OS_ERR(EFAULT);
- if ( DRM_OS_COPYTOUSR( &d->request_sizes[i],
+ return DRM_ERR(EFAULT);
+ if ( DRM_COPY_TO_USER( &d->request_sizes[i],
&buf->total, sizeof(buf->total) ) )
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
d->granted_count++;
}
return 0;
}
-int mga_dma_buffers( DRM_OS_IOCTL )
+int mga_dma_buffers( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
drm_dma_t d;
@@ -754,22 +754,22 @@ int mga_dma_buffers( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( d, (drm_dma_t *)data, sizeof(d) );
+ DRM_COPY_FROM_USER_IOCTL( d, (drm_dma_t *)data, sizeof(d) );
/* Please don't send us buffers.
*/
if ( d.send_count != 0 ) {
DRM_ERROR( "Process %d trying to send %d buffers via drmDMA\n",
- DRM_OS_CURRENTPID, d.send_count );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, d.send_count );
+ return DRM_ERR(EINVAL);
}
/* We'll send you buffers.
*/
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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, d.request_count, dma->buf_count );
+ return DRM_ERR(EINVAL);
}
WRAP_TEST_WITH_RETURN( dev_priv );
@@ -780,7 +780,7 @@ int mga_dma_buffers( DRM_OS_IOCTL )
ret = mga_dma_get_buffers( dev, &d );
}
- DRM_OS_KRNTOUSR( (drm_dma_t *)data, d, sizeof(d) );
+ DRM_COPY_TO_USER_IOCTL( (drm_dma_t *)data, d, sizeof(d) );
return ret;
}
diff --git a/shared-core/mga_drv.h b/shared-core/mga_drv.h
index b922c663..d50c10ec 100644
--- a/shared-core/mga_drv.h
+++ b/shared-core/mga_drv.h
@@ -101,10 +101,10 @@ typedef struct drm_mga_private {
} drm_mga_private_t;
/* mga_dma.c */
-extern int mga_dma_init( DRM_OS_IOCTL );
-extern int mga_dma_flush( DRM_OS_IOCTL );
-extern int mga_dma_reset( DRM_OS_IOCTL );
-extern int mga_dma_buffers( DRM_OS_IOCTL );
+extern int mga_dma_init( DRM_IOCTL_ARGS );
+extern int mga_dma_flush( DRM_IOCTL_ARGS );
+extern int mga_dma_reset( DRM_IOCTL_ARGS );
+extern int mga_dma_buffers( DRM_IOCTL_ARGS );
extern int mga_do_wait_for_idle( drm_mga_private_t *dev_priv );
extern int mga_do_dma_idle( drm_mga_private_t *dev_priv );
@@ -119,18 +119,18 @@ extern void mga_do_dma_wrap_end( drm_mga_private_t *dev_priv );
extern int mga_freelist_put( drm_device_t *dev, drm_buf_t *buf );
/* mga_state.c */
-extern int mga_dma_clear( DRM_OS_IOCTL );
-extern int mga_dma_swap( DRM_OS_IOCTL );
-extern int mga_dma_vertex( DRM_OS_IOCTL );
-extern int mga_dma_indices( DRM_OS_IOCTL );
-extern int mga_dma_iload( DRM_OS_IOCTL );
-extern int mga_dma_blit( DRM_OS_IOCTL );
+extern int mga_dma_clear( DRM_IOCTL_ARGS );
+extern int mga_dma_swap( DRM_IOCTL_ARGS );
+extern int mga_dma_vertex( DRM_IOCTL_ARGS );
+extern int mga_dma_indices( DRM_IOCTL_ARGS );
+extern int mga_dma_iload( DRM_IOCTL_ARGS );
+extern int mga_dma_blit( DRM_IOCTL_ARGS );
/* mga_warp.c */
extern int mga_warp_install_microcode( drm_mga_private_t *dev_priv );
extern int mga_warp_init( drm_mga_private_t *dev_priv );
-#define mga_flush_write_combine() DRM_OS_WRITEMEMORYBARRIER()
+#define mga_flush_write_combine() DRM_WRITEMEMORYBARRIER()
#define MGA_BASE( reg ) ((unsigned long)(dev_priv->mmio->handle))
@@ -141,12 +141,12 @@ extern int mga_warp_init( drm_mga_private_t *dev_priv );
#ifdef __alpha__
#define MGA_READ( reg ) (_MGA_READ((u32 *)MGA_ADDR(reg)))
-#define MGA_WRITE( reg, val ) do { DRM_OS_WRITEMEMORYBARRIER(); MGA_DEREF( reg ) = val; } while (0)
-#define MGA_WRITE8( reg, val ) do { DRM_OS_WRITEMEMORYBARRIER(); MGA_DEREF8( reg ) = val; } while (0)
+#define MGA_WRITE( reg, val ) do { DRM_WRITEMEMORYBARRIER(); MGA_DEREF( reg ) = val; } while (0)
+#define MGA_WRITE8( reg, val ) do { DRM_WRITEMEMORYBARRIER(); MGA_DEREF8( reg ) = val; } while (0)
static inline u32 _MGA_READ(u32 *addr)
{
- DRM_OS_READMEMORYBARRIER();
+ DRM_READMEMORYBARRIER();
return *(volatile u32 *)addr;
}
@@ -186,10 +186,10 @@ do { \
#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", \
__func__ ); \
- return DRM_OS_ERR(EINVAL); \
+ return DRM_ERR(EINVAL); \
} \
} while (0)
@@ -202,7 +202,7 @@ do { \
dev_priv->prim.high_mark ) { \
if ( MGA_DMA_DEBUG ) \
DRM_INFO( "%s: wrap...\n", __func__ ); \
- return DRM_OS_ERR(EBUSY); \
+ return DRM_ERR(EBUSY); \
} \
} \
} while (0)
@@ -213,7 +213,7 @@ do { \
if ( mga_do_wait_for_idle( dev_priv ) < 0 ) { \
if ( MGA_DMA_DEBUG ) \
DRM_INFO( "%s: wrap...\n", __func__ ); \
- return DRM_OS_ERR(EBUSY); \
+ return DRM_ERR(EBUSY); \
} \
mga_do_dma_wrap_end( dev_priv ); \
} \
diff --git a/shared-core/mga_state.c b/shared-core/mga_state.c
index 4001d360..adf67de3 100644
--- a/shared-core/mga_state.c
+++ b/shared-core/mga_state.c
@@ -421,7 +421,7 @@ static int mga_verify_context( drm_mga_private_t *dev_priv )
ctx->dstorg, dev_priv->front_offset,
dev_priv->back_offset );
ctx->dstorg = 0;
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
return 0;
@@ -441,7 +441,7 @@ static int mga_verify_tex( drm_mga_private_t *dev_priv, int unit )
DRM_ERROR( "*** bad TEXORG: 0x%x, unit %d\n",
tex->texorg, unit );
tex->texorg = 0;
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
return 0;
@@ -483,13 +483,13 @@ static int mga_verify_iload( drm_mga_private_t *dev_priv,
dstorg + length > (dev_priv->texture_offset +
dev_priv->texture_size) ) {
DRM_ERROR( "*** bad iload DSTORG: 0x%x\n", dstorg );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( length & MGA_ILOAD_MASK ) {
DRM_ERROR( "*** bad iload length: 0x%x\n",
length & MGA_ILOAD_MASK );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
return 0;
@@ -502,7 +502,7 @@ static int mga_verify_blit( drm_mga_private_t *dev_priv,
(dstorg & 0x3) == (MGA_SRCACC_PCI | MGA_SRCMAP_SYSMEM) ) {
DRM_ERROR( "*** bad blit: src=0x%x dst=0x%x\n",
srcorg, dstorg );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
return 0;
}
@@ -881,16 +881,16 @@ static void mga_dma_dispatch_blit( drm_device_t *dev,
*
*/
-int mga_dma_clear( DRM_OS_IOCTL )
+int mga_dma_clear( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_mga_private_t *dev_priv = dev->dev_private;
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_mga_clear_t clear;
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( clear, (drm_mga_clear_t *)data, sizeof(clear) );
+ DRM_COPY_FROM_USER_IOCTL( clear, (drm_mga_clear_t *)data, sizeof(clear) );
if ( sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS )
sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
@@ -906,9 +906,9 @@ int mga_dma_clear( DRM_OS_IOCTL )
return 0;
}
-int mga_dma_swap( DRM_OS_IOCTL )
+int mga_dma_swap( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_mga_private_t *dev_priv = dev->dev_private;
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
@@ -928,9 +928,9 @@ int mga_dma_swap( DRM_OS_IOCTL )
return 0;
}
-int mga_dma_vertex( DRM_OS_IOCTL )
+int mga_dma_vertex( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_mga_private_t *dev_priv = dev->dev_private;
drm_device_dma_t *dma = dev->dma;
drm_buf_t *buf;
@@ -939,11 +939,11 @@ int mga_dma_vertex( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( vertex,
+ DRM_COPY_FROM_USER_IOCTL( vertex,
(drm_mga_vertex_t *)data,
sizeof(vertex) );
- if(vertex.idx < 0 || vertex.idx > dma->buf_count) return DRM_OS_ERR(EINVAL);
+ if(vertex.idx < 0 || vertex.idx > dma->buf_count) return DRM_ERR(EINVAL);
buf = dma->buflist[vertex.idx];
buf_priv = buf->dev_private;
@@ -957,7 +957,7 @@ int mga_dma_vertex( DRM_OS_IOCTL )
buf_priv->dispatched = 0;
mga_freelist_put( dev, buf );
}
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
WRAP_TEST_WITH_RETURN( dev_priv );
@@ -967,9 +967,9 @@ int mga_dma_vertex( DRM_OS_IOCTL )
return 0;
}
-int mga_dma_indices( DRM_OS_IOCTL )
+int mga_dma_indices( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_mga_private_t *dev_priv = dev->dev_private;
drm_device_dma_t *dma = dev->dma;
drm_buf_t *buf;
@@ -978,11 +978,11 @@ int mga_dma_indices( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( indices,
+ DRM_COPY_FROM_USER_IOCTL( indices,
(drm_mga_indices_t *)data,
sizeof(indices) );
- if(indices.idx < 0 || indices.idx > dma->buf_count) return DRM_OS_ERR(EINVAL);
+ if(indices.idx < 0 || indices.idx > dma->buf_count) return DRM_ERR(EINVAL);
buf = dma->buflist[indices.idx];
buf_priv = buf->dev_private;
@@ -996,7 +996,7 @@ int mga_dma_indices( DRM_OS_IOCTL )
buf_priv->dispatched = 0;
mga_freelist_put( dev, buf );
}
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
WRAP_TEST_WITH_RETURN( dev_priv );
@@ -1006,9 +1006,9 @@ int mga_dma_indices( DRM_OS_IOCTL )
return 0;
}
-int mga_dma_iload( DRM_OS_IOCTL )
+int mga_dma_iload( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
drm_mga_private_t *dev_priv = dev->dev_private;
drm_buf_t *buf;
@@ -1018,23 +1018,23 @@ int mga_dma_iload( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( iload, (drm_mga_iload_t *)data, sizeof(iload) );
+ DRM_COPY_FROM_USER_IOCTL( iload, (drm_mga_iload_t *)data, sizeof(iload) );
#if 0
if ( mga_do_wait_for_idle( dev_priv ) < 0 ) {
if ( MGA_DMA_DEBUG )
DRM_INFO( "%s: -EBUSY\n", __func__ );
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
#endif
- if(iload.idx < 0 || iload.idx > dma->buf_count) return DRM_OS_ERR(EINVAL);
+ if(iload.idx < 0 || iload.idx > dma->buf_count) return DRM_ERR(EINVAL);
buf = dma->buflist[iload.idx];
buf_priv = buf->dev_private;
if ( mga_verify_iload( dev_priv, iload.dstorg, iload.length ) ) {
mga_freelist_put( dev, buf );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
WRAP_TEST_WITH_RETURN( dev_priv );
@@ -1048,9 +1048,9 @@ int mga_dma_iload( DRM_OS_IOCTL )
return 0;
}
-int mga_dma_blit( DRM_OS_IOCTL )
+int mga_dma_blit( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_mga_private_t *dev_priv = dev->dev_private;
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_mga_blit_t blit;
@@ -1058,13 +1058,13 @@ int mga_dma_blit( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( blit, (drm_mga_blit_t *)data, sizeof(blit) );
+ DRM_COPY_FROM_USER_IOCTL( blit, (drm_mga_blit_t *)data, sizeof(blit) );
if ( sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS )
sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
if ( mga_verify_blit( dev_priv, blit.srcorg, blit.dstorg ) )
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
WRAP_TEST_WITH_RETURN( dev_priv );
diff --git a/shared-core/mga_warp.c b/shared-core/mga_warp.c
index 7bc1a010..ea7f53a6 100644
--- a/shared-core/mga_warp.c
+++ b/shared-core/mga_warp.c
@@ -107,7 +107,7 @@ static int mga_warp_install_g400_microcode( drm_mga_private_t *dev_priv )
if ( size > dev_priv->warp->size ) {
DRM_ERROR( "microcode too large! (%u > %lu)\n",
size, dev_priv->warp->size );
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
memset( dev_priv->warp_pipe_phys, 0,
@@ -144,7 +144,7 @@ static int mga_warp_install_g200_microcode( drm_mga_private_t *dev_priv )
if ( size > dev_priv->warp->size ) {
DRM_ERROR( "microcode too large! (%u > %lu)\n",
size, dev_priv->warp->size );
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
memset( dev_priv->warp_pipe_phys, 0,
@@ -170,7 +170,7 @@ int mga_warp_install_microcode( drm_mga_private_t *dev_priv )
case MGA_CARD_TYPE_G200:
return mga_warp_install_g200_microcode( dev_priv );
default:
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
}
@@ -195,7 +195,7 @@ int mga_warp_init( drm_mga_private_t *dev_priv )
MGA_WRITE( MGA_WVRTXSZ, 7 );
break;
default:
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
MGA_WRITE( MGA_WMISC, (MGA_WUCODECACHE_ENABLE |
@@ -205,7 +205,7 @@ int mga_warp_init( drm_mga_private_t *dev_priv )
if ( wmisc != WMISC_EXPECTED ) {
DRM_ERROR( "WARP engine config failed! 0x%x != 0x%x\n",
wmisc, WMISC_EXPECTED );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
return 0;
diff --git a/shared-core/r128_cce.c b/shared-core/r128_cce.c
index 7ff773ff..f52b9a67 100644
--- a/shared-core/r128_cce.c
+++ b/shared-core/r128_cce.c
@@ -126,13 +126,13 @@ static int r128_do_pixcache_flush( drm_r128_private_t *dev_priv )
if ( !(R128_READ( R128_PC_NGUI_CTLSTAT ) & R128_PC_BUSY) ) {
return 0;
}
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if R128_FIFO_DEBUG
DRM_ERROR( "failed!\n" );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
static int r128_do_wait_for_fifo( drm_r128_private_t *dev_priv, int entries )
@@ -142,13 +142,13 @@ static int r128_do_wait_for_fifo( drm_r128_private_t *dev_priv, int entries )
for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) {
int slots = R128_READ( R128_GUI_STAT ) & R128_GUI_FIFOCNT_MASK;
if ( slots >= entries ) return 0;
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if R128_FIFO_DEBUG
DRM_ERROR( "failed!\n" );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
int r128_do_wait_for_idle( drm_r128_private_t *dev_priv )
@@ -163,13 +163,13 @@ int r128_do_wait_for_idle( drm_r128_private_t *dev_priv )
r128_do_pixcache_flush( dev_priv );
return 0;
}
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if R128_FIFO_DEBUG
DRM_ERROR( "failed!\n" );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
@@ -223,14 +223,14 @@ int r128_do_cce_idle( drm_r128_private_t *dev_priv )
return r128_do_pixcache_flush( dev_priv );
}
}
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if R128_FIFO_DEBUG
DRM_ERROR( "failed!\n" );
r128_status( dev_priv );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
/* Start the Concurrent Command Engine.
@@ -378,7 +378,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
dev_priv = DRM(alloc)( sizeof(drm_r128_private_t), DRM_MEM_DRIVER );
if ( dev_priv == NULL )
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
memset( dev_priv, 0, sizeof(drm_r128_private_t) );
@@ -388,7 +388,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_ERROR( "PCI GART memory not allocated!\n" );
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
dev_priv->usec_timeout = init->usec_timeout;
@@ -397,7 +397,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_DEBUG( "TIMEOUT problem!\n" );
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
dev_priv->cce_mode = init->cce_mode;
@@ -417,7 +417,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_DEBUG( "Bad cce_mode!\n" );
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
switch ( init->cce_mode ) {
@@ -479,13 +479,13 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
dev_priv->span_pitch_offset_c = (((dev_priv->depth_pitch/8) << 21) |
(dev_priv->span_offset >> 5));
- DRM_OS_GETSAREA();
+ DRM_GETSAREA();
if(!dev_priv->sarea) {
DRM_ERROR("could not find sarea!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->fb, init->fb_offset );
@@ -493,35 +493,35 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_ERROR("could not find framebuffer!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset );
if(!dev_priv->mmio) {
DRM_ERROR("could not find mmio region!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->cce_ring, init->ring_offset );
if(!dev_priv->cce_ring) {
DRM_ERROR("could not find cce ring region!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->ring_rptr, init->ring_rptr_offset );
if(!dev_priv->ring_rptr) {
DRM_ERROR("could not find ring read pointer!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
if(!dev_priv->buffers) {
DRM_ERROR("could not find dma buffer region!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( !dev_priv->is_pci ) {
@@ -531,7 +531,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_ERROR("could not find agp texture region!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
}
@@ -549,7 +549,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_ERROR("Could not ioremap agp regions!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
} else {
dev_priv->cce_ring->handle =
@@ -594,7 +594,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_ERROR( "failed to init PCI GART!\n" );
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
R128_WRITE( R128_PCI_GART_PAGE, dev_priv->bus_pci_gart );
}
@@ -638,14 +638,14 @@ int r128_do_cleanup_cce( drm_device_t *dev )
return 0;
}
-int r128_cce_init( DRM_OS_IOCTL )
+int r128_cce_init( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_init_t init;
DRM_DEBUG( "\n" );
- DRM_OS_KRNFROMUSR( init, (drm_r128_init_t *)data, sizeof(init) );
+ DRM_COPY_FROM_USER_IOCTL( init, (drm_r128_init_t *)data, sizeof(init) );
switch ( init.func ) {
case R128_INIT_CCE:
@@ -654,12 +654,12 @@ int r128_cce_init( DRM_OS_IOCTL )
return r128_do_cleanup_cce( dev );
}
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
-int r128_cce_start( DRM_OS_IOCTL )
+int r128_cce_start( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
@@ -678,9 +678,9 @@ int r128_cce_start( DRM_OS_IOCTL )
/* Stop the CCE. The engine must have been idled before calling this
* routine.
*/
-int r128_cce_stop( DRM_OS_IOCTL )
+int r128_cce_stop( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_r128_cce_stop_t stop;
int ret;
@@ -688,7 +688,7 @@ int r128_cce_stop( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR(stop, (drm_r128_cce_stop_t *)data, sizeof(stop) );
+ DRM_COPY_FROM_USER_IOCTL(stop, (drm_r128_cce_stop_t *)data, sizeof(stop) );
/* Flush any pending CCE commands. This ensures any outstanding
* commands are exectuted by the engine before we turn it off.
@@ -719,9 +719,9 @@ int r128_cce_stop( DRM_OS_IOCTL )
/* Just reset the CCE ring. Called as part of an X Server engine reset.
*/
-int r128_cce_reset( DRM_OS_IOCTL )
+int r128_cce_reset( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
@@ -729,7 +729,7 @@ int r128_cce_reset( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_DEBUG( "%s called before init done\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
r128_do_cce_reset( dev_priv );
@@ -740,9 +740,9 @@ int r128_cce_reset( DRM_OS_IOCTL )
return 0;
}
-int r128_cce_idle( DRM_OS_IOCTL )
+int r128_cce_idle( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
@@ -755,9 +755,9 @@ int r128_cce_idle( DRM_OS_IOCTL )
return r128_do_cce_idle( dev_priv );
}
-int r128_engine_reset( DRM_OS_IOCTL )
+int r128_engine_reset( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
DRM_DEBUG( "\n" );
LOCK_TEST_WITH_RETURN( dev );
@@ -802,14 +802,14 @@ int r128_do_cleanup_pageflip( drm_device_t *dev )
return 0;
}
-int r128_fullscreen( DRM_OS_IOCTL )
+int r128_fullscreen( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_fullscreen_t fs;
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( fs, (drm_r128_fullscreen_t *)data, sizeof(fs) );
+ DRM_COPY_FROM_USER_IOCTL( fs, (drm_r128_fullscreen_t *)data, sizeof(fs) );
switch ( fs.func ) {
case R128_INIT_FULLSCREEN:
@@ -818,7 +818,7 @@ int r128_fullscreen( DRM_OS_IOCTL )
return r128_do_cleanup_pageflip( dev );
}
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
@@ -841,7 +841,7 @@ static int r128_freelist_init( drm_device_t *dev )
dev_priv->head = DRM(alloc)( sizeof(drm_r128_freelist_t),
DRM_MEM_DRIVER );
if ( dev_priv->head == NULL )
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
memset( dev_priv->head, 0, sizeof(drm_r128_freelist_t) );
dev_priv->head->age = R128_BUFFER_USED;
@@ -852,7 +852,7 @@ static int r128_freelist_init( drm_device_t *dev )
entry = DRM(alloc)( sizeof(drm_r128_freelist_t),
DRM_MEM_DRIVER );
- if ( !entry ) return DRM_OS_ERR(ENOMEM);
+ if ( !entry ) return DRM_ERR(ENOMEM);
entry->age = R128_BUFFER_FREE;
entry->buf = buf;
@@ -907,7 +907,7 @@ drm_buf_t *r128_freelist_get( drm_device_t *dev )
return buf;
}
}
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
DRM_ERROR( "returning NULL!\n" );
@@ -940,12 +940,12 @@ int r128_wait_ring( drm_r128_private_t *dev_priv, int n )
r128_update_ring_snapshot( ring );
if ( ring->space >= n )
return 0;
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
/* FIXME: This is being ignored... */
DRM_ERROR( "failed!\n" );
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
static int r128_cce_get_buffers( drm_device_t *dev, drm_dma_t *d )
@@ -955,47 +955,47 @@ static int r128_cce_get_buffers( drm_device_t *dev, drm_dma_t *d )
for ( i = d->granted_count ; i < d->request_count ; i++ ) {
buf = r128_freelist_get( dev );
- if ( !buf ) return DRM_OS_ERR(EAGAIN);
+ if ( !buf ) return DRM_ERR(EAGAIN);
- buf->pid = DRM_OS_CURRENTPID;
+ buf->pid = DRM_CURRENTPID;
- if ( DRM_OS_COPYTOUSR( &d->request_indices[i], &buf->idx,
+ if ( DRM_COPY_TO_USER( &d->request_indices[i], &buf->idx,
sizeof(buf->idx) ) )
- return DRM_OS_ERR(EFAULT);
- if ( DRM_OS_COPYTOUSR( &d->request_sizes[i], &buf->total,
+ return DRM_ERR(EFAULT);
+ if ( DRM_COPY_TO_USER( &d->request_sizes[i], &buf->total,
sizeof(buf->total) ) )
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
d->granted_count++;
}
return 0;
}
-int r128_cce_buffers( DRM_OS_IOCTL )
+int r128_cce_buffers( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
int ret = 0;
drm_dma_t d;
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( d, (drm_dma_t *) data, sizeof(d) );
+ DRM_COPY_FROM_USER_IOCTL( d, (drm_dma_t *) data, sizeof(d) );
/* Please don't send us buffers.
*/
if ( d.send_count != 0 ) {
DRM_ERROR( "Process %d trying to send %d buffers via drmDMA\n",
- DRM_OS_CURRENTPID, d.send_count );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, d.send_count );
+ return DRM_ERR(EINVAL);
}
/* We'll send you buffers.
*/
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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, d.request_count, dma->buf_count );
+ return DRM_ERR(EINVAL);
}
d.granted_count = 0;
@@ -1004,7 +1004,7 @@ int r128_cce_buffers( DRM_OS_IOCTL )
ret = r128_cce_get_buffers( dev, &d );
}
- DRM_OS_KRNTOUSR((drm_dma_t *) data, d, sizeof(d) );
+ DRM_COPY_TO_USER_IOCTL((drm_dma_t *) data, d, sizeof(d) );
return ret;
}
diff --git a/shared-core/r128_drv.h b/shared-core/r128_drv.h
index 2b42a5d2..04296590 100644
--- a/shared-core/r128_drv.h
+++ b/shared-core/r128_drv.h
@@ -34,8 +34,8 @@
#ifndef __R128_DRV_H__
#define __R128_DRV_H__
-#define GET_RING_HEAD(ring) DRM_OS_READ32( (volatile u32 *) (ring)->head )
-#define SET_RING_HEAD(ring,val) DRM_OS_WRITE32( (volatile u32 *) (ring)->head, (val) )
+#define GET_RING_HEAD(ring) DRM_READ32( (volatile u32 *) (ring)->head )
+#define SET_RING_HEAD(ring,val) DRM_WRITE32( (volatile u32 *) (ring)->head, (val) )
typedef struct drm_r128_freelist {
unsigned int age;
@@ -116,14 +116,14 @@ typedef struct drm_r128_buf_priv {
} drm_r128_buf_priv_t;
/* r128_cce.c */
-extern int r128_cce_init( DRM_OS_IOCTL );
-extern int r128_cce_start( DRM_OS_IOCTL );
-extern int r128_cce_stop( DRM_OS_IOCTL );
-extern int r128_cce_reset( DRM_OS_IOCTL );
-extern int r128_cce_idle( DRM_OS_IOCTL );
-extern int r128_engine_reset( DRM_OS_IOCTL );
-extern int r128_fullscreen( DRM_OS_IOCTL );
-extern int r128_cce_buffers( DRM_OS_IOCTL );
+extern int r128_cce_init( DRM_IOCTL_ARGS );
+extern int r128_cce_start( DRM_IOCTL_ARGS );
+extern int r128_cce_stop( DRM_IOCTL_ARGS );
+extern int r128_cce_reset( DRM_IOCTL_ARGS );
+extern int r128_cce_idle( DRM_IOCTL_ARGS );
+extern int r128_engine_reset( DRM_IOCTL_ARGS );
+extern int r128_fullscreen( DRM_IOCTL_ARGS );
+extern int r128_cce_buffers( DRM_IOCTL_ARGS );
extern void r128_freelist_reset( drm_device_t *dev );
extern drm_buf_t *r128_freelist_get( drm_device_t *dev );
@@ -143,14 +143,14 @@ extern int r128_do_cleanup_cce( drm_device_t *dev );
extern int r128_do_cleanup_pageflip( drm_device_t *dev );
/* r128_state.c */
-extern int r128_cce_clear( DRM_OS_IOCTL );
-extern int r128_cce_swap( DRM_OS_IOCTL );
-extern int r128_cce_vertex( DRM_OS_IOCTL );
-extern int r128_cce_indices( DRM_OS_IOCTL );
-extern int r128_cce_blit( DRM_OS_IOCTL );
-extern int r128_cce_depth( DRM_OS_IOCTL );
-extern int r128_cce_stipple( DRM_OS_IOCTL );
-extern int r128_cce_indirect( DRM_OS_IOCTL );
+extern int r128_cce_clear( DRM_IOCTL_ARGS );
+extern int r128_cce_swap( DRM_IOCTL_ARGS );
+extern int r128_cce_vertex( DRM_IOCTL_ARGS );
+extern int r128_cce_indices( DRM_IOCTL_ARGS );
+extern int r128_cce_blit( DRM_IOCTL_ARGS );
+extern int r128_cce_depth( DRM_IOCTL_ARGS );
+extern int r128_cce_stipple( DRM_IOCTL_ARGS );
+extern int r128_cce_indirect( DRM_IOCTL_ARGS );
/* Register definitions, register access macros and drmAddMap constants
@@ -368,11 +368,11 @@ extern int r128_cce_indirect( DRM_OS_IOCTL );
#define R128_BASE(reg) ((unsigned long)(dev_priv->mmio->handle))
#define R128_ADDR(reg) (R128_BASE( reg ) + reg)
-#define R128_READ(reg) DRM_OS_READ32( (volatile u32 *) R128_ADDR(reg) )
-#define R128_WRITE(reg,val) DRM_OS_WRITE32( (volatile u32 *) R128_ADDR(reg), (val) )
+#define R128_READ(reg) DRM_READ32( (volatile u32 *) R128_ADDR(reg) )
+#define R128_WRITE(reg,val) DRM_WRITE32( (volatile u32 *) R128_ADDR(reg), (val) )
-#define R128_READ8(reg) DRM_OS_READ8( (volatile u8 *) R128_ADDR(reg) )
-#define R128_WRITE8(reg,val) DRM_OS_WRITE8( (volatile u8 *) R128_ADDR(reg), (val) )
+#define R128_READ8(reg) DRM_READ8( (volatile u8 *) R128_ADDR(reg) )
+#define R128_WRITE8(reg,val) DRM_WRITE8( (volatile u8 *) R128_ADDR(reg), (val) )
#define R128_WRITE_PLL(addr,val) \
do { \
@@ -400,9 +400,9 @@ extern int R128_READ_PLL(drm_device_t *dev, int addr);
#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", __func__ ); \
- return DRM_OS_ERR(EINVAL); \
+ return DRM_ERR(EINVAL); \
} \
} while (0)
@@ -414,10 +414,10 @@ do { \
r128_update_ring_snapshot( ring ); \
if ( ring->space >= ring->high_mark ) \
goto __ring_space_done; \
- DRM_OS_DELAY(1); \
+ DRM_UDELAY(1); \
} \
DRM_ERROR( "ring space check failed!\n" ); \
- return DRM_OS_ERR(EBUSY); \
+ return DRM_ERR(EBUSY); \
} \
__ring_space_done: \
; \
@@ -447,7 +447,7 @@ do { \
#if defined(__powerpc__)
#define r128_flush_write_combine() (void) GET_RING_HEAD( &dev_priv->ring )
#else
-#define r128_flush_write_combine() DRM_OS_WRITEMEMORYBARRIER()
+#define r128_flush_write_combine() DRM_WRITEMEMORYBARRIER()
#endif
diff --git a/shared-core/r128_state.c b/shared-core/r128_state.c
index 697d8ac8..a8ffd073 100644
--- a/shared-core/r128_state.c
+++ b/shared-core/r128_state.c
@@ -809,7 +809,7 @@ static int r128_cce_dispatch_blit( drm_device_t *dev,
break;
default:
DRM_ERROR( "invalid blit format %d\n", blit->format );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
/* Flush the pixel cache, and mark the contents as Read Invalid.
@@ -829,14 +829,14 @@ static int r128_cce_dispatch_blit( drm_device_t *dev,
buf = dma->buflist[blit->idx];
buf_priv = buf->dev_private;
- 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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, buf->pid );
+ return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
DRM_ERROR( "sending pending buffer %d\n", blit->idx );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
buf_priv->discard = 1;
@@ -901,33 +901,33 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
DRM_DEBUG( "\n" );
count = depth->n;
- if ( DRM_OS_COPYFROMUSR( &x, depth->x, sizeof(x) ) ) {
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( &x, depth->x, sizeof(x) ) ) {
+ return DRM_ERR(EFAULT);
}
- if ( DRM_OS_COPYFROMUSR( &y, depth->y, sizeof(y) ) ) {
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( &y, depth->y, sizeof(y) ) ) {
+ return DRM_ERR(EFAULT);
}
- buffer = DRM_OS_MALLOC( depth->n * sizeof(u32) );
+ buffer = DRM_MALLOC( depth->n * sizeof(u32) );
if ( buffer == NULL )
- return DRM_OS_ERR(ENOMEM);
- if ( DRM_OS_COPYFROMUSR( buffer, depth->buffer,
+ return DRM_ERR(ENOMEM);
+ if ( DRM_COPY_FROM_USER( buffer, depth->buffer,
depth->n * sizeof(u32) ) ) {
- DRM_OS_FREE( buffer );
- return DRM_OS_ERR(EFAULT);
+ DRM_FREE( buffer );
+ return DRM_ERR(EFAULT);
}
if ( depth->mask ) {
- mask = DRM_OS_MALLOC( depth->n * sizeof(u8) );
+ mask = DRM_MALLOC( depth->n * sizeof(u8) );
if ( mask == NULL ) {
- DRM_OS_FREE( buffer );
- return DRM_OS_ERR(ENOMEM);
+ DRM_FREE( buffer );
+ return DRM_ERR(ENOMEM);
}
- if ( DRM_OS_COPYFROMUSR( mask, depth->mask,
+ if ( DRM_COPY_FROM_USER( mask, depth->mask,
depth->n * sizeof(u8) ) ) {
- DRM_OS_FREE( buffer );
- DRM_OS_FREE( mask );
- return DRM_OS_ERR(EFAULT);
+ DRM_FREE( buffer );
+ DRM_FREE( mask );
+ return DRM_ERR(EFAULT);
}
for ( i = 0 ; i < count ; i++, x++ ) {
@@ -953,7 +953,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
- DRM_OS_FREE( mask );
+ DRM_FREE( mask );
} else {
for ( i = 0 ; i < count ; i++, x++ ) {
BEGIN_RING( 6 );
@@ -977,7 +977,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
- DRM_OS_FREE( buffer );
+ DRM_FREE( buffer );
return 0;
}
@@ -995,55 +995,55 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
count = depth->n;
- x = DRM_OS_MALLOC( count * sizeof(*x) );
+ x = DRM_MALLOC( count * sizeof(*x) );
if ( x == NULL ) {
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
- y = DRM_OS_MALLOC( count * sizeof(*y) );
+ y = DRM_MALLOC( count * sizeof(*y) );
if ( y == NULL ) {
- DRM_OS_FREE( x );
- return DRM_OS_ERR(ENOMEM);
+ DRM_FREE( x );
+ return DRM_ERR(ENOMEM);
}
- if ( DRM_OS_COPYFROMUSR( x, depth->x, count * sizeof(int) ) ) {
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( x, depth->x, count * sizeof(int) ) ) {
+ DRM_FREE( x );
+ DRM_FREE( y );
+ return DRM_ERR(EFAULT);
}
- if ( DRM_OS_COPYFROMUSR( y, depth->y, count * sizeof(int) ) ) {
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( y, depth->y, count * sizeof(int) ) ) {
+ DRM_FREE( x );
+ DRM_FREE( y );
+ return DRM_ERR(EFAULT);
}
- buffer = DRM_OS_MALLOC( depth->n * sizeof(u32) );
+ buffer = DRM_MALLOC( depth->n * sizeof(u32) );
if ( buffer == NULL ) {
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- return DRM_OS_ERR(ENOMEM);
+ DRM_FREE( x );
+ DRM_FREE( y );
+ return DRM_ERR(ENOMEM);
}
- if ( DRM_OS_COPYFROMUSR( buffer, depth->buffer,
+ if ( DRM_COPY_FROM_USER( buffer, depth->buffer,
depth->n * sizeof(u32) ) ) {
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- DRM_OS_FREE( buffer );
- return DRM_OS_ERR(EFAULT);
+ DRM_FREE( x );
+ DRM_FREE( y );
+ DRM_FREE( buffer );
+ return DRM_ERR(EFAULT);
}
if ( depth->mask ) {
- mask = DRM_OS_MALLOC( depth->n * sizeof(u8) );
+ mask = DRM_MALLOC( depth->n * sizeof(u8) );
if ( mask == NULL ) {
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- DRM_OS_FREE( buffer );
- return DRM_OS_ERR(ENOMEM);
+ DRM_FREE( x );
+ DRM_FREE( y );
+ DRM_FREE( buffer );
+ return DRM_ERR(ENOMEM);
}
- if ( DRM_OS_COPYFROMUSR( mask, depth->mask,
+ if ( DRM_COPY_FROM_USER( mask, depth->mask,
depth->n * sizeof(u8) ) ) {
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- DRM_OS_FREE( buffer );
- DRM_OS_FREE( mask );
- return DRM_OS_ERR(EFAULT);
+ DRM_FREE( x );
+ DRM_FREE( y );
+ DRM_FREE( buffer );
+ DRM_FREE( mask );
+ return DRM_ERR(EFAULT);
}
for ( i = 0 ; i < count ; i++ ) {
@@ -1069,7 +1069,7 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
- DRM_OS_FREE( mask );
+ DRM_FREE( mask );
} else {
for ( i = 0 ; i < count ; i++ ) {
BEGIN_RING( 6 );
@@ -1093,9 +1093,9 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- DRM_OS_FREE( buffer );
+ DRM_FREE( x );
+ DRM_FREE( y );
+ DRM_FREE( buffer );
return 0;
}
@@ -1109,11 +1109,11 @@ static int r128_cce_dispatch_read_span( drm_device_t *dev,
DRM_DEBUG( "\n" );
count = depth->n;
- if ( DRM_OS_COPYFROMUSR( &x, depth->x, sizeof(x) ) ) {
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( &x, depth->x, sizeof(x) ) ) {
+ return DRM_ERR(EFAULT);
}
- if ( DRM_OS_COPYFROMUSR( &y, depth->y, sizeof(y) ) ) {
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( &y, depth->y, sizeof(y) ) ) {
+ return DRM_ERR(EFAULT);
}
BEGIN_RING( 7 );
@@ -1155,24 +1155,24 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
count = dev_priv->depth_pitch;
}
- x = DRM_OS_MALLOC( count * sizeof(*x) );
+ x = DRM_MALLOC( count * sizeof(*x) );
if ( x == NULL ) {
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
- y = DRM_OS_MALLOC( count * sizeof(*y) );
+ y = DRM_MALLOC( count * sizeof(*y) );
if ( y == NULL ) {
- DRM_OS_FREE( x );
- return DRM_OS_ERR(ENOMEM);
+ DRM_FREE( x );
+ return DRM_ERR(ENOMEM);
}
- if ( DRM_OS_COPYFROMUSR( x, depth->x, count * sizeof(int) ) ) {
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( x, depth->x, count * sizeof(int) ) ) {
+ DRM_FREE( x );
+ DRM_FREE( y );
+ return DRM_ERR(EFAULT);
}
- if ( DRM_OS_COPYFROMUSR( y, depth->y, count * sizeof(int) ) ) {
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( y, depth->y, count * sizeof(int) ) ) {
+ DRM_FREE( x );
+ DRM_FREE( y );
+ return DRM_ERR(EFAULT);
}
for ( i = 0 ; i < count ; i++ ) {
@@ -1199,8 +1199,8 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
ADVANCE_RING();
}
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
+ DRM_FREE( x );
+ DRM_FREE( y );
return 0;
}
@@ -1232,9 +1232,9 @@ static void r128_cce_dispatch_stipple( drm_device_t *dev, u32 *stipple )
* IOCTL functions
*/
-int r128_cce_clear( DRM_OS_IOCTL )
+int r128_cce_clear( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_r128_clear_t clear;
@@ -1242,7 +1242,7 @@ int r128_cce_clear( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( clear, (drm_r128_clear_t *) data,
+ DRM_COPY_FROM_USER_IOCTL( clear, (drm_r128_clear_t *) data,
sizeof(clear) );
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1259,9 +1259,9 @@ int r128_cce_clear( DRM_OS_IOCTL )
return 0;
}
-int r128_cce_swap( DRM_OS_IOCTL )
+int r128_cce_swap( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
DRM_DEBUG( "%s\n", __func__ );
@@ -1284,9 +1284,9 @@ int r128_cce_swap( DRM_OS_IOCTL )
return 0;
}
-int r128_cce_vertex( DRM_OS_IOCTL )
+int r128_cce_vertex( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_device_dma_t *dma = dev->dma;
drm_buf_t *buf;
@@ -1297,25 +1297,25 @@ int r128_cce_vertex( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( vertex, (drm_r128_vertex_t *) data,
+ DRM_COPY_FROM_USER_IOCTL( vertex, (drm_r128_vertex_t *) data,
sizeof(vertex) );
DRM_DEBUG( "pid=%d index=%d count=%d discard=%d\n",
- DRM_OS_CURRENTPID,
+ DRM_CURRENTPID,
vertex.idx, vertex.count, vertex.discard );
if ( vertex.idx < 0 || vertex.idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
vertex.idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( vertex.prim < 0 ||
vertex.prim > R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 ) {
DRM_ERROR( "buffer prim %d\n", vertex.prim );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1324,14 +1324,14 @@ int r128_cce_vertex( DRM_OS_IOCTL )
buf = dma->buflist[vertex.idx];
buf_priv = buf->dev_private;
- 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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, buf->pid );
+ return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
DRM_ERROR( "sending pending buffer %d\n", vertex.idx );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
buf->used = vertex.count;
@@ -1343,9 +1343,9 @@ int r128_cce_vertex( DRM_OS_IOCTL )
return 0;
}
-int r128_cce_indices( DRM_OS_IOCTL )
+int r128_cce_indices( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_device_dma_t *dma = dev->dma;
drm_buf_t *buf;
@@ -1357,24 +1357,24 @@ int r128_cce_indices( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( elts, (drm_r128_indices_t *) data,
+ DRM_COPY_FROM_USER_IOCTL( elts, (drm_r128_indices_t *) data,
sizeof(elts) );
- DRM_DEBUG( "pid=%d buf=%d s=%d e=%d d=%d\n", DRM_OS_CURRENTPID,
+ DRM_DEBUG( "pid=%d buf=%d s=%d e=%d d=%d\n", DRM_CURRENTPID,
elts.idx, elts.start, elts.end, elts.discard );
if ( elts.idx < 0 || elts.idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
elts.idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( elts.prim < 0 ||
elts.prim > R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 ) {
DRM_ERROR( "buffer prim %d\n", elts.prim );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1383,14 +1383,14 @@ int r128_cce_indices( DRM_OS_IOCTL )
buf = dma->buflist[elts.idx];
buf_priv = buf->dev_private;
- 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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, buf->pid );
+ return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
DRM_ERROR( "sending pending buffer %d\n", elts.idx );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
count = (elts.end - elts.start) / sizeof(u16);
@@ -1398,11 +1398,11 @@ int r128_cce_indices( DRM_OS_IOCTL )
if ( elts.start & 0x7 ) {
DRM_ERROR( "misaligned buffer 0x%x\n", elts.start );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( elts.start < buf->used ) {
DRM_ERROR( "no header 0x%x - 0x%x\n", elts.start, buf->used );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
buf->used = elts.end;
@@ -1414,24 +1414,24 @@ int r128_cce_indices( DRM_OS_IOCTL )
return 0;
}
-int r128_cce_blit( DRM_OS_IOCTL )
+int r128_cce_blit( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_r128_blit_t blit;
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( blit, (drm_r128_blit_t *) data,
+ DRM_COPY_FROM_USER_IOCTL( blit, (drm_r128_blit_t *) data,
sizeof(blit) );
- DRM_DEBUG( "pid=%d index=%d\n", DRM_OS_CURRENTPID, blit.idx );
+ DRM_DEBUG( "pid=%d index=%d\n", DRM_CURRENTPID, blit.idx );
if ( blit.idx < 0 || blit.idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
blit.idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1440,15 +1440,15 @@ int r128_cce_blit( DRM_OS_IOCTL )
return r128_cce_dispatch_blit( dev, &blit );
}
-int r128_cce_depth( DRM_OS_IOCTL )
+int r128_cce_depth( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_r128_depth_t depth;
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( depth, (drm_r128_depth_t *) data,
+ DRM_COPY_FROM_USER_IOCTL( depth, (drm_r128_depth_t *) data,
sizeof(depth) );
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1464,24 +1464,24 @@ int r128_cce_depth( DRM_OS_IOCTL )
return r128_cce_dispatch_read_pixels( dev, &depth );
}
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
-int r128_cce_stipple( DRM_OS_IOCTL )
+int r128_cce_stipple( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_r128_stipple_t stipple;
u32 mask[32];
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( stipple, (drm_r128_stipple_t *) data,
+ DRM_COPY_FROM_USER_IOCTL( stipple, (drm_r128_stipple_t *) data,
sizeof(stipple) );
- if ( DRM_OS_COPYFROMUSR( &mask, stipple.mask,
+ if ( DRM_COPY_FROM_USER( &mask, stipple.mask,
32 * sizeof(u32) ) )
- return DRM_OS_ERR( EFAULT );
+ return DRM_ERR( EFAULT );
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1490,9 +1490,9 @@ int r128_cce_stipple( DRM_OS_IOCTL )
return 0;
}
-int r128_cce_indirect( DRM_OS_IOCTL )
+int r128_cce_indirect( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_device_dma_t *dma = dev->dma;
drm_buf_t *buf;
@@ -1506,10 +1506,10 @@ int r128_cce_indirect( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( indirect, (drm_r128_indirect_t *) data,
+ DRM_COPY_FROM_USER_IOCTL( indirect, (drm_r128_indirect_t *) data,
sizeof(indirect) );
DRM_DEBUG( "indirect: idx=%d s=%d e=%d d=%d\n",
@@ -1519,26 +1519,26 @@ int r128_cce_indirect( DRM_OS_IOCTL )
if ( indirect.idx < 0 || indirect.idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
indirect.idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
buf = dma->buflist[indirect.idx];
buf_priv = buf->dev_private;
- 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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, buf->pid );
+ return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
DRM_ERROR( "sending pending buffer %d\n", indirect.idx );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( indirect.start < buf->used ) {
DRM_ERROR( "reusing indirect: start=0x%x actual=0x%x\n",
indirect.start, buf->used );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
RING_SPACE_TEST_WITH_RETURN( dev_priv );
diff --git a/shared-core/radeon_cp.c b/shared-core/radeon_cp.c
index 79d7afeb..1ddbdced 100644
--- a/shared-core/radeon_cp.c
+++ b/shared-core/radeon_cp.c
@@ -354,14 +354,14 @@ static int radeon_do_pixcache_flush( drm_radeon_private_t *dev_priv )
& RADEON_RB2D_DC_BUSY) ) {
return 0;
}
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if RADEON_FIFO_DEBUG
DRM_ERROR( "failed!\n" );
radeon_status( dev_priv );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
static int radeon_do_wait_for_fifo( drm_radeon_private_t *dev_priv,
@@ -373,14 +373,14 @@ static int radeon_do_wait_for_fifo( drm_radeon_private_t *dev_priv,
int slots = ( RADEON_READ( RADEON_RBBM_STATUS )
& RADEON_RBBM_FIFOCNT_MASK );
if ( slots >= entries ) return 0;
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if RADEON_FIFO_DEBUG
DRM_ERROR( "failed!\n" );
radeon_status( dev_priv );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
static int radeon_do_wait_for_idle( drm_radeon_private_t *dev_priv )
@@ -396,14 +396,14 @@ static int radeon_do_wait_for_idle( drm_radeon_private_t *dev_priv )
radeon_do_pixcache_flush( dev_priv );
return 0;
}
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if RADEON_FIFO_DEBUG
DRM_ERROR( "failed!\n" );
radeon_status( dev_priv );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
@@ -657,7 +657,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
dev_priv = DRM(alloc)( sizeof(drm_radeon_private_t), DRM_MEM_DRIVER );
if ( dev_priv == NULL )
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
memset( dev_priv, 0, sizeof(drm_radeon_private_t) );
@@ -670,7 +670,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
DRM_ERROR( "PCI GART not yet supported for Radeon!\n" );
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
#endif
@@ -678,7 +678,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
DRM_ERROR( "PCI GART memory not allocated!\n" );
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
dev_priv->usec_timeout = init->usec_timeout;
@@ -687,7 +687,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
DRM_DEBUG( "TIMEOUT problem!\n" );
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
dev_priv->cp_mode = init->cp_mode;
@@ -705,7 +705,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
DRM_DEBUG( "BAD cp_mode (%x)!\n", init->cp_mode );
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
switch ( init->fb_bpp ) {
@@ -771,13 +771,13 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
RADEON_ROUND_MODE_TRUNC |
RADEON_ROUND_PREC_8TH_PIX);
- DRM_OS_GETSAREA();
+ DRM_GETSAREA();
if(!dev_priv->sarea) {
DRM_ERROR("could not find sarea!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->fb, init->fb_offset );
@@ -785,35 +785,35 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
DRM_ERROR("could not find framebuffer!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset );
if(!dev_priv->mmio) {
DRM_ERROR("could not find mmio region!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->cp_ring, init->ring_offset );
if(!dev_priv->cp_ring) {
DRM_ERROR("could not find cp ring region!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->ring_rptr, init->ring_rptr_offset );
if(!dev_priv->ring_rptr) {
DRM_ERROR("could not find ring read pointer!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
if(!dev_priv->buffers) {
DRM_ERROR("could not find dma buffer region!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( !dev_priv->is_pci ) {
@@ -823,7 +823,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
DRM_ERROR("could not find agp texture region!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
}
@@ -841,7 +841,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
DRM_ERROR("could not find ioremap agp regions!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
} else {
dev_priv->cp_ring->handle =
@@ -928,7 +928,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
DRM_ERROR( "failed to init PCI GART!\n" );
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
/* Turn on PCI GART
*/
@@ -1001,12 +1001,12 @@ int radeon_do_cleanup_cp( drm_device_t *dev )
return 0;
}
-int radeon_cp_init( DRM_OS_IOCTL )
+int radeon_cp_init( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_init_t init;
- DRM_OS_KRNFROMUSR( init, (drm_radeon_init_t *)data, sizeof(init) );
+ DRM_COPY_FROM_USER_IOCTL( init, (drm_radeon_init_t *)data, sizeof(init) );
switch ( init.func ) {
case RADEON_INIT_CP:
@@ -1015,12 +1015,12 @@ int radeon_cp_init( DRM_OS_IOCTL )
return radeon_do_cleanup_cp( dev );
}
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
-int radeon_cp_start( DRM_OS_IOCTL )
+int radeon_cp_start( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
@@ -1044,9 +1044,9 @@ int radeon_cp_start( DRM_OS_IOCTL )
/* Stop the CP. The engine must have been idled before calling this
* routine.
*/
-int radeon_cp_stop( DRM_OS_IOCTL )
+int radeon_cp_stop( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_cp_stop_t stop;
int ret;
@@ -1054,7 +1054,7 @@ int radeon_cp_stop( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( stop, (drm_radeon_cp_stop_t *)data, sizeof(stop) );
+ DRM_COPY_FROM_USER_IOCTL( stop, (drm_radeon_cp_stop_t *)data, sizeof(stop) );
/* Flush any pending CP commands. This ensures any outstanding
* commands are exectuted by the engine before we turn it off.
@@ -1085,9 +1085,9 @@ int radeon_cp_stop( DRM_OS_IOCTL )
/* Just reset the CP ring. Called as part of an X Server engine reset.
*/
-int radeon_cp_reset( DRM_OS_IOCTL )
+int radeon_cp_reset( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
@@ -1095,7 +1095,7 @@ int radeon_cp_reset( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_DEBUG( "%s called before init done\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
radeon_do_cp_reset( dev_priv );
@@ -1106,9 +1106,9 @@ int radeon_cp_reset( DRM_OS_IOCTL )
return 0;
}
-int radeon_cp_idle( DRM_OS_IOCTL )
+int radeon_cp_idle( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
@@ -1117,9 +1117,9 @@ int radeon_cp_idle( DRM_OS_IOCTL )
return radeon_do_cp_idle( dev_priv );
}
-int radeon_engine_reset( DRM_OS_IOCTL )
+int radeon_engine_reset( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
DRM_DEBUG( "\n" );
LOCK_TEST_WITH_RETURN( dev );
@@ -1134,7 +1134,7 @@ int radeon_engine_reset( DRM_OS_IOCTL )
/* KW: Deprecated to say the least:
*/
-int radeon_fullscreen( DRM_OS_IOCTL )
+int radeon_fullscreen( DRM_IOCTL_ARGS )
{
return 0;
}
@@ -1179,7 +1179,7 @@ drm_buf_t *radeon_freelist_get( drm_device_t *dev )
}
start = 0;
}
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
DRM_ERROR( "returning NULL!\n" );
@@ -1214,7 +1214,7 @@ int radeon_wait_ring( drm_radeon_private_t *dev_priv, int n )
radeon_update_ring_snapshot( ring );
if ( ring->space > n )
return 0;
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
/* FIXME: This return value is ignored in the BEGIN_RING macro! */
@@ -1222,7 +1222,7 @@ int radeon_wait_ring( drm_radeon_private_t *dev_priv, int n )
radeon_status( dev_priv );
DRM_ERROR( "failed!\n" );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
static int radeon_cp_get_buffers( drm_device_t *dev, drm_dma_t *d )
@@ -1232,47 +1232,47 @@ static int radeon_cp_get_buffers( drm_device_t *dev, drm_dma_t *d )
for ( i = d->granted_count ; i < d->request_count ; i++ ) {
buf = radeon_freelist_get( dev );
- if ( !buf ) return DRM_OS_ERR(EAGAIN);
+ if ( !buf ) return DRM_ERR(EAGAIN);
- buf->pid = DRM_OS_CURRENTPID;
+ buf->pid = DRM_CURRENTPID;
- if ( DRM_OS_COPYTOUSR( &d->request_indices[i], &buf->idx,
+ if ( DRM_COPY_TO_USER( &d->request_indices[i], &buf->idx,
sizeof(buf->idx) ) )
- return DRM_OS_ERR(EFAULT);
- if ( DRM_OS_COPYTOUSR( &d->request_sizes[i], &buf->total,
+ return DRM_ERR(EFAULT);
+ if ( DRM_COPY_TO_USER( &d->request_sizes[i], &buf->total,
sizeof(buf->total) ) )
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
d->granted_count++;
}
return 0;
}
-int radeon_cp_buffers( DRM_OS_IOCTL )
+int radeon_cp_buffers( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
int ret = 0;
drm_dma_t d;
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( d, (drm_dma_t *)data, sizeof(d) );
+ DRM_COPY_FROM_USER_IOCTL( d, (drm_dma_t *)data, sizeof(d) );
/* Please don't send us buffers.
*/
if ( d.send_count != 0 ) {
DRM_ERROR( "Process %d trying to send %d buffers via drmDMA\n",
- DRM_OS_CURRENTPID, d.send_count );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, d.send_count );
+ return DRM_ERR(EINVAL);
}
/* We'll send you buffers.
*/
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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, d.request_count, dma->buf_count );
+ return DRM_ERR(EINVAL);
}
d.granted_count = 0;
@@ -1281,7 +1281,7 @@ int radeon_cp_buffers( DRM_OS_IOCTL )
ret = radeon_cp_get_buffers( dev, &d );
}
- DRM_OS_KRNTOUSR( (drm_dma_t *)data, d, sizeof(d) );
+ DRM_COPY_TO_USER_IOCTL( (drm_dma_t *)data, d, sizeof(d) );
return ret;
}
diff --git a/shared-core/radeon_drv.h b/shared-core/radeon_drv.h
index a40e294b..b6b9d4c6 100644
--- a/shared-core/radeon_drv.h
+++ b/shared-core/radeon_drv.h
@@ -31,8 +31,8 @@
#ifndef __RADEON_DRV_H__
#define __RADEON_DRV_H__
-#define GET_RING_HEAD(ring) DRM_OS_READ32( (volatile u32 *) (ring)->head )
-#define SET_RING_HEAD(ring,val) DRM_OS_WRITE32( (volatile u32 *) (ring)->head , (val))
+#define GET_RING_HEAD(ring) DRM_READ32( (volatile u32 *) (ring)->head )
+#define SET_RING_HEAD(ring,val) DRM_WRITE32( (volatile u32 *) (ring)->head , (val))
typedef struct drm_radeon_freelist {
unsigned int age;
@@ -119,14 +119,14 @@ typedef struct drm_radeon_buf_priv {
} drm_radeon_buf_priv_t;
/* radeon_cp.c */
-extern int radeon_cp_init( DRM_OS_IOCTL );
-extern int radeon_cp_start( DRM_OS_IOCTL );
-extern int radeon_cp_stop( DRM_OS_IOCTL );
-extern int radeon_cp_reset( DRM_OS_IOCTL );
-extern int radeon_cp_idle( DRM_OS_IOCTL );
-extern int radeon_engine_reset( DRM_OS_IOCTL );
-extern int radeon_fullscreen( DRM_OS_IOCTL );
-extern int radeon_cp_buffers( DRM_OS_IOCTL );
+extern int radeon_cp_init( DRM_IOCTL_ARGS );
+extern int radeon_cp_start( DRM_IOCTL_ARGS );
+extern int radeon_cp_stop( DRM_IOCTL_ARGS );
+extern int radeon_cp_reset( DRM_IOCTL_ARGS );
+extern int radeon_cp_idle( DRM_IOCTL_ARGS );
+extern int radeon_engine_reset( DRM_IOCTL_ARGS );
+extern int radeon_fullscreen( DRM_IOCTL_ARGS );
+extern int radeon_cp_buffers( DRM_IOCTL_ARGS );
extern void radeon_freelist_reset( drm_device_t *dev );
extern drm_buf_t *radeon_freelist_get( drm_device_t *dev );
@@ -146,17 +146,17 @@ extern int radeon_do_cleanup_cp( drm_device_t *dev );
extern int radeon_do_cleanup_pageflip( drm_device_t *dev );
/* radeon_state.c */
-extern int radeon_cp_clear( DRM_OS_IOCTL );
-extern int radeon_cp_swap( DRM_OS_IOCTL );
-extern int radeon_cp_vertex( DRM_OS_IOCTL );
-extern int radeon_cp_indices( DRM_OS_IOCTL );
-extern int radeon_cp_texture( DRM_OS_IOCTL );
-extern int radeon_cp_stipple( DRM_OS_IOCTL );
-extern int radeon_cp_indirect( DRM_OS_IOCTL );
-extern int radeon_cp_vertex2( DRM_OS_IOCTL );
-extern int radeon_cp_cmdbuf( DRM_OS_IOCTL );
-extern int radeon_cp_getparam( DRM_OS_IOCTL );
-extern int radeon_cp_flip( DRM_OS_IOCTL );
+extern int radeon_cp_clear( DRM_IOCTL_ARGS );
+extern int radeon_cp_swap( DRM_IOCTL_ARGS );
+extern int radeon_cp_vertex( DRM_IOCTL_ARGS );
+extern int radeon_cp_indices( DRM_IOCTL_ARGS );
+extern int radeon_cp_texture( DRM_IOCTL_ARGS );
+extern int radeon_cp_stipple( DRM_IOCTL_ARGS );
+extern int radeon_cp_indirect( DRM_IOCTL_ARGS );
+extern int radeon_cp_vertex2( DRM_IOCTL_ARGS );
+extern int radeon_cp_cmdbuf( DRM_IOCTL_ARGS );
+extern int radeon_cp_getparam( DRM_IOCTL_ARGS );
+extern int radeon_cp_flip( DRM_IOCTL_ARGS );
@@ -524,11 +524,11 @@ extern int radeon_cp_flip( DRM_OS_IOCTL );
#define RADEON_BASE(reg) ((unsigned long)(dev_priv->mmio->handle))
#define RADEON_ADDR(reg) (RADEON_BASE( reg ) + reg)
-#define RADEON_READ(reg) DRM_OS_READ32( (volatile u32 *) RADEON_ADDR(reg) )
-#define RADEON_WRITE(reg,val) DRM_OS_WRITE32( (volatile u32 *) RADEON_ADDR(reg), (val) )
+#define RADEON_READ(reg) DRM_READ32( (volatile u32 *) RADEON_ADDR(reg) )
+#define RADEON_WRITE(reg,val) DRM_WRITE32( (volatile u32 *) RADEON_ADDR(reg), (val) )
-#define RADEON_READ8(reg) DRM_OS_READ8( (volatile u8 *) RADEON_ADDR(reg) )
-#define RADEON_WRITE8(reg,val) DRM_OS_WRITE8( (volatile u8 *) RADEON_ADDR(reg), (val) )
+#define RADEON_READ8(reg) DRM_READ8( (volatile u8 *) RADEON_ADDR(reg) )
+#define RADEON_WRITE8(reg,val) DRM_WRITE8( (volatile u8 *) RADEON_ADDR(reg), (val) )
#define RADEON_WRITE_PLL( addr, val ) \
do { \
@@ -608,9 +608,9 @@ extern int RADEON_READ_PLL( drm_device_t *dev, int addr );
#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", __func__ ); \
- return DRM_OS_ERR(EINVAL); \
+ return DRM_ERR(EINVAL); \
} \
} while (0)
@@ -622,7 +622,7 @@ do { \
radeon_update_ring_snapshot( ring ); \
if ( ring->space >= ring->high_mark ) \
goto __ring_space_done; \
- DRM_OS_DELAY( 1 ); \
+ DRM_UDELAY( 1 ); \
} \
DRM_ERROR( "ring space check from memory failed, reading register...\n" ); \
/* If ring space check fails from RAM, try reading the \
@@ -634,7 +634,7 @@ do { \
goto __ring_space_done; \
\
DRM_ERROR( "ring space check failed!\n" ); \
- return DRM_OS_ERR(EBUSY); \
+ return DRM_ERR(EBUSY); \
} \
__ring_space_done: \
; \
@@ -736,17 +736,17 @@ do { \
\
if (write + _size > mask) { \
int i = (mask+1) - write; \
- if (DRM_OS_COPYFROMUSR_NC( (int *)(ring+write), \
+ if (DRM_COPY_FROM_USER_UNCHECKED( (int *)(ring+write), \
_tab, i*4 )) \
- return DRM_OS_ERR(EFAULT); \
+ return DRM_ERR(EFAULT); \
write = 0; \
_size -= i; \
_tab += i; \
} \
\
- if (_size && DRM_OS_COPYFROMUSR_NC( (int *)(ring+write), \
+ if (_size && DRM_COPY_FROM_USER_UNCHECKED( (int *)(ring+write), \
_tab, _size*4 )) \
- return DRM_OS_ERR(EFAULT); \
+ return DRM_ERR(EFAULT); \
\
write += _size; \
write &= mask; \
diff --git a/shared-core/radeon_state.c b/shared-core/radeon_state.c
index c36258c1..ec00b880 100644
--- a/shared-core/radeon_state.c
+++ b/shared-core/radeon_state.c
@@ -684,7 +684,7 @@ static void radeon_cp_dispatch_vertex( drm_device_t *dev,
do {
/* Emit the next cliprect */
if ( i < nbox ) {
- if (DRM_OS_COPYFROMUSR_NC( &box, &boxes[i], sizeof(box) ))
+ if (DRM_COPY_FROM_USER_UNCHECKED( &box, &boxes[i], sizeof(box) ))
return;
radeon_emit_clip_rect( dev_priv, &box );
@@ -817,7 +817,7 @@ static void radeon_cp_dispatch_indices( drm_device_t *dev,
do {
if ( i < nbox ) {
- if (DRM_OS_COPYFROMUSR_NC( &box, &boxes[i], sizeof(box) ))
+ if (DRM_COPY_FROM_USER_UNCHECKED( &box, &boxes[i], sizeof(box) ))
return;
radeon_emit_clip_rect( dev_priv, &box );
@@ -851,7 +851,7 @@ static int radeon_cp_dispatch_texture( drm_device_t *dev,
/* FIXME: Be smarter about this...
*/
buf = radeon_freelist_get( dev );
- if ( !buf ) return DRM_OS_ERR(EAGAIN);
+ if ( !buf ) return DRM_ERR(EAGAIN);
DRM_DEBUG( "tex: ofs=0x%x p=%d f=%d x=%hd y=%hd w=%hd h=%hd\n",
tex->offset >> 10, tex->pitch, tex->format,
@@ -884,7 +884,7 @@ static int radeon_cp_dispatch_texture( drm_device_t *dev,
break;
default:
DRM_ERROR( "invalid texture format %d\n", tex->format );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_DEBUG( " tex=%dx%d blit=%d\n",
@@ -922,7 +922,7 @@ static int radeon_cp_dispatch_texture( drm_device_t *dev,
if ( size > RADEON_MAX_TEXTURE_SIZE ) {
/* Texture image is too large, do a multipass upload */
- ret = DRM_OS_ERR(EAGAIN);
+ ret = DRM_ERR(EAGAIN);
/* Adjust the blit size to fit the indirect buffer */
height = RADEON_MAX_TEXTURE_SIZE / blit_width;
@@ -933,9 +933,9 @@ static int radeon_cp_dispatch_texture( drm_device_t *dev,
image->height -= height;
image->data = (const char *)image->data + size;
- if ( DRM_OS_COPYTOUSR( tex->image, image, sizeof(*image) ) ) {
+ if ( DRM_COPY_TO_USER( tex->image, image, sizeof(*image) ) ) {
DRM_ERROR( "EFAULT on tex->image\n" );
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
}
} else if ( size < 4 && size > 0 ) {
size = 4;
@@ -970,9 +970,9 @@ static int radeon_cp_dispatch_texture( drm_device_t *dev,
/* Texture image width is larger than the minimum, so we
* can upload it directly.
*/
- if ( DRM_OS_COPYFROMUSR( buffer, data, dwords * sizeof(u32) ) ) {
+ if ( DRM_COPY_FROM_USER( buffer, data, dwords * sizeof(u32) ) ) {
DRM_ERROR( "EFAULT on data, %d dwords\n", dwords );
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
}
} else {
/* Texture image width is less than the minimum, so we
@@ -980,17 +980,17 @@ static int radeon_cp_dispatch_texture( drm_device_t *dev,
* width.
*/
for ( i = 0 ; i < tex->height ; i++ ) {
- if ( DRM_OS_COPYFROMUSR( buffer, data, tex_width ) ) {
+ if ( DRM_COPY_FROM_USER( buffer, data, tex_width ) ) {
DRM_ERROR( "EFAULT on pad, %d bytes\n",
tex_width );
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
}
buffer += 8;
data += tex_width;
}
}
- buf->pid = DRM_OS_CURRENTPID;
+ buf->pid = DRM_CURRENTPID;
buf->used = (dwords + 8) * sizeof(u32);
radeon_cp_dispatch_indirect( dev, buf, 0, buf->used );
@@ -1035,9 +1035,9 @@ static void radeon_cp_dispatch_stipple( drm_device_t *dev, u32 *stipple )
* IOCTL functions
*/
-int radeon_cp_clear( DRM_OS_IOCTL )
+int radeon_cp_clear( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_radeon_clear_t clear;
@@ -1046,7 +1046,7 @@ int radeon_cp_clear( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( clear, (drm_radeon_clear_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( clear, (drm_radeon_clear_t *)data,
sizeof(clear) );
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1054,9 +1054,9 @@ int radeon_cp_clear( DRM_OS_IOCTL )
if ( sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS )
sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
- if ( DRM_OS_COPYFROMUSR( &depth_boxes, clear.depth_boxes,
+ if ( DRM_COPY_FROM_USER( &depth_boxes, clear.depth_boxes,
sarea_priv->nbox * sizeof(depth_boxes[0]) ) )
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
radeon_cp_dispatch_clear( dev, &clear, depth_boxes );
@@ -1104,9 +1104,9 @@ int radeon_do_cleanup_pageflip( drm_device_t *dev )
/* Swapping and flipping are different operations, need different ioctls.
* They can & should be intermixed to support multiple 3d windows.
*/
-int radeon_cp_flip( DRM_OS_IOCTL )
+int radeon_cp_flip( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
@@ -1123,9 +1123,9 @@ int radeon_cp_flip( DRM_OS_IOCTL )
return 0;
}
-int radeon_cp_swap( DRM_OS_IOCTL )
+int radeon_cp_swap( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
DRM_DEBUG( "\n" );
@@ -1144,9 +1144,9 @@ int radeon_cp_swap( DRM_OS_IOCTL )
return 0;
}
-int radeon_cp_vertex( DRM_OS_IOCTL )
+int radeon_cp_vertex( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_device_dma_t *dma = dev->dma;
@@ -1158,25 +1158,25 @@ int radeon_cp_vertex( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( vertex, (drm_radeon_vertex_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( vertex, (drm_radeon_vertex_t *)data,
sizeof(vertex) );
DRM_DEBUG( "pid=%d index=%d count=%d discard=%d\n",
- DRM_OS_CURRENTPID,
+ DRM_CURRENTPID,
vertex.idx, vertex.count, vertex.discard );
if ( vertex.idx < 0 || vertex.idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
vertex.idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( vertex.prim < 0 ||
vertex.prim > RADEON_PRIM_TYPE_3VRT_LINE_LIST ) {
DRM_ERROR( "buffer prim %d\n", vertex.prim );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1184,14 +1184,14 @@ int radeon_cp_vertex( DRM_OS_IOCTL )
buf = dma->buflist[vertex.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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, buf->pid );
+ return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
DRM_ERROR( "sending pending buffer %d\n", vertex.idx );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
/* Build up a prim_t record:
@@ -1230,9 +1230,9 @@ int radeon_cp_vertex( DRM_OS_IOCTL )
return 0;
}
-int radeon_cp_indices( DRM_OS_IOCTL )
+int radeon_cp_indices( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_device_dma_t *dma = dev->dma;
@@ -1245,25 +1245,25 @@ int radeon_cp_indices( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( elts, (drm_radeon_indices_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( elts, (drm_radeon_indices_t *)data,
sizeof(elts) );
DRM_DEBUG( "pid=%d index=%d start=%d end=%d discard=%d\n",
- DRM_OS_CURRENTPID,
+ DRM_CURRENTPID,
elts.idx, elts.start, elts.end, elts.discard );
if ( elts.idx < 0 || elts.idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
elts.idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( elts.prim < 0 ||
elts.prim > RADEON_PRIM_TYPE_3VRT_LINE_LIST ) {
DRM_ERROR( "buffer prim %d\n", elts.prim );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1271,14 +1271,14 @@ int radeon_cp_indices( DRM_OS_IOCTL )
buf = dma->buflist[elts.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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, buf->pid );
+ return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
DRM_ERROR( "sending pending buffer %d\n", elts.idx );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
count = (elts.end - elts.start) / sizeof(u16);
@@ -1286,11 +1286,11 @@ int radeon_cp_indices( DRM_OS_IOCTL )
if ( elts.start & 0x7 ) {
DRM_ERROR( "misaligned buffer 0x%x\n", elts.start );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( elts.start < buf->used ) {
DRM_ERROR( "no header 0x%x - 0x%x\n", elts.start, buf->used );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
buf->used = elts.end;
@@ -1328,9 +1328,9 @@ int radeon_cp_indices( DRM_OS_IOCTL )
return 0;
}
-int radeon_cp_texture( DRM_OS_IOCTL )
+int radeon_cp_texture( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_texture_t tex;
drm_radeon_tex_image_t image;
@@ -1338,17 +1338,17 @@ int radeon_cp_texture( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( tex, (drm_radeon_texture_t *)data, sizeof(tex) );
+ DRM_COPY_FROM_USER_IOCTL( tex, (drm_radeon_texture_t *)data, sizeof(tex) );
if ( tex.image == NULL ) {
DRM_ERROR( "null texture image!\n" );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- if ( DRM_OS_COPYFROMUSR( &image,
+ if ( DRM_COPY_FROM_USER( &image,
(drm_radeon_tex_image_t *)tex.image,
sizeof(image) ) )
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
RING_SPACE_TEST_WITH_RETURN( dev_priv );
VB_AGE_TEST_WITH_RETURN( dev_priv );
@@ -1359,20 +1359,20 @@ int radeon_cp_texture( DRM_OS_IOCTL )
return ret;
}
-int radeon_cp_stipple( DRM_OS_IOCTL )
+int radeon_cp_stipple( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_stipple_t stipple;
u32 mask[32];
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( stipple, (drm_radeon_stipple_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( stipple, (drm_radeon_stipple_t *)data,
sizeof(stipple) );
- if ( DRM_OS_COPYFROMUSR( &mask, stipple.mask, 32 * sizeof(u32) ) )
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( &mask, stipple.mask, 32 * sizeof(u32) ) )
+ return DRM_ERR(EFAULT);
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1382,9 +1382,9 @@ int radeon_cp_stipple( DRM_OS_IOCTL )
return 0;
}
-int radeon_cp_indirect( DRM_OS_IOCTL )
+int radeon_cp_indirect( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_device_dma_t *dma = dev->dma;
drm_buf_t *buf;
@@ -1395,10 +1395,10 @@ int radeon_cp_indirect( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( indirect, (drm_radeon_indirect_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( indirect, (drm_radeon_indirect_t *)data,
sizeof(indirect) );
DRM_DEBUG( "indirect: idx=%d s=%d e=%d d=%d\n",
@@ -1408,25 +1408,25 @@ int radeon_cp_indirect( DRM_OS_IOCTL )
if ( indirect.idx < 0 || indirect.idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
indirect.idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
buf = dma->buflist[indirect.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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, buf->pid );
+ return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
DRM_ERROR( "sending pending buffer %d\n", indirect.idx );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( indirect.start < buf->used ) {
DRM_ERROR( "reusing indirect: start=0x%x actual=0x%x\n",
indirect.start, buf->used );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1457,9 +1457,9 @@ int radeon_cp_indirect( DRM_OS_IOCTL )
return 0;
}
-int radeon_cp_vertex2( DRM_OS_IOCTL )
+int radeon_cp_vertex2( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_device_dma_t *dma = dev->dma;
@@ -1472,20 +1472,20 @@ int radeon_cp_vertex2( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( vertex, (drm_radeon_vertex2_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( vertex, (drm_radeon_vertex2_t *)data,
sizeof(vertex) );
DRM_DEBUG( "pid=%d index=%d discard=%d\n",
- DRM_OS_CURRENTPID,
+ DRM_CURRENTPID,
vertex.idx, vertex.discard );
if ( vertex.idx < 0 || vertex.idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
vertex.idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1493,34 +1493,34 @@ int radeon_cp_vertex2( DRM_OS_IOCTL )
buf = dma->buflist[vertex.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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, buf->pid );
+ return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
DRM_ERROR( "sending pending buffer %d\n", vertex.idx );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
for (laststate = 0xff, i = 0 ; i < vertex.nr_prims ; i++) {
drm_radeon_prim_t prim;
drm_radeon_tcl_prim_t tclprim;
- if ( DRM_OS_COPYFROMUSR( &prim, &vertex.prim[i], sizeof(prim) ) )
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( &prim, &vertex.prim[i], sizeof(prim) ) )
+ return DRM_ERR(EFAULT);
if ( prim.stateidx != laststate ) {
drm_radeon_state_t state;
- if ( DRM_OS_COPYFROMUSR( &state,
+ if ( DRM_COPY_FROM_USER( &state,
&vertex.state[prim.stateidx],
sizeof(state) ) )
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
radeon_emit_state2( dev_priv, &state );
@@ -1573,7 +1573,7 @@ static int radeon_emit_packets(
RING_LOCALS;
if (sz * sizeof(int) > cmdbuf->bufsz)
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
BEGIN_RING(sz+1);
OUT_RING( CP_PACKET0( reg, (sz-1) ) );
@@ -1642,14 +1642,14 @@ static int radeon_emit_packet3( drm_device_t *dev,
DRM_DEBUG("\n");
- if (DRM_OS_FETCHU_32_NC( tmp, &cmd[0]))
- return DRM_OS_ERR(EFAULT);
+ if (DRM_GET_USER_UNCHECKED( tmp, &cmd[0]))
+ return DRM_ERR(EFAULT);
cmdsz = 2 + ((tmp & RADEON_CP_PACKET_COUNT_MASK) >> 16);
if ((tmp & 0xc0000000) != RADEON_CP_PACKET3 ||
cmdsz * 4 > cmdbuf->bufsz)
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
BEGIN_RING( cmdsz );
OUT_RING_USER_TABLE( cmd, cmdsz );
@@ -1674,19 +1674,19 @@ static int radeon_emit_packet3_cliprect( drm_device_t *dev,
DRM_DEBUG("\n");
- if (DRM_OS_FETCHU_32_NC( tmp, &cmd[0]))
- return DRM_OS_ERR(EFAULT);
+ if (DRM_GET_USER_UNCHECKED( tmp, &cmd[0]))
+ return DRM_ERR(EFAULT);
cmdsz = 2 + ((tmp & RADEON_CP_PACKET_COUNT_MASK) >> 16);
if ((tmp & 0xc0000000) != RADEON_CP_PACKET3 ||
cmdsz * 4 > cmdbuf->bufsz)
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
do {
if ( i < cmdbuf->nbox ) {
- if (DRM_OS_COPYFROMUSR_NC( &box, &boxes[i], sizeof(box) ))
- return DRM_OS_ERR(EFAULT);
+ if (DRM_COPY_FROM_USER_UNCHECKED( &box, &boxes[i], sizeof(box) ))
+ return DRM_ERR(EFAULT);
radeon_emit_clip_rect( dev_priv, &box );
}
@@ -1706,9 +1706,9 @@ static int radeon_emit_packet3_cliprect( drm_device_t *dev,
-int radeon_cp_cmdbuf( DRM_OS_IOCTL )
+int radeon_cp_cmdbuf( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_device_dma_t *dma = dev->dma;
drm_buf_t *buf = 0;
@@ -1720,30 +1720,30 @@ int radeon_cp_cmdbuf( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( cmdbuf, (drm_radeon_cmd_buffer_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( cmdbuf, (drm_radeon_cmd_buffer_t *)data,
sizeof(cmdbuf) );
- DRM_DEBUG( "pid=%d\n", DRM_OS_CURRENTPID );
+ DRM_DEBUG( "pid=%d\n", DRM_CURRENTPID );
RING_SPACE_TEST_WITH_RETURN( dev_priv );
VB_AGE_TEST_WITH_RETURN( dev_priv );
- if (DRM_OS_VERIFYAREA_READ( cmdbuf.buf, cmdbuf.bufsz ))
- return DRM_OS_ERR(EFAULT);
+ if (DRM_VERIFYAREA_READ( cmdbuf.buf, cmdbuf.bufsz ))
+ return DRM_ERR(EFAULT);
if (cmdbuf.nbox &&
- DRM_OS_VERIFYAREA_READ(cmdbuf.boxes,
+ DRM_VERIFYAREA_READ(cmdbuf.boxes,
cmdbuf.nbox * sizeof(drm_clip_rect_t)))
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
while ( cmdbuf.bufsz >= sizeof(header) ) {
- if (DRM_OS_FETCHU_32_NC( header.i, (int *)cmdbuf.buf )) {
+ if (DRM_GET_USER_UNCHECKED( header.i, (int *)cmdbuf.buf )) {
DRM_ERROR("__get_user %p\n", cmdbuf.buf);
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
}
cmdbuf.buf += sizeof(header);
@@ -1753,21 +1753,21 @@ int radeon_cp_cmdbuf( DRM_OS_IOCTL )
case RADEON_CMD_PACKET:
if (radeon_emit_packets( dev_priv, header, &cmdbuf )) {
DRM_ERROR("radeon_emit_packets failed\n");
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
break;
case RADEON_CMD_SCALARS:
if (radeon_emit_scalars( dev_priv, header, &cmdbuf )) {
DRM_ERROR("radeon_emit_scalars failed\n");
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
break;
case RADEON_CMD_VECTORS:
if (radeon_emit_vectors( dev_priv, header, &cmdbuf )) {
DRM_ERROR("radeon_emit_vectors failed\n");
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
break;
@@ -1776,13 +1776,13 @@ int radeon_cp_cmdbuf( DRM_OS_IOCTL )
if ( idx < 0 || idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
buf = dma->buflist[idx];
- if ( buf->pid != DRM_OS_CURRENTPID || buf->pending ) {
+ if ( buf->pid != DRM_CURRENTPID || buf->pending ) {
DRM_ERROR( "bad buffer\n" );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
radeon_cp_discard_buffer( dev, buf );
@@ -1791,14 +1791,14 @@ int radeon_cp_cmdbuf( DRM_OS_IOCTL )
case RADEON_CMD_PACKET3:
if (radeon_emit_packet3( dev, &cmdbuf )) {
DRM_ERROR("radeon_emit_packet3 failed\n");
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
break;
case RADEON_CMD_PACKET3_CLIP:
if (radeon_emit_packet3_cliprect( dev, &cmdbuf )) {
DRM_ERROR("radeon_emit_packet3_clip failed\n");
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
break;
@@ -1806,7 +1806,7 @@ int radeon_cp_cmdbuf( DRM_OS_IOCTL )
DRM_ERROR("bad cmd_type %d at %p\n",
header.header.cmd_type,
cmdbuf.buf - sizeof(header));
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
}
@@ -1817,34 +1817,34 @@ int radeon_cp_cmdbuf( DRM_OS_IOCTL )
-int radeon_cp_getparam( DRM_OS_IOCTL )
+int radeon_cp_getparam( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_getparam_t param;
int value;
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( param, (drm_radeon_getparam_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( param, (drm_radeon_getparam_t *)data,
sizeof(param) );
- DRM_DEBUG( "pid=%d\n", DRM_OS_CURRENTPID );
+ DRM_DEBUG( "pid=%d\n", DRM_CURRENTPID );
switch( param.param ) {
case RADEON_PARAM_AGP_BUFFER_OFFSET:
value = dev_priv->agp_buffers_offset;
break;
default:
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- if ( DRM_OS_COPYTOUSR( param.value, &value, sizeof(int) ) ) {
+ if ( DRM_COPY_TO_USER( param.value, &value, sizeof(int) ) ) {
DRM_ERROR( "copy_to_user\n" );
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
}
return 0;
diff --git a/shared/mga_dma.c b/shared/mga_dma.c
index 0802ba2f..1d64e1ca 100644
--- a/shared/mga_dma.c
+++ b/shared/mga_dma.c
@@ -59,14 +59,14 @@ int mga_do_wait_for_idle( drm_mga_private_t *dev_priv )
MGA_WRITE8( MGA_CRTC_INDEX, 0 );
return 0;
}
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if MGA_DMA_DEBUG
DRM_ERROR( "failed!\n" );
DRM_INFO( " status=0x%08x\n", status );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
int mga_do_dma_idle( drm_mga_private_t *dev_priv )
@@ -78,13 +78,13 @@ int mga_do_dma_idle( drm_mga_private_t *dev_priv )
for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) {
status = MGA_READ( MGA_STATUS ) & MGA_DMA_IDLE_MASK;
if ( status == MGA_ENDPRDMASTS ) return 0;
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if MGA_DMA_DEBUG
DRM_ERROR( "failed! status=0x%08x\n", status );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
int mga_do_dma_reset( drm_mga_private_t *dev_priv )
@@ -119,7 +119,7 @@ int mga_do_engine_reset( drm_mga_private_t *dev_priv )
* How about we clean up after ourselves?
*/
MGA_WRITE( MGA_RST, MGA_SOFTRESET );
- DRM_OS_DELAY( 15 ); /* Wait at least 10 usecs */
+ DRM_UDELAY( 15 ); /* Wait at least 10 usecs */
MGA_WRITE( MGA_RST, 0 );
/* Initialize the registers that get clobbered by the soft
@@ -302,7 +302,7 @@ static int mga_freelist_init( drm_device_t *dev, drm_mga_private_t *dev_priv )
dev_priv->head = DRM(alloc)( sizeof(drm_mga_freelist_t),
DRM_MEM_DRIVER );
if ( dev_priv->head == NULL )
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
memset( dev_priv->head, 0, sizeof(drm_mga_freelist_t) );
SET_AGE( &dev_priv->head->age, MGA_BUFFER_USED, 0 );
@@ -314,7 +314,7 @@ static int mga_freelist_init( drm_device_t *dev, drm_mga_private_t *dev_priv )
entry = DRM(alloc)( sizeof(drm_mga_freelist_t),
DRM_MEM_DRIVER );
if ( entry == NULL )
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
memset( entry, 0, sizeof(drm_mga_freelist_t) );
@@ -451,7 +451,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
dev_priv = DRM(alloc)( sizeof(drm_mga_private_t), DRM_MEM_DRIVER );
if ( !dev_priv )
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
memset( dev_priv, 0, sizeof(drm_mga_private_t) );
@@ -481,14 +481,14 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
dev_priv->texture_offset = init->texture_offset[0];
dev_priv->texture_size = init->texture_size[0];
- DRM_OS_GETSAREA();
+ DRM_GETSAREA();
if(!dev_priv->sarea) {
DRM_ERROR( "failed to find sarea!\n" );
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->fb, init->fb_offset );
@@ -497,7 +497,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset );
if(!dev_priv->mmio) {
@@ -505,7 +505,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->status, init->status_offset );
if(!dev_priv->status) {
@@ -513,7 +513,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->warp, init->warp_offset );
@@ -522,7 +522,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->primary, init->primary_offset );
if(!dev_priv->primary) {
@@ -530,7 +530,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
if(!dev_priv->buffers) {
@@ -538,7 +538,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
dev_priv->sarea_priv =
@@ -556,7 +556,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
ret = mga_warp_install_microcode( dev_priv );
@@ -618,7 +618,7 @@ static int mga_do_init_dma( drm_device_t *dev, drm_mga_init_t *init )
/* Assign dev_private so we can do cleanup. */
dev->dev_private = (void *)dev_priv;
mga_do_cleanup_dma( dev );
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
/* Make dev_private visable to others. */
@@ -649,12 +649,12 @@ int mga_do_cleanup_dma( drm_device_t *dev )
return 0;
}
-int mga_dma_init( DRM_OS_IOCTL )
+int mga_dma_init( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_mga_init_t init;
- DRM_OS_KRNFROMUSR( init, (drm_mga_init_t *)data, sizeof(init) );
+ DRM_COPY_FROM_USER_IOCTL( init, (drm_mga_init_t *)data, sizeof(init) );
switch ( init.func ) {
case MGA_INIT_DMA:
@@ -663,7 +663,7 @@ int mga_dma_init( DRM_OS_IOCTL )
return mga_do_cleanup_dma( dev );
}
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
@@ -671,15 +671,15 @@ int mga_dma_init( DRM_OS_IOCTL )
* Primary DMA stream management
*/
-int mga_dma_flush( DRM_OS_IOCTL )
+int mga_dma_flush( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
drm_lock_t lock;
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( lock, (drm_lock_t *)data, sizeof(lock) );
+ DRM_COPY_FROM_USER_IOCTL( lock, (drm_lock_t *)data, sizeof(lock) );
DRM_DEBUG( "%s%s%s\n",
(lock.flags & _DRM_LOCK_FLUSH) ? "flush, " : "",
@@ -706,9 +706,9 @@ int mga_dma_flush( DRM_OS_IOCTL )
}
}
-int mga_dma_reset( DRM_OS_IOCTL )
+int mga_dma_reset( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
LOCK_TEST_WITH_RETURN( dev );
@@ -728,25 +728,25 @@ static int mga_dma_get_buffers( drm_device_t *dev, drm_dma_t *d )
for ( i = d->granted_count ; i < d->request_count ; i++ ) {
buf = mga_freelist_get( dev );
- if ( !buf ) return DRM_OS_ERR(EAGAIN);
+ if ( !buf ) return DRM_ERR(EAGAIN);
- buf->pid = DRM_OS_CURRENTPID;
+ buf->pid = DRM_CURRENTPID;
- if ( DRM_OS_COPYTOUSR( &d->request_indices[i],
+ if ( DRM_COPY_TO_USER( &d->request_indices[i],
&buf->idx, sizeof(buf->idx) ) )
- return DRM_OS_ERR(EFAULT);
- if ( DRM_OS_COPYTOUSR( &d->request_sizes[i],
+ return DRM_ERR(EFAULT);
+ if ( DRM_COPY_TO_USER( &d->request_sizes[i],
&buf->total, sizeof(buf->total) ) )
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
d->granted_count++;
}
return 0;
}
-int mga_dma_buffers( DRM_OS_IOCTL )
+int mga_dma_buffers( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
drm_mga_private_t *dev_priv = (drm_mga_private_t *)dev->dev_private;
drm_dma_t d;
@@ -754,22 +754,22 @@ int mga_dma_buffers( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( d, (drm_dma_t *)data, sizeof(d) );
+ DRM_COPY_FROM_USER_IOCTL( d, (drm_dma_t *)data, sizeof(d) );
/* Please don't send us buffers.
*/
if ( d.send_count != 0 ) {
DRM_ERROR( "Process %d trying to send %d buffers via drmDMA\n",
- DRM_OS_CURRENTPID, d.send_count );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, d.send_count );
+ return DRM_ERR(EINVAL);
}
/* We'll send you buffers.
*/
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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, d.request_count, dma->buf_count );
+ return DRM_ERR(EINVAL);
}
WRAP_TEST_WITH_RETURN( dev_priv );
@@ -780,7 +780,7 @@ int mga_dma_buffers( DRM_OS_IOCTL )
ret = mga_dma_get_buffers( dev, &d );
}
- DRM_OS_KRNTOUSR( (drm_dma_t *)data, d, sizeof(d) );
+ DRM_COPY_TO_USER_IOCTL( (drm_dma_t *)data, d, sizeof(d) );
return ret;
}
diff --git a/shared/mga_drv.h b/shared/mga_drv.h
index b922c663..d50c10ec 100644
--- a/shared/mga_drv.h
+++ b/shared/mga_drv.h
@@ -101,10 +101,10 @@ typedef struct drm_mga_private {
} drm_mga_private_t;
/* mga_dma.c */
-extern int mga_dma_init( DRM_OS_IOCTL );
-extern int mga_dma_flush( DRM_OS_IOCTL );
-extern int mga_dma_reset( DRM_OS_IOCTL );
-extern int mga_dma_buffers( DRM_OS_IOCTL );
+extern int mga_dma_init( DRM_IOCTL_ARGS );
+extern int mga_dma_flush( DRM_IOCTL_ARGS );
+extern int mga_dma_reset( DRM_IOCTL_ARGS );
+extern int mga_dma_buffers( DRM_IOCTL_ARGS );
extern int mga_do_wait_for_idle( drm_mga_private_t *dev_priv );
extern int mga_do_dma_idle( drm_mga_private_t *dev_priv );
@@ -119,18 +119,18 @@ extern void mga_do_dma_wrap_end( drm_mga_private_t *dev_priv );
extern int mga_freelist_put( drm_device_t *dev, drm_buf_t *buf );
/* mga_state.c */
-extern int mga_dma_clear( DRM_OS_IOCTL );
-extern int mga_dma_swap( DRM_OS_IOCTL );
-extern int mga_dma_vertex( DRM_OS_IOCTL );
-extern int mga_dma_indices( DRM_OS_IOCTL );
-extern int mga_dma_iload( DRM_OS_IOCTL );
-extern int mga_dma_blit( DRM_OS_IOCTL );
+extern int mga_dma_clear( DRM_IOCTL_ARGS );
+extern int mga_dma_swap( DRM_IOCTL_ARGS );
+extern int mga_dma_vertex( DRM_IOCTL_ARGS );
+extern int mga_dma_indices( DRM_IOCTL_ARGS );
+extern int mga_dma_iload( DRM_IOCTL_ARGS );
+extern int mga_dma_blit( DRM_IOCTL_ARGS );
/* mga_warp.c */
extern int mga_warp_install_microcode( drm_mga_private_t *dev_priv );
extern int mga_warp_init( drm_mga_private_t *dev_priv );
-#define mga_flush_write_combine() DRM_OS_WRITEMEMORYBARRIER()
+#define mga_flush_write_combine() DRM_WRITEMEMORYBARRIER()
#define MGA_BASE( reg ) ((unsigned long)(dev_priv->mmio->handle))
@@ -141,12 +141,12 @@ extern int mga_warp_init( drm_mga_private_t *dev_priv );
#ifdef __alpha__
#define MGA_READ( reg ) (_MGA_READ((u32 *)MGA_ADDR(reg)))
-#define MGA_WRITE( reg, val ) do { DRM_OS_WRITEMEMORYBARRIER(); MGA_DEREF( reg ) = val; } while (0)
-#define MGA_WRITE8( reg, val ) do { DRM_OS_WRITEMEMORYBARRIER(); MGA_DEREF8( reg ) = val; } while (0)
+#define MGA_WRITE( reg, val ) do { DRM_WRITEMEMORYBARRIER(); MGA_DEREF( reg ) = val; } while (0)
+#define MGA_WRITE8( reg, val ) do { DRM_WRITEMEMORYBARRIER(); MGA_DEREF8( reg ) = val; } while (0)
static inline u32 _MGA_READ(u32 *addr)
{
- DRM_OS_READMEMORYBARRIER();
+ DRM_READMEMORYBARRIER();
return *(volatile u32 *)addr;
}
@@ -186,10 +186,10 @@ do { \
#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", \
__func__ ); \
- return DRM_OS_ERR(EINVAL); \
+ return DRM_ERR(EINVAL); \
} \
} while (0)
@@ -202,7 +202,7 @@ do { \
dev_priv->prim.high_mark ) { \
if ( MGA_DMA_DEBUG ) \
DRM_INFO( "%s: wrap...\n", __func__ ); \
- return DRM_OS_ERR(EBUSY); \
+ return DRM_ERR(EBUSY); \
} \
} \
} while (0)
@@ -213,7 +213,7 @@ do { \
if ( mga_do_wait_for_idle( dev_priv ) < 0 ) { \
if ( MGA_DMA_DEBUG ) \
DRM_INFO( "%s: wrap...\n", __func__ ); \
- return DRM_OS_ERR(EBUSY); \
+ return DRM_ERR(EBUSY); \
} \
mga_do_dma_wrap_end( dev_priv ); \
} \
diff --git a/shared/mga_state.c b/shared/mga_state.c
index 4001d360..adf67de3 100644
--- a/shared/mga_state.c
+++ b/shared/mga_state.c
@@ -421,7 +421,7 @@ static int mga_verify_context( drm_mga_private_t *dev_priv )
ctx->dstorg, dev_priv->front_offset,
dev_priv->back_offset );
ctx->dstorg = 0;
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
return 0;
@@ -441,7 +441,7 @@ static int mga_verify_tex( drm_mga_private_t *dev_priv, int unit )
DRM_ERROR( "*** bad TEXORG: 0x%x, unit %d\n",
tex->texorg, unit );
tex->texorg = 0;
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
return 0;
@@ -483,13 +483,13 @@ static int mga_verify_iload( drm_mga_private_t *dev_priv,
dstorg + length > (dev_priv->texture_offset +
dev_priv->texture_size) ) {
DRM_ERROR( "*** bad iload DSTORG: 0x%x\n", dstorg );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( length & MGA_ILOAD_MASK ) {
DRM_ERROR( "*** bad iload length: 0x%x\n",
length & MGA_ILOAD_MASK );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
return 0;
@@ -502,7 +502,7 @@ static int mga_verify_blit( drm_mga_private_t *dev_priv,
(dstorg & 0x3) == (MGA_SRCACC_PCI | MGA_SRCMAP_SYSMEM) ) {
DRM_ERROR( "*** bad blit: src=0x%x dst=0x%x\n",
srcorg, dstorg );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
return 0;
}
@@ -881,16 +881,16 @@ static void mga_dma_dispatch_blit( drm_device_t *dev,
*
*/
-int mga_dma_clear( DRM_OS_IOCTL )
+int mga_dma_clear( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_mga_private_t *dev_priv = dev->dev_private;
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_mga_clear_t clear;
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( clear, (drm_mga_clear_t *)data, sizeof(clear) );
+ DRM_COPY_FROM_USER_IOCTL( clear, (drm_mga_clear_t *)data, sizeof(clear) );
if ( sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS )
sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
@@ -906,9 +906,9 @@ int mga_dma_clear( DRM_OS_IOCTL )
return 0;
}
-int mga_dma_swap( DRM_OS_IOCTL )
+int mga_dma_swap( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_mga_private_t *dev_priv = dev->dev_private;
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
@@ -928,9 +928,9 @@ int mga_dma_swap( DRM_OS_IOCTL )
return 0;
}
-int mga_dma_vertex( DRM_OS_IOCTL )
+int mga_dma_vertex( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_mga_private_t *dev_priv = dev->dev_private;
drm_device_dma_t *dma = dev->dma;
drm_buf_t *buf;
@@ -939,11 +939,11 @@ int mga_dma_vertex( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( vertex,
+ DRM_COPY_FROM_USER_IOCTL( vertex,
(drm_mga_vertex_t *)data,
sizeof(vertex) );
- if(vertex.idx < 0 || vertex.idx > dma->buf_count) return DRM_OS_ERR(EINVAL);
+ if(vertex.idx < 0 || vertex.idx > dma->buf_count) return DRM_ERR(EINVAL);
buf = dma->buflist[vertex.idx];
buf_priv = buf->dev_private;
@@ -957,7 +957,7 @@ int mga_dma_vertex( DRM_OS_IOCTL )
buf_priv->dispatched = 0;
mga_freelist_put( dev, buf );
}
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
WRAP_TEST_WITH_RETURN( dev_priv );
@@ -967,9 +967,9 @@ int mga_dma_vertex( DRM_OS_IOCTL )
return 0;
}
-int mga_dma_indices( DRM_OS_IOCTL )
+int mga_dma_indices( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_mga_private_t *dev_priv = dev->dev_private;
drm_device_dma_t *dma = dev->dma;
drm_buf_t *buf;
@@ -978,11 +978,11 @@ int mga_dma_indices( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( indices,
+ DRM_COPY_FROM_USER_IOCTL( indices,
(drm_mga_indices_t *)data,
sizeof(indices) );
- if(indices.idx < 0 || indices.idx > dma->buf_count) return DRM_OS_ERR(EINVAL);
+ if(indices.idx < 0 || indices.idx > dma->buf_count) return DRM_ERR(EINVAL);
buf = dma->buflist[indices.idx];
buf_priv = buf->dev_private;
@@ -996,7 +996,7 @@ int mga_dma_indices( DRM_OS_IOCTL )
buf_priv->dispatched = 0;
mga_freelist_put( dev, buf );
}
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
WRAP_TEST_WITH_RETURN( dev_priv );
@@ -1006,9 +1006,9 @@ int mga_dma_indices( DRM_OS_IOCTL )
return 0;
}
-int mga_dma_iload( DRM_OS_IOCTL )
+int mga_dma_iload( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
drm_mga_private_t *dev_priv = dev->dev_private;
drm_buf_t *buf;
@@ -1018,23 +1018,23 @@ int mga_dma_iload( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( iload, (drm_mga_iload_t *)data, sizeof(iload) );
+ DRM_COPY_FROM_USER_IOCTL( iload, (drm_mga_iload_t *)data, sizeof(iload) );
#if 0
if ( mga_do_wait_for_idle( dev_priv ) < 0 ) {
if ( MGA_DMA_DEBUG )
DRM_INFO( "%s: -EBUSY\n", __func__ );
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
#endif
- if(iload.idx < 0 || iload.idx > dma->buf_count) return DRM_OS_ERR(EINVAL);
+ if(iload.idx < 0 || iload.idx > dma->buf_count) return DRM_ERR(EINVAL);
buf = dma->buflist[iload.idx];
buf_priv = buf->dev_private;
if ( mga_verify_iload( dev_priv, iload.dstorg, iload.length ) ) {
mga_freelist_put( dev, buf );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
WRAP_TEST_WITH_RETURN( dev_priv );
@@ -1048,9 +1048,9 @@ int mga_dma_iload( DRM_OS_IOCTL )
return 0;
}
-int mga_dma_blit( DRM_OS_IOCTL )
+int mga_dma_blit( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_mga_private_t *dev_priv = dev->dev_private;
drm_mga_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_mga_blit_t blit;
@@ -1058,13 +1058,13 @@ int mga_dma_blit( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( blit, (drm_mga_blit_t *)data, sizeof(blit) );
+ DRM_COPY_FROM_USER_IOCTL( blit, (drm_mga_blit_t *)data, sizeof(blit) );
if ( sarea_priv->nbox > MGA_NR_SAREA_CLIPRECTS )
sarea_priv->nbox = MGA_NR_SAREA_CLIPRECTS;
if ( mga_verify_blit( dev_priv, blit.srcorg, blit.dstorg ) )
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
WRAP_TEST_WITH_RETURN( dev_priv );
diff --git a/shared/mga_warp.c b/shared/mga_warp.c
index 7bc1a010..ea7f53a6 100644
--- a/shared/mga_warp.c
+++ b/shared/mga_warp.c
@@ -107,7 +107,7 @@ static int mga_warp_install_g400_microcode( drm_mga_private_t *dev_priv )
if ( size > dev_priv->warp->size ) {
DRM_ERROR( "microcode too large! (%u > %lu)\n",
size, dev_priv->warp->size );
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
memset( dev_priv->warp_pipe_phys, 0,
@@ -144,7 +144,7 @@ static int mga_warp_install_g200_microcode( drm_mga_private_t *dev_priv )
if ( size > dev_priv->warp->size ) {
DRM_ERROR( "microcode too large! (%u > %lu)\n",
size, dev_priv->warp->size );
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
memset( dev_priv->warp_pipe_phys, 0,
@@ -170,7 +170,7 @@ int mga_warp_install_microcode( drm_mga_private_t *dev_priv )
case MGA_CARD_TYPE_G200:
return mga_warp_install_g200_microcode( dev_priv );
default:
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
}
@@ -195,7 +195,7 @@ int mga_warp_init( drm_mga_private_t *dev_priv )
MGA_WRITE( MGA_WVRTXSZ, 7 );
break;
default:
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
MGA_WRITE( MGA_WMISC, (MGA_WUCODECACHE_ENABLE |
@@ -205,7 +205,7 @@ int mga_warp_init( drm_mga_private_t *dev_priv )
if ( wmisc != WMISC_EXPECTED ) {
DRM_ERROR( "WARP engine config failed! 0x%x != 0x%x\n",
wmisc, WMISC_EXPECTED );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
return 0;
diff --git a/shared/r128_cce.c b/shared/r128_cce.c
index 7ff773ff..f52b9a67 100644
--- a/shared/r128_cce.c
+++ b/shared/r128_cce.c
@@ -126,13 +126,13 @@ static int r128_do_pixcache_flush( drm_r128_private_t *dev_priv )
if ( !(R128_READ( R128_PC_NGUI_CTLSTAT ) & R128_PC_BUSY) ) {
return 0;
}
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if R128_FIFO_DEBUG
DRM_ERROR( "failed!\n" );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
static int r128_do_wait_for_fifo( drm_r128_private_t *dev_priv, int entries )
@@ -142,13 +142,13 @@ static int r128_do_wait_for_fifo( drm_r128_private_t *dev_priv, int entries )
for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) {
int slots = R128_READ( R128_GUI_STAT ) & R128_GUI_FIFOCNT_MASK;
if ( slots >= entries ) return 0;
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if R128_FIFO_DEBUG
DRM_ERROR( "failed!\n" );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
int r128_do_wait_for_idle( drm_r128_private_t *dev_priv )
@@ -163,13 +163,13 @@ int r128_do_wait_for_idle( drm_r128_private_t *dev_priv )
r128_do_pixcache_flush( dev_priv );
return 0;
}
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if R128_FIFO_DEBUG
DRM_ERROR( "failed!\n" );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
@@ -223,14 +223,14 @@ int r128_do_cce_idle( drm_r128_private_t *dev_priv )
return r128_do_pixcache_flush( dev_priv );
}
}
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if R128_FIFO_DEBUG
DRM_ERROR( "failed!\n" );
r128_status( dev_priv );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
/* Start the Concurrent Command Engine.
@@ -378,7 +378,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
dev_priv = DRM(alloc)( sizeof(drm_r128_private_t), DRM_MEM_DRIVER );
if ( dev_priv == NULL )
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
memset( dev_priv, 0, sizeof(drm_r128_private_t) );
@@ -388,7 +388,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_ERROR( "PCI GART memory not allocated!\n" );
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
dev_priv->usec_timeout = init->usec_timeout;
@@ -397,7 +397,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_DEBUG( "TIMEOUT problem!\n" );
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
dev_priv->cce_mode = init->cce_mode;
@@ -417,7 +417,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_DEBUG( "Bad cce_mode!\n" );
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
switch ( init->cce_mode ) {
@@ -479,13 +479,13 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
dev_priv->span_pitch_offset_c = (((dev_priv->depth_pitch/8) << 21) |
(dev_priv->span_offset >> 5));
- DRM_OS_GETSAREA();
+ DRM_GETSAREA();
if(!dev_priv->sarea) {
DRM_ERROR("could not find sarea!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->fb, init->fb_offset );
@@ -493,35 +493,35 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_ERROR("could not find framebuffer!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset );
if(!dev_priv->mmio) {
DRM_ERROR("could not find mmio region!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->cce_ring, init->ring_offset );
if(!dev_priv->cce_ring) {
DRM_ERROR("could not find cce ring region!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->ring_rptr, init->ring_rptr_offset );
if(!dev_priv->ring_rptr) {
DRM_ERROR("could not find ring read pointer!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
if(!dev_priv->buffers) {
DRM_ERROR("could not find dma buffer region!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( !dev_priv->is_pci ) {
@@ -531,7 +531,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_ERROR("could not find agp texture region!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
}
@@ -549,7 +549,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_ERROR("Could not ioremap agp regions!\n");
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
} else {
dev_priv->cce_ring->handle =
@@ -594,7 +594,7 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
DRM_ERROR( "failed to init PCI GART!\n" );
dev->dev_private = (void *)dev_priv;
r128_do_cleanup_cce( dev );
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
R128_WRITE( R128_PCI_GART_PAGE, dev_priv->bus_pci_gart );
}
@@ -638,14 +638,14 @@ int r128_do_cleanup_cce( drm_device_t *dev )
return 0;
}
-int r128_cce_init( DRM_OS_IOCTL )
+int r128_cce_init( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_init_t init;
DRM_DEBUG( "\n" );
- DRM_OS_KRNFROMUSR( init, (drm_r128_init_t *)data, sizeof(init) );
+ DRM_COPY_FROM_USER_IOCTL( init, (drm_r128_init_t *)data, sizeof(init) );
switch ( init.func ) {
case R128_INIT_CCE:
@@ -654,12 +654,12 @@ int r128_cce_init( DRM_OS_IOCTL )
return r128_do_cleanup_cce( dev );
}
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
-int r128_cce_start( DRM_OS_IOCTL )
+int r128_cce_start( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
@@ -678,9 +678,9 @@ int r128_cce_start( DRM_OS_IOCTL )
/* Stop the CCE. The engine must have been idled before calling this
* routine.
*/
-int r128_cce_stop( DRM_OS_IOCTL )
+int r128_cce_stop( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_r128_cce_stop_t stop;
int ret;
@@ -688,7 +688,7 @@ int r128_cce_stop( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR(stop, (drm_r128_cce_stop_t *)data, sizeof(stop) );
+ DRM_COPY_FROM_USER_IOCTL(stop, (drm_r128_cce_stop_t *)data, sizeof(stop) );
/* Flush any pending CCE commands. This ensures any outstanding
* commands are exectuted by the engine before we turn it off.
@@ -719,9 +719,9 @@ int r128_cce_stop( DRM_OS_IOCTL )
/* Just reset the CCE ring. Called as part of an X Server engine reset.
*/
-int r128_cce_reset( DRM_OS_IOCTL )
+int r128_cce_reset( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
@@ -729,7 +729,7 @@ int r128_cce_reset( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_DEBUG( "%s called before init done\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
r128_do_cce_reset( dev_priv );
@@ -740,9 +740,9 @@ int r128_cce_reset( DRM_OS_IOCTL )
return 0;
}
-int r128_cce_idle( DRM_OS_IOCTL )
+int r128_cce_idle( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
@@ -755,9 +755,9 @@ int r128_cce_idle( DRM_OS_IOCTL )
return r128_do_cce_idle( dev_priv );
}
-int r128_engine_reset( DRM_OS_IOCTL )
+int r128_engine_reset( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
DRM_DEBUG( "\n" );
LOCK_TEST_WITH_RETURN( dev );
@@ -802,14 +802,14 @@ int r128_do_cleanup_pageflip( drm_device_t *dev )
return 0;
}
-int r128_fullscreen( DRM_OS_IOCTL )
+int r128_fullscreen( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_fullscreen_t fs;
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( fs, (drm_r128_fullscreen_t *)data, sizeof(fs) );
+ DRM_COPY_FROM_USER_IOCTL( fs, (drm_r128_fullscreen_t *)data, sizeof(fs) );
switch ( fs.func ) {
case R128_INIT_FULLSCREEN:
@@ -818,7 +818,7 @@ int r128_fullscreen( DRM_OS_IOCTL )
return r128_do_cleanup_pageflip( dev );
}
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
@@ -841,7 +841,7 @@ static int r128_freelist_init( drm_device_t *dev )
dev_priv->head = DRM(alloc)( sizeof(drm_r128_freelist_t),
DRM_MEM_DRIVER );
if ( dev_priv->head == NULL )
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
memset( dev_priv->head, 0, sizeof(drm_r128_freelist_t) );
dev_priv->head->age = R128_BUFFER_USED;
@@ -852,7 +852,7 @@ static int r128_freelist_init( drm_device_t *dev )
entry = DRM(alloc)( sizeof(drm_r128_freelist_t),
DRM_MEM_DRIVER );
- if ( !entry ) return DRM_OS_ERR(ENOMEM);
+ if ( !entry ) return DRM_ERR(ENOMEM);
entry->age = R128_BUFFER_FREE;
entry->buf = buf;
@@ -907,7 +907,7 @@ drm_buf_t *r128_freelist_get( drm_device_t *dev )
return buf;
}
}
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
DRM_ERROR( "returning NULL!\n" );
@@ -940,12 +940,12 @@ int r128_wait_ring( drm_r128_private_t *dev_priv, int n )
r128_update_ring_snapshot( ring );
if ( ring->space >= n )
return 0;
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
/* FIXME: This is being ignored... */
DRM_ERROR( "failed!\n" );
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
static int r128_cce_get_buffers( drm_device_t *dev, drm_dma_t *d )
@@ -955,47 +955,47 @@ static int r128_cce_get_buffers( drm_device_t *dev, drm_dma_t *d )
for ( i = d->granted_count ; i < d->request_count ; i++ ) {
buf = r128_freelist_get( dev );
- if ( !buf ) return DRM_OS_ERR(EAGAIN);
+ if ( !buf ) return DRM_ERR(EAGAIN);
- buf->pid = DRM_OS_CURRENTPID;
+ buf->pid = DRM_CURRENTPID;
- if ( DRM_OS_COPYTOUSR( &d->request_indices[i], &buf->idx,
+ if ( DRM_COPY_TO_USER( &d->request_indices[i], &buf->idx,
sizeof(buf->idx) ) )
- return DRM_OS_ERR(EFAULT);
- if ( DRM_OS_COPYTOUSR( &d->request_sizes[i], &buf->total,
+ return DRM_ERR(EFAULT);
+ if ( DRM_COPY_TO_USER( &d->request_sizes[i], &buf->total,
sizeof(buf->total) ) )
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
d->granted_count++;
}
return 0;
}
-int r128_cce_buffers( DRM_OS_IOCTL )
+int r128_cce_buffers( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
int ret = 0;
drm_dma_t d;
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( d, (drm_dma_t *) data, sizeof(d) );
+ DRM_COPY_FROM_USER_IOCTL( d, (drm_dma_t *) data, sizeof(d) );
/* Please don't send us buffers.
*/
if ( d.send_count != 0 ) {
DRM_ERROR( "Process %d trying to send %d buffers via drmDMA\n",
- DRM_OS_CURRENTPID, d.send_count );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, d.send_count );
+ return DRM_ERR(EINVAL);
}
/* We'll send you buffers.
*/
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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, d.request_count, dma->buf_count );
+ return DRM_ERR(EINVAL);
}
d.granted_count = 0;
@@ -1004,7 +1004,7 @@ int r128_cce_buffers( DRM_OS_IOCTL )
ret = r128_cce_get_buffers( dev, &d );
}
- DRM_OS_KRNTOUSR((drm_dma_t *) data, d, sizeof(d) );
+ DRM_COPY_TO_USER_IOCTL((drm_dma_t *) data, d, sizeof(d) );
return ret;
}
diff --git a/shared/r128_drv.h b/shared/r128_drv.h
index 2b42a5d2..04296590 100644
--- a/shared/r128_drv.h
+++ b/shared/r128_drv.h
@@ -34,8 +34,8 @@
#ifndef __R128_DRV_H__
#define __R128_DRV_H__
-#define GET_RING_HEAD(ring) DRM_OS_READ32( (volatile u32 *) (ring)->head )
-#define SET_RING_HEAD(ring,val) DRM_OS_WRITE32( (volatile u32 *) (ring)->head, (val) )
+#define GET_RING_HEAD(ring) DRM_READ32( (volatile u32 *) (ring)->head )
+#define SET_RING_HEAD(ring,val) DRM_WRITE32( (volatile u32 *) (ring)->head, (val) )
typedef struct drm_r128_freelist {
unsigned int age;
@@ -116,14 +116,14 @@ typedef struct drm_r128_buf_priv {
} drm_r128_buf_priv_t;
/* r128_cce.c */
-extern int r128_cce_init( DRM_OS_IOCTL );
-extern int r128_cce_start( DRM_OS_IOCTL );
-extern int r128_cce_stop( DRM_OS_IOCTL );
-extern int r128_cce_reset( DRM_OS_IOCTL );
-extern int r128_cce_idle( DRM_OS_IOCTL );
-extern int r128_engine_reset( DRM_OS_IOCTL );
-extern int r128_fullscreen( DRM_OS_IOCTL );
-extern int r128_cce_buffers( DRM_OS_IOCTL );
+extern int r128_cce_init( DRM_IOCTL_ARGS );
+extern int r128_cce_start( DRM_IOCTL_ARGS );
+extern int r128_cce_stop( DRM_IOCTL_ARGS );
+extern int r128_cce_reset( DRM_IOCTL_ARGS );
+extern int r128_cce_idle( DRM_IOCTL_ARGS );
+extern int r128_engine_reset( DRM_IOCTL_ARGS );
+extern int r128_fullscreen( DRM_IOCTL_ARGS );
+extern int r128_cce_buffers( DRM_IOCTL_ARGS );
extern void r128_freelist_reset( drm_device_t *dev );
extern drm_buf_t *r128_freelist_get( drm_device_t *dev );
@@ -143,14 +143,14 @@ extern int r128_do_cleanup_cce( drm_device_t *dev );
extern int r128_do_cleanup_pageflip( drm_device_t *dev );
/* r128_state.c */
-extern int r128_cce_clear( DRM_OS_IOCTL );
-extern int r128_cce_swap( DRM_OS_IOCTL );
-extern int r128_cce_vertex( DRM_OS_IOCTL );
-extern int r128_cce_indices( DRM_OS_IOCTL );
-extern int r128_cce_blit( DRM_OS_IOCTL );
-extern int r128_cce_depth( DRM_OS_IOCTL );
-extern int r128_cce_stipple( DRM_OS_IOCTL );
-extern int r128_cce_indirect( DRM_OS_IOCTL );
+extern int r128_cce_clear( DRM_IOCTL_ARGS );
+extern int r128_cce_swap( DRM_IOCTL_ARGS );
+extern int r128_cce_vertex( DRM_IOCTL_ARGS );
+extern int r128_cce_indices( DRM_IOCTL_ARGS );
+extern int r128_cce_blit( DRM_IOCTL_ARGS );
+extern int r128_cce_depth( DRM_IOCTL_ARGS );
+extern int r128_cce_stipple( DRM_IOCTL_ARGS );
+extern int r128_cce_indirect( DRM_IOCTL_ARGS );
/* Register definitions, register access macros and drmAddMap constants
@@ -368,11 +368,11 @@ extern int r128_cce_indirect( DRM_OS_IOCTL );
#define R128_BASE(reg) ((unsigned long)(dev_priv->mmio->handle))
#define R128_ADDR(reg) (R128_BASE( reg ) + reg)
-#define R128_READ(reg) DRM_OS_READ32( (volatile u32 *) R128_ADDR(reg) )
-#define R128_WRITE(reg,val) DRM_OS_WRITE32( (volatile u32 *) R128_ADDR(reg), (val) )
+#define R128_READ(reg) DRM_READ32( (volatile u32 *) R128_ADDR(reg) )
+#define R128_WRITE(reg,val) DRM_WRITE32( (volatile u32 *) R128_ADDR(reg), (val) )
-#define R128_READ8(reg) DRM_OS_READ8( (volatile u8 *) R128_ADDR(reg) )
-#define R128_WRITE8(reg,val) DRM_OS_WRITE8( (volatile u8 *) R128_ADDR(reg), (val) )
+#define R128_READ8(reg) DRM_READ8( (volatile u8 *) R128_ADDR(reg) )
+#define R128_WRITE8(reg,val) DRM_WRITE8( (volatile u8 *) R128_ADDR(reg), (val) )
#define R128_WRITE_PLL(addr,val) \
do { \
@@ -400,9 +400,9 @@ extern int R128_READ_PLL(drm_device_t *dev, int addr);
#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", __func__ ); \
- return DRM_OS_ERR(EINVAL); \
+ return DRM_ERR(EINVAL); \
} \
} while (0)
@@ -414,10 +414,10 @@ do { \
r128_update_ring_snapshot( ring ); \
if ( ring->space >= ring->high_mark ) \
goto __ring_space_done; \
- DRM_OS_DELAY(1); \
+ DRM_UDELAY(1); \
} \
DRM_ERROR( "ring space check failed!\n" ); \
- return DRM_OS_ERR(EBUSY); \
+ return DRM_ERR(EBUSY); \
} \
__ring_space_done: \
; \
@@ -447,7 +447,7 @@ do { \
#if defined(__powerpc__)
#define r128_flush_write_combine() (void) GET_RING_HEAD( &dev_priv->ring )
#else
-#define r128_flush_write_combine() DRM_OS_WRITEMEMORYBARRIER()
+#define r128_flush_write_combine() DRM_WRITEMEMORYBARRIER()
#endif
diff --git a/shared/r128_state.c b/shared/r128_state.c
index 697d8ac8..a8ffd073 100644
--- a/shared/r128_state.c
+++ b/shared/r128_state.c
@@ -809,7 +809,7 @@ static int r128_cce_dispatch_blit( drm_device_t *dev,
break;
default:
DRM_ERROR( "invalid blit format %d\n", blit->format );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
/* Flush the pixel cache, and mark the contents as Read Invalid.
@@ -829,14 +829,14 @@ static int r128_cce_dispatch_blit( drm_device_t *dev,
buf = dma->buflist[blit->idx];
buf_priv = buf->dev_private;
- 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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, buf->pid );
+ return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
DRM_ERROR( "sending pending buffer %d\n", blit->idx );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
buf_priv->discard = 1;
@@ -901,33 +901,33 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
DRM_DEBUG( "\n" );
count = depth->n;
- if ( DRM_OS_COPYFROMUSR( &x, depth->x, sizeof(x) ) ) {
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( &x, depth->x, sizeof(x) ) ) {
+ return DRM_ERR(EFAULT);
}
- if ( DRM_OS_COPYFROMUSR( &y, depth->y, sizeof(y) ) ) {
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( &y, depth->y, sizeof(y) ) ) {
+ return DRM_ERR(EFAULT);
}
- buffer = DRM_OS_MALLOC( depth->n * sizeof(u32) );
+ buffer = DRM_MALLOC( depth->n * sizeof(u32) );
if ( buffer == NULL )
- return DRM_OS_ERR(ENOMEM);
- if ( DRM_OS_COPYFROMUSR( buffer, depth->buffer,
+ return DRM_ERR(ENOMEM);
+ if ( DRM_COPY_FROM_USER( buffer, depth->buffer,
depth->n * sizeof(u32) ) ) {
- DRM_OS_FREE( buffer );
- return DRM_OS_ERR(EFAULT);
+ DRM_FREE( buffer );
+ return DRM_ERR(EFAULT);
}
if ( depth->mask ) {
- mask = DRM_OS_MALLOC( depth->n * sizeof(u8) );
+ mask = DRM_MALLOC( depth->n * sizeof(u8) );
if ( mask == NULL ) {
- DRM_OS_FREE( buffer );
- return DRM_OS_ERR(ENOMEM);
+ DRM_FREE( buffer );
+ return DRM_ERR(ENOMEM);
}
- if ( DRM_OS_COPYFROMUSR( mask, depth->mask,
+ if ( DRM_COPY_FROM_USER( mask, depth->mask,
depth->n * sizeof(u8) ) ) {
- DRM_OS_FREE( buffer );
- DRM_OS_FREE( mask );
- return DRM_OS_ERR(EFAULT);
+ DRM_FREE( buffer );
+ DRM_FREE( mask );
+ return DRM_ERR(EFAULT);
}
for ( i = 0 ; i < count ; i++, x++ ) {
@@ -953,7 +953,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
- DRM_OS_FREE( mask );
+ DRM_FREE( mask );
} else {
for ( i = 0 ; i < count ; i++, x++ ) {
BEGIN_RING( 6 );
@@ -977,7 +977,7 @@ static int r128_cce_dispatch_write_span( drm_device_t *dev,
}
}
- DRM_OS_FREE( buffer );
+ DRM_FREE( buffer );
return 0;
}
@@ -995,55 +995,55 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
count = depth->n;
- x = DRM_OS_MALLOC( count * sizeof(*x) );
+ x = DRM_MALLOC( count * sizeof(*x) );
if ( x == NULL ) {
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
- y = DRM_OS_MALLOC( count * sizeof(*y) );
+ y = DRM_MALLOC( count * sizeof(*y) );
if ( y == NULL ) {
- DRM_OS_FREE( x );
- return DRM_OS_ERR(ENOMEM);
+ DRM_FREE( x );
+ return DRM_ERR(ENOMEM);
}
- if ( DRM_OS_COPYFROMUSR( x, depth->x, count * sizeof(int) ) ) {
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( x, depth->x, count * sizeof(int) ) ) {
+ DRM_FREE( x );
+ DRM_FREE( y );
+ return DRM_ERR(EFAULT);
}
- if ( DRM_OS_COPYFROMUSR( y, depth->y, count * sizeof(int) ) ) {
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( y, depth->y, count * sizeof(int) ) ) {
+ DRM_FREE( x );
+ DRM_FREE( y );
+ return DRM_ERR(EFAULT);
}
- buffer = DRM_OS_MALLOC( depth->n * sizeof(u32) );
+ buffer = DRM_MALLOC( depth->n * sizeof(u32) );
if ( buffer == NULL ) {
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- return DRM_OS_ERR(ENOMEM);
+ DRM_FREE( x );
+ DRM_FREE( y );
+ return DRM_ERR(ENOMEM);
}
- if ( DRM_OS_COPYFROMUSR( buffer, depth->buffer,
+ if ( DRM_COPY_FROM_USER( buffer, depth->buffer,
depth->n * sizeof(u32) ) ) {
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- DRM_OS_FREE( buffer );
- return DRM_OS_ERR(EFAULT);
+ DRM_FREE( x );
+ DRM_FREE( y );
+ DRM_FREE( buffer );
+ return DRM_ERR(EFAULT);
}
if ( depth->mask ) {
- mask = DRM_OS_MALLOC( depth->n * sizeof(u8) );
+ mask = DRM_MALLOC( depth->n * sizeof(u8) );
if ( mask == NULL ) {
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- DRM_OS_FREE( buffer );
- return DRM_OS_ERR(ENOMEM);
+ DRM_FREE( x );
+ DRM_FREE( y );
+ DRM_FREE( buffer );
+ return DRM_ERR(ENOMEM);
}
- if ( DRM_OS_COPYFROMUSR( mask, depth->mask,
+ if ( DRM_COPY_FROM_USER( mask, depth->mask,
depth->n * sizeof(u8) ) ) {
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- DRM_OS_FREE( buffer );
- DRM_OS_FREE( mask );
- return DRM_OS_ERR(EFAULT);
+ DRM_FREE( x );
+ DRM_FREE( y );
+ DRM_FREE( buffer );
+ DRM_FREE( mask );
+ return DRM_ERR(EFAULT);
}
for ( i = 0 ; i < count ; i++ ) {
@@ -1069,7 +1069,7 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
- DRM_OS_FREE( mask );
+ DRM_FREE( mask );
} else {
for ( i = 0 ; i < count ; i++ ) {
BEGIN_RING( 6 );
@@ -1093,9 +1093,9 @@ static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
}
}
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- DRM_OS_FREE( buffer );
+ DRM_FREE( x );
+ DRM_FREE( y );
+ DRM_FREE( buffer );
return 0;
}
@@ -1109,11 +1109,11 @@ static int r128_cce_dispatch_read_span( drm_device_t *dev,
DRM_DEBUG( "\n" );
count = depth->n;
- if ( DRM_OS_COPYFROMUSR( &x, depth->x, sizeof(x) ) ) {
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( &x, depth->x, sizeof(x) ) ) {
+ return DRM_ERR(EFAULT);
}
- if ( DRM_OS_COPYFROMUSR( &y, depth->y, sizeof(y) ) ) {
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( &y, depth->y, sizeof(y) ) ) {
+ return DRM_ERR(EFAULT);
}
BEGIN_RING( 7 );
@@ -1155,24 +1155,24 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
count = dev_priv->depth_pitch;
}
- x = DRM_OS_MALLOC( count * sizeof(*x) );
+ x = DRM_MALLOC( count * sizeof(*x) );
if ( x == NULL ) {
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
- y = DRM_OS_MALLOC( count * sizeof(*y) );
+ y = DRM_MALLOC( count * sizeof(*y) );
if ( y == NULL ) {
- DRM_OS_FREE( x );
- return DRM_OS_ERR(ENOMEM);
+ DRM_FREE( x );
+ return DRM_ERR(ENOMEM);
}
- if ( DRM_OS_COPYFROMUSR( x, depth->x, count * sizeof(int) ) ) {
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( x, depth->x, count * sizeof(int) ) ) {
+ DRM_FREE( x );
+ DRM_FREE( y );
+ return DRM_ERR(EFAULT);
}
- if ( DRM_OS_COPYFROMUSR( y, depth->y, count * sizeof(int) ) ) {
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( y, depth->y, count * sizeof(int) ) ) {
+ DRM_FREE( x );
+ DRM_FREE( y );
+ return DRM_ERR(EFAULT);
}
for ( i = 0 ; i < count ; i++ ) {
@@ -1199,8 +1199,8 @@ static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
ADVANCE_RING();
}
- DRM_OS_FREE( x );
- DRM_OS_FREE( y );
+ DRM_FREE( x );
+ DRM_FREE( y );
return 0;
}
@@ -1232,9 +1232,9 @@ static void r128_cce_dispatch_stipple( drm_device_t *dev, u32 *stipple )
* IOCTL functions
*/
-int r128_cce_clear( DRM_OS_IOCTL )
+int r128_cce_clear( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_r128_clear_t clear;
@@ -1242,7 +1242,7 @@ int r128_cce_clear( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( clear, (drm_r128_clear_t *) data,
+ DRM_COPY_FROM_USER_IOCTL( clear, (drm_r128_clear_t *) data,
sizeof(clear) );
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1259,9 +1259,9 @@ int r128_cce_clear( DRM_OS_IOCTL )
return 0;
}
-int r128_cce_swap( DRM_OS_IOCTL )
+int r128_cce_swap( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
DRM_DEBUG( "%s\n", __func__ );
@@ -1284,9 +1284,9 @@ int r128_cce_swap( DRM_OS_IOCTL )
return 0;
}
-int r128_cce_vertex( DRM_OS_IOCTL )
+int r128_cce_vertex( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_device_dma_t *dma = dev->dma;
drm_buf_t *buf;
@@ -1297,25 +1297,25 @@ int r128_cce_vertex( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( vertex, (drm_r128_vertex_t *) data,
+ DRM_COPY_FROM_USER_IOCTL( vertex, (drm_r128_vertex_t *) data,
sizeof(vertex) );
DRM_DEBUG( "pid=%d index=%d count=%d discard=%d\n",
- DRM_OS_CURRENTPID,
+ DRM_CURRENTPID,
vertex.idx, vertex.count, vertex.discard );
if ( vertex.idx < 0 || vertex.idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
vertex.idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( vertex.prim < 0 ||
vertex.prim > R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 ) {
DRM_ERROR( "buffer prim %d\n", vertex.prim );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1324,14 +1324,14 @@ int r128_cce_vertex( DRM_OS_IOCTL )
buf = dma->buflist[vertex.idx];
buf_priv = buf->dev_private;
- 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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, buf->pid );
+ return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
DRM_ERROR( "sending pending buffer %d\n", vertex.idx );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
buf->used = vertex.count;
@@ -1343,9 +1343,9 @@ int r128_cce_vertex( DRM_OS_IOCTL )
return 0;
}
-int r128_cce_indices( DRM_OS_IOCTL )
+int r128_cce_indices( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_device_dma_t *dma = dev->dma;
drm_buf_t *buf;
@@ -1357,24 +1357,24 @@ int r128_cce_indices( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( elts, (drm_r128_indices_t *) data,
+ DRM_COPY_FROM_USER_IOCTL( elts, (drm_r128_indices_t *) data,
sizeof(elts) );
- DRM_DEBUG( "pid=%d buf=%d s=%d e=%d d=%d\n", DRM_OS_CURRENTPID,
+ DRM_DEBUG( "pid=%d buf=%d s=%d e=%d d=%d\n", DRM_CURRENTPID,
elts.idx, elts.start, elts.end, elts.discard );
if ( elts.idx < 0 || elts.idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
elts.idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( elts.prim < 0 ||
elts.prim > R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2 ) {
DRM_ERROR( "buffer prim %d\n", elts.prim );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1383,14 +1383,14 @@ int r128_cce_indices( DRM_OS_IOCTL )
buf = dma->buflist[elts.idx];
buf_priv = buf->dev_private;
- 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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, buf->pid );
+ return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
DRM_ERROR( "sending pending buffer %d\n", elts.idx );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
count = (elts.end - elts.start) / sizeof(u16);
@@ -1398,11 +1398,11 @@ int r128_cce_indices( DRM_OS_IOCTL )
if ( elts.start & 0x7 ) {
DRM_ERROR( "misaligned buffer 0x%x\n", elts.start );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( elts.start < buf->used ) {
DRM_ERROR( "no header 0x%x - 0x%x\n", elts.start, buf->used );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
buf->used = elts.end;
@@ -1414,24 +1414,24 @@ int r128_cce_indices( DRM_OS_IOCTL )
return 0;
}
-int r128_cce_blit( DRM_OS_IOCTL )
+int r128_cce_blit( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_r128_blit_t blit;
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( blit, (drm_r128_blit_t *) data,
+ DRM_COPY_FROM_USER_IOCTL( blit, (drm_r128_blit_t *) data,
sizeof(blit) );
- DRM_DEBUG( "pid=%d index=%d\n", DRM_OS_CURRENTPID, blit.idx );
+ DRM_DEBUG( "pid=%d index=%d\n", DRM_CURRENTPID, blit.idx );
if ( blit.idx < 0 || blit.idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
blit.idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1440,15 +1440,15 @@ int r128_cce_blit( DRM_OS_IOCTL )
return r128_cce_dispatch_blit( dev, &blit );
}
-int r128_cce_depth( DRM_OS_IOCTL )
+int r128_cce_depth( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_r128_depth_t depth;
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( depth, (drm_r128_depth_t *) data,
+ DRM_COPY_FROM_USER_IOCTL( depth, (drm_r128_depth_t *) data,
sizeof(depth) );
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1464,24 +1464,24 @@ int r128_cce_depth( DRM_OS_IOCTL )
return r128_cce_dispatch_read_pixels( dev, &depth );
}
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
-int r128_cce_stipple( DRM_OS_IOCTL )
+int r128_cce_stipple( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_r128_stipple_t stipple;
u32 mask[32];
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( stipple, (drm_r128_stipple_t *) data,
+ DRM_COPY_FROM_USER_IOCTL( stipple, (drm_r128_stipple_t *) data,
sizeof(stipple) );
- if ( DRM_OS_COPYFROMUSR( &mask, stipple.mask,
+ if ( DRM_COPY_FROM_USER( &mask, stipple.mask,
32 * sizeof(u32) ) )
- return DRM_OS_ERR( EFAULT );
+ return DRM_ERR( EFAULT );
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1490,9 +1490,9 @@ int r128_cce_stipple( DRM_OS_IOCTL )
return 0;
}
-int r128_cce_indirect( DRM_OS_IOCTL )
+int r128_cce_indirect( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_r128_private_t *dev_priv = dev->dev_private;
drm_device_dma_t *dma = dev->dma;
drm_buf_t *buf;
@@ -1506,10 +1506,10 @@ int r128_cce_indirect( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( indirect, (drm_r128_indirect_t *) data,
+ DRM_COPY_FROM_USER_IOCTL( indirect, (drm_r128_indirect_t *) data,
sizeof(indirect) );
DRM_DEBUG( "indirect: idx=%d s=%d e=%d d=%d\n",
@@ -1519,26 +1519,26 @@ int r128_cce_indirect( DRM_OS_IOCTL )
if ( indirect.idx < 0 || indirect.idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
indirect.idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
buf = dma->buflist[indirect.idx];
buf_priv = buf->dev_private;
- 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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, buf->pid );
+ return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
DRM_ERROR( "sending pending buffer %d\n", indirect.idx );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( indirect.start < buf->used ) {
DRM_ERROR( "reusing indirect: start=0x%x actual=0x%x\n",
indirect.start, buf->used );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
RING_SPACE_TEST_WITH_RETURN( dev_priv );
diff --git a/shared/radeon_cp.c b/shared/radeon_cp.c
index 79d7afeb..1ddbdced 100644
--- a/shared/radeon_cp.c
+++ b/shared/radeon_cp.c
@@ -354,14 +354,14 @@ static int radeon_do_pixcache_flush( drm_radeon_private_t *dev_priv )
& RADEON_RB2D_DC_BUSY) ) {
return 0;
}
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if RADEON_FIFO_DEBUG
DRM_ERROR( "failed!\n" );
radeon_status( dev_priv );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
static int radeon_do_wait_for_fifo( drm_radeon_private_t *dev_priv,
@@ -373,14 +373,14 @@ static int radeon_do_wait_for_fifo( drm_radeon_private_t *dev_priv,
int slots = ( RADEON_READ( RADEON_RBBM_STATUS )
& RADEON_RBBM_FIFOCNT_MASK );
if ( slots >= entries ) return 0;
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if RADEON_FIFO_DEBUG
DRM_ERROR( "failed!\n" );
radeon_status( dev_priv );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
static int radeon_do_wait_for_idle( drm_radeon_private_t *dev_priv )
@@ -396,14 +396,14 @@ static int radeon_do_wait_for_idle( drm_radeon_private_t *dev_priv )
radeon_do_pixcache_flush( dev_priv );
return 0;
}
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
#if RADEON_FIFO_DEBUG
DRM_ERROR( "failed!\n" );
radeon_status( dev_priv );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
@@ -657,7 +657,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
dev_priv = DRM(alloc)( sizeof(drm_radeon_private_t), DRM_MEM_DRIVER );
if ( dev_priv == NULL )
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
memset( dev_priv, 0, sizeof(drm_radeon_private_t) );
@@ -670,7 +670,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
DRM_ERROR( "PCI GART not yet supported for Radeon!\n" );
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
#endif
@@ -678,7 +678,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
DRM_ERROR( "PCI GART memory not allocated!\n" );
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
dev_priv->usec_timeout = init->usec_timeout;
@@ -687,7 +687,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
DRM_DEBUG( "TIMEOUT problem!\n" );
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
dev_priv->cp_mode = init->cp_mode;
@@ -705,7 +705,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
DRM_DEBUG( "BAD cp_mode (%x)!\n", init->cp_mode );
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
switch ( init->fb_bpp ) {
@@ -771,13 +771,13 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
RADEON_ROUND_MODE_TRUNC |
RADEON_ROUND_PREC_8TH_PIX);
- DRM_OS_GETSAREA();
+ DRM_GETSAREA();
if(!dev_priv->sarea) {
DRM_ERROR("could not find sarea!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->fb, init->fb_offset );
@@ -785,35 +785,35 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
DRM_ERROR("could not find framebuffer!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->mmio, init->mmio_offset );
if(!dev_priv->mmio) {
DRM_ERROR("could not find mmio region!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->cp_ring, init->ring_offset );
if(!dev_priv->cp_ring) {
DRM_ERROR("could not find cp ring region!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->ring_rptr, init->ring_rptr_offset );
if(!dev_priv->ring_rptr) {
DRM_ERROR("could not find ring read pointer!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_FIND_MAP( dev_priv->buffers, init->buffers_offset );
if(!dev_priv->buffers) {
DRM_ERROR("could not find dma buffer region!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( !dev_priv->is_pci ) {
@@ -823,7 +823,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
DRM_ERROR("could not find agp texture region!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
}
@@ -841,7 +841,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
DRM_ERROR("could not find ioremap agp regions!\n");
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
} else {
dev_priv->cp_ring->handle =
@@ -928,7 +928,7 @@ static int radeon_do_init_cp( drm_device_t *dev, drm_radeon_init_t *init )
DRM_ERROR( "failed to init PCI GART!\n" );
dev->dev_private = (void *)dev_priv;
radeon_do_cleanup_cp(dev);
- return DRM_OS_ERR(ENOMEM);
+ return DRM_ERR(ENOMEM);
}
/* Turn on PCI GART
*/
@@ -1001,12 +1001,12 @@ int radeon_do_cleanup_cp( drm_device_t *dev )
return 0;
}
-int radeon_cp_init( DRM_OS_IOCTL )
+int radeon_cp_init( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_init_t init;
- DRM_OS_KRNFROMUSR( init, (drm_radeon_init_t *)data, sizeof(init) );
+ DRM_COPY_FROM_USER_IOCTL( init, (drm_radeon_init_t *)data, sizeof(init) );
switch ( init.func ) {
case RADEON_INIT_CP:
@@ -1015,12 +1015,12 @@ int radeon_cp_init( DRM_OS_IOCTL )
return radeon_do_cleanup_cp( dev );
}
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
-int radeon_cp_start( DRM_OS_IOCTL )
+int radeon_cp_start( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
@@ -1044,9 +1044,9 @@ int radeon_cp_start( DRM_OS_IOCTL )
/* Stop the CP. The engine must have been idled before calling this
* routine.
*/
-int radeon_cp_stop( DRM_OS_IOCTL )
+int radeon_cp_stop( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_cp_stop_t stop;
int ret;
@@ -1054,7 +1054,7 @@ int radeon_cp_stop( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( stop, (drm_radeon_cp_stop_t *)data, sizeof(stop) );
+ DRM_COPY_FROM_USER_IOCTL( stop, (drm_radeon_cp_stop_t *)data, sizeof(stop) );
/* Flush any pending CP commands. This ensures any outstanding
* commands are exectuted by the engine before we turn it off.
@@ -1085,9 +1085,9 @@ int radeon_cp_stop( DRM_OS_IOCTL )
/* Just reset the CP ring. Called as part of an X Server engine reset.
*/
-int radeon_cp_reset( DRM_OS_IOCTL )
+int radeon_cp_reset( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
@@ -1095,7 +1095,7 @@ int radeon_cp_reset( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_DEBUG( "%s called before init done\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
radeon_do_cp_reset( dev_priv );
@@ -1106,9 +1106,9 @@ int radeon_cp_reset( DRM_OS_IOCTL )
return 0;
}
-int radeon_cp_idle( DRM_OS_IOCTL )
+int radeon_cp_idle( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
@@ -1117,9 +1117,9 @@ int radeon_cp_idle( DRM_OS_IOCTL )
return radeon_do_cp_idle( dev_priv );
}
-int radeon_engine_reset( DRM_OS_IOCTL )
+int radeon_engine_reset( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
DRM_DEBUG( "\n" );
LOCK_TEST_WITH_RETURN( dev );
@@ -1134,7 +1134,7 @@ int radeon_engine_reset( DRM_OS_IOCTL )
/* KW: Deprecated to say the least:
*/
-int radeon_fullscreen( DRM_OS_IOCTL )
+int radeon_fullscreen( DRM_IOCTL_ARGS )
{
return 0;
}
@@ -1179,7 +1179,7 @@ drm_buf_t *radeon_freelist_get( drm_device_t *dev )
}
start = 0;
}
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
DRM_ERROR( "returning NULL!\n" );
@@ -1214,7 +1214,7 @@ int radeon_wait_ring( drm_radeon_private_t *dev_priv, int n )
radeon_update_ring_snapshot( ring );
if ( ring->space > n )
return 0;
- DRM_OS_DELAY( 1 );
+ DRM_UDELAY( 1 );
}
/* FIXME: This return value is ignored in the BEGIN_RING macro! */
@@ -1222,7 +1222,7 @@ int radeon_wait_ring( drm_radeon_private_t *dev_priv, int n )
radeon_status( dev_priv );
DRM_ERROR( "failed!\n" );
#endif
- return DRM_OS_ERR(EBUSY);
+ return DRM_ERR(EBUSY);
}
static int radeon_cp_get_buffers( drm_device_t *dev, drm_dma_t *d )
@@ -1232,47 +1232,47 @@ static int radeon_cp_get_buffers( drm_device_t *dev, drm_dma_t *d )
for ( i = d->granted_count ; i < d->request_count ; i++ ) {
buf = radeon_freelist_get( dev );
- if ( !buf ) return DRM_OS_ERR(EAGAIN);
+ if ( !buf ) return DRM_ERR(EAGAIN);
- buf->pid = DRM_OS_CURRENTPID;
+ buf->pid = DRM_CURRENTPID;
- if ( DRM_OS_COPYTOUSR( &d->request_indices[i], &buf->idx,
+ if ( DRM_COPY_TO_USER( &d->request_indices[i], &buf->idx,
sizeof(buf->idx) ) )
- return DRM_OS_ERR(EFAULT);
- if ( DRM_OS_COPYTOUSR( &d->request_sizes[i], &buf->total,
+ return DRM_ERR(EFAULT);
+ if ( DRM_COPY_TO_USER( &d->request_sizes[i], &buf->total,
sizeof(buf->total) ) )
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
d->granted_count++;
}
return 0;
}
-int radeon_cp_buffers( DRM_OS_IOCTL )
+int radeon_cp_buffers( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_device_dma_t *dma = dev->dma;
int ret = 0;
drm_dma_t d;
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( d, (drm_dma_t *)data, sizeof(d) );
+ DRM_COPY_FROM_USER_IOCTL( d, (drm_dma_t *)data, sizeof(d) );
/* Please don't send us buffers.
*/
if ( d.send_count != 0 ) {
DRM_ERROR( "Process %d trying to send %d buffers via drmDMA\n",
- DRM_OS_CURRENTPID, d.send_count );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, d.send_count );
+ return DRM_ERR(EINVAL);
}
/* We'll send you buffers.
*/
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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, d.request_count, dma->buf_count );
+ return DRM_ERR(EINVAL);
}
d.granted_count = 0;
@@ -1281,7 +1281,7 @@ int radeon_cp_buffers( DRM_OS_IOCTL )
ret = radeon_cp_get_buffers( dev, &d );
}
- DRM_OS_KRNTOUSR( (drm_dma_t *)data, d, sizeof(d) );
+ DRM_COPY_TO_USER_IOCTL( (drm_dma_t *)data, d, sizeof(d) );
return ret;
}
diff --git a/shared/radeon_drv.h b/shared/radeon_drv.h
index a40e294b..b6b9d4c6 100644
--- a/shared/radeon_drv.h
+++ b/shared/radeon_drv.h
@@ -31,8 +31,8 @@
#ifndef __RADEON_DRV_H__
#define __RADEON_DRV_H__
-#define GET_RING_HEAD(ring) DRM_OS_READ32( (volatile u32 *) (ring)->head )
-#define SET_RING_HEAD(ring,val) DRM_OS_WRITE32( (volatile u32 *) (ring)->head , (val))
+#define GET_RING_HEAD(ring) DRM_READ32( (volatile u32 *) (ring)->head )
+#define SET_RING_HEAD(ring,val) DRM_WRITE32( (volatile u32 *) (ring)->head , (val))
typedef struct drm_radeon_freelist {
unsigned int age;
@@ -119,14 +119,14 @@ typedef struct drm_radeon_buf_priv {
} drm_radeon_buf_priv_t;
/* radeon_cp.c */
-extern int radeon_cp_init( DRM_OS_IOCTL );
-extern int radeon_cp_start( DRM_OS_IOCTL );
-extern int radeon_cp_stop( DRM_OS_IOCTL );
-extern int radeon_cp_reset( DRM_OS_IOCTL );
-extern int radeon_cp_idle( DRM_OS_IOCTL );
-extern int radeon_engine_reset( DRM_OS_IOCTL );
-extern int radeon_fullscreen( DRM_OS_IOCTL );
-extern int radeon_cp_buffers( DRM_OS_IOCTL );
+extern int radeon_cp_init( DRM_IOCTL_ARGS );
+extern int radeon_cp_start( DRM_IOCTL_ARGS );
+extern int radeon_cp_stop( DRM_IOCTL_ARGS );
+extern int radeon_cp_reset( DRM_IOCTL_ARGS );
+extern int radeon_cp_idle( DRM_IOCTL_ARGS );
+extern int radeon_engine_reset( DRM_IOCTL_ARGS );
+extern int radeon_fullscreen( DRM_IOCTL_ARGS );
+extern int radeon_cp_buffers( DRM_IOCTL_ARGS );
extern void radeon_freelist_reset( drm_device_t *dev );
extern drm_buf_t *radeon_freelist_get( drm_device_t *dev );
@@ -146,17 +146,17 @@ extern int radeon_do_cleanup_cp( drm_device_t *dev );
extern int radeon_do_cleanup_pageflip( drm_device_t *dev );
/* radeon_state.c */
-extern int radeon_cp_clear( DRM_OS_IOCTL );
-extern int radeon_cp_swap( DRM_OS_IOCTL );
-extern int radeon_cp_vertex( DRM_OS_IOCTL );
-extern int radeon_cp_indices( DRM_OS_IOCTL );
-extern int radeon_cp_texture( DRM_OS_IOCTL );
-extern int radeon_cp_stipple( DRM_OS_IOCTL );
-extern int radeon_cp_indirect( DRM_OS_IOCTL );
-extern int radeon_cp_vertex2( DRM_OS_IOCTL );
-extern int radeon_cp_cmdbuf( DRM_OS_IOCTL );
-extern int radeon_cp_getparam( DRM_OS_IOCTL );
-extern int radeon_cp_flip( DRM_OS_IOCTL );
+extern int radeon_cp_clear( DRM_IOCTL_ARGS );
+extern int radeon_cp_swap( DRM_IOCTL_ARGS );
+extern int radeon_cp_vertex( DRM_IOCTL_ARGS );
+extern int radeon_cp_indices( DRM_IOCTL_ARGS );
+extern int radeon_cp_texture( DRM_IOCTL_ARGS );
+extern int radeon_cp_stipple( DRM_IOCTL_ARGS );
+extern int radeon_cp_indirect( DRM_IOCTL_ARGS );
+extern int radeon_cp_vertex2( DRM_IOCTL_ARGS );
+extern int radeon_cp_cmdbuf( DRM_IOCTL_ARGS );
+extern int radeon_cp_getparam( DRM_IOCTL_ARGS );
+extern int radeon_cp_flip( DRM_IOCTL_ARGS );
@@ -524,11 +524,11 @@ extern int radeon_cp_flip( DRM_OS_IOCTL );
#define RADEON_BASE(reg) ((unsigned long)(dev_priv->mmio->handle))
#define RADEON_ADDR(reg) (RADEON_BASE( reg ) + reg)
-#define RADEON_READ(reg) DRM_OS_READ32( (volatile u32 *) RADEON_ADDR(reg) )
-#define RADEON_WRITE(reg,val) DRM_OS_WRITE32( (volatile u32 *) RADEON_ADDR(reg), (val) )
+#define RADEON_READ(reg) DRM_READ32( (volatile u32 *) RADEON_ADDR(reg) )
+#define RADEON_WRITE(reg,val) DRM_WRITE32( (volatile u32 *) RADEON_ADDR(reg), (val) )
-#define RADEON_READ8(reg) DRM_OS_READ8( (volatile u8 *) RADEON_ADDR(reg) )
-#define RADEON_WRITE8(reg,val) DRM_OS_WRITE8( (volatile u8 *) RADEON_ADDR(reg), (val) )
+#define RADEON_READ8(reg) DRM_READ8( (volatile u8 *) RADEON_ADDR(reg) )
+#define RADEON_WRITE8(reg,val) DRM_WRITE8( (volatile u8 *) RADEON_ADDR(reg), (val) )
#define RADEON_WRITE_PLL( addr, val ) \
do { \
@@ -608,9 +608,9 @@ extern int RADEON_READ_PLL( drm_device_t *dev, int addr );
#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", __func__ ); \
- return DRM_OS_ERR(EINVAL); \
+ return DRM_ERR(EINVAL); \
} \
} while (0)
@@ -622,7 +622,7 @@ do { \
radeon_update_ring_snapshot( ring ); \
if ( ring->space >= ring->high_mark ) \
goto __ring_space_done; \
- DRM_OS_DELAY( 1 ); \
+ DRM_UDELAY( 1 ); \
} \
DRM_ERROR( "ring space check from memory failed, reading register...\n" ); \
/* If ring space check fails from RAM, try reading the \
@@ -634,7 +634,7 @@ do { \
goto __ring_space_done; \
\
DRM_ERROR( "ring space check failed!\n" ); \
- return DRM_OS_ERR(EBUSY); \
+ return DRM_ERR(EBUSY); \
} \
__ring_space_done: \
; \
@@ -736,17 +736,17 @@ do { \
\
if (write + _size > mask) { \
int i = (mask+1) - write; \
- if (DRM_OS_COPYFROMUSR_NC( (int *)(ring+write), \
+ if (DRM_COPY_FROM_USER_UNCHECKED( (int *)(ring+write), \
_tab, i*4 )) \
- return DRM_OS_ERR(EFAULT); \
+ return DRM_ERR(EFAULT); \
write = 0; \
_size -= i; \
_tab += i; \
} \
\
- if (_size && DRM_OS_COPYFROMUSR_NC( (int *)(ring+write), \
+ if (_size && DRM_COPY_FROM_USER_UNCHECKED( (int *)(ring+write), \
_tab, _size*4 )) \
- return DRM_OS_ERR(EFAULT); \
+ return DRM_ERR(EFAULT); \
\
write += _size; \
write &= mask; \
diff --git a/shared/radeon_state.c b/shared/radeon_state.c
index c36258c1..ec00b880 100644
--- a/shared/radeon_state.c
+++ b/shared/radeon_state.c
@@ -684,7 +684,7 @@ static void radeon_cp_dispatch_vertex( drm_device_t *dev,
do {
/* Emit the next cliprect */
if ( i < nbox ) {
- if (DRM_OS_COPYFROMUSR_NC( &box, &boxes[i], sizeof(box) ))
+ if (DRM_COPY_FROM_USER_UNCHECKED( &box, &boxes[i], sizeof(box) ))
return;
radeon_emit_clip_rect( dev_priv, &box );
@@ -817,7 +817,7 @@ static void radeon_cp_dispatch_indices( drm_device_t *dev,
do {
if ( i < nbox ) {
- if (DRM_OS_COPYFROMUSR_NC( &box, &boxes[i], sizeof(box) ))
+ if (DRM_COPY_FROM_USER_UNCHECKED( &box, &boxes[i], sizeof(box) ))
return;
radeon_emit_clip_rect( dev_priv, &box );
@@ -851,7 +851,7 @@ static int radeon_cp_dispatch_texture( drm_device_t *dev,
/* FIXME: Be smarter about this...
*/
buf = radeon_freelist_get( dev );
- if ( !buf ) return DRM_OS_ERR(EAGAIN);
+ if ( !buf ) return DRM_ERR(EAGAIN);
DRM_DEBUG( "tex: ofs=0x%x p=%d f=%d x=%hd y=%hd w=%hd h=%hd\n",
tex->offset >> 10, tex->pitch, tex->format,
@@ -884,7 +884,7 @@ static int radeon_cp_dispatch_texture( drm_device_t *dev,
break;
default:
DRM_ERROR( "invalid texture format %d\n", tex->format );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
DRM_DEBUG( " tex=%dx%d blit=%d\n",
@@ -922,7 +922,7 @@ static int radeon_cp_dispatch_texture( drm_device_t *dev,
if ( size > RADEON_MAX_TEXTURE_SIZE ) {
/* Texture image is too large, do a multipass upload */
- ret = DRM_OS_ERR(EAGAIN);
+ ret = DRM_ERR(EAGAIN);
/* Adjust the blit size to fit the indirect buffer */
height = RADEON_MAX_TEXTURE_SIZE / blit_width;
@@ -933,9 +933,9 @@ static int radeon_cp_dispatch_texture( drm_device_t *dev,
image->height -= height;
image->data = (const char *)image->data + size;
- if ( DRM_OS_COPYTOUSR( tex->image, image, sizeof(*image) ) ) {
+ if ( DRM_COPY_TO_USER( tex->image, image, sizeof(*image) ) ) {
DRM_ERROR( "EFAULT on tex->image\n" );
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
}
} else if ( size < 4 && size > 0 ) {
size = 4;
@@ -970,9 +970,9 @@ static int radeon_cp_dispatch_texture( drm_device_t *dev,
/* Texture image width is larger than the minimum, so we
* can upload it directly.
*/
- if ( DRM_OS_COPYFROMUSR( buffer, data, dwords * sizeof(u32) ) ) {
+ if ( DRM_COPY_FROM_USER( buffer, data, dwords * sizeof(u32) ) ) {
DRM_ERROR( "EFAULT on data, %d dwords\n", dwords );
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
}
} else {
/* Texture image width is less than the minimum, so we
@@ -980,17 +980,17 @@ static int radeon_cp_dispatch_texture( drm_device_t *dev,
* width.
*/
for ( i = 0 ; i < tex->height ; i++ ) {
- if ( DRM_OS_COPYFROMUSR( buffer, data, tex_width ) ) {
+ if ( DRM_COPY_FROM_USER( buffer, data, tex_width ) ) {
DRM_ERROR( "EFAULT on pad, %d bytes\n",
tex_width );
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
}
buffer += 8;
data += tex_width;
}
}
- buf->pid = DRM_OS_CURRENTPID;
+ buf->pid = DRM_CURRENTPID;
buf->used = (dwords + 8) * sizeof(u32);
radeon_cp_dispatch_indirect( dev, buf, 0, buf->used );
@@ -1035,9 +1035,9 @@ static void radeon_cp_dispatch_stipple( drm_device_t *dev, u32 *stipple )
* IOCTL functions
*/
-int radeon_cp_clear( DRM_OS_IOCTL )
+int radeon_cp_clear( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_radeon_clear_t clear;
@@ -1046,7 +1046,7 @@ int radeon_cp_clear( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( clear, (drm_radeon_clear_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( clear, (drm_radeon_clear_t *)data,
sizeof(clear) );
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1054,9 +1054,9 @@ int radeon_cp_clear( DRM_OS_IOCTL )
if ( sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS )
sarea_priv->nbox = RADEON_NR_SAREA_CLIPRECTS;
- if ( DRM_OS_COPYFROMUSR( &depth_boxes, clear.depth_boxes,
+ if ( DRM_COPY_FROM_USER( &depth_boxes, clear.depth_boxes,
sarea_priv->nbox * sizeof(depth_boxes[0]) ) )
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
radeon_cp_dispatch_clear( dev, &clear, depth_boxes );
@@ -1104,9 +1104,9 @@ int radeon_do_cleanup_pageflip( drm_device_t *dev )
/* Swapping and flipping are different operations, need different ioctls.
* They can & should be intermixed to support multiple 3d windows.
*/
-int radeon_cp_flip( DRM_OS_IOCTL )
+int radeon_cp_flip( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
DRM_DEBUG( "\n" );
@@ -1123,9 +1123,9 @@ int radeon_cp_flip( DRM_OS_IOCTL )
return 0;
}
-int radeon_cp_swap( DRM_OS_IOCTL )
+int radeon_cp_swap( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
DRM_DEBUG( "\n" );
@@ -1144,9 +1144,9 @@ int radeon_cp_swap( DRM_OS_IOCTL )
return 0;
}
-int radeon_cp_vertex( DRM_OS_IOCTL )
+int radeon_cp_vertex( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_device_dma_t *dma = dev->dma;
@@ -1158,25 +1158,25 @@ int radeon_cp_vertex( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( vertex, (drm_radeon_vertex_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( vertex, (drm_radeon_vertex_t *)data,
sizeof(vertex) );
DRM_DEBUG( "pid=%d index=%d count=%d discard=%d\n",
- DRM_OS_CURRENTPID,
+ DRM_CURRENTPID,
vertex.idx, vertex.count, vertex.discard );
if ( vertex.idx < 0 || vertex.idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
vertex.idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( vertex.prim < 0 ||
vertex.prim > RADEON_PRIM_TYPE_3VRT_LINE_LIST ) {
DRM_ERROR( "buffer prim %d\n", vertex.prim );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1184,14 +1184,14 @@ int radeon_cp_vertex( DRM_OS_IOCTL )
buf = dma->buflist[vertex.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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, buf->pid );
+ return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
DRM_ERROR( "sending pending buffer %d\n", vertex.idx );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
/* Build up a prim_t record:
@@ -1230,9 +1230,9 @@ int radeon_cp_vertex( DRM_OS_IOCTL )
return 0;
}
-int radeon_cp_indices( DRM_OS_IOCTL )
+int radeon_cp_indices( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_device_dma_t *dma = dev->dma;
@@ -1245,25 +1245,25 @@ int radeon_cp_indices( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( elts, (drm_radeon_indices_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( elts, (drm_radeon_indices_t *)data,
sizeof(elts) );
DRM_DEBUG( "pid=%d index=%d start=%d end=%d discard=%d\n",
- DRM_OS_CURRENTPID,
+ DRM_CURRENTPID,
elts.idx, elts.start, elts.end, elts.discard );
if ( elts.idx < 0 || elts.idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
elts.idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( elts.prim < 0 ||
elts.prim > RADEON_PRIM_TYPE_3VRT_LINE_LIST ) {
DRM_ERROR( "buffer prim %d\n", elts.prim );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1271,14 +1271,14 @@ int radeon_cp_indices( DRM_OS_IOCTL )
buf = dma->buflist[elts.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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, buf->pid );
+ return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
DRM_ERROR( "sending pending buffer %d\n", elts.idx );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
count = (elts.end - elts.start) / sizeof(u16);
@@ -1286,11 +1286,11 @@ int radeon_cp_indices( DRM_OS_IOCTL )
if ( elts.start & 0x7 ) {
DRM_ERROR( "misaligned buffer 0x%x\n", elts.start );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( elts.start < buf->used ) {
DRM_ERROR( "no header 0x%x - 0x%x\n", elts.start, buf->used );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
buf->used = elts.end;
@@ -1328,9 +1328,9 @@ int radeon_cp_indices( DRM_OS_IOCTL )
return 0;
}
-int radeon_cp_texture( DRM_OS_IOCTL )
+int radeon_cp_texture( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_texture_t tex;
drm_radeon_tex_image_t image;
@@ -1338,17 +1338,17 @@ int radeon_cp_texture( DRM_OS_IOCTL )
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( tex, (drm_radeon_texture_t *)data, sizeof(tex) );
+ DRM_COPY_FROM_USER_IOCTL( tex, (drm_radeon_texture_t *)data, sizeof(tex) );
if ( tex.image == NULL ) {
DRM_ERROR( "null texture image!\n" );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- if ( DRM_OS_COPYFROMUSR( &image,
+ if ( DRM_COPY_FROM_USER( &image,
(drm_radeon_tex_image_t *)tex.image,
sizeof(image) ) )
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
RING_SPACE_TEST_WITH_RETURN( dev_priv );
VB_AGE_TEST_WITH_RETURN( dev_priv );
@@ -1359,20 +1359,20 @@ int radeon_cp_texture( DRM_OS_IOCTL )
return ret;
}
-int radeon_cp_stipple( DRM_OS_IOCTL )
+int radeon_cp_stipple( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_stipple_t stipple;
u32 mask[32];
LOCK_TEST_WITH_RETURN( dev );
- DRM_OS_KRNFROMUSR( stipple, (drm_radeon_stipple_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( stipple, (drm_radeon_stipple_t *)data,
sizeof(stipple) );
- if ( DRM_OS_COPYFROMUSR( &mask, stipple.mask, 32 * sizeof(u32) ) )
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( &mask, stipple.mask, 32 * sizeof(u32) ) )
+ return DRM_ERR(EFAULT);
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1382,9 +1382,9 @@ int radeon_cp_stipple( DRM_OS_IOCTL )
return 0;
}
-int radeon_cp_indirect( DRM_OS_IOCTL )
+int radeon_cp_indirect( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_device_dma_t *dma = dev->dma;
drm_buf_t *buf;
@@ -1395,10 +1395,10 @@ int radeon_cp_indirect( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( indirect, (drm_radeon_indirect_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( indirect, (drm_radeon_indirect_t *)data,
sizeof(indirect) );
DRM_DEBUG( "indirect: idx=%d s=%d e=%d d=%d\n",
@@ -1408,25 +1408,25 @@ int radeon_cp_indirect( DRM_OS_IOCTL )
if ( indirect.idx < 0 || indirect.idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
indirect.idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
buf = dma->buflist[indirect.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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, buf->pid );
+ return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
DRM_ERROR( "sending pending buffer %d\n", indirect.idx );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if ( indirect.start < buf->used ) {
DRM_ERROR( "reusing indirect: start=0x%x actual=0x%x\n",
indirect.start, buf->used );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1457,9 +1457,9 @@ int radeon_cp_indirect( DRM_OS_IOCTL )
return 0;
}
-int radeon_cp_vertex2( DRM_OS_IOCTL )
+int radeon_cp_vertex2( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_sarea_t *sarea_priv = dev_priv->sarea_priv;
drm_device_dma_t *dma = dev->dma;
@@ -1472,20 +1472,20 @@ int radeon_cp_vertex2( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( vertex, (drm_radeon_vertex2_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( vertex, (drm_radeon_vertex2_t *)data,
sizeof(vertex) );
DRM_DEBUG( "pid=%d index=%d discard=%d\n",
- DRM_OS_CURRENTPID,
+ DRM_CURRENTPID,
vertex.idx, vertex.discard );
if ( vertex.idx < 0 || vertex.idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
vertex.idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
RING_SPACE_TEST_WITH_RETURN( dev_priv );
@@ -1493,34 +1493,34 @@ int radeon_cp_vertex2( DRM_OS_IOCTL )
buf = dma->buflist[vertex.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 );
- return DRM_OS_ERR(EINVAL);
+ DRM_CURRENTPID, buf->pid );
+ return DRM_ERR(EINVAL);
}
if ( buf->pending ) {
DRM_ERROR( "sending pending buffer %d\n", vertex.idx );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
if (sarea_priv->nbox > RADEON_NR_SAREA_CLIPRECTS)
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
for (laststate = 0xff, i = 0 ; i < vertex.nr_prims ; i++) {
drm_radeon_prim_t prim;
drm_radeon_tcl_prim_t tclprim;
- if ( DRM_OS_COPYFROMUSR( &prim, &vertex.prim[i], sizeof(prim) ) )
- return DRM_OS_ERR(EFAULT);
+ if ( DRM_COPY_FROM_USER( &prim, &vertex.prim[i], sizeof(prim) ) )
+ return DRM_ERR(EFAULT);
if ( prim.stateidx != laststate ) {
drm_radeon_state_t state;
- if ( DRM_OS_COPYFROMUSR( &state,
+ if ( DRM_COPY_FROM_USER( &state,
&vertex.state[prim.stateidx],
sizeof(state) ) )
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
radeon_emit_state2( dev_priv, &state );
@@ -1573,7 +1573,7 @@ static int radeon_emit_packets(
RING_LOCALS;
if (sz * sizeof(int) > cmdbuf->bufsz)
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
BEGIN_RING(sz+1);
OUT_RING( CP_PACKET0( reg, (sz-1) ) );
@@ -1642,14 +1642,14 @@ static int radeon_emit_packet3( drm_device_t *dev,
DRM_DEBUG("\n");
- if (DRM_OS_FETCHU_32_NC( tmp, &cmd[0]))
- return DRM_OS_ERR(EFAULT);
+ if (DRM_GET_USER_UNCHECKED( tmp, &cmd[0]))
+ return DRM_ERR(EFAULT);
cmdsz = 2 + ((tmp & RADEON_CP_PACKET_COUNT_MASK) >> 16);
if ((tmp & 0xc0000000) != RADEON_CP_PACKET3 ||
cmdsz * 4 > cmdbuf->bufsz)
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
BEGIN_RING( cmdsz );
OUT_RING_USER_TABLE( cmd, cmdsz );
@@ -1674,19 +1674,19 @@ static int radeon_emit_packet3_cliprect( drm_device_t *dev,
DRM_DEBUG("\n");
- if (DRM_OS_FETCHU_32_NC( tmp, &cmd[0]))
- return DRM_OS_ERR(EFAULT);
+ if (DRM_GET_USER_UNCHECKED( tmp, &cmd[0]))
+ return DRM_ERR(EFAULT);
cmdsz = 2 + ((tmp & RADEON_CP_PACKET_COUNT_MASK) >> 16);
if ((tmp & 0xc0000000) != RADEON_CP_PACKET3 ||
cmdsz * 4 > cmdbuf->bufsz)
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
do {
if ( i < cmdbuf->nbox ) {
- if (DRM_OS_COPYFROMUSR_NC( &box, &boxes[i], sizeof(box) ))
- return DRM_OS_ERR(EFAULT);
+ if (DRM_COPY_FROM_USER_UNCHECKED( &box, &boxes[i], sizeof(box) ))
+ return DRM_ERR(EFAULT);
radeon_emit_clip_rect( dev_priv, &box );
}
@@ -1706,9 +1706,9 @@ static int radeon_emit_packet3_cliprect( drm_device_t *dev,
-int radeon_cp_cmdbuf( DRM_OS_IOCTL )
+int radeon_cp_cmdbuf( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_device_dma_t *dma = dev->dma;
drm_buf_t *buf = 0;
@@ -1720,30 +1720,30 @@ int radeon_cp_cmdbuf( DRM_OS_IOCTL )
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( cmdbuf, (drm_radeon_cmd_buffer_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( cmdbuf, (drm_radeon_cmd_buffer_t *)data,
sizeof(cmdbuf) );
- DRM_DEBUG( "pid=%d\n", DRM_OS_CURRENTPID );
+ DRM_DEBUG( "pid=%d\n", DRM_CURRENTPID );
RING_SPACE_TEST_WITH_RETURN( dev_priv );
VB_AGE_TEST_WITH_RETURN( dev_priv );
- if (DRM_OS_VERIFYAREA_READ( cmdbuf.buf, cmdbuf.bufsz ))
- return DRM_OS_ERR(EFAULT);
+ if (DRM_VERIFYAREA_READ( cmdbuf.buf, cmdbuf.bufsz ))
+ return DRM_ERR(EFAULT);
if (cmdbuf.nbox &&
- DRM_OS_VERIFYAREA_READ(cmdbuf.boxes,
+ DRM_VERIFYAREA_READ(cmdbuf.boxes,
cmdbuf.nbox * sizeof(drm_clip_rect_t)))
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
while ( cmdbuf.bufsz >= sizeof(header) ) {
- if (DRM_OS_FETCHU_32_NC( header.i, (int *)cmdbuf.buf )) {
+ if (DRM_GET_USER_UNCHECKED( header.i, (int *)cmdbuf.buf )) {
DRM_ERROR("__get_user %p\n", cmdbuf.buf);
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
}
cmdbuf.buf += sizeof(header);
@@ -1753,21 +1753,21 @@ int radeon_cp_cmdbuf( DRM_OS_IOCTL )
case RADEON_CMD_PACKET:
if (radeon_emit_packets( dev_priv, header, &cmdbuf )) {
DRM_ERROR("radeon_emit_packets failed\n");
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
break;
case RADEON_CMD_SCALARS:
if (radeon_emit_scalars( dev_priv, header, &cmdbuf )) {
DRM_ERROR("radeon_emit_scalars failed\n");
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
break;
case RADEON_CMD_VECTORS:
if (radeon_emit_vectors( dev_priv, header, &cmdbuf )) {
DRM_ERROR("radeon_emit_vectors failed\n");
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
break;
@@ -1776,13 +1776,13 @@ int radeon_cp_cmdbuf( DRM_OS_IOCTL )
if ( idx < 0 || idx >= dma->buf_count ) {
DRM_ERROR( "buffer index %d (of %d max)\n",
idx, dma->buf_count - 1 );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
buf = dma->buflist[idx];
- if ( buf->pid != DRM_OS_CURRENTPID || buf->pending ) {
+ if ( buf->pid != DRM_CURRENTPID || buf->pending ) {
DRM_ERROR( "bad buffer\n" );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
radeon_cp_discard_buffer( dev, buf );
@@ -1791,14 +1791,14 @@ int radeon_cp_cmdbuf( DRM_OS_IOCTL )
case RADEON_CMD_PACKET3:
if (radeon_emit_packet3( dev, &cmdbuf )) {
DRM_ERROR("radeon_emit_packet3 failed\n");
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
break;
case RADEON_CMD_PACKET3_CLIP:
if (radeon_emit_packet3_cliprect( dev, &cmdbuf )) {
DRM_ERROR("radeon_emit_packet3_clip failed\n");
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
break;
@@ -1806,7 +1806,7 @@ int radeon_cp_cmdbuf( DRM_OS_IOCTL )
DRM_ERROR("bad cmd_type %d at %p\n",
header.header.cmd_type,
cmdbuf.buf - sizeof(header));
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
}
@@ -1817,34 +1817,34 @@ int radeon_cp_cmdbuf( DRM_OS_IOCTL )
-int radeon_cp_getparam( DRM_OS_IOCTL )
+int radeon_cp_getparam( DRM_IOCTL_ARGS )
{
- DRM_OS_DEVICE;
+ DRM_DEVICE;
drm_radeon_private_t *dev_priv = dev->dev_private;
drm_radeon_getparam_t param;
int value;
if ( !dev_priv ) {
DRM_ERROR( "%s called with no initialization\n", __func__ );
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- DRM_OS_KRNFROMUSR( param, (drm_radeon_getparam_t *)data,
+ DRM_COPY_FROM_USER_IOCTL( param, (drm_radeon_getparam_t *)data,
sizeof(param) );
- DRM_DEBUG( "pid=%d\n", DRM_OS_CURRENTPID );
+ DRM_DEBUG( "pid=%d\n", DRM_CURRENTPID );
switch( param.param ) {
case RADEON_PARAM_AGP_BUFFER_OFFSET:
value = dev_priv->agp_buffers_offset;
break;
default:
- return DRM_OS_ERR(EINVAL);
+ return DRM_ERR(EINVAL);
}
- if ( DRM_OS_COPYTOUSR( param.value, &value, sizeof(int) ) ) {
+ if ( DRM_COPY_TO_USER( param.value, &value, sizeof(int) ) ) {
DRM_ERROR( "copy_to_user\n" );
- return DRM_OS_ERR(EFAULT);
+ return DRM_ERR(EFAULT);
}
return 0;