| @@ -1,1263 +1,1260 @@ | | | @@ -1,1263 +1,1260 @@ |
1 | /* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*- | | 1 | /* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*- |
2 | * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com | | 2 | * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com |
3 | */ | | 3 | */ |
4 | /*- | | 4 | /*- |
5 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. | | 5 | * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas. |
6 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. | | 6 | * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California. |
7 | * All rights reserved. | | 7 | * All rights reserved. |
8 | * | | 8 | * |
9 | * Permission is hereby granted, free of charge, to any person obtaining a | | 9 | * Permission is hereby granted, free of charge, to any person obtaining a |
10 | * copy of this software and associated documentation files (the "Software"), | | 10 | * copy of this software and associated documentation files (the "Software"), |
11 | * to deal in the Software without restriction, including without limitation | | 11 | * to deal in the Software without restriction, including without limitation |
12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, | | 12 | * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
13 | * and/or sell copies of the Software, and to permit persons to whom the | | 13 | * and/or sell copies of the Software, and to permit persons to whom the |
14 | * Software is furnished to do so, subject to the following conditions: | | 14 | * Software is furnished to do so, subject to the following conditions: |
15 | * | | 15 | * |
16 | * The above copyright notice and this permission notice (including the next | | 16 | * The above copyright notice and this permission notice (including the next |
17 | * paragraph) shall be included in all copies or substantial portions of the | | 17 | * paragraph) shall be included in all copies or substantial portions of the |
18 | * Software. | | 18 | * Software. |
19 | * | | 19 | * |
20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | | 20 | * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | | 21 | * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL | | 22 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL |
23 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR | | 23 | * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR |
24 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, | | 24 | * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, |
25 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR | | 25 | * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR |
26 | * OTHER DEALINGS IN THE SOFTWARE. | | 26 | * OTHER DEALINGS IN THE SOFTWARE. |
27 | * | | 27 | * |
28 | * Authors: | | 28 | * Authors: |
29 | * Rickard E. (Rik) Faith <faith@valinux.com> | | 29 | * Rickard E. (Rik) Faith <faith@valinux.com> |
30 | * Gareth Hughes <gareth@valinux.com> | | 30 | * Gareth Hughes <gareth@valinux.com> |
31 | * | | 31 | * |
32 | */ | | 32 | */ |
33 | | | 33 | |
34 | #ifndef _DRM_P_H_ | | 34 | #ifndef _DRM_P_H_ |
35 | #define _DRM_P_H_ | | 35 | #define _DRM_P_H_ |
36 | | | 36 | |
37 | #if defined(_KERNEL) || defined(__KERNEL__) | | 37 | #if defined(_KERNEL) || defined(__KERNEL__) |
38 | | | 38 | |
39 | struct drm_device; | | 39 | struct drm_device; |
40 | struct drm_file; | | 40 | struct drm_file; |
41 | | | 41 | |
42 | #if defined(__NetBSD__) && defined(_KERNEL_OPT) | | 42 | #if defined(__NetBSD__) && defined(_KERNEL_OPT) |
43 | #include "opt_drm.h" | | 43 | #include "opt_drm.h" |
44 | #endif | | 44 | #endif |
45 | | | 45 | |
46 | #include <sys/param.h> | | 46 | #include <sys/param.h> |
47 | #include <sys/queue.h> | | 47 | #include <sys/queue.h> |
48 | #include <sys/malloc.h> | | 48 | #include <sys/malloc.h> |
49 | #include <sys/kernel.h> | | 49 | #include <sys/kernel.h> |
50 | #include <sys/module.h> | | 50 | #include <sys/module.h> |
51 | #include <sys/systm.h> | | 51 | #include <sys/systm.h> |
52 | #include <sys/conf.h> | | 52 | #include <sys/conf.h> |
53 | #include <sys/stat.h> | | 53 | #include <sys/stat.h> |
54 | #if __FreeBSD_version >= 700000 | | 54 | #if __FreeBSD_version >= 700000 |
55 | #include <sys/priv.h> | | 55 | #include <sys/priv.h> |
56 | #endif | | 56 | #endif |
57 | #include <sys/proc.h> | | 57 | #include <sys/proc.h> |
58 | #include <sys/lock.h> | | 58 | #include <sys/lock.h> |
59 | #include <sys/fcntl.h> | | 59 | #include <sys/fcntl.h> |
60 | #include <sys/uio.h> | | 60 | #include <sys/uio.h> |
61 | #include <sys/filio.h> | | 61 | #include <sys/filio.h> |
62 | #include <sys/sysctl.h> | | 62 | #include <sys/sysctl.h> |
63 | #include <sys/bus.h> | | 63 | #include <sys/bus.h> |
64 | #include <sys/signalvar.h> | | 64 | #include <sys/signalvar.h> |
65 | #include <sys/poll.h> | | 65 | #include <sys/poll.h> |
66 | #include <sys/tree.h> | | 66 | #include <sys/tree.h> |
67 | #ifdef __FreeBSD__ | | 67 | #ifdef __FreeBSD__ |
68 | #include <vm/vm.h> | | 68 | #include <vm/vm.h> |
69 | #include <vm/pmap.h> | | 69 | #include <vm/pmap.h> |
70 | #include <vm/vm_extern.h> | | 70 | #include <vm/vm_extern.h> |
71 | #include <vm/vm_map.h> | | 71 | #include <vm/vm_map.h> |
72 | #include <vm/vm_param.h> | | 72 | #include <vm/vm_param.h> |
73 | #include <machine/resource.h> | | 73 | #include <machine/resource.h> |
74 | #include <machine/param.h> | | 74 | #include <machine/param.h> |
75 | #endif | | 75 | #endif |
76 | #include <machine/pmap.h> | | 76 | #include <machine/pmap.h> |
77 | #include <machine/bus.h> | | 77 | #include <machine/bus.h> |
78 | #include <machine/specialreg.h> | | 78 | #include <machine/specialreg.h> |
79 | #include <machine/sysarch.h> | | 79 | #include <machine/sysarch.h> |
80 | #include <sys/endian.h> | | 80 | #include <sys/endian.h> |
81 | #include <sys/mman.h> | | 81 | #include <sys/mman.h> |
82 | #if defined( __FreeBSD__) | | 82 | #if defined( __FreeBSD__) |
83 | #include <sys/rman.h> | | 83 | #include <sys/rman.h> |
84 | #include <sys/memrange.h> | | 84 | #include <sys/memrange.h> |
85 | #if __FreeBSD_version >= 800004 | | 85 | #if __FreeBSD_version >= 800004 |
86 | #include <dev/agp/agpvar.h> | | 86 | #include <dev/agp/agpvar.h> |
87 | #else /* __FreeBSD_version >= 800004 */ | | 87 | #else /* __FreeBSD_version >= 800004 */ |
88 | #include <pci/agpvar.h> | | 88 | #include <pci/agpvar.h> |
89 | #endif /* __FreeBSD_version >= 800004 */ | | 89 | #endif /* __FreeBSD_version >= 800004 */ |
90 | #include <sys/agpio.h> | | 90 | #include <sys/agpio.h> |
91 | #include <sys/mutex.h> | | 91 | #include <sys/mutex.h> |
92 | #include <dev/pci/pcivar.h> | | 92 | #include <dev/pci/pcivar.h> |
93 | #include <dev/pci/pcireg.h> | | 93 | #include <dev/pci/pcireg.h> |
94 | #include <sys/selinfo.h> | | 94 | #include <sys/selinfo.h> |
95 | #include <sys/bus.h> | | 95 | #include <sys/bus.h> |
96 | #elif defined(__NetBSD__) | | 96 | #elif defined(__NetBSD__) |
97 | #include <machine/mtrr.h> | | 97 | #include <machine/mtrr.h> |
98 | #include <sys/vnode.h> | | 98 | #include <sys/vnode.h> |
99 | #include <sys/select.h> | | 99 | #include <sys/select.h> |
100 | #include <sys/device.h> | | 100 | #include <sys/device.h> |
101 | #include <sys/resourcevar.h> | | 101 | #include <sys/resourcevar.h> |
102 | #include <sys/agpio.h> | | 102 | #include <sys/agpio.h> |
103 | #include <sys/ttycom.h> | | 103 | #include <sys/ttycom.h> |
104 | #include <sys/mman.h> | | 104 | #include <sys/mman.h> |
105 | #include <sys/kauth.h> | | 105 | #include <sys/kauth.h> |
106 | #include <sys/types.h> | | 106 | #include <sys/types.h> |
107 | #include <sys/file.h> | | 107 | #include <sys/file.h> |
108 | #include <sys/atomic.h> | | 108 | #include <sys/atomic.h> |
109 | #include <sys/workqueue.h> | | 109 | #include <sys/workqueue.h> |
110 | #include <uvm/uvm.h> | | 110 | #include <uvm/uvm.h> |
111 | #include <dev/pci/pcireg.h> | | 111 | #include <dev/pci/pcireg.h> |
112 | #include <dev/pci/pcivar.h> | | 112 | #include <dev/pci/pcivar.h> |
113 | #include <dev/pci/agpvar.h> | | 113 | #include <dev/pci/agpvar.h> |
114 | #endif | | 114 | #endif |
115 | | | 115 | |
116 | #include "drm.h" | | 116 | #include "drm.h" |
117 | #include "drm_linux_list.h" | | 117 | #include "drm_linux_list.h" |
118 | #include "drm_atomic.h" | | 118 | #include "drm_atomic.h" |
119 | #include "drm_internal.h" | | 119 | #include "drm_internal.h" |
120 | | | 120 | |
121 | #ifdef __FreeBSD__ | | 121 | #ifdef __FreeBSD__ |
122 | #include <opt_drm.h> | | 122 | #include <opt_drm.h> |
123 | #endif | | 123 | #endif |
124 | | | 124 | |
125 | #ifdef DRM_DEBUG | | 125 | #ifdef DRM_DEBUG |
126 | #undef DRM_DEBUG | | 126 | #undef DRM_DEBUG |
127 | #define DRM_DEBUG_DEFAULT_ON 1 | | 127 | #define DRM_DEBUG_DEFAULT_ON 1 |
128 | #endif /* DRM_DEBUG */ | | 128 | #endif /* DRM_DEBUG */ |
129 | | | 129 | |
130 | #ifdef __FreeBSD__ | | 130 | #ifdef __FreeBSD__ |
131 | #define DRM_KASSERT(x,y) KASSERT(x,y) | | 131 | #define DRM_KASSERT(x,y) KASSERT(x,y) |
132 | #else | | 132 | #else |
133 | #define DRM_KASSERT(x,y) KASSERT(x) | | 133 | #define DRM_KASSERT(x,y) KASSERT(x) |
134 | #define device_get_softc(x) device_private(x) | | 134 | #define device_get_softc(x) device_private(x) |
135 | #define callout_deactivate(x) callout_stop(x) | | 135 | #define callout_deactivate(x) callout_stop(x) |
136 | #define callout_drain(x) callout_stop(x) | | 136 | #define callout_drain(x) callout_stop(x) |
137 | #endif | | 137 | #endif |
138 | | | 138 | |
139 | #if defined(DRM_LINUX) && DRM_LINUX && !defined(__amd64__) | | 139 | #if defined(DRM_LINUX) && DRM_LINUX && !defined(__amd64__) |
140 | #include <sys/file.h> | | 140 | #include <sys/file.h> |
141 | #include <sys/proc.h> | | 141 | #include <sys/proc.h> |
142 | #include <machine/../linux/linux.h> | | 142 | #include <machine/../linux/linux.h> |
143 | #include <machine/../linux/linux_proto.h> | | 143 | #include <machine/../linux/linux_proto.h> |
144 | #else | | 144 | #else |
145 | /* Either it was defined when it shouldn't be (FreeBSD amd64) or it isn't | | 145 | /* Either it was defined when it shouldn't be (FreeBSD amd64) or it isn't |
146 | * supported on this OS yet. | | 146 | * supported on this OS yet. |
147 | */ | | 147 | */ |
148 | #undef DRM_LINUX | | 148 | #undef DRM_LINUX |
149 | #define DRM_LINUX 0 | | 149 | #define DRM_LINUX 0 |
150 | #endif | | 150 | #endif |
151 | | | 151 | |
152 | /* driver capabilities and requirements mask */ | | 152 | /* driver capabilities and requirements mask */ |
153 | #define DRIVER_USE_AGP 0x1 | | 153 | #define DRIVER_USE_AGP 0x1 |
154 | #define DRIVER_REQUIRE_AGP 0x2 | | 154 | #define DRIVER_REQUIRE_AGP 0x2 |
155 | #define DRIVER_USE_MTRR 0x4 | | 155 | #define DRIVER_USE_MTRR 0x4 |
156 | #define DRIVER_PCI_DMA 0x8 | | 156 | #define DRIVER_PCI_DMA 0x8 |
157 | #define DRIVER_SG 0x10 | | 157 | #define DRIVER_SG 0x10 |
158 | #define DRIVER_HAVE_DMA 0x20 | | 158 | #define DRIVER_HAVE_DMA 0x20 |
159 | #define DRIVER_HAVE_IRQ 0x40 | | 159 | #define DRIVER_HAVE_IRQ 0x40 |
160 | #define DRIVER_DMA_QUEUE 0x100 | | 160 | #define DRIVER_DMA_QUEUE 0x100 |
161 | | | 161 | |
162 | | | 162 | |
163 | #define DRM_HASH_SIZE 16 /* Size of key hash table */ | | 163 | #define DRM_HASH_SIZE 16 /* Size of key hash table */ |
164 | #define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */ | | 164 | #define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */ |
165 | #define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */ | | 165 | #define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */ |
166 | | | 166 | |
167 | MALLOC_DECLARE(DRM_MEM_DMA); | | 167 | MALLOC_DECLARE(DRM_MEM_DMA); |
168 | MALLOC_DECLARE(DRM_MEM_SAREA); | | 168 | MALLOC_DECLARE(DRM_MEM_SAREA); |
169 | MALLOC_DECLARE(DRM_MEM_DRIVER); | | 169 | MALLOC_DECLARE(DRM_MEM_DRIVER); |
170 | MALLOC_DECLARE(DRM_MEM_MAGIC); | | 170 | MALLOC_DECLARE(DRM_MEM_MAGIC); |
171 | MALLOC_DECLARE(DRM_MEM_IOCTLS); | | 171 | MALLOC_DECLARE(DRM_MEM_IOCTLS); |
172 | MALLOC_DECLARE(DRM_MEM_MAPS); | | 172 | MALLOC_DECLARE(DRM_MEM_MAPS); |
173 | MALLOC_DECLARE(DRM_MEM_BUFS); | | 173 | MALLOC_DECLARE(DRM_MEM_BUFS); |
174 | MALLOC_DECLARE(DRM_MEM_SEGS); | | 174 | MALLOC_DECLARE(DRM_MEM_SEGS); |
175 | MALLOC_DECLARE(DRM_MEM_PAGES); | | 175 | MALLOC_DECLARE(DRM_MEM_PAGES); |
176 | MALLOC_DECLARE(DRM_MEM_FILES); | | 176 | MALLOC_DECLARE(DRM_MEM_FILES); |
177 | MALLOC_DECLARE(DRM_MEM_QUEUES); | | 177 | MALLOC_DECLARE(DRM_MEM_QUEUES); |
178 | MALLOC_DECLARE(DRM_MEM_CMDS); | | 178 | MALLOC_DECLARE(DRM_MEM_CMDS); |
179 | MALLOC_DECLARE(DRM_MEM_MAPPINGS); | | 179 | MALLOC_DECLARE(DRM_MEM_MAPPINGS); |
180 | MALLOC_DECLARE(DRM_MEM_BUFLISTS); | | 180 | MALLOC_DECLARE(DRM_MEM_BUFLISTS); |
181 | MALLOC_DECLARE(DRM_MEM_AGPLISTS); | | 181 | MALLOC_DECLARE(DRM_MEM_AGPLISTS); |
182 | MALLOC_DECLARE(DRM_MEM_CTXBITMAP); | | 182 | MALLOC_DECLARE(DRM_MEM_CTXBITMAP); |
183 | MALLOC_DECLARE(DRM_MEM_SGLISTS); | | 183 | MALLOC_DECLARE(DRM_MEM_SGLISTS); |
184 | MALLOC_DECLARE(DRM_MEM_DRAWABLE); | | 184 | MALLOC_DECLARE(DRM_MEM_DRAWABLE); |
185 | | | 185 | |
186 | #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8) | | 186 | #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8) |
187 | | | 187 | |
188 | /* Internal types and structures */ | | 188 | /* Internal types and structures */ |
189 | #define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) | | 189 | #define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0])) |
190 | #define DRM_MIN(a,b) ((a)<(b)?(a):(b)) | | 190 | #define DRM_MIN(a,b) ((a)<(b)?(a):(b)) |
191 | #define DRM_MAX(a,b) ((a)>(b)?(a):(b)) | | 191 | #define DRM_MAX(a,b) ((a)>(b)?(a):(b)) |
192 | | | 192 | |
193 | #define DRM_IF_VERSION(maj, min) (maj << 16 | min) | | 193 | #define DRM_IF_VERSION(maj, min) (maj << 16 | min) |
194 | | | 194 | |
195 | #define __OS_HAS_AGP 1 | | 195 | #define __OS_HAS_AGP 1 |
196 | | | 196 | |
197 | #define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) | | 197 | #define DRM_DEV_MODE (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP) |
198 | #define DRM_DEV_UID 0 | | 198 | #define DRM_DEV_UID 0 |
199 | #define DRM_DEV_GID 0 | | 199 | #define DRM_DEV_GID 0 |
200 | | | 200 | |
201 | #define wait_queue_head_t atomic_t | | 201 | #define wait_queue_head_t atomic_t |
202 | #define DRM_WAKEUP(w) wakeup((void *)w) | | 202 | #define DRM_WAKEUP(w) wakeup((void *)w) |
203 | #define DRM_WAKEUP_INT(w) wakeup(w) | | 203 | #define DRM_WAKEUP_INT(w) wakeup(w) |
204 | #define DRM_INIT_WAITQUEUE(queue) do {(void)(queue);} while (0) | | 204 | #define DRM_INIT_WAITQUEUE(queue) do {(void)(queue);} while (0) |
205 | | | 205 | |
206 | #if defined(__FreeBSD__) | | 206 | #if defined(__FreeBSD__) |
207 | #define DRM_CDEV struct cdev * | | 207 | #define DRM_CDEV struct cdev * |
208 | #define DRM_CURPROC curthread | | 208 | #define DRM_CURPROC curthread |
209 | #define DRM_STRUCTPROC struct thread | | 209 | #define DRM_STRUCTPROC struct thread |
210 | #define DRM_STRUCTCDEVPROC struct thread | | 210 | #define DRM_STRUCTCDEVPROC struct thread |
211 | #define DRM_CDEVPROC_REAL(p) (p) | | 211 | #define DRM_CDEVPROC_REAL(p) (p) |
212 | #define DRM_IOCTL_DATA caddr_t | | 212 | #define DRM_IOCTL_DATA caddr_t |
213 | #define DRM_SPINTYPE struct mtx | | 213 | #define DRM_SPINTYPE struct mtx |
214 | #define DRM_SPININIT(l,name) mtx_init(l, name, NULL, MTX_DEF) | | 214 | #define DRM_SPININIT(l,name) mtx_init(l, name, NULL, MTX_DEF) |
215 | #define DRM_SPINUNINIT(l) mtx_destroy(l) | | 215 | #define DRM_SPINUNINIT(l) mtx_destroy(l) |
216 | #define DRM_SPINLOCK(l) mtx_lock(l) | | 216 | #define DRM_SPINLOCK(l) mtx_lock(l) |
217 | #define DRM_SPINUNLOCK(u) mtx_unlock(u) | | 217 | #define DRM_SPINUNLOCK(u) mtx_unlock(u) |
218 | #define DRM_SPINLOCK_IRQSAVE(l, irqflags) do { \ | | 218 | #define DRM_SPINLOCK_IRQSAVE(l, irqflags) do { \ |
219 | mtx_lock(l); \ | | 219 | mtx_lock(l); \ |
220 | (void)irqflags; \ | | 220 | (void)irqflags; \ |
221 | } while (0) | | 221 | } while (0) |
222 | #define DRM_SPINUNLOCK_IRQRESTORE(u, irqflags) mtx_unlock(u) | | 222 | #define DRM_SPINUNLOCK_IRQRESTORE(u, irqflags) mtx_unlock(u) |
223 | #define DRM_SPINLOCK_ASSERT(l) mtx_assert(l, MA_OWNED) | | 223 | #define DRM_SPINLOCK_ASSERT(l) mtx_assert(l, MA_OWNED) |
224 | #define DRM_CURRENTPID curthread->td_proc->p_pid | | 224 | #define DRM_CURRENTPID curthread->td_proc->p_pid |
225 | #define DRM_LOCK() mtx_lock(&dev->dev_lock) | | 225 | #define DRM_LOCK() mtx_lock(&dev->dev_lock) |
226 | #define DRM_UNLOCK() mtx_unlock(&dev->dev_lock) | | 226 | #define DRM_UNLOCK() mtx_unlock(&dev->dev_lock) |
227 | #define DRM_SYSCTL_HANDLER_ARGS (SYSCTL_HANDLER_ARGS) | | 227 | #define DRM_SYSCTL_HANDLER_ARGS (SYSCTL_HANDLER_ARGS) |
228 | #elif defined(__NetBSD__) | | 228 | #elif defined(__NetBSD__) |
229 | #define DRM_CDEV dev_t | | 229 | #define DRM_CDEV dev_t |
230 | #define DRM_CURPROC curproc | | 230 | #define DRM_CURPROC curproc |
231 | #define DRM_STRUCTPROC struct proc | | 231 | #define DRM_STRUCTPROC struct proc |
232 | #define DRM_STRUCTCDEVPROC struct lwp | | 232 | #define DRM_STRUCTCDEVPROC struct lwp |
233 | #define DRM_CDEVPROC_REAL(l) (l)->l_proc | | 233 | #define DRM_CDEVPROC_REAL(l) (l)->l_proc |
234 | #define DRM_IOCTL_DATA void * | | 234 | #define DRM_IOCTL_DATA void * |
235 | #define DRM_SPINTYPE kmutex_t | | 235 | #define DRM_SPINTYPE kmutex_t |
236 | #define DRM_SPININIT(l,name) mutex_init(l, MUTEX_DEFAULT, /*IPL_NONE*/ IPL_VM) | | 236 | #define DRM_SPININIT(l,name) mutex_init(l, MUTEX_DEFAULT, /*IPL_NONE*/ IPL_VM) |
237 | #define DRM_SPINUNINIT(l) mutex_destroy(l) | | 237 | #define DRM_SPINUNINIT(l) mutex_destroy(l) |
238 | #define DRM_SPINLOCK(l) mutex_enter(l) | | 238 | #define DRM_SPINLOCK(l) mutex_enter(l) |
239 | #define DRM_SPINUNLOCK(u) mutex_exit(u) | | 239 | #define DRM_SPINUNLOCK(u) mutex_exit(u) |
240 | #define DRM_SPINLOCK_IRQSAVE(l, irqflags) do { \ | | 240 | #define DRM_SPINLOCK_IRQSAVE(l, irqflags) do { \ |
241 | mutex_enter(l); \ | | 241 | mutex_enter(l); \ |
242 | (void)irqflags; \ | | 242 | (void)irqflags; \ |
243 | } while (0) | | 243 | } while (0) |
244 | #define DRM_SPINUNLOCK_IRQRESTORE(u, irqflags) mutex_exit(u) | | 244 | #define DRM_SPINUNLOCK_IRQRESTORE(u, irqflags) mutex_exit(u) |
245 | #define DRM_SPINLOCK_ASSERT(l) mutex_owned(l) | | 245 | #define DRM_SPINLOCK_ASSERT(l) mutex_owned(l) |
246 | #define DRM_CURRENTPID curproc->p_pid | | 246 | #define DRM_CURRENTPID curproc->p_pid |
247 | #define DRM_LOCK() DRM_SPINLOCK(&dev->dev_lock) | | 247 | #define DRM_LOCK() DRM_SPINLOCK(&dev->dev_lock) |
248 | #define DRM_UNLOCK() DRM_SPINUNLOCK(&dev->dev_lock) | | 248 | #define DRM_UNLOCK() DRM_SPINUNLOCK(&dev->dev_lock) |
249 | #define DRM_SYSCTL_HANDLER_ARGS (SYSCTLFN_ARGS) | | 249 | #define DRM_SYSCTL_HANDLER_ARGS (SYSCTLFN_ARGS) |
250 | #define vslock(addr, len) uvm_vslock(curproc->p_vmspace, addr, len, VM_PROT_READ | VM_PROT_WRITE) | | 250 | #define vslock(addr, len) uvm_vslock(curproc->p_vmspace, addr, len, VM_PROT_READ | VM_PROT_WRITE) |
251 | #define vsunlock(addr, len) uvm_vsunlock(curproc->p_vmspace, addr, len) | | 251 | #define vsunlock(addr, len) uvm_vsunlock(curproc->p_vmspace, addr, len) |
252 | #endif | | 252 | #endif |
253 | | | 253 | |
254 | #define DRM_IRQ_ARGS void *arg | | 254 | #define DRM_IRQ_ARGS void *arg |
255 | #if defined(__FreeBSD__) | | 255 | #if defined(__FreeBSD__) |
256 | typedef void irqreturn_t; | | 256 | typedef void irqreturn_t; |
257 | #define IRQ_HANDLED /* nothing */ | | 257 | #define IRQ_HANDLED /* nothing */ |
258 | #define IRQ_NONE /* nothing */ | | 258 | #define IRQ_NONE /* nothing */ |
259 | #elif defined(__NetBSD__) | | 259 | #elif defined(__NetBSD__) |
260 | typedef int irqreturn_t; | | 260 | typedef int irqreturn_t; |
261 | #define IRQ_HANDLED 1 | | 261 | #define IRQ_HANDLED 1 |
262 | #define IRQ_NONE 0 | | 262 | #define IRQ_NONE 0 |
263 | #endif | | 263 | #endif |
264 | | | 264 | |
265 | enum { | | 265 | enum { |
266 | DRM_IS_NOT_AGP, | | 266 | DRM_IS_NOT_AGP, |
267 | DRM_IS_AGP, | | 267 | DRM_IS_AGP, |
268 | DRM_MIGHT_BE_AGP | | 268 | DRM_MIGHT_BE_AGP |
269 | }; | | 269 | }; |
270 | #define DRM_AGP_MEM struct agp_memory_info | | 270 | #define DRM_AGP_MEM struct agp_memory_info |
271 | | | 271 | |
272 | #if defined(__FreeBSD__) | | 272 | #if defined(__FreeBSD__) |
273 | #define drm_get_device_from_kdev(_kdev) (_kdev->si_drv1) | | 273 | #define drm_get_device_from_kdev(_kdev) (_kdev->si_drv1) |
274 | #elif defined(__NetBSD__) | | 274 | #elif defined(__NetBSD__) |
275 | #define drm_get_device_from_kdev(_kdev) ((minor(_kdev) < DRM_MAXUNITS) ? \ | | 275 | #define drm_get_device_from_kdev(_kdev) ((minor(_kdev) < DRM_MAXUNITS) ? \ |
276 | drm_units[minor(_kdev)] : NULL) | | 276 | drm_units[minor(_kdev)] : NULL) |
277 | #endif | | 277 | #endif |
278 | | | 278 | |
279 | #if defined(__FreeBSD__) | | 279 | #if defined(__FreeBSD__) |
280 | #define PAGE_ALIGN(addr) round_page(addr) | | 280 | #define PAGE_ALIGN(addr) round_page(addr) |
281 | /* DRM_SUSER returns true if the user is superuser */ | | 281 | /* DRM_SUSER returns true if the user is superuser */ |
282 | #if __FreeBSD_version >= 700000 | | 282 | #if __FreeBSD_version >= 700000 |
283 | #define DRM_SUSER(p) (priv_check(p, PRIV_DRIVER) == 0) | | 283 | #define DRM_SUSER(p) (priv_check(p, PRIV_DRIVER) == 0) |
284 | #else | | 284 | #else |
285 | #define DRM_SUSER(p) (suser(p) == 0) | | 285 | #define DRM_SUSER(p) (suser(p) == 0) |
286 | #endif | | 286 | #endif |
287 | #define DRM_AGP_FIND_DEVICE() agp_find_device() | | 287 | #define DRM_AGP_FIND_DEVICE() agp_find_device() |
288 | #define DRM_MTRR_WC MDF_WRITECOMBINE | | 288 | #define DRM_MTRR_WC MDF_WRITECOMBINE |
289 | #define jiffies ticks | | 289 | #define jiffies ticks |
290 | | | 290 | |
291 | #elif defined(__NetBSD__) | | 291 | #elif defined(__NetBSD__) |
292 | | | 292 | |
293 | #define PAGE_ALIGN(addr) ALIGN(addr) | | 293 | #define PAGE_ALIGN(addr) ALIGN(addr) |
294 | #define DRM_SUSER(p) (kauth_cred_getsvuid((p)->p_cred) == 0) | | 294 | #define DRM_SUSER(p) (kauth_cred_getsvuid((p)->p_cred) == 0) |
295 | #define DRM_AGP_FIND_DEVICE() agp_find_device(0) | | 295 | #define DRM_AGP_FIND_DEVICE() agp_find_device(0) |
296 | #define DRM_MTRR_WC MTRR_TYPE_WC | | 296 | #define DRM_MTRR_WC MTRR_TYPE_WC |
297 | #define jiffies hardclock_ticks | | 297 | #define jiffies hardclock_ticks |
298 | | | 298 | |
299 | #define DRM_MAXUNITS 128 | | 299 | #define DRM_MAXUNITS 128 |
300 | extern struct drm_device *drm_units[]; | | 300 | extern struct drm_device *drm_units[]; |
301 | | | 301 | |
302 | #endif | | 302 | #endif |
303 | | | 303 | |
304 | /* Capabilities taken from src/sys/dev/pci/pcireg.h. */ | | 304 | /* Capabilities taken from src/sys/dev/pci/pcireg.h. */ |
305 | #ifndef PCIY_AGP | | 305 | #ifndef PCIY_AGP |
306 | #define PCIY_AGP 0x02 | | 306 | #define PCIY_AGP 0x02 |
307 | #endif | | 307 | #endif |
308 | | | 308 | |
309 | #ifndef PCIY_EXPRESS | | 309 | #ifndef PCIY_EXPRESS |
310 | #define PCIY_EXPRESS 0x10 | | 310 | #define PCIY_EXPRESS 0x10 |
311 | #endif | | 311 | #endif |
312 | | | 312 | |
313 | typedef unsigned long dma_addr_t; | | 313 | typedef unsigned long dma_addr_t; |
314 | #if defined(__FreeBSD__) | | 314 | #if defined(__FreeBSD__) |
315 | typedef u_int64_t u64; | | 315 | typedef u_int64_t u64; |
316 | typedef u_int32_t u32; | | 316 | typedef u_int32_t u32; |
317 | typedef u_int16_t u16; | | 317 | typedef u_int16_t u16; |
318 | typedef u_int8_t u8; | | 318 | typedef u_int8_t u8; |
319 | #else | | 319 | #else |
320 | typedef uint64_t u64; | | 320 | typedef uint64_t u64; |
321 | typedef uint32_t u32; | | 321 | typedef uint32_t u32; |
322 | typedef uint16_t u16; | | 322 | typedef uint16_t u16; |
323 | typedef uint8_t u8; | | 323 | typedef uint8_t u8; |
324 | #endif | | 324 | #endif |
325 | | | 325 | |
326 | /* DRM_READMEMORYBARRIER() prevents reordering of reads. | | 326 | /* DRM_READMEMORYBARRIER() prevents reordering of reads. |
327 | * DRM_WRITEMEMORYBARRIER() prevents reordering of writes. | | 327 | * DRM_WRITEMEMORYBARRIER() prevents reordering of writes. |
328 | * DRM_MEMORYBARRIER() prevents reordering of reads and writes. | | 328 | * DRM_MEMORYBARRIER() prevents reordering of reads and writes. |
329 | */ | | 329 | */ |
330 | #if defined(__NetBSD__) | | 330 | #if defined(__NetBSD__) |
331 | #define DRM_READMEMORYBARRIER() membar_consumer() | | 331 | #define DRM_READMEMORYBARRIER() membar_consumer() |
332 | #define DRM_WRITEMEMORYBARRIER() membar_producer() | | 332 | #define DRM_WRITEMEMORYBARRIER() membar_producer() |
333 | #define DRM_MEMORYBARRIER() membar_sync() | | 333 | #define DRM_MEMORYBARRIER() membar_sync() |
334 | #elif defined(__i386__) | | 334 | #elif defined(__i386__) |
335 | #define DRM_READMEMORYBARRIER() __asm __volatile( \ | | 335 | #define DRM_READMEMORYBARRIER() __asm __volatile( \ |
336 | "lock; addl $0,0(%%esp)" : : : "memory"); | | 336 | "lock; addl $0,0(%%esp)" : : : "memory"); |
337 | #define DRM_WRITEMEMORYBARRIER() __asm __volatile("" : : : "memory"); | | 337 | #define DRM_WRITEMEMORYBARRIER() __asm __volatile("" : : : "memory"); |
338 | #define DRM_MEMORYBARRIER() __asm __volatile( \ | | 338 | #define DRM_MEMORYBARRIER() __asm __volatile( \ |
339 | "lock; addl $0,0(%%esp)" : : : "memory"); | | 339 | "lock; addl $0,0(%%esp)" : : : "memory"); |
340 | #elif defined(__alpha__) | | 340 | #elif defined(__alpha__) |
341 | #define DRM_READMEMORYBARRIER() alpha_mb(); | | 341 | #define DRM_READMEMORYBARRIER() alpha_mb(); |
342 | #define DRM_WRITEMEMORYBARRIER() alpha_wmb(); | | 342 | #define DRM_WRITEMEMORYBARRIER() alpha_wmb(); |
343 | #define DRM_MEMORYBARRIER() alpha_mb(); | | 343 | #define DRM_MEMORYBARRIER() alpha_mb(); |
344 | #elif defined(__amd64__) | | 344 | #elif defined(__amd64__) |
345 | #define DRM_READMEMORYBARRIER() __asm __volatile( \ | | 345 | #define DRM_READMEMORYBARRIER() __asm __volatile( \ |
346 | "lock; addl $0,0(%%rsp)" : : : "memory"); | | 346 | "lock; addl $0,0(%%rsp)" : : : "memory"); |
347 | #define DRM_WRITEMEMORYBARRIER() __asm __volatile("" : : : "memory"); | | 347 | #define DRM_WRITEMEMORYBARRIER() __asm __volatile("" : : : "memory"); |
348 | #define DRM_MEMORYBARRIER() __asm __volatile( \ | | 348 | #define DRM_MEMORYBARRIER() __asm __volatile( \ |
349 | "lock; addl $0,0(%%rsp)" : : : "memory"); | | 349 | "lock; addl $0,0(%%rsp)" : : : "memory"); |
350 | #endif | | 350 | #endif |
351 | | | 351 | |
352 | #if defined(__FreeBSD__) | | 352 | #if defined(__FreeBSD__) |
353 | | | 353 | |
354 | #define DRM_READ8(map, offset) \ | | 354 | #define DRM_READ8(map, offset) \ |
355 | *(volatile u_int8_t *)(((vm_offset_t)(map)->handle) + \ | | 355 | *(volatile u_int8_t *)(((vm_offset_t)(map)->handle) + \ |
356 | (vm_offset_t)(offset)) | | 356 | (vm_offset_t)(offset)) |
357 | #define DRM_READ16(map, offset) \ | | 357 | #define DRM_READ16(map, offset) \ |
358 | *(volatile u_int16_t *)(((vm_offset_t)(map)->handle) + \ | | 358 | *(volatile u_int16_t *)(((vm_offset_t)(map)->handle) + \ |
359 | (vm_offset_t)(offset)) | | 359 | (vm_offset_t)(offset)) |
360 | #define DRM_READ32(map, offset) \ | | 360 | #define DRM_READ32(map, offset) \ |
361 | *(volatile u_int32_t *)(((vm_offset_t)(map)->handle) + \ | | 361 | *(volatile u_int32_t *)(((vm_offset_t)(map)->handle) + \ |
362 | (vm_offset_t)(offset)) | | 362 | (vm_offset_t)(offset)) |
363 | #define DRM_WRITE8(map, offset, val) \ | | 363 | #define DRM_WRITE8(map, offset, val) \ |
364 | *(volatile u_int8_t *)(((vm_offset_t)(map)->handle) + \ | | 364 | *(volatile u_int8_t *)(((vm_offset_t)(map)->handle) + \ |
365 | (vm_offset_t)(offset)) = val | | 365 | (vm_offset_t)(offset)) = val |
366 | #define DRM_WRITE16(map, offset, val) \ | | 366 | #define DRM_WRITE16(map, offset, val) \ |
367 | *(volatile u_int16_t *)(((vm_offset_t)(map)->handle) + \ | | 367 | *(volatile u_int16_t *)(((vm_offset_t)(map)->handle) + \ |
368 | (vm_offset_t)(offset)) = val | | 368 | (vm_offset_t)(offset)) = val |
369 | #define DRM_WRITE32(map, offset, val) \ | | 369 | #define DRM_WRITE32(map, offset, val) \ |
370 | *(volatile u_int32_t *)(((vm_offset_t)(map)->handle) + \ | | 370 | *(volatile u_int32_t *)(((vm_offset_t)(map)->handle) + \ |
371 | (vm_offset_t)(offset)) = val | | 371 | (vm_offset_t)(offset)) = val |
372 | | | 372 | |
373 | #define DRM_VERIFYAREA_READ( uaddr, size ) \ | | 373 | #define DRM_VERIFYAREA_READ( uaddr, size ) \ |
374 | (!useracc(__DECONST(caddr_t, uaddr), size, VM_PROT_READ)) | | 374 | (!useracc(__DECONST(caddr_t, uaddr), size, VM_PROT_READ)) |
375 | | | 375 | |
376 | #elif defined(__NetBSD__) | | 376 | #elif defined(__NetBSD__) |
377 | | | 377 | |
378 | typedef vaddr_t vm_offset_t; | | 378 | typedef vaddr_t vm_offset_t; |
379 | | | 379 | |
380 | #define DRM_READ8(map, offset) \ | | 380 | #define DRM_READ8(map, offset) \ |
381 | bus_space_read_1( (map)->bst, (map)->bsh, (offset)) | | 381 | bus_space_read_1( (map)->bst, (map)->bsh, (offset)) |
382 | #define DRM_READ16(map, offset) \ | | 382 | #define DRM_READ16(map, offset) \ |
383 | bus_space_read_2( (map)->bst, (map)->bsh, (offset)) | | 383 | bus_space_read_2( (map)->bst, (map)->bsh, (offset)) |
384 | #define DRM_READ32(map, offset) \ | | 384 | #define DRM_READ32(map, offset) \ |
385 | bus_space_read_4( (map)->bst, (map)->bsh, (offset)) | | 385 | bus_space_read_4( (map)->bst, (map)->bsh, (offset)) |
386 | #define DRM_WRITE8(map, offset, val) \ | | 386 | #define DRM_WRITE8(map, offset, val) \ |
387 | bus_space_write_1((map)->bst, (map)->bsh, (offset), (val)) | | 387 | bus_space_write_1((map)->bst, (map)->bsh, (offset), (val)) |
388 | #define DRM_WRITE16(map, offset, val) \ | | 388 | #define DRM_WRITE16(map, offset, val) \ |
389 | bus_space_write_2((map)->bst, (map)->bsh, (offset), (val)) | | 389 | bus_space_write_2((map)->bst, (map)->bsh, (offset), (val)) |
390 | #define DRM_WRITE32(map, offset, val) \ | | 390 | #define DRM_WRITE32(map, offset, val) \ |
391 | bus_space_write_4((map)->bst, (map)->bsh, (offset), (val)) | | 391 | bus_space_write_4((map)->bst, (map)->bsh, (offset), (val)) |
392 | | | 392 | |
393 | #define DRM_VERIFYAREA_READ( uaddr, size ) \ | | 393 | #define DRM_VERIFYAREA_READ( uaddr, size ) \ |
394 | (!uvm_map_checkprot(&(curproc->p_vmspace->vm_map), \ | | 394 | (!uvm_map_checkprot(&(curproc->p_vmspace->vm_map), \ |
395 | (vaddr_t)uaddr, (vaddr_t)uaddr+size, UVM_PROT_READ)) | | 395 | (vaddr_t)uaddr, (vaddr_t)uaddr+size, UVM_PROT_READ)) |
396 | | | 396 | |
397 | #endif | | 397 | #endif |
398 | | | 398 | |
399 | #define DRM_COPY_TO_USER(user, kern, size) \ | | 399 | #define DRM_COPY_TO_USER(user, kern, size) \ |
400 | copyout(kern, user, size) | | 400 | copyout(kern, user, size) |
401 | #define DRM_COPY_FROM_USER(kern, user, size) \ | | 401 | #define DRM_COPY_FROM_USER(kern, user, size) \ |
402 | copyin(user, kern, size) | | 402 | copyin(user, kern, size) |
403 | #define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \ | | 403 | #define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \ |
404 | copyin(arg2, arg1, arg3) | | 404 | copyin(arg2, arg1, arg3) |
405 | #define DRM_COPY_TO_USER_UNCHECKED(arg1, arg2, arg3) \ | | 405 | #define DRM_COPY_TO_USER_UNCHECKED(arg1, arg2, arg3) \ |
406 | copyout(arg2, arg1, arg3) | | 406 | copyout(arg2, arg1, arg3) |
407 | #if defined(__FreeBSD__) | | 407 | #if defined(__FreeBSD__) |
408 | #define DRM_GET_USER_UNCHECKED(val, uaddr) \ | | 408 | #define DRM_GET_USER_UNCHECKED(val, uaddr) \ |
409 | ((val) = fuword32(uaddr), 0) | | 409 | ((val) = fuword32(uaddr), 0) |
410 | #else | | 410 | #else |
411 | #define DRM_GET_USER_UNCHECKED(val, uaddr) \ | | 411 | #define DRM_GET_USER_UNCHECKED(val, uaddr) \ |
412 | ((val) = fuword(uaddr), 0) | | 412 | ((val) = fuword(uaddr), 0) |
413 | #endif | | 413 | #endif |
414 | | | 414 | |
415 | #define cpu_to_le32(x) htole32(x) | | 415 | #define cpu_to_le32(x) htole32(x) |
416 | #define le32_to_cpu(x) le32toh(x) | | 416 | #define le32_to_cpu(x) le32toh(x) |
417 | | | 417 | |
418 | #define DRM_HZ hz | | 418 | #define DRM_HZ hz |
419 | #define DRM_UDELAY(udelay) DELAY(udelay) | | 419 | #define DRM_UDELAY(udelay) DELAY(udelay) |
420 | #define DRM_TIME_SLICE (hz/20) /* Time slice for GLXContexts */ | | 420 | #define DRM_TIME_SLICE (hz/20) /* Time slice for GLXContexts */ |
421 | | | 421 | |
422 | #define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \ | | 422 | #define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \ |
423 | (_map) = (_dev)->context_sareas[_ctx]; \ | | 423 | (_map) = (_dev)->context_sareas[_ctx]; \ |
424 | } while(0) | | 424 | } while(0) |
425 | | | 425 | |
426 | #define LOCK_TEST_WITH_RETURN(dev, file_priv) \ | | 426 | #define LOCK_TEST_WITH_RETURN(dev, file_priv) \ |
427 | do { \ | | 427 | do { \ |
428 | if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \ | | 428 | if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \ |
429 | dev->lock.file_priv != file_priv) { \ | | 429 | dev->lock.file_priv != file_priv) { \ |
430 | DRM_ERROR("%s called without lock held\n", \ | | 430 | DRM_ERROR("%s called without lock held\n", \ |
431 | __FUNCTION__); \ | | 431 | __FUNCTION__); \ |
432 | return EINVAL; \ | | 432 | return EINVAL; \ |
433 | } \ | | 433 | } \ |
434 | } while (0) | | 434 | } while (0) |
435 | | | 435 | |
436 | /* Returns -errno to shared code */ | | 436 | /* Returns -errno to shared code */ |
437 | #if defined(__FreeBSD__) | | 437 | #if defined(__FreeBSD__) |
438 | #define DRM_WAIT_ON( ret, queue, timeout, condition ) \ | | 438 | #define DRM_WAIT_ON( ret, queue, timeout, condition ) \ |
439 | for ( ret = 0 ; !ret && !(condition) ; ) { \ | | 439 | for ( ret = 0 ; !ret && !(condition) ; ) { \ |
440 | DRM_UNLOCK(); \ | | 440 | DRM_UNLOCK(); \ |
441 | mtx_lock(&dev->irq_lock); \ | | 441 | mtx_lock(&dev->irq_lock); \ |
442 | if (!(condition)) \ | | 442 | if (!(condition)) \ |
443 | ret = -mtx_sleep(&(queue), &dev->irq_lock, \ | | 443 | ret = -mtx_sleep(&(queue), &dev->irq_lock, \ |
444 | PCATCH, "drmwtq", (timeout)); \ | | 444 | PCATCH, "drmwtq", (timeout)); \ |
445 | mtx_unlock(&dev->irq_lock); \ | | 445 | mtx_unlock(&dev->irq_lock); \ |
446 | DRM_LOCK(); \ | | 446 | DRM_LOCK(); \ |
447 | } | | 447 | } |
448 | #elif defined(__NetBSD__) | | 448 | #elif defined(__NetBSD__) |
449 | /* Returns -errno to shared code */ | | 449 | /* Returns -errno to shared code */ |
450 | #define DRM_WAIT_ON( ret, queue, timeout, condition ) \ | | 450 | #define DRM_WAIT_ON( ret, queue, timeout, condition ) \ |
451 | for ( ret = 0 ; !ret && !(condition) ; ) { \ | | 451 | for ( ret = 0 ; !ret && !(condition) ; ) { \ |
452 | DRM_UNLOCK(); \ | | 452 | DRM_UNLOCK(); \ |
453 | mutex_enter(&dev->irq_lock); \ | | 453 | mutex_enter(&dev->irq_lock); \ |
454 | if (!(condition)) \ | | 454 | if (!(condition)) \ |
455 | ret = -mtsleep(&(queue), PCATCH, \ | | 455 | ret = -mtsleep(&(queue), PCATCH, \ |
456 | "drmwtq", (timeout), &dev->irq_lock); \ | | 456 | "drmwtq", (timeout), &dev->irq_lock); \ |
457 | mutex_exit(&dev->irq_lock); \ | | 457 | mutex_exit(&dev->irq_lock); \ |
458 | DRM_LOCK(); \ | | 458 | DRM_LOCK(); \ |
459 | } | | 459 | } |
460 | #endif | | 460 | #endif |
461 | | | 461 | |
462 | #define DRM_ERROR(fmt, ...) \ | | 462 | #define DRM_ERROR(fmt, ...) \ |
463 | printf("error: [" DRM_NAME ":pid%d:%s] *ERROR* " fmt, \ | | 463 | printf("error: [" DRM_NAME ":pid%d:%s] *ERROR* " fmt, \ |
464 | DRM_CURRENTPID, __func__ , ##__VA_ARGS__) | | 464 | DRM_CURRENTPID, __func__ , ##__VA_ARGS__) |
465 | | | 465 | |
466 | #define DRM_INFO(fmt, ...) printf("info: [" DRM_NAME "] " fmt , ##__VA_ARGS__) | | 466 | #define DRM_INFO(fmt, ...) printf("info: [" DRM_NAME "] " fmt , ##__VA_ARGS__) |
467 | | | 467 | |
468 | #define DRM_DEBUG(fmt, ...) do { \ | | 468 | #define DRM_DEBUG(fmt, ...) do { \ |
469 | if (drm_debug_flag) \ | | 469 | if (drm_debug_flag) \ |
470 | printf("[" DRM_NAME ":pid%d:%s] " fmt, DRM_CURRENTPID, \ | | 470 | printf("[" DRM_NAME ":pid%d:%s] " fmt, DRM_CURRENTPID, \ |
471 | __func__ , ##__VA_ARGS__); \ | | 471 | __func__ , ##__VA_ARGS__); \ |
472 | } while (0) | | 472 | } while (0) |
473 | | | 473 | |
474 | typedef struct drm_pci_id_list | | 474 | typedef struct drm_pci_id_list |
475 | { | | 475 | { |
476 | int vendor; | | 476 | int vendor; |
477 | int device; | | 477 | int device; |
478 | long driver_private; | | 478 | long driver_private; |
479 | #if defined(__NetBSD__) | | 479 | #if defined(__NetBSD__) |
480 | const char *name; | | 480 | const char *name; |
481 | #else | | 481 | #else |
482 | char *name; | | 482 | char *name; |
483 | #endif | | 483 | #endif |
484 | } drm_pci_id_list_t; | | 484 | } drm_pci_id_list_t; |
485 | | | 485 | |
486 | struct drm_msi_blacklist_entry | | 486 | struct drm_msi_blacklist_entry |
487 | { | | 487 | { |
488 | int vendor; | | 488 | int vendor; |
489 | int device; | | 489 | int device; |
490 | }; | | 490 | }; |
491 | | | 491 | |
492 | #define DRM_AUTH 0x1 | | 492 | #define DRM_AUTH 0x1 |
493 | #define DRM_MASTER 0x2 | | 493 | #define DRM_MASTER 0x2 |
494 | #define DRM_ROOT_ONLY 0x4 | | 494 | #define DRM_ROOT_ONLY 0x4 |
495 | typedef struct drm_ioctl_desc { | | 495 | typedef struct drm_ioctl_desc { |
496 | unsigned long cmd; | | 496 | unsigned long cmd; |
497 | int (*func)(struct drm_device *dev, void *data, | | 497 | int (*func)(struct drm_device *dev, void *data, |
498 | struct drm_file *file_priv); | | 498 | struct drm_file *file_priv); |
499 | int flags; | | 499 | int flags; |
500 | } drm_ioctl_desc_t; | | 500 | } drm_ioctl_desc_t; |
501 | /** | | 501 | /** |
502 | * Creates a driver or general drm_ioctl_desc array entry for the given | | 502 | * Creates a driver or general drm_ioctl_desc array entry for the given |
503 | * ioctl, for use by drm_ioctl(). | | 503 | * ioctl, for use by drm_ioctl(). |
504 | */ | | 504 | */ |
505 | #define DRM_IOCTL_DEF(ioctl, func, flags) \ | | 505 | #define DRM_IOCTL_DEF(ioctl, func, flags) \ |
506 | [DRM_IOCTL_NR(ioctl)] = {ioctl, func, flags} | | 506 | [DRM_IOCTL_NR(ioctl)] = {ioctl, func, flags} |
507 | | | 507 | |
508 | typedef struct drm_magic_entry { | | 508 | typedef struct drm_magic_entry { |
509 | drm_magic_t magic; | | 509 | drm_magic_t magic; |
510 | struct drm_file *priv; | | 510 | struct drm_file *priv; |
511 | struct drm_magic_entry *next; | | 511 | struct drm_magic_entry *next; |
512 | } drm_magic_entry_t; | | 512 | } drm_magic_entry_t; |
513 | | | 513 | |
514 | typedef struct drm_magic_head { | | 514 | typedef struct drm_magic_head { |
515 | struct drm_magic_entry *head; | | 515 | struct drm_magic_entry *head; |
516 | struct drm_magic_entry *tail; | | 516 | struct drm_magic_entry *tail; |
517 | } drm_magic_head_t; | | 517 | } drm_magic_head_t; |
518 | | | 518 | |
519 | typedef struct drm_buf { | | 519 | typedef struct drm_buf { |
520 | int idx; /* Index into master buflist */ | | 520 | int idx; /* Index into master buflist */ |
521 | int total; /* Buffer size */ | | 521 | int total; /* Buffer size */ |
522 | int order; /* log-base-2(total) */ | | 522 | int order; /* log-base-2(total) */ |
523 | int used; /* Amount of buffer in use (for DMA) */ | | 523 | int used; /* Amount of buffer in use (for DMA) */ |
524 | unsigned long offset; /* Byte offset (used internally) */ | | 524 | unsigned long offset; /* Byte offset (used internally) */ |
525 | void *address; /* Address of buffer */ | | 525 | void *address; /* Address of buffer */ |
526 | unsigned long bus_address; /* Bus address of buffer */ | | 526 | unsigned long bus_address; /* Bus address of buffer */ |
527 | struct drm_buf *next; /* Kernel-only: used for free list */ | | 527 | struct drm_buf *next; /* Kernel-only: used for free list */ |
528 | __volatile__ int pending; /* On hardware DMA queue */ | | 528 | __volatile__ int pending; /* On hardware DMA queue */ |
529 | struct drm_file *file_priv; /* Unique identifier of holding process */ | | 529 | struct drm_file *file_priv; /* Unique identifier of holding process */ |
530 | int context; /* Kernel queue for this buffer */ | | 530 | int context; /* Kernel queue for this buffer */ |
531 | enum { | | 531 | enum { |
532 | DRM_LIST_NONE = 0, | | 532 | DRM_LIST_NONE = 0, |
533 | DRM_LIST_FREE = 1, | | 533 | DRM_LIST_FREE = 1, |
534 | DRM_LIST_WAIT = 2, | | 534 | DRM_LIST_WAIT = 2, |
535 | DRM_LIST_PEND = 3, | | 535 | DRM_LIST_PEND = 3, |
536 | DRM_LIST_PRIO = 4, | | 536 | DRM_LIST_PRIO = 4, |
537 | DRM_LIST_RECLAIM = 5 | | 537 | DRM_LIST_RECLAIM = 5 |
538 | } list; /* Which list we're on */ | | 538 | } list; /* Which list we're on */ |
539 | | | 539 | |
540 | int dev_priv_size; /* Size of buffer private stoarge */ | | 540 | int dev_priv_size; /* Size of buffer private stoarge */ |
541 | void *dev_private; /* Per-buffer private storage */ | | 541 | void *dev_private; /* Per-buffer private storage */ |
542 | } drm_buf_t; | | 542 | } drm_buf_t; |
543 | | | 543 | |
544 | typedef struct drm_freelist { | | 544 | typedef struct drm_freelist { |
545 | int initialized; /* Freelist in use */ | | 545 | int initialized; /* Freelist in use */ |
546 | atomic_t count; /* Number of free buffers */ | | 546 | atomic_t count; /* Number of free buffers */ |
547 | drm_buf_t *next; /* End pointer */ | | 547 | drm_buf_t *next; /* End pointer */ |
548 | | | 548 | |
549 | int low_mark; /* Low water mark */ | | 549 | int low_mark; /* Low water mark */ |
550 | int high_mark; /* High water mark */ | | 550 | int high_mark; /* High water mark */ |
551 | } drm_freelist_t; | | 551 | } drm_freelist_t; |
552 | | | 552 | |
553 | typedef struct drm_dma_handle { | | 553 | typedef struct drm_dma_handle { |
554 | void *vaddr; | | 554 | void *vaddr; |
555 | bus_addr_t busaddr; | | 555 | bus_addr_t busaddr; |
556 | bus_dma_tag_t tag; | | 556 | bus_dma_tag_t tag; |
557 | bus_dmamap_t map; | | 557 | bus_dmamap_t map; |
558 | #if defined(__NetBSD__) | | 558 | #if defined(__NetBSD__) |
559 | size_t size; | | 559 | size_t size; |
560 | size_t nsegs; | | 560 | size_t nsegs; |
561 | bus_dma_segment_t segs[1]; | | 561 | bus_dma_segment_t segs[1]; |
562 | #endif | | 562 | #endif |
563 | } drm_dma_handle_t; | | 563 | } drm_dma_handle_t; |
564 | | | 564 | |
565 | typedef struct drm_buf_entry { | | 565 | typedef struct drm_buf_entry { |
566 | int buf_size; | | 566 | int buf_size; |
567 | int buf_count; | | 567 | int buf_count; |
568 | drm_buf_t *buflist; | | 568 | drm_buf_t *buflist; |
569 | int seg_count; | | 569 | int seg_count; |
570 | drm_dma_handle_t **seglist; | | 570 | drm_dma_handle_t **seglist; |
571 | int page_order; | | 571 | int page_order; |
572 | | | 572 | |
573 | drm_freelist_t freelist; | | 573 | drm_freelist_t freelist; |
574 | } drm_buf_entry_t; | | 574 | } drm_buf_entry_t; |
575 | | | 575 | |
576 | typedef TAILQ_HEAD(drm_file_list, drm_file) drm_file_list_t; | | 576 | typedef TAILQ_HEAD(drm_file_list, drm_file) drm_file_list_t; |
577 | struct drm_file { | | 577 | struct drm_file { |
578 | TAILQ_ENTRY(drm_file) link; | | 578 | TAILQ_ENTRY(drm_file) link; |
579 | struct drm_device *dev; | | 579 | struct drm_device *dev; |
580 | int authenticated; | | 580 | int authenticated; |
581 | int master; | | 581 | int master; |
582 | int minor; | | 582 | int minor; |
583 | pid_t pid; | | 583 | pid_t pid; |
584 | uid_t uid; | | 584 | uid_t uid; |
585 | #if defined(__NetBSD__) | | | |
586 | int refs; | | | |
587 | #endif | | | |
588 | drm_magic_t magic; | | 585 | drm_magic_t magic; |
589 | unsigned long ioctl_count; | | 586 | unsigned long ioctl_count; |
590 | void *driver_priv; | | 587 | void *driver_priv; |
591 | }; | | 588 | }; |
592 | | | 589 | |
593 | typedef struct drm_lock_data { | | 590 | typedef struct drm_lock_data { |
594 | struct drm_hw_lock *hw_lock; /* Hardware lock */ | | 591 | struct drm_hw_lock *hw_lock; /* Hardware lock */ |
595 | struct drm_file *file_priv; /* Unique identifier of holding process (NULL is kernel)*/ | | 592 | struct drm_file *file_priv; /* Unique identifier of holding process (NULL is kernel)*/ |
596 | int lock_queue; /* Queue of blocked processes */ | | 593 | int lock_queue; /* Queue of blocked processes */ |
597 | unsigned long lock_time; /* Time of last lock in jiffies */ | | 594 | unsigned long lock_time; /* Time of last lock in jiffies */ |
598 | } drm_lock_data_t; | | 595 | } drm_lock_data_t; |
599 | | | 596 | |
600 | /* This structure, in the struct drm_device, is always initialized while the | | 597 | /* This structure, in the struct drm_device, is always initialized while the |
601 | * device | | 598 | * device |
602 | * is open. dev->dma_lock protects the incrementing of dev->buf_use, which | | 599 | * is open. dev->dma_lock protects the incrementing of dev->buf_use, which |
603 | * when set marks that no further bufs may be allocated until device teardown | | 600 | * when set marks that no further bufs may be allocated until device teardown |
604 | * occurs (when the last open of the device has closed). The high/low | | 601 | * occurs (when the last open of the device has closed). The high/low |
605 | * watermarks of bufs are only touched by the X Server, and thus not | | 602 | * watermarks of bufs are only touched by the X Server, and thus not |
606 | * concurrently accessed, so no locking is needed. | | 603 | * concurrently accessed, so no locking is needed. |
607 | */ | | 604 | */ |
608 | typedef struct drm_device_dma { | | 605 | typedef struct drm_device_dma { |
609 | drm_buf_entry_t bufs[DRM_MAX_ORDER+1]; | | 606 | drm_buf_entry_t bufs[DRM_MAX_ORDER+1]; |
610 | int buf_count; | | 607 | int buf_count; |
611 | drm_buf_t **buflist; /* Vector of pointers info bufs */ | | 608 | drm_buf_t **buflist; /* Vector of pointers info bufs */ |
612 | int seg_count; | | 609 | int seg_count; |
613 | int page_count; | | 610 | int page_count; |
614 | unsigned long *pagelist; | | 611 | unsigned long *pagelist; |
615 | unsigned long byte_count; | | 612 | unsigned long byte_count; |
616 | enum { | | 613 | enum { |
617 | _DRM_DMA_USE_AGP = 0x01, | | 614 | _DRM_DMA_USE_AGP = 0x01, |
618 | _DRM_DMA_USE_SG = 0x02 | | 615 | _DRM_DMA_USE_SG = 0x02 |
619 | } flags; | | 616 | } flags; |
620 | } drm_device_dma_t; | | 617 | } drm_device_dma_t; |
621 | | | 618 | |
622 | typedef struct drm_agp_mem { | | 619 | typedef struct drm_agp_mem { |
623 | void *handle; | | 620 | void *handle; |
624 | unsigned long bound; /* address */ | | 621 | unsigned long bound; /* address */ |
625 | int pages; | | 622 | int pages; |
626 | struct drm_agp_mem *prev; | | 623 | struct drm_agp_mem *prev; |
627 | struct drm_agp_mem *next; | | 624 | struct drm_agp_mem *next; |
628 | } drm_agp_mem_t; | | 625 | } drm_agp_mem_t; |
629 | | | 626 | |
630 | typedef struct drm_agp_head { | | 627 | typedef struct drm_agp_head { |
631 | device_t agpdev; | | 628 | device_t agpdev; |
632 | struct agp_info info; | | 629 | struct agp_info info; |
633 | const char *chipset; | | 630 | const char *chipset; |
634 | drm_agp_mem_t *memory; | | 631 | drm_agp_mem_t *memory; |
635 | unsigned long mode; | | 632 | unsigned long mode; |
636 | int enabled; | | 633 | int enabled; |
637 | int acquired; | | 634 | int acquired; |
638 | unsigned long base; | | 635 | unsigned long base; |
639 | int mtrr; | | 636 | int mtrr; |
640 | int cant_use_aperture; | | 637 | int cant_use_aperture; |
641 | unsigned long page_mask; | | 638 | unsigned long page_mask; |
642 | } drm_agp_head_t; | | 639 | } drm_agp_head_t; |
643 | | | 640 | |
644 | typedef struct drm_sg_mem { | | 641 | typedef struct drm_sg_mem { |
645 | unsigned long handle; | | 642 | unsigned long handle; |
646 | void *virtual; | | 643 | void *virtual; |
647 | int pages; | | 644 | int pages; |
648 | dma_addr_t *busaddr; | | 645 | dma_addr_t *busaddr; |
649 | struct drm_dma_handle *sg_dmah; /* Handle for sg_pages */ | | 646 | struct drm_dma_handle *sg_dmah; /* Handle for sg_pages */ |
650 | struct drm_dma_handle *dmah; /* Handle to PCI memory */ | | 647 | struct drm_dma_handle *dmah; /* Handle to PCI memory */ |
651 | /* for ATI PCIGART table */ | | 648 | /* for ATI PCIGART table */ |
652 | } drm_sg_mem_t; | | 649 | } drm_sg_mem_t; |
653 | | | 650 | |
654 | typedef TAILQ_HEAD(drm_map_list, drm_local_map) drm_map_list_t; | | 651 | typedef TAILQ_HEAD(drm_map_list, drm_local_map) drm_map_list_t; |
655 | | | 652 | |
656 | typedef struct drm_local_map { | | 653 | typedef struct drm_local_map { |
657 | unsigned long offset; /* Physical address (0 for SAREA)*/ | | 654 | unsigned long offset; /* Physical address (0 for SAREA)*/ |
658 | unsigned long size; /* Physical size (bytes) */ | | 655 | unsigned long size; /* Physical size (bytes) */ |
659 | enum drm_map_type type; /* Type of memory mapped */ | | 656 | enum drm_map_type type; /* Type of memory mapped */ |
660 | enum drm_map_flags flags; /* Flags */ | | 657 | enum drm_map_flags flags; /* Flags */ |
661 | void *handle; /* User-space: "Handle" to pass to mmap */ | | 658 | void *handle; /* User-space: "Handle" to pass to mmap */ |
662 | /* Kernel-space: kernel-virtual address */ | | 659 | /* Kernel-space: kernel-virtual address */ |
663 | int mtrr; /* Boolean: MTRR used */ | | 660 | int mtrr; /* Boolean: MTRR used */ |
664 | /* Private data */ | | 661 | /* Private data */ |
665 | int rid; /* PCI resource ID for bus_space */ | | 662 | int rid; /* PCI resource ID for bus_space */ |
666 | #if defined(__FreeBSD__) | | 663 | #if defined(__FreeBSD__) |
667 | struct resource *bsr; | | 664 | struct resource *bsr; |
668 | #endif | | 665 | #endif |
669 | bus_space_tag_t bst; | | 666 | bus_space_tag_t bst; |
670 | bus_space_handle_t bsh; | | 667 | bus_space_handle_t bsh; |
671 | drm_dma_handle_t *dmah; | | 668 | drm_dma_handle_t *dmah; |
672 | #if defined(__NetBSD__) | | 669 | #if defined(__NetBSD__) |
673 | int *cnt; | | 670 | int *cnt; |
674 | bus_size_t mapsize; | | 671 | bus_size_t mapsize; |
675 | #endif | | 672 | #endif |
676 | TAILQ_ENTRY(drm_local_map) link; | | 673 | TAILQ_ENTRY(drm_local_map) link; |
677 | } drm_local_map_t; | | 674 | } drm_local_map_t; |
678 | | | 675 | |
679 | TAILQ_HEAD(drm_vbl_sig_list, drm_vbl_sig); | | 676 | TAILQ_HEAD(drm_vbl_sig_list, drm_vbl_sig); |
680 | typedef struct drm_vbl_sig { | | 677 | typedef struct drm_vbl_sig { |
681 | TAILQ_ENTRY(drm_vbl_sig) link; | | 678 | TAILQ_ENTRY(drm_vbl_sig) link; |
682 | unsigned int sequence; | | 679 | unsigned int sequence; |
683 | int signo; | | 680 | int signo; |
684 | int pid; | | 681 | int pid; |
685 | } drm_vbl_sig_t; | | 682 | } drm_vbl_sig_t; |
686 | | | 683 | |
687 | struct drm_vblank_info { | | 684 | struct drm_vblank_info { |
688 | wait_queue_head_t queue; /* vblank wait queue */ | | 685 | wait_queue_head_t queue; /* vblank wait queue */ |
689 | atomic_t count; /* number of VBLANK interrupts */ | | 686 | atomic_t count; /* number of VBLANK interrupts */ |
690 | /* (driver must alloc the right number of counters) */ | | 687 | /* (driver must alloc the right number of counters) */ |
691 | struct drm_vbl_sig_list sigs; /* signal list to send on VBLANK */ | | 688 | struct drm_vbl_sig_list sigs; /* signal list to send on VBLANK */ |
692 | atomic_t refcount; /* number of users of vblank interrupts */ | | 689 | atomic_t refcount; /* number of users of vblank interrupts */ |
693 | u32 last; /* protected by dev->vbl_lock, used */ | | 690 | u32 last; /* protected by dev->vbl_lock, used */ |
694 | /* for wraparound handling */ | | 691 | /* for wraparound handling */ |
695 | int enabled; /* so we don't call enable more than */ | | 692 | int enabled; /* so we don't call enable more than */ |
696 | /* once per disable */ | | 693 | /* once per disable */ |
697 | int inmodeset; /* Display driver is setting mode */ | | 694 | int inmodeset; /* Display driver is setting mode */ |
698 | }; | | 695 | }; |
699 | | | 696 | |
700 | /* location of GART table */ | | 697 | /* location of GART table */ |
701 | #define DRM_ATI_GART_MAIN 1 | | 698 | #define DRM_ATI_GART_MAIN 1 |
702 | #define DRM_ATI_GART_FB 2 | | 699 | #define DRM_ATI_GART_FB 2 |
703 | | | 700 | |
704 | #define DRM_ATI_GART_PCI 1 | | 701 | #define DRM_ATI_GART_PCI 1 |
705 | #define DRM_ATI_GART_PCIE 2 | | 702 | #define DRM_ATI_GART_PCIE 2 |
706 | #define DRM_ATI_GART_IGP 3 | | 703 | #define DRM_ATI_GART_IGP 3 |
707 | | | 704 | |
708 | struct drm_ati_pcigart_info { | | 705 | struct drm_ati_pcigart_info { |
709 | int gart_table_location; | | 706 | int gart_table_location; |
710 | int gart_reg_if; | | 707 | int gart_reg_if; |
711 | void *addr; | | 708 | void *addr; |
712 | dma_addr_t bus_addr; | | 709 | dma_addr_t bus_addr; |
713 | dma_addr_t table_mask; | | 710 | dma_addr_t table_mask; |
714 | dma_addr_t member_mask; | | 711 | dma_addr_t member_mask; |
715 | struct drm_dma_handle *table_handle; | | 712 | struct drm_dma_handle *table_handle; |
716 | drm_local_map_t mapping; | | 713 | drm_local_map_t mapping; |
717 | int table_size; | | 714 | int table_size; |
718 | }; | | 715 | }; |
719 | | | 716 | |
720 | #ifndef DMA_BIT_MASK | | 717 | #ifndef DMA_BIT_MASK |
721 | #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : (1ULL<<(n)) - 1) | | 718 | #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : (1ULL<<(n)) - 1) |
722 | #endif | | 719 | #endif |
723 | | | 720 | |
724 | #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) | | 721 | #define upper_32_bits(n) ((u32)(((n) >> 16) >> 16)) |
725 | | | 722 | |
726 | struct drm_driver_info { | | 723 | struct drm_driver_info { |
727 | int (*load)(struct drm_device *, unsigned long flags); | | 724 | int (*load)(struct drm_device *, unsigned long flags); |
728 | int (*firstopen)(struct drm_device *); | | 725 | int (*firstopen)(struct drm_device *); |
729 | int (*open)(struct drm_device *, struct drm_file *); | | 726 | int (*open)(struct drm_device *, struct drm_file *); |
730 | void (*preclose)(struct drm_device *, struct drm_file *file_priv); | | 727 | void (*preclose)(struct drm_device *, struct drm_file *file_priv); |
731 | void (*postclose)(struct drm_device *, struct drm_file *); | | 728 | void (*postclose)(struct drm_device *, struct drm_file *); |
732 | void (*lastclose)(struct drm_device *); | | 729 | void (*lastclose)(struct drm_device *); |
733 | int (*unload)(struct drm_device *); | | 730 | int (*unload)(struct drm_device *); |
734 | void (*reclaim_buffers_locked)(struct drm_device *, | | 731 | void (*reclaim_buffers_locked)(struct drm_device *, |
735 | struct drm_file *file_priv); | | 732 | struct drm_file *file_priv); |
736 | int (*dma_ioctl)(struct drm_device *dev, void *data, | | 733 | int (*dma_ioctl)(struct drm_device *dev, void *data, |
737 | struct drm_file *file_priv); | | 734 | struct drm_file *file_priv); |
738 | void (*dma_ready)(struct drm_device *); | | 735 | void (*dma_ready)(struct drm_device *); |
739 | int (*dma_quiescent)(struct drm_device *); | | 736 | int (*dma_quiescent)(struct drm_device *); |
740 | int (*dma_flush_block_and_flush)(struct drm_device *, int context, | | 737 | int (*dma_flush_block_and_flush)(struct drm_device *, int context, |
741 | enum drm_lock_flags flags); | | 738 | enum drm_lock_flags flags); |
742 | int (*dma_flush_unblock)(struct drm_device *, int context, | | 739 | int (*dma_flush_unblock)(struct drm_device *, int context, |
743 | enum drm_lock_flags flags); | | 740 | enum drm_lock_flags flags); |
744 | int (*context_ctor)(struct drm_device *dev, int context); | | 741 | int (*context_ctor)(struct drm_device *dev, int context); |
745 | int (*context_dtor)(struct drm_device *dev, int context); | | 742 | int (*context_dtor)(struct drm_device *dev, int context); |
746 | int (*kernel_context_switch)(struct drm_device *dev, int old, | | 743 | int (*kernel_context_switch)(struct drm_device *dev, int old, |
747 | int new); | | 744 | int new); |
748 | int (*kernel_context_switch_unlock)(struct drm_device *dev); | | 745 | int (*kernel_context_switch_unlock)(struct drm_device *dev); |
749 | void (*irq_preinstall)(struct drm_device *dev); | | 746 | void (*irq_preinstall)(struct drm_device *dev); |
750 | int (*irq_postinstall)(struct drm_device *dev); | | 747 | int (*irq_postinstall)(struct drm_device *dev); |
751 | void (*irq_uninstall)(struct drm_device *dev); | | 748 | void (*irq_uninstall)(struct drm_device *dev); |
752 | irqreturn_t (*irq_handler)(DRM_IRQ_ARGS); | | 749 | irqreturn_t (*irq_handler)(DRM_IRQ_ARGS); |
753 | u32 (*get_vblank_counter)(struct drm_device *dev, int crtc); | | 750 | u32 (*get_vblank_counter)(struct drm_device *dev, int crtc); |
754 | int (*enable_vblank)(struct drm_device *dev, int crtc); | | 751 | int (*enable_vblank)(struct drm_device *dev, int crtc); |
755 | void (*disable_vblank)(struct drm_device *dev, int crtc); | | 752 | void (*disable_vblank)(struct drm_device *dev, int crtc); |
756 | | | 753 | |
757 | drm_pci_id_list_t *id_entry; /* PCI ID, name, and chipset private */ | | 754 | drm_pci_id_list_t *id_entry; /* PCI ID, name, and chipset private */ |
758 | | | 755 | |
759 | /** | | 756 | /** |
760 | * Called by \c drm_device_is_agp. Typically used to determine if a | | 757 | * Called by \c drm_device_is_agp. Typically used to determine if a |
761 | * card is really attached to AGP or not. | | 758 | * card is really attached to AGP or not. |
762 | * | | 759 | * |
763 | * \param dev DRM device handle | | 760 | * \param dev DRM device handle |
764 | * | | 761 | * |
765 | * \returns | | 762 | * \returns |
766 | * One of three values is returned depending on whether or not the | | 763 | * One of three values is returned depending on whether or not the |
767 | * card is absolutely \b not AGP (return of 0), absolutely \b is AGP | | 764 | * card is absolutely \b not AGP (return of 0), absolutely \b is AGP |
768 | * (return of 1), or may or may not be AGP (return of 2). | | 765 | * (return of 1), or may or may not be AGP (return of 2). |
769 | */ | | 766 | */ |
770 | int (*device_is_agp) (struct drm_device * dev); | | 767 | int (*device_is_agp) (struct drm_device * dev); |
771 | | | 768 | |
772 | drm_ioctl_desc_t *ioctls; | | 769 | drm_ioctl_desc_t *ioctls; |
773 | int max_ioctl; | | 770 | int max_ioctl; |
774 | | | 771 | |
775 | int buf_priv_size; | | 772 | int buf_priv_size; |
776 | | | 773 | |
777 | int major; | | 774 | int major; |
778 | int minor; | | 775 | int minor; |
779 | int patchlevel; | | 776 | int patchlevel; |
780 | const char *name; /* Simple driver name */ | | 777 | const char *name; /* Simple driver name */ |
781 | const char *desc; /* Longer driver name */ | | 778 | const char *desc; /* Longer driver name */ |
782 | const char *date; /* Date of last major changes. */ | | 779 | const char *date; /* Date of last major changes. */ |
783 | | | 780 | |
784 | u32 driver_features; | | 781 | u32 driver_features; |
785 | }; | | 782 | }; |
786 | | | 783 | |
787 | /* Length for the array of resource pointers for drm_get_resource_*. */ | | 784 | /* Length for the array of resource pointers for drm_get_resource_*. */ |
788 | #define DRM_MAX_PCI_RESOURCE 6 | | 785 | #define DRM_MAX_PCI_RESOURCE 6 |
789 | | | 786 | |
790 | #if defined(__NetBSD__) | | 787 | #if defined(__NetBSD__) |
791 | typedef struct { | | 788 | typedef struct { |
792 | int mapped; | | 789 | int mapped; |
793 | int maptype; | | 790 | int maptype; |
794 | bus_addr_t base; | | 791 | bus_addr_t base; |
795 | bus_size_t size; | | 792 | bus_size_t size; |
796 | bus_space_handle_t bsh; | | 793 | bus_space_handle_t bsh; |
797 | int flags; | | 794 | int flags; |
798 | void * vaddr; | | 795 | void * vaddr; |
799 | } pci_map_data_t; | | 796 | } pci_map_data_t; |
800 | #endif | | 797 | #endif |
801 | | | 798 | |
802 | /** | | 799 | /** |
803 | * DRM device functions structure | | 800 | * DRM device functions structure |
804 | */ | | 801 | */ |
805 | struct drm_device { | | 802 | struct drm_device { |
806 | struct drm_driver_info *driver; | | 803 | struct drm_driver_info *driver; |
807 | drm_pci_id_list_t *id_entry; /* PCI ID, name, and chipset private */ | | 804 | drm_pci_id_list_t *id_entry; /* PCI ID, name, and chipset private */ |
808 | | | 805 | |
809 | u_int16_t pci_device; /* PCI device id */ | | 806 | u_int16_t pci_device; /* PCI device id */ |
810 | u_int16_t pci_vendor; /* PCI vendor id */ | | 807 | u_int16_t pci_vendor; /* PCI vendor id */ |
811 | | | 808 | |
812 | char *unique; /* Unique identifier: e.g., busid */ | | 809 | char *unique; /* Unique identifier: e.g., busid */ |
813 | int unique_len; /* Length of unique field */ | | 810 | int unique_len; /* Length of unique field */ |
814 | device_t device; /* Device instance from newbus */ | | 811 | device_t device; /* Device instance from newbus */ |
815 | #if defined(__FreeBSD__) | | 812 | #if defined(__FreeBSD__) |
816 | struct cdev *devnode; /* Device number for mknod */ | | 813 | struct cdev *devnode; /* Device number for mknod */ |
817 | #endif | | 814 | #endif |
818 | int if_version; /* Highest interface version set */ | | 815 | int if_version; /* Highest interface version set */ |
819 | | | 816 | |
820 | int flags; /* Flags to open(2) */ | | 817 | int flags; /* Flags to open(2) */ |
821 | | | 818 | |
822 | /* Locks */ | | 819 | /* Locks */ |
823 | DRM_SPINTYPE vbl_lock; /* protects vblank operations */ | | 820 | DRM_SPINTYPE vbl_lock; /* protects vblank operations */ |
824 | DRM_SPINTYPE dma_lock; /* protects dev->dma */ | | 821 | DRM_SPINTYPE dma_lock; /* protects dev->dma */ |
825 | DRM_SPINTYPE irq_lock; /* protects irq condition checks */ | | 822 | DRM_SPINTYPE irq_lock; /* protects irq condition checks */ |
826 | DRM_SPINTYPE dev_lock; /* protects everything else */ | | 823 | DRM_SPINTYPE dev_lock; /* protects everything else */ |
827 | DRM_SPINTYPE drw_lock; | | 824 | DRM_SPINTYPE drw_lock; |
828 | | | 825 | |
829 | /* Usage Counters */ | | 826 | /* Usage Counters */ |
830 | int open_count; /* Outstanding files open */ | | 827 | int open_count; /* Outstanding files open */ |
831 | int buf_use; /* Buffers in use -- cannot alloc */ | | 828 | int buf_use; /* Buffers in use -- cannot alloc */ |
832 | | | 829 | |
833 | /* Performance counters */ | | 830 | /* Performance counters */ |
834 | unsigned long counters; | | 831 | unsigned long counters; |
835 | enum drm_stat_type types[15]; | | 832 | enum drm_stat_type types[15]; |
836 | atomic_t counts[15]; | | 833 | atomic_t counts[15]; |
837 | | | 834 | |
838 | /* Authentication */ | | 835 | /* Authentication */ |
839 | drm_file_list_t files; | | 836 | drm_file_list_t files; |
840 | drm_magic_head_t magiclist[DRM_HASH_SIZE]; | | 837 | drm_magic_head_t magiclist[DRM_HASH_SIZE]; |
841 | | | 838 | |
842 | /* Linked list of mappable regions. Protected by dev_lock */ | | 839 | /* Linked list of mappable regions. Protected by dev_lock */ |
843 | drm_map_list_t maplist; | | 840 | drm_map_list_t maplist; |
844 | | | 841 | |
845 | drm_local_map_t **context_sareas; | | 842 | drm_local_map_t **context_sareas; |
846 | int max_context; | | 843 | int max_context; |
847 | | | 844 | |
848 | drm_lock_data_t lock; /* Information on hardware lock */ | | 845 | drm_lock_data_t lock; /* Information on hardware lock */ |
849 | | | 846 | |
850 | /* DMA queues (contexts) */ | | 847 | /* DMA queues (contexts) */ |
851 | drm_device_dma_t *dma; /* Optional pointer for DMA support */ | | 848 | drm_device_dma_t *dma; /* Optional pointer for DMA support */ |
852 | | | 849 | |
853 | /* Context support */ | | 850 | /* Context support */ |
854 | int irq; /* Interrupt used by board */ | | 851 | int irq; /* Interrupt used by board */ |
855 | int irq_enabled; /* True if the irq handler is enabled */ | | 852 | int irq_enabled; /* True if the irq handler is enabled */ |
856 | int msi_enabled; /* MSI enabled */ | | 853 | int msi_enabled; /* MSI enabled */ |
857 | #if defined(__FreeBSD__) | | 854 | #if defined(__FreeBSD__) |
858 | int irqrid; /* Interrupt used by board */ | | 855 | int irqrid; /* Interrupt used by board */ |
859 | struct resource *irqr; /* Resource for interrupt used by board */ | | 856 | struct resource *irqr; /* Resource for interrupt used by board */ |
860 | | | 857 | |
861 | /* Storage of resource pointers for drm_get_resource_* */ | | 858 | /* Storage of resource pointers for drm_get_resource_* */ |
862 | struct resource *pcir[DRM_MAX_PCI_RESOURCE]; | | 859 | struct resource *pcir[DRM_MAX_PCI_RESOURCE]; |
863 | int pcirid[DRM_MAX_PCI_RESOURCE]; | | 860 | int pcirid[DRM_MAX_PCI_RESOURCE]; |
864 | #elif defined(__NetBSD__) | | 861 | #elif defined(__NetBSD__) |
865 | struct pci_attach_args pa; | | 862 | struct pci_attach_args pa; |
866 | pci_map_data_t pci_map_data[DRM_MAX_PCI_RESOURCE]; | | 863 | pci_map_data_t pci_map_data[DRM_MAX_PCI_RESOURCE]; |
867 | pci_map_data_t agp_map_data[DRM_MAX_PCI_RESOURCE]; | | 864 | pci_map_data_t agp_map_data[DRM_MAX_PCI_RESOURCE]; |
868 | dev_t kdev; | | 865 | dev_t kdev; |
869 | #endif | | 866 | #endif |
870 | void *irqh; /* Handle from bus_setup_intr */ | | 867 | void *irqh; /* Handle from bus_setup_intr */ |
871 | | | 868 | |
872 | int pci_domain; | | 869 | int pci_domain; |
873 | int pci_bus; | | 870 | int pci_bus; |
874 | int pci_slot; | | 871 | int pci_slot; |
875 | int pci_func; | | 872 | int pci_func; |
876 | | | 873 | |
877 | atomic_t context_flag; /* Context swapping flag */ | | 874 | atomic_t context_flag; /* Context swapping flag */ |
878 | int last_context; /* Last current context */ | | 875 | int last_context; /* Last current context */ |
879 | | | 876 | |
880 | int vblank_disable_allowed; | | 877 | int vblank_disable_allowed; |
881 | atomic_t vbl_signal_pending; /* number of signals pending on all crtcs */ | | 878 | atomic_t vbl_signal_pending; /* number of signals pending on all crtcs */ |
882 | struct callout vblank_disable_timer; | | 879 | struct callout vblank_disable_timer; |
883 | u32 max_vblank_count; /* size of vblank counter register */ | | 880 | u32 max_vblank_count; /* size of vblank counter register */ |
884 | struct drm_vblank_info *vblank; /* per crtc vblank info */ | | 881 | struct drm_vblank_info *vblank; /* per crtc vblank info */ |
885 | int num_crtcs; | | 882 | int num_crtcs; |
886 | | | 883 | |
887 | #if defined(__FreeBSD__) | | 884 | #if defined(__FreeBSD__) |
888 | struct sigio *buf_sigio; /* Processes waiting for SIGIO */ | | 885 | struct sigio *buf_sigio; /* Processes waiting for SIGIO */ |
889 | #elif defined(__NetBSD__) | | 886 | #elif defined(__NetBSD__) |
890 | pid_t buf_pgid; | | 887 | pid_t buf_pgid; |
891 | #endif | | 888 | #endif |
892 | | | 889 | |
893 | /* Sysctl support */ | | 890 | /* Sysctl support */ |
894 | struct drm_sysctl_info *sysctl; | | 891 | struct drm_sysctl_info *sysctl; |
895 | | | 892 | |
896 | drm_agp_head_t *agp; | | 893 | drm_agp_head_t *agp; |
897 | drm_sg_mem_t *sg; /* Scatter gather memory */ | | 894 | drm_sg_mem_t *sg; /* Scatter gather memory */ |
898 | atomic_t *ctx_bitmap; | | 895 | atomic_t *ctx_bitmap; |
899 | void *dev_private; | | 896 | void *dev_private; |
900 | unsigned int agp_buffer_token; | | 897 | unsigned int agp_buffer_token; |
901 | drm_local_map_t *agp_buffer_map; | | 898 | drm_local_map_t *agp_buffer_map; |
902 | | | 899 | |
903 | #if defined(__FreeBSD__) | | 900 | #if defined(__FreeBSD__) |
904 | struct unrhdr *drw_unrhdr; | | 901 | struct unrhdr *drw_unrhdr; |
905 | #elif defined(__NetBSD__) | | 902 | #elif defined(__NetBSD__) |
906 | int drw_no; | | 903 | int drw_no; |
907 | #endif | | 904 | #endif |
908 | /* RB tree of drawable infos */ | | 905 | /* RB tree of drawable infos */ |
909 | RB_HEAD(drawable_tree, bsd_drm_drawable_info) drw_head; | | 906 | RB_HEAD(drawable_tree, bsd_drm_drawable_info) drw_head; |
910 | }; | | 907 | }; |
911 | | | 908 | |
912 | static __inline__ int drm_core_check_feature(struct drm_device *dev, | | 909 | static __inline__ int drm_core_check_feature(struct drm_device *dev, |
913 | int feature) | | 910 | int feature) |
914 | { | | 911 | { |
915 | return ((dev->driver->driver_features & feature) ? 1 : 0); | | 912 | return ((dev->driver->driver_features & feature) ? 1 : 0); |
916 | } | | 913 | } |
917 | | | 914 | |
918 | #if __OS_HAS_AGP | | 915 | #if __OS_HAS_AGP |
919 | static inline int drm_core_has_AGP(struct drm_device *dev) | | 916 | static inline int drm_core_has_AGP(struct drm_device *dev) |
920 | { | | 917 | { |
921 | return drm_core_check_feature(dev, DRIVER_USE_AGP); | | 918 | return drm_core_check_feature(dev, DRIVER_USE_AGP); |
922 | } | | 919 | } |
923 | #else | | 920 | #else |
924 | #define drm_core_has_AGP(dev) (0) | | 921 | #define drm_core_has_AGP(dev) (0) |
925 | #endif | | 922 | #endif |
926 | | | 923 | |
927 | extern int drm_debug_flag; | | 924 | extern int drm_debug_flag; |
928 | | | 925 | |
929 | /* Device setup support (drm_drv.c) */ | | 926 | /* Device setup support (drm_drv.c) */ |
930 | #if defined(__FreeBSD__) | | 927 | #if defined(__FreeBSD__) |
931 | int drm_probe(device_t kdev, drm_pci_id_list_t *idlist); | | 928 | int drm_probe(device_t kdev, drm_pci_id_list_t *idlist); |
932 | int drm_attach(device_t kdev, drm_pci_id_list_t *idlist); | | 929 | int drm_attach(device_t kdev, drm_pci_id_list_t *idlist); |
933 | void drm_close(void *data); | | 930 | void drm_close(void *data); |
934 | int drm_detach(device_t kdev); | | 931 | int drm_detach(device_t kdev); |
935 | d_ioctl_t drm_ioctl; | | 932 | d_ioctl_t drm_ioctl; |
936 | d_open_t drm_open; | | 933 | d_open_t drm_open; |
937 | d_read_t drm_read; | | 934 | d_read_t drm_read; |
938 | d_poll_t drm_poll; | | 935 | d_poll_t drm_poll; |
939 | d_mmap_t drm_mmap; | | 936 | d_mmap_t drm_mmap; |
940 | #elif defined(__NetBSD__) | | 937 | #elif defined(__NetBSD__) |
941 | int drm_probe(struct pci_attach_args *pa, drm_pci_id_list_t *idlist); | | 938 | int drm_probe(struct pci_attach_args *pa, drm_pci_id_list_t *idlist); |
942 | void drm_attach(device_t kdev, struct pci_attach_args *pa, drm_pci_id_list_t *idlist); | | 939 | void drm_attach(device_t kdev, struct pci_attach_args *pa, drm_pci_id_list_t *idlist); |
943 | int drm_detach(device_t self, int flags); | | 940 | int drm_detach(device_t self, int flags); |
944 | int drm_activate(device_t self, devact_t act); | | 941 | int drm_activate(device_t self, devact_t act); |
945 | dev_type_ioctl(drm_ioctl); | | 942 | dev_type_ioctl(drm_ioctl); |
946 | dev_type_open(drm_open); | | 943 | dev_type_open(drm_open); |
947 | dev_type_close(drm_close); | | 944 | dev_type_close(drm_close); |
948 | dev_type_read(drm_read); | | 945 | dev_type_read(drm_read); |
949 | dev_type_poll(drm_poll); | | 946 | dev_type_poll(drm_poll); |
950 | dev_type_mmap(drm_mmap); | | 947 | dev_type_mmap(drm_mmap); |
951 | #endif | | 948 | #endif |
952 | extern drm_local_map_t *drm_getsarea(struct drm_device *dev); | | 949 | extern drm_local_map_t *drm_getsarea(struct drm_device *dev); |
953 | | | 950 | |
954 | int drm_close_pid(struct drm_device *dev, struct drm_file *priv, pid_t pid); | | 951 | int drm_close_pid(struct drm_device *dev, struct drm_file *priv, pid_t pid); |
955 | | | 952 | |
956 | /* File operations helpers (drm_fops.c) */ | | 953 | /* File operations helpers (drm_fops.c) */ |
957 | #if defined(__FreeBSD__) | | 954 | #if defined(__FreeBSD__) |
958 | extern int drm_open_helper(struct cdev *kdev, int flags, int fmt, | | 955 | extern int drm_open_helper(struct cdev *kdev, int flags, int fmt, |
959 | DRM_STRUCTPROC *p, | | 956 | DRM_STRUCTPROC *p, |
960 | struct drm_device *dev); | | 957 | struct drm_device *dev); |
961 | #elif defined(__NetBSD__) | | 958 | #elif defined(__NetBSD__) |
962 | extern struct drm_file *drm_find_file_by_proc(struct drm_device *dev, | | 959 | extern struct drm_file *drm_find_file_by_proc(struct drm_device *dev, |
963 | struct proc *p); | | 960 | struct proc *p); |
964 | extern int drm_open_helper(dev_t kdev, int flags, int fmt, | | 961 | extern int drm_open_helper(dev_t kdev, int flags, int fmt, |
965 | struct proc *p, struct drm_device *dev); | | 962 | struct proc *p, struct drm_device *dev); |
966 | #endif | | 963 | #endif |
967 | | | 964 | |
968 | /* Memory management support (drm_memory.c) */ | | 965 | /* Memory management support (drm_memory.c) */ |
969 | void drm_mem_init(void); | | 966 | void drm_mem_init(void); |
970 | void drm_mem_uninit(void); | | 967 | void drm_mem_uninit(void); |
971 | void *drm_ioremap_wc(struct drm_device *dev, drm_local_map_t *map); | | 968 | void *drm_ioremap_wc(struct drm_device *dev, drm_local_map_t *map); |
972 | void *drm_ioremap(struct drm_device *dev, drm_local_map_t *map); | | 969 | void *drm_ioremap(struct drm_device *dev, drm_local_map_t *map); |
973 | void drm_ioremapfree(drm_local_map_t *map); | | 970 | void drm_ioremapfree(drm_local_map_t *map); |
974 | #if defined(__FreeBSD__) | | 971 | #if defined(__FreeBSD__) |
975 | int drm_mtrr_add(unsigned long offset, size_t size, int flags); | | 972 | int drm_mtrr_add(unsigned long offset, size_t size, int flags); |
976 | int drm_mtrr_del(int handle, unsigned long offset, size_t size, int flags); | | 973 | int drm_mtrr_del(int handle, unsigned long offset, size_t size, int flags); |
977 | #elif defined(__NetBSD__) | | 974 | #elif defined(__NetBSD__) |
978 | int drm_mtrr_add(unsigned long offset, size_t size, int flags); | | 975 | int drm_mtrr_add(unsigned long offset, size_t size, int flags); |
979 | int drm_mtrr_del(unsigned long offset, size_t size, int flags); | | 976 | int drm_mtrr_del(unsigned long offset, size_t size, int flags); |
980 | #endif | | 977 | #endif |
981 | | | 978 | |
982 | int drm_context_switch(struct drm_device *dev, int old, int new); | | 979 | int drm_context_switch(struct drm_device *dev, int old, int new); |
983 | int drm_context_switch_complete(struct drm_device *dev, int new); | | 980 | int drm_context_switch_complete(struct drm_device *dev, int new); |
984 | | | 981 | |
985 | int drm_ctxbitmap_init(struct drm_device *dev); | | 982 | int drm_ctxbitmap_init(struct drm_device *dev); |
986 | void drm_ctxbitmap_cleanup(struct drm_device *dev); | | 983 | void drm_ctxbitmap_cleanup(struct drm_device *dev); |
987 | void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle); | | 984 | void drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle); |
988 | int drm_ctxbitmap_next(struct drm_device *dev); | | 985 | int drm_ctxbitmap_next(struct drm_device *dev); |
989 | | | 986 | |
990 | /* Locking IOCTL support (drm_lock.c) */ | | 987 | /* Locking IOCTL support (drm_lock.c) */ |
991 | int drm_lock_take(struct drm_lock_data *lock_data, | | 988 | int drm_lock_take(struct drm_lock_data *lock_data, |
992 | unsigned int context); | | 989 | unsigned int context); |
993 | int drm_lock_transfer(struct drm_lock_data *lock_data, | | 990 | int drm_lock_transfer(struct drm_lock_data *lock_data, |
994 | unsigned int context); | | 991 | unsigned int context); |
995 | int drm_lock_free(struct drm_lock_data *lock_data, | | 992 | int drm_lock_free(struct drm_lock_data *lock_data, |
996 | unsigned int context); | | 993 | unsigned int context); |
997 | | | 994 | |
998 | /* Buffer management support (drm_bufs.c) */ | | 995 | /* Buffer management support (drm_bufs.c) */ |
999 | unsigned long drm_get_resource_start(struct drm_device *dev, | | 996 | unsigned long drm_get_resource_start(struct drm_device *dev, |
1000 | unsigned int resource); | | 997 | unsigned int resource); |
1001 | unsigned long drm_get_resource_len(struct drm_device *dev, | | 998 | unsigned long drm_get_resource_len(struct drm_device *dev, |
1002 | unsigned int resource); | | 999 | unsigned int resource); |
1003 | void drm_rmmap(struct drm_device *dev, drm_local_map_t *map); | | 1000 | void drm_rmmap(struct drm_device *dev, drm_local_map_t *map); |
1004 | int drm_order(unsigned long size); | | 1001 | int drm_order(unsigned long size); |
1005 | int drm_addmap(struct drm_device *dev, unsigned long offset, | | 1002 | int drm_addmap(struct drm_device *dev, unsigned long offset, |
1006 | unsigned long size, | | 1003 | unsigned long size, |
1007 | enum drm_map_type type, enum drm_map_flags flags, | | 1004 | enum drm_map_type type, enum drm_map_flags flags, |
1008 | drm_local_map_t **map_ptr); | | 1005 | drm_local_map_t **map_ptr); |
1009 | int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc *request); | | 1006 | int drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc *request); |
1010 | int drm_addbufs_sg(struct drm_device *dev, struct drm_buf_desc *request); | | 1007 | int drm_addbufs_sg(struct drm_device *dev, struct drm_buf_desc *request); |
1011 | int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc *request); | | 1008 | int drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc *request); |
1012 | | | 1009 | |
1013 | /* DMA support (drm_dma.c) */ | | 1010 | /* DMA support (drm_dma.c) */ |
1014 | int drm_dma_setup(struct drm_device *dev); | | 1011 | int drm_dma_setup(struct drm_device *dev); |
1015 | void drm_dma_takedown(struct drm_device *dev); | | 1012 | void drm_dma_takedown(struct drm_device *dev); |
1016 | void drm_free_buffer(struct drm_device *dev, drm_buf_t *buf); | | 1013 | void drm_free_buffer(struct drm_device *dev, drm_buf_t *buf); |
1017 | void drm_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv); | | 1014 | void drm_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv); |
1018 | #define drm_core_reclaim_buffers drm_reclaim_buffers | | 1015 | #define drm_core_reclaim_buffers drm_reclaim_buffers |
1019 | | | 1016 | |
1020 | /* IRQ support (drm_irq.c) */ | | 1017 | /* IRQ support (drm_irq.c) */ |
1021 | int drm_irq_install(struct drm_device *dev); | | 1018 | int drm_irq_install(struct drm_device *dev); |
1022 | int drm_irq_uninstall(struct drm_device *dev); | | 1019 | int drm_irq_uninstall(struct drm_device *dev); |
1023 | irqreturn_t drm_irq_handler(DRM_IRQ_ARGS); | | 1020 | irqreturn_t drm_irq_handler(DRM_IRQ_ARGS); |
1024 | void drm_driver_irq_preinstall(struct drm_device *dev); | | 1021 | void drm_driver_irq_preinstall(struct drm_device *dev); |
1025 | void drm_driver_irq_postinstall(struct drm_device *dev); | | 1022 | void drm_driver_irq_postinstall(struct drm_device *dev); |
1026 | void drm_driver_irq_uninstall(struct drm_device *dev); | | 1023 | void drm_driver_irq_uninstall(struct drm_device *dev); |
1027 | void drm_handle_vblank(struct drm_device *dev, int crtc); | | 1024 | void drm_handle_vblank(struct drm_device *dev, int crtc); |
1028 | u32 drm_vblank_count(struct drm_device *dev, int crtc); | | 1025 | u32 drm_vblank_count(struct drm_device *dev, int crtc); |
1029 | int drm_vblank_get(struct drm_device *dev, int crtc); | | 1026 | int drm_vblank_get(struct drm_device *dev, int crtc); |
1030 | void drm_vblank_put(struct drm_device *dev, int crtc); | | 1027 | void drm_vblank_put(struct drm_device *dev, int crtc); |
1031 | void drm_vblank_cleanup(struct drm_device *dev); | | 1028 | void drm_vblank_cleanup(struct drm_device *dev); |
1032 | int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq); | | 1029 | int drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq); |
1033 | int drm_vblank_init(struct drm_device *dev, int num_crtcs); | | 1030 | int drm_vblank_init(struct drm_device *dev, int num_crtcs); |
1034 | void drm_vbl_send_signals(struct drm_device *dev, int crtc); | | 1031 | void drm_vbl_send_signals(struct drm_device *dev, int crtc); |
1035 | int drm_modeset_ctl(struct drm_device *dev, void *data, | | 1032 | int drm_modeset_ctl(struct drm_device *dev, void *data, |
1036 | struct drm_file *file_priv); | | 1033 | struct drm_file *file_priv); |
1037 | | | 1034 | |
1038 | /* AGP/PCI Express/GART support (drm_agpsupport.c) */ | | 1035 | /* AGP/PCI Express/GART support (drm_agpsupport.c) */ |
1039 | int drm_device_is_agp(struct drm_device *dev); | | 1036 | int drm_device_is_agp(struct drm_device *dev); |
1040 | int drm_device_is_pcie(struct drm_device *dev); | | 1037 | int drm_device_is_pcie(struct drm_device *dev); |
1041 | drm_agp_head_t *drm_agp_init(struct drm_device *dev); | | 1038 | drm_agp_head_t *drm_agp_init(struct drm_device *dev); |
1042 | int drm_agp_acquire(struct drm_device *dev); | | 1039 | int drm_agp_acquire(struct drm_device *dev); |
1043 | int drm_agp_release(struct drm_device *dev); | | 1040 | int drm_agp_release(struct drm_device *dev); |
1044 | int drm_agp_info(struct drm_device * dev, struct drm_agp_info *info); | | 1041 | int drm_agp_info(struct drm_device * dev, struct drm_agp_info *info); |
1045 | int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode); | | 1042 | int drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode); |
1046 | void *drm_agp_allocate_memory(size_t pages, u32 type); | | 1043 | void *drm_agp_allocate_memory(size_t pages, u32 type); |
1047 | int drm_agp_free_memory(void *handle); | | 1044 | int drm_agp_free_memory(void *handle); |
1048 | int drm_agp_bind_memory(void *handle, off_t start); | | 1045 | int drm_agp_bind_memory(void *handle, off_t start); |
1049 | int drm_agp_unbind_memory(void *handle); | | 1046 | int drm_agp_unbind_memory(void *handle); |
1050 | int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request); | | 1047 | int drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request); |
1051 | int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); | | 1048 | int drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request); |
1052 | int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); | | 1049 | int drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request); |
1053 | int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); | | 1050 | int drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request); |
1054 | | | 1051 | |
1055 | /* Scatter Gather Support (drm_scatter.c) */ | | 1052 | /* Scatter Gather Support (drm_scatter.c) */ |
1056 | void drm_sg_cleanup(drm_sg_mem_t *entry); | | 1053 | void drm_sg_cleanup(drm_sg_mem_t *entry); |
1057 | int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request); | | 1054 | int drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request); |
1058 | | | 1055 | |
1059 | /* sysctl support (drm_sysctl.h) */ | | 1056 | /* sysctl support (drm_sysctl.h) */ |
1060 | extern int drm_sysctl_init(struct drm_device *dev); | | 1057 | extern int drm_sysctl_init(struct drm_device *dev); |
1061 | extern int drm_sysctl_cleanup(struct drm_device *dev); | | 1058 | extern int drm_sysctl_cleanup(struct drm_device *dev); |
1062 | | | 1059 | |
1063 | /* ATI PCIGART support (ati_pcigart.c) */ | | 1060 | /* ATI PCIGART support (ati_pcigart.c) */ |
1064 | int drm_ati_pcigart_init(struct drm_device *dev, | | 1061 | int drm_ati_pcigart_init(struct drm_device *dev, |
1065 | struct drm_ati_pcigart_info *gart_info); | | 1062 | struct drm_ati_pcigart_info *gart_info); |
1066 | int drm_ati_pcigart_cleanup(struct drm_device *dev, | | 1063 | int drm_ati_pcigart_cleanup(struct drm_device *dev, |
1067 | struct drm_ati_pcigart_info *gart_info); | | 1064 | struct drm_ati_pcigart_info *gart_info); |
1068 | | | 1065 | |
1069 | /* Locking IOCTL support (drm_drv.c) */ | | 1066 | /* Locking IOCTL support (drm_drv.c) */ |
1070 | int drm_lock(struct drm_device *dev, void *data, | | 1067 | int drm_lock(struct drm_device *dev, void *data, |
1071 | struct drm_file *file_priv); | | 1068 | struct drm_file *file_priv); |
1072 | int drm_unlock(struct drm_device *dev, void *data, | | 1069 | int drm_unlock(struct drm_device *dev, void *data, |
1073 | struct drm_file *file_priv); | | 1070 | struct drm_file *file_priv); |
1074 | int drm_version(struct drm_device *dev, void *data, | | 1071 | int drm_version(struct drm_device *dev, void *data, |
1075 | struct drm_file *file_priv); | | 1072 | struct drm_file *file_priv); |
1076 | int drm_setversion(struct drm_device *dev, void *data, | | 1073 | int drm_setversion(struct drm_device *dev, void *data, |
1077 | struct drm_file *file_priv); | | 1074 | struct drm_file *file_priv); |
1078 | | | 1075 | |
1079 | /* Misc. IOCTL support (drm_ioctl.c) */ | | 1076 | /* Misc. IOCTL support (drm_ioctl.c) */ |
1080 | int drm_irq_by_busid(struct drm_device *dev, void *data, | | 1077 | int drm_irq_by_busid(struct drm_device *dev, void *data, |
1081 | struct drm_file *file_priv); | | 1078 | struct drm_file *file_priv); |
1082 | int drm_getunique(struct drm_device *dev, void *data, | | 1079 | int drm_getunique(struct drm_device *dev, void *data, |
1083 | struct drm_file *file_priv); | | 1080 | struct drm_file *file_priv); |
1084 | int drm_setunique(struct drm_device *dev, void *data, | | 1081 | int drm_setunique(struct drm_device *dev, void *data, |
1085 | struct drm_file *file_priv); | | 1082 | struct drm_file *file_priv); |
1086 | int drm_getmap(struct drm_device *dev, void *data, | | 1083 | int drm_getmap(struct drm_device *dev, void *data, |
1087 | struct drm_file *file_priv); | | 1084 | struct drm_file *file_priv); |
1088 | int drm_getclient(struct drm_device *dev, void *data, | | 1085 | int drm_getclient(struct drm_device *dev, void *data, |
1089 | struct drm_file *file_priv); | | 1086 | struct drm_file *file_priv); |
1090 | int drm_getstats(struct drm_device *dev, void *data, | | 1087 | int drm_getstats(struct drm_device *dev, void *data, |
1091 | struct drm_file *file_priv); | | 1088 | struct drm_file *file_priv); |
1092 | int drm_noop(struct drm_device *dev, void *data, | | 1089 | int drm_noop(struct drm_device *dev, void *data, |
1093 | struct drm_file *file_priv); | | 1090 | struct drm_file *file_priv); |
1094 | | | 1091 | |
1095 | /* Context IOCTL support (drm_context.c) */ | | 1092 | /* Context IOCTL support (drm_context.c) */ |
1096 | int drm_resctx(struct drm_device *dev, void *data, | | 1093 | int drm_resctx(struct drm_device *dev, void *data, |
1097 | struct drm_file *file_priv); | | 1094 | struct drm_file *file_priv); |
1098 | int drm_addctx(struct drm_device *dev, void *data, | | 1095 | int drm_addctx(struct drm_device *dev, void *data, |
1099 | struct drm_file *file_priv); | | 1096 | struct drm_file *file_priv); |
1100 | int drm_modctx(struct drm_device *dev, void *data, | | 1097 | int drm_modctx(struct drm_device *dev, void *data, |
1101 | struct drm_file *file_priv); | | 1098 | struct drm_file *file_priv); |
1102 | int drm_getctx(struct drm_device *dev, void *data, | | 1099 | int drm_getctx(struct drm_device *dev, void *data, |
1103 | struct drm_file *file_priv); | | 1100 | struct drm_file *file_priv); |
1104 | int drm_switchctx(struct drm_device *dev, void *data, | | 1101 | int drm_switchctx(struct drm_device *dev, void *data, |
1105 | struct drm_file *file_priv); | | 1102 | struct drm_file *file_priv); |
1106 | int drm_newctx(struct drm_device *dev, void *data, | | 1103 | int drm_newctx(struct drm_device *dev, void *data, |
1107 | struct drm_file *file_priv); | | 1104 | struct drm_file *file_priv); |
1108 | int drm_rmctx(struct drm_device *dev, void *data, | | 1105 | int drm_rmctx(struct drm_device *dev, void *data, |
1109 | struct drm_file *file_priv); | | 1106 | struct drm_file *file_priv); |
1110 | int drm_setsareactx(struct drm_device *dev, void *data, | | 1107 | int drm_setsareactx(struct drm_device *dev, void *data, |
1111 | struct drm_file *file_priv); | | 1108 | struct drm_file *file_priv); |
1112 | int drm_getsareactx(struct drm_device *dev, void *data, | | 1109 | int drm_getsareactx(struct drm_device *dev, void *data, |
1113 | struct drm_file *file_priv); | | 1110 | struct drm_file *file_priv); |
1114 | | | 1111 | |
1115 | /* Drawable IOCTL support (drm_drawable.c) */ | | 1112 | /* Drawable IOCTL support (drm_drawable.c) */ |
1116 | int drm_adddraw(struct drm_device *dev, void *data, | | 1113 | int drm_adddraw(struct drm_device *dev, void *data, |
1117 | struct drm_file *file_priv); | | 1114 | struct drm_file *file_priv); |
1118 | int drm_rmdraw(struct drm_device *dev, void *data, | | 1115 | int drm_rmdraw(struct drm_device *dev, void *data, |
1119 | struct drm_file *file_priv); | | 1116 | struct drm_file *file_priv); |
1120 | int drm_update_draw(struct drm_device *dev, void *data, | | 1117 | int drm_update_draw(struct drm_device *dev, void *data, |
1121 | struct drm_file *file_priv); | | 1118 | struct drm_file *file_priv); |
1122 | struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev, | | 1119 | struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev, |
1123 | int handle); | | 1120 | int handle); |
1124 | | | 1121 | |
1125 | /* Drawable support (drm_drawable.c) */ | | 1122 | /* Drawable support (drm_drawable.c) */ |
1126 | void drm_drawable_free_all(struct drm_device *dev); | | 1123 | void drm_drawable_free_all(struct drm_device *dev); |
1127 | | | 1124 | |
1128 | /* Authentication IOCTL support (drm_auth.c) */ | | 1125 | /* Authentication IOCTL support (drm_auth.c) */ |
1129 | int drm_getmagic(struct drm_device *dev, void *data, | | 1126 | int drm_getmagic(struct drm_device *dev, void *data, |
1130 | struct drm_file *file_priv); | | 1127 | struct drm_file *file_priv); |
1131 | int drm_authmagic(struct drm_device *dev, void *data, | | 1128 | int drm_authmagic(struct drm_device *dev, void *data, |
1132 | struct drm_file *file_priv); | | 1129 | struct drm_file *file_priv); |
1133 | | | 1130 | |
1134 | /* Buffer management support (drm_bufs.c) */ | | 1131 | /* Buffer management support (drm_bufs.c) */ |
1135 | int drm_addmap_ioctl(struct drm_device *dev, void *data, | | 1132 | int drm_addmap_ioctl(struct drm_device *dev, void *data, |
1136 | struct drm_file *file_priv); | | 1133 | struct drm_file *file_priv); |
1137 | int drm_rmmap_ioctl(struct drm_device *dev, void *data, | | 1134 | int drm_rmmap_ioctl(struct drm_device *dev, void *data, |
1138 | struct drm_file *file_priv); | | 1135 | struct drm_file *file_priv); |
1139 | int drm_addbufs(struct drm_device *dev, void *data, | | 1136 | int drm_addbufs(struct drm_device *dev, void *data, |
1140 | struct drm_file *file_priv); | | 1137 | struct drm_file *file_priv); |
1141 | int drm_infobufs(struct drm_device *dev, void *data, | | 1138 | int drm_infobufs(struct drm_device *dev, void *data, |
1142 | struct drm_file *file_priv); | | 1139 | struct drm_file *file_priv); |
1143 | int drm_markbufs(struct drm_device *dev, void *data, | | 1140 | int drm_markbufs(struct drm_device *dev, void *data, |
1144 | struct drm_file *file_priv); | | 1141 | struct drm_file *file_priv); |
1145 | int drm_freebufs(struct drm_device *dev, void *data, | | 1142 | int drm_freebufs(struct drm_device *dev, void *data, |
1146 | struct drm_file *file_priv); | | 1143 | struct drm_file *file_priv); |
1147 | int drm_mapbufs(struct drm_device *dev, void *data, | | 1144 | int drm_mapbufs(struct drm_device *dev, void *data, |
1148 | struct drm_file *file_priv); | | 1145 | struct drm_file *file_priv); |
1149 | | | 1146 | |
1150 | /* DMA support (drm_dma.c) */ | | 1147 | /* DMA support (drm_dma.c) */ |
1151 | int drm_dma(struct drm_device *dev, void *data, struct drm_file *file_priv); | | 1148 | int drm_dma(struct drm_device *dev, void *data, struct drm_file *file_priv); |
1152 | | | 1149 | |
1153 | /* IRQ support (drm_irq.c) */ | | 1150 | /* IRQ support (drm_irq.c) */ |
1154 | int drm_control(struct drm_device *dev, void *data, | | 1151 | int drm_control(struct drm_device *dev, void *data, |
1155 | struct drm_file *file_priv); | | 1152 | struct drm_file *file_priv); |
1156 | int drm_wait_vblank(struct drm_device *dev, void *data, | | 1153 | int drm_wait_vblank(struct drm_device *dev, void *data, |
1157 | struct drm_file *file_priv); | | 1154 | struct drm_file *file_priv); |
1158 | | | 1155 | |
1159 | /* AGP/GART support (drm_agpsupport.c) */ | | 1156 | /* AGP/GART support (drm_agpsupport.c) */ |
1160 | int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, | | 1157 | int drm_agp_acquire_ioctl(struct drm_device *dev, void *data, |
1161 | struct drm_file *file_priv); | | 1158 | struct drm_file *file_priv); |
1162 | int drm_agp_release_ioctl(struct drm_device *dev, void *data, | | 1159 | int drm_agp_release_ioctl(struct drm_device *dev, void *data, |
1163 | struct drm_file *file_priv); | | 1160 | struct drm_file *file_priv); |
1164 | int drm_agp_enable_ioctl(struct drm_device *dev, void *data, | | 1161 | int drm_agp_enable_ioctl(struct drm_device *dev, void *data, |
1165 | struct drm_file *file_priv); | | 1162 | struct drm_file *file_priv); |
1166 | int drm_agp_info_ioctl(struct drm_device *dev, void *data, | | 1163 | int drm_agp_info_ioctl(struct drm_device *dev, void *data, |
1167 | struct drm_file *file_priv); | | 1164 | struct drm_file *file_priv); |
1168 | int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, | | 1165 | int drm_agp_alloc_ioctl(struct drm_device *dev, void *data, |
1169 | struct drm_file *file_priv); | | 1166 | struct drm_file *file_priv); |
1170 | int drm_agp_free_ioctl(struct drm_device *dev, void *data, | | 1167 | int drm_agp_free_ioctl(struct drm_device *dev, void *data, |
1171 | struct drm_file *file_priv); | | 1168 | struct drm_file *file_priv); |
1172 | int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, | | 1169 | int drm_agp_unbind_ioctl(struct drm_device *dev, void *data, |
1173 | struct drm_file *file_priv); | | 1170 | struct drm_file *file_priv); |
1174 | int drm_agp_bind_ioctl(struct drm_device *dev, void *data, | | 1171 | int drm_agp_bind_ioctl(struct drm_device *dev, void *data, |
1175 | struct drm_file *file_priv); | | 1172 | struct drm_file *file_priv); |
1176 | | | 1173 | |
1177 | /* Scatter Gather Support (drm_scatter.c) */ | | 1174 | /* Scatter Gather Support (drm_scatter.c) */ |
1178 | int drm_sg_alloc_ioctl(struct drm_device *dev, void *data, | | 1175 | int drm_sg_alloc_ioctl(struct drm_device *dev, void *data, |
1179 | struct drm_file *file_priv); | | 1176 | struct drm_file *file_priv); |
1180 | int drm_sg_free(struct drm_device *dev, void *data, | | 1177 | int drm_sg_free(struct drm_device *dev, void *data, |
1181 | struct drm_file *file_priv); | | 1178 | struct drm_file *file_priv); |
1182 | | | 1179 | |
1183 | /* consistent PCI memory functions (drm_pci.c) */ | | 1180 | /* consistent PCI memory functions (drm_pci.c) */ |
1184 | drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size, | | 1181 | drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size, |
1185 | size_t align, dma_addr_t maxaddr); | | 1182 | size_t align, dma_addr_t maxaddr); |
1186 | void drm_pci_free(struct drm_device *dev, drm_dma_handle_t *dmah); | | 1183 | void drm_pci_free(struct drm_device *dev, drm_dma_handle_t *dmah); |
1187 | | | 1184 | |
1188 | /* Inline replacements for drm_alloc and friends */ | | 1185 | /* Inline replacements for drm_alloc and friends */ |
1189 | static __inline__ void * | | 1186 | static __inline__ void * |
1190 | drm_alloc(size_t size, struct malloc_type *area) | | 1187 | drm_alloc(size_t size, struct malloc_type *area) |
1191 | { | | 1188 | { |
1192 | return malloc(size, area, M_NOWAIT); | | 1189 | return malloc(size, area, M_NOWAIT); |
1193 | } | | 1190 | } |
1194 | | | 1191 | |
1195 | static __inline__ void * | | 1192 | static __inline__ void * |
1196 | drm_calloc(size_t nmemb, size_t size, struct malloc_type *area) | | 1193 | drm_calloc(size_t nmemb, size_t size, struct malloc_type *area) |
1197 | { | | 1194 | { |
1198 | return malloc(size * nmemb, area, M_NOWAIT | M_ZERO); | | 1195 | return malloc(size * nmemb, area, M_NOWAIT | M_ZERO); |
1199 | } | | 1196 | } |
1200 | | | 1197 | |
1201 | static __inline__ void * | | 1198 | static __inline__ void * |
1202 | drm_realloc(void *oldpt, size_t oldsize, size_t size, | | 1199 | drm_realloc(void *oldpt, size_t oldsize, size_t size, |
1203 | struct malloc_type *area) | | 1200 | struct malloc_type *area) |
1204 | { | | 1201 | { |
1205 | #if defined(__FreeBSD__) | | 1202 | #if defined(__FreeBSD__) |
1206 | return reallocf(oldpt, size, area, M_NOWAIT); | | 1203 | return reallocf(oldpt, size, area, M_NOWAIT); |
1207 | #elif defined(__NetBSD__) | | 1204 | #elif defined(__NetBSD__) |
1208 | void *pt; | | 1205 | void *pt; |
1209 | | | 1206 | |
1210 | pt = malloc(size, area, M_NOWAIT); | | 1207 | pt = malloc(size, area, M_NOWAIT); |
1211 | if (pt == NULL) | | 1208 | if (pt == NULL) |
1212 | return NULL; | | 1209 | return NULL; |
1213 | if (oldpt && oldsize) { | | 1210 | if (oldpt && oldsize) { |
1214 | memcpy(pt, oldpt, oldsize); | | 1211 | memcpy(pt, oldpt, oldsize); |
1215 | free(oldpt, area); | | 1212 | free(oldpt, area); |
1216 | } | | 1213 | } |
1217 | return pt; | | 1214 | return pt; |
1218 | #endif | | 1215 | #endif |
1219 | } | | 1216 | } |
1220 | | | 1217 | |
1221 | static __inline__ void | | 1218 | static __inline__ void |
1222 | drm_free(void *pt, size_t size, struct malloc_type *area) | | 1219 | drm_free(void *pt, size_t size, struct malloc_type *area) |
1223 | { | | 1220 | { |
1224 | free(pt, area); | | 1221 | free(pt, area); |
1225 | } | | 1222 | } |
1226 | | | 1223 | |
1227 | /* Inline replacements for DRM_IOREMAP macros */ | | 1224 | /* Inline replacements for DRM_IOREMAP macros */ |
1228 | static __inline__ void | | 1225 | static __inline__ void |
1229 | drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev) | | 1226 | drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev) |
1230 | { | | 1227 | { |
1231 | map->handle = drm_ioremap_wc(dev, map); | | 1228 | map->handle = drm_ioremap_wc(dev, map); |
1232 | } | | 1229 | } |
1233 | static __inline__ void | | 1230 | static __inline__ void |
1234 | drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev) | | 1231 | drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev) |
1235 | { | | 1232 | { |
1236 | map->handle = drm_ioremap(dev, map); | | 1233 | map->handle = drm_ioremap(dev, map); |
1237 | } | | 1234 | } |
1238 | static __inline__ void | | 1235 | static __inline__ void |
1239 | drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev) | | 1236 | drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev) |
1240 | { | | 1237 | { |
1241 | if ( map->handle && map->size ) | | 1238 | if ( map->handle && map->size ) |
1242 | drm_ioremapfree(map); | | 1239 | drm_ioremapfree(map); |
1243 | } | | 1240 | } |
1244 | | | 1241 | |
1245 | static __inline__ struct drm_local_map * | | 1242 | static __inline__ struct drm_local_map * |
1246 | drm_core_findmap(struct drm_device *dev, unsigned long offset) | | 1243 | drm_core_findmap(struct drm_device *dev, unsigned long offset) |
1247 | { | | 1244 | { |
1248 | drm_local_map_t *map; | | 1245 | drm_local_map_t *map; |
1249 | | | 1246 | |
1250 | DRM_SPINLOCK_ASSERT(&dev->dev_lock); | | 1247 | DRM_SPINLOCK_ASSERT(&dev->dev_lock); |
1251 | TAILQ_FOREACH(map, &dev->maplist, link) { | | 1248 | TAILQ_FOREACH(map, &dev->maplist, link) { |
1252 | if (map->offset == offset) | | 1249 | if (map->offset == offset) |
1253 | return map; | | 1250 | return map; |
1254 | } | | 1251 | } |
1255 | return NULL; | | 1252 | return NULL; |
1256 | } | | 1253 | } |
1257 | | | 1254 | |
1258 | static __inline__ void drm_core_dropmap(struct drm_map *map) | | 1255 | static __inline__ void drm_core_dropmap(struct drm_map *map) |
1259 | { | | 1256 | { |
1260 | } | | 1257 | } |
1261 | | | 1258 | |
1262 | #endif /* __KERNEL__ */ | | 1259 | #endif /* __KERNEL__ */ |
1263 | #endif /* _DRM_P_H_ */ | | 1260 | #endif /* _DRM_P_H_ */ |