~ubuntu-branches/ubuntu/gutsy/vnc4/gutsy

« back to all changes in this revision

Viewing changes to unix/xc/programs/Xserver/hw/xfree86/os-support/bsd/drm/kernel/drmP.h

  • Committer: Bazaar Package Importer
  • Author(s): Ola Lundqvist
  • Date: 2006-05-15 20:35:17 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20060515203517-l4lre1ku942mn26k
Tags: 4.1.1+X4.3.0-10
* Correction of critical security issue. Thanks to Martin Kogler
  <e9925248@student.tuwien.ac.at> that informed me about the issue,
  and provided the patch.
  This flaw was originally found by Steve Wiseman of intelliadmin.com.
* Applied patch from Javier Kohen <jkohen@users.sourceforge.net> that
  inform the user that only 8 first characters of the password will
  actually be used when typing more than 8 characters, closes:
  #355619.

Show diffs side-by-side

added added

removed removed

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