Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * This file is subject to the terms and conditions of the GNU General Public |
| 3 | * License. See the file "COPYING" in the main directory of this archive |
| 4 | * for more details. |
| 5 | * |
| 6 | * Copyright (C) 1996, 99, 2003 by Ralf Baechle |
| 7 | */ |
| 8 | #ifndef _ASM_BYTEORDER_H |
| 9 | #define _ASM_BYTEORDER_H |
| 10 | |
Ralf Baechle | 1e32ceec | 2006-02-01 15:29:21 +0000 | [diff] [blame] | 11 | #include <linux/compiler.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 12 | #include <asm/types.h> |
| 13 | |
Harvey Harrison | 255a12f | 2008-10-29 14:21:32 -0700 | [diff] [blame] | 14 | #if defined(__MIPSEB__) |
| 15 | # define __BIG_ENDIAN |
| 16 | #elif defined(__MIPSEL__) |
| 17 | # define __LITTLE_ENDIAN |
| 18 | #else |
| 19 | # error "MIPS, but neither __MIPSEB__, nor __MIPSEL__???" |
| 20 | #endif |
| 21 | |
| 22 | #define __SWAB_64_THRU_32__ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 23 | |
Ralf Baechle | 1e32ceec | 2006-02-01 15:29:21 +0000 | [diff] [blame] | 24 | #ifdef CONFIG_CPU_MIPSR2 |
| 25 | |
Harvey Harrison | 255a12f | 2008-10-29 14:21:32 -0700 | [diff] [blame] | 26 | static inline __attribute_const__ __u16 __arch_swab16(__u16 x) |
Ralf Baechle | 1e32ceec | 2006-02-01 15:29:21 +0000 | [diff] [blame] | 27 | { |
| 28 | __asm__( |
| 29 | " wsbh %0, %1 \n" |
| 30 | : "=r" (x) |
| 31 | : "r" (x)); |
| 32 | |
| 33 | return x; |
| 34 | } |
Harvey Harrison | 255a12f | 2008-10-29 14:21:32 -0700 | [diff] [blame] | 35 | #define __arch_swab16 __arch_swab16 |
Ralf Baechle | 1e32ceec | 2006-02-01 15:29:21 +0000 | [diff] [blame] | 36 | |
Harvey Harrison | 255a12f | 2008-10-29 14:21:32 -0700 | [diff] [blame] | 37 | static inline __attribute_const__ __u32 __arch_swab32(__u32 x) |
Ralf Baechle | 1e32ceec | 2006-02-01 15:29:21 +0000 | [diff] [blame] | 38 | { |
| 39 | __asm__( |
| 40 | " wsbh %0, %1 \n" |
| 41 | " rotr %0, %0, 16 \n" |
| 42 | : "=r" (x) |
| 43 | : "r" (x)); |
| 44 | |
| 45 | return x; |
| 46 | } |
Harvey Harrison | 255a12f | 2008-10-29 14:21:32 -0700 | [diff] [blame] | 47 | #define __arch_swab32 __arch_swab32 |
Ralf Baechle | 1e32ceec | 2006-02-01 15:29:21 +0000 | [diff] [blame] | 48 | |
Ralf Baechle | bbad812 | 2006-02-15 13:06:34 +0000 | [diff] [blame] | 49 | #ifdef CONFIG_CPU_MIPS64_R2 |
Harvey Harrison | 255a12f | 2008-10-29 14:21:32 -0700 | [diff] [blame] | 50 | static inline __attribute_const__ __u64 __arch_swab64(__u64 x) |
Ralf Baechle | bbad812 | 2006-02-15 13:06:34 +0000 | [diff] [blame] | 51 | { |
| 52 | __asm__( |
David Daney | ed2b03e | 2008-12-17 13:28:39 -0800 | [diff] [blame] | 53 | " dsbh %0, %1\n" |
| 54 | " dshd %0, %0" |
Ralf Baechle | bbad812 | 2006-02-15 13:06:34 +0000 | [diff] [blame] | 55 | : "=r" (x) |
| 56 | : "r" (x)); |
| 57 | |
| 58 | return x; |
| 59 | } |
Harvey Harrison | 255a12f | 2008-10-29 14:21:32 -0700 | [diff] [blame] | 60 | #define __arch_swab64 __arch_swab64 |
Ralf Baechle | bbad812 | 2006-02-15 13:06:34 +0000 | [diff] [blame] | 61 | #endif /* CONFIG_CPU_MIPS64_R2 */ |
| 62 | |
Ralf Baechle | 1e32ceec | 2006-02-01 15:29:21 +0000 | [diff] [blame] | 63 | #endif /* CONFIG_CPU_MIPSR2 */ |
| 64 | |
Harvey Harrison | 255a12f | 2008-10-29 14:21:32 -0700 | [diff] [blame] | 65 | #include <linux/byteorder.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 66 | |
| 67 | #endif /* _ASM_BYTEORDER_H */ |