0001
0002
0003
0004
0005
0006
0007
0008
0009 #ifndef _ASM_SWAB_H
0010 #define _ASM_SWAB_H
0011
0012 #include <linux/compiler.h>
0013 #include <linux/types.h>
0014
0015 #define __SWAB_64_THRU_32__
0016
0017 #if !defined(__mips16) && \
0018 ((defined(__mips_isa_rev) && (__mips_isa_rev >= 2)) || \
0019 defined(_MIPS_ARCH_LOONGSON3A))
0020
0021 static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
0022 {
0023 __asm__(
0024 " .set push \n"
0025 " .set arch=mips32r2 \n"
0026 " wsbh %0, %1 \n"
0027 " .set pop \n"
0028 : "=r" (x)
0029 : "r" (x));
0030
0031 return x;
0032 }
0033 #define __arch_swab16 __arch_swab16
0034
0035 static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
0036 {
0037 __asm__(
0038 " .set push \n"
0039 " .set arch=mips32r2 \n"
0040 " wsbh %0, %1 \n"
0041 " rotr %0, %0, 16 \n"
0042 " .set pop \n"
0043 : "=r" (x)
0044 : "r" (x));
0045
0046 return x;
0047 }
0048 #define __arch_swab32 __arch_swab32
0049
0050
0051
0052
0053
0054 #ifdef __mips64
0055 static inline __attribute_const__ __u64 __arch_swab64(__u64 x)
0056 {
0057 __asm__(
0058 " .set push \n"
0059 " .set arch=mips64r2 \n"
0060 " dsbh %0, %1 \n"
0061 " dshd %0, %0 \n"
0062 " .set pop \n"
0063 : "=r" (x)
0064 : "r" (x));
0065
0066 return x;
0067 }
0068 #define __arch_swab64 __arch_swab64
0069 #endif
0070 #endif
0071 #endif