Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

ARM: 8189/1: arm64:add bitrev.h file to support rbit instruction

This patch add bitrev.h file to support rbit instruction,
so that we can do bitrev operation by hardware.

Signed-off-by: Yalin Wang <yalin.wang@sonymobile.com>
Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Russell King <rmk+kernel@arm.linux.org.uk>

authored by

Yalin Wang and committed by
Russell King
8e7a4cef 556d2f05

+20
+1
arch/arm64/Kconfig
··· 39 39 select HARDIRQS_SW_RESEND 40 40 select HAVE_ALIGNED_STRUCT_PAGE if SLUB 41 41 select HAVE_ARCH_AUDITSYSCALL 42 + select HAVE_ARCH_BITREVERSE 42 43 select HAVE_ARCH_JUMP_LABEL 43 44 select HAVE_ARCH_KGDB 44 45 select HAVE_ARCH_SECCOMP_FILTER
+19
arch/arm64/include/asm/bitrev.h
··· 1 + #ifndef __ASM_BITREV_H 2 + #define __ASM_BITREV_H 3 + static __always_inline __attribute_const__ u32 __arch_bitrev32(u32 x) 4 + { 5 + __asm__ ("rbit %w0, %w1" : "=r" (x) : "r" (x)); 6 + return x; 7 + } 8 + 9 + static __always_inline __attribute_const__ u16 __arch_bitrev16(u16 x) 10 + { 11 + return __arch_bitrev32((u32)x) >> 16; 12 + } 13 + 14 + static __always_inline __attribute_const__ u8 __arch_bitrev8(u8 x) 15 + { 16 + return __arch_bitrev32((u32)x) >> 24; 17 + } 18 + 19 + #endif