aboutsummaryrefslogtreecommitdiffstats
path: root/arch/s390/include/asm/swab.h
blob: eb18dc1f327bf906187358713a92e1c7066417e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#ifndef _S390_SWAB_H
#define _S390_SWAB_H

/*
 *  include/asm-s390/swab.h
 *
 *  S390 version
 *    Copyright (C) 1999 IBM Deutschland Entwicklung GmbH, IBM Corporation
 *    Author(s): Martin Schwidefsky (schwidefsky@de.ibm.com)
 */

#include <linux/types.h>

#ifndef __s390x__
# define __SWAB_64_THRU_32__
#endif

#ifdef __s390x__
static inline __u64 __arch_swab64p(const __u64 *x)
{
	__u64 result;

	asm volatile("lrvg %0,%1" : "=d" (result) : "m" (*x));
	return result;
}
#define __arch_swab64p __arch_swab64p

static inline __u64 __arch_swab64(__u64 x)
{
	__u64 result;

	asm volatile("lrvgr %0,%1" : "=d" (result) : "d" (x));
	return result;
}
#define __arch_swab64 __arch_swab64

static inline void __arch_swab64s(__u64 *x)
{
	*x = __arch_swab64p(x);
}
#define __arch_swab64s __arch_swab64s
#endif /* __s390x__ */

static inline __u32 __arch_swab32p(const __u32 *x)
{
	__u32 result;
	
	asm volatile(
#ifndef __s390x__
		"	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");
#else /* __s390x__ */
		"	lrv	%0,%1"
		: "=d" (result) : "m" (*x));
#endif /* __s390x__ */
	return result;
}
#define __arch_swab32p __arch_swab32p

#ifdef __s390x__
static inline __u32 __arch_swab32(__u32 x)
{
	__u32 result;
	
	asm volatile("lrvr  %0,%1" : "=d" (result) : "d" (x));
	return result;
}
#define __arch_swab32 __arch_swab32
#endif /* __s390x__ */

static inline __u16 __arch_swab16p(const __u16 *x)
{
	__u16 result;
	
	asm volatile(
#ifndef __s390x__
		"	icm	%0,2,1(%1)\n"
		"	ic	%0,0(%1)\n"
		: "=&d" (result) : "a" (x), "m" (*x) : "cc");
#else /* __s390x__ */
		"	lrvh	%0,%1"
		: "=d" (result) : "m" (*x));
#endif /* __s390x__ */
	return result;
}
#define __arch_swab16p __arch_swab16p

#endif /* _S390_SWAB_H */