From mboxrd@z Thu Jan 1 00:00:00 1970 From: Andrew Jones Subject: [PATCH v5 17/19] arm: Add IO accessors to avoid register-writeback Date: Wed, 11 Jun 2014 16:01:32 +0200 Message-ID: <1402495294-30737-18-git-send-email-drjones@redhat.com> References: <1402495294-30737-1-git-send-email-drjones@redhat.com> Cc: christoffer.dall@linaro.org, pbonzini@redhat.com To: kvmarm@lists.cs.columbia.edu, kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:21306 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932317AbaFKOCF (ORCPT ); Wed, 11 Jun 2014 10:02:05 -0400 In-Reply-To: <1402495294-30737-1-git-send-email-drjones@redhat.com> Sender: kvm-owner@vger.kernel.org List-ID: From: Christoffer Dall Add IO accessor functions to the arm library functions to avoid register-writeback IO accessors that are not yet supported by the kernel. Signed-off-by: Christoffer Dall Signed-off-by: Andrew Jones --- lib/arm/asm/io.h | 57 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 57 insertions(+) diff --git a/lib/arm/asm/io.h b/lib/arm/asm/io.h index 51ec6e9aa2e99..1d0abb7d9f405 100644 --- a/lib/arm/asm/io.h +++ b/lib/arm/asm/io.h @@ -3,6 +3,9 @@ #include "libcflat.h" #include "asm/barrier.h" +#define __iomem +#define __force + #define __bswap16 bswap16 static inline u16 bswap16(u16 val) { @@ -19,6 +22,60 @@ static inline u32 bswap32(u32 val) return ret; } +#define __raw_readb __raw_readb +static inline u8 __raw_readb(const volatile void __iomem *addr) +{ + u8 val; + asm volatile("ldrb %1, %0" + : "+Qo" (*(volatile u8 __force *)addr), + "=r" (val)); + return val; +} + +#define __raw_readw __raw_readw +static inline u16 __raw_readw(const volatile void __iomem *addr) +{ + u16 val; + asm volatile("ldrh %1, %0" + : "+Q" (*(volatile u16 __force *)addr), + "=r" (val)); + return val; +} + +#define __raw_readl __raw_readl +static inline u32 __raw_readl(const volatile void __iomem *addr) +{ + u32 val; + asm volatile("ldr %1, %0" + : "+Qo" (*(volatile u32 __force *)addr), + "=r" (val)); + return val; +} + +#define __raw_writeb __raw_writeb +static inline void __raw_writeb(u8 val, volatile void __iomem *addr) +{ + asm volatile("strb %1, %0" + : "+Qo" (*(volatile u8 __force *)addr) + : "r" (val)); +} + +#define __raw_writew __raw_writew +static inline void __raw_writew(u16 val, volatile void __iomem *addr) +{ + asm volatile("strh %1, %0" + : "+Q" (*(volatile u16 __force *)addr) + : "r" (val)); +} + +#define __raw_writel __raw_writel +static inline void __raw_writel(u32 val, volatile void __iomem *addr) +{ + asm volatile("str %1, %0" + : "+Qo" (*(volatile u32 __force *)addr) + : "r" (val)); +} + #include "asm-generic/io.h" #endif /* _ASMARM_IO_H_ */ -- 1.9.3