diff options
author | Paul Mundt <lethal@linux-sh.org> | 2007-11-08 23:58:44 -0500 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2008-01-27 23:18:41 -0500 |
commit | 7a65eaf4885d1d0afeec45239eaf9208a3235b51 (patch) | |
tree | 6b478fa021a92b33e23d3751b912fe60242c6dd1 /include/asm-sh/byteorder.h | |
parent | 4690bdc7c6e4f18fb58350ccde40df5fcd85a6d9 (diff) |
sh: SH-5 byteorder routines.
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
Diffstat (limited to 'include/asm-sh/byteorder.h')
-rw-r--r-- | include/asm-sh/byteorder.h | 45 |
1 files changed, 30 insertions, 15 deletions
diff --git a/include/asm-sh/byteorder.h b/include/asm-sh/byteorder.h index bff2b1382e01..0eb9904b6545 100644 --- a/include/asm-sh/byteorder.h +++ b/include/asm-sh/byteorder.h | |||
@@ -3,40 +3,55 @@ | |||
3 | 3 | ||
4 | /* | 4 | /* |
5 | * Copyright (C) 1999 Niibe Yutaka | 5 | * Copyright (C) 1999 Niibe Yutaka |
6 | * Copyright (C) 2000, 2001 Paolo Alberelli | ||
6 | */ | 7 | */ |
7 | |||
8 | #include <asm/types.h> | ||
9 | #include <linux/compiler.h> | 8 | #include <linux/compiler.h> |
9 | #include <linux/types.h> | ||
10 | 10 | ||
11 | static __inline__ __attribute_const__ __u32 ___arch__swab32(__u32 x) | 11 | static inline __attribute_const__ __u32 ___arch__swab32(__u32 x) |
12 | { | 12 | { |
13 | __asm__("swap.b %0, %0\n\t" | 13 | __asm__( |
14 | "swap.w %0, %0\n\t" | 14 | #ifdef CONFIG_SUPERH32 |
15 | "swap.b %0, %0" | 15 | "swap.b %0, %0\n\t" |
16 | "swap.w %0, %0\n\t" | ||
17 | "swap.b %0, %0" | ||
18 | #else | ||
19 | "byterev %0, %0\n\t" | ||
20 | "shari %0, 32, %0" | ||
21 | #endif | ||
16 | : "=r" (x) | 22 | : "=r" (x) |
17 | : "0" (x)); | 23 | : "0" (x)); |
24 | |||
18 | return x; | 25 | return x; |
19 | } | 26 | } |
20 | 27 | ||
21 | static __inline__ __attribute_const__ __u16 ___arch__swab16(__u16 x) | 28 | static inline __attribute_const__ __u16 ___arch__swab16(__u16 x) |
22 | { | 29 | { |
23 | __asm__("swap.b %0, %0" | 30 | __asm__( |
31 | #ifdef CONFIG_SUPERH32 | ||
32 | "swap.b %0, %0" | ||
33 | #else | ||
34 | "byterev %0, %0\n\t" | ||
35 | "shari %0, 32, %0" | ||
36 | |||
37 | #endif | ||
24 | : "=r" (x) | 38 | : "=r" (x) |
25 | : "0" (x)); | 39 | : "0" (x)); |
40 | |||
26 | return x; | 41 | return x; |
27 | } | 42 | } |
28 | 43 | ||
29 | static inline __u64 ___arch__swab64(__u64 val) | 44 | static inline __u64 ___arch__swab64(__u64 val) |
30 | { | 45 | { |
31 | union { | 46 | union { |
32 | struct { __u32 a,b; } s; | 47 | struct { __u32 a,b; } s; |
33 | __u64 u; | 48 | __u64 u; |
34 | } v, w; | 49 | } v, w; |
35 | v.u = val; | 50 | v.u = val; |
36 | w.s.b = ___arch__swab32(v.s.a); | 51 | w.s.b = ___arch__swab32(v.s.a); |
37 | w.s.a = ___arch__swab32(v.s.b); | 52 | w.s.a = ___arch__swab32(v.s.b); |
38 | return w.u; | 53 | return w.u; |
39 | } | 54 | } |
40 | 55 | ||
41 | #define __arch__swab64(x) ___arch__swab64(x) | 56 | #define __arch__swab64(x) ___arch__swab64(x) |
42 | #define __arch__swab32(x) ___arch__swab32(x) | 57 | #define __arch__swab32(x) ___arch__swab32(x) |