summaryrefslogtreecommitdiff
path: root/target-ppc/op_mem_access.h
blob: 48be20e5a7abe9cc7aa582e3caacea3ce9ee7fcf (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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/*
 *  PowerPC emulation memory access helpers for qemu.
 *
 *  Copyright (c) 2003-2007 Jocelyn Mayer
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

/* 8 bits accesses */
static always_inline target_ulong glue(ldu8, MEMSUFFIX) (target_ulong EA)
{
    return (uint8_t)glue(ldub, MEMSUFFIX)(EA);
}

static always_inline target_long glue(lds8, MEMSUFFIX) (target_ulong EA)
{
    return (int8_t)glue(ldsb, MEMSUFFIX)(EA);
}

static always_inline void glue(st8, MEMSUFFIX) (target_ulong EA, uint8_t val)
{
    glue(stb, MEMSUFFIX)(EA, val);
}

/* 16 bits accesses */
static always_inline target_ulong glue(ldu16, MEMSUFFIX) (target_ulong EA)
{
    return (uint16_t)glue(lduw, MEMSUFFIX)(EA);
}

static always_inline target_long glue(lds16, MEMSUFFIX) (target_ulong EA)
{
    return (int16_t)glue(ldsw, MEMSUFFIX)(EA);
}

static always_inline void glue(st16, MEMSUFFIX) (target_ulong EA, uint16_t val)
{
    glue(stw, MEMSUFFIX)(EA, val);
}

static always_inline target_ulong glue(ldu16r, MEMSUFFIX) (target_ulong EA)
{
    return (uint16_t)bswap16(glue(lduw, MEMSUFFIX)(EA));
}

static always_inline target_long glue(lds16r, MEMSUFFIX) (target_ulong EA)
{
    return (int16_t)bswap16(glue(lduw, MEMSUFFIX)(EA));
}

static always_inline void glue(st16r, MEMSUFFIX) (target_ulong EA, uint16_t val)
{
    glue(stw, MEMSUFFIX)(EA, bswap16(val));
}

/* 32 bits accesses */
static always_inline uint32_t glue(__ldul, MEMSUFFIX) (target_ulong EA)
{
    return (uint32_t)glue(ldl, MEMSUFFIX)(EA);
}

static always_inline int32_t glue(__ldsl, MEMSUFFIX) (target_ulong EA)
{
    return (int32_t)glue(ldl, MEMSUFFIX)(EA);
}

static always_inline target_ulong glue(ldu32, MEMSUFFIX) (target_ulong EA)
{
    return glue(__ldul, MEMSUFFIX)(EA);
}

static always_inline target_long glue(lds32, MEMSUFFIX) (target_ulong EA)
{
    return glue(__ldsl, MEMSUFFIX)(EA);
}

static always_inline void glue(st32, MEMSUFFIX) (target_ulong EA, uint32_t val)
{
    glue(stl, MEMSUFFIX)(EA, val);
}

static always_inline target_ulong glue(ldu32r, MEMSUFFIX) (target_ulong EA)
{
    return bswap32(glue(__ldul, MEMSUFFIX)(EA));
}

static always_inline target_long glue(lds32r, MEMSUFFIX) (target_ulong EA)
{
    return (int32_t)bswap32(glue(__ldul, MEMSUFFIX)(EA));
}

static always_inline void glue(st32r, MEMSUFFIX) (target_ulong EA, uint32_t val)
{
    glue(stl, MEMSUFFIX)(EA, bswap32(val));
}

/* 64 bits accesses */
static always_inline uint64_t glue(__lduq, MEMSUFFIX) (target_ulong EA)
{
    return (uint64_t)glue(ldq, MEMSUFFIX)(EA);
}

static always_inline int64_t glue(__ldsq, MEMSUFFIX) (target_ulong EA)
{
    return (int64_t)glue(ldq, MEMSUFFIX)(EA);
}

static always_inline uint64_t glue(ldu64, MEMSUFFIX) (target_ulong EA)
{
    return glue(__lduq, MEMSUFFIX)(EA);
}

static always_inline int64_t glue(lds64, MEMSUFFIX) (target_ulong EA)
{
    return glue(__ldsq, MEMSUFFIX)(EA);
}

static always_inline void glue(st64, MEMSUFFIX) (target_ulong EA, uint64_t val)
{
    glue(stq, MEMSUFFIX)(EA, val);
}

static always_inline uint64_t glue(ldu64r, MEMSUFFIX) (target_ulong EA)
{
    return bswap64(glue(__lduq, MEMSUFFIX)(EA));
}

static always_inline int64_t glue(lds64r, MEMSUFFIX) (target_ulong EA)
{
    return (int64_t)bswap64(glue(__lduq, MEMSUFFIX)(EA));
}

static always_inline void glue(st64r, MEMSUFFIX) (target_ulong EA, uint64_t val)
{
    glue(stq, MEMSUFFIX)(EA, bswap64(val));
}