2 * Copyright (C) Paul Mackerras 2005
3 * Copyright (C) Alan Hourihane 2005
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice (including the next
14 * paragraph) shall be included in all copies or substantial portions of the
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * THE AUTHOR BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
26 * Paul Mackerras <paulus@samba.org>
27 * Alan Hourihane <alanh@fairlite.demon.co.uk>
30 #include <sys/cdefs.h>
31 __FBSDID("$FreeBSD$");
33 #include "opt_compat.h"
35 #ifdef COMPAT_FREEBSD32
37 /** @file i915_ioc32.c
38 * 32-bit ioctl compatibility routines for the i915 DRM.
41 #include <dev/drm2/drmP.h>
42 #include <dev/drm2/drm.h>
43 #include <dev/drm2/i915/i915_drm.h>
44 #include <dev/drm2/i915/i915_drv.h>
45 #include <dev/drm2/i915/intel_drv.h>
47 typedef struct _drm_i915_batchbuffer32 {
48 int start; /* agp offset */
49 int used; /* nr bytes in use */
50 int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
51 int DR4; /* window origin for GFX_OP_DRAWRECT_INFO */
52 int num_cliprects; /* mulitpass with multiple cliprects? */
53 u32 cliprects; /* pointer to userspace cliprects */
54 } drm_i915_batchbuffer32_t;
56 static int compat_i915_batchbuffer(struct drm_device *dev, void *data, struct drm_file *file_priv)
58 drm_i915_batchbuffer32_t *batchbuffer32 = data;
59 drm_i915_batchbuffer_t batchbuffer;
61 batchbuffer.start = batchbuffer32->start;
62 batchbuffer.used = batchbuffer32->used;
63 batchbuffer.DR1 = batchbuffer32->DR1;
64 batchbuffer.DR4 = batchbuffer32->DR4;
65 batchbuffer.num_cliprects = batchbuffer32->num_cliprects;
66 batchbuffer.cliprects = (void *)(unsigned long)batchbuffer32->cliprects;
68 return i915_batchbuffer(dev, (void *)&batchbuffer, file_priv);
71 typedef struct _drm_i915_cmdbuffer32 {
72 u32 buf; /* pointer to userspace command buffer */
73 int sz; /* nr bytes in buf */
74 int DR1; /* hw flags for GFX_OP_DRAWRECT_INFO */
75 int DR4; /* window origin for GFX_OP_DRAWRECT_INFO */
76 int num_cliprects; /* mulitpass with multiple cliprects? */
77 u32 cliprects; /* pointer to userspace cliprects */
78 } drm_i915_cmdbuffer32_t;
80 static int compat_i915_cmdbuffer(struct drm_device *dev, void *data, struct drm_file *file_priv)
82 drm_i915_cmdbuffer32_t *cmdbuffer32 = data;
83 drm_i915_cmdbuffer_t cmdbuffer;
85 cmdbuffer.sz = cmdbuffer32->sz;
86 cmdbuffer.DR1 = cmdbuffer32->DR1;
87 cmdbuffer.DR4 = cmdbuffer32->DR4;
88 cmdbuffer.num_cliprects = cmdbuffer32->num_cliprects;
89 cmdbuffer.cliprects = (void *)(unsigned long)cmdbuffer32->cliprects;
91 return i915_cmdbuffer(dev, (void *)&cmdbuffer, file_priv);
94 typedef struct drm_i915_irq_emit32 {
96 } drm_i915_irq_emit32_t;
98 static int compat_i915_irq_emit(struct drm_device *dev, void *data, struct drm_file *file_priv)
100 drm_i915_irq_emit32_t *req32 = data;
101 drm_i915_irq_emit_t request;
103 request.irq_seq = (int *)(unsigned long)req32->irq_seq;
105 return i915_irq_emit(dev, (void *)&request, file_priv);
107 typedef struct drm_i915_getparam32 {
110 } drm_i915_getparam32_t;
112 static int compat_i915_getparam(struct drm_device *dev, void *data, struct drm_file *file_priv)
114 drm_i915_getparam32_t *req32 = data;
115 drm_i915_getparam_t request;
117 request.param = req32->param;
118 request.value = (void *)(unsigned long)req32->value;
120 return i915_getparam(dev, (void *)&request, file_priv);
123 typedef struct drm_i915_mem_alloc32 {
127 u32 region_offset; /* offset from start of fb or agp */
128 } drm_i915_mem_alloc32_t;
130 drm_ioctl_desc_t i915_compat_ioctls[] = {
131 DRM_IOCTL_DEF(DRM_I915_BATCHBUFFER, compat_i915_batchbuffer, DRM_AUTH),
132 DRM_IOCTL_DEF(DRM_I915_CMDBUFFER, compat_i915_cmdbuffer, DRM_AUTH),
133 DRM_IOCTL_DEF(DRM_I915_GETPARAM, compat_i915_getparam, DRM_AUTH),
134 DRM_IOCTL_DEF(DRM_I915_IRQ_EMIT, compat_i915_irq_emit, DRM_AUTH)
136 int i915_compat_ioctls_nr = DRM_ARRAY_SIZE(i915_compat_ioctls);