3 * OS abstraction macros.
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>
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))
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))
32 #define DRM_WAIT_ON( ret, queue, timeout, condition ) \
34 DECLARE_WAITQUEUE(entry, current); \
35 unsigned long end = jiffies + (timeout); \
36 add_wait_queue(&(queue), &entry); \
39 __set_current_state(TASK_INTERRUPTIBLE); \
42 if (time_after_eq(jiffies, end)) { \
46 schedule_timeout((HZ/100 > 1) ? HZ/100 : 1); \
47 if (signal_pending(current)) { \
52 __set_current_state(TASK_RUNNING); \
53 remove_wait_queue(&(queue), &entry); \