2 * \file drm_os_dragonfly.h
3 * OS abstraction macros.
7 #include <sys/endian.h>
9 #include <sys/serialize.h>
10 #include <linux/interrupt.h> /* For task queue support */
11 #include <linux/delay.h>
13 /* Handle the DRM options from kernel config. */
18 # define DRM_DEBUG_DEFAULT_ON 2
20 # define DRM_DEBUG_DEFAULT_ON 1
23 #else /* !DRM_DEBUG */
24 # define DRM_DEBUG_DEFAULT_ON 0
25 #endif /* DRM_DEBUG */
26 #endif /* __DragonFly__ */
29 static inline u64 readq(void __iomem *reg)
31 return ((u64) readl(reg)) | (((u64) readl(reg + 4UL)) << 32);
34 static inline void writeq(u64 val, void __iomem *reg)
36 writel(val & 0xffffffff, reg);
37 writel(val >> 32, reg + 0x4UL);
41 /** Current process ID */
42 #define DRM_CURRENTPID (curproc != NULL ? curproc->p_pid : -1)
43 #define DRM_UDELAY(d) DELAY(d)
44 /** Read a byte from a MMIO region */
45 #define DRM_READ8(map, offset) readb(((void __iomem *)(map)->handle) + (offset))
46 /** Read a word from a MMIO region */
47 #define DRM_READ16(map, offset) readw(((void __iomem *)(map)->handle) + (offset))
48 /** Read a dword from a MMIO region */
49 #define DRM_READ32(map, offset) readl(((void __iomem *)(map)->handle) + (offset))
50 /** Write a byte into a MMIO region */
51 #define DRM_WRITE8(map, offset, val) writeb(val, ((void __iomem *)(map)->handle) + (offset))
52 /** Write a word into a MMIO region */
53 #define DRM_WRITE16(map, offset, val) writew(val, ((void __iomem *)(map)->handle) + (offset))
54 /** Write a dword into a MMIO region */
55 #define DRM_WRITE32(map, offset, val) \
56 *(volatile u_int32_t *)(((vm_offset_t)(map)->handle) + \
57 (vm_offset_t)(offset)) = htole32(val)
59 /** Read a qword from a MMIO region - be careful using these unless you really understand them */
60 #define DRM_READ64(map, offset) readq(((void __iomem *)(map)->handle) + (offset))
61 /** Write a qword into a MMIO region */
62 #define DRM_WRITE64(map, offset, val) writeq(val, ((void __iomem *)(map)->handle) + (offset))
64 #define DRM_WAIT_ON( ret, queue, timeout, condition ) \
66 wait_queue_t entry = { \
68 .func = default_wake_function, \
70 unsigned long end = jiffies + (timeout); \
71 add_wait_queue(&(queue), &entry); \
74 __set_current_state(TASK_INTERRUPTIBLE); \
77 if (time_after_eq(jiffies, end)) { \
81 schedule_timeout((HZ/100 > 1) ? HZ/100 : 1); \
82 if (signal_pending(current)) { \
87 __set_current_state(TASK_RUNNING); \
88 remove_wait_queue(&(queue), &entry); \
91 /* include code to override EDID blocks from external firmware modules */
92 #define CONFIG_DRM_LOAD_EDID_FIRMWARE