1 /** 2 * \file drm_os_dragonfly.h 3 * OS abstraction macros. 4 */ 5 6 #include <sys/param.h> 7 #include <sys/endian.h> 8 #include <sys/systm.h> 9 #include <sys/serialize.h> 10 #include <linux/delay.h> 11 12 /* Handle the DRM options from kernel config. */ 13 #ifdef __DragonFly__ 14 #include "opt_drm.h" 15 #ifdef DRM_DEBUG 16 # if DRM_DEBUG>1 17 # define DRM_DEBUG_DEFAULT_ON 2 18 # else 19 # define DRM_DEBUG_DEFAULT_ON 1 20 # endif 21 #undef DRM_DEBUG 22 /* XXX disable DRM_LINUX for now to unbreak LINT64 */ 23 #undef DRM_LINUX 24 #endif /* DRM_DEBUG */ 25 #endif /* DragonFly */ 26 27 #ifndef readq 28 static inline u64 readq(void __iomem *reg) 29 { 30 return ((u64) readl(reg)) | (((u64) readl(reg + 4UL)) << 32); 31 } 32 33 static inline void writeq(u64 val, void __iomem *reg) 34 { 35 writel(val & 0xffffffff, reg); 36 writel(val >> 32, reg + 0x4UL); 37 } 38 #endif 39 40 /** Current process ID */ 41 #define DRM_CURRENTPID (curproc != NULL ? curproc->p_pid : -1) 42 #define DRM_UDELAY(d) DELAY(d) 43 /** Read a byte from a MMIO region */ 44 #define DRM_READ8(map, offset) readb(((void __iomem *)(map)->handle) + (offset)) 45 /** Read a word from a MMIO region */ 46 #define DRM_READ16(map, offset) readw(((void __iomem *)(map)->handle) + (offset)) 47 /** Read a dword from a MMIO region */ 48 #define DRM_READ32(map, offset) readl(((void __iomem *)(map)->handle) + (offset)) 49 /** Write a byte into a MMIO region */ 50 #define DRM_WRITE8(map, offset, val) writeb(val, ((void __iomem *)(map)->handle) + (offset)) 51 /** Write a word into a MMIO region */ 52 #define DRM_WRITE16(map, offset, val) writew(val, ((void __iomem *)(map)->handle) + (offset)) 53 /** Write a dword into a MMIO region */ 54 #define DRM_WRITE32(map, offset, val) \ 55 *(volatile u_int32_t *)(((vm_offset_t)(map)->handle) + \ 56 (vm_offset_t)(offset)) = htole32(val) 57 58 /** Read a qword from a MMIO region - be careful using these unless you really understand them */ 59 #define DRM_READ64(map, offset) readq(((void __iomem *)(map)->handle) + (offset)) 60 /** Write a qword into a MMIO region */ 61 #define DRM_WRITE64(map, offset, val) writeq(val, ((void __iomem *)(map)->handle) + (offset)) 62 63 #define DRM_WAIT_ON( ret, queue, timeout, condition ) \ 64 for ( ret = 0 ; !ret && !(condition) ; ) { \ 65 lwkt_serialize_enter(&dev->irq_lock); \ 66 if (!(condition)) { \ 67 tsleep_interlock(&(queue), PCATCH); \ 68 lwkt_serialize_exit(&dev->irq_lock); \ 69 ret = -tsleep(&(queue), PCATCH | PINTERLOCKED, \ 70 "drmwtq", (timeout)); \ 71 } else { \ 72 lwkt_serialize_exit(&dev->irq_lock); \ 73 } \ 74 } 75 76 /* include code to override EDID blocks from external firmware modules */ 77 #define CONFIG_DRM_LOAD_EDID_FIRMWARE 78