2005-04-16 22:20:36 +00:00
|
|
|
/*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*
|
|
|
|
* Copyright (C) 1996, 99, 2003 by Ralf Baechle
|
|
|
|
*/
|
|
|
|
#ifndef _ASM_BYTEORDER_H
|
|
|
|
#define _ASM_BYTEORDER_H
|
|
|
|
|
2006-02-01 15:29:21 +00:00
|
|
|
#include <linux/compiler.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
#include <asm/types.h>
|
|
|
|
|
2008-10-29 21:21:32 +00:00
|
|
|
#if defined(__MIPSEB__)
|
|
|
|
# define __BIG_ENDIAN
|
|
|
|
#elif defined(__MIPSEL__)
|
|
|
|
# define __LITTLE_ENDIAN
|
|
|
|
#else
|
|
|
|
# error "MIPS, but neither __MIPSEB__, nor __MIPSEL__???"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define __SWAB_64_THRU_32__
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2006-02-01 15:29:21 +00:00
|
|
|
#ifdef CONFIG_CPU_MIPSR2
|
|
|
|
|
2008-10-29 21:21:32 +00:00
|
|
|
static inline __attribute_const__ __u16 __arch_swab16(__u16 x)
|
2006-02-01 15:29:21 +00:00
|
|
|
{
|
|
|
|
__asm__(
|
|
|
|
" wsbh %0, %1 \n"
|
|
|
|
: "=r" (x)
|
|
|
|
: "r" (x));
|
|
|
|
|
|
|
|
return x;
|
|
|
|
}
|
2008-10-29 21:21:32 +00:00
|
|
|
#define __arch_swab16 __arch_swab16
|
2006-02-01 15:29:21 +00:00
|
|
|
|
2008-10-29 21:21:32 +00:00
|
|
|
static inline __attribute_const__ __u32 __arch_swab32(__u32 x)
|
2006-02-01 15:29:21 +00:00
|
|
|
{
|
|
|
|
__asm__(
|
|
|
|
" wsbh %0, %1 \n"
|
|
|
|
" rotr %0, %0, 16 \n"
|
|
|
|
: "=r" (x)
|
|
|
|
: "r" (x));
|
|
|
|
|
|
|
|
return x;
|
|
|
|
}
|
2008-10-29 21:21:32 +00:00
|
|
|
#define __arch_swab32 __arch_swab32
|
2006-02-01 15:29:21 +00:00
|
|
|
|
2006-02-15 13:06:34 +00:00
|
|
|
#ifdef CONFIG_CPU_MIPS64_R2
|
2008-10-29 21:21:32 +00:00
|
|
|
static inline __attribute_const__ __u64 __arch_swab64(__u64 x)
|
2006-02-15 13:06:34 +00:00
|
|
|
{
|
|
|
|
__asm__(
|
2008-12-17 21:28:39 +00:00
|
|
|
" dsbh %0, %1\n"
|
|
|
|
" dshd %0, %0"
|
2006-02-15 13:06:34 +00:00
|
|
|
: "=r" (x)
|
|
|
|
: "r" (x));
|
|
|
|
|
|
|
|
return x;
|
|
|
|
}
|
2008-10-29 21:21:32 +00:00
|
|
|
#define __arch_swab64 __arch_swab64
|
2006-02-15 13:06:34 +00:00
|
|
|
#endif /* CONFIG_CPU_MIPS64_R2 */
|
|
|
|
|
2006-02-01 15:29:21 +00:00
|
|
|
#endif /* CONFIG_CPU_MIPSR2 */
|
|
|
|
|
2008-10-29 21:21:32 +00:00
|
|
|
#include <linux/byteorder.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#endif /* _ASM_BYTEORDER_H */
|