From owner-svn-src-all@freebsd.org Tue May 10 12:04:58 2016 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id D771EB353D1; Tue, 10 May 2016 12:04:58 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id B31221DB0; Tue, 10 May 2016 12:04:58 +0000 (UTC) (envelope-from hselasky@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u4AC4viw007265; Tue, 10 May 2016 12:04:57 GMT (envelope-from hselasky@FreeBSD.org) Received: (from hselasky@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u4AC4vhR007264; Tue, 10 May 2016 12:04:57 GMT (envelope-from hselasky@FreeBSD.org) Message-Id: <201605101204.u4AC4vhR007264@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: hselasky set sender to hselasky@FreeBSD.org using -f From: Hans Petter Selasky Date: Tue, 10 May 2016 12:04:57 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r299364 - head/sys/compat/linuxkpi/common/include/linux X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 May 2016 12:04:58 -0000 Author: hselasky Date: Tue May 10 12:04:57 2016 New Revision: 299364 URL: https://svnweb.freebsd.org/changeset/base/299364 Log: Add more LinuxKPI I/O functions. Obtained from: kmacy @ MFC after: 1 week Sponsored by: Mellanox Technologies Modified: head/sys/compat/linuxkpi/common/include/linux/io.h Modified: head/sys/compat/linuxkpi/common/include/linux/io.h ============================================================================== --- head/sys/compat/linuxkpi/common/include/linux/io.h Tue May 10 11:39:36 2016 (r299363) +++ head/sys/compat/linuxkpi/common/include/linux/io.h Tue May 10 12:04:57 2016 (r299364) @@ -35,6 +35,8 @@ #include #include +#include + static inline uint32_t __raw_readl(const volatile void *addr) { @@ -62,7 +64,7 @@ __raw_writeq(uint64_t b, volatile void * /* * XXX This is all x86 specific. It should be bus space access. */ -#define mmiowb() +#define mmiowb() barrier() #undef writel static inline void @@ -92,6 +94,27 @@ writew(uint16_t b, void *addr) *(volatile uint16_t *)addr = b; } +#undef ioread8 +static inline uint8_t +ioread8(const volatile void *addr) +{ + return *(const volatile uint8_t *)addr; +} + +#undef ioread16 +static inline uint16_t +ioread16(const volatile void *addr) +{ + return *(const volatile uint16_t *)addr; +} + +#undef ioread32 +static inline uint32_t +ioread32(const volatile void *addr) +{ + return *(const volatile uint32_t *)addr; +} + #undef ioread32be static inline uint32_t ioread32be(const volatile void *addr) @@ -99,6 +122,27 @@ ioread32be(const volatile void *addr) return be32toh(*(const volatile uint32_t *)addr); } +#undef iowrite8 +static inline void +iowrite8(uint8_t v, volatile void *addr) +{ + *(volatile uint8_t *)addr = v; +} + +#undef iowrite16 +static inline void +iowrite16(uint16_t v, volatile void *addr) +{ + *(volatile uint16_t *)addr = v; +} + +#undef iowrite32 +static inline void +iowrite32(uint32_t v, volatile void *addr) +{ + *(volatile uint32_t *)addr = v; +} + #undef iowrite32be static inline void iowrite32be(uint32_t v, volatile void *addr) @@ -137,6 +181,8 @@ void *_ioremap_attr(vm_paddr_t phys_addr _ioremap_attr((addr), (size), VM_MEMATTR_UNCACHEABLE) #define ioremap_wc(addr, size) \ _ioremap_attr((addr), (size), VM_MEMATTR_WRITE_COMBINING) +#define ioremap_wb(addr, size) \ + _ioremap_attr((addr), (size), VM_MEMATTR_WRITE_BACK) #define ioremap(addr, size) \ _ioremap_attr((addr), (size), VM_MEMATTR_UNCACHEABLE) void iounmap(void *addr); @@ -166,5 +212,35 @@ __iowrite64_copy(void *to, void *from, s #endif } +enum { + MEMREMAP_WB = 1 << 0, + MEMREMAP_WT = 1 << 1, + MEMREMAP_WC = 1 << 2, +}; + +static inline void * +memremap(resource_size_t offset, size_t size, unsigned long flags) +{ + void *addr = NULL; + + if ((flags & MEMREMAP_WB) && + (addr = ioremap_wb(offset, size)) != NULL) + goto done; + if ((flags & MEMREMAP_WT) && + (addr = ioremap_nocache(offset, size)) != NULL) + goto done; + if ((flags & MEMREMAP_WC) && + (addr = ioremap_wc(offset, size)) != NULL) + goto done; +done: + return (addr); +} + +static inline void +memunmap(void *addr) +{ + /* XXX May need to check if this is RAM */ + iounmap(addr); +} #endif /* _LINUX_IO_H_ */