2005-04-16 22:20:36 +00:00
|
|
|
#ifndef _S390_BYTEORDER_H
|
|
|
|
#define _S390_BYTEORDER_H
|
|
|
|
|
|
|
|
/*
|
|
|
|
* include/asm-s390/byteorder.h
|
|
|
|
*
|
|
|
|
* S390 version
|
|
|
|
* Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
|
|
|
|
* Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <asm/types.h>
|
|
|
|
|
2008-12-25 12:39:20 +00:00
|
|
|
#define __BIG_ENDIAN
|
|
|
|
|
|
|
|
#ifndef __s390x__
|
|
|
|
# define __SWAB_64_THRU_32__
|
|
|
|
#endif
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#ifdef __s390x__
|
2008-12-25 12:39:20 +00:00
|
|
|
static inline __u64 __arch_swab64p(const __u64 *x)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
__u64 result;
|
|
|
|
|
2006-09-28 14:56:43 +00:00
|
|
|
asm volatile("lrvg %0,%1" : "=d" (result) : "m" (*x));
|
2005-04-16 22:20:36 +00:00
|
|
|
return result;
|
|
|
|
}
|
2008-12-25 12:39:20 +00:00
|
|
|
#define __arch_swab64p __arch_swab64p
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-12-25 12:39:20 +00:00
|
|
|
static inline __u64 __arch_swab64(__u64 x)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
__u64 result;
|
|
|
|
|
2006-09-28 14:56:43 +00:00
|
|
|
asm volatile("lrvgr %0,%1" : "=d" (result) : "d" (x));
|
2005-04-16 22:20:36 +00:00
|
|
|
return result;
|
|
|
|
}
|
2008-12-25 12:39:20 +00:00
|
|
|
#define __arch_swab64 __arch_swab64
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-12-25 12:39:20 +00:00
|
|
|
static inline void __arch_swab64s(__u64 *x)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
2008-12-25 12:39:20 +00:00
|
|
|
*x = __arch_swab64p(x);
|
2005-04-16 22:20:36 +00:00
|
|
|
}
|
2008-12-25 12:39:20 +00:00
|
|
|
#define __arch_swab64s __arch_swab64s
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* __s390x__ */
|
|
|
|
|
2008-12-25 12:39:20 +00:00
|
|
|
static inline __u32 __arch_swab32p(const __u32 *x)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
__u32 result;
|
|
|
|
|
2006-09-28 14:56:43 +00:00
|
|
|
asm volatile(
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifndef __s390x__
|
2006-09-28 14:56:43 +00:00
|
|
|
" icm %0,8,3(%1)\n"
|
|
|
|
" icm %0,4,2(%1)\n"
|
|
|
|
" icm %0,2,1(%1)\n"
|
|
|
|
" ic %0,0(%1)"
|
|
|
|
: "=&d" (result) : "a" (x), "m" (*x) : "cc");
|
2005-04-16 22:20:36 +00:00
|
|
|
#else /* __s390x__ */
|
2006-09-28 14:56:43 +00:00
|
|
|
" lrv %0,%1"
|
|
|
|
: "=d" (result) : "m" (*x));
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* __s390x__ */
|
|
|
|
return result;
|
|
|
|
}
|
2008-12-25 12:39:20 +00:00
|
|
|
#define __arch_swab32p __arch_swab32p
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-12-25 12:39:20 +00:00
|
|
|
#ifdef __s390x__
|
|
|
|
static inline __u32 __arch_swab32(__u32 x)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
__u32 result;
|
|
|
|
|
2006-09-28 14:56:43 +00:00
|
|
|
asm volatile("lrvr %0,%1" : "=d" (result) : "d" (x));
|
2005-04-16 22:20:36 +00:00
|
|
|
return result;
|
|
|
|
}
|
2008-12-25 12:39:20 +00:00
|
|
|
#define __arch_swab32 __arch_swab32
|
|
|
|
#endif /* __s390x__ */
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-12-25 12:39:20 +00:00
|
|
|
static inline __u16 __arch_swab16p(const __u16 *x)
|
2005-04-16 22:20:36 +00:00
|
|
|
{
|
|
|
|
__u16 result;
|
|
|
|
|
2006-09-28 14:56:43 +00:00
|
|
|
asm volatile(
|
2005-04-16 22:20:36 +00:00
|
|
|
#ifndef __s390x__
|
2006-09-28 14:56:43 +00:00
|
|
|
" icm %0,2,1(%1)\n"
|
|
|
|
" ic %0,0(%1)\n"
|
|
|
|
: "=&d" (result) : "a" (x), "m" (*x) : "cc");
|
2005-04-16 22:20:36 +00:00
|
|
|
#else /* __s390x__ */
|
2006-09-28 14:56:43 +00:00
|
|
|
" lrvh %0,%1"
|
|
|
|
: "=d" (result) : "m" (*x));
|
2005-04-16 22:20:36 +00:00
|
|
|
#endif /* __s390x__ */
|
|
|
|
return result;
|
|
|
|
}
|
2008-12-25 12:39:20 +00:00
|
|
|
#define __arch_swab16p __arch_swab16p
|
2005-04-16 22:20:36 +00:00
|
|
|
|
2008-12-25 12:39:20 +00:00
|
|
|
#include <linux/byteorder.h>
|
2005-04-16 22:20:36 +00:00
|
|
|
|
|
|
|
#endif /* _S390_BYTEORDER_H */
|