blob: 738414b2655818ad3587e29494ed100d065f44ea [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _SPARC_BYTEORDER_H
2#define _SPARC_BYTEORDER_H
3
Sam Ravnborgfffeeb42009-01-02 21:31:58 -08004#include <linux/types.h>
David S. Millerf610bbc2007-11-16 02:59:58 -08005#include <asm/asi.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -07006
Harvey Harrison398cf932008-10-29 15:36:00 -07007#define __BIG_ENDIAN
David S. Millerf610bbc2007-11-16 02:59:58 -08008
Sam Ravnborgfffeeb42009-01-02 21:31:58 -08009#if defined(__sparc__) && defined(__arch64__)
Harvey Harrison398cf932008-10-29 15:36:00 -070010static inline __u16 __arch_swab16p(const __u16 *addr)
David S. Millerf610bbc2007-11-16 02:59:58 -080011{
12 __u16 ret;
13
14 __asm__ __volatile__ ("lduha [%1] %2, %0"
15 : "=r" (ret)
16 : "r" (addr), "i" (ASI_PL));
17 return ret;
18}
Harvey Harrison398cf932008-10-29 15:36:00 -070019#define __arch_swab16p __arch_swab16p
David S. Millerf610bbc2007-11-16 02:59:58 -080020
Harvey Harrison398cf932008-10-29 15:36:00 -070021static inline __u32 __arch_swab32p(const __u32 *addr)
David S. Millerf610bbc2007-11-16 02:59:58 -080022{
23 __u32 ret;
24
25 __asm__ __volatile__ ("lduwa [%1] %2, %0"
26 : "=r" (ret)
27 : "r" (addr), "i" (ASI_PL));
28 return ret;
29}
Harvey Harrison398cf932008-10-29 15:36:00 -070030#define __arch_swab32p __arch_swab32p
David S. Millerf610bbc2007-11-16 02:59:58 -080031
Harvey Harrison398cf932008-10-29 15:36:00 -070032static inline __u64 __arch_swab64p(const __u64 *addr)
David S. Millerf610bbc2007-11-16 02:59:58 -080033{
34 __u64 ret;
35
36 __asm__ __volatile__ ("ldxa [%1] %2, %0"
37 : "=r" (ret)
38 : "r" (addr), "i" (ASI_PL));
39 return ret;
40}
Harvey Harrison398cf932008-10-29 15:36:00 -070041#define __arch_swab64p __arch_swab64p
David S. Millerf610bbc2007-11-16 02:59:58 -080042
Sam Ravnborgfffeeb42009-01-02 21:31:58 -080043#else
44#define __SWAB_64_THRU_32__
45#endif /* defined(__sparc__) && defined(__arch64__) */
David S. Millerf610bbc2007-11-16 02:59:58 -080046
Harvey Harrison398cf932008-10-29 15:36:00 -070047#include <linux/byteorder.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070048
49#endif /* _SPARC_BYTEORDER_H */