]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/blob - include/drm/drm_os_linux.h
netfilter: nat: fix src map lookup
[mirror_ubuntu-artful-kernel.git] / include / drm / drm_os_linux.h
1 /**
2 * \file drm_os_linux.h
3 * OS abstraction macros.
4 */
5
6 #include <linux/interrupt.h> /* For task queue support */
7 #include <linux/sched/signal.h>
8 #include <linux/delay.h>
9 #include <linux/io-64-nonatomic-lo-hi.h>
10
11 /** Current process ID */
12 #define DRM_CURRENTPID task_pid_nr(current)
13 #define DRM_UDELAY(d) udelay(d)
14 /** Read a byte from a MMIO region */
15 #define DRM_READ8(map, offset) readb(((void __iomem *)(map)->handle) + (offset))
16 /** Read a word from a MMIO region */
17 #define DRM_READ16(map, offset) readw(((void __iomem *)(map)->handle) + (offset))
18 /** Read a dword from a MMIO region */
19 #define DRM_READ32(map, offset) readl(((void __iomem *)(map)->handle) + (offset))
20 /** Write a byte into a MMIO region */
21 #define DRM_WRITE8(map, offset, val) writeb(val, ((void __iomem *)(map)->handle) + (offset))
22 /** Write a word into a MMIO region */
23 #define DRM_WRITE16(map, offset, val) writew(val, ((void __iomem *)(map)->handle) + (offset))
24 /** Write a dword into a MMIO region */
25 #define DRM_WRITE32(map, offset, val) writel(val, ((void __iomem *)(map)->handle) + (offset))
26
27 /** Read a qword from a MMIO region - be careful using these unless you really understand them */
28 #define DRM_READ64(map, offset) readq(((void __iomem *)(map)->handle) + (offset))
29 /** Write a qword into a MMIO region */
30 #define DRM_WRITE64(map, offset, val) writeq(val, ((void __iomem *)(map)->handle) + (offset))
31
32 #define DRM_WAIT_ON( ret, queue, timeout, condition ) \
33 do { \
34 DECLARE_WAITQUEUE(entry, current); \
35 unsigned long end = jiffies + (timeout); \
36 add_wait_queue(&(queue), &entry); \
37 \
38 for (;;) { \
39 __set_current_state(TASK_INTERRUPTIBLE); \
40 if (condition) \
41 break; \
42 if (time_after_eq(jiffies, end)) { \
43 ret = -EBUSY; \
44 break; \
45 } \
46 schedule_timeout((HZ/100 > 1) ? HZ/100 : 1); \
47 if (signal_pending(current)) { \
48 ret = -EINTR; \
49 break; \
50 } \
51 } \
52 __set_current_state(TASK_RUNNING); \
53 remove_wait_queue(&(queue), &entry); \
54 } while (0)