blob: 5a70f137f1f7de30a568bad15e34d815e2aed6b4 [file] [log] [blame]
Linus Torvalds1da177e2005-04-16 15:20:36 -07001#ifndef _SPARC_BYTEORDER_H
2#define _SPARC_BYTEORDER_H
3
4#include <asm/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
9#ifdef CONFIG_SPARC32
10#define __SWAB_64_THRU_32__
11#endif
12
13#ifdef CONFIG_SPARC64
Harvey Harrison398cf932008-10-29 15:36:00 -070014static inline __u16 __arch_swab16p(const __u16 *addr)
David S. Millerf610bbc2007-11-16 02:59:58 -080015{
16 __u16 ret;
17
18 __asm__ __volatile__ ("lduha [%1] %2, %0"
19 : "=r" (ret)
20 : "r" (addr), "i" (ASI_PL));
21 return ret;
22}
Harvey Harrison398cf932008-10-29 15:36:00 -070023#define __arch_swab16p __arch_swab16p
David S. Millerf610bbc2007-11-16 02:59:58 -080024
Harvey Harrison398cf932008-10-29 15:36:00 -070025static inline __u32 __arch_swab32p(const __u32 *addr)
David S. Millerf610bbc2007-11-16 02:59:58 -080026{
27 __u32 ret;
28
29 __asm__ __volatile__ ("lduwa [%1] %2, %0"
30 : "=r" (ret)
31 : "r" (addr), "i" (ASI_PL));
32 return ret;
33}
Harvey Harrison398cf932008-10-29 15:36:00 -070034#define __arch_swab32p __arch_swab32p
David S. Millerf610bbc2007-11-16 02:59:58 -080035
Harvey Harrison398cf932008-10-29 15:36:00 -070036static inline __u64 __arch_swab64p(const __u64 *addr)
David S. Millerf610bbc2007-11-16 02:59:58 -080037{
38 __u64 ret;
39
40 __asm__ __volatile__ ("ldxa [%1] %2, %0"
41 : "=r" (ret)
42 : "r" (addr), "i" (ASI_PL));
43 return ret;
44}
Harvey Harrison398cf932008-10-29 15:36:00 -070045#define __arch_swab64p __arch_swab64p
David S. Millerf610bbc2007-11-16 02:59:58 -080046
47#endif /* CONFIG_SPARC64 */
48
Harvey Harrison398cf932008-10-29 15:36:00 -070049#include <linux/byteorder.h>
Linus Torvalds1da177e2005-04-16 15:20:36 -070050
51#endif /* _SPARC_BYTEORDER_H */