root / target-sh4 / helper.c @ 68f6dc7e
History | View | Annotate | Download (17.6 kB)
1 | fdf9b3e8 | bellard | /*
|
---|---|---|---|
2 | fdf9b3e8 | bellard | * SH4 emulation
|
3 | 5fafdf24 | ths | *
|
4 | fdf9b3e8 | bellard | * Copyright (c) 2005 Samuel Tardieu
|
5 | fdf9b3e8 | bellard | *
|
6 | fdf9b3e8 | bellard | * This library is free software; you can redistribute it and/or
|
7 | fdf9b3e8 | bellard | * modify it under the terms of the GNU Lesser General Public
|
8 | fdf9b3e8 | bellard | * License as published by the Free Software Foundation; either
|
9 | fdf9b3e8 | bellard | * version 2 of the License, or (at your option) any later version.
|
10 | fdf9b3e8 | bellard | *
|
11 | fdf9b3e8 | bellard | * This library is distributed in the hope that it will be useful,
|
12 | fdf9b3e8 | bellard | * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
13 | fdf9b3e8 | bellard | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
14 | fdf9b3e8 | bellard | * Lesser General Public License for more details.
|
15 | fdf9b3e8 | bellard | *
|
16 | fdf9b3e8 | bellard | * You should have received a copy of the GNU Lesser General Public
|
17 | 8167ee88 | Blue Swirl | * License along with this library; if not, see <http://www.gnu.org/licenses/>.
|
18 | fdf9b3e8 | bellard | */
|
19 | fdf9b3e8 | bellard | #include <stdarg.h> |
20 | fdf9b3e8 | bellard | #include <stdlib.h> |
21 | fdf9b3e8 | bellard | #include <stdio.h> |
22 | fdf9b3e8 | bellard | #include <string.h> |
23 | fdf9b3e8 | bellard | #include <inttypes.h> |
24 | fdf9b3e8 | bellard | #include <signal.h> |
25 | fdf9b3e8 | bellard | |
26 | fdf9b3e8 | bellard | #include "cpu.h" |
27 | fdf9b3e8 | bellard | #include "exec-all.h" |
28 | e96e2044 | ths | #include "hw/sh_intc.h" |
29 | fdf9b3e8 | bellard | |
30 | 355fb23d | pbrook | #if defined(CONFIG_USER_ONLY)
|
31 | 355fb23d | pbrook | |
32 | 355fb23d | pbrook | void do_interrupt (CPUState *env)
|
33 | 355fb23d | pbrook | { |
34 | 355fb23d | pbrook | env->exception_index = -1;
|
35 | 355fb23d | pbrook | } |
36 | 355fb23d | pbrook | |
37 | 355fb23d | pbrook | int cpu_sh4_handle_mmu_fault(CPUState * env, target_ulong address, int rw, |
38 | 6ebbf390 | j_mayer | int mmu_idx, int is_softmmu) |
39 | 355fb23d | pbrook | { |
40 | 355fb23d | pbrook | env->tea = address; |
41 | c3b5bc8a | ths | env->exception_index = 0;
|
42 | 355fb23d | pbrook | switch (rw) {
|
43 | 355fb23d | pbrook | case 0: |
44 | 355fb23d | pbrook | env->exception_index = 0x0a0;
|
45 | 355fb23d | pbrook | break;
|
46 | 355fb23d | pbrook | case 1: |
47 | 355fb23d | pbrook | env->exception_index = 0x0c0;
|
48 | 355fb23d | pbrook | break;
|
49 | cf7055bd | aurel32 | case 2: |
50 | cf7055bd | aurel32 | env->exception_index = 0x0a0;
|
51 | cf7055bd | aurel32 | break;
|
52 | 355fb23d | pbrook | } |
53 | 355fb23d | pbrook | return 1; |
54 | 355fb23d | pbrook | } |
55 | 355fb23d | pbrook | |
56 | 9b3c35e0 | j_mayer | target_phys_addr_t cpu_get_phys_page_debug(CPUState * env, target_ulong addr) |
57 | 355fb23d | pbrook | { |
58 | 355fb23d | pbrook | return addr;
|
59 | 355fb23d | pbrook | } |
60 | 355fb23d | pbrook | |
61 | 3c1adf12 | edgar_igl | int cpu_sh4_is_cached(CPUSH4State * env, target_ulong addr)
|
62 | 3c1adf12 | edgar_igl | { |
63 | 3c1adf12 | edgar_igl | /* For user mode, only U0 area is cachable. */
|
64 | 679dee3c | edgar_igl | return !(addr & 0x80000000); |
65 | 3c1adf12 | edgar_igl | } |
66 | 3c1adf12 | edgar_igl | |
67 | 355fb23d | pbrook | #else /* !CONFIG_USER_ONLY */ |
68 | 355fb23d | pbrook | |
69 | fdf9b3e8 | bellard | #define MMU_OK 0 |
70 | fdf9b3e8 | bellard | #define MMU_ITLB_MISS (-1) |
71 | fdf9b3e8 | bellard | #define MMU_ITLB_MULTIPLE (-2) |
72 | fdf9b3e8 | bellard | #define MMU_ITLB_VIOLATION (-3) |
73 | fdf9b3e8 | bellard | #define MMU_DTLB_MISS_READ (-4) |
74 | fdf9b3e8 | bellard | #define MMU_DTLB_MISS_WRITE (-5) |
75 | fdf9b3e8 | bellard | #define MMU_DTLB_INITIAL_WRITE (-6) |
76 | fdf9b3e8 | bellard | #define MMU_DTLB_VIOLATION_READ (-7) |
77 | fdf9b3e8 | bellard | #define MMU_DTLB_VIOLATION_WRITE (-8) |
78 | fdf9b3e8 | bellard | #define MMU_DTLB_MULTIPLE (-9) |
79 | fdf9b3e8 | bellard | #define MMU_DTLB_MISS (-10) |
80 | cf7055bd | aurel32 | #define MMU_IADDR_ERROR (-11) |
81 | cf7055bd | aurel32 | #define MMU_DADDR_ERROR_READ (-12) |
82 | cf7055bd | aurel32 | #define MMU_DADDR_ERROR_WRITE (-13) |
83 | fdf9b3e8 | bellard | |
84 | fdf9b3e8 | bellard | void do_interrupt(CPUState * env)
|
85 | fdf9b3e8 | bellard | { |
86 | e96e2044 | ths | int do_irq = env->interrupt_request & CPU_INTERRUPT_HARD;
|
87 | e96e2044 | ths | int do_exp, irq_vector = env->exception_index;
|
88 | e96e2044 | ths | |
89 | e96e2044 | ths | /* prioritize exceptions over interrupts */
|
90 | e96e2044 | ths | |
91 | e96e2044 | ths | do_exp = env->exception_index != -1;
|
92 | e96e2044 | ths | do_irq = do_irq && (env->exception_index == -1);
|
93 | e96e2044 | ths | |
94 | e96e2044 | ths | if (env->sr & SR_BL) {
|
95 | e96e2044 | ths | if (do_exp && env->exception_index != 0x1e0) { |
96 | e96e2044 | ths | env->exception_index = 0x000; /* masked exception -> reset */ |
97 | e96e2044 | ths | } |
98 | 833ed386 | aurel32 | if (do_irq && !env->intr_at_halt) {
|
99 | e96e2044 | ths | return; /* masked */ |
100 | e96e2044 | ths | } |
101 | 833ed386 | aurel32 | env->intr_at_halt = 0;
|
102 | e96e2044 | ths | } |
103 | e96e2044 | ths | |
104 | e96e2044 | ths | if (do_irq) {
|
105 | e96e2044 | ths | irq_vector = sh_intc_get_pending_vector(env->intc_handle, |
106 | e96e2044 | ths | (env->sr >> 4) & 0xf); |
107 | e96e2044 | ths | if (irq_vector == -1) { |
108 | e96e2044 | ths | return; /* masked */ |
109 | e96e2044 | ths | } |
110 | e96e2044 | ths | } |
111 | e96e2044 | ths | |
112 | 8fec2b8c | aliguori | if (qemu_loglevel_mask(CPU_LOG_INT)) {
|
113 | fdf9b3e8 | bellard | const char *expname; |
114 | fdf9b3e8 | bellard | switch (env->exception_index) {
|
115 | fdf9b3e8 | bellard | case 0x0e0: |
116 | fdf9b3e8 | bellard | expname = "addr_error";
|
117 | fdf9b3e8 | bellard | break;
|
118 | fdf9b3e8 | bellard | case 0x040: |
119 | fdf9b3e8 | bellard | expname = "tlb_miss";
|
120 | fdf9b3e8 | bellard | break;
|
121 | fdf9b3e8 | bellard | case 0x0a0: |
122 | fdf9b3e8 | bellard | expname = "tlb_violation";
|
123 | fdf9b3e8 | bellard | break;
|
124 | fdf9b3e8 | bellard | case 0x180: |
125 | fdf9b3e8 | bellard | expname = "illegal_instruction";
|
126 | fdf9b3e8 | bellard | break;
|
127 | fdf9b3e8 | bellard | case 0x1a0: |
128 | fdf9b3e8 | bellard | expname = "slot_illegal_instruction";
|
129 | fdf9b3e8 | bellard | break;
|
130 | fdf9b3e8 | bellard | case 0x800: |
131 | fdf9b3e8 | bellard | expname = "fpu_disable";
|
132 | fdf9b3e8 | bellard | break;
|
133 | fdf9b3e8 | bellard | case 0x820: |
134 | fdf9b3e8 | bellard | expname = "slot_fpu";
|
135 | fdf9b3e8 | bellard | break;
|
136 | fdf9b3e8 | bellard | case 0x100: |
137 | fdf9b3e8 | bellard | expname = "data_write";
|
138 | fdf9b3e8 | bellard | break;
|
139 | fdf9b3e8 | bellard | case 0x060: |
140 | fdf9b3e8 | bellard | expname = "dtlb_miss_write";
|
141 | fdf9b3e8 | bellard | break;
|
142 | fdf9b3e8 | bellard | case 0x0c0: |
143 | fdf9b3e8 | bellard | expname = "dtlb_violation_write";
|
144 | fdf9b3e8 | bellard | break;
|
145 | fdf9b3e8 | bellard | case 0x120: |
146 | fdf9b3e8 | bellard | expname = "fpu_exception";
|
147 | fdf9b3e8 | bellard | break;
|
148 | fdf9b3e8 | bellard | case 0x080: |
149 | fdf9b3e8 | bellard | expname = "initial_page_write";
|
150 | fdf9b3e8 | bellard | break;
|
151 | fdf9b3e8 | bellard | case 0x160: |
152 | fdf9b3e8 | bellard | expname = "trapa";
|
153 | fdf9b3e8 | bellard | break;
|
154 | fdf9b3e8 | bellard | default:
|
155 | e96e2044 | ths | expname = do_irq ? "interrupt" : "???"; |
156 | e96e2044 | ths | break;
|
157 | fdf9b3e8 | bellard | } |
158 | 93fcfe39 | aliguori | qemu_log("exception 0x%03x [%s] raised\n",
|
159 | 93fcfe39 | aliguori | irq_vector, expname); |
160 | 93fcfe39 | aliguori | log_cpu_state(env, 0);
|
161 | fdf9b3e8 | bellard | } |
162 | fdf9b3e8 | bellard | |
163 | fdf9b3e8 | bellard | env->ssr = env->sr; |
164 | e96e2044 | ths | env->spc = env->pc; |
165 | fdf9b3e8 | bellard | env->sgr = env->gregs[15];
|
166 | fdf9b3e8 | bellard | env->sr |= SR_BL | SR_MD | SR_RB; |
167 | fdf9b3e8 | bellard | |
168 | 274a9e70 | aurel32 | if (env->flags & (DELAY_SLOT | DELAY_SLOT_CONDITIONAL)) {
|
169 | 274a9e70 | aurel32 | /* Branch instruction should be executed again before delay slot. */
|
170 | 274a9e70 | aurel32 | env->spc -= 2;
|
171 | 274a9e70 | aurel32 | /* Clear flags for exception/interrupt routine. */
|
172 | 274a9e70 | aurel32 | env->flags &= ~(DELAY_SLOT | DELAY_SLOT_CONDITIONAL | DELAY_SLOT_TRUE); |
173 | 274a9e70 | aurel32 | } |
174 | 274a9e70 | aurel32 | if (env->flags & DELAY_SLOT_CLEARME)
|
175 | 274a9e70 | aurel32 | env->flags = 0;
|
176 | 274a9e70 | aurel32 | |
177 | e96e2044 | ths | if (do_exp) {
|
178 | e96e2044 | ths | env->expevt = env->exception_index; |
179 | e96e2044 | ths | switch (env->exception_index) {
|
180 | e96e2044 | ths | case 0x000: |
181 | e96e2044 | ths | case 0x020: |
182 | e96e2044 | ths | case 0x140: |
183 | e96e2044 | ths | env->sr &= ~SR_FD; |
184 | e96e2044 | ths | env->sr |= 0xf << 4; /* IMASK */ |
185 | e96e2044 | ths | env->pc = 0xa0000000;
|
186 | e96e2044 | ths | break;
|
187 | e96e2044 | ths | case 0x040: |
188 | e96e2044 | ths | case 0x060: |
189 | e96e2044 | ths | env->pc = env->vbr + 0x400;
|
190 | e96e2044 | ths | break;
|
191 | e96e2044 | ths | case 0x160: |
192 | e96e2044 | ths | env->spc += 2; /* special case for TRAPA */ |
193 | e96e2044 | ths | /* fall through */
|
194 | e96e2044 | ths | default:
|
195 | e96e2044 | ths | env->pc = env->vbr + 0x100;
|
196 | e96e2044 | ths | break;
|
197 | e96e2044 | ths | } |
198 | e96e2044 | ths | return;
|
199 | e96e2044 | ths | } |
200 | e96e2044 | ths | |
201 | e96e2044 | ths | if (do_irq) {
|
202 | e96e2044 | ths | env->intevt = irq_vector; |
203 | e96e2044 | ths | env->pc = env->vbr + 0x600;
|
204 | e96e2044 | ths | return;
|
205 | fdf9b3e8 | bellard | } |
206 | fdf9b3e8 | bellard | } |
207 | fdf9b3e8 | bellard | |
208 | fdf9b3e8 | bellard | static void update_itlb_use(CPUState * env, int itlbnb) |
209 | fdf9b3e8 | bellard | { |
210 | fdf9b3e8 | bellard | uint8_t or_mask = 0, and_mask = (uint8_t) - 1; |
211 | fdf9b3e8 | bellard | |
212 | fdf9b3e8 | bellard | switch (itlbnb) {
|
213 | fdf9b3e8 | bellard | case 0: |
214 | ea2b542a | aurel32 | and_mask = 0x1f;
|
215 | fdf9b3e8 | bellard | break;
|
216 | fdf9b3e8 | bellard | case 1: |
217 | fdf9b3e8 | bellard | and_mask = 0xe7;
|
218 | fdf9b3e8 | bellard | or_mask = 0x80;
|
219 | fdf9b3e8 | bellard | break;
|
220 | fdf9b3e8 | bellard | case 2: |
221 | fdf9b3e8 | bellard | and_mask = 0xfb;
|
222 | fdf9b3e8 | bellard | or_mask = 0x50;
|
223 | fdf9b3e8 | bellard | break;
|
224 | fdf9b3e8 | bellard | case 3: |
225 | fdf9b3e8 | bellard | or_mask = 0x2c;
|
226 | fdf9b3e8 | bellard | break;
|
227 | fdf9b3e8 | bellard | } |
228 | fdf9b3e8 | bellard | |
229 | ea2b542a | aurel32 | env->mmucr &= (and_mask << 24) | 0x00ffffff; |
230 | fdf9b3e8 | bellard | env->mmucr |= (or_mask << 24);
|
231 | fdf9b3e8 | bellard | } |
232 | fdf9b3e8 | bellard | |
233 | fdf9b3e8 | bellard | static int itlb_replacement(CPUState * env) |
234 | fdf9b3e8 | bellard | { |
235 | fdf9b3e8 | bellard | if ((env->mmucr & 0xe0000000) == 0xe0000000) |
236 | fdf9b3e8 | bellard | return 0; |
237 | ea2b542a | aurel32 | if ((env->mmucr & 0x98000000) == 0x18000000) |
238 | fdf9b3e8 | bellard | return 1; |
239 | fdf9b3e8 | bellard | if ((env->mmucr & 0x54000000) == 0x04000000) |
240 | fdf9b3e8 | bellard | return 2; |
241 | fdf9b3e8 | bellard | if ((env->mmucr & 0x2c000000) == 0x00000000) |
242 | fdf9b3e8 | bellard | return 3; |
243 | fdf9b3e8 | bellard | assert(0);
|
244 | fdf9b3e8 | bellard | } |
245 | fdf9b3e8 | bellard | |
246 | fdf9b3e8 | bellard | /* Find the corresponding entry in the right TLB
|
247 | fdf9b3e8 | bellard | Return entry, MMU_DTLB_MISS or MMU_DTLB_MULTIPLE
|
248 | fdf9b3e8 | bellard | */
|
249 | fdf9b3e8 | bellard | static int find_tlb_entry(CPUState * env, target_ulong address, |
250 | fdf9b3e8 | bellard | tlb_t * entries, uint8_t nbtlb, int use_asid)
|
251 | fdf9b3e8 | bellard | { |
252 | fdf9b3e8 | bellard | int match = MMU_DTLB_MISS;
|
253 | fdf9b3e8 | bellard | uint32_t start, end; |
254 | fdf9b3e8 | bellard | uint8_t asid; |
255 | fdf9b3e8 | bellard | int i;
|
256 | fdf9b3e8 | bellard | |
257 | fdf9b3e8 | bellard | asid = env->pteh & 0xff;
|
258 | fdf9b3e8 | bellard | |
259 | fdf9b3e8 | bellard | for (i = 0; i < nbtlb; i++) { |
260 | fdf9b3e8 | bellard | if (!entries[i].v)
|
261 | fdf9b3e8 | bellard | continue; /* Invalid entry */ |
262 | eeda6778 | aurel32 | if (!entries[i].sh && use_asid && entries[i].asid != asid)
|
263 | fdf9b3e8 | bellard | continue; /* Bad ASID */ |
264 | fdf9b3e8 | bellard | #if 0
|
265 | fdf9b3e8 | bellard | switch (entries[i].sz) {
|
266 | fdf9b3e8 | bellard | case 0:
|
267 | fdf9b3e8 | bellard | size = 1024; /* 1kB */
|
268 | fdf9b3e8 | bellard | break;
|
269 | fdf9b3e8 | bellard | case 1:
|
270 | fdf9b3e8 | bellard | size = 4 * 1024; /* 4kB */
|
271 | fdf9b3e8 | bellard | break;
|
272 | fdf9b3e8 | bellard | case 2:
|
273 | fdf9b3e8 | bellard | size = 64 * 1024; /* 64kB */
|
274 | fdf9b3e8 | bellard | break;
|
275 | fdf9b3e8 | bellard | case 3:
|
276 | fdf9b3e8 | bellard | size = 1024 * 1024; /* 1MB */
|
277 | fdf9b3e8 | bellard | break;
|
278 | fdf9b3e8 | bellard | default:
|
279 | fdf9b3e8 | bellard | assert(0);
|
280 | fdf9b3e8 | bellard | }
|
281 | fdf9b3e8 | bellard | #endif
|
282 | fdf9b3e8 | bellard | start = (entries[i].vpn << 10) & ~(entries[i].size - 1); |
283 | fdf9b3e8 | bellard | end = start + entries[i].size - 1;
|
284 | fdf9b3e8 | bellard | if (address >= start && address <= end) { /* Match */ |
285 | ea2b542a | aurel32 | if (match != MMU_DTLB_MISS)
|
286 | fdf9b3e8 | bellard | return MMU_DTLB_MULTIPLE; /* Multiple match */ |
287 | fdf9b3e8 | bellard | match = i; |
288 | fdf9b3e8 | bellard | } |
289 | fdf9b3e8 | bellard | } |
290 | fdf9b3e8 | bellard | return match;
|
291 | fdf9b3e8 | bellard | } |
292 | fdf9b3e8 | bellard | |
293 | 29e179bc | aurel32 | static int same_tlb_entry_exists(const tlb_t * haystack, uint8_t nbtlb, |
294 | 29e179bc | aurel32 | const tlb_t * needle)
|
295 | 29e179bc | aurel32 | { |
296 | 29e179bc | aurel32 | int i;
|
297 | 29e179bc | aurel32 | for (i = 0; i < nbtlb; i++) |
298 | 29e179bc | aurel32 | if (!memcmp(&haystack[i], needle, sizeof(tlb_t))) |
299 | 29e179bc | aurel32 | return 1; |
300 | 29e179bc | aurel32 | return 0; |
301 | 29e179bc | aurel32 | } |
302 | 29e179bc | aurel32 | |
303 | 29e179bc | aurel32 | static void increment_urc(CPUState * env) |
304 | 29e179bc | aurel32 | { |
305 | 29e179bc | aurel32 | uint8_t urb, urc; |
306 | 29e179bc | aurel32 | |
307 | 29e179bc | aurel32 | /* Increment URC */
|
308 | 29e179bc | aurel32 | urb = ((env->mmucr) >> 18) & 0x3f; |
309 | 29e179bc | aurel32 | urc = ((env->mmucr) >> 10) & 0x3f; |
310 | 29e179bc | aurel32 | urc++; |
311 | 927e3a4e | aurel32 | if ((urb > 0 && urc > urb) || urc > (UTLB_SIZE - 1)) |
312 | 29e179bc | aurel32 | urc = 0;
|
313 | 29e179bc | aurel32 | env->mmucr = (env->mmucr & 0xffff03ff) | (urc << 10); |
314 | 29e179bc | aurel32 | } |
315 | 29e179bc | aurel32 | |
316 | fdf9b3e8 | bellard | /* Find itlb entry - update itlb from utlb if necessary and asked for
|
317 | fdf9b3e8 | bellard | Return entry, MMU_ITLB_MISS, MMU_ITLB_MULTIPLE or MMU_DTLB_MULTIPLE
|
318 | fdf9b3e8 | bellard | Update the itlb from utlb if update is not 0
|
319 | fdf9b3e8 | bellard | */
|
320 | ef7ec1c1 | aurel32 | static int find_itlb_entry(CPUState * env, target_ulong address, |
321 | ef7ec1c1 | aurel32 | int use_asid, int update) |
322 | fdf9b3e8 | bellard | { |
323 | fdf9b3e8 | bellard | int e, n;
|
324 | fdf9b3e8 | bellard | |
325 | fdf9b3e8 | bellard | e = find_tlb_entry(env, address, env->itlb, ITLB_SIZE, use_asid); |
326 | fdf9b3e8 | bellard | if (e == MMU_DTLB_MULTIPLE)
|
327 | fdf9b3e8 | bellard | e = MMU_ITLB_MULTIPLE; |
328 | fdf9b3e8 | bellard | else if (e == MMU_DTLB_MISS && update) { |
329 | fdf9b3e8 | bellard | e = find_tlb_entry(env, address, env->utlb, UTLB_SIZE, use_asid); |
330 | fdf9b3e8 | bellard | if (e >= 0) { |
331 | 06afe2c8 | aurel32 | tlb_t * ientry; |
332 | fdf9b3e8 | bellard | n = itlb_replacement(env); |
333 | 06afe2c8 | aurel32 | ientry = &env->itlb[n]; |
334 | 06afe2c8 | aurel32 | if (ientry->v) {
|
335 | 06afe2c8 | aurel32 | if (!same_tlb_entry_exists(env->utlb, UTLB_SIZE, ientry))
|
336 | 06afe2c8 | aurel32 | tlb_flush_page(env, ientry->vpn << 10);
|
337 | 06afe2c8 | aurel32 | } |
338 | 06afe2c8 | aurel32 | *ientry = env->utlb[e]; |
339 | fdf9b3e8 | bellard | e = n; |
340 | ea2b542a | aurel32 | } else if (e == MMU_DTLB_MISS) |
341 | ea2b542a | aurel32 | e = MMU_ITLB_MISS; |
342 | ea2b542a | aurel32 | } else if (e == MMU_DTLB_MISS) |
343 | ea2b542a | aurel32 | e = MMU_ITLB_MISS; |
344 | fdf9b3e8 | bellard | if (e >= 0) |
345 | fdf9b3e8 | bellard | update_itlb_use(env, e); |
346 | fdf9b3e8 | bellard | return e;
|
347 | fdf9b3e8 | bellard | } |
348 | fdf9b3e8 | bellard | |
349 | fdf9b3e8 | bellard | /* Find utlb entry
|
350 | fdf9b3e8 | bellard | Return entry, MMU_DTLB_MISS, MMU_DTLB_MULTIPLE */
|
351 | ef7ec1c1 | aurel32 | static int find_utlb_entry(CPUState * env, target_ulong address, int use_asid) |
352 | fdf9b3e8 | bellard | { |
353 | 29e179bc | aurel32 | /* per utlb access */
|
354 | 29e179bc | aurel32 | increment_urc(env); |
355 | fdf9b3e8 | bellard | |
356 | fdf9b3e8 | bellard | /* Return entry */
|
357 | fdf9b3e8 | bellard | return find_tlb_entry(env, address, env->utlb, UTLB_SIZE, use_asid);
|
358 | fdf9b3e8 | bellard | } |
359 | fdf9b3e8 | bellard | |
360 | fdf9b3e8 | bellard | /* Match address against MMU
|
361 | fdf9b3e8 | bellard | Return MMU_OK, MMU_DTLB_MISS_READ, MMU_DTLB_MISS_WRITE,
|
362 | fdf9b3e8 | bellard | MMU_DTLB_INITIAL_WRITE, MMU_DTLB_VIOLATION_READ,
|
363 | fdf9b3e8 | bellard | MMU_DTLB_VIOLATION_WRITE, MMU_ITLB_MISS,
|
364 | cf7055bd | aurel32 | MMU_ITLB_MULTIPLE, MMU_ITLB_VIOLATION,
|
365 | cf7055bd | aurel32 | MMU_IADDR_ERROR, MMU_DADDR_ERROR_READ, MMU_DADDR_ERROR_WRITE.
|
366 | fdf9b3e8 | bellard | */
|
367 | fdf9b3e8 | bellard | static int get_mmu_address(CPUState * env, target_ulong * physical, |
368 | fdf9b3e8 | bellard | int *prot, target_ulong address,
|
369 | fdf9b3e8 | bellard | int rw, int access_type) |
370 | fdf9b3e8 | bellard | { |
371 | cf7055bd | aurel32 | int use_asid, n;
|
372 | fdf9b3e8 | bellard | tlb_t *matching = NULL;
|
373 | fdf9b3e8 | bellard | |
374 | 06afe2c8 | aurel32 | use_asid = (env->mmucr & MMUCR_SV) == 0 || (env->sr & SR_MD) == 0; |
375 | fdf9b3e8 | bellard | |
376 | cf7055bd | aurel32 | if (rw == 2) { |
377 | fdf9b3e8 | bellard | n = find_itlb_entry(env, address, use_asid, 1);
|
378 | fdf9b3e8 | bellard | if (n >= 0) { |
379 | fdf9b3e8 | bellard | matching = &env->itlb[n]; |
380 | fdf9b3e8 | bellard | if ((env->sr & SR_MD) & !(matching->pr & 2)) |
381 | fdf9b3e8 | bellard | n = MMU_ITLB_VIOLATION; |
382 | fdf9b3e8 | bellard | else
|
383 | fdf9b3e8 | bellard | *prot = PAGE_READ; |
384 | fdf9b3e8 | bellard | } |
385 | fdf9b3e8 | bellard | } else {
|
386 | fdf9b3e8 | bellard | n = find_utlb_entry(env, address, use_asid); |
387 | fdf9b3e8 | bellard | if (n >= 0) { |
388 | fdf9b3e8 | bellard | matching = &env->utlb[n]; |
389 | fdf9b3e8 | bellard | switch ((matching->pr << 1) | ((env->sr & SR_MD) ? 1 : 0)) { |
390 | fdf9b3e8 | bellard | case 0: /* 000 */ |
391 | fdf9b3e8 | bellard | case 2: /* 010 */ |
392 | cf7055bd | aurel32 | n = (rw == 1) ? MMU_DTLB_VIOLATION_WRITE :
|
393 | fdf9b3e8 | bellard | MMU_DTLB_VIOLATION_READ; |
394 | fdf9b3e8 | bellard | break;
|
395 | fdf9b3e8 | bellard | case 1: /* 001 */ |
396 | fdf9b3e8 | bellard | case 4: /* 100 */ |
397 | fdf9b3e8 | bellard | case 5: /* 101 */ |
398 | cf7055bd | aurel32 | if (rw == 1) |
399 | fdf9b3e8 | bellard | n = MMU_DTLB_VIOLATION_WRITE; |
400 | fdf9b3e8 | bellard | else
|
401 | fdf9b3e8 | bellard | *prot = PAGE_READ; |
402 | fdf9b3e8 | bellard | break;
|
403 | fdf9b3e8 | bellard | case 3: /* 011 */ |
404 | fdf9b3e8 | bellard | case 6: /* 110 */ |
405 | fdf9b3e8 | bellard | case 7: /* 111 */ |
406 | cf7055bd | aurel32 | *prot = (rw == 1)? PAGE_WRITE : PAGE_READ;
|
407 | fdf9b3e8 | bellard | break;
|
408 | fdf9b3e8 | bellard | } |
409 | fdf9b3e8 | bellard | } else if (n == MMU_DTLB_MISS) { |
410 | cf7055bd | aurel32 | n = (rw == 1) ? MMU_DTLB_MISS_WRITE :
|
411 | fdf9b3e8 | bellard | MMU_DTLB_MISS_READ; |
412 | fdf9b3e8 | bellard | } |
413 | fdf9b3e8 | bellard | } |
414 | fdf9b3e8 | bellard | if (n >= 0) { |
415 | fdf9b3e8 | bellard | *physical = ((matching->ppn << 10) & ~(matching->size - 1)) | |
416 | fdf9b3e8 | bellard | (address & (matching->size - 1));
|
417 | cf7055bd | aurel32 | if ((rw == 1) & !matching->d) |
418 | fdf9b3e8 | bellard | n = MMU_DTLB_INITIAL_WRITE; |
419 | fdf9b3e8 | bellard | else
|
420 | fdf9b3e8 | bellard | n = MMU_OK; |
421 | fdf9b3e8 | bellard | } |
422 | fdf9b3e8 | bellard | return n;
|
423 | fdf9b3e8 | bellard | } |
424 | fdf9b3e8 | bellard | |
425 | ef7ec1c1 | aurel32 | static int get_physical_address(CPUState * env, target_ulong * physical, |
426 | ef7ec1c1 | aurel32 | int *prot, target_ulong address,
|
427 | ef7ec1c1 | aurel32 | int rw, int access_type) |
428 | fdf9b3e8 | bellard | { |
429 | fdf9b3e8 | bellard | /* P1, P2 and P4 areas do not use translation */
|
430 | fdf9b3e8 | bellard | if ((address >= 0x80000000 && address < 0xc0000000) || |
431 | fdf9b3e8 | bellard | address >= 0xe0000000) {
|
432 | fdf9b3e8 | bellard | if (!(env->sr & SR_MD)
|
433 | fdf9b3e8 | bellard | && (address < 0xe0000000 || address > 0xe4000000)) { |
434 | fdf9b3e8 | bellard | /* Unauthorized access in user mode (only store queues are available) */
|
435 | fdf9b3e8 | bellard | fprintf(stderr, "Unauthorized access\n");
|
436 | cf7055bd | aurel32 | if (rw == 0) |
437 | cf7055bd | aurel32 | return MMU_DADDR_ERROR_READ;
|
438 | cf7055bd | aurel32 | else if (rw == 1) |
439 | cf7055bd | aurel32 | return MMU_DADDR_ERROR_WRITE;
|
440 | cf7055bd | aurel32 | else
|
441 | cf7055bd | aurel32 | return MMU_IADDR_ERROR;
|
442 | fdf9b3e8 | bellard | } |
443 | 29e179bc | aurel32 | if (address >= 0x80000000 && address < 0xc0000000) { |
444 | 29e179bc | aurel32 | /* Mask upper 3 bits for P1 and P2 areas */
|
445 | 29e179bc | aurel32 | *physical = address & 0x1fffffff;
|
446 | 29e179bc | aurel32 | } else {
|
447 | 29e179bc | aurel32 | *physical = address; |
448 | 29e179bc | aurel32 | } |
449 | fdf9b3e8 | bellard | *prot = PAGE_READ | PAGE_WRITE; |
450 | fdf9b3e8 | bellard | return MMU_OK;
|
451 | fdf9b3e8 | bellard | } |
452 | fdf9b3e8 | bellard | |
453 | fdf9b3e8 | bellard | /* If MMU is disabled, return the corresponding physical page */
|
454 | fdf9b3e8 | bellard | if (!env->mmucr & MMUCR_AT) {
|
455 | fdf9b3e8 | bellard | *physical = address & 0x1FFFFFFF;
|
456 | fdf9b3e8 | bellard | *prot = PAGE_READ | PAGE_WRITE; |
457 | fdf9b3e8 | bellard | return MMU_OK;
|
458 | fdf9b3e8 | bellard | } |
459 | fdf9b3e8 | bellard | |
460 | fdf9b3e8 | bellard | /* We need to resort to the MMU */
|
461 | fdf9b3e8 | bellard | return get_mmu_address(env, physical, prot, address, rw, access_type);
|
462 | fdf9b3e8 | bellard | } |
463 | fdf9b3e8 | bellard | |
464 | fdf9b3e8 | bellard | int cpu_sh4_handle_mmu_fault(CPUState * env, target_ulong address, int rw, |
465 | 6ebbf390 | j_mayer | int mmu_idx, int is_softmmu) |
466 | fdf9b3e8 | bellard | { |
467 | fdf9b3e8 | bellard | target_ulong physical, page_offset, page_size; |
468 | fdf9b3e8 | bellard | int prot, ret, access_type;
|
469 | fdf9b3e8 | bellard | |
470 | fdf9b3e8 | bellard | access_type = ACCESS_INT; |
471 | fdf9b3e8 | bellard | ret = |
472 | fdf9b3e8 | bellard | get_physical_address(env, &physical, &prot, address, rw, |
473 | fdf9b3e8 | bellard | access_type); |
474 | fdf9b3e8 | bellard | |
475 | fdf9b3e8 | bellard | if (ret != MMU_OK) {
|
476 | fdf9b3e8 | bellard | env->tea = address; |
477 | fdf9b3e8 | bellard | switch (ret) {
|
478 | fdf9b3e8 | bellard | case MMU_ITLB_MISS:
|
479 | fdf9b3e8 | bellard | case MMU_DTLB_MISS_READ:
|
480 | fdf9b3e8 | bellard | env->exception_index = 0x040;
|
481 | fdf9b3e8 | bellard | break;
|
482 | fdf9b3e8 | bellard | case MMU_DTLB_MULTIPLE:
|
483 | fdf9b3e8 | bellard | case MMU_ITLB_MULTIPLE:
|
484 | fdf9b3e8 | bellard | env->exception_index = 0x140;
|
485 | fdf9b3e8 | bellard | break;
|
486 | fdf9b3e8 | bellard | case MMU_ITLB_VIOLATION:
|
487 | fdf9b3e8 | bellard | env->exception_index = 0x0a0;
|
488 | fdf9b3e8 | bellard | break;
|
489 | fdf9b3e8 | bellard | case MMU_DTLB_MISS_WRITE:
|
490 | fdf9b3e8 | bellard | env->exception_index = 0x060;
|
491 | fdf9b3e8 | bellard | break;
|
492 | fdf9b3e8 | bellard | case MMU_DTLB_INITIAL_WRITE:
|
493 | fdf9b3e8 | bellard | env->exception_index = 0x080;
|
494 | fdf9b3e8 | bellard | break;
|
495 | fdf9b3e8 | bellard | case MMU_DTLB_VIOLATION_READ:
|
496 | fdf9b3e8 | bellard | env->exception_index = 0x0a0;
|
497 | fdf9b3e8 | bellard | break;
|
498 | fdf9b3e8 | bellard | case MMU_DTLB_VIOLATION_WRITE:
|
499 | fdf9b3e8 | bellard | env->exception_index = 0x0c0;
|
500 | fdf9b3e8 | bellard | break;
|
501 | cf7055bd | aurel32 | case MMU_IADDR_ERROR:
|
502 | cf7055bd | aurel32 | case MMU_DADDR_ERROR_READ:
|
503 | cf7055bd | aurel32 | env->exception_index = 0x0c0;
|
504 | cf7055bd | aurel32 | break;
|
505 | cf7055bd | aurel32 | case MMU_DADDR_ERROR_WRITE:
|
506 | cf7055bd | aurel32 | env->exception_index = 0x100;
|
507 | cf7055bd | aurel32 | break;
|
508 | fdf9b3e8 | bellard | default:
|
509 | fdf9b3e8 | bellard | assert(0);
|
510 | fdf9b3e8 | bellard | } |
511 | fdf9b3e8 | bellard | return 1; |
512 | fdf9b3e8 | bellard | } |
513 | fdf9b3e8 | bellard | |
514 | fdf9b3e8 | bellard | page_size = TARGET_PAGE_SIZE; |
515 | fdf9b3e8 | bellard | page_offset = |
516 | fdf9b3e8 | bellard | (address - (address & TARGET_PAGE_MASK)) & ~(page_size - 1);
|
517 | fdf9b3e8 | bellard | address = (address & TARGET_PAGE_MASK) + page_offset; |
518 | fdf9b3e8 | bellard | physical = (physical & TARGET_PAGE_MASK) + page_offset; |
519 | fdf9b3e8 | bellard | |
520 | 6ebbf390 | j_mayer | return tlb_set_page(env, address, physical, prot, mmu_idx, is_softmmu);
|
521 | fdf9b3e8 | bellard | } |
522 | 355fb23d | pbrook | |
523 | 9b3c35e0 | j_mayer | target_phys_addr_t cpu_get_phys_page_debug(CPUState * env, target_ulong addr) |
524 | 355fb23d | pbrook | { |
525 | 355fb23d | pbrook | target_ulong physical; |
526 | 355fb23d | pbrook | int prot;
|
527 | 355fb23d | pbrook | |
528 | cf7055bd | aurel32 | get_physical_address(env, &physical, &prot, addr, 0, 0); |
529 | 355fb23d | pbrook | return physical;
|
530 | 355fb23d | pbrook | } |
531 | 355fb23d | pbrook | |
532 | ef7ec1c1 | aurel32 | void cpu_load_tlb(CPUSH4State * env)
|
533 | ea2b542a | aurel32 | { |
534 | ea2b542a | aurel32 | int n = cpu_mmucr_urc(env->mmucr);
|
535 | ea2b542a | aurel32 | tlb_t * entry = &env->utlb[n]; |
536 | ea2b542a | aurel32 | |
537 | 06afe2c8 | aurel32 | if (entry->v) {
|
538 | 06afe2c8 | aurel32 | /* Overwriting valid entry in utlb. */
|
539 | 06afe2c8 | aurel32 | target_ulong address = entry->vpn << 10;
|
540 | 06afe2c8 | aurel32 | if (!same_tlb_entry_exists(env->itlb, ITLB_SIZE, entry)) {
|
541 | 06afe2c8 | aurel32 | tlb_flush_page(env, address); |
542 | 06afe2c8 | aurel32 | } |
543 | 06afe2c8 | aurel32 | } |
544 | 06afe2c8 | aurel32 | |
545 | ea2b542a | aurel32 | /* Take values into cpu status from registers. */
|
546 | ea2b542a | aurel32 | entry->asid = (uint8_t)cpu_pteh_asid(env->pteh); |
547 | ea2b542a | aurel32 | entry->vpn = cpu_pteh_vpn(env->pteh); |
548 | ea2b542a | aurel32 | entry->v = (uint8_t)cpu_ptel_v(env->ptel); |
549 | ea2b542a | aurel32 | entry->ppn = cpu_ptel_ppn(env->ptel); |
550 | ea2b542a | aurel32 | entry->sz = (uint8_t)cpu_ptel_sz(env->ptel); |
551 | ea2b542a | aurel32 | switch (entry->sz) {
|
552 | ea2b542a | aurel32 | case 0: /* 00 */ |
553 | ea2b542a | aurel32 | entry->size = 1024; /* 1K */ |
554 | ea2b542a | aurel32 | break;
|
555 | ea2b542a | aurel32 | case 1: /* 01 */ |
556 | ea2b542a | aurel32 | entry->size = 1024 * 4; /* 4K */ |
557 | ea2b542a | aurel32 | break;
|
558 | ea2b542a | aurel32 | case 2: /* 10 */ |
559 | ea2b542a | aurel32 | entry->size = 1024 * 64; /* 64K */ |
560 | ea2b542a | aurel32 | break;
|
561 | ea2b542a | aurel32 | case 3: /* 11 */ |
562 | ea2b542a | aurel32 | entry->size = 1024 * 1024; /* 1M */ |
563 | ea2b542a | aurel32 | break;
|
564 | ea2b542a | aurel32 | default:
|
565 | ea2b542a | aurel32 | assert(0);
|
566 | ea2b542a | aurel32 | break;
|
567 | ea2b542a | aurel32 | } |
568 | ea2b542a | aurel32 | entry->sh = (uint8_t)cpu_ptel_sh(env->ptel); |
569 | ea2b542a | aurel32 | entry->c = (uint8_t)cpu_ptel_c(env->ptel); |
570 | ea2b542a | aurel32 | entry->pr = (uint8_t)cpu_ptel_pr(env->ptel); |
571 | ea2b542a | aurel32 | entry->d = (uint8_t)cpu_ptel_d(env->ptel); |
572 | ea2b542a | aurel32 | entry->wt = (uint8_t)cpu_ptel_wt(env->ptel); |
573 | ea2b542a | aurel32 | entry->sa = (uint8_t)cpu_ptea_sa(env->ptea); |
574 | ea2b542a | aurel32 | entry->tc = (uint8_t)cpu_ptea_tc(env->ptea); |
575 | ea2b542a | aurel32 | } |
576 | ea2b542a | aurel32 | |
577 | 29e179bc | aurel32 | void cpu_sh4_write_mmaped_utlb_addr(CPUSH4State *s, target_phys_addr_t addr,
|
578 | 29e179bc | aurel32 | uint32_t mem_value) |
579 | 29e179bc | aurel32 | { |
580 | 29e179bc | aurel32 | int associate = addr & 0x0000080; |
581 | 29e179bc | aurel32 | uint32_t vpn = (mem_value & 0xfffffc00) >> 10; |
582 | 29e179bc | aurel32 | uint8_t d = (uint8_t)((mem_value & 0x00000200) >> 9); |
583 | 29e179bc | aurel32 | uint8_t v = (uint8_t)((mem_value & 0x00000100) >> 8); |
584 | 29e179bc | aurel32 | uint8_t asid = (uint8_t)(mem_value & 0x000000ff);
|
585 | eeda6778 | aurel32 | int use_asid = (s->mmucr & MMUCR_SV) == 0 || (s->sr & SR_MD) == 0; |
586 | 29e179bc | aurel32 | |
587 | 29e179bc | aurel32 | if (associate) {
|
588 | 29e179bc | aurel32 | int i;
|
589 | 29e179bc | aurel32 | tlb_t * utlb_match_entry = NULL;
|
590 | 29e179bc | aurel32 | int needs_tlb_flush = 0; |
591 | 29e179bc | aurel32 | |
592 | 29e179bc | aurel32 | /* search UTLB */
|
593 | 29e179bc | aurel32 | for (i = 0; i < UTLB_SIZE; i++) { |
594 | 29e179bc | aurel32 | tlb_t * entry = &s->utlb[i]; |
595 | 29e179bc | aurel32 | if (!entry->v)
|
596 | 29e179bc | aurel32 | continue;
|
597 | 29e179bc | aurel32 | |
598 | eeda6778 | aurel32 | if (entry->vpn == vpn
|
599 | eeda6778 | aurel32 | && (!use_asid || entry->asid == asid || entry->sh)) { |
600 | 29e179bc | aurel32 | if (utlb_match_entry) {
|
601 | 29e179bc | aurel32 | /* Multiple TLB Exception */
|
602 | 29e179bc | aurel32 | s->exception_index = 0x140;
|
603 | 29e179bc | aurel32 | s->tea = addr; |
604 | 29e179bc | aurel32 | break;
|
605 | 29e179bc | aurel32 | } |
606 | 29e179bc | aurel32 | if (entry->v && !v)
|
607 | 29e179bc | aurel32 | needs_tlb_flush = 1;
|
608 | 29e179bc | aurel32 | entry->v = v; |
609 | 29e179bc | aurel32 | entry->d = d; |
610 | 29e179bc | aurel32 | utlb_match_entry = entry; |
611 | 29e179bc | aurel32 | } |
612 | 29e179bc | aurel32 | increment_urc(s); /* per utlb access */
|
613 | 29e179bc | aurel32 | } |
614 | 29e179bc | aurel32 | |
615 | 29e179bc | aurel32 | /* search ITLB */
|
616 | 29e179bc | aurel32 | for (i = 0; i < ITLB_SIZE; i++) { |
617 | 29e179bc | aurel32 | tlb_t * entry = &s->itlb[i]; |
618 | eeda6778 | aurel32 | if (entry->vpn == vpn
|
619 | eeda6778 | aurel32 | && (!use_asid || entry->asid == asid || entry->sh)) { |
620 | 29e179bc | aurel32 | if (entry->v && !v)
|
621 | 29e179bc | aurel32 | needs_tlb_flush = 1;
|
622 | 29e179bc | aurel32 | if (utlb_match_entry)
|
623 | 29e179bc | aurel32 | *entry = *utlb_match_entry; |
624 | 29e179bc | aurel32 | else
|
625 | 29e179bc | aurel32 | entry->v = v; |
626 | 29e179bc | aurel32 | break;
|
627 | 29e179bc | aurel32 | } |
628 | 29e179bc | aurel32 | } |
629 | 29e179bc | aurel32 | |
630 | 29e179bc | aurel32 | if (needs_tlb_flush)
|
631 | 29e179bc | aurel32 | tlb_flush_page(s, vpn << 10);
|
632 | 29e179bc | aurel32 | |
633 | 29e179bc | aurel32 | } else {
|
634 | 29e179bc | aurel32 | int index = (addr & 0x00003f00) >> 8; |
635 | 29e179bc | aurel32 | tlb_t * entry = &s->utlb[index]; |
636 | 29e179bc | aurel32 | if (entry->v) {
|
637 | 29e179bc | aurel32 | /* Overwriting valid entry in utlb. */
|
638 | 29e179bc | aurel32 | target_ulong address = entry->vpn << 10;
|
639 | 29e179bc | aurel32 | if (!same_tlb_entry_exists(s->itlb, ITLB_SIZE, entry)) {
|
640 | 29e179bc | aurel32 | tlb_flush_page(s, address); |
641 | 29e179bc | aurel32 | } |
642 | 29e179bc | aurel32 | } |
643 | 29e179bc | aurel32 | entry->asid = asid; |
644 | 29e179bc | aurel32 | entry->vpn = vpn; |
645 | 29e179bc | aurel32 | entry->d = d; |
646 | 29e179bc | aurel32 | entry->v = v; |
647 | 29e179bc | aurel32 | increment_urc(s); |
648 | 29e179bc | aurel32 | } |
649 | 29e179bc | aurel32 | } |
650 | 29e179bc | aurel32 | |
651 | 852d481f | edgar_igl | int cpu_sh4_is_cached(CPUSH4State * env, target_ulong addr)
|
652 | 852d481f | edgar_igl | { |
653 | 852d481f | edgar_igl | int n;
|
654 | 852d481f | edgar_igl | int use_asid = (env->mmucr & MMUCR_SV) == 0 || (env->sr & SR_MD) == 0; |
655 | 852d481f | edgar_igl | |
656 | 852d481f | edgar_igl | /* check area */
|
657 | 852d481f | edgar_igl | if (env->sr & SR_MD) {
|
658 | 852d481f | edgar_igl | /* For previledged mode, P2 and P4 area is not cachable. */
|
659 | 852d481f | edgar_igl | if ((0xA0000000 <= addr && addr < 0xC0000000) || 0xE0000000 <= addr) |
660 | 852d481f | edgar_igl | return 0; |
661 | 852d481f | edgar_igl | } else {
|
662 | 852d481f | edgar_igl | /* For user mode, only U0 area is cachable. */
|
663 | 852d481f | edgar_igl | if (0x80000000 <= addr) |
664 | 852d481f | edgar_igl | return 0; |
665 | 852d481f | edgar_igl | } |
666 | 852d481f | edgar_igl | |
667 | 852d481f | edgar_igl | /*
|
668 | 852d481f | edgar_igl | * TODO : Evaluate CCR and check if the cache is on or off.
|
669 | 852d481f | edgar_igl | * Now CCR is not in CPUSH4State, but in SH7750State.
|
670 | 852d481f | edgar_igl | * When you move the ccr inot CPUSH4State, the code will be
|
671 | 852d481f | edgar_igl | * as follows.
|
672 | 852d481f | edgar_igl | */
|
673 | 852d481f | edgar_igl | #if 0
|
674 | 852d481f | edgar_igl | /* check if operand cache is enabled or not. */
|
675 | 852d481f | edgar_igl | if (!(env->ccr & 1))
|
676 | 852d481f | edgar_igl | return 0;
|
677 | 852d481f | edgar_igl | #endif
|
678 | 852d481f | edgar_igl | |
679 | 852d481f | edgar_igl | /* if MMU is off, no check for TLB. */
|
680 | 852d481f | edgar_igl | if (env->mmucr & MMUCR_AT)
|
681 | 852d481f | edgar_igl | return 1; |
682 | 852d481f | edgar_igl | |
683 | 852d481f | edgar_igl | /* check TLB */
|
684 | 852d481f | edgar_igl | n = find_tlb_entry(env, addr, env->itlb, ITLB_SIZE, use_asid); |
685 | 852d481f | edgar_igl | if (n >= 0) |
686 | 852d481f | edgar_igl | return env->itlb[n].c;
|
687 | 852d481f | edgar_igl | |
688 | 852d481f | edgar_igl | n = find_tlb_entry(env, addr, env->utlb, UTLB_SIZE, use_asid); |
689 | 852d481f | edgar_igl | if (n >= 0) |
690 | 852d481f | edgar_igl | return env->utlb[n].c;
|
691 | 852d481f | edgar_igl | |
692 | 852d481f | edgar_igl | return 0; |
693 | 852d481f | edgar_igl | } |
694 | 852d481f | edgar_igl | |
695 | 355fb23d | pbrook | #endif |