bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 1 | /* |
| 2 | * Software MMU support |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 3 | * |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 4 | * Copyright (c) 2003 Fabrice Bellard |
| 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 | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 18 | */ |
| 19 | #if DATA_SIZE == 8 |
| 20 | #define SUFFIX q |
bellard | 61382a5 | 2003-10-27 21:22:23 +0000 | [diff] [blame] | 21 | #define USUFFIX q |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 22 | #define DATA_TYPE uint64_t |
| 23 | #elif DATA_SIZE == 4 |
| 24 | #define SUFFIX l |
bellard | 61382a5 | 2003-10-27 21:22:23 +0000 | [diff] [blame] | 25 | #define USUFFIX l |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 26 | #define DATA_TYPE uint32_t |
| 27 | #elif DATA_SIZE == 2 |
| 28 | #define SUFFIX w |
bellard | 61382a5 | 2003-10-27 21:22:23 +0000 | [diff] [blame] | 29 | #define USUFFIX uw |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 30 | #define DATA_TYPE uint16_t |
| 31 | #define DATA_STYPE int16_t |
| 32 | #elif DATA_SIZE == 1 |
| 33 | #define SUFFIX b |
bellard | 61382a5 | 2003-10-27 21:22:23 +0000 | [diff] [blame] | 34 | #define USUFFIX ub |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 35 | #define DATA_TYPE uint8_t |
| 36 | #define DATA_STYPE int8_t |
| 37 | #else |
| 38 | #error unsupported data size |
| 39 | #endif |
| 40 | |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 41 | #if ACCESS_TYPE < (NB_MMU_MODES) |
bellard | 61382a5 | 2003-10-27 21:22:23 +0000 | [diff] [blame] | 42 | |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 43 | #define CPU_MMU_INDEX ACCESS_TYPE |
bellard | 61382a5 | 2003-10-27 21:22:23 +0000 | [diff] [blame] | 44 | #define MMUSUFFIX _mmu |
| 45 | |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 46 | #elif ACCESS_TYPE == (NB_MMU_MODES) |
bellard | 61382a5 | 2003-10-27 21:22:23 +0000 | [diff] [blame] | 47 | |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 48 | #define CPU_MMU_INDEX (cpu_mmu_index(env)) |
bellard | 61382a5 | 2003-10-27 21:22:23 +0000 | [diff] [blame] | 49 | #define MMUSUFFIX _mmu |
| 50 | |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 51 | #elif ACCESS_TYPE == (NB_MMU_MODES + 1) |
bellard | 61382a5 | 2003-10-27 21:22:23 +0000 | [diff] [blame] | 52 | |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 53 | #define CPU_MMU_INDEX (cpu_mmu_index(env)) |
bellard | 61382a5 | 2003-10-27 21:22:23 +0000 | [diff] [blame] | 54 | #define MMUSUFFIX _cmmu |
| 55 | |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 56 | #else |
bellard | 61382a5 | 2003-10-27 21:22:23 +0000 | [diff] [blame] | 57 | #error invalid ACCESS_TYPE |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 58 | #endif |
| 59 | |
| 60 | #if DATA_SIZE == 8 |
| 61 | #define RES_TYPE uint64_t |
| 62 | #else |
| 63 | #define RES_TYPE int |
| 64 | #endif |
| 65 | |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 66 | #if ACCESS_TYPE == (NB_MMU_MODES + 1) |
bellard | 84b7b8e | 2005-11-28 21:19:04 +0000 | [diff] [blame] | 67 | #define ADDR_READ addr_code |
| 68 | #else |
| 69 | #define ADDR_READ addr_read |
| 70 | #endif |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 71 | |
bellard | c27004e | 2005-01-03 23:35:10 +0000 | [diff] [blame] | 72 | #if (DATA_SIZE <= 4) && (TARGET_LONG_BITS == 32) && defined(__i386__) && \ |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 73 | (ACCESS_TYPE < NB_MMU_MODES) && defined(ASM_SOFTMMU) |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 74 | |
bellard | c27004e | 2005-01-03 23:35:10 +0000 | [diff] [blame] | 75 | static inline RES_TYPE glue(glue(ld, USUFFIX), MEMSUFFIX)(target_ulong ptr) |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 76 | { |
| 77 | int res; |
| 78 | |
| 79 | asm volatile ("movl %1, %%edx\n" |
| 80 | "movl %1, %%eax\n" |
| 81 | "shrl %3, %%edx\n" |
| 82 | "andl %4, %%eax\n" |
| 83 | "andl %2, %%edx\n" |
| 84 | "leal %5(%%edx, %%ebp), %%edx\n" |
| 85 | "cmpl (%%edx), %%eax\n" |
| 86 | "movl %1, %%eax\n" |
| 87 | "je 1f\n" |
bellard | d656469 | 2008-01-31 09:22:27 +0000 | [diff] [blame] | 88 | "movl %6, %%edx\n" |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 89 | "call %7\n" |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 90 | "movl %%eax, %0\n" |
| 91 | "jmp 2f\n" |
| 92 | "1:\n" |
bellard | 84b7b8e | 2005-11-28 21:19:04 +0000 | [diff] [blame] | 93 | "addl 12(%%edx), %%eax\n" |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 94 | #if DATA_SIZE == 1 |
| 95 | "movzbl (%%eax), %0\n" |
| 96 | #elif DATA_SIZE == 2 |
| 97 | "movzwl (%%eax), %0\n" |
| 98 | #elif DATA_SIZE == 4 |
| 99 | "movl (%%eax), %0\n" |
| 100 | #else |
| 101 | #error unsupported size |
| 102 | #endif |
| 103 | "2:\n" |
| 104 | : "=r" (res) |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 105 | : "r" (ptr), |
| 106 | "i" ((CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS), |
| 107 | "i" (TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS), |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 108 | "i" (TARGET_PAGE_MASK | (DATA_SIZE - 1)), |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 109 | "m" (*(uint32_t *)offsetof(CPUState, tlb_table[CPU_MMU_INDEX][0].addr_read)), |
| 110 | "i" (CPU_MMU_INDEX), |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 111 | "m" (*(uint8_t *)&glue(glue(__ld, SUFFIX), MMUSUFFIX)) |
| 112 | : "%eax", "%ecx", "%edx", "memory", "cc"); |
| 113 | return res; |
| 114 | } |
| 115 | |
| 116 | #if DATA_SIZE <= 2 |
bellard | c27004e | 2005-01-03 23:35:10 +0000 | [diff] [blame] | 117 | static inline int glue(glue(lds, SUFFIX), MEMSUFFIX)(target_ulong ptr) |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 118 | { |
| 119 | int res; |
| 120 | |
| 121 | asm volatile ("movl %1, %%edx\n" |
| 122 | "movl %1, %%eax\n" |
| 123 | "shrl %3, %%edx\n" |
| 124 | "andl %4, %%eax\n" |
| 125 | "andl %2, %%edx\n" |
| 126 | "leal %5(%%edx, %%ebp), %%edx\n" |
| 127 | "cmpl (%%edx), %%eax\n" |
| 128 | "movl %1, %%eax\n" |
| 129 | "je 1f\n" |
bellard | d656469 | 2008-01-31 09:22:27 +0000 | [diff] [blame] | 130 | "movl %6, %%edx\n" |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 131 | "call %7\n" |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 132 | #if DATA_SIZE == 1 |
| 133 | "movsbl %%al, %0\n" |
| 134 | #elif DATA_SIZE == 2 |
| 135 | "movswl %%ax, %0\n" |
| 136 | #else |
| 137 | #error unsupported size |
| 138 | #endif |
| 139 | "jmp 2f\n" |
| 140 | "1:\n" |
bellard | 84b7b8e | 2005-11-28 21:19:04 +0000 | [diff] [blame] | 141 | "addl 12(%%edx), %%eax\n" |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 142 | #if DATA_SIZE == 1 |
| 143 | "movsbl (%%eax), %0\n" |
| 144 | #elif DATA_SIZE == 2 |
| 145 | "movswl (%%eax), %0\n" |
| 146 | #else |
| 147 | #error unsupported size |
| 148 | #endif |
| 149 | "2:\n" |
| 150 | : "=r" (res) |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 151 | : "r" (ptr), |
| 152 | "i" ((CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS), |
| 153 | "i" (TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS), |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 154 | "i" (TARGET_PAGE_MASK | (DATA_SIZE - 1)), |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 155 | "m" (*(uint32_t *)offsetof(CPUState, tlb_table[CPU_MMU_INDEX][0].addr_read)), |
| 156 | "i" (CPU_MMU_INDEX), |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 157 | "m" (*(uint8_t *)&glue(glue(__ld, SUFFIX), MMUSUFFIX)) |
| 158 | : "%eax", "%ecx", "%edx", "memory", "cc"); |
| 159 | return res; |
| 160 | } |
| 161 | #endif |
| 162 | |
bellard | c27004e | 2005-01-03 23:35:10 +0000 | [diff] [blame] | 163 | static inline void glue(glue(st, SUFFIX), MEMSUFFIX)(target_ulong ptr, RES_TYPE v) |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 164 | { |
| 165 | asm volatile ("movl %0, %%edx\n" |
| 166 | "movl %0, %%eax\n" |
| 167 | "shrl %3, %%edx\n" |
| 168 | "andl %4, %%eax\n" |
| 169 | "andl %2, %%edx\n" |
| 170 | "leal %5(%%edx, %%ebp), %%edx\n" |
| 171 | "cmpl (%%edx), %%eax\n" |
| 172 | "movl %0, %%eax\n" |
| 173 | "je 1f\n" |
| 174 | #if DATA_SIZE == 1 |
| 175 | "movzbl %b1, %%edx\n" |
| 176 | #elif DATA_SIZE == 2 |
| 177 | "movzwl %w1, %%edx\n" |
| 178 | #elif DATA_SIZE == 4 |
| 179 | "movl %1, %%edx\n" |
| 180 | #else |
| 181 | #error unsupported size |
| 182 | #endif |
bellard | d656469 | 2008-01-31 09:22:27 +0000 | [diff] [blame] | 183 | "movl %6, %%ecx\n" |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 184 | "call %7\n" |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 185 | "jmp 2f\n" |
| 186 | "1:\n" |
bellard | 84b7b8e | 2005-11-28 21:19:04 +0000 | [diff] [blame] | 187 | "addl 8(%%edx), %%eax\n" |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 188 | #if DATA_SIZE == 1 |
| 189 | "movb %b1, (%%eax)\n" |
| 190 | #elif DATA_SIZE == 2 |
| 191 | "movw %w1, (%%eax)\n" |
| 192 | #elif DATA_SIZE == 4 |
| 193 | "movl %1, (%%eax)\n" |
| 194 | #else |
| 195 | #error unsupported size |
| 196 | #endif |
| 197 | "2:\n" |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 198 | : |
| 199 | : "r" (ptr), |
bellard | f220f4e | 2008-01-21 15:07:18 +0000 | [diff] [blame] | 200 | #if DATA_SIZE == 1 |
| 201 | "q" (v), |
| 202 | #else |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 203 | "r" (v), |
bellard | f220f4e | 2008-01-21 15:07:18 +0000 | [diff] [blame] | 204 | #endif |
ths | 5fafdf2 | 2007-09-16 21:08:06 +0000 | [diff] [blame] | 205 | "i" ((CPU_TLB_SIZE - 1) << CPU_TLB_ENTRY_BITS), |
| 206 | "i" (TARGET_PAGE_BITS - CPU_TLB_ENTRY_BITS), |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 207 | "i" (TARGET_PAGE_MASK | (DATA_SIZE - 1)), |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 208 | "m" (*(uint32_t *)offsetof(CPUState, tlb_table[CPU_MMU_INDEX][0].addr_write)), |
| 209 | "i" (CPU_MMU_INDEX), |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 210 | "m" (*(uint8_t *)&glue(glue(__st, SUFFIX), MMUSUFFIX)) |
| 211 | : "%eax", "%ecx", "%edx", "memory", "cc"); |
| 212 | } |
| 213 | |
| 214 | #else |
| 215 | |
| 216 | /* generic load/store macros */ |
| 217 | |
bellard | c27004e | 2005-01-03 23:35:10 +0000 | [diff] [blame] | 218 | static inline RES_TYPE glue(glue(ld, USUFFIX), MEMSUFFIX)(target_ulong ptr) |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 219 | { |
blueswir1 | 4d7a088 | 2008-05-10 10:14:22 +0000 | [diff] [blame] | 220 | int page_index; |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 221 | RES_TYPE res; |
bellard | c27004e | 2005-01-03 23:35:10 +0000 | [diff] [blame] | 222 | target_ulong addr; |
| 223 | unsigned long physaddr; |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 224 | int mmu_idx; |
bellard | 61382a5 | 2003-10-27 21:22:23 +0000 | [diff] [blame] | 225 | |
bellard | c27004e | 2005-01-03 23:35:10 +0000 | [diff] [blame] | 226 | addr = ptr; |
blueswir1 | 4d7a088 | 2008-05-10 10:14:22 +0000 | [diff] [blame] | 227 | page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 228 | mmu_idx = CPU_MMU_INDEX; |
ths | 551bd27 | 2008-07-03 17:57:36 +0000 | [diff] [blame] | 229 | if (unlikely(env->tlb_table[mmu_idx][page_index].ADDR_READ != |
| 230 | (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 231 | res = glue(glue(__ld, SUFFIX), MMUSUFFIX)(addr, mmu_idx); |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 232 | } else { |
blueswir1 | 4d7a088 | 2008-05-10 10:14:22 +0000 | [diff] [blame] | 233 | physaddr = addr + env->tlb_table[mmu_idx][page_index].addend; |
bellard | 61382a5 | 2003-10-27 21:22:23 +0000 | [diff] [blame] | 234 | res = glue(glue(ld, USUFFIX), _raw)((uint8_t *)physaddr); |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 235 | } |
| 236 | return res; |
| 237 | } |
| 238 | |
| 239 | #if DATA_SIZE <= 2 |
bellard | c27004e | 2005-01-03 23:35:10 +0000 | [diff] [blame] | 240 | static inline int glue(glue(lds, SUFFIX), MEMSUFFIX)(target_ulong ptr) |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 241 | { |
blueswir1 | 4d7a088 | 2008-05-10 10:14:22 +0000 | [diff] [blame] | 242 | int res, page_index; |
bellard | c27004e | 2005-01-03 23:35:10 +0000 | [diff] [blame] | 243 | target_ulong addr; |
| 244 | unsigned long physaddr; |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 245 | int mmu_idx; |
bellard | 61382a5 | 2003-10-27 21:22:23 +0000 | [diff] [blame] | 246 | |
bellard | c27004e | 2005-01-03 23:35:10 +0000 | [diff] [blame] | 247 | addr = ptr; |
blueswir1 | 4d7a088 | 2008-05-10 10:14:22 +0000 | [diff] [blame] | 248 | page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 249 | mmu_idx = CPU_MMU_INDEX; |
ths | 551bd27 | 2008-07-03 17:57:36 +0000 | [diff] [blame] | 250 | if (unlikely(env->tlb_table[mmu_idx][page_index].ADDR_READ != |
| 251 | (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 252 | res = (DATA_STYPE)glue(glue(__ld, SUFFIX), MMUSUFFIX)(addr, mmu_idx); |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 253 | } else { |
blueswir1 | 4d7a088 | 2008-05-10 10:14:22 +0000 | [diff] [blame] | 254 | physaddr = addr + env->tlb_table[mmu_idx][page_index].addend; |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 255 | res = glue(glue(lds, SUFFIX), _raw)((uint8_t *)physaddr); |
| 256 | } |
| 257 | return res; |
| 258 | } |
| 259 | #endif |
| 260 | |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 261 | #if ACCESS_TYPE != (NB_MMU_MODES + 1) |
bellard | 84b7b8e | 2005-11-28 21:19:04 +0000 | [diff] [blame] | 262 | |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 263 | /* generic store macro */ |
| 264 | |
bellard | c27004e | 2005-01-03 23:35:10 +0000 | [diff] [blame] | 265 | static inline void glue(glue(st, SUFFIX), MEMSUFFIX)(target_ulong ptr, RES_TYPE v) |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 266 | { |
blueswir1 | 4d7a088 | 2008-05-10 10:14:22 +0000 | [diff] [blame] | 267 | int page_index; |
bellard | c27004e | 2005-01-03 23:35:10 +0000 | [diff] [blame] | 268 | target_ulong addr; |
| 269 | unsigned long physaddr; |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 270 | int mmu_idx; |
bellard | 61382a5 | 2003-10-27 21:22:23 +0000 | [diff] [blame] | 271 | |
bellard | c27004e | 2005-01-03 23:35:10 +0000 | [diff] [blame] | 272 | addr = ptr; |
blueswir1 | 4d7a088 | 2008-05-10 10:14:22 +0000 | [diff] [blame] | 273 | page_index = (addr >> TARGET_PAGE_BITS) & (CPU_TLB_SIZE - 1); |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 274 | mmu_idx = CPU_MMU_INDEX; |
ths | 551bd27 | 2008-07-03 17:57:36 +0000 | [diff] [blame] | 275 | if (unlikely(env->tlb_table[mmu_idx][page_index].addr_write != |
| 276 | (addr & (TARGET_PAGE_MASK | (DATA_SIZE - 1))))) { |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 277 | glue(glue(__st, SUFFIX), MMUSUFFIX)(addr, v, mmu_idx); |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 278 | } else { |
blueswir1 | 4d7a088 | 2008-05-10 10:14:22 +0000 | [diff] [blame] | 279 | physaddr = addr + env->tlb_table[mmu_idx][page_index].addend; |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 280 | glue(glue(st, SUFFIX), _raw)((uint8_t *)physaddr, v); |
| 281 | } |
| 282 | } |
| 283 | |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 284 | #endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */ |
bellard | 84b7b8e | 2005-11-28 21:19:04 +0000 | [diff] [blame] | 285 | |
| 286 | #endif /* !asm */ |
| 287 | |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 288 | #if ACCESS_TYPE != (NB_MMU_MODES + 1) |
bellard | e16c53f | 2004-01-04 18:15:29 +0000 | [diff] [blame] | 289 | |
bellard | 2d603d2 | 2004-01-04 23:56:24 +0000 | [diff] [blame] | 290 | #if DATA_SIZE == 8 |
bellard | 3f87bf6 | 2005-11-06 19:56:23 +0000 | [diff] [blame] | 291 | static inline float64 glue(ldfq, MEMSUFFIX)(target_ulong ptr) |
bellard | 2d603d2 | 2004-01-04 23:56:24 +0000 | [diff] [blame] | 292 | { |
| 293 | union { |
bellard | 3f87bf6 | 2005-11-06 19:56:23 +0000 | [diff] [blame] | 294 | float64 d; |
bellard | 2d603d2 | 2004-01-04 23:56:24 +0000 | [diff] [blame] | 295 | uint64_t i; |
| 296 | } u; |
| 297 | u.i = glue(ldq, MEMSUFFIX)(ptr); |
| 298 | return u.d; |
| 299 | } |
| 300 | |
bellard | 3f87bf6 | 2005-11-06 19:56:23 +0000 | [diff] [blame] | 301 | static inline void glue(stfq, MEMSUFFIX)(target_ulong ptr, float64 v) |
bellard | 2d603d2 | 2004-01-04 23:56:24 +0000 | [diff] [blame] | 302 | { |
| 303 | union { |
bellard | 3f87bf6 | 2005-11-06 19:56:23 +0000 | [diff] [blame] | 304 | float64 d; |
bellard | 2d603d2 | 2004-01-04 23:56:24 +0000 | [diff] [blame] | 305 | uint64_t i; |
| 306 | } u; |
| 307 | u.d = v; |
| 308 | glue(stq, MEMSUFFIX)(ptr, u.i); |
| 309 | } |
| 310 | #endif /* DATA_SIZE == 8 */ |
| 311 | |
| 312 | #if DATA_SIZE == 4 |
bellard | 3f87bf6 | 2005-11-06 19:56:23 +0000 | [diff] [blame] | 313 | static inline float32 glue(ldfl, MEMSUFFIX)(target_ulong ptr) |
bellard | 2d603d2 | 2004-01-04 23:56:24 +0000 | [diff] [blame] | 314 | { |
| 315 | union { |
bellard | 3f87bf6 | 2005-11-06 19:56:23 +0000 | [diff] [blame] | 316 | float32 f; |
bellard | 2d603d2 | 2004-01-04 23:56:24 +0000 | [diff] [blame] | 317 | uint32_t i; |
| 318 | } u; |
| 319 | u.i = glue(ldl, MEMSUFFIX)(ptr); |
| 320 | return u.f; |
| 321 | } |
| 322 | |
bellard | 3f87bf6 | 2005-11-06 19:56:23 +0000 | [diff] [blame] | 323 | static inline void glue(stfl, MEMSUFFIX)(target_ulong ptr, float32 v) |
bellard | 2d603d2 | 2004-01-04 23:56:24 +0000 | [diff] [blame] | 324 | { |
| 325 | union { |
bellard | 3f87bf6 | 2005-11-06 19:56:23 +0000 | [diff] [blame] | 326 | float32 f; |
bellard | 2d603d2 | 2004-01-04 23:56:24 +0000 | [diff] [blame] | 327 | uint32_t i; |
| 328 | } u; |
| 329 | u.f = v; |
| 330 | glue(stl, MEMSUFFIX)(ptr, u.i); |
| 331 | } |
| 332 | #endif /* DATA_SIZE == 4 */ |
| 333 | |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 334 | #endif /* ACCESS_TYPE != (NB_MMU_MODES + 1) */ |
bellard | 84b7b8e | 2005-11-28 21:19:04 +0000 | [diff] [blame] | 335 | |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 336 | #undef RES_TYPE |
| 337 | #undef DATA_TYPE |
| 338 | #undef DATA_STYPE |
| 339 | #undef SUFFIX |
bellard | 61382a5 | 2003-10-27 21:22:23 +0000 | [diff] [blame] | 340 | #undef USUFFIX |
bellard | b92e5a2 | 2003-08-08 23:58:05 +0000 | [diff] [blame] | 341 | #undef DATA_SIZE |
j_mayer | 6ebbf39 | 2007-10-14 07:07:08 +0000 | [diff] [blame] | 342 | #undef CPU_MMU_INDEX |
bellard | 61382a5 | 2003-10-27 21:22:23 +0000 | [diff] [blame] | 343 | #undef MMUSUFFIX |
bellard | 84b7b8e | 2005-11-28 21:19:04 +0000 | [diff] [blame] | 344 | #undef ADDR_READ |