linux/arch/s390/include/uapi/asm/swab.h
<<
>>
Prefs
   1#ifndef _S390_SWAB_H
   2#define _S390_SWAB_H
   3
   4/*
   5 *  S390 version
   6 *    Copyright IBM Corp. 1999
   7 *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
   8 */
   9
  10#include <linux/types.h>
  11
  12#ifndef __s390x__
  13# define __SWAB_64_THRU_32__
  14#endif
  15
  16#ifdef __s390x__
  17static inline __u64 __arch_swab64p(const __u64 *x)
  18{
  19        __u64 result;
  20
  21        asm volatile("lrvg %0,%1" : "=d" (result) : "m" (*x));
  22        return result;
  23}
  24#define __arch_swab64p __arch_swab64p
  25
  26static inline __u64 __arch_swab64(__u64 x)
  27{
  28        __u64 result;
  29
  30        asm volatile("lrvgr %0,%1" : "=d" (result) : "d" (x));
  31        return result;
  32}
  33#define __arch_swab64 __arch_swab64
  34
  35static inline void __arch_swab64s(__u64 *x)
  36{
  37        *x = __arch_swab64p(x);
  38}
  39#define __arch_swab64s __arch_swab64s
  40#endif /* __s390x__ */
  41
  42static inline __u32 __arch_swab32p(const __u32 *x)
  43{
  44        __u32 result;
  45        
  46        asm volatile(
  47#ifndef __s390x__
  48                "       icm     %0,8,%O1+3(%R1)\n"
  49                "       icm     %0,4,%O1+2(%R1)\n"
  50                "       icm     %0,2,%O1+1(%R1)\n"
  51                "       ic      %0,%1"
  52                : "=&d" (result) : "Q" (*x) : "cc");
  53#else /* __s390x__ */
  54                "       lrv     %0,%1"
  55                : "=d" (result) : "m" (*x));
  56#endif /* __s390x__ */
  57        return result;
  58}
  59#define __arch_swab32p __arch_swab32p
  60
  61#ifdef __s390x__
  62static inline __u32 __arch_swab32(__u32 x)
  63{
  64        __u32 result;
  65        
  66        asm volatile("lrvr  %0,%1" : "=d" (result) : "d" (x));
  67        return result;
  68}
  69#define __arch_swab32 __arch_swab32
  70#endif /* __s390x__ */
  71
  72static inline __u16 __arch_swab16p(const __u16 *x)
  73{
  74        __u16 result;
  75        
  76        asm volatile(
  77#ifndef __s390x__
  78                "       icm     %0,2,%O1+1(%R1)\n"
  79                "       ic      %0,%1\n"
  80                : "=&d" (result) : "Q" (*x) : "cc");
  81#else /* __s390x__ */
  82                "       lrvh    %0,%1"
  83                : "=d" (result) : "m" (*x));
  84#endif /* __s390x__ */
  85        return result;
  86}
  87#define __arch_swab16p __arch_swab16p
  88
  89#endif /* _S390_SWAB_H */
  90