summaryrefslogtreecommitdiff
path: root/bsd-core/drm_ioctl.c
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2002-07-15 20:21:18 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2002-07-15 20:21:18 +0000
commiteef49a73b541d69be5da9b289deff36f5bb96ab0 (patch)
tree0cc0fa5559d7bf87c25d277ef63d816d0090ccf4 /bsd-core/drm_ioctl.c
parentdeb296f395bb16ef7cf4bfe48f6e6c2cbacea0bc (diff)
Merge trunk into r200-branchr200-0-1-20020715
Diffstat (limited to 'bsd-core/drm_ioctl.c')
-rw-r--r--bsd-core/drm_ioctl.c84
1 files changed, 43 insertions, 41 deletions
diff --git a/bsd-core/drm_ioctl.c b/bsd-core/drm_ioctl.c
index 1e8281e6..63562fef 100644
--- a/bsd-core/drm_ioctl.c
+++ b/bsd-core/drm_ioctl.c
@@ -29,20 +29,18 @@
* Gareth Hughes <gareth@valinux.com>
*/
-#define __NO_VERSION__
#include "drmP.h"
-#include <sys/bus.h>
-#include <pci/pcivar.h>
-int DRM(irq_busid)( DRM_OS_IOCTL )
+int DRM(irq_busid)( DRM_IOCTL_ARGS )
{
+#ifdef __FreeBSD__
drm_irq_busid_t id;
devclass_t pci;
device_t bus, dev;
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)
@@ -71,49 +69,53 @@ 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
+ /* don't support interrupt-driven drivers on Net yet */
+ return ENOENT;
+#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';
@@ -121,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);
@@ -130,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) {
@@ -163,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)
{
@@ -193,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)
@@ -229,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;
}