VirtualBox

source: vbox/trunk/src/VBox/Additions/solaris/DRM/include/drmP.h

Last change on this file was 88215, checked in by vboxsync, 4 years ago

Solaris-specific changes needed for building VBox on Solaris 11.4.
ticketref:9956

/Config.kmk,tools/Makefile.kmk: The Solaris package FMRI changed in
Solaris 11.4 so further care is needed when parsing the 'pkg contents -o
pkg.fmri' output. Some further simplification done as well as only the
Solaris 11 update and build number are needed for feature checking
elsewhere.

Additions/solaris/DRM: In Solaris 11 FCS <sys/queue.h> was taken from
FreeBSD and added to the OS. VirtualBox copied this file to
Additions/solaris/DRM/include and it is included by
Additions/solaris/DRM/include/drmP.h. Solaris 11.4 modified <sys/modctl.h>
to include <sys/queue.h> and drmP.h includes <sys/modctl.h> so thus
drmP.h shouldn't include queue.h on Solaris 11.4 FCS and later.

Additions/solaris/SharedFolders,Runtime/r0drv/solaris: Solaris 11.4
removed the 'alignment' argument from the VM map_addr() and
choose_addr() routines so we now leverage RTR0DbgKrnlInfoQuerySymbol()
at module initialization to determine which version of these functions
needs to be invoked.

Runtime/r0drv/solaris: In Solaris 11.4 the VM seg_ops getpolicy()
routine changed its return value and added an extra argument but since
we don't need to do anything for this and Solaris 10 and 11 both check
for a non-NULL s_ops->getpolicy() entry or else for s_ops->capable()
before calling getpolicy() we just set the s_SegVBoxOps getpolicy()
entry to NULL. Solaris 11.4 also added an extra argument to the VM
seg_ops dump() routine but there aren't any checks made before calling
it. Since we don't do anything with dump() we just use #ifdefs to get
the correct prototype at build-time.

Additions/x11/vboxvideo: The Xorg vboxvideo_drv.so shared object on
Solaris 11.4 has an undefined weak symbol reference to assert_c99
which needs to be added to the undefined_xorg file.

  • Property svn:eol-style set to native
File size: 27.0 KB
Line 
1/*
2 * drmP.h -- Private header for Direct Rendering Manager -*- linux-c -*-
3 * Created: Mon Jan 4 10:05:05 1999 by [email protected]
4 */
5/*
6 * Copyright 1999 Precision Insight, Inc., Cedar Park, Texas.
7 * Copyright 2000 VA Linux Systems, Inc., Sunnyvale, California.
8 * All rights reserved.
9 *
10 * Permission is hereby granted, free of charge, to any person obtaining a
11 * copy of this software and associated documentation files (the "Software"),
12 * to deal in the Software without restriction, including without limitation
13 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
14 * and/or sell copies of the Software, and to permit persons to whom the
15 * Software is furnished to do so, subject to the following conditions:
16 *
17 * The above copyright notice and this permission notice (including the next
18 * paragraph) shall be included in all copies or substantial portions of the
19 * Software.
20 *
21 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
22 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
23 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
24 * VA LINUX SYSTEMS AND/OR ITS SUPPLIERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
25 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
26 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
27 * OTHER DEALINGS IN THE SOFTWARE.
28 *
29 * Authors:
30 * Rickard E. (Rik) Faith <[email protected]>
31 * Gareth Hughes <[email protected]>
32 *
33 */
34
35/*
36 * Copyright 2009-2010 Oracle Corporation
37 * All rights reserved.
38 * Use is subject to license terms.
39 */
40
41#ifndef _DRMP_H
42#define _DRMP_H
43
44#include <sys/types.h>
45#include <sys/conf.h>
46#include <sys/modctl.h>
47#include <sys/stat.h>
48#include <sys/file.h>
49#include <sys/cmn_err.h>
50#include <sys/varargs.h>
51#include <sys/pci.h>
52#include <sys/ddi.h>
53#include <sys/sunddi.h>
54#include <sys/sunldi.h>
55#include <sys/pmem.h>
56#include <sys/agpgart.h>
57#include <sys/time.h>
58#include "drm_atomic.h"
59#include "drm.h"
60#if !defined(VBOX_WITH_SYSTEM_QUEUE_H)
61# include "queue.h"
62#endif
63#include "drm_linux_list.h"
64
65#ifndef __inline__
66#define __inline__ inline
67#endif
68
69#if !defined(__FUNCTION__)
70#if defined(C99)
71#define __FUNCTION__ __func__
72#else
73#define __FUNCTION__ " "
74#endif
75#endif
76
77/* DRM space units */
78#define DRM_PAGE_SHIFT PAGESHIFT
79#define DRM_PAGE_SIZE (1 << DRM_PAGE_SHIFT)
80#define DRM_PAGE_OFFSET (DRM_PAGE_SIZE - 1)
81#define DRM_PAGE_MASK ~(DRM_PAGE_SIZE - 1)
82#define DRM_MB2PAGES(x) ((x) << 8)
83#define DRM_PAGES2BYTES(x) ((x) << DRM_PAGE_SHIFT)
84#define DRM_BYTES2PAGES(x) ((x) >> DRM_PAGE_SHIFT)
85#define DRM_PAGES2KB(x) ((x) << 2)
86#define DRM_ALIGNED(offset) (((offset) & DRM_PAGE_OFFSET) == 0)
87
88#define PAGE_SHIFT DRM_PAGE_SHIFT
89#define PAGE_SIZE DRM_PAGE_SIZE
90
91#define DRM_MAX_INSTANCES 8
92#define DRM_DEVNODE "drm"
93#define DRM_UNOPENED 0
94#define DRM_OPENED 1
95
96#define DRM_HASH_SIZE 16 /* Size of key hash table */
97#define DRM_KERNEL_CONTEXT 0 /* Change drm_resctx if changed */
98#define DRM_RESERVED_CONTEXTS 1 /* Change drm_resctx if changed */
99
100#define DRM_MEM_DMA 0
101#define DRM_MEM_SAREA 1
102#define DRM_MEM_DRIVER 2
103#define DRM_MEM_MAGIC 3
104#define DRM_MEM_IOCTLS 4
105#define DRM_MEM_MAPS 5
106#define DRM_MEM_BUFS 6
107#define DRM_MEM_SEGS 7
108#define DRM_MEM_PAGES 8
109#define DRM_MEM_FILES 9
110#define DRM_MEM_QUEUES 10
111#define DRM_MEM_CMDS 11
112#define DRM_MEM_MAPPINGS 12
113#define DRM_MEM_BUFLISTS 13
114#define DRM_MEM_DRMLISTS 14
115#define DRM_MEM_TOTALDRM 15
116#define DRM_MEM_BOUNDDRM 16
117#define DRM_MEM_CTXBITMAP 17
118#define DRM_MEM_STUB 18
119#define DRM_MEM_SGLISTS 19
120#define DRM_MEM_AGPLISTS 20
121#define DRM_MEM_CTXLIST 21
122#define DRM_MEM_MM 22
123#define DRM_MEM_HASHTAB 23
124#define DRM_MEM_OBJECTS 24
125
126#define DRM_MAX_CTXBITMAP (PAGE_SIZE * 8)
127#define DRM_MAP_HASH_OFFSET 0x10000000
128#define DRM_MAP_HASH_ORDER 12
129#define DRM_OBJECT_HASH_ORDER 12
130#define DRM_FILE_PAGE_OFFSET_START ((0xFFFFFFFFUL >> PAGE_SHIFT) + 1)
131#define DRM_FILE_PAGE_OFFSET_SIZE ((0xFFFFFFFFUL >> PAGE_SHIFT) * 16)
132#define DRM_MM_INIT_MAX_PAGES 256
133
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_IF_VERSION(maj, min) (maj << 16 | min)
141
142#define __OS_HAS_AGP 1
143
144#define DRM_DEV_MOD (S_IRUSR|S_IWUSR|S_IRGRP|S_IWGRP)
145#define DRM_DEV_UID 0
146#define DRM_DEV_GID 0
147
148#define DRM_CURRENTPID ddi_get_pid()
149#define DRM_SPINLOCK(l) mutex_enter(l)
150#define DRM_SPINUNLOCK(u) mutex_exit(u)
151#define DRM_SPINLOCK_ASSERT(l)
152#define DRM_LOCK() mutex_enter(&dev->dev_lock)
153#define DRM_UNLOCK() mutex_exit(&dev->dev_lock)
154#define DRM_LOCK_OWNED() ASSERT(mutex_owned(&dev->dev_lock))
155#define spin_lock_irqsave(l, flag) mutex_enter(l)
156#define spin_unlock_irqrestore(u, flag) mutex_exit(u)
157#define spin_lock(l) mutex_enter(l)
158#define spin_unlock(u) mutex_exit(u)
159
160#define DRM_UDELAY(sec) delay(drv_usectohz(sec *1000))
161#define DRM_MEMORYBARRIER()
162
163typedef struct drm_file drm_file_t;
164typedef struct drm_device drm_device_t;
165typedef struct drm_driver_info drm_driver_t;
166
167#define DRM_DEVICE drm_device_t *dev = dev1
168#define DRM_IOCTL_ARGS \
169 drm_device_t *dev1, intptr_t data, drm_file_t *fpriv, int mode
170
171#define DRM_COPYFROM_WITH_RETURN(dest, src, size) \
172 if (ddi_copyin(src, dest, size, 0)) \
173 return (EFAULT)
174
175#define DRM_COPYTO_WITH_RETURN(dest, src, size) \
176 if (ddi_copyout((src), (dest), (size), 0)) \
177 return (EFAULT)
178
179#define DRM_COPY_FROM_USER(dest, src, size) \
180 ddi_copyin((src), (dest), (size), 0) /* flag for src */
181
182#define DRM_COPY_TO_USER(dest, src, size) \
183 ddi_copyout((src), (dest), (size), 0) /* flags for dest */
184
185#define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \
186 ddi_copyin((arg2), (arg1), (arg3), 0)
187
188#define DRM_COPY_TO_USER_UNCHECKED(arg1, arg2, arg3) \
189 ddi_copyout((arg2), arg1, arg3, 0)
190
191#define DRM_READ8(map, offset) \
192 *(uint8_t *)((uintptr_t)((map)->dev_addr) + (offset))
193#define DRM_READ16(map, offset) \
194 *(uint16_t *)((uintptr_t)((map)->dev_addr) + (offset))
195#define DRM_READ32(map, offset) \
196 *(uint32_t *)((uintptr_t)((map)->dev_addr) + (offset))
197#define DRM_WRITE8(map, offset, val) \
198 *(uint8_t *)((uintptr_t)((map)->dev_addr) + (offset)) = (val)
199#define DRM_WRITE16(map, offset, val) \
200 *(uint16_t *)((uintptr_t)((map)->dev_addr) + (offset)) = (val)
201#define DRM_WRITE32(map, offset, val) \
202 *(uint32_t *)((uintptr_t)((map)->dev_addr) + (offset)) = (val)
203
204typedef struct drm_wait_queue {
205 kcondvar_t cv;
206 kmutex_t lock;
207}wait_queue_head_t;
208
209#define DRM_INIT_WAITQUEUE(q, pri) \
210{ \
211 mutex_init(&(q)->lock, NULL, MUTEX_DRIVER, pri); \
212 cv_init(&(q)->cv, NULL, CV_DRIVER, NULL); \
213}
214
215#define DRM_FINI_WAITQUEUE(q) \
216{ \
217 mutex_destroy(&(q)->lock); \
218 cv_destroy(&(q)->cv); \
219}
220
221#define DRM_WAKEUP(q) \
222{ \
223 mutex_enter(&(q)->lock); \
224 cv_broadcast(&(q)->cv); \
225 mutex_exit(&(q)->lock); \
226}
227
228#define jiffies ddi_get_lbolt()
229#define DRM_WAIT_ON(ret, q, timeout, condition) \
230mutex_enter(&(q)->lock); \
231while (!(condition)) { \
232 ret = cv_timedwait_sig(&(q)->cv, &(q)->lock, jiffies + timeout); \
233 if (ret == -1) { \
234 ret = EBUSY; \
235 break; \
236 } else if (ret == 0) { \
237 ret = EINTR; \
238 break; \
239 } else { \
240 ret = 0; \
241 } \
242} \
243mutex_exit(&(q)->lock);
244
245#define DRM_GETSAREA() \
246{ \
247 drm_local_map_t *map; \
248 DRM_SPINLOCK_ASSERT(&dev->dev_lock); \
249 TAILQ_FOREACH(map, &dev->maplist, link) { \
250 if (map->type == _DRM_SHM && \
251 map->flags & _DRM_CONTAINS_LOCK) { \
252 dev_priv->sarea = map; \
253 break; \
254 } \
255 } \
256}
257
258#define LOCK_TEST_WITH_RETURN(dev, fpriv) \
259 if (!_DRM_LOCK_IS_HELD(dev->lock.hw_lock->lock) || \
260 dev->lock.filp != fpriv) { \
261 DRM_ERROR("called without lock held"); \
262 return (EINVAL); \
263 }
264
265#define DRM_IRQ_ARGS caddr_t arg
266#define IRQ_HANDLED DDI_INTR_CLAIMED
267#define IRQ_NONE DDI_INTR_UNCLAIMED
268
269enum {
270 DRM_IS_NOT_AGP,
271 DRM_IS_AGP,
272 DRM_MIGHT_BE_AGP
273};
274
275/* Capabilities taken from src/sys/dev/pci/pcireg.h. */
276#ifndef PCIY_AGP
277#define PCIY_AGP 0x02
278#endif
279
280#ifndef PCIY_EXPRESS
281#define PCIY_EXPRESS 0x10
282#endif
283
284#define PAGE_ALIGN(addr) (((addr) + DRM_PAGE_SIZE - 1) & DRM_PAGE_MASK)
285#define DRM_SUSER(p) (crgetgid(p) == 0 || crgetuid(p) == 0)
286
287/*
288 * wait for 400 milliseconds
289 */
290#define DRM_HZ drv_usectohz(400000)
291
292typedef unsigned long dma_addr_t;
293typedef uint64_t u64;
294typedef uint32_t u32;
295typedef uint16_t u16;
296typedef uint8_t u8;
297typedef uint_t irqreturn_t;
298
299#define DRM_SUPPORT 1
300#define DRM_UNSUPPORT 0
301
302#define __OS_HAS_AGP 1
303
304#define __offsetof(type, field) ((size_t)(&((type *)0)->field))
305#define offsetof(type, field) __offsetof(type, field)
306
307typedef struct drm_pci_id_list
308{
309 int vendor;
310 int device;
311 long driver_private;
312 char *name;
313} drm_pci_id_list_t;
314
315#define DRM_AUTH 0x1
316#define DRM_MASTER 0x2
317#define DRM_ROOT_ONLY 0x4
318typedef int drm_ioctl_t(DRM_IOCTL_ARGS);
319typedef struct drm_ioctl_desc {
320 int (*func)(DRM_IOCTL_ARGS);
321 int flags;
322} drm_ioctl_desc_t;
323
324typedef struct drm_magic_entry {
325 drm_magic_t magic;
326 struct drm_file *priv;
327 struct drm_magic_entry *next;
328} drm_magic_entry_t;
329
330typedef struct drm_magic_head {
331 struct drm_magic_entry *head;
332 struct drm_magic_entry *tail;
333} drm_magic_head_t;
334
335typedef struct drm_buf {
336 int idx; /* Index into master buflist */
337 int total; /* Buffer size */
338 int order; /* log-base-2(total) */
339 int used; /* Amount of buffer in use (for DMA) */
340 unsigned long offset; /* Byte offset (used internally) */
341 void *address; /* Address of buffer */
342 unsigned long bus_address; /* Bus address of buffer */
343 struct drm_buf *next; /* Kernel-only: used for free list */
344 volatile int pending; /* On hardware DMA queue */
345 drm_file_t *filp;
346 /* Uniq. identifier of holding process */
347 int context; /* Kernel queue for this buffer */
348 enum {
349 DRM_LIST_NONE = 0,
350 DRM_LIST_FREE = 1,
351 DRM_LIST_WAIT = 2,
352 DRM_LIST_PEND = 3,
353 DRM_LIST_PRIO = 4,
354 DRM_LIST_RECLAIM = 5
355 } list; /* Which list we're on */
356
357 int dev_priv_size; /* Size of buffer private storage */
358 void *dev_private; /* Per-buffer private storage */
359} drm_buf_t;
360
361typedef struct drm_freelist {
362 int initialized; /* Freelist in use */
363 uint32_t count; /* Number of free buffers */
364 drm_buf_t *next; /* End pointer */
365
366 int low_mark; /* Low water mark */
367 int high_mark; /* High water mark */
368} drm_freelist_t;
369
370typedef struct drm_buf_entry {
371 int buf_size;
372 int buf_count;
373 drm_buf_t *buflist;
374 int seg_count;
375 int page_order;
376
377 uint32_t *seglist;
378 unsigned long *seglist_bus;
379
380 drm_freelist_t freelist;
381} drm_buf_entry_t;
382
383typedef TAILQ_HEAD(drm_file_list, drm_file) drm_file_list_t;
384struct drm_file {
385 TAILQ_ENTRY(drm_file) link;
386 int authenticated;
387 int master;
388 int minor;
389 pid_t pid;
390 uid_t uid;
391 int refs;
392 drm_magic_t magic;
393 unsigned long ioctl_count;
394 void *driver_priv;
395};
396
397typedef struct drm_lock_data {
398 drm_hw_lock_t *hw_lock; /* Hardware lock */
399 drm_file_t *filp;
400 /* Uniq. identifier of holding process */
401 kcondvar_t lock_cv; /* lock queue - SOLARIS Specific */
402 kmutex_t lock_mutex; /* lock - SOLARIS Specific */
403 unsigned long lock_time; /* Time of last lock in jiffies */
404} drm_lock_data_t;
405
406/*
407 * This structure, in drm_device_t, is always initialized while the device
408 * is open. dev->dma_lock protects the incrementing of dev->buf_use, which
409 * when set marks that no further bufs may be allocated until device teardown
410 * occurs (when the last open of the device has closed). The high/low
411 * watermarks of bufs are only touched by the X Server, and thus not
412 * concurrently accessed, so no locking is needed.
413 */
414typedef struct drm_device_dma {
415 drm_buf_entry_t bufs[DRM_MAX_ORDER+1];
416 int buf_count;
417 drm_buf_t **buflist; /* Vector of pointers info bufs */
418 int seg_count;
419 int page_count;
420 unsigned long *pagelist;
421 unsigned long byte_count;
422 enum {
423 _DRM_DMA_USE_AGP = 0x01,
424 _DRM_DMA_USE_SG = 0x02
425 } flags;
426} drm_device_dma_t;
427
428typedef struct drm_agp_mem {
429 void *handle;
430 unsigned long bound; /* address */
431 int pages;
432 caddr_t phys_addr;
433 struct drm_agp_mem *prev;
434 struct drm_agp_mem *next;
435} drm_agp_mem_t;
436
437typedef struct drm_agp_head {
438 agp_info_t agp_info;
439 const char *chipset;
440 drm_agp_mem_t *memory;
441 unsigned long mode;
442 int enabled;
443 int acquired;
444 unsigned long base;
445 int mtrr;
446 int cant_use_aperture;
447 unsigned long page_mask;
448 ldi_ident_t agpgart_li;
449 ldi_handle_t agpgart_lh;
450} drm_agp_head_t;
451
452
453typedef struct drm_dma_handle {
454 ddi_dma_handle_t dma_hdl;
455 ddi_acc_handle_t acc_hdl;
456 ddi_dma_cookie_t cookie;
457 uint_t cookie_num;
458 uintptr_t vaddr; /* virtual addr */
459 uintptr_t paddr; /* physical addr */
460 size_t real_sz; /* real size of memory */
461} drm_dma_handle_t;
462
463typedef struct drm_sg_mem {
464 unsigned long handle;
465 void *virtual;
466 int pages;
467 dma_addr_t *busaddr;
468 ddi_umem_cookie_t *umem_cookie;
469 drm_dma_handle_t *dmah_sg;
470 drm_dma_handle_t *dmah_gart; /* Handle to PCI memory */
471} drm_sg_mem_t;
472
473typedef TAILQ_HEAD(drm_map_list, drm_local_map) drm_map_list_t;
474
475/* BEGIN CSTYLED */
476typedef struct drm_local_map {
477 unsigned long offset; /* Physical address (0 for SAREA) */
478 unsigned long size; /* Physical size (bytes) */
479 drm_map_type_t type; /* Type of memory mapped */
480 drm_map_flags_t flags; /* Flags */
481 void *handle; /* User-space: "Handle" to pass to mmap */
482 /* Kernel-space: kernel-virtual address */
483 int mtrr; /* Boolean: MTRR used */
484 /* Private data */
485 int rid; /* PCI resource ID for bus_space */
486 int kernel_owned; /* Boolean: 1= initmapped, 0= addmapped */
487 caddr_t dev_addr; /* base device address */
488 ddi_acc_handle_t dev_handle; /* The data access handle */
489 ddi_umem_cookie_t drm_umem_cookie; /* For SAREA alloc and free */
490 TAILQ_ENTRY(drm_local_map) link;
491} drm_local_map_t;
492/* END CSTYLED */
493
494typedef TAILQ_HEAD(drm_vbl_sig_list, drm_vbl_sig) drm_vbl_sig_list_t;
495typedef struct drm_vbl_sig {
496 TAILQ_ENTRY(drm_vbl_sig) link;
497 unsigned int sequence;
498 int signo;
499 int pid;
500} drm_vbl_sig_t;
501
502
503/* used for clone device */
504typedef TAILQ_HEAD(drm_cminor_list, drm_cminor) drm_cminor_list_t;
505typedef struct drm_cminor {
506 TAILQ_ENTRY(drm_cminor) link;
507 drm_file_t *fpriv;
508 int minor;
509} drm_cminor_t;
510
511/* location of GART table */
512#define DRM_ATI_GART_MAIN 1
513#define DRM_ATI_GART_FB 2
514
515typedef struct ati_pcigart_info {
516 int gart_table_location;
517 int is_pcie;
518 void *addr;
519 dma_addr_t bus_addr;
520 drm_local_map_t mapping;
521} drm_ati_pcigart_info;
522
523/* DRM device structure */
524struct drm_device;
525struct drm_driver_info {
526 int (*load)(struct drm_device *, unsigned long);
527 int (*firstopen)(struct drm_device *);
528 int (*open)(struct drm_device *, drm_file_t *);
529 void (*preclose)(struct drm_device *, drm_file_t *);
530 void (*postclose)(struct drm_device *, drm_file_t *);
531 void (*lastclose)(struct drm_device *);
532 int (*unload)(struct drm_device *);
533 void (*reclaim_buffers_locked)(struct drm_device *, drm_file_t *);
534 int (*presetup)(struct drm_device *);
535 int (*postsetup)(struct drm_device *);
536 int (*open_helper)(struct drm_device *, drm_file_t *);
537 void (*free_filp_priv)(struct drm_device *, drm_file_t *);
538 void (*release)(struct drm_device *, void *);
539 int (*dma_ioctl)(DRM_IOCTL_ARGS);
540 void (*dma_ready)(struct drm_device *);
541 int (*dma_quiescent)(struct drm_device *);
542 int (*dma_flush_block_and_flush)(struct drm_device *,
543 int, drm_lock_flags_t);
544 int (*dma_flush_unblock)(struct drm_device *, int,
545 drm_lock_flags_t);
546 int (*context_ctor)(struct drm_device *, int);
547 int (*context_dtor)(struct drm_device *, int);
548 int (*kernel_context_switch)(struct drm_device *, int, int);
549 int (*kernel_context_switch_unlock)(struct drm_device *);
550 int (*device_is_agp) (struct drm_device *);
551 int (*irq_preinstall)(struct drm_device *);
552 void (*irq_postinstall)(struct drm_device *);
553 void (*irq_uninstall)(struct drm_device *dev);
554 uint_t (*irq_handler)(DRM_IRQ_ARGS);
555 int (*vblank_wait)(struct drm_device *, unsigned int *);
556 int (*vblank_wait2)(struct drm_device *, unsigned int *);
557 /* added for intel minimized vblank */
558 u32 (*get_vblank_counter)(struct drm_device *dev, int crtc);
559 int (*enable_vblank)(struct drm_device *dev, int crtc);
560 void (*disable_vblank)(struct drm_device *dev, int crtc);
561
562 drm_ioctl_desc_t *driver_ioctls;
563 int max_driver_ioctl;
564
565 int buf_priv_size;
566 int driver_major;
567 int driver_minor;
568 int driver_patchlevel;
569 const char *driver_name; /* Simple driver name */
570 const char *driver_desc; /* Longer driver name */
571 const char *driver_date; /* Date of last major changes. */
572
573 unsigned use_agp :1;
574 unsigned require_agp :1;
575 unsigned use_sg :1;
576 unsigned use_dma :1;
577 unsigned use_pci_dma :1;
578 unsigned use_dma_queue :1;
579 unsigned use_irq :1;
580 unsigned use_vbl_irq :1;
581 unsigned use_vbl_irq2 :1;
582 unsigned use_mtrr :1;
583};
584
585/*
586 * hardware-specific code needs to initialize mutexes which
587 * can be used in interrupt context, so they need to know
588 * the interrupt priority. Interrupt cookie in drm_device
589 * structure is the intr_block field.
590 */
591#define DRM_INTR_PRI(dev) \
592 DDI_INTR_PRI((dev)->intr_block)
593
594struct drm_device {
595 drm_driver_t *driver;
596 drm_cminor_list_t minordevs;
597 dev_info_t *dip;
598 void *drm_handle;
599 int drm_supported;
600 const char *desc; /* current driver description */
601 kmutex_t *irq_mutex;
602 kcondvar_t *irq_cv;
603
604 ddi_iblock_cookie_t intr_block;
605 uint32_t pci_device; /* PCI device id */
606 uint32_t pci_vendor;
607 char *unique; /* Unique identifier: e.g., busid */
608 int unique_len; /* Length of unique field */
609 int if_version; /* Highest interface version set */
610 int flags; /* Flags to open(2) */
611
612 /* Locks */
613 kmutex_t vbl_lock; /* protects vblank operations */
614 kmutex_t dma_lock; /* protects dev->dma */
615 kmutex_t irq_lock; /* protects irq condition checks */
616 kmutex_t dev_lock; /* protects everything else */
617 drm_lock_data_t lock; /* Information on hardware lock */
618
619 /* Usage Counters */
620 int open_count; /* Outstanding files open */
621 int buf_use; /* Buffers in use -- cannot alloc */
622
623 /* Performance counters */
624 unsigned long counters;
625 drm_stat_type_t types[15];
626 uint32_t counts[15];
627
628 /* Authentication */
629 drm_file_list_t files;
630 drm_magic_head_t magiclist[DRM_HASH_SIZE];
631
632 /* Linked list of mappable regions. Protected by dev_lock */
633 drm_map_list_t maplist;
634
635 drm_local_map_t **context_sareas;
636 int max_context;
637
638 /* DMA queues (contexts) */
639 drm_device_dma_t *dma; /* Optional pointer for DMA support */
640
641 /* Context support */
642 int irq; /* Interrupt used by board */
643 int irq_enabled; /* True if the irq handler is enabled */
644 int pci_domain;
645 int pci_bus;
646 int pci_slot;
647 int pci_func;
648 atomic_t context_flag; /* Context swapping flag */
649 int last_context; /* Last current context */
650
651 /* Only used for Radeon */
652 atomic_t vbl_received;
653 atomic_t vbl_received2;
654
655 drm_vbl_sig_list_t vbl_sig_list;
656 drm_vbl_sig_list_t vbl_sig_list2;
657
658 wait_queue_head_t vbl_queue; /* vbl wait channel */
659 /* vbl wait channel array */
660 wait_queue_head_t *vbl_queues;
661
662 /* number of VBLANK interrupts */
663 /* (driver must alloc the right number of counters) */
664 atomic_t *_vblank_count;
665 /* signal list to send on VBLANK */
666 struct drm_vbl_sig_list *vbl_sigs;
667
668 /* number of signals pending on all crtcs */
669 atomic_t vbl_signal_pending;
670 /* number of users of vblank interrupts per crtc */
671 atomic_t *vblank_refcount;
672 /* protected by dev->vbl_lock, used for wraparound handling */
673 u32 *last_vblank;
674 /* so we don't call enable more than */
675 atomic_t *vblank_enabled;
676 /* for compensation of spurious wraparounds */
677 u32 *vblank_premodeset;
678 /* Don't wait while crtc is likely disabled */
679 int *vblank_suspend;
680 /* size of vblank counter register */
681 u32 max_vblank_count;
682 int num_crtcs;
683 kmutex_t tasklet_lock;
684 void (*locked_tasklet_func)(struct drm_device *dev);
685
686 pid_t buf_pgid;
687 drm_agp_head_t *agp;
688 drm_sg_mem_t *sg; /* Scatter gather memory */
689 uint32_t *ctx_bitmap;
690 void *dev_private;
691 unsigned int agp_buffer_token;
692 drm_local_map_t *agp_buffer_map;
693
694 kstat_t *asoft_ksp; /* kstat support */
695
696 /* name Drawable information */
697 kmutex_t drw_lock;
698 unsigned int drw_bitfield_length;
699 u32 *drw_bitfield;
700 unsigned int drw_info_length;
701 drm_drawable_info_t **drw_info;
702 /*
703 * Saving S3 context
704 */
705 void *s3_private;
706};
707
708/* Memory management support (drm_memory.c) */
709void drm_mem_init(void);
710void drm_mem_uninit(void);
711void *drm_alloc(size_t, int);
712void *drm_calloc(size_t, size_t, int);
713void *drm_realloc(void *, size_t, size_t, int);
714void drm_free(void *, size_t, int);
715int drm_ioremap(drm_device_t *, drm_local_map_t *);
716void drm_ioremapfree(drm_local_map_t *);
717
718void drm_core_ioremap(struct drm_local_map *, struct drm_device *);
719void drm_core_ioremapfree(struct drm_local_map *, struct drm_device *);
720
721void drm_pci_free(drm_device_t *, drm_dma_handle_t *);
722void *drm_pci_alloc(drm_device_t *, size_t, size_t, dma_addr_t, int);
723
724struct drm_local_map *drm_core_findmap(struct drm_device *, unsigned long);
725
726int drm_context_switch(drm_device_t *, int, int);
727int drm_context_switch_complete(drm_device_t *, int);
728int drm_ctxbitmap_init(drm_device_t *);
729void drm_ctxbitmap_cleanup(drm_device_t *);
730void drm_ctxbitmap_free(drm_device_t *, int);
731int drm_ctxbitmap_next(drm_device_t *);
732
733/* Locking IOCTL support (drm_lock.c) */
734int drm_lock_take(drm_lock_data_t *, unsigned int);
735int drm_lock_transfer(drm_device_t *,
736 drm_lock_data_t *, unsigned int);
737int drm_lock_free(drm_device_t *,
738 volatile unsigned int *, unsigned int);
739
740/* Buffer management support (drm_bufs.c) */
741unsigned long drm_get_resource_start(drm_device_t *, unsigned int);
742unsigned long drm_get_resource_len(drm_device_t *, unsigned int);
743int drm_initmap(drm_device_t *, unsigned long, unsigned long,
744 unsigned int, int, int);
745void drm_rmmap(drm_device_t *, drm_local_map_t *);
746int drm_addmap(drm_device_t *, unsigned long, unsigned long,
747 drm_map_type_t, drm_map_flags_t, drm_local_map_t **);
748int drm_order(unsigned long);
749
750/* DMA support (drm_dma.c) */
751int drm_dma_setup(drm_device_t *);
752void drm_dma_takedown(drm_device_t *);
753void drm_free_buffer(drm_device_t *, drm_buf_t *);
754void drm_reclaim_buffers(drm_device_t *, drm_file_t *);
755#define drm_core_reclaim_buffers drm_reclaim_buffers
756
757/* IRQ support (drm_irq.c) */
758int drm_irq_install(drm_device_t *);
759int drm_irq_uninstall(drm_device_t *);
760uint_t drm_irq_handler(DRM_IRQ_ARGS);
761void drm_driver_irq_preinstall(drm_device_t *);
762void drm_driver_irq_postinstall(drm_device_t *);
763void drm_driver_irq_uninstall(drm_device_t *);
764int drm_vblank_wait(drm_device_t *, unsigned int *);
765void drm_vbl_send_signals(drm_device_t *);
766void drm_handle_vblank(struct drm_device *dev, int crtc);
767u32 drm_vblank_count(struct drm_device *dev, int crtc);
768int drm_vblank_get(struct drm_device *dev, int crtc);
769void drm_vblank_put(struct drm_device *dev, int crtc);
770int drm_vblank_init(struct drm_device *dev, int num_crtcs);
771void drm_locked_tasklet(drm_device_t *, void(*func)(drm_device_t *));
772
773/* AGP/GART support (drm_agpsupport.c) */
774int drm_device_is_agp(drm_device_t *);
775int drm_device_is_pcie(drm_device_t *);
776drm_agp_head_t *drm_agp_init(drm_device_t *);
777void drm_agp_fini(drm_device_t *);
778int drm_agp_do_release(drm_device_t *);
779void *drm_agp_allocate_memory(size_t, uint32_t);
780int drm_agp_free_memory(void *);
781int drm_agp_bind_memory(unsigned int, uint32_t, drm_device_t *);
782int drm_agp_unbind_memory(unsigned long, drm_device_t *);
783
784/* kstat support (drm_kstats.c) */
785int drm_init_kstats(drm_device_t *);
786void drm_fini_kstats(drm_device_t *);
787
788/* Scatter Gather Support (drm_scatter.c) */
789void drm_sg_cleanup(drm_device_t *, drm_sg_mem_t *);
790
791/* ATI PCIGART support (ati_pcigart.c) */
792int drm_ati_pcigart_init(drm_device_t *, drm_ati_pcigart_info *);
793int drm_ati_pcigart_cleanup(drm_device_t *, drm_ati_pcigart_info *);
794
795/* Locking IOCTL support (drm_drv.c) */
796int drm_lock(DRM_IOCTL_ARGS);
797int drm_unlock(DRM_IOCTL_ARGS);
798int drm_version(DRM_IOCTL_ARGS);
799int drm_setversion(DRM_IOCTL_ARGS);
800
801/* Misc. IOCTL support (drm_ioctl.c) */
802int drm_irq_by_busid(DRM_IOCTL_ARGS);
803int drm_getunique(DRM_IOCTL_ARGS);
804int drm_setunique(DRM_IOCTL_ARGS);
805int drm_getmap(DRM_IOCTL_ARGS);
806int drm_getclient(DRM_IOCTL_ARGS);
807int drm_getstats(DRM_IOCTL_ARGS);
808int drm_noop(DRM_IOCTL_ARGS);
809
810/* Context IOCTL support (drm_context.c) */
811int drm_resctx(DRM_IOCTL_ARGS);
812int drm_addctx(DRM_IOCTL_ARGS);
813int drm_modctx(DRM_IOCTL_ARGS);
814int drm_getctx(DRM_IOCTL_ARGS);
815int drm_switchctx(DRM_IOCTL_ARGS);
816int drm_newctx(DRM_IOCTL_ARGS);
817int drm_rmctx(DRM_IOCTL_ARGS);
818int drm_setsareactx(DRM_IOCTL_ARGS);
819int drm_getsareactx(DRM_IOCTL_ARGS);
820
821/* Drawable IOCTL support (drm_drawable.c) */
822int drm_adddraw(DRM_IOCTL_ARGS);
823int drm_rmdraw(DRM_IOCTL_ARGS);
824int drm_update_draw(DRM_IOCTL_ARGS);
825
826/* Authentication IOCTL support (drm_auth.c) */
827int drm_getmagic(DRM_IOCTL_ARGS);
828int drm_authmagic(DRM_IOCTL_ARGS);
829int drm_remove_magic(drm_device_t *, drm_magic_t);
830drm_file_t *drm_find_file(drm_device_t *, drm_magic_t);
831/* Buffer management support (drm_bufs.c) */
832int drm_addmap_ioctl(DRM_IOCTL_ARGS);
833int drm_rmmap_ioctl(DRM_IOCTL_ARGS);
834int drm_addbufs_ioctl(DRM_IOCTL_ARGS);
835int drm_infobufs(DRM_IOCTL_ARGS);
836int drm_markbufs(DRM_IOCTL_ARGS);
837int drm_freebufs(DRM_IOCTL_ARGS);
838int drm_mapbufs(DRM_IOCTL_ARGS);
839
840/* DMA support (drm_dma.c) */
841int drm_dma(DRM_IOCTL_ARGS);
842
843/* IRQ support (drm_irq.c) */
844int drm_control(DRM_IOCTL_ARGS);
845int drm_wait_vblank(DRM_IOCTL_ARGS);
846
847/* AGP/GART support (drm_agpsupport.c) */
848int drm_agp_acquire(DRM_IOCTL_ARGS);
849int drm_agp_release(DRM_IOCTL_ARGS);
850int drm_agp_enable(DRM_IOCTL_ARGS);
851int drm_agp_info(DRM_IOCTL_ARGS);
852int drm_agp_alloc(DRM_IOCTL_ARGS);
853int drm_agp_free(DRM_IOCTL_ARGS);
854int drm_agp_unbind(DRM_IOCTL_ARGS);
855int drm_agp_bind(DRM_IOCTL_ARGS);
856
857/* Scatter Gather Support (drm_scatter.c) */
858int drm_sg_alloc(DRM_IOCTL_ARGS);
859int drm_sg_free(DRM_IOCTL_ARGS);
860
861extern int drm_debug_flag;
862
863
864/* We add function to support DRM_DEBUG,DRM_ERROR,DRM_INFO */
865extern void drm_debug(const char *fmt, ...);
866extern void drm_error(const char *fmt, ...);
867extern void drm_info(const char *fmt, ...);
868
869#ifdef DEBUG
870#define DRM_DEBUG if (drm_debug_flag >= 2) drm_debug
871#define DRM_INFO if (drm_debug_flag >= 1) drm_info
872#else
873#define DRM_DEBUG(...)
874#define DRM_INFO(...)
875#endif
876
877#define DRM_ERROR drm_error
878
879
880#define MAX_INSTNUMS 16
881
882extern int drm_dev_to_instance(dev_t);
883extern int drm_dev_to_minor(dev_t);
884extern void *drm_supp_register(dev_info_t *, drm_device_t *);
885extern int drm_supp_unregister(void *);
886
887extern int drm_open(drm_device_t *, drm_cminor_t *, int, int, cred_t *);
888extern int drm_close(drm_device_t *, int, int, int, cred_t *);
889extern int drm_attach(drm_device_t *);
890extern int drm_detach(drm_device_t *);
891extern int drm_probe(drm_device_t *, drm_pci_id_list_t *);
892
893extern int drm_pci_init(drm_device_t *);
894extern void drm_pci_end(drm_device_t *);
895extern int pci_get_info(drm_device_t *, int *, int *, int *);
896extern int pci_get_irq(drm_device_t *);
897extern int pci_get_vendor(drm_device_t *);
898extern int pci_get_device(drm_device_t *);
899
900extern struct drm_drawable_info *drm_get_drawable_info(drm_device_t *,
901 drm_drawable_t);
902/* File Operations helpers (drm_fops.c) */
903extern drm_file_t *drm_find_file_by_proc(drm_device_t *, cred_t *);
904extern drm_cminor_t *drm_find_file_by_minor(drm_device_t *, int);
905extern int drm_open_helper(drm_device_t *, drm_cminor_t *, int, int,
906 cred_t *);
907
908#endif /* _DRMP_H */
Note: See TracBrowser for help on using the repository browser.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette