bellard | 9a64fbe | 2004-01-04 22:58:38 +0000 | [diff] [blame] | 1 | /* |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 2 | * PowerPC memory access emulation helpers for QEMU. |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 3 | * |
j_mayer | 76a6625 | 2007-03-07 08:32:30 +0000 | [diff] [blame] | 4 | * Copyright (c) 2003-2007 Jocelyn Mayer |
bellard | 9a64fbe | 2004-01-04 22:58:38 +0000 | [diff] [blame] | 5 | * |
| 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. |
| 10 | * |
| 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. |
| 15 | * |
| 16 | * You should have received a copy of the GNU Lesser General Public |
Blue Swirl | 8167ee8 | 2009-07-16 20:47:01 +0000 | [diff] [blame] | 17 | * License along with this library; if not, see <http://www.gnu.org/licenses/>. |
bellard | 9a64fbe | 2004-01-04 22:58:38 +0000 | [diff] [blame] | 18 | */ |
Blue Swirl | 3e45717 | 2011-07-13 12:44:15 +0000 | [diff] [blame] | 19 | #include "cpu.h" |
j_mayer | 603fccc | 2007-10-28 12:54:53 +0000 | [diff] [blame] | 20 | #include "host-utils.h" |
pbrook | a7812ae | 2008-11-17 14:43:54 +0000 | [diff] [blame] | 21 | #include "helper.h" |
bellard | 9a64fbe | 2004-01-04 22:58:38 +0000 | [diff] [blame] | 22 | |
j_mayer | 0411a97 | 2007-10-25 21:35:50 +0000 | [diff] [blame] | 23 | #include "helper_regs.h" |
j_mayer | 0487d6a | 2007-03-20 22:11:31 +0000 | [diff] [blame] | 24 | |
Blue Swirl | 3e45717 | 2011-07-13 12:44:15 +0000 | [diff] [blame] | 25 | #if !defined(CONFIG_USER_ONLY) |
Paolo Bonzini | 022c62c | 2012-12-17 18:19:49 +0100 | [diff] [blame^] | 26 | #include "exec/softmmu_exec.h" |
Blue Swirl | 3e45717 | 2011-07-13 12:44:15 +0000 | [diff] [blame] | 27 | #endif /* !defined(CONFIG_USER_ONLY) */ |
| 28 | |
bellard | fdabc36 | 2005-07-04 22:17:05 +0000 | [diff] [blame] | 29 | //#define DEBUG_OP |
aliguori | d12d51d | 2009-01-15 21:48:06 +0000 | [diff] [blame] | 30 | |
bellard | 9a64fbe | 2004-01-04 22:58:38 +0000 | [diff] [blame] | 31 | /*****************************************************************************/ |
aurel32 | ff4a62c | 2008-11-30 16:23:56 +0000 | [diff] [blame] | 32 | /* Memory load and stores */ |
| 33 | |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 34 | static inline target_ulong addr_add(CPUPPCState *env, target_ulong addr, |
| 35 | target_long arg) |
aurel32 | ff4a62c | 2008-11-30 16:23:56 +0000 | [diff] [blame] | 36 | { |
| 37 | #if defined(TARGET_PPC64) |
Alexander Graf | e42a61f | 2012-06-20 21:20:29 +0200 | [diff] [blame] | 38 | if (!msr_is_64bit(env, env->msr)) { |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 39 | return (uint32_t)(addr + arg); |
| 40 | } else |
aurel32 | ff4a62c | 2008-11-30 16:23:56 +0000 | [diff] [blame] | 41 | #endif |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 42 | { |
| 43 | return addr + arg; |
aurel32 | ff4a62c | 2008-11-30 16:23:56 +0000 | [diff] [blame] | 44 | } |
| 45 | } |
| 46 | |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 47 | void helper_lmw(CPUPPCState *env, target_ulong addr, uint32_t reg) |
aurel32 | ff4a62c | 2008-11-30 16:23:56 +0000 | [diff] [blame] | 48 | { |
aurel32 | 76db3ba | 2008-12-08 18:11:21 +0000 | [diff] [blame] | 49 | for (; reg < 32; reg++) { |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 50 | if (msr_le) { |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 51 | env->gpr[reg] = bswap32(cpu_ldl_data(env, addr)); |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 52 | } else { |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 53 | env->gpr[reg] = cpu_ldl_data(env, addr); |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 54 | } |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 55 | addr = addr_add(env, addr, 4); |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 56 | } |
| 57 | } |
| 58 | |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 59 | void helper_stmw(CPUPPCState *env, target_ulong addr, uint32_t reg) |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 60 | { |
| 61 | for (; reg < 32; reg++) { |
| 62 | if (msr_le) { |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 63 | cpu_stl_data(env, addr, bswap32((uint32_t)env->gpr[reg])); |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 64 | } else { |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 65 | cpu_stl_data(env, addr, (uint32_t)env->gpr[reg]); |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 66 | } |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 67 | addr = addr_add(env, addr, 4); |
aurel32 | ff4a62c | 2008-11-30 16:23:56 +0000 | [diff] [blame] | 68 | } |
| 69 | } |
| 70 | |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 71 | void helper_lsw(CPUPPCState *env, target_ulong addr, uint32_t nb, uint32_t reg) |
aurel32 | dfbc799 | 2008-11-30 16:24:21 +0000 | [diff] [blame] | 72 | { |
| 73 | int sh; |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 74 | |
aurel32 | 76db3ba | 2008-12-08 18:11:21 +0000 | [diff] [blame] | 75 | for (; nb > 3; nb -= 4) { |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 76 | env->gpr[reg] = cpu_ldl_data(env, addr); |
aurel32 | dfbc799 | 2008-11-30 16:24:21 +0000 | [diff] [blame] | 77 | reg = (reg + 1) % 32; |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 78 | addr = addr_add(env, addr, 4); |
aurel32 | dfbc799 | 2008-11-30 16:24:21 +0000 | [diff] [blame] | 79 | } |
| 80 | if (unlikely(nb > 0)) { |
| 81 | env->gpr[reg] = 0; |
aurel32 | 76db3ba | 2008-12-08 18:11:21 +0000 | [diff] [blame] | 82 | for (sh = 24; nb > 0; nb--, sh -= 8) { |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 83 | env->gpr[reg] |= cpu_ldub_data(env, addr) << sh; |
| 84 | addr = addr_add(env, addr, 1); |
aurel32 | dfbc799 | 2008-11-30 16:24:21 +0000 | [diff] [blame] | 85 | } |
| 86 | } |
| 87 | } |
| 88 | /* PPC32 specification says we must generate an exception if |
| 89 | * rA is in the range of registers to be loaded. |
| 90 | * In an other hand, IBM says this is valid, but rA won't be loaded. |
| 91 | * For now, I'll follow the spec... |
| 92 | */ |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 93 | void helper_lswx(CPUPPCState *env, target_ulong addr, uint32_t reg, |
| 94 | uint32_t ra, uint32_t rb) |
aurel32 | dfbc799 | 2008-11-30 16:24:21 +0000 | [diff] [blame] | 95 | { |
| 96 | if (likely(xer_bc != 0)) { |
| 97 | if (unlikely((ra != 0 && reg < ra && (reg + xer_bc) > ra) || |
| 98 | (reg < rb && (reg + xer_bc) > rb))) { |
Blue Swirl | e5f17ac | 2012-05-30 04:23:23 +0000 | [diff] [blame] | 99 | helper_raise_exception_err(env, POWERPC_EXCP_PROGRAM, |
aurel32 | e06fcd7 | 2008-12-11 22:42:14 +0000 | [diff] [blame] | 100 | POWERPC_EXCP_INVAL | |
| 101 | POWERPC_EXCP_INVAL_LSWX); |
aurel32 | dfbc799 | 2008-11-30 16:24:21 +0000 | [diff] [blame] | 102 | } else { |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 103 | helper_lsw(env, addr, xer_bc, reg); |
aurel32 | dfbc799 | 2008-11-30 16:24:21 +0000 | [diff] [blame] | 104 | } |
| 105 | } |
| 106 | } |
| 107 | |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 108 | void helper_stsw(CPUPPCState *env, target_ulong addr, uint32_t nb, |
| 109 | uint32_t reg) |
aurel32 | dfbc799 | 2008-11-30 16:24:21 +0000 | [diff] [blame] | 110 | { |
| 111 | int sh; |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 112 | |
aurel32 | 76db3ba | 2008-12-08 18:11:21 +0000 | [diff] [blame] | 113 | for (; nb > 3; nb -= 4) { |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 114 | cpu_stl_data(env, addr, env->gpr[reg]); |
aurel32 | dfbc799 | 2008-11-30 16:24:21 +0000 | [diff] [blame] | 115 | reg = (reg + 1) % 32; |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 116 | addr = addr_add(env, addr, 4); |
aurel32 | dfbc799 | 2008-11-30 16:24:21 +0000 | [diff] [blame] | 117 | } |
| 118 | if (unlikely(nb > 0)) { |
aurel32 | a16b45e | 2008-12-29 09:46:58 +0000 | [diff] [blame] | 119 | for (sh = 24; nb > 0; nb--, sh -= 8) { |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 120 | cpu_stb_data(env, addr, (env->gpr[reg] >> sh) & 0xFF); |
| 121 | addr = addr_add(env, addr, 1); |
aurel32 | a16b45e | 2008-12-29 09:46:58 +0000 | [diff] [blame] | 122 | } |
aurel32 | dfbc799 | 2008-11-30 16:24:21 +0000 | [diff] [blame] | 123 | } |
| 124 | } |
| 125 | |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 126 | static void do_dcbz(CPUPPCState *env, target_ulong addr, int dcache_line_size) |
aurel32 | 799a8c8 | 2008-11-30 16:24:05 +0000 | [diff] [blame] | 127 | { |
aurel32 | 799a8c8 | 2008-11-30 16:24:05 +0000 | [diff] [blame] | 128 | int i; |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 129 | |
| 130 | addr &= ~(dcache_line_size - 1); |
| 131 | for (i = 0; i < dcache_line_size; i += 4) { |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 132 | cpu_stl_data(env, addr + i, 0); |
aurel32 | 799a8c8 | 2008-11-30 16:24:05 +0000 | [diff] [blame] | 133 | } |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 134 | if (env->reserve_addr == addr) { |
Nathan Froyd | 18b21a2 | 2009-08-03 08:43:25 -0700 | [diff] [blame] | 135 | env->reserve_addr = (target_ulong)-1ULL; |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 136 | } |
aurel32 | 799a8c8 | 2008-11-30 16:24:05 +0000 | [diff] [blame] | 137 | } |
| 138 | |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 139 | void helper_dcbz(CPUPPCState *env, target_ulong addr) |
aurel32 | 799a8c8 | 2008-11-30 16:24:05 +0000 | [diff] [blame] | 140 | { |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 141 | do_dcbz(env, addr, env->dcache_line_size); |
aurel32 | 799a8c8 | 2008-11-30 16:24:05 +0000 | [diff] [blame] | 142 | } |
| 143 | |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 144 | void helper_dcbz_970(CPUPPCState *env, target_ulong addr) |
aurel32 | 799a8c8 | 2008-11-30 16:24:05 +0000 | [diff] [blame] | 145 | { |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 146 | if (((env->spr[SPR_970_HID5] >> 7) & 0x3) == 1) { |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 147 | do_dcbz(env, addr, 32); |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 148 | } else { |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 149 | do_dcbz(env, addr, env->dcache_line_size); |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 150 | } |
aurel32 | 799a8c8 | 2008-11-30 16:24:05 +0000 | [diff] [blame] | 151 | } |
| 152 | |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 153 | void helper_icbi(CPUPPCState *env, target_ulong addr) |
aurel32 | 37d269d | 2008-11-30 16:24:13 +0000 | [diff] [blame] | 154 | { |
aurel32 | 76db3ba | 2008-12-08 18:11:21 +0000 | [diff] [blame] | 155 | addr &= ~(env->dcache_line_size - 1); |
aurel32 | 37d269d | 2008-11-30 16:24:13 +0000 | [diff] [blame] | 156 | /* Invalidate one cache line : |
| 157 | * PowerPC specification says this is to be treated like a load |
| 158 | * (not a fetch) by the MMU. To be sure it will be so, |
| 159 | * do the load "by hand". |
| 160 | */ |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 161 | cpu_ldl_data(env, addr); |
aurel32 | 37d269d | 2008-11-30 16:24:13 +0000 | [diff] [blame] | 162 | } |
| 163 | |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 164 | /* XXX: to be tested */ |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 165 | target_ulong helper_lscbx(CPUPPCState *env, target_ulong addr, uint32_t reg, |
| 166 | uint32_t ra, uint32_t rb) |
aurel32 | bdb4b68 | 2008-11-30 16:24:30 +0000 | [diff] [blame] | 167 | { |
| 168 | int i, c, d; |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 169 | |
aurel32 | bdb4b68 | 2008-11-30 16:24:30 +0000 | [diff] [blame] | 170 | d = 24; |
| 171 | for (i = 0; i < xer_bc; i++) { |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 172 | c = cpu_ldub_data(env, addr); |
| 173 | addr = addr_add(env, addr, 1); |
aurel32 | bdb4b68 | 2008-11-30 16:24:30 +0000 | [diff] [blame] | 174 | /* ra (if not 0) and rb are never modified */ |
| 175 | if (likely(reg != rb && (ra == 0 || reg != ra))) { |
| 176 | env->gpr[reg] = (env->gpr[reg] & ~(0xFF << d)) | (c << d); |
| 177 | } |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 178 | if (unlikely(c == xer_cmp)) { |
aurel32 | bdb4b68 | 2008-11-30 16:24:30 +0000 | [diff] [blame] | 179 | break; |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 180 | } |
aurel32 | bdb4b68 | 2008-11-30 16:24:30 +0000 | [diff] [blame] | 181 | if (likely(d != 0)) { |
| 182 | d -= 8; |
| 183 | } else { |
| 184 | d = 24; |
| 185 | reg++; |
| 186 | reg = reg & 0x1F; |
| 187 | } |
| 188 | } |
| 189 | return i; |
| 190 | } |
| 191 | |
aurel32 | ff4a62c | 2008-11-30 16:23:56 +0000 | [diff] [blame] | 192 | /*****************************************************************************/ |
aurel32 | d6a46fe | 2009-01-03 13:31:19 +0000 | [diff] [blame] | 193 | /* Altivec extension helpers */ |
Juan Quintela | e2542fe | 2009-07-27 16:13:06 +0200 | [diff] [blame] | 194 | #if defined(HOST_WORDS_BIGENDIAN) |
aurel32 | d6a46fe | 2009-01-03 13:31:19 +0000 | [diff] [blame] | 195 | #define HI_IDX 0 |
| 196 | #define LO_IDX 1 |
| 197 | #else |
| 198 | #define HI_IDX 1 |
| 199 | #define LO_IDX 0 |
| 200 | #endif |
| 201 | |
aurel32 | cbfb6ae | 2009-01-04 22:13:10 +0000 | [diff] [blame] | 202 | #define LVE(name, access, swap, element) \ |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 203 | void helper_##name(CPUPPCState *env, ppc_avr_t *r, \ |
| 204 | target_ulong addr) \ |
aurel32 | cbfb6ae | 2009-01-04 22:13:10 +0000 | [diff] [blame] | 205 | { \ |
| 206 | size_t n_elems = ARRAY_SIZE(r->element); \ |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 207 | int adjust = HI_IDX*(n_elems - 1); \ |
aurel32 | cbfb6ae | 2009-01-04 22:13:10 +0000 | [diff] [blame] | 208 | int sh = sizeof(r->element[0]) >> 1; \ |
| 209 | int index = (addr & 0xf) >> sh; \ |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 210 | \ |
| 211 | if (msr_le) { \ |
| 212 | r->element[LO_IDX ? index : (adjust - index)] = \ |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 213 | swap(access(env, addr)); \ |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 214 | } else { \ |
| 215 | r->element[LO_IDX ? index : (adjust - index)] = \ |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 216 | access(env, addr); \ |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 217 | } \ |
aurel32 | cbfb6ae | 2009-01-04 22:13:10 +0000 | [diff] [blame] | 218 | } |
| 219 | #define I(x) (x) |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 220 | LVE(lvebx, cpu_ldub_data, I, u8) |
| 221 | LVE(lvehx, cpu_lduw_data, bswap16, u16) |
| 222 | LVE(lvewx, cpu_ldl_data, bswap32, u32) |
aurel32 | cbfb6ae | 2009-01-04 22:13:10 +0000 | [diff] [blame] | 223 | #undef I |
| 224 | #undef LVE |
| 225 | |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 226 | #define STVE(name, access, swap, element) \ |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 227 | void helper_##name(CPUPPCState *env, ppc_avr_t *r, \ |
| 228 | target_ulong addr) \ |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 229 | { \ |
| 230 | size_t n_elems = ARRAY_SIZE(r->element); \ |
| 231 | int adjust = HI_IDX * (n_elems - 1); \ |
| 232 | int sh = sizeof(r->element[0]) >> 1; \ |
| 233 | int index = (addr & 0xf) >> sh; \ |
| 234 | \ |
| 235 | if (msr_le) { \ |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 236 | access(env, addr, swap(r->element[LO_IDX ? index : \ |
| 237 | (adjust - index)])); \ |
aurel32 | cbfb6ae | 2009-01-04 22:13:10 +0000 | [diff] [blame] | 238 | } else { \ |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 239 | access(env, addr, r->element[LO_IDX ? index : \ |
| 240 | (adjust - index)]); \ |
aurel32 | cbfb6ae | 2009-01-04 22:13:10 +0000 | [diff] [blame] | 241 | } \ |
| 242 | } |
| 243 | #define I(x) (x) |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 244 | STVE(stvebx, cpu_stb_data, I, u8) |
| 245 | STVE(stvehx, cpu_stw_data, bswap16, u16) |
| 246 | STVE(stvewx, cpu_stl_data, bswap32, u32) |
aurel32 | cbfb6ae | 2009-01-04 22:13:10 +0000 | [diff] [blame] | 247 | #undef I |
| 248 | #undef LVE |
| 249 | |
aurel32 | d6a46fe | 2009-01-03 13:31:19 +0000 | [diff] [blame] | 250 | #undef HI_IDX |
| 251 | #undef LO_IDX |
| 252 | |
| 253 | /*****************************************************************************/ |
bellard | fdabc36 | 2005-07-04 22:17:05 +0000 | [diff] [blame] | 254 | /* Softmmu support */ |
Blue Swirl | b327c65 | 2012-05-30 04:23:21 +0000 | [diff] [blame] | 255 | #if !defined(CONFIG_USER_ONLY) |
bellard | fdabc36 | 2005-07-04 22:17:05 +0000 | [diff] [blame] | 256 | |
| 257 | #define MMUSUFFIX _mmu |
bellard | fdabc36 | 2005-07-04 22:17:05 +0000 | [diff] [blame] | 258 | |
| 259 | #define SHIFT 0 |
Paolo Bonzini | 022c62c | 2012-12-17 18:19:49 +0100 | [diff] [blame^] | 260 | #include "exec/softmmu_template.h" |
bellard | fdabc36 | 2005-07-04 22:17:05 +0000 | [diff] [blame] | 261 | |
| 262 | #define SHIFT 1 |
Paolo Bonzini | 022c62c | 2012-12-17 18:19:49 +0100 | [diff] [blame^] | 263 | #include "exec/softmmu_template.h" |
bellard | fdabc36 | 2005-07-04 22:17:05 +0000 | [diff] [blame] | 264 | |
| 265 | #define SHIFT 2 |
Paolo Bonzini | 022c62c | 2012-12-17 18:19:49 +0100 | [diff] [blame^] | 266 | #include "exec/softmmu_template.h" |
bellard | fdabc36 | 2005-07-04 22:17:05 +0000 | [diff] [blame] | 267 | |
| 268 | #define SHIFT 3 |
Paolo Bonzini | 022c62c | 2012-12-17 18:19:49 +0100 | [diff] [blame^] | 269 | #include "exec/softmmu_template.h" |
bellard | fdabc36 | 2005-07-04 22:17:05 +0000 | [diff] [blame] | 270 | |
| 271 | /* try to fill the TLB and return an exception if error. If retaddr is |
| 272 | NULL, it means that the function was called in C code (i.e. not |
| 273 | from generated code or from helper.c) */ |
| 274 | /* XXX: fix it to restore all registers */ |
Blue Swirl | 2f5a189 | 2012-05-30 04:23:40 +0000 | [diff] [blame] | 275 | void tlb_fill(CPUPPCState *env, target_ulong addr, int is_write, int mmu_idx, |
Blue Swirl | 2050396 | 2012-04-09 14:20:20 +0000 | [diff] [blame] | 276 | uintptr_t retaddr) |
bellard | fdabc36 | 2005-07-04 22:17:05 +0000 | [diff] [blame] | 277 | { |
bellard | fdabc36 | 2005-07-04 22:17:05 +0000 | [diff] [blame] | 278 | int ret; |
| 279 | |
Blue Swirl | 97b348e | 2011-08-01 16:12:17 +0000 | [diff] [blame] | 280 | ret = cpu_ppc_handle_mmu_fault(env, addr, is_write, mmu_idx); |
j_mayer | 76a6625 | 2007-03-07 08:32:30 +0000 | [diff] [blame] | 281 | if (unlikely(ret != 0)) { |
bellard | fdabc36 | 2005-07-04 22:17:05 +0000 | [diff] [blame] | 282 | if (likely(retaddr)) { |
| 283 | /* now we have a real cpu fault */ |
Blue Swirl | a8a826a | 2012-12-04 20:16:07 +0000 | [diff] [blame] | 284 | cpu_restore_state(env, retaddr); |
bellard | fdabc36 | 2005-07-04 22:17:05 +0000 | [diff] [blame] | 285 | } |
Blue Swirl | e5f17ac | 2012-05-30 04:23:23 +0000 | [diff] [blame] | 286 | helper_raise_exception_err(env, env->exception_index, env->error_code); |
bellard | fdabc36 | 2005-07-04 22:17:05 +0000 | [diff] [blame] | 287 | } |
bellard | fdabc36 | 2005-07-04 22:17:05 +0000 | [diff] [blame] | 288 | } |
j_mayer | 76a6625 | 2007-03-07 08:32:30 +0000 | [diff] [blame] | 289 | #endif /* !CONFIG_USER_ONLY */ |