summaryrefslogtreecommitdiffstats
path: root/sys/dev/drm2/drm_drv.c
diff options
context:
space:
mode:
authorkib <kib@FreeBSD.org>2012-08-18 18:26:25 +0000
committerkib <kib@FreeBSD.org>2012-08-18 18:26:25 +0000
commit5028d10ff9fc400816f6b6c53f1231a377de2fe9 (patch)
treeae7c76b597a15c639b1db105dd5907b4faad1bf9 /sys/dev/drm2/drm_drv.c
parent4382478fb0493636a0ba7551117e6b863258d3d8 (diff)
downloadFreeBSD-src-5028d10ff9fc400816f6b6c53f1231a377de2fe9.zip
FreeBSD-src-5028d10ff9fc400816f6b6c53f1231a377de2fe9.tar.gz
Add drm and i915 ioctl translations for 32 bit process on 64 bit host.
Submitted by: meowthink@gmail.com MFC after: 2 weeks
Diffstat (limited to 'sys/dev/drm2/drm_drv.c')
-rw-r--r--sys/dev/drm2/drm_drv.c30
1 files changed, 27 insertions, 3 deletions
diff --git a/sys/dev/drm2/drm_drv.c b/sys/dev/drm2/drm_drv.c
index 42ff194..33e50ea 100644
--- a/sys/dev/drm2/drm_drv.c
+++ b/sys/dev/drm2/drm_drv.c
@@ -36,8 +36,8 @@ __FBSDID("$FreeBSD$");
* open/close, and ioctl dispatch.
*/
-
#include <sys/limits.h>
+#include <sys/sysent.h>
#include <dev/drm2/drmP.h>
#include <dev/drm2/drm.h>
#include <dev/drm2/drm_sarea.h>
@@ -802,6 +802,8 @@ void drm_close(void *data)
DRM_UNLOCK(dev);
}
+extern drm_ioctl_desc_t drm_compat_ioctls[];
+
/* drm_ioctl is called whenever a process performs an ioctl on /dev/drm.
*/
int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
@@ -846,7 +848,22 @@ int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
return EINVAL;
}
- ioctl = &drm_ioctls[nr];
+#ifdef COMPAT_FREEBSD32
+ /*
+ * Called whenever a 32-bit process running under a 64-bit
+ * kernel performs an ioctl on /dev/drm.
+ */
+ if (SV_CURPROC_FLAG(SV_ILP32) && drm_compat_ioctls[nr].func != NULL)
+ /*
+ * Assume that ioctls without an explicit compat
+ * routine will just work. This may not always be a
+ * good assumption, but it's better than always
+ * failing.
+ */
+ ioctl = &drm_compat_ioctls[nr];
+ else
+#endif
+ ioctl = &drm_ioctls[nr];
/* It's not a core DRM ioctl, try driver-specific. */
if (ioctl->func == NULL && nr >= DRM_COMMAND_BASE) {
/* The array entries begin at DRM_COMMAND_BASE ioctl nr */
@@ -856,7 +873,14 @@ int drm_ioctl(struct cdev *kdev, u_long cmd, caddr_t data, int flags,
nr, dev->driver->max_ioctl);
return EINVAL;
}
- ioctl = &dev->driver->ioctls[nr];
+#ifdef COMPAT_FREEBSD32
+ if (SV_CURPROC_FLAG(SV_ILP32) &&
+ nr < *dev->driver->compat_ioctls_nr &&
+ dev->driver->compat_ioctls[nr].func != NULL)
+ ioctl = &dev->driver->compat_ioctls[nr];
+ else
+#endif
+ ioctl = &dev->driver->ioctls[nr];
is_driver_ioctl = 1;
}
func = ioctl->func;
OpenPOWER on IntegriCloud