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
|
/* $OpenBSD: endian.h,v 1.5 2014/03/25 03:53:35 dlg Exp $ */
#ifndef _MACHINE_ENDIAN_H_
#define _MACHINE_ENDIAN_H_
#define _BYTE_ORDER _BIG_ENDIAN
#ifdef _KERNEL
#define ASI_P_L 0x88
static inline __uint16_t
__mswap16(volatile __uint16_t *m)
{
__uint16_t v;
__asm("lduha [%1] %2, %0 ! %3"
: "=r" (v)
: "r" (m), "n" (ASI_P_L), "m" (*m));
return (v);
}
static inline __uint32_t
__mswap32(volatile __uint32_t *m)
{
__uint32_t v;
__asm("lduwa [%1] %2, %0 ! %3"
: "=r" (v)
: "r" (m), "n" (ASI_P_L), "m" (*m));
return (v);
}
static inline __uint64_t
__mswap64(volatile __uint64_t *m)
{
__uint64_t v;
__asm("ldxa [%1] %2, %0 ! %3"
: "=r" (v)
: "r" (m), "n" (ASI_P_L), "m" (*m));
return (v);
}
static inline void
__swapm16(volatile __uint16_t *m, __uint16_t v)
{
__asm("stha %1, [%2] %3 ! %0"
: "=m" (*m)
: "r" (v), "r" (m), "n" (ASI_P_L));
}
static inline void
__swapm32(volatile __uint32_t *m, __uint32_t v)
{
__asm("stwa %1, [%2] %3 ! %0"
: "=m" (*m)
: "r" (v), "r" (m), "n" (ASI_P_L));
}
static inline void
__swapm64(volatile __uint64_t *m, __uint64_t v)
{
__asm("stxa %1, [%2] %3 ! %0"
: "=m" (*m)
: "r" (v), "r" (m), "n" (ASI_P_L));
}
#undef ASI_P_L
#define MD_SWAPIO
#endif /* _KERNEL */
#include <sys/endian.h>
#define __STRICT_ALIGNMENT
#endif /* _MACHINE_ENDIAN_H_ */
|