1#ifndef _S390_BYTEORDER_H 2#define _S390_BYTEORDER_H 3 4/* 5 * include/asm-s390/byteorder.h 6 * 7 * S390 version 8 * Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation 9 * Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com) 10 */ 11 12#include <asm/types.h> 13 14#ifdef __GNUC__ 15 16static __inline__ __const__ __u32 ___arch__swab32(__u32 x) 17{ 18 __u32 temp; 19 20 __asm__ __volatile__ ( 21 " st %0,0(%1)\n" 22 " icm %0,8,3(%1)\n" 23 " icm %0,4,2(%1)\n" 24 " icm %0,2,1(%1)\n" 25 " ic %0,0(%1)" 26 : "+&d" (x) : "a" (&temp) : "cc" ); 27 return x; 28} 29 30static __inline__ __const__ __u32 ___arch__swab32p(__u32 *x) 31{ 32 __u32 result; 33 34 __asm__ __volatile__ ( 35 " icm %0,8,3(%1)\n" 36 " icm %0,4,2(%1)\n" 37 " icm %0,2,1(%1)\n" 38 " ic %0,0(%1)" 39 : "=&d" (result) : "a" (x) : "cc" ); 40 return result; 41} 42 43static __inline__ void ___arch__swab32s(__u32 *x) 44{ 45 __asm__ __volatile__ ( 46 " icm 0,8,3(%0)\n" 47 " icm 0,4,2(%0)\n" 48 " icm 0,2,1(%0)\n" 49 " ic 0,0(%0)\n" 50 " st 0,0(%0)" 51 : : "a" (x) : "0", "memory", "cc"); 52} 53 54static __inline__ __const__ __u16 ___arch__swab16(__u16 x) 55{ 56 __u16 temp; 57 58 __asm__ __volatile__ ( 59 " sth %0,0(%1)\n" 60 " icm %0,2,1(%1)\n" 61 " ic %0,0(%1)\n" 62 : "+&d" (x) : "a" (&temp) : "memory", "cc" ); 63 return x; 64} 65 66static __inline__ __const__ __u16 ___arch__swab16p(__u16 *x) 67{ 68 __u16 result; 69 70 __asm__ __volatile__ ( 71 " sr %0,%0\n" 72 " icm %0,2,1(%1)\n" 73 " ic %0,0(%1)\n" 74 : "=&d" (result) : "a" (x) : "cc" ); 75 return result; 76} 77 78static __inline__ void ___arch__swab16s(__u16 *x) 79{ 80 __asm__ __volatile__( 81 " icm 0,2,1(%0)\n" 82 " ic 0,0(%0)\n" 83 " sth 0,0(%0)" 84 : : "a" (x) : "0", "memory", "cc" ); 85} 86 87#define __arch__swab32(x) ___arch__swab32(x) 88#define __arch__swab16(x) ___arch__swab16(x) 89#define __arch__swab32p(x) ___arch__swab32p(x) 90#define __arch__swab16p(x) ___arch__swab16p(x) 91#define __arch__swab32s(x) ___arch__swab32s(x) 92#define __arch__swab16s(x) ___arch__swab16s(x) 93 94#if !defined(__STRICT_ANSI__) || defined(__KERNEL__) 95# define __BYTEORDER_HAS_U64__ 96# define __SWAB_64_THRU_32__ 97#endif 98 99#endif /* __GNUC__ */ 100 101#include <linux/byteorder/big_endian.h> 102 103#endif /* _S390_BYTEORDER_H */ 104