Remove the map argument from DRM_*MEMORYBARRIER. Not all of the uses of
[platform/upstream/libdrm.git] / linux-core / drm_os_linux.h
1 #define __NO_VERSION__
2
3 #include <linux/interrupt.h>    /* For task queue support */
4 #include <linux/delay.h>
5
6 #define DRMFILE                         struct file *
7 #define DRM_IOCTL_ARGS                  struct inode *inode, struct file *filp, unsigned int cmd, unsigned long data
8 #define DRM_ERR(d)                      -(d)
9 #define DRM_CURRENTPID                  current->pid
10 #define DRM_UDELAY(d)                   udelay(d)
11 #define DRM_READ8(map, offset)          readb(((unsigned long)(map)->handle) + (offset))
12 #define DRM_READ32(map, offset)         readl(((unsigned long)(map)->handle) + (offset))
13 #define DRM_WRITE8(map, offset, val)    writeb(val, ((unsigned long)(map)->handle) + (offset))
14 #define DRM_WRITE32(map, offset, val)   writel(val, ((unsigned long)(map)->handle) + (offset))
15 #define DRM_READMEMORYBARRIER()         rmb()
16 #define DRM_WRITEMEMORYBARRIER()        wmb()
17 #define DRM_MEMORYBARRIER()             mb()
18 #define DRM_DEVICE      drm_file_t      *priv   = filp->private_data; \
19                         drm_device_t    *dev    = priv->dev
20
21 #define DRM_IRQ_ARGS            int irq, void *arg, struct pt_regs *regs
22 #define DRM_TASKQUEUE_ARGS      void *arg
23
24 /* For data going from/to the kernel through the ioctl argument */
25 #define DRM_COPY_FROM_USER_IOCTL(arg1, arg2, arg3)      \
26         if ( copy_from_user(&arg1, arg2, arg3) )        \
27                 return -EFAULT
28 #define DRM_COPY_TO_USER_IOCTL(arg1, arg2, arg3)        \
29         if ( copy_to_user(arg1, &arg2, arg3) )          \
30                 return -EFAULT
31 /* Other copying of data from/to kernel space */
32 #define DRM_COPY_FROM_USER(arg1, arg2, arg3)            \
33         copy_from_user(arg1, arg2, arg3)
34 #define DRM_COPY_TO_USER(arg1, arg2, arg3)              \
35         copy_to_user(arg1, arg2, arg3)
36 /* Macros for copyfrom user, but checking readability only once */
37 #define DRM_VERIFYAREA_READ( uaddr, size )              \
38         verify_area( VERIFY_READ, uaddr, size )
39 #define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3)  \
40         __copy_from_user(arg1, arg2, arg3)
41 #define DRM_GET_USER_UNCHECKED(val, uaddr)              \
42         __get_user(val, uaddr)
43
44
45 /* malloc/free without the overhead of DRM(alloc) */
46 #define DRM_MALLOC(x) kmalloc(x, GFP_KERNEL)
47 #define DRM_FREE(x,size) kfree(x)
48
49 #define DRM_GETSAREA()                                                   \
50 do {                                                                     \
51         drm_map_list_t *entry;                                           \
52         list_for_each_entry( entry, &dev->maplist->head, head ) {        \
53                 if ( entry->map &&                                       \
54                      entry->map->type == _DRM_SHM &&                     \
55                      (entry->map->flags & _DRM_CONTAINS_LOCK) ) {        \
56                         dev_priv->sarea = entry->map;                    \
57                         break;                                           \
58                 }                                                        \
59         }                                                                \
60 } while (0)
61
62 #define DRM_HZ HZ
63
64 #define DRM_WAIT_ON( ret, queue, timeout, condition )           \
65 do {                                                            \
66         DECLARE_WAITQUEUE(entry, current);                      \
67         unsigned long end = jiffies + (timeout);                \
68         add_wait_queue(&(queue), &entry);                       \
69                                                                 \
70         for (;;) {                                              \
71                 current->state = TASK_INTERRUPTIBLE;            \
72                 if (condition)                                  \
73                         break;                                  \
74                 if (time_after_eq(jiffies, end)) {              \
75                         ret = -EBUSY;                           \
76                         break;                                  \
77                 }                                               \
78                 schedule_timeout((HZ/100 > 1) ? HZ/100 : 1);    \
79                 if (signal_pending(current)) {                  \
80                         ret = -EINTR;                           \
81                         break;                                  \
82                 }                                               \
83         }                                                       \
84         current->state = TASK_RUNNING;                          \
85         remove_wait_queue(&(queue), &entry);                    \
86 } while (0)
87
88
89 #define DRM_WAKEUP( queue ) wake_up_interruptible( queue )
90 #define DRM_INIT_WAITQUEUE( queue ) init_waitqueue_head( queue )
91