MIPS: MIPS64R2: Fix buggy __arch_swab64
[deliverable/linux.git] / arch / mips / include / asm / byteorder.h
CommitLineData
1da177e4
LT
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
1e32ceec 11#include <linux/compiler.h>
1da177e4
LT
12#include <asm/types.h>
13
255a12fb
HH
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__
1da177e4 23
1e32ceec
RB
24#ifdef CONFIG_CPU_MIPSR2
25
255a12fb 26static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
1e32ceec
RB
27{
28 __asm__(
29 " wsbh %0, %1 \n"
30 : "=r" (x)
31 : "r" (x));
32
33 return x;
34}
255a12fb 35#define __arch_swab16 __arch_swab16
1e32ceec 36
255a12fb 37static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
1e32ceec
RB
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}
255a12fb 47#define __arch_swab32 __arch_swab32
1e32ceec 48
bbad8123 49#ifdef CONFIG_CPU_MIPS64_R2
255a12fb 50static inline __attribute_const__ __u64 __arch_swab64(__u64 x)
bbad8123
RB
51{
52 __asm__(
ed2b03ed
DD
53 " dsbh %0, %1\n"
54 " dshd %0, %0"
bbad8123
RB
55 : "=r" (x)
56 : "r" (x));
57
58 return x;
59}
255a12fb 60#define __arch_swab64 __arch_swab64
bbad8123
RB
61#endif /* CONFIG_CPU_MIPS64_R2 */
62
1e32ceec
RB
63#endif /* CONFIG_CPU_MIPSR2 */
64
255a12fb 65#include <linux/byteorder.h>
1da177e4
LT
66
67#endif /* _ASM_BYTEORDER_H */
This page took 0.565791 seconds and 5 git commands to generate.