xref: /titanic_41/usr/src/uts/common/io/drm/drmP.h (revision 1f0f5e3e328e41529296f756090856aa7f239b1c)
1 /*
2  * drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
3  * Created: Mon Jan  4 10:05:05 1999 by faith@precisioninsight.com
4  */
5 /*
6  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
7  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
8  * Copyright (c) 2009, Intel Corporation.
9  * All rights reserved.
10  *
11  * Permission is hereby granted, free of charge, to any person obtaining a
12  * copy of this software and associated documentation files (the "Software"),
13  * to deal in the Software without restriction, including without limitation
14  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
15  * and/or sell copies of the Software, and to permit persons to whom the
16  * Software is furnished to do so, subject to the following conditions:
17  *
18  * The above copyright notice and this permission notice (including the next
19  * paragraph) shall be included in all copies or substantial portions of the
20  * Software.
21  *
22  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
23  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
24  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
25  * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
26  * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
27  * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
28  * OTHER DEALINGS IN THE SOFTWARE.
29  *
30  * Authors:
31  *    Rickard E. (Rik) Faith <faith@valinux.com>
32  *    Gareth Hughes <gareth@valinux.com>
33  *
34  */
35 
36 /*
37  * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
38  * Use is subject to license terms.
39  */
40 
41 #ifndef	_DRMP_H
42 #define	_DRMP_H
43 
44 #include <sys/types.h>
45 #include <sys/conf.h>
46 #include <sys/modctl.h>
47 #include <sys/stat.h>
48 #include <sys/file.h>
49 #include <sys/cmn_err.h>
50 #include <sys/varargs.h>
51 #include <sys/pci.h>
52 #include <sys/ddi.h>
53 #include <sys/sunddi.h>
54 #include <sys/sunldi.h>
55 #include <sys/pmem.h>
56 #include <sys/agpgart.h>
57 #include <sys/time.h>
58 #include "drm_atomic.h"
59 #include "drm.h"
60 #include "queue.h"
61 #include "drm_linux_list.h"
62 
63 #ifndef __inline__
64 #define	__inline__	inline
65 #endif
66 
67 #if !defined(__FUNCTION__)
68 #if defined(C99)
69 #define	__FUNCTION__ __func__
70 #else
71 #define	__FUNCTION__	" "
72 #endif
73 #endif
74 
75 /* DRM space units */
76 #define	DRM_PAGE_SHIFT			PAGESHIFT
77 #define	DRM_PAGE_SIZE			(1 << DRM_PAGE_SHIFT)
78 #define	DRM_PAGE_OFFSET			(DRM_PAGE_SIZE - 1)
79 #define	DRM_PAGE_MASK			~(DRM_PAGE_SIZE - 1)
80 #define	DRM_MB2PAGES(x)			((x) << 8)
81 #define	DRM_PAGES2BYTES(x)		((x) << DRM_PAGE_SHIFT)
82 #define	DRM_BYTES2PAGES(x)		((x) >> DRM_PAGE_SHIFT)
83 #define	DRM_PAGES2KB(x)			((x) << 2)
84 #define	DRM_ALIGNED(offset)		(((offset) & DRM_PAGE_OFFSET) == 0)
85 
86 #define	PAGE_SHIFT			DRM_PAGE_SHIFT
87 #define	PAGE_SIZE			DRM_PAGE_SIZE
88 
89 #define	DRM_MAX_INSTANCES	8
90 #define	DRM_DEVNODE		"drm"
91 #define	DRM_UNOPENED		0
92 #define	DRM_OPENED		1
93 
94 #define	DRM_HASH_SIZE		16 /* Size of key hash table */
95 #define	DRM_KERNEL_CONTEXT	0  /* Change drm_resctx if changed */
96 #define	DRM_RESERVED_CONTEXTS	1  /* Change drm_resctx if changed */
97 
98 #define	DRM_MEM_DMA	   0
99 #define	DRM_MEM_SAREA	   1
100 #define	DRM_MEM_DRIVER	   2
101 #define	DRM_MEM_MAGIC	   3
102 #define	DRM_MEM_IOCTLS	   4
103 #define	DRM_MEM_MAPS	   5
104 #define	DRM_MEM_BUFS	   6
105 #define	DRM_MEM_SEGS	   7
106 #define	DRM_MEM_PAGES	   8
107 #define	DRM_MEM_FILES	  9
108 #define	DRM_MEM_QUEUES	  10
109 #define	DRM_MEM_CMDS	  11
110 #define	DRM_MEM_MAPPINGS  12
111 #define	DRM_MEM_BUFLISTS  13
112 #define	DRM_MEM_DRMLISTS  14
113 #define	DRM_MEM_TOTALDRM  15
114 #define	DRM_MEM_BOUNDDRM  16
115 #define	DRM_MEM_CTXBITMAP 17
116 #define	DRM_MEM_STUB	  18
117 #define	DRM_MEM_SGLISTS	  19
118 #define	DRM_MEM_AGPLISTS  20
119 #define	DRM_MEM_CTXLIST   21
120 #define	DRM_MEM_MM		22
121 #define	DRM_MEM_HASHTAB		23
122 #define	DRM_MEM_OBJECTS		24
123 
124 #define	DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
125 #define	DRM_MAP_HASH_OFFSET 0x10000000
126 #define	DRM_MAP_HASH_ORDER 12
127 #define	DRM_OBJECT_HASH_ORDER 12
128 #define	DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFFUL >> PAGE_SHIFT) + 1)
129 #define	DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFFUL >> PAGE_SHIFT) * 16)
130 #define	DRM_MM_INIT_MAX_PAGES 256
131 
132 
133 /* Internal types and structures */
134 #define	DRM_ARRAY_SIZE(x) (sizeof (x) / sizeof (x[0]))
135 #define	DRM_MIN(a, b) ((a) < (b) ? (a) : (b))
136 #define	DRM_MAX(a, b) ((a) > (b) ? (a) : (b))
137 
138 #define	DRM_IF_VERSION(maj, min) (maj << 16 | min)
139 
140 #define	__OS_HAS_AGP	1
141 
142 #define	DRM_DEV_MOD	(S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
143 #define	DRM_DEV_UID	0
144 #define	DRM_DEV_GID	0
145 
146 #define	DRM_CURRENTPID		ddi_get_pid()
147 #define	DRM_SPINLOCK(l)		mutex_enter(l)
148 #define	DRM_SPINUNLOCK(u)	mutex_exit(u)
149 #define	DRM_SPINLOCK_ASSERT(l)
150 #define	DRM_LOCK()	mutex_enter(&dev->dev_lock)
151 #define	DRM_UNLOCK()	mutex_exit(&dev->dev_lock)
152 #define	DRM_LOCK_OWNED()	ASSERT(mutex_owned(&dev->dev_lock))
153 #define	spin_lock_irqsave(l, flag)		mutex_enter(l)
154 #define	spin_unlock_irqrestore(u, flag) mutex_exit(u)
155 #define	spin_lock(l)	mutex_enter(l)
156 #define	spin_unlock(u)	mutex_exit(u)
157 
158 
159 #define	DRM_UDELAY(sec)  delay(drv_usectohz(sec *1000))
160 #define	DRM_MEMORYBARRIER()
161 
162 typedef	struct drm_file		drm_file_t;
163 typedef struct drm_device	drm_device_t;
164 typedef struct drm_driver_info drm_driver_t;
165 
166 #define	DRM_DEVICE	drm_device_t *dev = dev1
167 #define	DRM_IOCTL_ARGS	\
168 	drm_device_t *dev1, intptr_t data, drm_file_t *fpriv, int mode
169 
170 #define	DRM_COPYFROM_WITH_RETURN(dest, src, size)	\
171 	if (ddi_copyin((src), (dest), (size), 0)) {	\
172 		DRM_ERROR("%s: copy from user failed", __func__);	\
173 		return (EFAULT);	\
174 	}
175 
176 #define	DRM_COPYTO_WITH_RETURN(dest, src, size)	\
177 	if (ddi_copyout((src), (dest), (size), 0)) {	\
178 		DRM_ERROR("%s: copy to user failed", __func__);	\
179 		return (EFAULT);	\
180 	}
181 
182 #define	DRM_COPY_FROM_USER(dest, src, size) \
183 	ddi_copyin((src), (dest), (size), 0) /* flag for src */
184 
185 #define	DRM_COPY_TO_USER(dest, src, size) \
186 	ddi_copyout((src), (dest), (size), 0) /* flags for dest */
187 
188 #define	DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3)  \
189 	ddi_copyin((arg2), (arg1), (arg3), 0)
190 
191 #define	DRM_COPY_TO_USER_UNCHECKED(arg1, arg2, arg3)        \
192 	ddi_copyout((arg2), arg1, arg3, 0)
193 
194 #define	DRM_READ8(map, offset) \
195 	*(uint8_t *)((uintptr_t)((map)->dev_addr) + (offset))
196 #define	DRM_READ16(map, offset) \
197 	*(uint16_t *)((uintptr_t)((map)->dev_addr) + (offset))
198 #define	DRM_READ32(map, offset) \
199 	*(uint32_t *)((uintptr_t)((map)->dev_addr) + (offset))
200 #define	DRM_WRITE8(map, offset, val) \
201 	*(uint8_t *)((uintptr_t)((map)->dev_addr) + (offset)) = (val)
202 #define	DRM_WRITE16(map, offset, val) \
203 	*(uint16_t *)((uintptr_t)((map)->dev_addr) + (offset)) = (val)
204 #define	DRM_WRITE32(map, offset, val) \
205 	*(uint32_t *)((uintptr_t)((map)->dev_addr) + (offset)) = (val)
206 
207 typedef struct drm_wait_queue {
208 	kcondvar_t	cv;
209 	kmutex_t	lock;
210 }wait_queue_head_t;
211 
212 #define	DRM_INIT_WAITQUEUE(q, pri)	\
213 { \
214 	mutex_init(&(q)->lock, NULL, MUTEX_DRIVER, pri); \
215 	cv_init(&(q)->cv, NULL, CV_DRIVER, NULL);	\
216 }
217 
218 #define	DRM_FINI_WAITQUEUE(q)	\
219 { \
220 	mutex_destroy(&(q)->lock);	\
221 	cv_destroy(&(q)->cv);	\
222 }
223 
224 #define	DRM_WAKEUP(q)	\
225 { \
226 	mutex_enter(&(q)->lock); \
227 	cv_broadcast(&(q)->cv);	\
228 	mutex_exit(&(q)->lock);	\
229 }
230 
231 #define	jiffies	ddi_get_lbolt()
232 
233 #define	DRM_WAIT_ON(ret, q, timeout, condition)  			\
234 	mutex_enter(&(q)->lock);					\
235 	while (!(condition)) {						\
236 		ret = cv_reltimedwait_sig(&(q)->cv, &(q)->lock, timeout,\
237 		    TR_CLOCK_TICK);					\
238 		if (ret == -1) {					\
239 			ret = EBUSY;					\
240 			break;						\
241 		} else if (ret == 0) {					\
242 			ret = EINTR;  					\
243 			break; 						\
244 		} else { 						\
245 			ret = 0; 					\
246 		} 							\
247 	} 								\
248 	mutex_exit(&(q)->lock);
249 
250 #define	DRM_WAIT(ret, q, condition)  \
251 mutex_enter(&(q)->lock);	\
252 if (!(condition)) {	\
253 	ret = cv_timedwait_sig(&(q)->cv, &(q)->lock, jiffies + 30 * DRM_HZ); \
254 	if (ret == -1) {				\
255 		/* gfx maybe hang */	\
256 		if (!(condition)) 	\
257 			ret = -2;	\
258 	} else {	\
259 		ret = 0;	\
260 	}	\
261 } \
262 mutex_exit(&(q)->lock);
263 
264 
265 #define	DRM_GETSAREA()  					\
266 {                                				\
267 	drm_local_map_t *map;					\
268 	DRM_SPINLOCK_ASSERT(&dev->dev_lock);			\
269 	TAILQ_FOREACH(map, &dev->maplist, link) {		\
270 		if (map->type == _DRM_SHM &&			\
271 			map->flags & _DRM_CONTAINS_LOCK) {	\
272 			dev_priv->sarea = map;			\
273 			break;					\
274 		}						\
275 	}							\
276 }
277 
278 #define	LOCK_TEST_WITH_RETURN(dev, fpriv)				\
279 	if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) ||		\
280 	    dev->lock.filp != fpriv) {					\
281 		DRM_DEBUG("%s called without lock held", __func__);	\
282 		return (EINVAL);	\
283 	}
284 
285 #define	DRM_IRQ_ARGS	caddr_t arg
286 #define	IRQ_HANDLED		DDI_INTR_CLAIMED
287 #define	IRQ_NONE		DDI_INTR_UNCLAIMED
288 
289 enum {
290 	DRM_IS_NOT_AGP,
291 	DRM_IS_AGP,
292 	DRM_MIGHT_BE_AGP
293 };
294 
295 /* Capabilities taken from src/sys/dev/pci/pcireg.h. */
296 #ifndef PCIY_AGP
297 #define	PCIY_AGP		0x02
298 #endif
299 
300 #ifndef PCIY_EXPRESS
301 #define	PCIY_EXPRESS		0x10
302 #endif
303 
304 #define	PAGE_ALIGN(addr)	(((addr) + DRM_PAGE_SIZE - 1) & DRM_PAGE_MASK)
305 #define	DRM_SUSER(p)		(crgetsgid(p) == 0 || crgetsuid(p) == 0)
306 
307 #define	DRM_GEM_OBJIDR_HASHNODE	1024
308 #define	idr_list_for_each(entry, head) \
309 	for (int key = 0; key < DRM_GEM_OBJIDR_HASHNODE; key++) \
310 		list_for_each(entry, &(head)->next[key])
311 
312 /*
313  * wait for 400 milliseconds
314  */
315 #define	DRM_HZ			drv_usectohz(400000)
316 
317 typedef unsigned long dma_addr_t;
318 typedef uint64_t	u64;
319 typedef uint32_t	u32;
320 typedef uint16_t	u16;
321 typedef uint8_t		u8;
322 typedef uint_t		irqreturn_t;
323 
324 #define	DRM_SUPPORT	1
325 #define	DRM_UNSUPPORT	0
326 
327 #define	__OS_HAS_AGP	1
328 
329 #define	__offsetof(type, field) ((size_t)(&((type *)0)->field))
330 #define	offsetof(type, field)   __offsetof(type, field)
331 
332 typedef struct drm_pci_id_list
333 {
334 	int vendor;
335 	int device;
336 	long driver_private;
337 	char *name;
338 } drm_pci_id_list_t;
339 
340 #define	DRM_AUTH	0x1
341 #define	DRM_MASTER	0x2
342 #define	DRM_ROOT_ONLY	0x4
343 typedef int drm_ioctl_t(DRM_IOCTL_ARGS);
344 typedef struct drm_ioctl_desc {
345 	int	(*func)(DRM_IOCTL_ARGS);
346 	int	flags;
347 } drm_ioctl_desc_t;
348 
349 typedef struct drm_magic_entry {
350 	drm_magic_t		magic;
351 	struct drm_file		*priv;
352 	struct drm_magic_entry	*next;
353 } drm_magic_entry_t;
354 
355 typedef struct drm_magic_head {
356 	struct drm_magic_entry *head;
357 	struct drm_magic_entry *tail;
358 } drm_magic_head_t;
359 
360 typedef struct drm_buf {
361 	int		idx;		/* Index into master buflist */
362 	int		total;		/* Buffer size */
363 	int		order;		/* log-base-2(total) */
364 	int		used;		/* Amount of buffer in use (for DMA) */
365 	unsigned long	offset;		/* Byte offset (used internally) */
366 	void		*address;	/* Address of buffer */
367 	unsigned long	bus_address;	/* Bus address of buffer */
368 	struct drm_buf	*next;		/* Kernel-only: used for free list */
369 	volatile int	pending;	/* On hardware DMA queue */
370 	drm_file_t		*filp;
371 				/* Uniq. 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 
386 typedef struct drm_freelist {
387 	int		  initialized;	/* Freelist in use		*/
388 	uint32_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 
395 typedef struct drm_buf_entry {
396 	int		  buf_size;
397 	int		  buf_count;
398 	drm_buf_t	  *buflist;
399 	int		  seg_count;
400 	int		  page_order;
401 
402 	uint32_t	  *seglist;
403 	unsigned long	  *seglist_bus;
404 
405 	drm_freelist_t	  freelist;
406 } drm_buf_entry_t;
407 
408 typedef TAILQ_HEAD(drm_file_list, drm_file) drm_file_list_t;
409 
410 /* BEGIN CSTYLED */
411 typedef struct drm_local_map {
412 	unsigned long	offset;  /*  Physical address (0 for SAREA)	*/
413 	unsigned long	size;	 /* Physical size (bytes)		*/
414 	drm_map_type_t	type;	 /* Type of memory mapped		*/
415 	drm_map_flags_t flags;	 /* Flags				*/
416 	void		*handle; /* User-space: "Handle" to pass to mmap */
417 				 /* Kernel-space: kernel-virtual address */
418 	int		mtrr;	 /* Boolean: MTRR used 			*/
419 				 /* Private data			*/
420 	int		rid;	 /* PCI resource ID for bus_space 	*/
421 	int		kernel_owned; /* Boolean: 1= initmapped, 0= addmapped */
422 	caddr_t		dev_addr;	  /* base device address 	*/
423 	ddi_acc_handle_t  dev_handle;	  /* The data access handle 	*/
424 	ddi_umem_cookie_t drm_umem_cookie; /* For SAREA alloc and free  */
425 	TAILQ_ENTRY(drm_local_map) link;
426 } drm_local_map_t;
427 /* END CSTYLED */
428 
429 /*
430  * This structure defines the drm_mm memory object, which will be used by the
431  * DRM for its buffer objects.
432  */
433 struct drm_gem_object {
434 	/* Reference count of this object */
435 	atomic_t refcount;
436 
437 	/* Handle count of this object. Each handle also holds a reference */
438 	atomic_t handlecount;
439 
440 	/* Related drm device */
441 	struct drm_device *dev;
442 
443 	int flink;
444 	/*
445 	 * Size of the object, in bytes.  Immutable over the object's
446 	 * lifetime.
447 	 */
448 	size_t size;
449 
450 	/*
451 	 * Global name for this object, starts at 1. 0 means unnamed.
452 	 * Access is covered by the object_name_lock in the related drm_device
453 	 */
454 	int name;
455 
456 	/*
457 	 * Memory domains. These monitor which caches contain read/write data
458 	 * related to the object. When transitioning from one set of domains
459 	 * to another, the driver is called to ensure that caches are suitably
460 	 * flushed and invalidated
461 	 */
462 	uint32_t read_domains;
463 	uint32_t write_domain;
464 
465 	/*
466 	 * While validating an exec operation, the
467 	 * new read/write domain values are computed here.
468 	 * They will be transferred to the above values
469 	 * at the point that any cache flushing occurs
470 	 */
471 	uint32_t pending_read_domains;
472 	uint32_t pending_write_domain;
473 
474 	void *driver_private;
475 
476 	drm_local_map_t *map;
477 	ddi_dma_handle_t dma_hdl;
478 	ddi_acc_handle_t acc_hdl;
479 	caddr_t kaddr;
480 	size_t real_size;	/* real size of memory */
481 	pfn_t *pfnarray;
482 };
483 
484 struct idr_list {
485 	struct idr_list *next, *prev;
486 	struct drm_gem_object *obj;
487 	uint32_t	handle;
488 	caddr_t	contain_ptr;
489 };
490 
491 struct drm_file {
492 	TAILQ_ENTRY(drm_file) link;
493 	int		  authenticated;
494 	int		  master;
495 	int		  minor;
496 	pid_t		  pid;
497 	uid_t		  uid;
498 	int		  refs;
499 	drm_magic_t	  magic;
500 	unsigned long	  ioctl_count;
501 	void		 *driver_priv;
502 	/* Mapping of mm object handles to object pointers. */
503 	struct idr_list object_idr;
504 	/* Lock for synchronization of access to object_idr. */
505 	kmutex_t table_lock;
506 
507 	dev_t dev;
508 	cred_t *credp;
509 };
510 
511 typedef struct drm_lock_data {
512 	drm_hw_lock_t	*hw_lock;	/* Hardware lock		*/
513 	drm_file_t	*filp;
514 	/* Uniq. identifier of holding process */
515 	kcondvar_t	lock_cv;	/* lock queue - SOLARIS Specific */
516 	kmutex_t	lock_mutex;	/* lock - SOLARIS Specific */
517 	unsigned long	lock_time;	/* Time of last lock in clock ticks */
518 } drm_lock_data_t;
519 
520 /*
521  * This structure, in drm_device_t, is always initialized while the device
522  * is open.  dev->dma_lock protects the incrementing of dev->buf_use, which
523  * when set marks that no further bufs may be allocated until device teardown
524  * occurs (when the last open of the device has closed).  The high/low
525  * watermarks of bufs are only touched by the X Server, and thus not
526  * concurrently accessed, so no locking is needed.
527  */
528 typedef struct drm_device_dma {
529 	drm_buf_entry_t	bufs[DRM_MAX_ORDER+1];
530 	int		buf_count;
531 	drm_buf_t	**buflist;	/* Vector of pointers info bufs	   */
532 	int		seg_count;
533 	int		page_count;
534 	unsigned long	*pagelist;
535 	unsigned long	byte_count;
536 	enum {
537 		_DRM_DMA_USE_AGP = 0x01,
538 		_DRM_DMA_USE_SG  = 0x02
539 	} flags;
540 } drm_device_dma_t;
541 
542 typedef struct drm_agp_mem {
543 	void		*handle;
544 	unsigned long	bound; /* address */
545 	int		pages;
546 	caddr_t		phys_addr;
547 	struct drm_agp_mem *prev;
548 	struct drm_agp_mem *next;
549 } drm_agp_mem_t;
550 
551 typedef struct drm_agp_head {
552 	agp_info_t	agp_info;
553 	const char	*chipset;
554 	drm_agp_mem_t	*memory;
555 	unsigned long	mode;
556 	int		enabled;
557 	int		acquired;
558 	unsigned long	base;
559 	int		mtrr;
560 	int		cant_use_aperture;
561 	unsigned long	page_mask;
562 	ldi_ident_t	agpgart_li;
563 	ldi_handle_t	agpgart_lh;
564 } drm_agp_head_t;
565 
566 
567 typedef struct drm_dma_handle {
568 	ddi_dma_handle_t	dma_hdl;
569 	ddi_acc_handle_t	acc_hdl;
570 	ddi_dma_cookie_t	cookie;
571 	uint_t		cookie_num;
572 	uintptr_t		vaddr;   /* virtual addr */
573 	uintptr_t		paddr;   /* physical addr */
574 	size_t		real_sz; /* real size of memory */
575 } drm_dma_handle_t;
576 
577 typedef struct drm_sg_mem {
578 	unsigned long	handle;
579 	void		*virtual;
580 	int		pages;
581 	dma_addr_t  	*busaddr;
582 	ddi_umem_cookie_t	*umem_cookie;
583 	drm_dma_handle_t	*dmah_sg;
584 	drm_dma_handle_t	*dmah_gart; /* Handle to PCI memory */
585 } drm_sg_mem_t;
586 
587 /*
588  * Generic memory manager structs
589  */
590 
591 struct drm_mm_node {
592 	struct list_head fl_entry;
593 	struct list_head ml_entry;
594 	int free;
595 	unsigned long start;
596 	unsigned long size;
597 	struct drm_mm *mm;
598 	void *private;
599 };
600 
601 struct drm_mm {
602 	struct list_head fl_entry;
603 	struct list_head ml_entry;
604 };
605 
606 typedef TAILQ_HEAD(drm_map_list, drm_local_map) drm_map_list_t;
607 
608 typedef TAILQ_HEAD(drm_vbl_sig_list, drm_vbl_sig) drm_vbl_sig_list_t;
609 typedef struct drm_vbl_sig {
610 	TAILQ_ENTRY(drm_vbl_sig) link;
611 	unsigned int	sequence;
612 	int		signo;
613 	int		pid;
614 } drm_vbl_sig_t;
615 
616 
617 /* used for clone device */
618 typedef TAILQ_HEAD(drm_cminor_list, drm_cminor) drm_cminor_list_t;
619 typedef struct drm_cminor {
620 	TAILQ_ENTRY(drm_cminor) link;
621 	drm_file_t		*fpriv;
622 	int			minor;
623 } drm_cminor_t;
624 
625 /* location of GART table */
626 #define	DRM_ATI_GART_MAIN	1
627 #define	DRM_ATI_GART_FB		2
628 
629 typedef struct ati_pcigart_info {
630 	int gart_table_location;
631 	int is_pcie;
632 	void *addr;
633 	dma_addr_t bus_addr;
634 	drm_local_map_t mapping;
635 } drm_ati_pcigart_info;
636 
637 /* DRM device structure */
638 struct drm_device;
639 struct drm_driver_info {
640 	int (*load)(struct drm_device *, unsigned long);
641 	int (*firstopen)(struct drm_device *);
642 	int (*open)(struct drm_device *, drm_file_t *);
643 	void (*preclose)(struct drm_device *, drm_file_t *);
644 	void (*postclose)(struct drm_device *, drm_file_t *);
645 	void (*lastclose)(struct drm_device *);
646 	int (*unload)(struct drm_device *);
647 	void (*reclaim_buffers_locked)(struct drm_device *, drm_file_t *);
648 	int (*presetup)(struct drm_device *);
649 	int (*postsetup)(struct drm_device *);
650 	int (*open_helper)(struct drm_device *, drm_file_t *);
651 	void (*free_filp_priv)(struct drm_device *, drm_file_t *);
652 	void (*release)(struct drm_device *, void *);
653 	int (*dma_ioctl)(DRM_IOCTL_ARGS);
654 	void (*dma_ready)(struct drm_device *);
655 	int (*dma_quiescent)(struct drm_device *);
656 	int (*dma_flush_block_and_flush)(struct drm_device *,
657 			int, drm_lock_flags_t);
658 	int (*dma_flush_unblock)(struct drm_device *, int,
659 					drm_lock_flags_t);
660 	int (*context_ctor)(struct drm_device *, int);
661 	int (*context_dtor)(struct drm_device *, int);
662 	int (*kernel_context_switch)(struct drm_device *, int, int);
663 	int (*kernel_context_switch_unlock)(struct drm_device *);
664 	int (*device_is_agp) (struct drm_device *);
665 	int (*irq_preinstall)(struct drm_device *);
666 	void (*irq_postinstall)(struct drm_device *);
667 	void (*irq_uninstall)(struct drm_device *dev);
668 	uint_t (*irq_handler)(DRM_IRQ_ARGS);
669 	int (*vblank_wait)(struct drm_device *, unsigned int *);
670 	int (*vblank_wait2)(struct drm_device *, unsigned int *);
671 	/* added for intel minimized vblank */
672 	u32 (*get_vblank_counter)(struct drm_device *dev, int crtc);
673 	int (*enable_vblank)(struct drm_device *dev, int crtc);
674 	void (*disable_vblank)(struct drm_device *dev, int crtc);
675 
676 	/*
677 	 * Driver-specific constructor for drm_gem_objects, to set up
678 	 * obj->driver_private.
679 	 *
680 	 * Returns 0 on success.
681 	 */
682 	int (*gem_init_object) (struct drm_gem_object *obj);
683 	void (*gem_free_object) (struct drm_gem_object *obj);
684 
685 
686 	drm_ioctl_desc_t *driver_ioctls;
687 	int	max_driver_ioctl;
688 
689 	int	buf_priv_size;
690 	int	driver_major;
691 	int	driver_minor;
692 	int	driver_patchlevel;
693 	const char *driver_name;	/* Simple driver name		   */
694 	const char *driver_desc;	/* Longer driver name		   */
695 	const char *driver_date;	/* Date of last major changes.	   */
696 
697 	unsigned use_agp :1;
698 	unsigned require_agp :1;
699 	unsigned use_sg :1;
700 	unsigned use_dma :1;
701 	unsigned use_pci_dma :1;
702 	unsigned use_dma_queue :1;
703 	unsigned use_irq :1;
704 	unsigned use_vbl_irq :1;
705 	unsigned use_vbl_irq2 :1;
706 	unsigned use_mtrr :1;
707 	unsigned use_gem;
708 };
709 
710 /*
711  * hardware-specific code needs to initialize mutexes which
712  * can be used in interrupt context, so they need to know
713  * the interrupt priority. Interrupt cookie in drm_device
714  * structure is the intr_block field.
715  */
716 #define	DRM_INTR_PRI(dev) \
717 	DDI_INTR_PRI((dev)->intr_block)
718 
719 struct drm_device {
720 	drm_driver_t	*driver;
721 	drm_cminor_list_t	minordevs;
722 	dev_info_t *dip;
723 	void	*drm_handle;
724 	int drm_supported;
725 	const char *desc; /* current driver description */
726 	kmutex_t *irq_mutex;
727 	kcondvar_t *irq_cv;
728 
729 	ddi_iblock_cookie_t intr_block;
730 	uint32_t	pci_device;	/* PCI device id */
731 	uint32_t	pci_vendor;
732 	char		*unique;	/* Unique identifier: e.g., busid  */
733 	int		unique_len;	/* Length of unique field	   */
734 	int		if_version;	/* Highest interface version set */
735 	int		flags;	/* Flags to open(2)		   */
736 
737 	/* Locks */
738 	kmutex_t	vbl_lock;	/* protects vblank operations */
739 	kmutex_t	dma_lock;	/* protects dev->dma */
740 	kmutex_t	irq_lock;	/* protects irq condition checks */
741 	kmutex_t	dev_lock;	/* protects everything else */
742 	drm_lock_data_t   lock;		/* Information on hardware lock    */
743 	kmutex_t	struct_mutex;	/* < For others	*/
744 
745 	/* Usage Counters */
746 	int		  open_count;	/* Outstanding files open	   */
747 	int		  buf_use;	/* Buffers in use -- cannot alloc  */
748 
749 	/* Performance counters */
750 	unsigned long	  counters;
751 	drm_stat_type_t	  types[15];
752 	uint32_t	  counts[15];
753 
754 	/* Authentication */
755 	drm_file_list_t   files;
756 	drm_magic_head_t  magiclist[DRM_HASH_SIZE];
757 
758 	/* Linked list of mappable regions. Protected by dev_lock */
759 	drm_map_list_t	  maplist;
760 
761 	drm_local_map_t	  **context_sareas;
762 	int		  max_context;
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 	int		  pci_domain;
771 	int		  pci_bus;
772 	int		  pci_slot;
773 	int		  pci_func;
774 	atomic_t	  context_flag;	/* Context swapping flag	   */
775 	int		  last_context;	/* Last current context		   */
776 
777 	/* Only used for Radeon */
778 	atomic_t	vbl_received;
779 	atomic_t	vbl_received2;
780 
781 	drm_vbl_sig_list_t vbl_sig_list;
782 	drm_vbl_sig_list_t vbl_sig_list2;
783 	/*
784 	 * At load time, disabling the vblank interrupt won't be allowed since
785 	 * old clients may not call the modeset ioctl and therefore misbehave.
786 	 * Once the modeset ioctl *has* been called though, we can safely
787 	 * disable them when unused.
788 	 */
789 	int vblank_disable_allowed;
790 
791 	wait_queue_head_t	vbl_queue;	/* vbl wait channel */
792 	/* vbl wait channel array */
793 	wait_queue_head_t	*vbl_queues;
794 
795 	/* number of VBLANK interrupts */
796 	/* (driver must alloc the right number of counters) */
797 	atomic_t	  *_vblank_count;
798 	/* signal list to send on VBLANK */
799 	struct drm_vbl_sig_list *vbl_sigs;
800 
801 	/* number of signals pending on all crtcs */
802 	atomic_t	  vbl_signal_pending;
803 	/* number of users of vblank interrupts per crtc */
804 	atomic_t	  *vblank_refcount;
805 	/* protected by dev->vbl_lock, used for wraparound handling */
806 	u32		  *last_vblank;
807 	/* so we don't call enable more than */
808 	atomic_t	  *vblank_enabled;
809 	/* Display driver is setting mode */
810 	int		*vblank_inmodeset;
811 	/* Don't wait while crtc is likely disabled */
812 	int		*vblank_suspend;
813 	/* size of vblank counter register */
814 	u32		max_vblank_count;
815 	int		num_crtcs;
816 	kmutex_t	tasklet_lock;
817 	void (*locked_tasklet_func)(struct drm_device *dev);
818 
819 	pid_t		  buf_pgid;
820 	drm_agp_head_t    *agp;
821 	drm_sg_mem_t	  *sg;  /* Scatter gather memory */
822 	uint32_t	  *ctx_bitmap;
823 	void		  *dev_private;
824 	unsigned int	  agp_buffer_token;
825 	drm_local_map_t   *agp_buffer_map;
826 
827 	kstat_t		  *asoft_ksp; /* kstat support */
828 
829 	/* name Drawable information */
830 	kmutex_t	drw_lock;
831 	unsigned int drw_bitfield_length;
832 	u32 *drw_bitfield;
833 	unsigned int drw_info_length;
834 	drm_drawable_info_t **drw_info;
835 
836 	/* \name GEM information */
837 	/* @{ */
838 	kmutex_t object_name_lock;
839 	struct idr_list	object_name_idr;
840 	atomic_t object_count;
841 	atomic_t object_memory;
842 	atomic_t pin_count;
843 	atomic_t pin_memory;
844 	atomic_t gtt_count;
845 	atomic_t gtt_memory;
846 	uint32_t gtt_total;
847 	uint32_t invalidate_domains;	/* domains pending invalidation */
848 	uint32_t flush_domains;	/* domains pending flush */
849 	/* @} */
850 
851 	/*
852 	 * Saving S3 context
853 	 */
854 	void		  *s3_private;
855 };
856 
857 /* Memory management support (drm_memory.c) */
858 void	drm_mem_init(void);
859 void	drm_mem_uninit(void);
860 void	*drm_alloc(size_t, int);
861 void	*drm_calloc(size_t, size_t, int);
862 void	*drm_realloc(void *, size_t, size_t, int);
863 void	drm_free(void *, size_t, int);
864 int 	drm_ioremap(drm_device_t *, drm_local_map_t *);
865 void	drm_ioremapfree(drm_local_map_t *);
866 
867 void drm_core_ioremap(struct drm_local_map *, struct drm_device *);
868 void drm_core_ioremapfree(struct drm_local_map *, struct drm_device *);
869 
870 void drm_pci_free(drm_device_t *, drm_dma_handle_t *);
871 void *drm_pci_alloc(drm_device_t *, size_t, size_t, dma_addr_t, int);
872 
873 struct drm_local_map *drm_core_findmap(struct drm_device *, unsigned long);
874 
875 int	drm_context_switch(drm_device_t *, int, int);
876 int	drm_context_switch_complete(drm_device_t *, int);
877 int	drm_ctxbitmap_init(drm_device_t *);
878 void	drm_ctxbitmap_cleanup(drm_device_t *);
879 void	drm_ctxbitmap_free(drm_device_t *, int);
880 int	drm_ctxbitmap_next(drm_device_t *);
881 
882 /* Locking IOCTL support (drm_lock.c) */
883 int	drm_lock_take(drm_lock_data_t *, unsigned int);
884 int	drm_lock_transfer(drm_device_t *,
885 			drm_lock_data_t *, unsigned int);
886 int	drm_lock_free(drm_device_t *,
887 		    volatile unsigned int *, unsigned int);
888 
889 /* Buffer management support (drm_bufs.c) */
890 unsigned long drm_get_resource_start(drm_device_t *, unsigned int);
891 unsigned long drm_get_resource_len(drm_device_t *, unsigned int);
892 int	drm_initmap(drm_device_t *, unsigned long, unsigned long,
893     unsigned int, int, int);
894 void	drm_rmmap(drm_device_t *, drm_local_map_t *);
895 int	drm_addmap(drm_device_t *, unsigned long, unsigned long,
896     drm_map_type_t, drm_map_flags_t, drm_local_map_t **);
897 int	drm_order(unsigned long);
898 
899 /* DMA support (drm_dma.c) */
900 int	drm_dma_setup(drm_device_t *);
901 void	drm_dma_takedown(drm_device_t *);
902 void	drm_free_buffer(drm_device_t *, drm_buf_t *);
903 void	drm_reclaim_buffers(drm_device_t *, drm_file_t *);
904 #define	drm_core_reclaim_buffers	drm_reclaim_buffers
905 
906 /* IRQ support (drm_irq.c) */
907 int	drm_irq_install(drm_device_t *);
908 int	drm_irq_uninstall(drm_device_t *);
909 uint_t	drm_irq_handler(DRM_IRQ_ARGS);
910 void	drm_driver_irq_preinstall(drm_device_t *);
911 void	drm_driver_irq_postinstall(drm_device_t *);
912 void	drm_driver_irq_uninstall(drm_device_t *);
913 int	drm_vblank_wait(drm_device_t *, unsigned int *);
914 void	drm_vbl_send_signals(drm_device_t *);
915 void    drm_handle_vblank(struct drm_device *dev, int crtc);
916 u32	drm_vblank_count(struct drm_device *dev, int crtc);
917 int	drm_vblank_get(struct drm_device *dev, int crtc);
918 void	drm_vblank_put(struct drm_device *dev, int crtc);
919 int	drm_vblank_init(struct drm_device *dev, int num_crtcs);
920 void	drm_vblank_cleanup(struct drm_device *dev);
921 int    drm_modeset_ctl(DRM_IOCTL_ARGS);
922 
923 /* AGP/GART support (drm_agpsupport.c) */
924 int	drm_device_is_agp(drm_device_t *);
925 int 	drm_device_is_pcie(drm_device_t *);
926 drm_agp_head_t *drm_agp_init(drm_device_t *);
927 void	drm_agp_fini(drm_device_t *);
928 int 	drm_agp_do_release(drm_device_t *);
929 void	*drm_agp_allocate_memory(size_t pages,
930 	    uint32_t type, drm_device_t *dev);
931 int	drm_agp_free_memory(agp_allocate_t *handle, drm_device_t *dev);
932 int	drm_agp_bind_memory(unsigned int, uint32_t, drm_device_t *);
933 int	drm_agp_unbind_memory(unsigned long, drm_device_t *);
934 int	drm_agp_bind_pages(drm_device_t *dev,
935 		    pfn_t *pages,
936 		    unsigned long num_pages,
937 		    uint32_t gtt_offset);
938 int	drm_agp_unbind_pages(drm_device_t *dev,
939 		    unsigned long num_pages,
940 		    uint32_t gtt_offset,
941 		    uint32_t type);
942 void drm_agp_chipset_flush(struct drm_device *dev);
943 void drm_agp_rebind(struct drm_device *dev);
944 
945 /* kstat support (drm_kstats.c) */
946 int	drm_init_kstats(drm_device_t *);
947 void	drm_fini_kstats(drm_device_t *);
948 
949 /* Scatter Gather Support (drm_scatter.c) */
950 void	drm_sg_cleanup(drm_device_t *, drm_sg_mem_t *);
951 
952 /* ATI PCIGART support (ati_pcigart.c) */
953 int	drm_ati_pcigart_init(drm_device_t *, drm_ati_pcigart_info *);
954 int	drm_ati_pcigart_cleanup(drm_device_t *, drm_ati_pcigart_info *);
955 
956 /* Locking IOCTL support (drm_drv.c) */
957 int	drm_lock(DRM_IOCTL_ARGS);
958 int	drm_unlock(DRM_IOCTL_ARGS);
959 int	drm_version(DRM_IOCTL_ARGS);
960 int	drm_setversion(DRM_IOCTL_ARGS);
961 /* Cache management (drm_cache.c) */
962 void drm_clflush_pages(caddr_t *pages, unsigned long num_pages);
963 
964 /* Misc. IOCTL support (drm_ioctl.c) */
965 int	drm_irq_by_busid(DRM_IOCTL_ARGS);
966 int	drm_getunique(DRM_IOCTL_ARGS);
967 int	drm_setunique(DRM_IOCTL_ARGS);
968 int	drm_getmap(DRM_IOCTL_ARGS);
969 int	drm_getclient(DRM_IOCTL_ARGS);
970 int	drm_getstats(DRM_IOCTL_ARGS);
971 int	drm_noop(DRM_IOCTL_ARGS);
972 
973 /* Context IOCTL support (drm_context.c) */
974 int	drm_resctx(DRM_IOCTL_ARGS);
975 int	drm_addctx(DRM_IOCTL_ARGS);
976 int	drm_modctx(DRM_IOCTL_ARGS);
977 int	drm_getctx(DRM_IOCTL_ARGS);
978 int	drm_switchctx(DRM_IOCTL_ARGS);
979 int	drm_newctx(DRM_IOCTL_ARGS);
980 int	drm_rmctx(DRM_IOCTL_ARGS);
981 int	drm_setsareactx(DRM_IOCTL_ARGS);
982 int	drm_getsareactx(DRM_IOCTL_ARGS);
983 
984 /* Drawable IOCTL support (drm_drawable.c) */
985 int	drm_adddraw(DRM_IOCTL_ARGS);
986 int	drm_rmdraw(DRM_IOCTL_ARGS);
987 int	drm_update_draw(DRM_IOCTL_ARGS);
988 
989 /* Authentication IOCTL support (drm_auth.c) */
990 int	drm_getmagic(DRM_IOCTL_ARGS);
991 int	drm_authmagic(DRM_IOCTL_ARGS);
992 int	drm_remove_magic(drm_device_t *, drm_magic_t);
993 drm_file_t	*drm_find_file(drm_device_t *, drm_magic_t);
994 /* Buffer management support (drm_bufs.c) */
995 int	drm_addmap_ioctl(DRM_IOCTL_ARGS);
996 int	drm_rmmap_ioctl(DRM_IOCTL_ARGS);
997 int	drm_addbufs_ioctl(DRM_IOCTL_ARGS);
998 int	drm_infobufs(DRM_IOCTL_ARGS);
999 int	drm_markbufs(DRM_IOCTL_ARGS);
1000 int	drm_freebufs(DRM_IOCTL_ARGS);
1001 int	drm_mapbufs(DRM_IOCTL_ARGS);
1002 
1003 /* DMA support (drm_dma.c) */
1004 int	drm_dma(DRM_IOCTL_ARGS);
1005 
1006 /* IRQ support (drm_irq.c) */
1007 int	drm_control(DRM_IOCTL_ARGS);
1008 int	drm_wait_vblank(DRM_IOCTL_ARGS);
1009 
1010 /* AGP/GART support (drm_agpsupport.c) */
1011 int	drm_agp_acquire(DRM_IOCTL_ARGS);
1012 int	drm_agp_release(DRM_IOCTL_ARGS);
1013 int	drm_agp_enable(DRM_IOCTL_ARGS);
1014 int	drm_agp_info(DRM_IOCTL_ARGS);
1015 int	drm_agp_alloc(DRM_IOCTL_ARGS);
1016 int	drm_agp_free(DRM_IOCTL_ARGS);
1017 int	drm_agp_unbind(DRM_IOCTL_ARGS);
1018 int	drm_agp_bind(DRM_IOCTL_ARGS);
1019 
1020 /* Scatter Gather Support (drm_scatter.c) */
1021 int	drm_sg_alloc(DRM_IOCTL_ARGS);
1022 int	drm_sg_free(DRM_IOCTL_ARGS);
1023 
1024 /*	drm_mm.c	*/
1025 struct drm_mm_node *drm_mm_get_block(struct drm_mm_node *parent,
1026 				    unsigned long size, unsigned alignment);
1027 struct drm_mm_node *drm_mm_search_free(const struct drm_mm *mm,
1028 				    unsigned long size,
1029 				    unsigned alignment, int best_match);
1030 
1031 extern void drm_mm_clean_ml(const struct drm_mm *mm);
1032 extern int drm_debug_flag;
1033 
1034 /* We add function to support DRM_DEBUG,DRM_ERROR,DRM_INFO */
1035 extern void drm_debug(const char *fmt, ...);
1036 extern void drm_error(const char *fmt, ...);
1037 extern void drm_info(const char *fmt, ...);
1038 
1039 #ifdef DEBUG
1040 #define	DRM_DEBUG		if (drm_debug_flag >= 2) drm_debug
1041 #define	DRM_INFO		if (drm_debug_flag >= 1) drm_info
1042 #else
1043 #define	DRM_DEBUG(...)
1044 #define	DRM_INFO(...)
1045 #endif
1046 
1047 #define	DRM_ERROR		drm_error
1048 
1049 
1050 #define	MAX_INSTNUMS 16
1051 
1052 extern int drm_dev_to_instance(dev_t);
1053 extern int drm_dev_to_minor(dev_t);
1054 extern void *drm_supp_register(dev_info_t *, drm_device_t *);
1055 extern int drm_supp_unregister(void *);
1056 
1057 extern int drm_open(drm_device_t *, drm_cminor_t *, int, int, cred_t *);
1058 extern int drm_close(drm_device_t *, int, int, int, cred_t *);
1059 extern int drm_attach(drm_device_t *);
1060 extern int drm_detach(drm_device_t *);
1061 extern int drm_probe(drm_device_t *, drm_pci_id_list_t *);
1062 
1063 extern int drm_pci_init(drm_device_t *);
1064 extern void drm_pci_end(drm_device_t *);
1065 extern int pci_get_info(drm_device_t *, int *, int *, int *);
1066 extern int pci_get_irq(drm_device_t *);
1067 extern int pci_get_vendor(drm_device_t *);
1068 extern int pci_get_device(drm_device_t *);
1069 
1070 extern struct drm_drawable_info *drm_get_drawable_info(drm_device_t *,
1071 							drm_drawable_t);
1072 /* File Operations helpers (drm_fops.c) */
1073 extern drm_file_t *drm_find_file_by_proc(drm_device_t *, cred_t *);
1074 extern drm_cminor_t *drm_find_file_by_minor(drm_device_t *, int);
1075 extern int drm_open_helper(drm_device_t *, drm_cminor_t *, int, int,
1076     cred_t *);
1077 
1078 /* Graphics Execution Manager library functions (drm_gem.c) */
1079 int drm_gem_init(struct drm_device *dev);
1080 void drm_gem_object_free(struct drm_gem_object *obj);
1081 struct drm_gem_object *drm_gem_object_alloc(struct drm_device *dev,
1082 					    size_t size);
1083 void drm_gem_object_handle_free(struct drm_gem_object *obj);
1084 
1085 void drm_gem_object_reference(struct drm_gem_object *obj);
1086 void drm_gem_object_unreference(struct drm_gem_object *obj);
1087 
1088 int drm_gem_handle_create(struct drm_file *file_priv,
1089 			    struct drm_gem_object *obj,
1090 			    int *handlep);
1091 void drm_gem_object_handle_reference(struct drm_gem_object *obj);
1092 
1093 void drm_gem_object_handle_unreference(struct drm_gem_object *obj);
1094 
1095 struct drm_gem_object *drm_gem_object_lookup(struct drm_file *filp,
1096 					    int handle);
1097 int drm_gem_close_ioctl(DRM_IOCTL_ARGS);
1098 int drm_gem_flink_ioctl(DRM_IOCTL_ARGS);
1099 int drm_gem_open_ioctl(DRM_IOCTL_ARGS);
1100 void drm_gem_open(struct drm_file *file_private);
1101 void drm_gem_release(struct drm_device *dev, struct drm_file *file_private);
1102 
1103 
1104 #endif	/* _DRMP_H */
1105