xref: /openbmc/linux/arch/sparc/include/uapi/asm/swab.h (revision 2a598d0b)
1 /* SPDX-License-Identifier: GPL-2.0 WITH Linux-syscall-note */
2 #ifndef _SPARC_SWAB_H
3 #define _SPARC_SWAB_H
4 
5 #include <linux/types.h>
6 #include <asm/asi.h>
7 
8 #if defined(__sparc__) && defined(__arch64__)
9 static inline __u16 __arch_swab16p(const __u16 *addr)
10 {
11 	__u16 ret;
12 
13 	__asm__ __volatile__ ("lduha [%2] %3, %0"
14 			      : "=r" (ret)
15 			      : "m" (*addr), "r" (addr), "i" (ASI_PL));
16 	return ret;
17 }
18 #define __arch_swab16p __arch_swab16p
19 
20 static inline __u32 __arch_swab32p(const __u32 *addr)
21 {
22 	__u32 ret;
23 
24 	__asm__ __volatile__ ("lduwa [%2] %3, %0"
25 			      : "=r" (ret)
26 			      : "m" (*addr), "r" (addr), "i" (ASI_PL));
27 	return ret;
28 }
29 #define __arch_swab32p __arch_swab32p
30 
31 static inline __u64 __arch_swab64p(const __u64 *addr)
32 {
33 	__u64 ret;
34 
35 	__asm__ __volatile__ ("ldxa [%2] %3, %0"
36 			      : "=r" (ret)
37 			      : "m" (*addr), "r" (addr), "i" (ASI_PL));
38 	return ret;
39 }
40 #define __arch_swab64p __arch_swab64p
41 
42 #else
43 #define __SWAB_64_THRU_32__
44 #endif /* defined(__sparc__) && defined(__arch64__) */
45 
46 #endif /* _SPARC_SWAB_H */
47