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