diff options
Diffstat (limited to 'arch/s390/include/asm/swab.h')
-rw-r--r-- | arch/s390/include/asm/swab.h | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/arch/s390/include/asm/swab.h b/arch/s390/include/asm/swab.h new file mode 100644 index 000000000000..bd9321aa55a9 --- /dev/null +++ b/arch/s390/include/asm/swab.h | |||
@@ -0,0 +1,91 @@ | |||
1 | #ifndef _S390_SWAB_H | ||
2 | #define _S390_SWAB_H | ||
3 | |||
4 | /* | ||
5 | * include/asm-s390/swab.h | ||
6 | * | ||
7 | * S390 version | ||
8 | * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation | ||
9 | * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) | ||
10 | */ | ||
11 | |||
12 | #include <asm/types.h> | ||
13 | |||
14 | #ifndef __s390x__ | ||
15 | # define __SWAB_64_THRU_32__ | ||
16 | #endif | ||
17 | |||
18 | #ifdef __s390x__ | ||
19 | static inline __u64 __arch_swab64p(const __u64 *x) | ||
20 | { | ||
21 | __u64 result; | ||
22 | |||
23 | asm volatile("lrvg %0,%1" : "=d" (result) : "m" (*x)); | ||
24 | return result; | ||
25 | } | ||
26 | #define __arch_swab64p __arch_swab64p | ||
27 | |||
28 | static inline __u64 __arch_swab64(__u64 x) | ||
29 | { | ||
30 | __u64 result; | ||
31 | |||
32 | asm volatile("lrvgr %0,%1" : "=d" (result) : "d" (x)); | ||
33 | return result; | ||
34 | } | ||
35 | #define __arch_swab64 __arch_swab64 | ||
36 | |||
37 | static inline void __arch_swab64s(__u64 *x) | ||
38 | { | ||
39 | *x = __arch_swab64p(x); | ||
40 | } | ||
41 | #define __arch_swab64s __arch_swab64s | ||
42 | #endif /* __s390x__ */ | ||
43 | |||
44 | static inline __u32 __arch_swab32p(const __u32 *x) | ||
45 | { | ||
46 | __u32 result; | ||
47 | |||
48 | asm volatile( | ||
49 | #ifndef __s390x__ | ||
50 | " icm %0,8,3(%1)\n" | ||
51 | " icm %0,4,2(%1)\n" | ||
52 | " icm %0,2,1(%1)\n" | ||
53 | " ic %0,0(%1)" | ||
54 | : "=&d" (result) : "a" (x), "m" (*x) : "cc"); | ||
55 | #else /* __s390x__ */ | ||
56 | " lrv %0,%1" | ||
57 | : "=d" (result) : "m" (*x)); | ||
58 | #endif /* __s390x__ */ | ||
59 | return result; | ||
60 | } | ||
61 | #define __arch_swab32p __arch_swab32p | ||
62 | |||
63 | #ifdef __s390x__ | ||
64 | static inline __u32 __arch_swab32(__u32 x) | ||
65 | { | ||
66 | __u32 result; | ||
67 | |||
68 | asm volatile("lrvr %0,%1" : "=d" (result) : "d" (x)); | ||
69 | return result; | ||
70 | } | ||
71 | #define __arch_swab32 __arch_swab32 | ||
72 | #endif /* __s390x__ */ | ||
73 | |||
74 | static inline __u16 __arch_swab16p(const __u16 *x) | ||
75 | { | ||
76 | __u16 result; | ||
77 | |||
78 | asm volatile( | ||
79 | #ifndef __s390x__ | ||
80 | " icm %0,2,1(%1)\n" | ||
81 | " ic %0,0(%1)\n" | ||
82 | : "=&d" (result) : "a" (x), "m" (*x) : "cc"); | ||
83 | #else /* __s390x__ */ | ||
84 | " lrvh %0,%1" | ||
85 | : "=d" (result) : "m" (*x)); | ||
86 | #endif /* __s390x__ */ | ||
87 | return result; | ||
88 | } | ||
89 | #define __arch_swab16p __arch_swab16p | ||
90 | |||
91 | #endif /* _S390_SWAB_H */ | ||