1 /* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
2 * Created: Mon Jan 4 10:05:05 1999 by faith@precisioninsight.com
4 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
5 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
8 * Permission is hereby granted, free of charge, to any person obtaining a
9 * copy of this software and associated documentation files (the "Software"),
10 * to deal in the Software without restriction, including without limitation
11 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12 * and/or sell copies of the Software, and to permit persons to whom the
13 * Software is furnished to do so, subject to the following conditions:
15 * The above copyright notice and this permission notice (including the next
16 * paragraph) shall be included in all copies or substantial portions of the
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
23 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
24 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
25 * OTHER DEALINGS IN THE SOFTWARE.
28 * Rickard E. (Rik) Faith <faith@valinux.com>
29 * Gareth Hughes <gareth@valinux.com>
37 /* add include of current.h so that "current" is defined
38 * before static inline funcs in wait.h. Doing this so we
39 * can build the DRM (part of PI DRI). 4/21/2000 S + B */
40 #include <asm/current.h>
41 #endif /* __alpha__ */
42 #include <linux/config.h>
43 #include <linux/module.h>
44 #include <linux/kernel.h>
45 #include <linux/miscdevice.h>
47 #include <linux/proc_fs.h>
48 #include <linux/init.h>
49 #include <linux/file.h>
50 #include <linux/pci.h>
51 #include <linux/wrapper.h>
52 #include <linux/version.h>
53 #include <linux/sched.h>
54 #include <linux/smp_lock.h> /* For (un)lock_kernel */
57 #include <asm/pgtable.h> /* For pte_wrprotect */
61 #include <asm/uaccess.h>
65 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
66 #include <linux/types.h>
67 #include <linux/agp_backend.h>
69 #if LINUX_VERSION_CODE >= 0x020100 /* KERNEL_VERSION(2,1,0) */
70 #include <linux/tqueue.h>
71 #include <linux/poll.h>
73 #if LINUX_VERSION_CODE < 0x020400
74 #include "compat-pre24.h"
78 /* DRM template customization defaults
89 #ifndef __HAVE_DMA_WAITLIST
90 #define __HAVE_DMA_WAITLIST 0
92 #ifndef __HAVE_DMA_FREELIST
93 #define __HAVE_DMA_FREELIST 0
96 #define __REALLY_HAVE_AGP (__HAVE_AGP && (defined(CONFIG_AGP) || \
97 defined(CONFIG_AGP_MODULE)))
98 #define __REALLY_HAVE_MTRR (__HAVE_MTRR && defined(CONFIG_MTRR))
104 #define DRM_DEBUG_CODE 2 /* Include debugging code (if > 1, then
105 also include looping detection. */
106 #define DRM_DMA_HISTOGRAM 1 /* Make histogram of DMA latency. */
108 #define DRM_HASH_SIZE 16 /* Size of key hash table */
109 #define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */
110 #define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */
111 #define DRM_LOOPING_LIMIT 5000000
112 #define DRM_BSZ 1024 /* Buffer size for /dev/drm? output */
113 #define DRM_TIME_SLICE (HZ/20) /* Time slice for GLXContexts */
114 #define DRM_LOCK_SLICE 1 /* Time slice for lock, in jiffies */
116 #define DRM_FLAG_DEBUG 0x01
117 #define DRM_FLAG_NOCTX 0x02
119 #define DRM_MEM_DMA 0
120 #define DRM_MEM_SAREA 1
121 #define DRM_MEM_DRIVER 2
122 #define DRM_MEM_MAGIC 3
123 #define DRM_MEM_IOCTLS 4
124 #define DRM_MEM_MAPS 5
125 #define DRM_MEM_VMAS 6
126 #define DRM_MEM_BUFS 7
127 #define DRM_MEM_SEGS 8
128 #define DRM_MEM_PAGES 9
129 #define DRM_MEM_FILES 10
130 #define DRM_MEM_QUEUES 11
131 #define DRM_MEM_CMDS 12
132 #define DRM_MEM_MAPPINGS 13
133 #define DRM_MEM_BUFLISTS 14
134 #define DRM_MEM_AGPLISTS 15
135 #define DRM_MEM_TOTALAGP 16
136 #define DRM_MEM_BOUNDAGP 17
137 #define DRM_MEM_CTXBITMAP 18
138 #define DRM_MEM_STUB 19
140 #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
142 /* Backward compatibility section */
143 /* _PAGE_WT changed to _PAGE_PWT in 2.2.6 */
145 #define _PAGE_PWT _PAGE_WT
147 /* Wait queue declarations changed in 2.3.1 */
148 #ifndef DECLARE_WAITQUEUE
149 #define DECLARE_WAITQUEUE(w,c) struct wait_queue w = { c, NULL }
150 typedef struct wait_queue *wait_queue_head_t;
151 #define init_waitqueue_head(q) *q = NULL;
154 /* _PAGE_4M changed to _PAGE_PSE in 2.3.23 */
156 #define _PAGE_PSE _PAGE_4M
159 /* vm_offset changed to vm_pgoff in 2.3.25 */
160 #if LINUX_VERSION_CODE < 0x020319
161 #define VM_OFFSET(vma) ((vma)->vm_offset)
163 #define VM_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT)
166 /* *_nopage return values defined in 2.3.26 */
167 #ifndef NOPAGE_SIGBUS
168 #define NOPAGE_SIGBUS 0
174 /* module_init/module_exit added in 2.3.13 */
176 #define module_init(x) int init_module(void) { return x(); }
179 #define module_exit(x) void cleanup_module(void) { x(); }
182 /* Generic cmpxchg added in 2.3.x */
183 #ifndef __HAVE_ARCH_CMPXCHG
184 /* Include this here so that driver can be
185 used with older kernels. */
186 #if defined(__alpha__)
187 static __inline__ unsigned long
188 __cmpxchg_u32(volatile int *m, int old, int new)
190 unsigned long prev, cmp;
192 __asm__ __volatile__(
203 : "=&r"(prev), "=&r"(cmp), "=m"(*m)
204 : "r"((long) old), "r"(new), "m"(*m));
209 static __inline__ unsigned long
210 __cmpxchg_u64(volatile long *m, unsigned long old, unsigned long new)
212 unsigned long prev, cmp;
214 __asm__ __volatile__(
225 : "=&r"(prev), "=&r"(cmp), "=m"(*m)
226 : "r"((long) old), "r"(new), "m"(*m));
231 static __inline__ unsigned long
232 __cmpxchg(volatile void *ptr, unsigned long old, unsigned long new, int size)
236 return __cmpxchg_u32(ptr, old, new);
238 return __cmpxchg_u64(ptr, old, new);
242 #define cmpxchg(ptr,o,n) \
244 __typeof__(*(ptr)) _o_ = (o); \
245 __typeof__(*(ptr)) _n_ = (n); \
246 (__typeof__(*(ptr))) __cmpxchg((ptr), (unsigned long)_o_, \
247 (unsigned long)_n_, sizeof(*(ptr))); \
251 static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old,
252 unsigned long new, int size)
257 __asm__ __volatile__(LOCK_PREFIX "cmpxchgb %b1,%2"
259 : "q"(new), "m"(*__xg(ptr)), "0"(old)
263 __asm__ __volatile__(LOCK_PREFIX "cmpxchgw %w1,%2"
265 : "q"(new), "m"(*__xg(ptr)), "0"(old)
269 __asm__ __volatile__(LOCK_PREFIX "cmpxchgl %1,%2"
271 : "q"(new), "m"(*__xg(ptr)), "0"(old)
278 #define cmpxchg(ptr,o,n) \
279 ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o), \
280 (unsigned long)(n),sizeof(*(ptr))))
281 #endif /* i386 & alpha */
284 /* Macros to make printk easier */
285 #define DRM_ERROR(fmt, arg...) \
286 printk(KERN_ERR "[" DRM_NAME ":" __FUNCTION__ "] *ERROR* " fmt , ##arg)
287 #define DRM_MEM_ERROR(area, fmt, arg...) \
288 printk(KERN_ERR "[" DRM_NAME ":" __FUNCTION__ ":%s] *ERROR* " fmt , \
289 DRM(mem_stats)[area].name , ##arg)
290 #define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)
293 #define DRM_DEBUG(fmt, arg...) \
295 if ( DRM(flags) & DRM_FLAG_DEBUG ) \
297 "[" DRM_NAME ":" __FUNCTION__ "] " fmt , \
301 #define DRM_DEBUG(fmt, arg...) do { } while (0)
304 #define DRM_PROC_LIMIT (PAGE_SIZE-80)
306 #define DRM_PROC_PRINT(fmt, arg...) \
307 len += sprintf(&buf[len], fmt , ##arg); \
308 if (len > DRM_PROC_LIMIT) { *eof = 1; return len - offset; }
310 #define DRM_PROC_PRINT_RET(ret, fmt, arg...) \
311 len += sprintf(&buf[len], fmt , ##arg); \
312 if (len > DRM_PROC_LIMIT) { ret; *eof = 1; return len - offset; }
314 /* Mapping helper macros */
315 #define DRM_IOREMAP(map) \
316 (map)->handle = DRM(ioremap)( (map)->offset, (map)->size )
318 #define DRM_IOREMAPFREE(map) \
320 if ( (map)->handle && (map)->size ) \
321 DRM(ioremapfree)( (map)->handle, (map)->size ); \
324 #define DRM_FIND_MAP(map, o) \
327 for ( i = 0 ; i < dev->map_count ; i++ ) { \
328 if ( dev->maplist[i]->offset == o ) { \
329 map = dev->maplist[i]; \
335 /* Internal types and structures */
336 #define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
337 #define DRM_MIN(a,b) ((a)<(b)?(a):(b))
338 #define DRM_MAX(a,b) ((a)>(b)?(a):(b))
340 #define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
341 #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
342 #define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)
344 typedef int drm_ioctl_t( struct inode *inode, struct file *filp,
345 unsigned int cmd, unsigned long arg );
347 typedef struct drm_ioctl_desc {
353 typedef struct drm_devstate {
354 pid_t owner; /* X server pid holding x_lock */
358 typedef struct drm_magic_entry {
360 struct drm_file *priv;
361 struct drm_magic_entry *next;
364 typedef struct drm_magic_head {
365 struct drm_magic_entry *head;
366 struct drm_magic_entry *tail;
369 typedef struct drm_vma_entry {
370 struct vm_area_struct *vma;
371 struct drm_vma_entry *next;
375 typedef struct drm_buf {
376 int idx; /* Index into master buflist */
377 int total; /* Buffer size */
378 int order; /* log-base-2(total) */
379 int used; /* Amount of buffer in use (for DMA) */
380 unsigned long offset; /* Byte offset (used internally) */
381 void *address; /* Address of buffer */
382 unsigned long bus_address; /* Bus address of buffer */
383 struct drm_buf *next; /* Kernel-only: used for free list */
384 __volatile__ int waiting; /* On kernel DMA queue */
385 __volatile__ int pending; /* On hardware DMA queue */
386 wait_queue_head_t dma_wait; /* Processes waiting */
387 pid_t pid; /* PID of holding process */
388 int context; /* Kernel queue for this buffer */
389 int while_locked;/* Dispatch this buffer while locked */
397 } list; /* Which list we're on */
399 #if DRM_DMA_HISTOGRAM
400 cycles_t time_queued; /* Queued to kernel DMA queue */
401 cycles_t time_dispatched; /* Dispatched to hardware */
402 cycles_t time_completed; /* Completed by hardware */
403 cycles_t time_freed; /* Back on freelist */
406 int dev_priv_size; /* Size of buffer private stoarge */
407 void *dev_private; /* Per-buffer private storage */
410 #if DRM_DMA_HISTOGRAM
411 #define DRM_DMA_HISTOGRAM_SLOTS 9
412 #define DRM_DMA_HISTOGRAM_INITIAL 10
413 #define DRM_DMA_HISTOGRAM_NEXT(current) ((current)*10)
414 typedef struct drm_histogram {
417 atomic_t queued_to_dispatched[DRM_DMA_HISTOGRAM_SLOTS];
418 atomic_t dispatched_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
419 atomic_t completed_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
421 atomic_t queued_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
422 atomic_t queued_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
424 atomic_t dma[DRM_DMA_HISTOGRAM_SLOTS];
425 atomic_t schedule[DRM_DMA_HISTOGRAM_SLOTS];
426 atomic_t ctx[DRM_DMA_HISTOGRAM_SLOTS];
427 atomic_t lacq[DRM_DMA_HISTOGRAM_SLOTS];
428 atomic_t lhld[DRM_DMA_HISTOGRAM_SLOTS];
432 /* bufs is one longer than it has to be */
433 typedef struct drm_waitlist {
434 int count; /* Number of possible buffers */
435 drm_buf_t **bufs; /* List of pointers to buffers */
436 drm_buf_t **rp; /* Read pointer */
437 drm_buf_t **wp; /* Write pointer */
438 drm_buf_t **end; /* End pointer */
439 spinlock_t read_lock;
440 spinlock_t write_lock;
443 typedef struct drm_freelist {
444 int initialized; /* Freelist in use */
445 atomic_t count; /* Number of free buffers */
446 drm_buf_t *next; /* End pointer */
448 wait_queue_head_t waiting; /* Processes waiting on free bufs */
449 int low_mark; /* Low water mark */
450 int high_mark; /* High water mark */
451 atomic_t wfh; /* If waiting for high mark */
455 typedef struct drm_buf_entry {
461 unsigned long *seglist;
463 drm_freelist_t freelist;
466 typedef struct drm_hw_lock {
467 __volatile__ unsigned int lock;
468 char padding[60]; /* Pad to cache line */
471 typedef struct drm_file {
477 unsigned long ioctl_count;
478 struct drm_file *next;
479 struct drm_file *prev;
480 struct drm_device *dev;
481 int remove_auth_on_close;
485 typedef struct drm_queue {
486 atomic_t use_count; /* Outstanding uses (+1) */
487 atomic_t finalization; /* Finalization in progress */
488 atomic_t block_count; /* Count of processes waiting */
489 atomic_t block_read; /* Queue blocked for reads */
490 wait_queue_head_t read_queue; /* Processes waiting on block_read */
491 atomic_t block_write; /* Queue blocked for writes */
492 wait_queue_head_t write_queue; /* Processes waiting on block_write */
494 atomic_t total_queued; /* Total queued statistic */
495 atomic_t total_flushed;/* Total flushes statistic */
496 atomic_t total_locks; /* Total locks statistics */
498 drm_ctx_flags_t flags; /* Context preserving and 2D-only */
499 drm_waitlist_t waitlist; /* Pending buffers */
500 wait_queue_head_t flush_queue; /* Processes waiting until flush */
503 typedef struct drm_lock_data {
504 drm_hw_lock_t *hw_lock; /* Hardware lock */
505 pid_t pid; /* PID of lock holder (0=kernel) */
506 wait_queue_head_t lock_queue; /* Queue of blocked processes */
507 unsigned long lock_time; /* Time of last lock in jiffies */
510 typedef struct drm_device_dma {
512 /* Performance Counters */
513 atomic_t total_prio; /* Total DRM_DMA_PRIORITY */
514 atomic_t total_bytes; /* Total bytes DMA'd */
515 atomic_t total_dmas; /* Total DMA buffers dispatched */
517 atomic_t total_missed_dma; /* Missed drm_do_dma */
518 atomic_t total_missed_lock; /* Missed lock in drm_do_dma */
519 atomic_t total_missed_free; /* Missed drm_free_this_buffer */
520 atomic_t total_missed_sched;/* Missed drm_dma_schedule */
522 atomic_t total_tried; /* Tried next_buffer */
523 atomic_t total_hit; /* Sent next_buffer */
524 atomic_t total_lost; /* Lost interrupt */
527 drm_buf_entry_t bufs[DRM_MAX_ORDER+1];
529 drm_buf_t **buflist; /* Vector of pointers info bufs */
532 unsigned long *pagelist;
533 unsigned long byte_count;
535 _DRM_DMA_USE_AGP = 0x01
539 drm_buf_t *this_buffer; /* Buffer being sent */
540 drm_buf_t *next_buffer; /* Selected buffer to send */
541 drm_queue_t *next_queue; /* Queue from which buffer selected*/
542 wait_queue_head_t waiting; /* Processes waiting on free bufs */
545 #if __REALLY_HAVE_AGP
546 typedef struct drm_agp_mem {
547 unsigned long handle;
549 unsigned long bound; /* address */
551 struct drm_agp_mem *prev;
552 struct drm_agp_mem *next;
555 typedef struct drm_agp_head {
556 agp_kern_info agp_info;
558 drm_agp_mem_t *memory;
567 typedef struct drm_sigdata {
572 typedef struct drm_device {
573 const char *name; /* Simple driver name */
574 char *unique; /* Unique identifier: e.g., busid */
575 int unique_len; /* Length of unique field */
576 dev_t device; /* Device number for mknod */
577 char *devname; /* For /proc/interrupts */
579 int blocked; /* Blocked due to VC switch? */
580 struct proc_dir_entry *root; /* Root for this device's entries */
583 spinlock_t count_lock; /* For inuse, open_count, buf_use */
584 struct semaphore struct_sem; /* For others */
587 int open_count; /* Outstanding files open */
588 atomic_t ioctl_count; /* Outstanding IOCTLs pending */
589 atomic_t vma_count; /* Outstanding vma areas open */
590 int buf_use; /* Buffers in use -- cannot alloc */
591 atomic_t buf_alloc; /* Buffer allocation in progress */
593 /* Performance counters */
594 unsigned long counters;
595 drm_stat_type_t types[15];
599 drm_file_t *file_first;
600 drm_file_t *file_last;
601 drm_magic_head_t magiclist[DRM_HASH_SIZE];
603 /* Memory management */
604 drm_map_t **maplist; /* Vector of pointers to regions */
605 int map_count; /* Number of mappable regions */
607 drm_vma_entry_t *vmalist; /* List of vmas (for debugging) */
608 drm_lock_data_t lock; /* Information on hardware lock */
610 /* DMA queues (contexts) */
611 int queue_count; /* Number of active DMA queues */
612 int queue_reserved; /* Number of reserved DMA queues */
613 int queue_slots; /* Actual length of queuelist */
614 drm_queue_t **queuelist; /* Vector of pointers to DMA queues */
615 drm_device_dma_t *dma; /* Optional pointer for DMA support */
617 /* Context support */
618 int irq; /* Interrupt used by board */
619 __volatile__ long context_flag; /* Context swapping flag */
620 __volatile__ long interrupt_flag; /* Interruption handler flag */
621 __volatile__ long dma_flag; /* DMA dispatch flag */
622 struct timer_list timer; /* Timer for delaying ctx switch */
623 wait_queue_head_t context_wait; /* Processes waiting on ctx switch */
624 int last_checked; /* Last context checked for DMA */
625 int last_context; /* Last current context */
626 unsigned long last_switch; /* jiffies at last context switch */
630 #if DRM_DMA_HISTOGRAM
631 drm_histogram_t histo;
634 /* Callback to X server for context switch
635 and for heavy-handed reset. */
636 char buf[DRM_BSZ]; /* Output buffer */
637 char *buf_rp; /* Read pointer */
638 char *buf_wp; /* Write pointer */
639 char *buf_end; /* End pointer */
640 struct fasync_struct *buf_async;/* Processes waiting for SIGIO */
641 wait_queue_head_t buf_readers; /* Processes waiting to read */
642 wait_queue_head_t buf_writers; /* Processes waiting to ctx switch */
644 #if __REALLY_HAVE_AGP
647 unsigned long *ctx_bitmap;
649 drm_sigdata_t sigdata; /* For block_all_signals */
654 /* Internal function definitions */
656 /* Misc. support (init.c) */
657 extern int DRM(flags);
658 extern void DRM(parse_options)( char *s );
659 extern int DRM(cpu_valid)( void );
661 /* Driver support (drm_drv.h) */
662 extern int DRM(version)(struct inode *inode, struct file *filp,
663 unsigned int cmd, unsigned long arg);
664 extern int DRM(open)(struct inode *inode, struct file *filp);
665 extern int DRM(release)(struct inode *inode, struct file *filp);
666 extern int DRM(ioctl)(struct inode *inode, struct file *filp,
667 unsigned int cmd, unsigned long arg);
668 extern int DRM(lock)(struct inode *inode, struct file *filp,
669 unsigned int cmd, unsigned long arg);
670 extern int DRM(unlock)(struct inode *inode, struct file *filp,
671 unsigned int cmd, unsigned long arg);
673 /* Device support (fops.c) */
674 extern int DRM(open_helper)(struct inode *inode, struct file *filp,
676 extern int DRM(flush)(struct file *filp);
677 extern int DRM(release_fuck)(struct inode *inode, struct file *filp);
678 extern int DRM(fasync)(int fd, struct file *filp, int on);
679 extern ssize_t DRM(read)(struct file *filp, char *buf, size_t count,
681 extern int DRM(write_string)(drm_device_t *dev, const char *s);
682 extern unsigned int DRM(poll)(struct file *filp,
683 struct poll_table_struct *wait);
685 /* Mapping support (vm.c) */
686 #if LINUX_VERSION_CODE < 0x020317
687 extern unsigned long DRM(vm_nopage)(struct vm_area_struct *vma,
688 unsigned long address,
690 extern unsigned long DRM(vm_shm_nopage)(struct vm_area_struct *vma,
691 unsigned long address,
693 extern unsigned long DRM(vm_shm_nopage_lock)(struct vm_area_struct *vma,
694 unsigned long address,
696 extern unsigned long DRM(vm_dma_nopage)(struct vm_area_struct *vma,
697 unsigned long address,
700 /* Return type changed in 2.3.23 */
701 extern struct page *DRM(vm_nopage)(struct vm_area_struct *vma,
702 unsigned long address,
704 extern struct page *DRM(vm_shm_nopage)(struct vm_area_struct *vma,
705 unsigned long address,
707 extern struct page *DRM(vm_shm_nopage_lock)(struct vm_area_struct *vma,
708 unsigned long address,
710 extern struct page *DRM(vm_dma_nopage)(struct vm_area_struct *vma,
711 unsigned long address,
714 extern void DRM(vm_open)(struct vm_area_struct *vma);
715 extern void DRM(vm_close)(struct vm_area_struct *vma);
716 extern int DRM(mmap_dma)(struct file *filp,
717 struct vm_area_struct *vma);
718 extern int DRM(mmap)(struct file *filp, struct vm_area_struct *vma);
721 /* Proc support (proc.c) */
722 extern struct proc_dir_entry *drm_proc_init(drm_device_t *dev,
724 struct proc_dir_entry *root,
725 struct proc_dir_entry **dev_root);
726 extern int drm_proc_cleanup(int minor,
727 struct proc_dir_entry *root,
728 struct proc_dir_entry *dev_root);
730 /* Memory management support (memory.c) */
731 extern void DRM(mem_init)(void);
732 extern int DRM(mem_info)(char *buf, char **start, off_t offset,
733 int request, int *eof, void *data);
734 extern void *DRM(alloc)(size_t size, int area);
735 extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
737 extern char *DRM(strdup)(const char *s, int area);
738 extern void DRM(strfree)(const char *s, int area);
739 extern void DRM(free)(void *pt, size_t size, int area);
740 extern unsigned long DRM(alloc_pages)(int order, int area);
741 extern void DRM(free_pages)(unsigned long address, int order,
743 extern void *DRM(ioremap)(unsigned long offset, unsigned long size);
744 extern void DRM(ioremapfree)(void *pt, unsigned long size);
746 #if __REALLY_HAVE_AGP
747 extern agp_memory *DRM(alloc_agp)(int pages, u32 type);
748 extern int DRM(free_agp)(agp_memory *handle, int pages);
749 extern int DRM(bind_agp)(agp_memory *handle, unsigned int start);
750 extern int DRM(unbind_agp)(agp_memory *handle);
753 /* Misc. IOCTL support (ioctl.c) */
754 extern int DRM(irq_busid)(struct inode *inode, struct file *filp,
755 unsigned int cmd, unsigned long arg);
756 extern int DRM(getunique)(struct inode *inode, struct file *filp,
757 unsigned int cmd, unsigned long arg);
758 extern int DRM(setunique)(struct inode *inode, struct file *filp,
759 unsigned int cmd, unsigned long arg);
760 extern int DRM(getmap)(struct inode *inode, struct file *filp,
761 unsigned int cmd, unsigned long arg);
762 extern int DRM(getclient)(struct inode *inode, struct file *filp,
763 unsigned int cmd, unsigned long arg);
764 extern int DRM(getstats)(struct inode *inode, struct file *filp,
765 unsigned int cmd, unsigned long arg);
767 /* Context IOCTL support (context.c) */
768 extern int DRM(resctx)( struct inode *inode, struct file *filp,
769 unsigned int cmd, unsigned long arg );
770 extern int DRM(addctx)( struct inode *inode, struct file *filp,
771 unsigned int cmd, unsigned long arg );
772 extern int DRM(modctx)( struct inode *inode, struct file *filp,
773 unsigned int cmd, unsigned long arg );
774 extern int DRM(getctx)( struct inode *inode, struct file *filp,
775 unsigned int cmd, unsigned long arg );
776 extern int DRM(switchctx)( struct inode *inode, struct file *filp,
777 unsigned int cmd, unsigned long arg );
778 extern int DRM(newctx)( struct inode *inode, struct file *filp,
779 unsigned int cmd, unsigned long arg );
780 extern int DRM(rmctx)( struct inode *inode, struct file *filp,
781 unsigned int cmd, unsigned long arg );
783 extern int DRM(context_switch)(drm_device_t *dev, int old, int new);
784 extern int DRM(context_switch_complete)(drm_device_t *dev, int new);
786 /* Drawable IOCTL support (drawable.c) */
787 extern int DRM(adddraw)(struct inode *inode, struct file *filp,
788 unsigned int cmd, unsigned long arg);
789 extern int DRM(rmdraw)(struct inode *inode, struct file *filp,
790 unsigned int cmd, unsigned long arg);
793 /* Authentication IOCTL support (auth.c) */
794 extern int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv,
796 extern int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic);
797 extern int DRM(getmagic)(struct inode *inode, struct file *filp,
798 unsigned int cmd, unsigned long arg);
799 extern int DRM(authmagic)(struct inode *inode, struct file *filp,
800 unsigned int cmd, unsigned long arg);
803 /* Locking IOCTL support (lock.c) */
804 extern int DRM(block)(struct inode *inode, struct file *filp,
805 unsigned int cmd, unsigned long arg);
806 extern int DRM(unblock)(struct inode *inode, struct file *filp,
807 unsigned int cmd, unsigned long arg);
808 extern int DRM(lock_take)(__volatile__ unsigned int *lock,
809 unsigned int context);
810 extern int DRM(lock_transfer)(drm_device_t *dev,
811 __volatile__ unsigned int *lock,
812 unsigned int context);
813 extern int DRM(lock_free)(drm_device_t *dev,
814 __volatile__ unsigned int *lock,
815 unsigned int context);
816 extern int DRM(finish)(struct inode *inode, struct file *filp,
817 unsigned int cmd, unsigned long arg);
818 extern int DRM(flush_unblock)(drm_device_t *dev, int context,
819 drm_lock_flags_t flags);
820 extern int DRM(flush_block_and_flush)(drm_device_t *dev, int context,
821 drm_lock_flags_t flags);
822 extern int DRM(notifier)(void *priv);
824 /* Context Bitmap support (ctxbitmap.c) */
825 extern int DRM(ctxbitmap_init)( drm_device_t *dev );
826 extern void DRM(ctxbitmap_cleanup)( drm_device_t *dev );
831 /* Buffer management support (bufs.c) */
832 extern int DRM(order)( unsigned long size );
833 extern int DRM(addmap)( struct inode *inode, struct file *filp,
834 unsigned int cmd, unsigned long arg );
835 extern int DRM(addbufs)( struct inode *inode, struct file *filp,
836 unsigned int cmd, unsigned long arg );
837 extern int DRM(infobufs)( struct inode *inode, struct file *filp,
838 unsigned int cmd, unsigned long arg );
839 extern int DRM(markbufs)( struct inode *inode, struct file *filp,
840 unsigned int cmd, unsigned long arg );
841 extern int DRM(freebufs)( struct inode *inode, struct file *filp,
842 unsigned int cmd, unsigned long arg );
843 extern int DRM(mapbufs)( struct inode *inode, struct file *filp,
844 unsigned int cmd, unsigned long arg );
848 /* DMA support (dma.c) */
849 extern int DRM(dma_setup)(drm_device_t *dev);
850 extern void DRM(dma_takedown)(drm_device_t *dev);
851 extern void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf);
852 extern void DRM(reclaim_buffers)(drm_device_t *dev, pid_t pid);
853 extern void DRM(clear_next_buffer)(drm_device_t *dev);
854 extern int DRM(select_queue)(drm_device_t *dev,
855 void (*wrapper)(unsigned long));
856 extern int DRM(dma_enqueue)(drm_device_t *dev, drm_dma_t *dma);
858 extern int DRM(dma_get_buffers)(drm_device_t *dev, drm_dma_t *dma);
860 #if DRM_DMA_HISTOGRAM
861 extern int DRM(histogram_slot)(unsigned long count);
862 extern void DRM(histogram_compute)(drm_device_t *dev, drm_buf_t *buf);
866 /* Buffer list management support (lists.c) */
867 #if __HAVE_DMA_WAITLIST
868 extern int DRM(waitlist_create)(drm_waitlist_t *bl, int count);
869 extern int DRM(waitlist_destroy)(drm_waitlist_t *bl);
870 extern int DRM(waitlist_put)(drm_waitlist_t *bl, drm_buf_t *buf);
871 extern drm_buf_t *DRM(waitlist_get)(drm_waitlist_t *bl);
873 #if __HAVE_DMA_FREELIST
874 extern int DRM(freelist_create)(drm_freelist_t *bl, int count);
875 extern int DRM(freelist_destroy)(drm_freelist_t *bl);
876 extern int DRM(freelist_put)(drm_device_t *dev, drm_freelist_t *bl,
878 extern drm_buf_t *DRM(freelist_get)(drm_freelist_t *bl, int block);
881 #if __REALLY_HAVE_AGP
882 /* AGP/GART support (agpsupport.c) */
883 extern drm_agp_head_t *DRM(agp_init)(void);
884 extern void DRM(agp_uninit)(void);
885 extern int DRM(agp_acquire)(struct inode *inode, struct file *filp,
886 unsigned int cmd, unsigned long arg);
887 extern void DRM(agp_do_release)(void);
888 extern int DRM(agp_release)(struct inode *inode, struct file *filp,
889 unsigned int cmd, unsigned long arg);
890 extern int DRM(agp_enable)(struct inode *inode, struct file *filp,
891 unsigned int cmd, unsigned long arg);
892 extern int DRM(agp_info)(struct inode *inode, struct file *filp,
893 unsigned int cmd, unsigned long arg);
894 extern int DRM(agp_alloc)(struct inode *inode, struct file *filp,
895 unsigned int cmd, unsigned long arg);
896 extern int DRM(agp_free)(struct inode *inode, struct file *filp,
897 unsigned int cmd, unsigned long arg);
898 extern int DRM(agp_unbind)(struct inode *inode, struct file *filp,
899 unsigned int cmd, unsigned long arg);
900 extern int DRM(agp_bind)(struct inode *inode, struct file *filp,
901 unsigned int cmd, unsigned long arg);
902 extern agp_memory *DRM(agp_allocate_memory)(size_t pages, u32 type);
903 extern int DRM(agp_free_memory)(agp_memory *handle);
904 extern int DRM(agp_bind_memory)(agp_memory *handle, off_t start);
905 extern int DRM(agp_unbind_memory)(agp_memory *handle);
907 /* Stub support (drm_stub.h) */
908 int DRM(stub_register)(const char *name,
909 struct file_operations *fops,
911 int DRM(stub_unregister)(int minor);