]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - sys/dev/drm/drmP.h
This commit was generated by cvs2svn to compensate for changes in r98503,
[FreeBSD/FreeBSD.git] / sys / dev / drm / drmP.h
1 /* drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
2  * Created: Mon Jan  4 10:05:05 1999 by faith@precisioninsight.com
3  *
4  * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
5  * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
6  * All rights reserved.
7  *
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:
14  *
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
17  * Software.
18  *
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.
26  *
27  * Authors:
28  *    Rickard E. (Rik) Faith <faith@valinux.com>
29  *    Gareth Hughes <gareth@valinux.com>
30  *
31  * $FreeBSD$
32  */
33
34 #ifndef _DRM_P_H_
35 #define _DRM_P_H_
36
37 #if defined(_KERNEL) || defined(__KERNEL__)
38
39 /* DRM template customization defaults
40  */
41 #ifndef __HAVE_AGP
42 #define __HAVE_AGP              0
43 #endif
44 #ifndef __HAVE_MTRR
45 #define __HAVE_MTRR             0
46 #endif
47 #ifndef __HAVE_CTX_BITMAP
48 #define __HAVE_CTX_BITMAP       0
49 #endif
50 #ifndef __HAVE_DMA
51 #define __HAVE_DMA              0
52 #endif
53 #ifndef __HAVE_DMA_IRQ
54 #define __HAVE_DMA_IRQ          0
55 #endif
56 #ifndef __HAVE_DMA_WAITLIST
57 #define __HAVE_DMA_WAITLIST     0
58 #endif
59 #ifndef __HAVE_DMA_FREELIST
60 #define __HAVE_DMA_FREELIST     0
61 #endif
62 #ifndef __HAVE_DMA_HISTOGRAM
63 #define __HAVE_DMA_HISTOGRAM    0
64 #endif
65
66 #define DRM_DEBUG_CODE 0          /* Include debugging code (if > 1, then
67                                      also include looping detection. */
68
69 typedef struct drm_device drm_device_t;
70 typedef struct drm_file drm_file_t;
71
72 /* There's undoubtably more of this file to go into these OS dependent ones. */
73 #ifdef __linux__
74 #include "dev/drm/drm_os_linux.h"
75 #endif /* __linux__ */
76
77 #ifdef __FreeBSD__
78 #include "dev/drm/drm_os_freebsd.h"
79 #endif /* __FreeBSD__ */
80
81 #include "dev/drm/drm.h"
82
83 /* Begin the DRM... */
84
85 #define DRM_HASH_SIZE         16 /* Size of key hash table                */
86 #define DRM_KERNEL_CONTEXT    0  /* Change drm_resctx if changed          */
87 #define DRM_RESERVED_CONTEXTS 1  /* Change drm_resctx if changed          */
88 #define DRM_LOOPING_LIMIT     5000000
89 #define DRM_BSZ               1024 /* Buffer size for /dev/drm? output    */
90 #define DRM_LOCK_SLICE        1 /* Time slice for lock, in jiffies        */
91
92 #define DRM_FLAG_DEBUG    0x01
93 #define DRM_FLAG_NOCTX    0x02
94
95 #define DRM_MEM_DMA        0
96 #define DRM_MEM_SAREA      1
97 #define DRM_MEM_DRIVER     2
98 #define DRM_MEM_MAGIC      3
99 #define DRM_MEM_IOCTLS     4
100 #define DRM_MEM_MAPS       5
101 #define DRM_MEM_VMAS       6
102 #define DRM_MEM_BUFS       7
103 #define DRM_MEM_SEGS       8
104 #define DRM_MEM_PAGES      9
105 #define DRM_MEM_FILES     10
106 #define DRM_MEM_QUEUES    11
107 #define DRM_MEM_CMDS      12
108 #define DRM_MEM_MAPPINGS  13
109 #define DRM_MEM_BUFLISTS  14
110 #define DRM_MEM_AGPLISTS  15
111 #define DRM_MEM_TOTALAGP  16
112 #define DRM_MEM_BOUNDAGP  17
113 #define DRM_MEM_CTXBITMAP 18
114 #define DRM_MEM_STUB      19
115 #define DRM_MEM_SGLISTS   20
116
117 #define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
118
119                                 /* Mapping helper macros */
120 #define DRM_IOREMAP(map)                                                \
121         (map)->handle = DRM(ioremap)( (map)->offset, (map)->size )
122
123 #define DRM_IOREMAPFREE(map)                                            \
124         do {                                                            \
125                 if ( (map)->handle && (map)->size )                     \
126                         DRM(ioremapfree)( (map)->handle, (map)->size ); \
127         } while (0)
128
129                                 /* Internal types and structures */
130 #define DRM_ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
131 #define DRM_MIN(a,b) ((a)<(b)?(a):(b))
132 #define DRM_MAX(a,b) ((a)>(b)?(a):(b))
133
134 #define DRM_LEFTCOUNT(x) (((x)->rp + (x)->count - (x)->wp) % ((x)->count + 1))
135 #define DRM_BUFCOUNT(x) ((x)->count - DRM_LEFTCOUNT(x))
136 #define DRM_WAITCOUNT(dev,idx) DRM_BUFCOUNT(&dev->queuelist[idx]->waitlist)
137
138 #define DRM_GET_PRIV_SAREA(_dev, _ctx, _map) do {       \
139         (_map) = (_dev)->context_sareas[_ctx];          \
140 } while(0)
141
142 typedef int drm_ioctl_t( DRM_OS_IOCTL );
143
144 typedef struct drm_pci_list {
145         u16 vendor;
146         u16 device;
147 } drm_pci_list_t;
148
149 typedef struct drm_ioctl_desc {
150         drm_ioctl_t          *func;
151         int                  auth_needed;
152         int                  root_only;
153 } drm_ioctl_desc_t;
154
155 typedef struct drm_devstate {
156         pid_t             owner;        /* X server pid holding x_lock */
157
158 } drm_devstate_t;
159
160 typedef struct drm_magic_entry {
161         drm_magic_t            magic;
162         struct drm_file        *priv;
163         struct drm_magic_entry *next;
164 } drm_magic_entry_t;
165
166 typedef struct drm_magic_head {
167         struct drm_magic_entry *head;
168         struct drm_magic_entry *tail;
169 } drm_magic_head_t;
170
171 typedef struct drm_vma_entry {
172         struct vm_area_struct *vma;
173         struct drm_vma_entry  *next;
174         pid_t                 pid;
175 } drm_vma_entry_t;
176
177 typedef struct drm_buf {
178         int               idx;         /* Index into master buflist          */
179         int               total;       /* Buffer size                        */
180         int               order;       /* log-base-2(total)                  */
181         int               used;        /* Amount of buffer in use (for DMA)  */
182         unsigned long     offset;      /* Byte offset (used internally)      */
183         void              *address;    /* Address of buffer                  */
184         unsigned long     bus_address; /* Bus address of buffer              */
185         struct drm_buf    *next;       /* Kernel-only: used for free list    */
186         __volatile__ int  waiting;     /* On kernel DMA queue                */
187         __volatile__ int  pending;     /* On hardware DMA queue              */
188         wait_queue_head_t dma_wait;    /* Processes waiting                  */
189         pid_t             pid;         /* PID of holding process             */
190         int               context;     /* Kernel queue for this buffer       */
191         int               while_locked;/* Dispatch this buffer while locked  */
192         enum {
193                 DRM_LIST_NONE    = 0,
194                 DRM_LIST_FREE    = 1,
195                 DRM_LIST_WAIT    = 2,
196                 DRM_LIST_PEND    = 3,
197                 DRM_LIST_PRIO    = 4,
198                 DRM_LIST_RECLAIM = 5
199         }                 list;        /* Which list we're on                */
200
201 #if DRM_DMA_HISTOGRAM
202         cycles_t          time_queued;     /* Queued to kernel DMA queue     */
203         cycles_t          time_dispatched; /* Dispatched to hardware         */
204         cycles_t          time_completed;  /* Completed by hardware          */
205         cycles_t          time_freed;      /* Back on freelist               */
206 #endif
207
208         int               dev_priv_size; /* Size of buffer private stoarge   */
209         void              *dev_private;  /* Per-buffer private storage       */
210 } drm_buf_t;
211
212 #if DRM_DMA_HISTOGRAM
213 #define DRM_DMA_HISTOGRAM_SLOTS           9
214 #define DRM_DMA_HISTOGRAM_INITIAL        10
215 #define DRM_DMA_HISTOGRAM_NEXT(current)  ((current)*10)
216 typedef struct drm_histogram {
217         atomic_t          total;
218
219         atomic_t          queued_to_dispatched[DRM_DMA_HISTOGRAM_SLOTS];
220         atomic_t          dispatched_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
221         atomic_t          completed_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
222
223         atomic_t          queued_to_completed[DRM_DMA_HISTOGRAM_SLOTS];
224         atomic_t          queued_to_freed[DRM_DMA_HISTOGRAM_SLOTS];
225
226         atomic_t          dma[DRM_DMA_HISTOGRAM_SLOTS];
227         atomic_t          schedule[DRM_DMA_HISTOGRAM_SLOTS];
228         atomic_t          ctx[DRM_DMA_HISTOGRAM_SLOTS];
229         atomic_t          lacq[DRM_DMA_HISTOGRAM_SLOTS];
230         atomic_t          lhld[DRM_DMA_HISTOGRAM_SLOTS];
231 } drm_histogram_t;
232 #endif
233
234                                 /* bufs is one longer than it has to be */
235 typedef struct drm_waitlist {
236         int               count;        /* Number of possible buffers      */
237         drm_buf_t         **bufs;       /* List of pointers to buffers     */
238         drm_buf_t         **rp;         /* Read pointer                    */
239         drm_buf_t         **wp;         /* Write pointer                   */
240         drm_buf_t         **end;        /* End pointer                     */
241         DRM_OS_SPINTYPE   read_lock;
242         DRM_OS_SPINTYPE   write_lock;
243 } drm_waitlist_t;
244
245 typedef struct drm_freelist {
246         int               initialized; /* Freelist in use                  */
247         atomic_t          count;       /* Number of free buffers           */
248         drm_buf_t         *next;       /* End pointer                      */
249
250         wait_queue_head_t waiting;     /* Processes waiting on free bufs   */
251         int               low_mark;    /* Low water mark                   */
252         int               high_mark;   /* High water mark                  */
253         atomic_t          wfh;         /* If waiting for high mark         */
254         DRM_OS_SPINTYPE   lock;
255 } drm_freelist_t;
256
257 typedef struct drm_buf_entry {
258         int               buf_size;
259         int               buf_count;
260         drm_buf_t         *buflist;
261         int               seg_count;
262         int               page_order;
263         unsigned long     *seglist;
264
265         drm_freelist_t    freelist;
266 } drm_buf_entry_t;
267
268 typedef struct drm_hw_lock {
269         __volatile__ unsigned int lock;
270         char                      padding[60]; /* Pad to cache line */
271 } drm_hw_lock_t;
272
273 #ifdef __linux__
274 struct drm_file {
275         int               authenticated;
276         int               minor;
277         pid_t             pid;
278         uid_t             uid;
279         drm_magic_t       magic;
280         unsigned long     ioctl_count;
281         struct drm_file   *next;
282         struct drm_file   *prev;
283         struct drm_device *dev;
284         int               remove_auth_on_close;
285 };
286 #endif /* __linux__ */
287 #ifdef __FreeBSD__
288 typedef TAILQ_HEAD(drm_file_list, drm_file) drm_file_list_t;
289 struct drm_file {
290         TAILQ_ENTRY(drm_file) link;
291         int               authenticated;
292         int               minor;
293         pid_t             pid;
294         uid_t             uid;
295         int               refs;
296         drm_magic_t       magic;
297         unsigned long     ioctl_count;
298         struct drm_device *devXX;
299 };
300 #endif /* __FreeBSD__ */
301
302 typedef struct drm_queue {
303         atomic_t          use_count;    /* Outstanding uses (+1)            */
304         atomic_t          finalization; /* Finalization in progress         */
305         atomic_t          block_count;  /* Count of processes waiting       */
306         atomic_t          block_read;   /* Queue blocked for reads          */
307         wait_queue_head_t read_queue;   /* Processes waiting on block_read  */
308         atomic_t          block_write;  /* Queue blocked for writes         */
309         wait_queue_head_t write_queue;  /* Processes waiting on block_write */
310 #if 1
311         atomic_t          total_queued; /* Total queued statistic           */
312         atomic_t          total_flushed;/* Total flushes statistic          */
313         atomic_t          total_locks;  /* Total locks statistics           */
314 #endif
315         drm_ctx_flags_t   flags;        /* Context preserving and 2D-only   */
316         drm_waitlist_t    waitlist;     /* Pending buffers                  */
317         wait_queue_head_t flush_queue;  /* Processes waiting until flush    */
318 } drm_queue_t;
319
320 typedef struct drm_lock_data {
321         drm_hw_lock_t     *hw_lock;     /* Hardware lock                   */
322         pid_t             pid;          /* PID of lock holder (0=kernel)   */
323         wait_queue_head_t lock_queue;   /* Queue of blocked processes      */
324         unsigned long     lock_time;    /* Time of last lock in jiffies    */
325 } drm_lock_data_t;
326
327 typedef struct drm_device_dma {
328 #if 0
329                                 /* Performance Counters */
330         atomic_t          total_prio;   /* Total DRM_DMA_PRIORITY          */
331         atomic_t          total_bytes;  /* Total bytes DMA'd               */
332         atomic_t          total_dmas;   /* Total DMA buffers dispatched    */
333
334         atomic_t          total_missed_dma;  /* Missed drm_do_dma           */
335         atomic_t          total_missed_lock; /* Missed lock in drm_do_dma   */
336         atomic_t          total_missed_free; /* Missed drm_free_this_buffer */
337         atomic_t          total_missed_sched;/* Missed drm_dma_schedule     */
338
339         atomic_t          total_tried;  /* Tried next_buffer                */
340         atomic_t          total_hit;    /* Sent next_buffer                 */
341         atomic_t          total_lost;   /* Lost interrupt                   */
342 #endif
343
344         drm_buf_entry_t   bufs[DRM_MAX_ORDER+1];
345         int               buf_count;
346         drm_buf_t         **buflist;    /* Vector of pointers info bufs    */
347         int               seg_count;
348         int               page_count;
349         unsigned long     *pagelist;
350         unsigned long     byte_count;
351         enum {
352                 _DRM_DMA_USE_AGP = 0x01,
353                 _DRM_DMA_USE_SG  = 0x02
354         } flags;
355
356                                 /* DMA support */
357         drm_buf_t         *this_buffer; /* Buffer being sent               */
358         drm_buf_t         *next_buffer; /* Selected buffer to send         */
359         drm_queue_t       *next_queue;  /* Queue from which buffer selected*/
360         wait_queue_head_t waiting;      /* Processes waiting on free bufs  */
361 } drm_device_dma_t;
362
363 #if __REALLY_HAVE_AGP
364 typedef struct drm_agp_mem {
365 #ifdef __linux__
366         unsigned long      handle;
367         agp_memory         *memory;
368 #endif /* __linux__ */
369 #ifdef __FreeBSD__
370         void               *handle;
371 #endif /* __FreeBSD__ */
372         unsigned long      bound; /* address */
373         int                pages;
374         struct drm_agp_mem *prev;
375         struct drm_agp_mem *next;
376 } drm_agp_mem_t;
377
378 typedef struct drm_agp_head {
379 #ifdef __linux__
380         agp_kern_info      agp_info;
381 #endif /* __linux__ */
382 #ifdef __FreeBSD__
383         device_t           agpdev;
384         struct agp_info    info;
385 #endif /* __FreeBSD__ */
386         const char         *chipset;
387         drm_agp_mem_t      *memory;
388         unsigned long      mode;
389         int                enabled;
390         int                acquired;
391         unsigned long      base;
392         int                agp_mtrr;
393         int                cant_use_aperture;
394         unsigned long      page_mask;
395 } drm_agp_head_t;
396 #endif
397
398 typedef struct drm_sg_mem {
399         unsigned long   handle;
400         void            *virtual;
401         int             pages;
402         struct page     **pagelist;
403 #ifdef __linux__
404         dma_addr_t      *busaddr;
405 #endif /* __linux__ */
406 } drm_sg_mem_t;
407
408 typedef struct drm_sigdata {
409         int           context;
410         drm_hw_lock_t *lock;
411 } drm_sigdata_t;
412
413 #ifdef __linux__
414 typedef struct drm_map_list {
415         struct list_head        head;
416         drm_map_t               *map;
417 } drm_map_list_t;
418 #endif /* __linux__ */
419 #ifdef __FreeBSD__
420 typedef TAILQ_HEAD(drm_map_list, drm_map_list_entry) drm_map_list_t;
421 typedef struct drm_map_list_entry {
422         TAILQ_ENTRY(drm_map_list_entry) link;
423         drm_map_t       *map;
424 } drm_map_list_entry_t;
425 #endif /* __FreeBSD__ */
426
427 struct drm_device {
428         const char        *name;        /* Simple driver name              */
429         char              *unique;      /* Unique identifier: e.g., busid  */
430         int               unique_len;   /* Length of unique field          */
431 #ifdef __linux__
432         dev_t             device;       /* Device number for mknod         */
433 #endif /* __linux__ */
434 #ifdef __FreeBSD__
435         device_t          device;       /* Device instance from newbus     */
436         dev_t             devnode;      /* Device number for mknod         */
437 #endif /* __FreeBSD__ */
438         char              *devname;     /* For /proc/interrupts            */
439
440         int               blocked;      /* Blocked due to VC switch?       */
441 #ifdef __FreeBSD__
442         int               flags;        /* Flags to open(2)                */
443         int               writable;     /* Opened with FWRITE              */
444 #endif /* __FreeBSD__ */
445 #ifdef __linux__
446         struct proc_dir_entry *root;    /* Root for this device's entries  */
447 #endif /* __linux__ */
448
449                                 /* Locks */
450         DRM_OS_SPINTYPE   count_lock;   /* For inuse, open_count, buf_use  */
451 #ifdef __linux__
452         struct semaphore  struct_sem;   /* For others                      */
453 #endif /* __linux__ */
454 #ifdef __FreeBSD__
455         struct lock       dev_lock;     /* For others                      */
456 #endif /* __FreeBSD__ */
457
458                                 /* Usage Counters */
459         int               open_count;   /* Outstanding files open          */
460         atomic_t          ioctl_count;  /* Outstanding IOCTLs pending      */
461         atomic_t          vma_count;    /* Outstanding vma areas open      */
462         int               buf_use;      /* Buffers in use -- cannot alloc  */
463         atomic_t          buf_alloc;    /* Buffer allocation in progress   */
464
465                                 /* Performance counters */
466         unsigned long     counters;
467         drm_stat_type_t   types[15];
468         atomic_t          counts[15];
469
470                                 /* Authentication */
471 #ifdef __linux__
472         drm_file_t        *file_first;
473         drm_file_t        *file_last;
474 #endif /* __linux__ */
475 #ifdef __FreeBSD__
476         drm_file_list_t   files;
477 #endif /* __FreeBSD__ */
478         drm_magic_head_t  magiclist[DRM_HASH_SIZE];
479
480                                 /* Memory management */
481         drm_map_list_t    *maplist;     /* Linked list of regions          */
482         int               map_count;    /* Number of mappable regions      */
483
484         drm_map_t         **context_sareas;
485         int               max_context;
486
487         drm_vma_entry_t   *vmalist;     /* List of vmas (for debugging)    */
488         drm_lock_data_t   lock;         /* Information on hardware lock    */
489
490                                 /* DMA queues (contexts) */
491         int               queue_count;  /* Number of active DMA queues     */
492         int               queue_reserved; /* Number of reserved DMA queues */
493         int               queue_slots;  /* Actual length of queuelist      */
494         drm_queue_t       **queuelist;  /* Vector of pointers to DMA queues */
495         drm_device_dma_t  *dma;         /* Optional pointer for DMA support */
496
497                                 /* Context support */
498         int               irq;          /* Interrupt used by board         */
499 #ifdef __FreeBSD__
500         struct resource   *irqr;        /* Resource for interrupt used by board    */
501         void              *irqh;        /* Handle from bus_setup_intr      */
502 #endif /* __FreeBSD__ */
503         __volatile__ long context_flag; /* Context swapping flag           */
504         __volatile__ long interrupt_flag; /* Interruption handler flag     */
505         __volatile__ long dma_flag;     /* DMA dispatch flag               */
506 #ifdef __linux__
507         struct timer_list timer;        /* Timer for delaying ctx switch   */
508 #endif /* __linux__ */
509 #ifdef __FreeBSD__
510         struct callout    timer;        /* Timer for delaying ctx switch   */
511 #endif /* __FreeBSD__ */
512         wait_queue_head_t context_wait; /* Processes waiting on ctx switch */
513         int               last_checked; /* Last context checked for DMA    */
514         int               last_context; /* Last current context            */
515         unsigned long     last_switch;  /* jiffies at last context switch  */
516 #ifdef __linux__
517         struct tq_struct  tq;
518 #endif /* __linux__ */
519 #ifdef __FreeBSD__
520 #if __FreeBSD_version >= 400005
521         struct task       task;
522 #endif
523 #endif /* __FreeBSD__ */
524         cycles_t          ctx_start;
525         cycles_t          lck_start;
526 #if __HAVE_DMA_HISTOGRAM
527         drm_histogram_t   histo;
528 #endif
529
530                                 /* Callback to X server for context switch
531                                    and for heavy-handed reset. */
532         char              buf[DRM_BSZ]; /* Output buffer                   */
533         char              *buf_rp;      /* Read pointer                    */
534         char              *buf_wp;      /* Write pointer                   */
535         char              *buf_end;     /* End pointer                     */
536 #ifdef __linux__
537         struct fasync_struct *buf_async;/* Processes waiting for SIGIO     */
538 #endif /* __linux__ */
539 #ifdef __FreeBSD__
540         struct sigio      *buf_sigio;   /* Processes waiting for SIGIO     */
541         struct selinfo    buf_sel;      /* Workspace for select/poll       */
542         int               buf_selecting;/* True if poll sleeper            */
543 #endif /* __FreeBSD__ */
544         wait_queue_head_t buf_readers;  /* Processes waiting to read       */
545         wait_queue_head_t buf_writers;  /* Processes waiting to ctx switch */
546
547 #ifdef __FreeBSD__
548                                 /* Sysctl support */
549         struct drm_sysctl_info *sysctl;
550 #endif /* __FreeBSD__ */
551
552 #if __REALLY_HAVE_AGP
553         drm_agp_head_t    *agp;
554 #endif
555         struct pci_dev *pdev;
556 #ifdef __alpha__
557 #if LINUX_VERSION_CODE < 0x020403
558         struct pci_controler *hose;
559 #else
560         struct pci_controller *hose;
561 #endif
562 #endif
563         drm_sg_mem_t      *sg;  /* Scatter gather memory */
564         unsigned long     *ctx_bitmap;
565         void              *dev_private;
566         drm_sigdata_t     sigdata; /* For block_all_signals */
567         sigset_t          sigmask;
568 };
569
570 /* ================================================================
571  * Internal function definitions
572  */
573
574 extern int           DRM(flags);
575 extern void          DRM(parse_options)( char *s );
576 extern int           DRM(cpu_valid)( void );
577
578                                 /* Driver support (drm_drv.h) */
579 extern int           DRM(version)( DRM_OS_IOCTL );
580 extern int           DRM(ioctl)( DRM_OS_IOCTL );
581 extern int           DRM(lock)( DRM_OS_IOCTL );
582 extern int           DRM(unlock)( DRM_OS_IOCTL );
583 extern int           DRM(write_string)(drm_device_t *dev, const char *s);
584
585                                 /* Memory management support (drm_memory.h) */
586 extern void          DRM(mem_init)(void);
587 extern void          *DRM(alloc)(size_t size, int area);
588 extern void          *DRM(realloc)(void *oldpt, size_t oldsize, size_t size,
589                                    int area);
590 extern char          *DRM(strdup)(const char *s, int area);
591 extern void          DRM(strfree)(char *s, int area);
592 extern void          DRM(free)(void *pt, size_t size, int area);
593 extern unsigned long DRM(alloc_pages)(int order, int area);
594 extern void          DRM(free_pages)(unsigned long address, int order,
595                                      int area);
596 extern void          *DRM(ioremap)(unsigned long offset, unsigned long size);
597 extern void          DRM(ioremapfree)(void *pt, unsigned long size);
598
599 #if __REALLY_HAVE_AGP
600 extern agp_memory    *DRM(alloc_agp)(int pages, u32 type);
601 extern int           DRM(free_agp)(agp_memory *handle, int pages);
602 extern int           DRM(bind_agp)(agp_memory *handle, unsigned int start);
603 extern int           DRM(unbind_agp)(agp_memory *handle);
604 #endif
605
606                                 /* Misc. IOCTL support (drm_ioctl.h) */
607 extern int           DRM(irq_busid)( DRM_OS_IOCTL );
608 extern int           DRM(getunique)( DRM_OS_IOCTL );
609 extern int           DRM(setunique)( DRM_OS_IOCTL );
610 extern int           DRM(getmap)( DRM_OS_IOCTL );
611 extern int           DRM(getclient)( DRM_OS_IOCTL );
612 extern int           DRM(getstats)( DRM_OS_IOCTL );
613
614                                 /* Context IOCTL support (drm_context.h) */
615 extern int           DRM(resctx)( DRM_OS_IOCTL );
616 extern int           DRM(addctx)( DRM_OS_IOCTL );
617 extern int           DRM(modctx)( DRM_OS_IOCTL );
618 extern int           DRM(getctx)( DRM_OS_IOCTL );
619 extern int           DRM(switchctx)( DRM_OS_IOCTL );
620 extern int           DRM(newctx)( DRM_OS_IOCTL );
621 extern int           DRM(rmctx)( DRM_OS_IOCTL );
622
623 extern int           DRM(context_switch)(drm_device_t *dev, int old, int new);
624 extern int           DRM(context_switch_complete)(drm_device_t *dev, int new);
625
626 #if __HAVE_CTX_BITMAP
627 extern int           DRM(ctxbitmap_init)( drm_device_t *dev );
628 extern void          DRM(ctxbitmap_cleanup)( drm_device_t *dev );
629 extern void          DRM(ctxbitmap_free)( drm_device_t *dev, int ctx_handle );
630 extern int           DRM(ctxbitmap_next)( drm_device_t *dev );
631 #endif
632
633 extern int           DRM(setsareactx)( DRM_OS_IOCTL );
634 extern int           DRM(getsareactx)( DRM_OS_IOCTL );
635
636                                 /* Drawable IOCTL support (drm_drawable.h) */
637 extern int           DRM(adddraw)( DRM_OS_IOCTL );
638 extern int           DRM(rmdraw)( DRM_OS_IOCTL );
639
640                                 /* Authentication IOCTL support (drm_auth.h) */
641 extern int           DRM(add_magic)(drm_device_t *dev, drm_file_t *priv, 
642                                     drm_magic_t magic);
643 extern int           DRM(remove_magic)(drm_device_t *dev, drm_magic_t magic);
644 extern int           DRM(getmagic)( DRM_OS_IOCTL );
645 extern int           DRM(authmagic)( DRM_OS_IOCTL );
646
647                                 /* Locking IOCTL support (drm_lock.h) */
648 extern int           DRM(block)( DRM_OS_IOCTL );
649 extern int           DRM(unblock)( DRM_OS_IOCTL );
650 extern int           DRM(finish)( DRM_OS_IOCTL );
651 extern int           DRM(lock_take)(__volatile__ unsigned int *lock,
652                                     unsigned int context);
653 extern int           DRM(lock_transfer)(drm_device_t *dev,
654                                         __volatile__ unsigned int *lock,
655                                         unsigned int context);
656 extern int           DRM(lock_free)(drm_device_t *dev,
657                                     __volatile__ unsigned int *lock,
658                                     unsigned int context);
659 extern int           DRM(flush_unblock)(drm_device_t *dev, int context,
660                                         drm_lock_flags_t flags);
661 extern int           DRM(flush_block_and_flush)(drm_device_t *dev, int context,
662                                                 drm_lock_flags_t flags);
663 extern int           DRM(notifier)(void *priv);
664
665                                 /* Buffer management support (drm_bufs.h) */
666 extern int           DRM(order)( unsigned long size );
667 extern int           DRM(addmap)( DRM_OS_IOCTL );
668 extern int           DRM(rmmap)( DRM_OS_IOCTL );
669
670 #if __HAVE_DMA
671 extern int           DRM(addbufs)( DRM_OS_IOCTL );
672 extern int           DRM(infobufs)( DRM_OS_IOCTL );
673 extern int           DRM(markbufs)( DRM_OS_IOCTL );
674 extern int           DRM(freebufs)( DRM_OS_IOCTL );
675 extern int           DRM(mapbufs)( DRM_OS_IOCTL );
676 extern int           DRM(control)( DRM_OS_IOCTL );
677
678                                 /* DMA support (drm_dma.h) */
679 extern int           DRM(dma_setup)(drm_device_t *dev);
680 extern void          DRM(dma_takedown)(drm_device_t *dev);
681 extern void          DRM(free_buffer)(drm_device_t *dev, drm_buf_t *buf);
682 extern void          DRM(reclaim_buffers)(drm_device_t *dev, pid_t pid);
683 #if __HAVE_OLD_DMA
684 /* GH: This is a dirty hack for now...
685  */
686 extern void          DRM(clear_next_buffer)(drm_device_t *dev);
687 extern int           DRM(select_queue)(drm_device_t *dev,
688                                        void (*wrapper)(unsigned long));
689 extern int           DRM(dma_enqueue)(drm_device_t *dev, drm_dma_t *dma);
690 extern int           DRM(dma_get_buffers)(drm_device_t *dev, drm_dma_t *dma);
691 #endif
692 #if __HAVE_DMA_IRQ
693 extern int           DRM(irq_install)( drm_device_t *dev, int irq );
694 extern int           DRM(irq_uninstall)( drm_device_t *dev );
695 extern void          DRM(dma_service)( DRM_OS_IRQ_ARGS );
696 #if __HAVE_DMA_IRQ_BH
697 extern void          DRM(dma_immediate_bh)( DRM_OS_TASKQUEUE_ARGS );
698 #endif
699 #endif
700 #if DRM_DMA_HISTOGRAM
701 extern int           DRM(histogram_slot)(unsigned long count);
702 extern void          DRM(histogram_compute)(drm_device_t *dev, drm_buf_t *buf);
703 #endif
704
705                                 /* Buffer list support (drm_lists.h) */
706 #if __HAVE_DMA_WAITLIST
707 extern int           DRM(waitlist_create)(drm_waitlist_t *bl, int count);
708 extern int           DRM(waitlist_destroy)(drm_waitlist_t *bl);
709 extern int           DRM(waitlist_put)(drm_waitlist_t *bl, drm_buf_t *buf);
710 extern drm_buf_t     *DRM(waitlist_get)(drm_waitlist_t *bl);
711 #endif
712 #if __HAVE_DMA_FREELIST
713 extern int           DRM(freelist_create)(drm_freelist_t *bl, int count);
714 extern int           DRM(freelist_destroy)(drm_freelist_t *bl);
715 extern int           DRM(freelist_put)(drm_device_t *dev, drm_freelist_t *bl,
716                                        drm_buf_t *buf);
717 extern drm_buf_t     *DRM(freelist_get)(drm_freelist_t *bl, int block);
718 #endif
719 #endif /* __HAVE_DMA */
720
721 #if __REALLY_HAVE_AGP
722                                 /* AGP/GART support (drm_agpsupport.h) */
723 extern int            DRM(agp_acquire)( DRM_OS_IOCTL );
724 extern int            DRM(agp_release)( DRM_OS_IOCTL );
725 extern int            DRM(agp_enable)( DRM_OS_IOCTL );
726 extern int            DRM(agp_info)( DRM_OS_IOCTL );
727 extern int            DRM(agp_alloc)( DRM_OS_IOCTL );
728 extern int            DRM(agp_free)( DRM_OS_IOCTL );
729 extern int            DRM(agp_unbind)( DRM_OS_IOCTL );
730 extern int            DRM(agp_bind)( DRM_OS_IOCTL );
731 extern drm_agp_head_t *DRM(agp_init)(void);
732 extern void           DRM(agp_uninit)(void);
733 extern void           DRM(agp_do_release)(void);
734 extern agp_memory     *DRM(agp_allocate_memory)(size_t pages, u32 type);
735 extern int            DRM(agp_free_memory)(agp_memory *handle);
736 extern int            DRM(agp_bind_memory)(agp_memory *handle, off_t start);
737 extern int            DRM(agp_unbind_memory)(agp_memory *handle);
738 #endif
739
740 #if __HAVE_SG
741                                 /* Scatter Gather Support (drm_scatter.h) */
742 extern void           DRM(sg_cleanup)(drm_sg_mem_t *entry);
743 extern int            DRM(sg_alloc)( DRM_OS_IOCTL );
744 extern int            DRM(sg_free)( DRM_OS_IOCTL );
745 #endif
746
747 #if __REALLY_HAVE_SG
748                                /* ATI PCIGART support (ati_pcigart.h) */
749 extern int            DRM(ati_pcigart_init)(drm_device_t *dev,
750                                             unsigned long *addr,
751                                             dma_addr_t *bus_addr);
752 extern int            DRM(ati_pcigart_cleanup)(drm_device_t *dev,
753                                                unsigned long addr,
754                                                dma_addr_t bus_addr);
755 #endif
756
757 #endif /* __KERNEL__ */
758 #endif