drmP.h revision 190399
1174604Sscottl/* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
2174604Sscottl * Created: Mon Jan  4 10:05:05 1999 by faith@precisioninsight.com
3174604Sscottl */
4174604Sscottl/*-
5174604Sscottl * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
6174604Sscottl * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
7174604Sscottl * All rights reserved.
8174604Sscottl *
9174604Sscottl * Permission is hereby granted, free of charge, to any person obtaining a
10174604Sscottl * copy of this software and associated documentation files (the "Software"),
11174604Sscottl * to deal in the Software without restriction, including without limitation
12174604Sscottl * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13174604Sscottl * and/or sell copies of the Software, and to permit persons to whom the
14174604Sscottl * Software is furnished to do so, subject to the following conditions:
15174604Sscottl *
16174604Sscottl * The above copyright notice and this permission notice (including the next
17174604Sscottl * paragraph) shall be included in all copies or substantial portions of the
18174604Sscottl * Software.
19174604Sscottl *
20174604Sscottl * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21174604Sscottl * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22174604Sscottl * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
23174604Sscottl * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
24174604Sscottl * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
25174604Sscottl * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
26174604Sscottl * OTHER DEALINGS IN THE SOFTWARE.
27174604Sscottl *
28174604Sscottl * Authors:
29174604Sscottl *    Rickard E. (Rik) Faith <faith@valinux.com>
30174604Sscottl *    Gareth Hughes <gareth@valinux.com>
31174604Sscottl *
32174604Sscottl */
33174604Sscottl
34174604Sscottl#include <sys/cdefs.h>
35174604Sscottl__FBSDID("$FreeBSD: head/sys/dev/drm/drmP.h 190399 2009-03-25 01:41:56Z rnoland $");
36174604Sscottl
37174604Sscottl#ifndef _DRM_P_H_
38174604Sscottl#define _DRM_P_H_
39174604Sscottl
40174604Sscottl#if defined(_KERNEL) || defined(__KERNEL__)
41174604Sscottl
42174604Sscottlstruct drm_device;
43174604Sscottlstruct drm_file;
44174604Sscottl
45174604Sscottl#include <sys/param.h>
46174604Sscottl#include <sys/queue.h>
47174604Sscottl#include <sys/malloc.h>
48174604Sscottl#include <sys/kernel.h>
49174604Sscottl#include <sys/module.h>
50174604Sscottl#include <sys/systm.h>
51174604Sscottl#include <sys/conf.h>
52174604Sscottl#include <sys/stat.h>
53174604Sscottl#if __FreeBSD_version >= 700000
54174604Sscottl#include <sys/priv.h>
55174604Sscottl#endif
56174604Sscottl#include <sys/proc.h>
57174604Sscottl#include <sys/lock.h>
58174604Sscottl#include <sys/fcntl.h>
59174604Sscottl#include <sys/uio.h>
60174604Sscottl#include <sys/filio.h>
61174604Sscottl#include <sys/sysctl.h>
62174604Sscottl#include <sys/bus.h>
63174604Sscottl#include <sys/signalvar.h>
64174604Sscottl#include <sys/poll.h>
65174604Sscottl#include <sys/tree.h>
66174604Sscottl#include <vm/vm.h>
67174604Sscottl#include <vm/pmap.h>
68174604Sscottl#include <vm/vm_extern.h>
69174604Sscottl#include <vm/vm_map.h>
70174604Sscottl#include <vm/vm_param.h>
71174604Sscottl#include <machine/param.h>
72174604Sscottl#include <machine/pmap.h>
73174604Sscottl#include <machine/bus.h>
74174604Sscottl#include <machine/resource.h>
75174604Sscottl#include <machine/specialreg.h>
76174604Sscottl#include <machine/sysarch.h>
77174604Sscottl#include <sys/endian.h>
78174604Sscottl#include <sys/mman.h>
79174604Sscottl#include <sys/rman.h>
80174604Sscottl#include <sys/memrange.h>
81174604Sscottl#if __FreeBSD_version >= 800004
82174604Sscottl#include <dev/agp/agpvar.h>
83174604Sscottl#else /* __FreeBSD_version >= 800004 */
84174604Sscottl#include <pci/agpvar.h>
85174604Sscottl#endif /* __FreeBSD_version >= 800004 */
86174604Sscottl#include <sys/agpio.h>
87174604Sscottl#include <sys/mutex.h>
88174604Sscottl#include <dev/pci/pcivar.h>
89174604Sscottl#include <dev/pci/pcireg.h>
90174604Sscottl#include <sys/selinfo.h>
91174604Sscottl#include <sys/bus.h>
92174604Sscottl
93174604Sscottl#include "dev/drm/drm.h"
94174604Sscottl#include "dev/drm/drm_linux_list.h"
95174604Sscottl#include "dev/drm/drm_atomic.h"
96174604Sscottl#include "dev/drm/drm_internal.h"
97174604Sscottl
98174604Sscottl#include <opt_drm.h>
99174604Sscottl#ifdef DRM_DEBUG
100174604Sscottl#undef DRM_DEBUG
101174604Sscottl#define DRM_DEBUG_DEFAULT_ON 1
102174604Sscottl#endif /* DRM_DEBUG */
103174604Sscottl
104174604Sscottl#if defined(DRM_LINUX) && DRM_LINUX && !defined(__amd64__)
105174604Sscottl#include <sys/file.h>
106174604Sscottl#include <sys/proc.h>
107174604Sscottl#include <machine/../linux/linux.h>
108174604Sscottl#include <machine/../linux/linux_proto.h>
109174604Sscottl#else
110174604Sscottl/* Either it was defined when it shouldn't be (FreeBSD amd64) or it isn't
111174604Sscottl * supported on this OS yet.
112174604Sscottl */
113174604Sscottl#undef DRM_LINUX
114174604Sscottl#define DRM_LINUX 0
115174604Sscottl#endif
116174604Sscottl
117174604Sscottl/* driver capabilities and requirements mask */
118174604Sscottl#define DRIVER_USE_AGP     0x1
119174604Sscottl#define DRIVER_REQUIRE_AGP 0x2
120174604Sscottl#define DRIVER_USE_MTRR    0x4
121174604Sscottl#define DRIVER_PCI_DMA     0x8
122174604Sscottl#define DRIVER_SG          0x10
123174604Sscottl#define DRIVER_HAVE_DMA    0x20
124174604Sscottl#define DRIVER_HAVE_IRQ    0x40
125174604Sscottl#define DRIVER_DMA_QUEUE   0x100
126174604Sscottl
127174604Sscottl
128174604Sscottl#define DRM_HASH_SIZE	      16 /* Size of key hash table		  */
129174604Sscottl#define DRM_KERNEL_CONTEXT    0	 /* Change drm_resctx if changed	  */
130174604Sscottl#define DRM_RESERVED_CONTEXTS 1	 /* Change drm_resctx if changed	  */
131174604Sscottl
132174604SscottlMALLOC_DECLARE(DRM_MEM_DMA);
133174604SscottlMALLOC_DECLARE(DRM_MEM_SAREA);
134174604SscottlMALLOC_DECLARE(DRM_MEM_DRIVER);
135176939SscottlMALLOC_DECLARE(DRM_MEM_MAGIC);
136174604SscottlMALLOC_DECLARE(DRM_MEM_IOCTLS);
137174604SscottlMALLOC_DECLARE(DRM_MEM_MAPS);
138174604SscottlMALLOC_DECLARE(DRM_MEM_BUFS);
139174604SscottlMALLOC_DECLARE(DRM_MEM_SEGS);
140174604SscottlMALLOC_DECLARE(DRM_MEM_PAGES);
141174604SscottlMALLOC_DECLARE(DRM_MEM_FILES);
142174604SscottlMALLOC_DECLARE(DRM_MEM_QUEUES);
143174604SscottlMALLOC_DECLARE(DRM_MEM_CMDS);
144174604SscottlMALLOC_DECLARE(DRM_MEM_MAPPINGS);
145174604SscottlMALLOC_DECLARE(DRM_MEM_BUFLISTS);
146174604SscottlMALLOC_DECLARE(DRM_MEM_AGPLISTS);
147174604SscottlMALLOC_DECLARE(DRM_MEM_CTXBITMAP);
148174604SscottlMALLOC_DECLARE(DRM_MEM_SGLISTS);
149174604SscottlMALLOC_DECLARE(DRM_MEM_DRAWABLE);
150174604Sscottl
151174604Sscottl#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
152174604Sscottl
153174604Sscottl				/* Internal types and structures */
154174604Sscottl#define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
155174604Sscottl#define DRM_MIN(a,b) ((a)<(b)?(a):(b))
156174604Sscottl#define DRM_MAX(a,b) ((a)>(b)?(a):(b))
157174604Sscottl
158174604Sscottl#define DRM_IF_VERSION(maj, min) (maj << 16 | min)
159174604Sscottl
160174604Sscottl#define __OS_HAS_AGP	1
161174604Sscottl
162174604Sscottl#define DRM_DEV_MODE	(S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
163174604Sscottl#define DRM_DEV_UID	0
164174604Sscottl#define DRM_DEV_GID	0
165174604Sscottl
166174604Sscottl#define wait_queue_head_t	atomic_t
167174604Sscottl#define DRM_WAKEUP(w)		wakeup((void *)w)
168174604Sscottl#define DRM_WAKEUP_INT(w)	wakeup(w)
169174604Sscottl#define DRM_INIT_WAITQUEUE(queue) do {(void)(queue);} while (0)
170174604Sscottl
171174604Sscottl#define DRM_CURPROC		curthread
172174604Sscottl#define DRM_STRUCTPROC		struct thread
173174604Sscottl#define DRM_SPINTYPE		struct mtx
174174604Sscottl#define DRM_SPININIT(l,name)	mtx_init(l, name, NULL, MTX_DEF)
175176939Sscottl#define DRM_SPINUNINIT(l)	mtx_destroy(l)
176174604Sscottl#define DRM_SPINLOCK(l)		mtx_lock(l)
177174604Sscottl#define DRM_SPINUNLOCK(u)	mtx_unlock(u)
178174604Sscottl#define DRM_SPINLOCK_IRQSAVE(l, irqflags) do {		\
179174604Sscottl	mtx_lock(l);					\
180174604Sscottl	(void)irqflags;					\
181174604Sscottl} while (0)
182174604Sscottl#define DRM_SPINUNLOCK_IRQRESTORE(u, irqflags) mtx_unlock(u)
183174604Sscottl#define DRM_SPINLOCK_ASSERT(l)	mtx_assert(l, MA_OWNED)
184174604Sscottl#define DRM_CURRENTPID		curthread->td_proc->p_pid
185174604Sscottl#define DRM_LOCK()		mtx_lock(&dev->dev_lock)
186174604Sscottl#define DRM_UNLOCK() 		mtx_unlock(&dev->dev_lock)
187174604Sscottl#define DRM_SYSCTL_HANDLER_ARGS	(SYSCTL_HANDLER_ARGS)
188174604Sscottl
189174604Sscottl#define DRM_IRQ_ARGS		void *arg
190174604Sscottltypedef void			irqreturn_t;
191174604Sscottl#define IRQ_HANDLED		/* nothing */
192174604Sscottl#define IRQ_NONE		/* nothing */
193174604Sscottl
194174604Sscottlenum {
195174604Sscottl	DRM_IS_NOT_AGP,
196174604Sscottl	DRM_IS_AGP,
197174604Sscottl	DRM_MIGHT_BE_AGP
198174604Sscottl};
199174604Sscottl#define DRM_AGP_MEM		struct agp_memory_info
200174604Sscottl
201174604Sscottl#define drm_get_device_from_kdev(_kdev) (_kdev->si_drv1)
202174604Sscottl
203174604Sscottl#define PAGE_ALIGN(addr) round_page(addr)
204174604Sscottl/* DRM_SUSER returns true if the user is superuser */
205174604Sscottl#if __FreeBSD_version >= 700000
206174604Sscottl#define DRM_SUSER(p)		(priv_check(p, PRIV_DRIVER) == 0)
207174604Sscottl#else
208174604Sscottl#define DRM_SUSER(p)		(suser(p) == 0)
209174604Sscottl#endif
210174604Sscottl#define DRM_AGP_FIND_DEVICE()	agp_find_device()
211174604Sscottl#define DRM_MTRR_WC		MDF_WRITECOMBINE
212174604Sscottl#define jiffies			ticks
213174604Sscottl
214174604Sscottltypedef unsigned long dma_addr_t;
215174604Sscottltypedef u_int64_t u64;
216174604Sscottltypedef u_int32_t u32;
217174604Sscottltypedef u_int16_t u16;
218174604Sscottltypedef u_int8_t u8;
219174604Sscottl
220174604Sscottl/* DRM_READMEMORYBARRIER() prevents reordering of reads.
221174604Sscottl * DRM_WRITEMEMORYBARRIER() prevents reordering of writes.
222174604Sscottl * DRM_MEMORYBARRIER() prevents reordering of reads and writes.
223269615Sjhb */
224269615Sjhb#if defined(__i386__)
225269615Sjhb#define DRM_READMEMORYBARRIER()		__asm __volatile( \
226174604Sscottl					"lock; addl $0,0(%%esp)" : : : "memory");
227174604Sscottl#define DRM_WRITEMEMORYBARRIER()	__asm __volatile("" : : : "memory");
228174604Sscottl#define DRM_MEMORYBARRIER()		__asm __volatile( \
229174604Sscottl					"lock; addl $0,0(%%esp)" : : : "memory");
230174604Sscottl#elif defined(__alpha__)
231174604Sscottl#define DRM_READMEMORYBARRIER()		alpha_mb();
232174604Sscottl#define DRM_WRITEMEMORYBARRIER()	alpha_wmb();
233174604Sscottl#define DRM_MEMORYBARRIER()		alpha_mb();
234174604Sscottl#elif defined(__amd64__)
235174604Sscottl#define DRM_READMEMORYBARRIER()		__asm __volatile( \
236174604Sscottl					"lock; addl $0,0(%%rsp)" : : : "memory");
237174604Sscottl#define DRM_WRITEMEMORYBARRIER()	__asm __volatile("" : : : "memory");
238174604Sscottl#define DRM_MEMORYBARRIER()		__asm __volatile( \
239174604Sscottl					"lock; addl $0,0(%%rsp)" : : : "memory");
240174604Sscottl#endif
241174604Sscottl
242174604Sscottl#define DRM_READ8(map, offset)						\
243174604Sscottl	*(volatile u_int8_t *)(((vm_offset_t)(map)->handle) +		\
244174604Sscottl	    (vm_offset_t)(offset))
245174604Sscottl#define DRM_READ16(map, offset)						\
246174604Sscottl	*(volatile u_int16_t *)(((vm_offset_t)(map)->handle) +		\
247174604Sscottl	    (vm_offset_t)(offset))
248174604Sscottl#define DRM_READ32(map, offset)						\
249174604Sscottl	*(volatile u_int32_t *)(((vm_offset_t)(map)->handle) +		\
250174604Sscottl	    (vm_offset_t)(offset))
251174604Sscottl#define DRM_WRITE8(map, offset, val)					\
252174604Sscottl	*(volatile u_int8_t *)(((vm_offset_t)(map)->handle) +		\
253174604Sscottl	    (vm_offset_t)(offset)) = val
254174604Sscottl#define DRM_WRITE16(map, offset, val)					\
255174604Sscottl	*(volatile u_int16_t *)(((vm_offset_t)(map)->handle) +		\
256174604Sscottl	    (vm_offset_t)(offset)) = val
257174604Sscottl#define DRM_WRITE32(map, offset, val)					\
258174604Sscottl	*(volatile u_int32_t *)(((vm_offset_t)(map)->handle) +		\
259267368Sdelphij	    (vm_offset_t)(offset)) = val
260174604Sscottl
261174604Sscottl#define DRM_VERIFYAREA_READ( uaddr, size )		\
262174604Sscottl	(!useracc(__DECONST(caddr_t, uaddr), size, VM_PROT_READ))
263174604Sscottl
264174604Sscottl#define DRM_COPY_TO_USER(user, kern, size) \
265174604Sscottl	copyout(kern, user, size)
266174604Sscottl#define DRM_COPY_FROM_USER(kern, user, size) \
267174604Sscottl	copyin(user, kern, size)
268174604Sscottl#define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) 	\
269174604Sscottl	copyin(arg2, arg1, arg3)
270174604Sscottl#define DRM_COPY_TO_USER_UNCHECKED(arg1, arg2, arg3)	\
271174604Sscottl	copyout(arg2, arg1, arg3)
272174604Sscottl#define DRM_GET_USER_UNCHECKED(val, uaddr)		\
273174604Sscottl	((val) = fuword32(uaddr), 0)
274174604Sscottl
275174604Sscottl#define cpu_to_le32(x) htole32(x)
276174604Sscottl#define le32_to_cpu(x) le32toh(x)
277174604Sscottl
278176939Sscottl#define DRM_HZ			hz
279174604Sscottl#define DRM_UDELAY(udelay)	DELAY(udelay)
280174604Sscottl#define DRM_TIME_SLICE		(hz/20)  /* Time slice for GLXContexts	  */
281174604Sscottl
282174604Sscottl#define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do {	\
283174604Sscottl	(_map) = (_dev)->context_sareas[_ctx];		\
284174604Sscottl} while(0)
285174604Sscottl
286174604Sscottl#define LOCK_TEST_WITH_RETURN(dev, file_priv)				\
287176031Sscottldo {									\
288174604Sscottl	if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) ||		\
289	     dev->lock.file_priv != file_priv) {			\
290		DRM_ERROR("%s called without lock held\n",		\
291			   __FUNCTION__);				\
292		return EINVAL;						\
293	}								\
294} while (0)
295
296/* Returns -errno to shared code */
297#define DRM_WAIT_ON( ret, queue, timeout, condition )		\
298for ( ret = 0 ; !ret && !(condition) ; ) {			\
299	DRM_UNLOCK();						\
300	mtx_lock(&dev->irq_lock);				\
301	if (!(condition))					\
302	    ret = -mtx_sleep(&(queue), &dev->irq_lock, 		\
303		PCATCH, "drmwtq", (timeout));			\
304	mtx_unlock(&dev->irq_lock);				\
305	DRM_LOCK();						\
306}
307
308#define DRM_ERROR(fmt, ...) \
309	printf("error: [" DRM_NAME ":pid%d:%s] *ERROR* " fmt,		\
310	    DRM_CURRENTPID, __func__ , ##__VA_ARGS__)
311
312#define DRM_INFO(fmt, ...)  printf("info: [" DRM_NAME "] " fmt , ##__VA_ARGS__)
313
314#define DRM_DEBUG(fmt, ...) do {					\
315	if (drm_debug_flag)						\
316		printf("[" DRM_NAME ":pid%d:%s] " fmt, DRM_CURRENTPID,	\
317			__func__ , ##__VA_ARGS__);			\
318} while (0)
319
320typedef struct drm_pci_id_list
321{
322	int vendor;
323	int device;
324	long driver_private;
325	char *name;
326} drm_pci_id_list_t;
327
328struct drm_msi_blacklist_entry
329{
330	int vendor;
331	int device;
332};
333
334#define DRM_AUTH	0x1
335#define DRM_MASTER	0x2
336#define DRM_ROOT_ONLY	0x4
337typedef struct drm_ioctl_desc {
338	unsigned long cmd;
339	int (*func)(struct drm_device *dev, void *data,
340		    struct drm_file *file_priv);
341	int flags;
342} drm_ioctl_desc_t;
343/**
344 * Creates a driver or general drm_ioctl_desc array entry for the given
345 * ioctl, for use by drm_ioctl().
346 */
347#define DRM_IOCTL_DEF(ioctl, func, flags) \
348	[DRM_IOCTL_NR(ioctl)] = {ioctl, func, flags}
349
350typedef struct drm_magic_entry {
351	drm_magic_t	       magic;
352	struct drm_file	       *priv;
353	struct drm_magic_entry *next;
354} drm_magic_entry_t;
355
356typedef struct drm_magic_head {
357	struct drm_magic_entry *head;
358	struct drm_magic_entry *tail;
359} drm_magic_head_t;
360
361typedef struct drm_buf {
362	int		  idx;	       /* Index into master buflist	     */
363	int		  total;       /* Buffer size			     */
364	int		  order;       /* log-base-2(total)		     */
365	int		  used;	       /* Amount of buffer in use (for DMA)  */
366	unsigned long	  offset;      /* Byte offset (used internally)	     */
367	void		  *address;    /* Address of buffer		     */
368	unsigned long	  bus_address; /* Bus address of buffer		     */
369	struct drm_buf	  *next;       /* Kernel-only: used for free list    */
370	__volatile__ int  pending;     /* On hardware DMA queue		     */
371	struct drm_file   *file_priv;  /* Unique identifier of holding process */
372	int		  context;     /* Kernel queue for this buffer	     */
373	enum {
374		DRM_LIST_NONE	 = 0,
375		DRM_LIST_FREE	 = 1,
376		DRM_LIST_WAIT	 = 2,
377		DRM_LIST_PEND	 = 3,
378		DRM_LIST_PRIO	 = 4,
379		DRM_LIST_RECLAIM = 5
380	}		  list;	       /* Which list we're on		     */
381
382	int		  dev_priv_size; /* Size of buffer private stoarge   */
383	void		  *dev_private;  /* Per-buffer private storage       */
384} drm_buf_t;
385
386typedef struct drm_freelist {
387	int		  initialized; /* Freelist in use		   */
388	atomic_t	  count;       /* Number of free buffers	   */
389	drm_buf_t	  *next;       /* End pointer			   */
390
391	int		  low_mark;    /* Low water mark		   */
392	int		  high_mark;   /* High water mark		   */
393} drm_freelist_t;
394
395typedef struct drm_dma_handle {
396	void *vaddr;
397	bus_addr_t busaddr;
398	bus_dma_tag_t tag;
399	bus_dmamap_t map;
400} drm_dma_handle_t;
401
402typedef struct drm_buf_entry {
403	int		  buf_size;
404	int		  buf_count;
405	drm_buf_t	  *buflist;
406	int		  seg_count;
407	drm_dma_handle_t  **seglist;
408	int		  page_order;
409
410	drm_freelist_t	  freelist;
411} drm_buf_entry_t;
412
413typedef TAILQ_HEAD(drm_file_list, drm_file) drm_file_list_t;
414struct drm_file {
415	TAILQ_ENTRY(drm_file) link;
416	struct drm_device *dev;
417	int		  authenticated;
418	int		  master;
419	int		  minor;
420	pid_t		  pid;
421	uid_t		  uid;
422	drm_magic_t	  magic;
423	unsigned long	  ioctl_count;
424	void		 *driver_priv;
425};
426
427typedef struct drm_lock_data {
428	struct drm_hw_lock	*hw_lock;	/* Hardware lock		   */
429	struct drm_file   *file_priv;   /* Unique identifier of holding process (NULL is kernel)*/
430	int		  lock_queue;	/* Queue of blocked processes	   */
431	unsigned long	  lock_time;	/* Time of last lock in jiffies	   */
432} drm_lock_data_t;
433
434/* This structure, in the struct drm_device, is always initialized while the
435 * device
436 * is open.  dev->dma_lock protects the incrementing of dev->buf_use, which
437 * when set marks that no further bufs may be allocated until device teardown
438 * occurs (when the last open of the device has closed).  The high/low
439 * watermarks of bufs are only touched by the X Server, and thus not
440 * concurrently accessed, so no locking is needed.
441 */
442typedef struct drm_device_dma {
443	drm_buf_entry_t	  bufs[DRM_MAX_ORDER+1];
444	int		  buf_count;
445	drm_buf_t	  **buflist;	/* Vector of pointers info bufs	   */
446	int		  seg_count;
447	int		  page_count;
448	unsigned long	  *pagelist;
449	unsigned long	  byte_count;
450	enum {
451		_DRM_DMA_USE_AGP = 0x01,
452		_DRM_DMA_USE_SG  = 0x02
453	} flags;
454} drm_device_dma_t;
455
456typedef struct drm_agp_mem {
457	void               *handle;
458	unsigned long      bound; /* address */
459	int                pages;
460	struct drm_agp_mem *prev;
461	struct drm_agp_mem *next;
462} drm_agp_mem_t;
463
464typedef struct drm_agp_head {
465	device_t	   agpdev;
466	struct agp_info    info;
467	const char         *chipset;
468	drm_agp_mem_t      *memory;
469	unsigned long      mode;
470	int                enabled;
471	int                acquired;
472	unsigned long      base;
473   	int 		   mtrr;
474	int		   cant_use_aperture;
475	unsigned long	   page_mask;
476} drm_agp_head_t;
477
478typedef struct drm_sg_mem {
479	unsigned long		  handle;
480	void			 *virtual;
481	int			  pages;
482	dma_addr_t		 *busaddr;
483	struct drm_dma_handle	 *dmah;		/* Handle to PCI memory  */
484} drm_sg_mem_t;
485
486typedef TAILQ_HEAD(drm_map_list, drm_local_map) drm_map_list_t;
487
488typedef struct drm_local_map {
489	unsigned long	offset;	 /* Physical address (0 for SAREA)*/
490	unsigned long	size;	 /* Physical size (bytes)	    */
491	enum drm_map_type	type;	 /* Type of memory mapped		    */
492	enum drm_map_flags	flags;	 /* Flags				    */
493	void		*handle; /* User-space: "Handle" to pass to mmap    */
494				 /* Kernel-space: kernel-virtual address    */
495	int		mtrr;	 /* Boolean: MTRR used */
496				 /* Private data			    */
497	int		rid;	 /* PCI resource ID for bus_space */
498	struct resource *bsr;
499	bus_space_tag_t bst;
500	bus_space_handle_t bsh;
501	drm_dma_handle_t *dmah;
502	TAILQ_ENTRY(drm_local_map) link;
503} drm_local_map_t;
504
505TAILQ_HEAD(drm_vbl_sig_list, drm_vbl_sig);
506typedef struct drm_vbl_sig {
507	TAILQ_ENTRY(drm_vbl_sig) link;
508	unsigned int	sequence;
509	int		signo;
510	int		pid;
511} drm_vbl_sig_t;
512
513struct drm_vblank_info {
514	wait_queue_head_t queue;	/* vblank wait queue */
515	atomic_t count;			/* number of VBLANK interrupts */
516					/* (driver must alloc the right number of counters) */
517	struct drm_vbl_sig_list sigs;	/* signal list to send on VBLANK */
518	atomic_t refcount;		/* number of users of vblank interrupts */
519	u32 last;			/* protected by dev->vbl_lock, used */
520					/* for wraparound handling */
521	int enabled;			/* so we don't call enable more than */
522					/* once per disable */
523	int inmodeset;			/* Display driver is setting mode */
524};
525
526/* location of GART table */
527#define DRM_ATI_GART_MAIN 1
528#define DRM_ATI_GART_FB   2
529
530#define DRM_ATI_GART_PCI  1
531#define DRM_ATI_GART_PCIE 2
532#define DRM_ATI_GART_IGP  3
533
534struct drm_ati_pcigart_info {
535	int gart_table_location;
536	int gart_reg_if;
537	void *addr;
538	dma_addr_t bus_addr;
539	dma_addr_t table_mask;
540	dma_addr_t member_mask;
541	struct drm_dma_handle *table_handle;
542	drm_local_map_t mapping;
543	int table_size;
544	struct drm_dma_handle *dmah; /* handle for ATI PCIGART table */
545};
546
547#ifndef DMA_BIT_MASK
548#define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : (1ULL<<(n)) - 1)
549#endif
550
551#define upper_32_bits(n) ((u32)(((n) >> 16) >> 16))
552
553struct drm_driver_info {
554	int	(*load)(struct drm_device *, unsigned long flags);
555	int	(*firstopen)(struct drm_device *);
556	int	(*open)(struct drm_device *, struct drm_file *);
557	void	(*preclose)(struct drm_device *, struct drm_file *file_priv);
558	void	(*postclose)(struct drm_device *, struct drm_file *);
559	void	(*lastclose)(struct drm_device *);
560	int	(*unload)(struct drm_device *);
561	void	(*reclaim_buffers_locked)(struct drm_device *,
562					  struct drm_file *file_priv);
563	int	(*dma_ioctl)(struct drm_device *dev, void *data,
564			     struct drm_file *file_priv);
565	void	(*dma_ready)(struct drm_device *);
566	int	(*dma_quiescent)(struct drm_device *);
567	int	(*dma_flush_block_and_flush)(struct drm_device *, int context,
568					     enum drm_lock_flags flags);
569	int	(*dma_flush_unblock)(struct drm_device *, int context,
570				     enum drm_lock_flags flags);
571	int	(*context_ctor)(struct drm_device *dev, int context);
572	int	(*context_dtor)(struct drm_device *dev, int context);
573	int	(*kernel_context_switch)(struct drm_device *dev, int old,
574					 int new);
575	int	(*kernel_context_switch_unlock)(struct drm_device *dev);
576	void	(*irq_preinstall)(struct drm_device *dev);
577	int	(*irq_postinstall)(struct drm_device *dev);
578	void	(*irq_uninstall)(struct drm_device *dev);
579	void	(*irq_handler)(DRM_IRQ_ARGS);
580	u32	(*get_vblank_counter)(struct drm_device *dev, int crtc);
581	int	(*enable_vblank)(struct drm_device *dev, int crtc);
582	void	(*disable_vblank)(struct drm_device *dev, int crtc);
583
584	drm_pci_id_list_t *id_entry;	/* PCI ID, name, and chipset private */
585
586	/**
587	 * Called by \c drm_device_is_agp.  Typically used to determine if a
588	 * card is really attached to AGP or not.
589	 *
590	 * \param dev  DRM device handle
591	 *
592	 * \returns
593	 * One of three values is returned depending on whether or not the
594	 * card is absolutely \b not AGP (return of 0), absolutely \b is AGP
595	 * (return of 1), or may or may not be AGP (return of 2).
596	 */
597	int	(*device_is_agp) (struct drm_device * dev);
598
599	drm_ioctl_desc_t *ioctls;
600	int	max_ioctl;
601
602	int	buf_priv_size;
603
604	int	major;
605	int	minor;
606	int	patchlevel;
607	const char *name;		/* Simple driver name		   */
608	const char *desc;		/* Longer driver name		   */
609	const char *date;		/* Date of last major changes.	   */
610
611	u32 driver_features;
612};
613
614/* Length for the array of resource pointers for drm_get_resource_*. */
615#define DRM_MAX_PCI_RESOURCE	6
616
617/**
618 * DRM device functions structure
619 */
620struct drm_device {
621	struct drm_driver_info *driver;
622	drm_pci_id_list_t *id_entry;	/* PCI ID, name, and chipset private */
623
624	u_int16_t pci_device;		/* PCI device id */
625	u_int16_t pci_vendor;		/* PCI vendor id */
626
627	char		  *unique;	/* Unique identifier: e.g., busid  */
628	int		  unique_len;	/* Length of unique field	   */
629	device_t	  device;	/* Device instance from newbus     */
630	struct cdev	  *devnode;	/* Device number for mknod	   */
631	int		  if_version;	/* Highest interface version set */
632
633	int		  flags;	/* Flags to open(2)		   */
634
635				/* Locks */
636	struct mtx	  vbl_lock;	/* protects vblank operations */
637	struct mtx	  dma_lock;	/* protects dev->dma */
638	struct mtx	  irq_lock;	/* protects irq condition checks */
639	struct mtx	  dev_lock;	/* protects everything else */
640	DRM_SPINTYPE	  drw_lock;
641
642				/* Usage Counters */
643	int		  open_count;	/* Outstanding files open	   */
644	int		  buf_use;	/* Buffers in use -- cannot alloc  */
645
646				/* Performance counters */
647	unsigned long     counters;
648	enum drm_stat_type	types[15];
649	atomic_t          counts[15];
650
651				/* Authentication */
652	drm_file_list_t   files;
653	drm_magic_head_t  magiclist[DRM_HASH_SIZE];
654
655	/* Linked list of mappable regions. Protected by dev_lock */
656	drm_map_list_t	  maplist;
657
658	drm_local_map_t	  **context_sareas;
659	int		  max_context;
660
661	drm_lock_data_t	  lock;		/* Information on hardware lock	   */
662
663				/* DMA queues (contexts) */
664	drm_device_dma_t  *dma;		/* Optional pointer for DMA support */
665
666				/* Context support */
667	int		  irq;		/* Interrupt used by board	   */
668	int		  irq_enabled;	/* True if the irq handler is enabled */
669	int		  msi_enabled;	/* MSI enabled */
670	int		  irqrid;	/* Interrupt used by board */
671	struct resource   *irqr;	/* Resource for interrupt used by board	   */
672	void		  *irqh;	/* Handle from bus_setup_intr      */
673
674	/* Storage of resource pointers for drm_get_resource_* */
675	struct resource   *pcir[DRM_MAX_PCI_RESOURCE];
676	int		  pcirid[DRM_MAX_PCI_RESOURCE];
677
678	int		  pci_domain;
679	int		  pci_bus;
680	int		  pci_slot;
681	int		  pci_func;
682
683	atomic_t	  context_flag;	/* Context swapping flag	   */
684	int		  last_context;	/* Last current context		   */
685
686	int		  vblank_disable_allowed;
687	atomic_t 	  vbl_signal_pending;	/* number of signals pending on all crtcs */
688	struct callout	  vblank_disable_timer;
689	u32		  max_vblank_count;	/* size of vblank counter register */
690	struct drm_vblank_info *vblank;		/* per crtc vblank info */
691	int		  num_crtcs;
692
693	struct sigio      *buf_sigio;	/* Processes waiting for SIGIO     */
694
695				/* Sysctl support */
696	struct drm_sysctl_info *sysctl;
697
698	drm_agp_head_t    *agp;
699	drm_sg_mem_t      *sg;  /* Scatter gather memory */
700	atomic_t          *ctx_bitmap;
701	void		  *dev_private;
702	unsigned int	  agp_buffer_token;
703	drm_local_map_t   *agp_buffer_map;
704
705	struct unrhdr	  *drw_unrhdr;
706	/* RB tree of drawable infos */
707	RB_HEAD(drawable_tree, bsd_drm_drawable_info) drw_head;
708};
709
710static __inline__ int drm_core_check_feature(struct drm_device *dev,
711					     int feature)
712{
713	return ((dev->driver->driver_features & feature) ? 1 : 0);
714}
715
716#if __OS_HAS_AGP
717static inline int drm_core_has_AGP(struct drm_device *dev)
718{
719	return drm_core_check_feature(dev, DRIVER_USE_AGP);
720}
721#else
722#define drm_core_has_AGP(dev) (0)
723#endif
724
725extern int	drm_debug_flag;
726
727/* Device setup support (drm_drv.c) */
728int	drm_probe(device_t kdev, drm_pci_id_list_t *idlist);
729int	drm_attach(device_t kdev, drm_pci_id_list_t *idlist);
730void	drm_close(void *data);
731int	drm_detach(device_t kdev);
732d_ioctl_t drm_ioctl;
733d_open_t drm_open;
734d_read_t drm_read;
735d_poll_t drm_poll;
736d_mmap_t drm_mmap;
737extern drm_local_map_t	*drm_getsarea(struct drm_device *dev);
738
739/* File operations helpers (drm_fops.c) */
740extern int		drm_open_helper(struct cdev *kdev, int flags, int fmt,
741					 DRM_STRUCTPROC *p,
742					struct drm_device *dev);
743
744/* Memory management support (drm_memory.c) */
745void	drm_mem_init(void);
746void	drm_mem_uninit(void);
747void	*drm_ioremap_wc(struct drm_device *dev, drm_local_map_t *map);
748void	*drm_ioremap(struct drm_device *dev, drm_local_map_t *map);
749void	drm_ioremapfree(drm_local_map_t *map);
750int	drm_mtrr_add(unsigned long offset, size_t size, int flags);
751int	drm_mtrr_del(int handle, unsigned long offset, size_t size, int flags);
752
753int	drm_context_switch(struct drm_device *dev, int old, int new);
754int	drm_context_switch_complete(struct drm_device *dev, int new);
755
756int	drm_ctxbitmap_init(struct drm_device *dev);
757void	drm_ctxbitmap_cleanup(struct drm_device *dev);
758void	drm_ctxbitmap_free(struct drm_device *dev, int ctx_handle);
759int	drm_ctxbitmap_next(struct drm_device *dev);
760
761/* Locking IOCTL support (drm_lock.c) */
762int	drm_lock_take(struct drm_lock_data *lock_data,
763		      unsigned int context);
764int	drm_lock_transfer(struct drm_lock_data *lock_data,
765			  unsigned int context);
766int	drm_lock_free(struct drm_lock_data *lock_data,
767		      unsigned int context);
768
769/* Buffer management support (drm_bufs.c) */
770unsigned long drm_get_resource_start(struct drm_device *dev,
771				     unsigned int resource);
772unsigned long drm_get_resource_len(struct drm_device *dev,
773				   unsigned int resource);
774void	drm_rmmap(struct drm_device *dev, drm_local_map_t *map);
775int	drm_order(unsigned long size);
776int	drm_addmap(struct drm_device *dev, unsigned long offset,
777		   unsigned long size,
778		   enum drm_map_type type, enum drm_map_flags flags,
779		   drm_local_map_t **map_ptr);
780int	drm_addbufs_pci(struct drm_device *dev, struct drm_buf_desc *request);
781int	drm_addbufs_sg(struct drm_device *dev, struct drm_buf_desc *request);
782int	drm_addbufs_agp(struct drm_device *dev, struct drm_buf_desc *request);
783
784/* DMA support (drm_dma.c) */
785int	drm_dma_setup(struct drm_device *dev);
786void	drm_dma_takedown(struct drm_device *dev);
787void	drm_free_buffer(struct drm_device *dev, drm_buf_t *buf);
788void	drm_reclaim_buffers(struct drm_device *dev, struct drm_file *file_priv);
789#define drm_core_reclaim_buffers drm_reclaim_buffers
790
791/* IRQ support (drm_irq.c) */
792int	drm_irq_install(struct drm_device *dev);
793int	drm_irq_uninstall(struct drm_device *dev);
794irqreturn_t drm_irq_handler(DRM_IRQ_ARGS);
795void	drm_driver_irq_preinstall(struct drm_device *dev);
796void	drm_driver_irq_postinstall(struct drm_device *dev);
797void	drm_driver_irq_uninstall(struct drm_device *dev);
798void	drm_handle_vblank(struct drm_device *dev, int crtc);
799u32	drm_vblank_count(struct drm_device *dev, int crtc);
800int	drm_vblank_get(struct drm_device *dev, int crtc);
801void	drm_vblank_put(struct drm_device *dev, int crtc);
802void	drm_vblank_cleanup(struct drm_device *dev);
803int	drm_vblank_wait(struct drm_device *dev, unsigned int *vbl_seq);
804int	drm_vblank_init(struct drm_device *dev, int num_crtcs);
805void	drm_vbl_send_signals(struct drm_device *dev, int crtc);
806int 	drm_modeset_ctl(struct drm_device *dev, void *data,
807			struct drm_file *file_priv);
808
809/* AGP/PCI Express/GART support (drm_agpsupport.c) */
810int	drm_device_is_agp(struct drm_device *dev);
811int	drm_device_is_pcie(struct drm_device *dev);
812drm_agp_head_t *drm_agp_init(void);
813int	drm_agp_acquire(struct drm_device *dev);
814int	drm_agp_release(struct drm_device *dev);
815int	drm_agp_info(struct drm_device * dev, struct drm_agp_info *info);
816int	drm_agp_enable(struct drm_device *dev, struct drm_agp_mode mode);
817void	*drm_agp_allocate_memory(size_t pages, u32 type);
818int	drm_agp_free_memory(void *handle);
819int	drm_agp_bind_memory(void *handle, off_t start);
820int	drm_agp_unbind_memory(void *handle);
821int	drm_agp_alloc(struct drm_device *dev, struct drm_agp_buffer *request);
822int	drm_agp_free(struct drm_device *dev, struct drm_agp_buffer *request);
823int	drm_agp_bind(struct drm_device *dev, struct drm_agp_binding *request);
824int	drm_agp_unbind(struct drm_device *dev, struct drm_agp_binding *request);
825
826/* Scatter Gather Support (drm_scatter.c) */
827void	drm_sg_cleanup(drm_sg_mem_t *entry);
828int	drm_sg_alloc(struct drm_device *dev, struct drm_scatter_gather * request);
829
830/* sysctl support (drm_sysctl.h) */
831extern int		drm_sysctl_init(struct drm_device *dev);
832extern int		drm_sysctl_cleanup(struct drm_device *dev);
833
834/* ATI PCIGART support (ati_pcigart.c) */
835int	drm_ati_pcigart_init(struct drm_device *dev,
836				struct drm_ati_pcigart_info *gart_info);
837int	drm_ati_pcigart_cleanup(struct drm_device *dev,
838				struct drm_ati_pcigart_info *gart_info);
839
840/* Locking IOCTL support (drm_drv.c) */
841int	drm_lock(struct drm_device *dev, void *data,
842		 struct drm_file *file_priv);
843int	drm_unlock(struct drm_device *dev, void *data,
844		   struct drm_file *file_priv);
845int	drm_version(struct drm_device *dev, void *data,
846		    struct drm_file *file_priv);
847int	drm_setversion(struct drm_device *dev, void *data,
848		       struct drm_file *file_priv);
849
850/* Misc. IOCTL support (drm_ioctl.c) */
851int	drm_irq_by_busid(struct drm_device *dev, void *data,
852			 struct drm_file *file_priv);
853int	drm_getunique(struct drm_device *dev, void *data,
854		      struct drm_file *file_priv);
855int	drm_setunique(struct drm_device *dev, void *data,
856		      struct drm_file *file_priv);
857int	drm_getmap(struct drm_device *dev, void *data,
858		   struct drm_file *file_priv);
859int	drm_getclient(struct drm_device *dev, void *data,
860		      struct drm_file *file_priv);
861int	drm_getstats(struct drm_device *dev, void *data,
862		     struct drm_file *file_priv);
863int	drm_noop(struct drm_device *dev, void *data,
864		 struct drm_file *file_priv);
865
866/* Context IOCTL support (drm_context.c) */
867int	drm_resctx(struct drm_device *dev, void *data,
868		   struct drm_file *file_priv);
869int	drm_addctx(struct drm_device *dev, void *data,
870		   struct drm_file *file_priv);
871int	drm_modctx(struct drm_device *dev, void *data,
872		   struct drm_file *file_priv);
873int	drm_getctx(struct drm_device *dev, void *data,
874		   struct drm_file *file_priv);
875int	drm_switchctx(struct drm_device *dev, void *data,
876		      struct drm_file *file_priv);
877int	drm_newctx(struct drm_device *dev, void *data,
878		   struct drm_file *file_priv);
879int	drm_rmctx(struct drm_device *dev, void *data,
880		  struct drm_file *file_priv);
881int	drm_setsareactx(struct drm_device *dev, void *data,
882			struct drm_file *file_priv);
883int	drm_getsareactx(struct drm_device *dev, void *data,
884			struct drm_file *file_priv);
885
886/* Drawable IOCTL support (drm_drawable.c) */
887int	drm_adddraw(struct drm_device *dev, void *data,
888		    struct drm_file *file_priv);
889int	drm_rmdraw(struct drm_device *dev, void *data,
890		   struct drm_file *file_priv);
891int	drm_update_draw(struct drm_device *dev, void *data,
892			struct drm_file *file_priv);
893struct drm_drawable_info *drm_get_drawable_info(struct drm_device *dev,
894						int handle);
895
896/* Drawable support (drm_drawable.c) */
897void drm_drawable_free_all(struct drm_device *dev);
898
899/* Authentication IOCTL support (drm_auth.c) */
900int	drm_getmagic(struct drm_device *dev, void *data,
901		     struct drm_file *file_priv);
902int	drm_authmagic(struct drm_device *dev, void *data,
903		      struct drm_file *file_priv);
904
905/* Buffer management support (drm_bufs.c) */
906int	drm_addmap_ioctl(struct drm_device *dev, void *data,
907			 struct drm_file *file_priv);
908int	drm_rmmap_ioctl(struct drm_device *dev, void *data,
909			struct drm_file *file_priv);
910int	drm_addbufs(struct drm_device *dev, void *data,
911		    struct drm_file *file_priv);
912int	drm_infobufs(struct drm_device *dev, void *data,
913		     struct drm_file *file_priv);
914int	drm_markbufs(struct drm_device *dev, void *data,
915		     struct drm_file *file_priv);
916int	drm_freebufs(struct drm_device *dev, void *data,
917		     struct drm_file *file_priv);
918int	drm_mapbufs(struct drm_device *dev, void *data,
919		    struct drm_file *file_priv);
920
921/* DMA support (drm_dma.c) */
922int	drm_dma(struct drm_device *dev, void *data, struct drm_file *file_priv);
923
924/* IRQ support (drm_irq.c) */
925int	drm_control(struct drm_device *dev, void *data,
926		    struct drm_file *file_priv);
927int	drm_wait_vblank(struct drm_device *dev, void *data,
928			struct drm_file *file_priv);
929
930/* AGP/GART support (drm_agpsupport.c) */
931int	drm_agp_acquire_ioctl(struct drm_device *dev, void *data,
932			      struct drm_file *file_priv);
933int	drm_agp_release_ioctl(struct drm_device *dev, void *data,
934			      struct drm_file *file_priv);
935int	drm_agp_enable_ioctl(struct drm_device *dev, void *data,
936			     struct drm_file *file_priv);
937int	drm_agp_info_ioctl(struct drm_device *dev, void *data,
938			   struct drm_file *file_priv);
939int	drm_agp_alloc_ioctl(struct drm_device *dev, void *data,
940			    struct drm_file *file_priv);
941int	drm_agp_free_ioctl(struct drm_device *dev, void *data,
942			   struct drm_file *file_priv);
943int	drm_agp_unbind_ioctl(struct drm_device *dev, void *data,
944			     struct drm_file *file_priv);
945int	drm_agp_bind_ioctl(struct drm_device *dev, void *data,
946			   struct drm_file *file_priv);
947
948/* Scatter Gather Support (drm_scatter.c) */
949int	drm_sg_alloc_ioctl(struct drm_device *dev, void *data,
950			   struct drm_file *file_priv);
951int	drm_sg_free(struct drm_device *dev, void *data,
952		    struct drm_file *file_priv);
953
954/* consistent PCI memory functions (drm_pci.c) */
955drm_dma_handle_t *drm_pci_alloc(struct drm_device *dev, size_t size,
956				size_t align, dma_addr_t maxaddr);
957void	drm_pci_free(struct drm_device *dev, drm_dma_handle_t *dmah);
958
959/* Inline replacements for drm_alloc and friends */
960static __inline__ void *
961drm_alloc(size_t size, struct malloc_type *area)
962{
963	return malloc(size, area, M_NOWAIT);
964}
965
966static __inline__ void *
967drm_calloc(size_t nmemb, size_t size, struct malloc_type *area)
968{
969	return malloc(size * nmemb, area, M_NOWAIT | M_ZERO);
970}
971
972static __inline__ void *
973drm_realloc(void *oldpt, size_t oldsize, size_t size,
974    struct malloc_type *area)
975{
976	return reallocf(oldpt, size, area, M_NOWAIT);
977}
978
979static __inline__ void
980drm_free(void *pt, size_t size, struct malloc_type *area)
981{
982	free(pt, area);
983}
984
985/* Inline replacements for DRM_IOREMAP macros */
986static __inline__ void
987drm_core_ioremap_wc(struct drm_local_map *map, struct drm_device *dev)
988{
989	map->handle = drm_ioremap_wc(dev, map);
990}
991static __inline__ void
992drm_core_ioremap(struct drm_local_map *map, struct drm_device *dev)
993{
994	map->handle = drm_ioremap(dev, map);
995}
996static __inline__ void
997drm_core_ioremapfree(struct drm_local_map *map, struct drm_device *dev)
998{
999	if ( map->handle && map->size )
1000		drm_ioremapfree(map);
1001}
1002
1003static __inline__ struct drm_local_map *
1004drm_core_findmap(struct drm_device *dev, unsigned long offset)
1005{
1006	drm_local_map_t *map;
1007
1008	DRM_SPINLOCK_ASSERT(&dev->dev_lock);
1009	TAILQ_FOREACH(map, &dev->maplist, link) {
1010		if (map->offset == offset)
1011			return map;
1012	}
1013	return NULL;
1014}
1015
1016static __inline__ void drm_core_dropmap(struct drm_map *map)
1017{
1018}
1019
1020#endif /* __KERNEL__ */
1021#endif /* _DRM_P_H_ */
1022