2
* PowerPC emulation memory access helpers for qemu.
4
* Copyright (c) 2003-2007 Jocelyn Mayer
6
* This library is free software; you can redistribute it and/or
7
* modify it under the terms of the GNU Lesser General Public
8
* License as published by the Free Software Foundation; either
9
* version 2 of the License, or (at your option) any later version.
11
* This library is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14
* Lesser General Public License for more details.
16
* You should have received a copy of the GNU Lesser General Public
17
* License along with this library; if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22
static always_inline target_ulong glue(ldu8, MEMSUFFIX) (target_ulong EA)
24
return (uint8_t)glue(ldub, MEMSUFFIX)(EA);
27
static always_inline target_long glue(lds8, MEMSUFFIX) (target_ulong EA)
29
return (int8_t)glue(ldsb, MEMSUFFIX)(EA);
32
static always_inline void glue(st8, MEMSUFFIX) (target_ulong EA, uint8_t val)
34
glue(stb, MEMSUFFIX)(EA, val);
37
/* 16 bits accesses */
38
static always_inline target_ulong glue(ldu16, MEMSUFFIX) (target_ulong EA)
40
return (uint16_t)glue(lduw, MEMSUFFIX)(EA);
43
static always_inline target_long glue(lds16, MEMSUFFIX) (target_ulong EA)
45
return (int16_t)glue(ldsw, MEMSUFFIX)(EA);
48
static always_inline void glue(st16, MEMSUFFIX) (target_ulong EA, uint16_t val)
50
glue(stw, MEMSUFFIX)(EA, val);
53
static always_inline target_ulong glue(ldu16r, MEMSUFFIX) (target_ulong EA)
55
return (uint16_t)bswap16(glue(lduw, MEMSUFFIX)(EA));
58
static always_inline target_long glue(lds16r, MEMSUFFIX) (target_ulong EA)
60
return (int16_t)bswap16(glue(lduw, MEMSUFFIX)(EA));
63
static always_inline void glue(st16r, MEMSUFFIX) (target_ulong EA, uint16_t val)
65
glue(stw, MEMSUFFIX)(EA, bswap16(val));
68
/* 32 bits accesses */
69
static always_inline uint32_t glue(__ldul, MEMSUFFIX) (target_ulong EA)
71
return (uint32_t)glue(ldl, MEMSUFFIX)(EA);
74
static always_inline int32_t glue(__ldsl, MEMSUFFIX) (target_ulong EA)
76
return (int32_t)glue(ldl, MEMSUFFIX)(EA);
79
static always_inline target_ulong glue(ldu32, MEMSUFFIX) (target_ulong EA)
81
return glue(__ldul, MEMSUFFIX)(EA);
84
static always_inline target_long glue(lds32, MEMSUFFIX) (target_ulong EA)
86
return glue(__ldsl, MEMSUFFIX)(EA);
89
static always_inline void glue(st32, MEMSUFFIX) (target_ulong EA, uint32_t val)
91
glue(stl, MEMSUFFIX)(EA, val);
94
static always_inline target_ulong glue(ldu32r, MEMSUFFIX) (target_ulong EA)
96
return bswap32(glue(__ldul, MEMSUFFIX)(EA));
99
static always_inline target_long glue(lds32r, MEMSUFFIX) (target_ulong EA)
101
return (int32_t)bswap32(glue(__ldul, MEMSUFFIX)(EA));
104
static always_inline void glue(st32r, MEMSUFFIX) (target_ulong EA, uint32_t val)
106
glue(stl, MEMSUFFIX)(EA, bswap32(val));
109
/* 64 bits accesses */
110
static always_inline uint64_t glue(__lduq, MEMSUFFIX) (target_ulong EA)
112
return (uint64_t)glue(ldq, MEMSUFFIX)(EA);
115
static always_inline int64_t glue(__ldsq, MEMSUFFIX) (target_ulong EA)
117
return (int64_t)glue(ldq, MEMSUFFIX)(EA);
120
static always_inline uint64_t glue(ldu64, MEMSUFFIX) (target_ulong EA)
122
return glue(__lduq, MEMSUFFIX)(EA);
125
static always_inline int64_t glue(lds64, MEMSUFFIX) (target_ulong EA)
127
return glue(__ldsq, MEMSUFFIX)(EA);
130
static always_inline void glue(st64, MEMSUFFIX) (target_ulong EA, uint64_t val)
132
glue(stq, MEMSUFFIX)(EA, val);
135
static always_inline uint64_t glue(ldu64r, MEMSUFFIX) (target_ulong EA)
137
return bswap64(glue(__lduq, MEMSUFFIX)(EA));
140
static always_inline int64_t glue(lds64r, MEMSUFFIX) (target_ulong EA)
142
return (int64_t)bswap64(glue(__lduq, MEMSUFFIX)(EA));
145
static always_inline void glue(st64r, MEMSUFFIX) (target_ulong EA, uint64_t val)
147
glue(stq, MEMSUFFIX)(EA, bswap64(val));