3 #include <linux/interrupt.h> /* For task queue support */
4 #include <linux/delay.h>
6 #define DRM_IOCTL_ARGS struct inode *inode, struct file *filp, unsigned int cmd, unsigned long data
7 #define DRM_ERR(d) -(d)
8 #define DRM_CURRENTPID current->pid
9 #define DRM_UDELAY(d) udelay(d)
10 #define DRM_READ8(map, offset) readb(((unsigned long)(map)->handle) + (offset))
11 #define DRM_READ32(map, offset) readl(((unsigned long)(map)->handle) + (offset))
12 #define DRM_WRITE8(map, offset, val) writeb(val, ((unsigned long)(map)->handle) + (offset))
13 #define DRM_WRITE32(map, offset, val) writel(val, ((unsigned long)(map)->handle) + (offset))
14 #define DRM_READMEMORYBARRIER(map) mb()
15 #define DRM_WRITEMEMORYBARRIER(map) wmb()
16 #define DRM_DEVICE drm_file_t *priv = filp->private_data; \
17 drm_device_t *dev = priv->dev
19 #define DRM_IRQ_ARGS int irq, void *arg, struct pt_regs *regs
20 #define DRM_TASKQUEUE_ARGS void *arg
22 /* For data going from/to the kernel through the ioctl argument */
23 #define DRM_COPY_FROM_USER_IOCTL(arg1, arg2, arg3) \
24 if ( copy_from_user(&arg1, arg2, arg3) ) \
26 #define DRM_COPY_TO_USER_IOCTL(arg1, arg2, arg3) \
27 if ( copy_to_user(arg1, &arg2, arg3) ) \
29 /* Other copying of data from/to kernel space */
30 #define DRM_COPY_FROM_USER(arg1, arg2, arg3) \
31 copy_from_user(arg1, arg2, arg3)
32 #define DRM_COPY_TO_USER(arg1, arg2, arg3) \
33 copy_to_user(arg1, arg2, arg3)
34 /* Macros for copyfrom user, but checking readability only once */
35 #define DRM_VERIFYAREA_READ( uaddr, size ) \
36 verify_area( VERIFY_READ, uaddr, size )
37 #define DRM_COPY_FROM_USER_UNCHECKED(arg1, arg2, arg3) \
38 __copy_from_user(arg1, arg2, arg3)
39 #define DRM_GET_USER_UNCHECKED(val, uaddr) \
40 __get_user(val, uaddr)
43 /* malloc/free without the overhead of DRM(alloc) */
44 #define DRM_MALLOC(x) kmalloc(x, GFP_KERNEL)
45 #define DRM_FREE(x) kfree(x)
47 #define DRM_GETSAREA() \
49 struct list_head *list; \
50 list_for_each( list, &dev->maplist->head ) { \
51 drm_map_list_t *entry = (drm_map_list_t *)list; \
53 entry->map->type == _DRM_SHM && \
54 (entry->map->flags & _DRM_CONTAINS_LOCK) ) { \
55 dev_priv->sarea = entry->map; \
63 #define DRM_WAIT_ON( ret, queue, timeout, condition ) \
65 DECLARE_WAITQUEUE(entry, current); \
66 unsigned long end = jiffies + (timeout); \
67 add_wait_queue(&(queue), &entry); \
70 current->state = TASK_INTERRUPTIBLE; \
73 if((signed)(end - jiffies) <= 0) { \
77 schedule_timeout((HZ/100 > 1) ? HZ/100 : 1); \
78 if (signal_pending(current)) { \
83 current->state = TASK_RUNNING; \
84 remove_wait_queue(&(queue), &entry); \
88 #define DRM_WAKEUP( queue ) wake_up_interruptible( queue )
89 #define DRM_INIT_WAITQUEUE( queue ) init_waitqueue_head( queue )