3 * Private header for Direct Rendering Manager
5 * \author Rickard E. (Rik) Faith <faith@valinux.com>
6 * \author Gareth Hughes <gareth@valinux.com>
10 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
11 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
12 * All rights reserved.
14 * Permission is hereby granted, free of charge, to any person obtaining a
15 * copy of this software and associated documentation files (the "Software"),
16 * to deal in the Software without restriction, including without limitation
17 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
18 * and/or sell copies of the Software, and to permit persons to whom the
19 * Software is furnished to do so, subject to the following conditions:
21 * The above copyright notice and this permission notice (including the next
22 * paragraph) shall be included in all copies or substantial portions of the
25 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
26 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
27 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
28 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
29 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
30 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
31 * OTHER DEALINGS IN THE SOFTWARE.
40 /* add include of current.h so that "current" is defined
41 * before static inline funcs in wait.h. Doing this so we
42 * can build the DRM (part of PI DRI). 4/21/2000 S + B */
43 #include <asm/current.h>
44 #endif /* __alpha__ */
45 #include <linux/config.h>
46 #include <linux/module.h>
47 #include <linux/kernel.h>
48 #include <linux/miscdevice.h>
50 #include <linux/proc_fs.h>
51 #include <linux/init.h>
52 #include <linux/file.h>
53 #include <linux/pci.h>
54 #include <linux/version.h>
55 #include <linux/jiffies.h>
56 #include <linux/smp_lock.h> /* For (un)lock_kernel */
58 #if defined(__alpha__) || defined(__powerpc__)
59 #include <asm/pgtable.h> /* For pte_wrprotect */
63 #include <asm/uaccess.h>
67 #if defined(CONFIG_AGP) || defined(CONFIG_AGP_MODULE)
68 #include <linux/types.h>
69 #include <linux/agp_backend.h>
71 #include <linux/workqueue.h>
72 #include <linux/poll.h>
73 #include <asm/pgalloc.h>
76 #include "drm_os_linux.h"
79 /***********************************************************************/
80 /** \name DRM template customization defaults */
89 #ifndef __HAVE_CTX_BITMAP
90 #define __HAVE_CTX_BITMAP 0
95 #ifndef __HAVE_DMA_IRQ
96 #define __HAVE_DMA_IRQ 0
98 #ifndef __HAVE_DMA_WAITLIST
99 #define __HAVE_DMA_WAITLIST 0
101 #ifndef __HAVE_DMA_FREELIST
102 #define __HAVE_DMA_FREELIST 0
105 #define __REALLY_HAVE_AGP (__HAVE_AGP && (defined(CONFIG_AGP) || \
106 defined(CONFIG_AGP_MODULE)))
107 #define __REALLY_HAVE_MTRR (__HAVE_MTRR && defined(CONFIG_MTRR))
108 #define __REALLY_HAVE_SG (__HAVE_SG)
113 /***********************************************************************/
114 /** \name Begin the DRM... */
117 #define DRM_DEBUG_CODE 2 /**< Include debugging code if > 1, then
118 also include looping detection. */
120 #define DRM_HASH_SIZE 16 /**< Size of key hash table. Must be power of 2. */
121 #define DRM_KERNEL_CONTEXT 0 /**< Change drm_resctx if changed */
122 #define DRM_RESERVED_CONTEXTS 1 /**< Change drm_resctx if changed */
123 #define DRM_LOOPING_LIMIT 5000000
124 #define DRM_BSZ 1024 /**< Buffer size for /dev/drm? output */
125 #define DRM_TIME_SLICE (HZ/20) /**< Time slice for GLXContexts */
126 #define DRM_LOCK_SLICE 1 /**< Time slice for lock, in jiffies */
128 #define DRM_FLAG_DEBUG 0x01
130 #define DRM_MEM_DMA 0
131 #define DRM_MEM_SAREA 1
132 #define DRM_MEM_DRIVER 2
133 #define DRM_MEM_MAGIC 3
134 #define DRM_MEM_IOCTLS 4
135 #define DRM_MEM_MAPS 5
136 #define DRM_MEM_VMAS 6
137 #define DRM_MEM_BUFS 7
138 #define DRM_MEM_SEGS 8
139 #define DRM_MEM_PAGES 9
140 #define DRM_MEM_FILES 10
141 #define DRM_MEM_QUEUES 11
142 #define DRM_MEM_CMDS 12
143 #define DRM_MEM_MAPPINGS 13
144 #define DRM_MEM_BUFLISTS 14
145 #define DRM_MEM_AGPLISTS 15
146 #define DRM_MEM_TOTALAGP 16
147 #define DRM_MEM_BOUNDAGP 17
148 #define DRM_MEM_CTXBITMAP 18
149 #define DRM_MEM_STUB 19
150 #define DRM_MEM_SGLISTS 20
152 #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
157 /***********************************************************************/
158 /** \name Backward compatibility section */
161 #ifndef MODULE_LICENSE
162 #define MODULE_LICENSE(x)
165 #ifndef preempt_disable
166 #define preempt_disable()
167 #define preempt_enable()
170 #ifndef pte_offset_map
171 #define pte_offset_map pte_offset
172 #define pte_unmap(pte)
175 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,19)
176 static inline struct page * vmalloc_to_page(void * vmalloc_addr)
178 unsigned long addr = (unsigned long) vmalloc_addr;
179 struct page *page = NULL;
180 pgd_t *pgd = pgd_offset_k(addr);
184 if (!pgd_none(*pgd)) {
185 pmd = pmd_offset(pgd, addr);
186 if (!pmd_none(*pmd)) {
188 ptep = pte_offset_map(pmd, addr);
190 if (pte_present(pte))
191 page = pte_page(pte);
200 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,5,0)
201 #define DRM_RPR_ARG(vma)
203 #define DRM_RPR_ARG(vma) vma,
206 #define VM_OFFSET(vma) ((vma)->vm_pgoff << PAGE_SHIFT)
211 /***********************************************************************/
212 /** \name Macros to make printk easier */
218 * \param fmt printf() like format string.
219 * \param arg arguments
221 #define DRM_ERROR(fmt, arg...) \
222 printk(KERN_ERR "[" DRM_NAME ":%s] *ERROR* " fmt , __FUNCTION__ , ##arg)
225 * Memory error output.
227 * \param area memory area where the error occurred.
228 * \param fmt printf() like format string.
229 * \param arg arguments
231 #define DRM_MEM_ERROR(area, fmt, arg...) \
232 printk(KERN_ERR "[" DRM_NAME ":%s:%s] *ERROR* " fmt , __FUNCTION__, \
233 DRM(mem_stats)[area].name , ##arg)
234 #define DRM_INFO(fmt, arg...) printk(KERN_INFO "[" DRM_NAME "] " fmt , ##arg)
239 * \param fmt printf() like format string.
240 * \param arg arguments
243 #define DRM_DEBUG(fmt, arg...) \
245 if ( DRM(flags) & DRM_FLAG_DEBUG ) \
247 "[" DRM_NAME ":%s] " fmt , \
248 __FUNCTION__ , ##arg); \
251 #define DRM_DEBUG(fmt, arg...) do { } while (0)
254 #define DRM_PROC_LIMIT (PAGE_SIZE-80)
256 #define DRM_PROC_PRINT(fmt, arg...) \
257 len += sprintf(&buf[len], fmt , ##arg); \
258 if (len > DRM_PROC_LIMIT) { *eof = 1; return len - offset; }
260 #define DRM_PROC_PRINT_RET(ret, fmt, arg...) \
261 len += sprintf(&buf[len], fmt , ##arg); \
262 if (len > DRM_PROC_LIMIT) { ret; *eof = 1; return len - offset; }
267 /***********************************************************************/
268 /** \name Mapping helper macros */
271 #define DRM_IOREMAP(map, dev) \
272 (map)->handle = DRM(ioremap)( (map)->offset, (map)->size, (dev) )
274 #define DRM_IOREMAP_NOCACHE(map, dev) \
275 (map)->handle = DRM(ioremap_nocache)((map)->offset, (map)->size, (dev))
277 #define DRM_IOREMAPFREE(map, dev) \
279 if ( (map)->handle && (map)->size ) \
280 DRM(ioremapfree)( (map)->handle, (map)->size, (dev) ); \
286 * \param _map matching mapping if found, untouched otherwise.
289 * Expects the existence of a local variable named \p dev pointing to the
290 * drm_device structure.
292 #define DRM_FIND_MAP(_map, _o) \
294 struct list_head *_list; \
295 list_for_each( _list, &dev->maplist->head ) { \
296 drm_map_list_t *_entry = list_entry( _list, drm_map_list_t, head ); \
297 if ( _entry->map && \
298 _entry->map->offset == (_o) ) { \
299 (_map) = _entry->map; \
310 #define DRM_DROP_MAP(_map)
315 /***********************************************************************/
316 /** \name Internal types and structures */
319 #define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
320 #define DRM_MIN(a,b) ((a)<(b)?(a):(b))
321 #define DRM_MAX(a,b) ((a)>(b)?(a):(b))
323 #define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
324 #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
325 #define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)
328 * Get the private SAREA mapping.
330 * \param _dev DRM device.
331 * \param _ctx context number.
332 * \param _map output mapping.
334 #define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do { \
335 (_map) = (_dev)->context_sareas[_ctx]; \
339 * Test that the hardware lock is held by the caller, returning otherwise.
341 * \param dev DRM device.
342 * \param filp file pointer of the caller.
344 #define LOCK_TEST_WITH_RETURN( dev, filp ) \
346 if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) || \
347 dev->lock.filp != filp ) { \
348 DRM_ERROR( "%s called without lock held\n", \
355 * Ioctl function type.
357 * \param inode device inode.
358 * \param filp file pointer.
359 * \param cmd command.
360 * \param arg argument.
362 typedef int drm_ioctl_t( struct inode *inode, struct file *filp,
363 unsigned int cmd, unsigned long arg );
365 typedef struct drm_pci_list {
370 typedef struct drm_ioctl_desc {
376 typedef struct drm_devstate {
377 pid_t owner; /**< X server pid holding x_lock */
380 typedef struct drm_magic_entry {
382 struct drm_file *priv;
383 struct drm_magic_entry *next;
386 typedef struct drm_magic_head {
387 struct drm_magic_entry *head;
388 struct drm_magic_entry *tail;
391 typedef struct drm_vma_entry {
392 struct vm_area_struct *vma;
393 struct drm_vma_entry *next;
400 typedef struct drm_buf {
401 int idx; /**< Index into master buflist */
402 int total; /**< Buffer size */
403 int order; /**< log-base-2(total) */
404 int used; /**< Amount of buffer in use (for DMA) */
405 unsigned long offset; /**< Byte offset (used internally) */
406 void *address; /**< Address of buffer */
407 unsigned long bus_address; /**< Bus address of buffer */
408 struct drm_buf *next; /**< Kernel-only: used for free list */
409 __volatile__ int waiting; /**< On kernel DMA queue */
410 __volatile__ int pending; /**< On hardware DMA queue */
411 wait_queue_head_t dma_wait; /**< Processes waiting */
412 struct file *filp; /**< Pointer to holding file descr */
413 int context; /**< Kernel queue for this buffer */
414 int while_locked;/**< Dispatch this buffer while locked */
422 } list; /**< Which list we're on */
424 int dev_priv_size; /**< Size of buffer private storage */
425 void *dev_private; /**< Per-buffer private storage */
429 /** bufs is one longer than it has to be */
430 typedef struct drm_waitlist {
431 int count; /**< Number of possible buffers */
432 drm_buf_t **bufs; /**< List of pointers to buffers */
433 drm_buf_t **rp; /**< Read pointer */
434 drm_buf_t **wp; /**< Write pointer */
435 drm_buf_t **end; /**< End pointer */
436 spinlock_t read_lock;
437 spinlock_t write_lock;
440 typedef struct drm_freelist {
441 int initialized; /**< Freelist in use */
442 atomic_t count; /**< Number of free buffers */
443 drm_buf_t *next; /**< End pointer */
445 wait_queue_head_t waiting; /**< Processes waiting on free bufs */
446 int low_mark; /**< Low water mark */
447 int high_mark; /**< High water mark */
448 atomic_t wfh; /**< If waiting for high mark */
453 * Buffer entry. There is one of this for each buffer size order.
455 typedef struct drm_buf_entry {
456 int buf_size; /**< size */
457 int buf_count; /**< number of buffers */
458 drm_buf_t *buflist; /**< buffer list */
461 unsigned long *seglist;
463 drm_freelist_t freelist;
469 * The lock structure is a simple cache-line aligned integer. To avoid
470 * processor bus contention on a multiprocessor system, there should not be any
471 * other data stored in the same cache line.
473 typedef struct drm_hw_lock {
474 __volatile__ unsigned int lock; /**< lock variable */
475 char padding[60]; /**< Pad to cache line */
478 /** File private data */
479 typedef struct drm_file {
485 unsigned long ioctl_count;
486 struct drm_file *next;
487 struct drm_file *prev;
488 struct drm_device *dev;
489 int remove_auth_on_close;
490 unsigned long lock_count;
494 typedef struct drm_queue {
495 atomic_t use_count; /**< Outstanding uses (+1) */
496 atomic_t finalization; /**< Finalization in progress */
497 atomic_t block_count; /**< Count of processes waiting */
498 atomic_t block_read; /**< Queue blocked for reads */
499 wait_queue_head_t read_queue; /**< Processes waiting on block_read */
500 atomic_t block_write; /**< Queue blocked for writes */
501 wait_queue_head_t write_queue; /**< Processes waiting on block_write */
503 atomic_t total_queued; /**< Total queued statistic */
504 atomic_t total_flushed;/**< Total flushes statistic */
505 atomic_t total_locks; /**< Total locks statistics */
507 drm_ctx_flags_t flags; /**< Context preserving and 2D-only */
508 drm_waitlist_t waitlist; /**< Pending buffers */
509 wait_queue_head_t flush_queue; /**< Processes waiting until flush */
515 typedef struct drm_lock_data {
516 drm_hw_lock_t *hw_lock; /**< Hardware lock */
517 struct file *filp; /**< File descr of lock holder (0=kernel) */
518 wait_queue_head_t lock_queue; /**< Queue of blocked processes */
519 unsigned long lock_time; /**< Time of last lock in jiffies */
525 typedef struct drm_device_dma {
527 drm_buf_entry_t bufs[DRM_MAX_ORDER+1]; /**< buffers, grouped by their size order */
528 int buf_count; /**< total number of buffers */
529 drm_buf_t **buflist; /**< Vector of pointers into drm_device_dma::bufs */
531 int page_count; /**< number of pages */
532 unsigned long *pagelist; /**< page list */
533 unsigned long byte_count;
535 _DRM_DMA_USE_AGP = 0x01,
536 _DRM_DMA_USE_SG = 0x02
539 /** \name DMA support */
541 drm_buf_t *this_buffer; /**< Buffer being sent */
542 drm_buf_t *next_buffer; /**< Selected buffer to send */
543 drm_queue_t *next_queue; /**< Queue from which buffer selected*/
544 wait_queue_head_t waiting; /**< Processes waiting on free bufs */
548 #if __REALLY_HAVE_AGP
550 * AGP memory entry. Stored as a doubly linked list.
552 typedef struct drm_agp_mem {
553 unsigned long handle; /**< handle */
555 unsigned long bound; /**< address */
557 struct drm_agp_mem *prev; /**< previous entry */
558 struct drm_agp_mem *next; /**< next entry */
564 * \sa DRM(agp_init)() and drm_device::agp.
566 typedef struct drm_agp_head {
567 DRM_AGP_KERN agp_info; /**< AGP device information */
568 drm_agp_mem_t *memory; /**< memory entries */
569 unsigned long mode; /**< AGP mode */
570 int enabled; /**< whether the AGP bus as been enabled */
571 int acquired; /**< whether the AGP device has been acquired */
574 int cant_use_aperture;
575 unsigned long page_mask;
580 * Scatter-gather memory.
582 typedef struct drm_sg_mem {
583 unsigned long handle;
586 struct page **pagelist;
590 typedef struct drm_sigdata {
598 typedef struct drm_map_list {
599 struct list_head head; /**< list head */
600 drm_map_t *map; /**< mapping */
603 typedef drm_map_t drm_local_map_t;
607 typedef struct drm_vbl_sig {
608 struct list_head head;
609 unsigned int sequence;
611 struct task_struct *task;
617 * DRM device structure.
619 typedef struct drm_device {
620 const char *name; /**< Simple driver name */
621 char *unique; /**< Unique identifier: e.g., busid */
622 int unique_len; /**< Length of unique field */
623 dev_t device; /**< Device number for mknod */
624 char *devname; /**< For /proc/interrupts */
626 int blocked; /**< Blocked due to VC switch? */
627 struct proc_dir_entry *root; /**< Root for this device's entries */
631 spinlock_t count_lock; /**< For inuse, drm_device::open_count, drm_device::buf_use */
632 struct semaphore struct_sem; /**< For others */
635 /** \name Usage Counters */
637 int open_count; /**< Outstanding files open */
638 atomic_t ioctl_count; /**< Outstanding IOCTLs pending */
639 atomic_t vma_count; /**< Outstanding vma areas open */
640 int buf_use; /**< Buffers in use -- cannot alloc */
641 atomic_t buf_alloc; /**< Buffer allocation in progress */
644 /** \name Performance counters */
646 unsigned long counters;
647 drm_stat_type_t types[15];
651 /** \name Authentication */
653 drm_file_t *file_first; /**< file list head */
654 drm_file_t *file_last; /**< file list tail */
655 drm_magic_head_t magiclist[DRM_HASH_SIZE]; /**< magic hash table */
658 /** \name Memory management */
660 drm_map_list_t *maplist; /**< Linked list of regions */
661 int map_count; /**< Number of mappable regions */
663 drm_map_t **context_sareas; /**< per-context SAREA's */
666 drm_vma_entry_t *vmalist; /**< List of vmas (for debugging) */
667 drm_lock_data_t lock; /**< Information on hardware lock */
670 /** \name DMA queues (contexts) */
672 int queue_count; /**< Number of active DMA queues */
673 int queue_reserved; /**< Number of reserved DMA queues */
674 int queue_slots; /**< Actual length of queuelist */
675 drm_queue_t **queuelist; /**< Vector of pointers to DMA queues */
676 drm_device_dma_t *dma; /**< Optional pointer for DMA support */
679 /** \name Context support */
681 int irq; /**< Interrupt used by board */
682 __volatile__ long context_flag; /**< Context swapping flag */
683 __volatile__ long interrupt_flag; /**< Interruption handler flag */
684 __volatile__ long dma_flag; /**< DMA dispatch flag */
685 struct timer_list timer; /**< Timer for delaying ctx switch */
686 wait_queue_head_t context_wait; /**< Processes waiting on ctx switch */
687 int last_checked; /**< Last context checked for DMA */
688 int last_context; /**< Last current context */
689 unsigned long last_switch; /**< jiffies at last context switch */
692 struct work_struct work;
693 /** \name VBLANK IRQ support */
696 wait_queue_head_t vbl_queue; /**< VBLANK wait queue */
697 atomic_t vbl_received;
699 drm_vbl_sig_t vbl_sigs; /**< signal list to send on VBLANK */
700 unsigned int vbl_pending;
706 char buf[DRM_BSZ]; /**< Output buffer */
707 char *buf_rp; /**< Read pointer */
708 char *buf_wp; /**< Write pointer */
709 char *buf_end; /**< End pointer */
710 struct fasync_struct *buf_async;/**< Processes waiting for SIGIO */
711 wait_queue_head_t buf_readers; /**< Processes waiting to read */
712 wait_queue_head_t buf_writers; /**< Processes waiting to ctx switch */
714 #if __REALLY_HAVE_AGP
715 drm_agp_head_t *agp; /**< AGP data */
717 struct pci_dev *pdev; /**< PCI device structure */
719 #if LINUX_VERSION_CODE < KERNEL_VERSION(2,4,3)
720 struct pci_controler *hose;
722 struct pci_controller *hose;
725 drm_sg_mem_t *sg; /**< Scatter gather memory */
726 unsigned long *ctx_bitmap; /**< context bitmap */
727 void *dev_private; /**< device private data */
728 drm_sigdata_t sigdata; /**< For block_all_signals */
733 /******************************************************************/
734 /** \name Internal function definitions */
737 /* Misc. support (drm_init.h) */
738 extern int DRM(flags);
739 extern void DRM(parse_options)( char *s );
740 extern int DRM(cpu_valid)( void );
742 /* Driver support (drm_drv.h) */
743 extern int DRM(version)(struct inode *inode, struct file *filp,
744 unsigned int cmd, unsigned long arg);
745 extern int DRM(open)(struct inode *inode, struct file *filp);
746 extern int DRM(release)(struct inode *inode, struct file *filp);
747 extern int DRM(ioctl)(struct inode *inode, struct file *filp,
748 unsigned int cmd, unsigned long arg);
749 extern int DRM(lock)(struct inode *inode, struct file *filp,
750 unsigned int cmd, unsigned long arg);
751 extern int DRM(unlock)(struct inode *inode, struct file *filp,
752 unsigned int cmd, unsigned long arg);
754 /* Device support (drm_fops.h) */
755 extern int DRM(open_helper)(struct inode *inode, struct file *filp,
757 extern int DRM(flush)(struct file *filp);
758 extern int DRM(fasync)(int fd, struct file *filp, int on);
760 /* Mapping support (drm_vm.h) */
761 extern struct page *DRM(vm_nopage)(struct vm_area_struct *vma,
762 unsigned long address,
764 extern struct page *DRM(vm_shm_nopage)(struct vm_area_struct *vma,
765 unsigned long address,
767 extern struct page *DRM(vm_dma_nopage)(struct vm_area_struct *vma,
768 unsigned long address,
770 extern struct page *DRM(vm_sg_nopage)(struct vm_area_struct *vma,
771 unsigned long address,
773 extern void DRM(vm_open)(struct vm_area_struct *vma);
774 extern void DRM(vm_close)(struct vm_area_struct *vma);
775 extern void DRM(vm_shm_close)(struct vm_area_struct *vma);
776 extern int DRM(mmap_dma)(struct file *filp,
777 struct vm_area_struct *vma);
778 extern int DRM(mmap)(struct file *filp, struct vm_area_struct *vma);
779 extern unsigned int DRM(poll)(struct file *filp, struct poll_table_struct *wait);
780 extern ssize_t DRM(read)(struct file *filp, char *buf, size_t count, loff_t *off);
782 /* Memory management support (drm_memory.h) */
783 extern void DRM(mem_init)(void);
784 extern int DRM(mem_info)(char *buf, char **start, off_t offset,
785 int request, int *eof, void *data);
786 extern void *DRM(alloc)(size_t size, int area);
787 extern void *DRM(calloc)(size_t nmemb, size_t size, int area);
788 extern void *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
790 extern void DRM(free)(void *pt, size_t size, int area);
791 extern unsigned long DRM(alloc_pages)(int order, int area);
792 extern void DRM(free_pages)(unsigned long address, int order,
794 extern void *DRM(ioremap)(unsigned long offset, unsigned long size, drm_device_t *dev);
795 extern void *DRM(ioremap_nocache)(unsigned long offset, unsigned long size,
797 extern void DRM(ioremapfree)(void *pt, unsigned long size, drm_device_t *dev);
799 #if __REALLY_HAVE_AGP
800 extern DRM_AGP_MEM *DRM(alloc_agp)(int pages, u32 type);
801 extern int DRM(free_agp)(DRM_AGP_MEM *handle, int pages);
802 extern int DRM(bind_agp)(DRM_AGP_MEM *handle, unsigned int start);
803 extern int DRM(unbind_agp)(DRM_AGP_MEM *handle);
806 /* Misc. IOCTL support (drm_ioctl.h) */
807 extern int DRM(irq_busid)(struct inode *inode, struct file *filp,
808 unsigned int cmd, unsigned long arg);
809 extern int DRM(getunique)(struct inode *inode, struct file *filp,
810 unsigned int cmd, unsigned long arg);
811 extern int DRM(setunique)(struct inode *inode, struct file *filp,
812 unsigned int cmd, unsigned long arg);
813 extern int DRM(getmap)(struct inode *inode, struct file *filp,
814 unsigned int cmd, unsigned long arg);
815 extern int DRM(getclient)(struct inode *inode, struct file *filp,
816 unsigned int cmd, unsigned long arg);
817 extern int DRM(getstats)(struct inode *inode, struct file *filp,
818 unsigned int cmd, unsigned long arg);
820 /* Context IOCTL support (drm_context.h) */
821 extern int DRM(resctx)( struct inode *inode, struct file *filp,
822 unsigned int cmd, unsigned long arg );
823 extern int DRM(addctx)( struct inode *inode, struct file *filp,
824 unsigned int cmd, unsigned long arg );
825 extern int DRM(modctx)( struct inode *inode, struct file *filp,
826 unsigned int cmd, unsigned long arg );
827 extern int DRM(getctx)( struct inode *inode, struct file *filp,
828 unsigned int cmd, unsigned long arg );
829 extern int DRM(switchctx)( struct inode *inode, struct file *filp,
830 unsigned int cmd, unsigned long arg );
831 extern int DRM(newctx)( struct inode *inode, struct file *filp,
832 unsigned int cmd, unsigned long arg );
833 extern int DRM(rmctx)( struct inode *inode, struct file *filp,
834 unsigned int cmd, unsigned long arg );
836 extern int DRM(context_switch)(drm_device_t *dev, int old, int new);
837 extern int DRM(context_switch_complete)(drm_device_t *dev, int new);
839 #if __HAVE_CTX_BITMAP
840 extern int DRM(ctxbitmap_init)( drm_device_t *dev );
841 extern void DRM(ctxbitmap_cleanup)( drm_device_t *dev );
844 extern int DRM(setsareactx)( struct inode *inode, struct file *filp,
845 unsigned int cmd, unsigned long arg );
846 extern int DRM(getsareactx)( struct inode *inode, struct file *filp,
847 unsigned int cmd, unsigned long arg );
849 /* Drawable IOCTL support (drm_drawable.h) */
850 extern int DRM(adddraw)(struct inode *inode, struct file *filp,
851 unsigned int cmd, unsigned long arg);
852 extern int DRM(rmdraw)(struct inode *inode, struct file *filp,
853 unsigned int cmd, unsigned long arg);
856 /* Authentication IOCTL support (drm_auth.h) */
857 extern int DRM(add_magic)(drm_device_t *dev, drm_file_t *priv,
859 extern int DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic);
860 extern int DRM(getmagic)(struct inode *inode, struct file *filp,
861 unsigned int cmd, unsigned long arg);
862 extern int DRM(authmagic)(struct inode *inode, struct file *filp,
863 unsigned int cmd, unsigned long arg);
865 /* Placeholder for ioctls past */
866 extern int DRM(noop)(struct inode *inode, struct file *filp,
867 unsigned int cmd, unsigned long arg);
869 /* Locking IOCTL support (drm_lock.h) */
870 extern int DRM(lock_take)(__volatile__ unsigned int *lock,
871 unsigned int context);
872 extern int DRM(lock_transfer)(drm_device_t *dev,
873 __volatile__ unsigned int *lock,
874 unsigned int context);
875 extern int DRM(lock_free)(drm_device_t *dev,
876 __volatile__ unsigned int *lock,
877 unsigned int context);
878 extern int DRM(notifier)(void *priv);
880 /* Buffer management support (drm_bufs.h) */
881 extern int DRM(order)( unsigned long size );
882 extern int DRM(addmap)( struct inode *inode, struct file *filp,
883 unsigned int cmd, unsigned long arg );
884 extern int DRM(rmmap)( struct inode *inode, struct file *filp,
885 unsigned int cmd, unsigned long arg );
887 extern int DRM(addbufs)( struct inode *inode, struct file *filp,
888 unsigned int cmd, unsigned long arg );
889 extern int DRM(infobufs)( struct inode *inode, struct file *filp,
890 unsigned int cmd, unsigned long arg );
891 extern int DRM(markbufs)( struct inode *inode, struct file *filp,
892 unsigned int cmd, unsigned long arg );
893 extern int DRM(freebufs)( struct inode *inode, struct file *filp,
894 unsigned int cmd, unsigned long arg );
895 extern int DRM(mapbufs)( struct inode *inode, struct file *filp,
896 unsigned int cmd, unsigned long arg );
898 /* DMA support (drm_dma.h) */
899 extern int DRM(dma_setup)(drm_device_t *dev);
900 extern void DRM(dma_takedown)(drm_device_t *dev);
901 extern void DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf);
902 extern void DRM(reclaim_buffers)( struct file *filp );
904 extern int DRM(control)( struct inode *inode, struct file *filp,
905 unsigned int cmd, unsigned long arg );
906 extern int DRM(irq_install)( drm_device_t *dev, int irq );
907 extern int DRM(irq_uninstall)( drm_device_t *dev );
908 extern irqreturn_t DRM(dma_service)( DRM_IRQ_ARGS );
909 extern void DRM(driver_irq_preinstall)( drm_device_t *dev );
910 extern void DRM(driver_irq_postinstall)( drm_device_t *dev );
911 extern void DRM(driver_irq_uninstall)( drm_device_t *dev );
913 extern int DRM(wait_vblank)(struct inode *inode, struct file *filp,
914 unsigned int cmd, unsigned long arg);
915 extern int DRM(vblank_wait)(drm_device_t *dev, unsigned int *vbl_seq);
916 extern void DRM(vbl_send_signals)( drm_device_t *dev );
918 #if __HAVE_DMA_IRQ_BH
919 extern void DRM(dma_immediate_bh)( void *dev );
923 #endif /* __HAVE_DMA */
925 #if __REALLY_HAVE_AGP
926 /* AGP/GART support (drm_agpsupport.h) */
927 extern drm_agp_head_t *DRM(agp_init)(void);
928 extern void DRM(agp_uninit)(void);
929 extern int DRM(agp_acquire)(struct inode *inode, struct file *filp,
930 unsigned int cmd, unsigned long arg);
931 extern void DRM(agp_do_release)(void);
932 extern int DRM(agp_release)(struct inode *inode, struct file *filp,
933 unsigned int cmd, unsigned long arg);
934 extern int DRM(agp_enable)(struct inode *inode, struct file *filp,
935 unsigned int cmd, unsigned long arg);
936 extern int DRM(agp_info)(struct inode *inode, struct file *filp,
937 unsigned int cmd, unsigned long arg);
938 extern int DRM(agp_alloc)(struct inode *inode, struct file *filp,
939 unsigned int cmd, unsigned long arg);
940 extern int DRM(agp_free)(struct inode *inode, struct file *filp,
941 unsigned int cmd, unsigned long arg);
942 extern int DRM(agp_unbind)(struct inode *inode, struct file *filp,
943 unsigned int cmd, unsigned long arg);
944 extern int DRM(agp_bind)(struct inode *inode, struct file *filp,
945 unsigned int cmd, unsigned long arg);
946 extern DRM_AGP_MEM *DRM(agp_allocate_memory)(size_t pages, u32 type);
947 extern int DRM(agp_free_memory)(DRM_AGP_MEM *handle);
948 extern int DRM(agp_bind_memory)(DRM_AGP_MEM *handle, off_t start);
949 extern int DRM(agp_unbind_memory)(DRM_AGP_MEM *handle);
952 /* Stub support (drm_stub.h) */
953 int DRM(stub_register)(const char *name,
954 struct file_operations *fops,
956 int DRM(stub_unregister)(int minor);
958 /* Proc support (drm_proc.h) */
959 extern struct proc_dir_entry *DRM(proc_init)(drm_device_t *dev,
961 struct proc_dir_entry *root,
962 struct proc_dir_entry **dev_root);
963 extern int DRM(proc_cleanup)(int minor,
964 struct proc_dir_entry *root,
965 struct proc_dir_entry *dev_root);
968 /* Scatter Gather Support (drm_scatter.h) */
969 extern void DRM(sg_cleanup)(drm_sg_mem_t *entry);
970 extern int DRM(sg_alloc)(struct inode *inode, struct file *filp,
971 unsigned int cmd, unsigned long arg);
972 extern int DRM(sg_free)(struct inode *inode, struct file *filp,
973 unsigned int cmd, unsigned long arg);
976 /* ATI PCIGART support (ati_pcigart.h) */
977 extern int DRM(ati_pcigart_init)(drm_device_t *dev,
979 dma_addr_t *bus_addr);
980 extern int DRM(ati_pcigart_cleanup)(drm_device_t *dev,
982 dma_addr_t bus_addr);
986 #endif /* __KERNEL__ */