add initial support for hardware accelerated byte swapping
[oweals/openwrt.git] / target / linux / adm5120-2.6 / patches / 008-adm5120_hardware_swab.patch
1 --- linux-2.6.19.2/include/asm-mips/byteorder.h 2007-01-10 20:10:37.000000000 +0100
2 +++ linux-2.6.19.2.new/include/asm-mips/byteorder.h     2007-05-16 21:14:47.000000000 +0200
3 @@ -58,6 +58,35 @@
4  
5  #endif /* CONFIG_CPU_MIPSR2 */
6  
7 +#ifdef CONFIG_ADM5120_HARDWARE_SWAB
8 +
9 +static __inline__ __attribute_const__ __u16 ___adm5120__swab16(__u16 x)
10 +{
11 +       __asm__ (
12 +       "       sw      %2, 0xC8(%1)                    \n"
13 +       "       lhu     %0, 0xCC(%1)                    \n"
14 +       : "=r" (x)
15 +       : "r" (0xB2000000), "r" (x));
16 +
17 +       return x;
18 +}
19 +
20 +static __inline__ __attribute_const__ __u32 ___adm5120__swab32(__u32 x)
21 +{
22 +       __asm__ (
23 +       "       sw      %2, 0xC8(%1)                    \n"
24 +       "       lw      %0, 0xCC(%1)                    \n"
25 +       : "=r" (x)
26 +       : "r" (0xB2000000), "r" (x));
27 +
28 +       return x;
29 +}
30 +
31 +#define __arch__swab16(x)      ___adm5120__swab16(x)
32 +#define __arch__swab32(x)      ___adm5120__swab32(x)
33 +
34 +#endif /* CONFIG_ADM5120_HARDWARE_SWAB */
35 +
36  #if !defined(__STRICT_ANSI__) || defined(__KERNEL__)
37  #  define __BYTEORDER_HAS_U64__
38  #  define __SWAB_64_THRU_32__